]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
attributes fAllLVSensitive, fForceAllLVSensitive and their setters removed
[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.21  2001/06/27 16:06:59  hristov
19 Rotation matrix in BuildGeometry has been changed to rotx999
20
21 Revision 1.20.2.1  2001/06/27 10:51:15  alla
22 Rotation matrix in BuildGeometry has benn changed to rotx999
23
24 Revision 1.20  2001/05/16 14:57:21  alibrary
25 New files for folders and Stack
26
27 Revision 1.19  2001/04/04 12:10:18  alla
28 changes according Coding Convension
29
30 Revision 1.18  2001/03/12 17:46:43  hristov
31 Changes needed on Sun with CC 5.0
32
33 Revision 1.17  2001/01/26 19:59:53  hristov
34 Major upgrade of AliRoot code
35
36 Revision 1.16  2001/01/17 10:56:08  hristov
37 Corrections to destructors
38
39 Revision 1.15  2001/01/01 13:10:42  hristov
40 Local definition of digits removed
41
42 Revision 1.14  2000/12/22 16:17:15  hristov
43 Updated  START code from Alla
44
45 Revision 1.13  2000/12/18 11:39:41  alibrary
46 Quick fix to avoid crash in display waiting for new version
47
48 Revision 1.12  2000/12/04 08:48:19  alibrary
49 Fixing problems in the HEAD
50
51 Revision 1.11  2000/10/13 13:14:08  hristov
52 Bug fixes and code cleaning
53
54 Revision 1.10  2000/10/02 21:28:13  fca
55 Removal of useless dependecies via forward declarations
56
57 Revision 1.9  2000/07/13 16:41:29  fca
58 New START corrected for coding conventions
59
60 Revision 1.8  2000/03/27 17:24:25  alla
61 Modifing geometry
62
63 Revision 1.6  2000/01/21 15:45:23  fca
64 New Version from Alla
65
66 Revision 1.5  2000/01/19 17:17:15  fca
67 Introducing a list of lists of hits -- more hits allowed for detector now
68
69 Revision 1.4  1999/11/12 15:04:00  fca
70 Modifications from A.Maevskaya
71
72 Revision 1.3  1999/09/29 09:24:29  fca
73 Introduction of the Copyright and cvs Log
74
75 */
76
77 ///////////////////////////////////////////////////////////////////////////////
78 //                                                                           //
79 //  START (T-Zero) Detector                                            //
80 //  This class contains the base procedures for the START     //
81 //  detector                                                                 //
82 //                                                                           //
83 //Begin_Html
84 /*
85 <img src="gif/AliSTARTClass.gif">
86 </pre>
87 <br clear=left>
88 <font size=+2 color=red>
89 <p>The responsible person for this module is
90 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
91 </font>
92 <pre>
93 */
94 //End_Html
95 //                                                                           //
96 //                                                                           //
97 ///////////////////////////////////////////////////////////////////////////////
98
99 #include <iostream.h>
100 #include <fstream.h>
101
102 #include "TMath.h"
103 #include "TTUBE.h"
104 #include "TNode.h"
105 #include "TRandom.h"
106 #include "TGeometry.h"
107 #include "TFile.h"
108 #include "TParticle.h"
109
110 #include "AliRun.h"
111 #include "AliSTART.h"
112 #include "AliSTARTdigit.h"
113 #include "AliMC.h"
114 #include "AliSTARThit.h"
115 #include "AliSTARTvertex.h"
116
117 ClassImp(AliSTART)
118
119 static  AliSTARTdigit *digits; 
120
121 //_____________________________________________________________________________
122 AliSTART::AliSTART()
123 {
124   //
125   // Default constructor for class AliSTART
126   //
127   fIshunt   = 1;
128   fHits     = 0;
129   fDigits   = 0;
130 }
131  
132 //_____________________________________________________________________________
133 AliSTART::AliSTART(const char *name, const char *title)
134        : AliDetector(name,title)
135 {
136   //
137   // Standard constructor for START Detector
138   //
139
140   
141   //
142   // Initialise Hit array
143   fHits       = new TClonesArray("AliSTARThit",  405);
144   gAlice->AddHitList(fHits);
145   
146   fIshunt     =  1;
147   fIdSens   =  0;
148   SetMarkerColor(kRed);
149 }
150
151 //_____________________________________________________________________________
152 AliSTART::~AliSTART() {
153   if (fHits) {
154     fHits->Delete();
155     delete fHits;
156   }
157 }
158  
159 //_____________________________________________________________________________
160 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
161 {
162   //
163   // Add a START hit
164   //
165   TClonesArray &lhits = *fHits;
166   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
167 }
168
169 //_____________________________________________________________________________
170
171 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
172 {
173   
174   //  Add a START digit to the list. Dummy function.
175   
176 }
177
178 //_____________________________________________________________________________
179 void AliSTART::BuildGeometry()
180 {
181   //
182   // Build simple ROOT TNode geometry for event display
183   //
184   TNode *node, *top;
185   const int kColorSTART  = 19;
186
187   top=gAlice->GetGeometry()->GetNode("alice");
188
189   // START define the different volumes
190   new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
191
192   new TTUBE("S_0ST1","START  volume 1","void",5.,10.7,5.3);
193   top->cd();
194   node = new TNode("0ST1","0ST01","S_0ST1",0,0,75.,"");
195   node->SetLineColor(kColorSTART);
196   fNodes->Add(node);
197
198   new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
199   top->cd();
200   node = new TNode("0ST2","0ST2","S_0ST2",0,0,-75,"rotx999");
201   node->SetLineColor(kColorSTART);
202   fNodes->Add(node);
203 }
204  
205 //_____________________________________________________________________________
206 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
207 {
208   //
209   // Calculate the distance from the mouse to the START on the screen
210   // Dummy routine
211   //
212   return 9999;
213 }
214  
215 //-------------------------------------------------------------------------
216 void AliSTART::Init()
217 {
218   //
219   // Initialis the START after it has been built
220   Int_t i;
221   //
222   if(fDebug) {
223     printf("\n%s: ",ClassName());
224     for(i=0;i<35;i++) printf("*");
225     printf(" START_INIT ");
226     for(i=0;i<35;i++) printf("*");
227     printf("\n%s: ",ClassName());
228     //
229     // Here the START initialisation code (if any!)
230     for(i=0;i<80;i++) printf("*");
231     printf("\n");
232   }
233 }
234
235 //---------------------------------------------------------------------------
236 void AliSTART::MakeBranch(Option_t* option, const char *file)
237 {
238   //
239   // Specific START branches
240   //
241   // Create Tree branches for the START.
242   Int_t buffersize = 400;
243   char branchname[10];
244   sprintf(branchname,"%s",GetName());
245
246   AliDetector::MakeBranch(option,file);
247
248   const char *cD = strstr(option,"D");
249   
250   if (cD) {
251     digits = new AliSTARTdigit();
252     MakeBranchInTree(gAlice->TreeD(), 
253                      branchname, "AliSTARTdigit", digits, buffersize, 1, file);
254   } 
255 /*
256   char *cR = strstr(option,"R");
257   
258   if (cR)   {  
259     MakeBranchInTree(gAlice->TreeR(), 
260                      branchname, "Int_t", &fZposit, buffersize, 1, file);
261   }
262   */
263 }    
264
265 //_____________________________________________________________________________
266
267 void AliSTART::Hit2digit(Int_t evnum) 
268 {
269   //
270   // From hits to digits
271   //
272   Float_t x,y,e;
273   Int_t nbytes = 0;
274   Int_t hit;
275   Int_t nhits;
276   Int_t volume,pmt;
277   char nameTH[8],nameTD[8];
278   Float_t timediff,timeright,timeleft,timeav;
279   Float_t besttimeright,besttimeleft,meanTime;
280   Int_t channelWidth=10;
281
282   TParticle *particle;
283   AliSTARThit  *startHit;
284
285   Int_t buffersize=256;
286
287   digits= new AliSTARTdigit();
288   TBranch *bDig=0;
289
290   
291  // Event ------------------------- LOOP  
292  
293     sprintf(nameTD,"TreeD%d",evnum);
294     TTree *td = new TTree(nameTD,"START");
295     bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
296
297     besttimeright=9999.;
298     besttimeleft=9999.;
299     Int_t timeDiff=0;
300     Int_t timeAv=0;
301
302     Int_t nparticles = gAlice->GetEvent(evnum);
303     if (nparticles <= 0) return;
304     printf("\n nparticles %d\n",nparticles);
305     
306    
307     sprintf(nameTH,"TreeH%d",evnum);
308     printf("%s\n",nameTH);
309     TTree *th = gAlice->TreeH();
310     Int_t ntracks    = (Int_t) th->GetEntries();
311     if (ntracks<=0) return;
312     // Start loop on tracks in the hits containers
313     for (Int_t track=0; track<ntracks;track++) {
314       gAlice->ResetHits();
315       nbytes += th->GetEvent(track);
316       particle=gAlice->Particle(track);
317       nhits =fHits->GetEntriesFast();
318       
319       for (hit=0;hit<nhits;hit++) {
320         startHit   = (AliSTARThit*)fHits->UncheckedAt(hit);
321         pmt=startHit->fPmt;
322         e=startHit->fEtot;
323         x=startHit->X();
324         y=startHit->Y();
325         volume = startHit->fVolume;
326         if(volume==1){
327           timeright = startHit->fTime;
328           if(timeright<besttimeright) {
329             besttimeright=timeright;
330           } //timeright
331         }//time for right shoulder
332         if(volume==2){            
333           timeleft = startHit->fTime;
334           //                printf("timeleft %f\n",timeleft);
335           if(timeleft<besttimeleft) {
336             besttimeleft=timeleft;
337           } //timeleftbest
338         }//time for left shoulder
339       } //hit loop
340     } //track loop
341
342     //folding with experimental time distribution
343     Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
344     Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
345     timediff=besttimerightGaus-besttimeleftGaus;
346     meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
347     if ( TMath::Abs(timediff)<2. && meanTime<3.) 
348      {
349        //we assume centre of bunch is 5ns after TTS signal
350        //TOF values are relative of the end of bunch
351        Float_t ppBunch=25;
352     
353        ppBunch=ppBunch-10/2;
354        Float_t t1=1000.*besttimeleftGaus;
355        Float_t t2=1000.*besttimerightGaus;
356        t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
357        t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
358      
359        timeav=(t1+t2)/2.;
360      
361        // Time to TDC signal
362        // 256 channels for timediff, range 1ns
363        
364        timediff=128+1000*timediff/channelWidth; // time in ps 
365
366        timeAv = (Int_t)(timeav);   // time (ps) channel numbres
367        timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
368        digits->Set(timeAv,timeDiff);
369      }
370     else
371       {timeAv=999999; timeDiff=99999;}
372       
373     td->Fill();
374     printf("digits-> %d \n",digits->GetTime());
375     td->Write();
376
377 }
378
379
380
381
382
383
384
385
386
387
388
389
390  
391