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