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