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