]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
Removal of useless dependecies via forward declarations
[u/mrichter/AliRoot.git] / START / AliSTART.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.9  2000/07/13 16:41:29  fca
19 New START corrected for coding conventions
20
21 Revision 1.8  2000/03/27 17:24:25  alla
22 Modifing geometry
23
24 Revision 1.6  2000/01/21 15:45:23  fca
25 New Version from Alla
26
27 Revision 1.5  2000/01/19 17:17:15  fca
28 Introducing a list of lists of hits -- more hits allowed for detector now
29
30 Revision 1.4  1999/11/12 15:04:00  fca
31 Modifications from A.Maevskaya
32
33 Revision 1.3  1999/09/29 09:24:29  fca
34 Introduction of the Copyright and cvs Log
35
36 */
37
38 ///////////////////////////////////////////////////////////////////////////////
39 //                                                                           //
40 //  START (T-Zero) Detector                                            //
41 //  This class contains the base procedures for the START     //
42 //  detector                                                                 //
43 //                                                                           //
44 //Begin_Html
45 /*
46 <img src="gif/AliSTARTClass.gif">
47 </pre>
48 <br clear=left>
49 <font size=+2 color=red>
50 <p>The responsible person for this module is
51 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
52 </font>
53 <pre>
54 */
55 //End_Html
56 //                                                                           //
57 //                                                                           //
58 ///////////////////////////////////////////////////////////////////////////////
59
60 #include <iostream.h>
61 #include <fstream.h>
62
63 #include "TMath.h"
64 #include "TTUBE.h"
65 #include "TNode.h"
66 #include "TRandom.h"
67 #include "TGeometry.h"
68 #include "AliRun.h"
69 #include "AliSTART.h"
70 #include "AliSTARTdigit.h"
71 #include "AliMC.h"
72 #include "AliSTARThit.h"
73 #include "AliSTARTvertex.h"
74
75 ClassImp(AliSTART)
76
77 static  AliSTARTdigit *digits; 
78
79 //_____________________________________________________________________________
80 AliSTART::AliSTART()
81 {
82   //
83   // Default constructor for class AliSTART
84   //
85   fIshunt   = 0;
86   fHits     = 0;
87   fDigits   = 0;
88 }
89  
90 //_____________________________________________________________________________
91 AliSTART::AliSTART(const char *name, const char *title)
92        : AliDetector(name,title)
93 {
94   //
95   // Standard constructor for START Detector
96   //
97
98   
99   //
100   // Initialise Hit array
101   fHits       = new TClonesArray("AliSTARThit",  405);
102   //  gAlice->AddHitList(fHits);
103   //  fDigits     = new TClonesArray("AliSTARTdigit",500);
104   
105   fIshunt     =  0;
106   fIdSens   =  0;
107   SetMarkerColor(kRed);
108 }
109  
110 //_____________________________________________________________________________
111 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
112 {
113   //
114   // Add a START hit
115   //
116   TClonesArray &lhits = *fHits;
117   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
118 }
119
120 //_____________________________________________________________________________
121
122 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
123 {
124   
125   //  Add a START digit to the list
126   
127 //  printf (" AddDigit*******");
128     // TClonesArray &ldigits = *fDigits;
129     // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits);
130 }
131
132 //_____________________________________________________________________________
133 void AliSTART::BuildGeometry()
134 {
135   //
136   // Build simple ROOT TNode geometry for event display
137   //
138   TNode *node, *top;
139   const int kColorSTART  = 19;
140   //
141   top=gAlice->GetGeometry()->GetNode("alice");
142
143   // START define the different volumes
144   new TRotMatrix("rot999","rot999",  90,0,90,90,180,0);
145
146   new TTUBE("S_STR1","START  volume 1","void",5.,10.7,5.3);
147   top->cd();
148   node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
149   node->SetLineColor(kColorSTART);
150   fNodes->Add(node);
151
152   new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
153   top->cd();
154   node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
155   node->SetLineColor(kColorSTART);
156   fNodes->Add(node);
157 }
158  
159 //_____________________________________________________________________________
160 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
161 {
162   //
163   // Calculate the distance from the mouse to the START on the screen
164   // Dummy routine
165   //
166   return 9999;
167 }
168  
169 //-------------------------------------------------------------------------
170 void AliSTART::Init()
171 {
172   //
173   // Initialis the START after it has been built
174   Int_t i;
175   //
176   printf("\n");
177   for(i=0;i<35;i++) printf("*");
178   printf(" START_INIT ");
179   for(i=0;i<35;i++) printf("*");
180   printf("\n");
181   //
182   // Here the START initialisation code (if any!)
183   for(i=0;i<80;i++) printf("*");
184   printf("\n");
185   //
186   //
187   //  fIdSensRad=gMC->VolId("PTOP");
188   //  fIdSensPC =gMC->VolId("T0PC");
189
190 }
191
192 //---------------------------------------------------------------------------
193 void AliSTART::MakeBranch(Option_t* option)
194 {
195   //
196   // Specific START branches
197   //
198   AliSTARTdigit *digits; 
199   // Create Tree branches for the START.
200   Int_t buffersize = 400;
201   char branchname[10];
202   sprintf(branchname,"%s",GetName());
203
204   AliDetector::MakeBranch(option);
205
206   TTree *td = gAlice->TreeD();
207   digits = new AliSTARTdigit();
208   td->Branch(branchname,"AliSTARTdigit",&digits, buffersize);
209   printf("Making Branch %s for digits\n",branchname);
210     
211 /*
212   gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize);
213   printf("Making Branch %s for vertex position %d\n",branchname);
214   */
215 }    
216
217 //_____________________________________________________________________________
218
219 void AliSTART::Hit2digit(Int_t evnum) 
220 {
221   //
222   // From hits to digits
223   //
224   Float_t x,y,e;
225   Int_t nbytes = 0;
226   Int_t hit;
227   Int_t nhits;
228   Int_t volume,pmt;
229   char nameTH[8],nameTD[8];
230   Float_t timediff,timeright,timeleft,timeav;
231   Float_t besttimeright,besttimeleft,meanTime;
232   Int_t channelWidth=10;
233
234   TParticle *particle;
235   AliSTARThit  *startHit;
236
237   Int_t buffersize=256;
238   Int_t split=1;
239
240   digits= new AliSTARTdigit();
241   TBranch *bDig=0;
242
243   
244  // Event ------------------------- LOOP  
245  
246     sprintf(nameTD,"TreeD%d",evnum);
247     TTree *td = new TTree(nameTD,"START");
248     bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
249
250     besttimeright=9999.;
251     besttimeleft=9999.;
252     Int_t timeDiff=0;
253     Int_t timeAv=0;
254
255     Int_t nparticles = gAlice->GetEvent(evnum);
256     if (nparticles <= 0) return;
257     printf("\n nparticles %d\n",nparticles);
258     
259     TClonesArray *particles = gAlice->Particles();
260    
261     sprintf(nameTH,"TreeH%d",evnum);
262     printf("%s\n",nameTH);
263     TTree *th = gAlice->TreeH();
264     Int_t ntracks    = (Int_t) th->GetEntries();
265     if (ntracks<=0) return;
266     // Start loop on tracks in the hits containers
267     for (Int_t track=0; track<ntracks;track++) {
268       gAlice->ResetHits();
269       nbytes += th->GetEvent(track);
270       particle=(TParticle*)particles->UncheckedAt(track);
271       nhits =fHits->GetEntriesFast();
272       
273       for (hit=0;hit<nhits;hit++) {
274         startHit   = (AliSTARThit*)fHits->UncheckedAt(hit);
275         pmt=startHit->fPmt;
276         e=startHit->fEtot;
277         x=startHit->X();
278         y=startHit->Y();
279         volume = startHit->fVolume;
280         if(volume==1){
281           timeright = startHit->fTime;
282           if(timeright<besttimeright) {
283             besttimeright=timeright;
284           } //timeright
285         }//time for right shoulder
286         if(volume==2){            
287           timeleft = startHit->fTime;
288           //                printf("timeleft %f\n",timeleft);
289           if(timeleft<besttimeleft) {
290             besttimeleft=timeleft;
291           } //timeleftbest
292         }//time for left shoulder
293       } //hit loop
294     } //track loop
295
296     //folding with experimental time distribution
297     Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
298     Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
299     timediff=besttimerightGaus-besttimeleftGaus;
300     meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
301     if ( TMath::Abs(timediff)<2. && meanTime<3.) 
302      {
303        //we assume centre of bunch is 5ns after TTS signal
304        //TOF values are relative of the end of bunch
305        Float_t ppBunch=25;
306     
307        ppBunch=ppBunch-10/2;
308        Float_t t1=1000.*besttimeleftGaus;
309        Float_t t2=1000.*besttimerightGaus;
310        t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
311        t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
312      
313        timeav=(t1+t2)/2.;
314      
315        // Time to TDC signal
316        // 256 channels for timediff, range 1ns
317        
318        timediff=128+1000*timediff/channelWidth; // time in ps 
319
320        timeAv = (Int_t)(timeav);   // time (ps) channel numbres
321        timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
322        digits->Set(timeAv,timeDiff);
323      }
324        else
325          {timeAv=999999; timeDiff=99999;}
326        td->Fill();
327        digits->MyDump();
328        printf("digits-> %d \n",digits->GetTime());
329        td->Write();
330        //     } //timediff
331    
332
333 } // end macro
334
335
336
337
338
339
340
341
342
343
344
345
346  
347