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