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