]>
Commit | Line | Data |
---|---|---|
99d554c8 | 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 | ||
acd84897 | 16 | /* $Id$ */ |
99d554c8 | 17 | |
fe4da5cc | 18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Control class for Alice C++ // | |
21 | // Only one single instance of this class exists. // | |
22 | // The object is created in main program aliroot // | |
23 | // and is pointed by the global gAlice. // | |
24 | // // | |
8494b010 | 25 | // -Supports the list of all Alice Detectors (fModules). // |
fe4da5cc | 26 | // -Supports the list of particles (fParticles). // |
27 | // -Supports the Trees. // | |
28 | // -Supports the geometry. // | |
29 | // -Supports the event display. // | |
30 | //Begin_Html | |
31 | /* | |
1439f98e | 32 | <img src="picts/AliRunClass.gif"> |
fe4da5cc | 33 | */ |
34 | //End_Html | |
35 | //Begin_Html | |
36 | /* | |
1439f98e | 37 | <img src="picts/alirun.gif"> |
fe4da5cc | 38 | */ |
39 | //End_Html | |
40 | // // | |
41 | /////////////////////////////////////////////////////////////////////////////// | |
42 | ||
94de3818 | 43 | #include <stdio.h> |
98490ea9 | 44 | #include <stdlib.h> |
94de3818 | 45 | #include <string.h> |
46 | ||
98490ea9 | 47 | #include "Riostream.h" |
48 | #include "TBRIK.h" | |
49 | #include "TBrowser.h" | |
50 | #include "TCint.h" | |
51 | #include "TFile.h" | |
52 | #include "TFolder.h" | |
53 | #include "TGeometry.h" | |
98490ea9 | 54 | #include "TNode.h" |
1578254f | 55 | #include "TParticle.h" |
98490ea9 | 56 | #include "TRandom3.h" |
57 | #include "TROOT.h" | |
58 | #include "TSystem.h" | |
59 | #include "TTree.h" | |
60 | ||
61 | #include "AliConfig.h" | |
62 | #include "AliDetector.h" | |
fe4da5cc | 63 | #include "AliDisplay.h" |
98490ea9 | 64 | #include "AliGenerator.h" |
65 | #include "AliHeader.h" | |
dffd31ef | 66 | #include "AliLego.h" |
98490ea9 | 67 | #include "AliLegoGenerator.h" |
68 | #include "AliMCQA.h" | |
aee8290b | 69 | #include "AliMagFC.h" |
70 | #include "AliMagFCM.h" | |
71 | #include "AliMagFDM.h" | |
141f90e3 | 72 | #include "AliPDG.h" |
98490ea9 | 73 | #include "AliRun.h" |
74 | #include "AliStack.h" | |
fe4da5cc | 75 | |
fe4da5cc | 76 | AliRun *gAlice; |
77 | ||
fe4da5cc | 78 | ClassImp(AliRun) |
79 | ||
e2afb3b6 | 80 | //_______________________________________________________________________ |
81 | AliRun::AliRun(): | |
82 | fRun(0), | |
83 | fEvent(0), | |
84 | fEventNrInRun(0), | |
85 | fEventsPerRun(0), | |
86 | fDebug(0), | |
87 | fHeader(0), | |
88 | fTreeD(0), | |
89 | fTreeS(0), | |
90 | fTreeH(0), | |
91 | fTreeTR(0), | |
92 | fTreeE(0), | |
93 | fTreeR(0), | |
94 | fModules(0), | |
95 | fGeometry(0), | |
96 | fDisplay(0), | |
97 | fTimer(), | |
98 | fField(0), | |
99 | fMC(0), | |
100 | fImedia(0), | |
101 | fNdets(0), | |
102 | fTrRmax(1.e10), | |
103 | fTrZmax(1.e10), | |
104 | fGenerator(0), | |
105 | fInitDone(kFALSE), | |
106 | fLego(0), | |
107 | fPDGDB(0), //Particle factory object | |
108 | fHitLists(0), | |
109 | fEventEnergy(0), | |
110 | fSummEnergy(0), | |
111 | fSum2Energy(0), | |
112 | fConfigFunction("\0"), | |
113 | fRandom(0), | |
114 | fMCQA(0), | |
115 | fTransParName("\0"), | |
116 | fBaseFileName("\0"), | |
117 | fStack(0), | |
118 | fTreeDFileName(""), | |
119 | fTreeDFile(0), | |
120 | fTreeSFileName(""), | |
121 | fTreeSFile(0), | |
122 | fTreeRFileName(""), | |
123 | fTreeRFile(0) | |
fe4da5cc | 124 | { |
125 | // | |
126 | // Default constructor for AliRun | |
127 | // | |
e2afb3b6 | 128 | } |
129 | ||
130 | //_______________________________________________________________________ | |
131 | AliRun::AliRun(const AliRun& arun): | |
132 | TVirtualMCApplication(arun), | |
133 | fRun(0), | |
134 | fEvent(0), | |
135 | fEventNrInRun(0), | |
136 | fEventsPerRun(0), | |
137 | fDebug(0), | |
138 | fHeader(0), | |
139 | fTreeD(0), | |
140 | fTreeS(0), | |
141 | fTreeH(0), | |
142 | fTreeTR(0), | |
143 | fTreeE(0), | |
144 | fTreeR(0), | |
145 | fModules(0), | |
146 | fGeometry(0), | |
147 | fDisplay(0), | |
148 | fTimer(), | |
149 | fField(0), | |
150 | fMC(0), | |
151 | fImedia(0), | |
152 | fNdets(0), | |
153 | fTrRmax(1.e10), | |
154 | fTrZmax(1.e10), | |
155 | fGenerator(0), | |
156 | fInitDone(kFALSE), | |
157 | fLego(0), | |
158 | fPDGDB(0), //Particle factory object | |
159 | fHitLists(0), | |
160 | fEventEnergy(0), | |
161 | fSummEnergy(0), | |
162 | fSum2Energy(0), | |
163 | fConfigFunction("\0"), | |
164 | fRandom(0), | |
165 | fMCQA(0), | |
166 | fTransParName("\0"), | |
167 | fBaseFileName("\0"), | |
168 | fStack(0), | |
169 | fTreeDFileName(""), | |
170 | fTreeDFile(0), | |
171 | fTreeSFileName(""), | |
172 | fTreeSFile(0), | |
173 | fTreeRFileName(""), | |
174 | fTreeRFile(0) | |
175 | { | |
176 | // | |
177 | // Copy constructor for AliRun | |
178 | // | |
179 | arun.Copy(*this); | |
fe4da5cc | 180 | } |
181 | ||
182 | //_____________________________________________________________________________ | |
e2afb3b6 | 183 | AliRun::AliRun(const char *name, const char *title): |
184 | TVirtualMCApplication(name,title), | |
185 | fRun(0), | |
186 | fEvent(0), | |
187 | fEventNrInRun(0), | |
188 | fEventsPerRun(0), | |
189 | fDebug(0), | |
190 | fHeader(new AliHeader()), | |
191 | fTreeD(0), | |
192 | fTreeS(0), | |
193 | fTreeH(0), | |
194 | fTreeTR(0), | |
195 | fTreeE(0), | |
196 | fTreeR(0), | |
197 | fModules(new TObjArray(77)), // Support list for the Detectors | |
198 | fGeometry(0), | |
199 | fDisplay(0), | |
200 | fTimer(), | |
201 | fField(0), | |
202 | fMC(gMC), | |
203 | fImedia(new TArrayI(1000)), | |
204 | fNdets(0), | |
205 | fTrRmax(1.e10), | |
206 | fTrZmax(1.e10), | |
207 | fGenerator(0), | |
208 | fInitDone(kFALSE), | |
209 | fLego(0), | |
210 | fPDGDB(TDatabasePDG::Instance()), //Particle factory object! | |
211 | fHitLists(new TList()), // Create HitLists list | |
212 | fEventEnergy(0), | |
213 | fSummEnergy(0), | |
214 | fSum2Energy(0), | |
215 | fConfigFunction("Config();"), | |
216 | fRandom(new TRandom3()), | |
217 | fMCQA(0), | |
218 | fTransParName("\0"), | |
219 | fBaseFileName("\0"), | |
220 | fStack(new AliStack(10000)), //Particle stack | |
221 | fTreeDFileName(""), | |
222 | fTreeDFile(0), | |
223 | fTreeSFileName(""), | |
224 | fTreeSFile(0), | |
225 | fTreeRFileName(""), | |
226 | fTreeRFile(0) | |
fe4da5cc | 227 | { |
228 | // | |
229 | // Constructor for the main processor. | |
230 | // Creates the geometry | |
231 | // Creates the list of Detectors. | |
232 | // Creates the list of particles. | |
233 | // | |
e2afb3b6 | 234 | |
fe4da5cc | 235 | gAlice = this; |
65fb704d | 236 | |
237 | // Set random number generator | |
e2afb3b6 | 238 | gRandom = fRandom; |
2ab0c725 | 239 | |
240 | if (gSystem->Getenv("CONFIG_SEED")) { | |
e2afb3b6 | 241 | gRandom->SetSeed(static_cast<UInt_t>(atoi(gSystem->Getenv("CONFIG_SEED")))); |
2ab0c725 | 242 | } |
e2afb3b6 | 243 | |
244 | // Add to list of browsable | |
fe4da5cc | 245 | gROOT->GetListOfBrowsables()->Add(this,name); |
e2afb3b6 | 246 | |
fe4da5cc | 247 | // Create the TNode geometry for the event display |
fe4da5cc | 248 | BuildSimpleGeometry(); |
249 | ||
fe4da5cc | 250 | // Create default mag field |
251 | SetField(); | |
e2afb3b6 | 252 | |
fe4da5cc | 253 | // Prepare the tracking medium lists |
e2afb3b6 | 254 | for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99; |
9e1a0ddb | 255 | |
e2afb3b6 | 256 | // Add particle list to configuration |
9e1a0ddb | 257 | AliConfig::Instance()->Add(fPDGDB); |
e2afb3b6 | 258 | |
259 | // Set transport parameters | |
65fb704d | 260 | SetTransPar(); |
fe4da5cc | 261 | } |
262 | ||
aee8290b | 263 | |
e2afb3b6 | 264 | //_______________________________________________________________________ |
fe4da5cc | 265 | AliRun::~AliRun() |
266 | { | |
267 | // | |
2ab0c725 | 268 | // Default AliRun destructor |
fe4da5cc | 269 | // |
7a16e9cc | 270 | TFile *curfil =0; |
271 | if(fTreeE)curfil=fTreeE->GetCurrentFile(); | |
fe4da5cc | 272 | delete fImedia; |
273 | delete fField; | |
875c717b | 274 | delete fMC; |
fe4da5cc | 275 | delete fGeometry; |
276 | delete fDisplay; | |
277 | delete fGenerator; | |
278 | delete fLego; | |
279 | delete fTreeD; | |
fe4da5cc | 280 | delete fTreeH; |
aab9c8d5 | 281 | delete fTreeTR; |
fe4da5cc | 282 | delete fTreeE; |
283 | delete fTreeR; | |
2ab0c725 | 284 | delete fTreeS; |
8494b010 | 285 | if (fModules) { |
286 | fModules->Delete(); | |
287 | delete fModules; | |
fe4da5cc | 288 | } |
9e1a0ddb | 289 | delete fStack; |
1cedd08a | 290 | delete fHitLists; |
c222d2b0 | 291 | delete fPDGDB; |
e460afec | 292 | delete fMCQA; |
9e1a0ddb | 293 | delete fHeader; |
7a16e9cc | 294 | // avoid to delete TFile objects not owned by this object |
295 | // avoid multiple deletions | |
296 | if(curfil == fTreeDFile) fTreeDFile=0; | |
297 | if(curfil == fTreeSFile) fTreeSFile=0; | |
298 | if(curfil == fTreeRFile) fTreeRFile=0; | |
299 | if(fTreeSFile == fTreeDFile) fTreeSFile=0; | |
300 | if(fTreeRFile == fTreeDFile) fTreeRFile=0; | |
301 | if(fTreeRFile == fTreeSFile) fTreeRFile=0; | |
302 | if(fTreeDFile){ | |
303 | if(fTreeDFile->IsOpen())fTreeDFile->Close(); | |
304 | delete fTreeDFile; | |
305 | } | |
306 | if(fTreeSFile){ | |
307 | if(fTreeSFile->IsOpen())fTreeSFile->Close(); | |
308 | delete fTreeSFile; | |
309 | } | |
310 | if(fTreeRFile){ | |
311 | if(fTreeRFile->IsOpen())fTreeRFile->Close(); | |
312 | delete fTreeRFile; | |
313 | } | |
314 | if (gROOT->GetListOfBrowsables()) | |
315 | gROOT->GetListOfBrowsables()->Remove(this); | |
b9d0a01d | 316 | |
317 | gAlice=0; | |
fe4da5cc | 318 | } |
319 | ||
e2afb3b6 | 320 | //_______________________________________________________________________ |
321 | void AliRun::Copy(AliRun &) const | |
322 | { | |
37d06d5b | 323 | // |
324 | // Copy method ... not implemented | |
325 | // | |
e2afb3b6 | 326 | Fatal("Copy","Not implemented!\n"); |
327 | } | |
328 | ||
329 | //_______________________________________________________________________ | |
fe4da5cc | 330 | void AliRun::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const |
331 | { | |
332 | // | |
333 | // Add a hit to detector id | |
334 | // | |
8494b010 | 335 | TObjArray &dets = *fModules; |
e2afb3b6 | 336 | if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits); |
fe4da5cc | 337 | } |
338 | ||
e2afb3b6 | 339 | //_______________________________________________________________________ |
fe4da5cc | 340 | void AliRun::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const |
341 | { | |
342 | // | |
343 | // Add digit to detector id | |
344 | // | |
8494b010 | 345 | TObjArray &dets = *fModules; |
e2afb3b6 | 346 | if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits); |
fe4da5cc | 347 | } |
348 | ||
e2afb3b6 | 349 | //_______________________________________________________________________ |
fe4da5cc | 350 | void AliRun::Browse(TBrowser *b) |
351 | { | |
352 | // | |
353 | // Called when the item "Run" is clicked on the left pane | |
354 | // of the Root browser. | |
355 | // It displays the Root Trees and all detectors. | |
356 | // | |
9e1a0ddb | 357 | if(!fStack) fStack=fHeader->Stack(); |
358 | TTree* pTreeK = fStack->TreeK(); | |
359 | ||
360 | if (pTreeK) b->Add(pTreeK,pTreeK->GetName()); | |
fe4da5cc | 361 | if (fTreeH) b->Add(fTreeH,fTreeH->GetName()); |
aab9c8d5 | 362 | if (fTreeTR) b->Add(fTreeTR,fTreeH->GetName()); |
fe4da5cc | 363 | if (fTreeD) b->Add(fTreeD,fTreeD->GetName()); |
364 | if (fTreeE) b->Add(fTreeE,fTreeE->GetName()); | |
365 | if (fTreeR) b->Add(fTreeR,fTreeR->GetName()); | |
2ab0c725 | 366 | if (fTreeS) b->Add(fTreeS,fTreeS->GetName()); |
fe4da5cc | 367 | |
8494b010 | 368 | TIter next(fModules); |
369 | AliModule *detector; | |
e2afb3b6 | 370 | while((detector = dynamic_cast<AliModule*>(next()))) { |
fe4da5cc | 371 | b->Add(detector,detector->GetName()); |
372 | } | |
65fb704d | 373 | b->Add(fMCQA,"AliMCQA"); |
fe4da5cc | 374 | } |
375 | ||
e2afb3b6 | 376 | //_______________________________________________________________________ |
fe4da5cc | 377 | void AliRun::Build() |
378 | { | |
379 | // | |
380 | // Initialize Alice geometry | |
381 | // Dummy routine | |
382 | // | |
383 | } | |
384 | ||
e2afb3b6 | 385 | //_______________________________________________________________________ |
fe4da5cc | 386 | void AliRun::BuildSimpleGeometry() |
387 | { | |
388 | // | |
389 | // Create a simple TNode geometry used by Root display engine | |
390 | // | |
391 | // Initialise geometry | |
392 | // | |
393 | fGeometry = new TGeometry("AliceGeom","Galice Geometry for Hits"); | |
394 | new TMaterial("void","Vacuum",0,0,0); //Everything is void | |
395 | TBRIK *brik = new TBRIK("S_alice","alice volume","void",2000,2000,3000); | |
396 | brik->SetVisibility(0); | |
397 | new TNode("alice","alice","S_alice"); | |
398 | } | |
399 | ||
e2afb3b6 | 400 | //_______________________________________________________________________ |
fe4da5cc | 401 | void AliRun::CleanDetectors() |
402 | { | |
403 | // | |
404 | // Clean Detectors at the end of event | |
405 | // | |
8494b010 | 406 | TIter next(fModules); |
407 | AliModule *detector; | |
e2afb3b6 | 408 | while((detector = dynamic_cast<AliModule*>(next()))) { |
fe4da5cc | 409 | detector->FinishEvent(); |
410 | } | |
411 | } | |
412 | ||
e2afb3b6 | 413 | //_______________________________________________________________________ |
116cbefd | 414 | Int_t AliRun::DistancetoPrimitive(Int_t, Int_t) const |
fe4da5cc | 415 | { |
416 | // | |
417 | // Return the distance from the mouse to the AliRun object | |
418 | // Dummy routine | |
419 | // | |
420 | return 9999; | |
421 | } | |
422 | ||
e2afb3b6 | 423 | //_______________________________________________________________________ |
94de3818 | 424 | void AliRun::DumpPart (Int_t i) const |
fe4da5cc | 425 | { |
426 | // | |
427 | // Dumps particle i in the stack | |
428 | // | |
9e1a0ddb | 429 | fStack->DumpPart(i); |
fe4da5cc | 430 | } |
431 | ||
e2afb3b6 | 432 | //_______________________________________________________________________ |
94de3818 | 433 | void AliRun::DumpPStack () const |
fe4da5cc | 434 | { |
435 | // | |
436 | // Dumps the particle stack | |
437 | // | |
9e1a0ddb | 438 | fStack->DumpPStack(); |
fe4da5cc | 439 | } |
440 | ||
e2afb3b6 | 441 | //_______________________________________________________________________ |
d8408e76 | 442 | void AliRun::SetField(AliMagF* magField) |
443 | { | |
444 | // Set Magnetic Field Map | |
445 | fField = magField; | |
446 | fField->ReadField(); | |
447 | } | |
448 | ||
e2afb3b6 | 449 | //_______________________________________________________________________ |
fe4da5cc | 450 | void AliRun::SetField(Int_t type, Int_t version, Float_t scale, |
451 | Float_t maxField, char* filename) | |
452 | { | |
453 | // | |
454 | // Set magnetic field parameters | |
455 | // type Magnetic field transport flag 0=no field, 2=helix, 3=Runge Kutta | |
456 | // version Magnetic field map version (only 1 active now) | |
457 | // scale Scale factor for the magnetic field | |
458 | // maxField Maximum value for the magnetic field | |
459 | ||
460 | // | |
461 | // --- Sanity check on mag field flags | |
fe4da5cc | 462 | if(fField) delete fField; |
463 | if(version==1) { | |
d8408e76 | 464 | fField = new AliMagFC("Map1"," ",type,scale,maxField); |
f1b9d7c3 | 465 | } else if(version<=2) { |
d8408e76 | 466 | fField = new AliMagFCM("Map2-3",filename,type,scale,maxField); |
fe4da5cc | 467 | fField->ReadField(); |
f1b9d7c3 | 468 | } else if(version==3) { |
d8408e76 | 469 | fField = new AliMagFDM("Map4",filename,type,scale,maxField); |
f1b9d7c3 | 470 | fField->ReadField(); |
fe4da5cc | 471 | } else { |
23370b7a | 472 | Warning("SetField","Invalid map %d\n",version); |
fe4da5cc | 473 | } |
474 | } | |
fe4da5cc | 475 | |
e2afb3b6 | 476 | //_______________________________________________________________________ |
fe4da5cc | 477 | void AliRun::FinishRun() |
478 | { | |
479 | // | |
480 | // Called at the end of the run. | |
481 | // | |
482 | ||
dffd31ef | 483 | // |
484 | if(fLego) fLego->FinishRun(); | |
8e70f139 | 485 | |
fe4da5cc | 486 | // Clean detector information |
8494b010 | 487 | TIter next(fModules); |
488 | AliModule *detector; | |
e2afb3b6 | 489 | while((detector = dynamic_cast<AliModule*>(next()))) { |
fe4da5cc | 490 | detector->FinishRun(); |
491 | } | |
492 | ||
493 | //Output energy summary tables | |
494 | EnergySummary(); | |
2ab0c725 | 495 | |
496 | TFile *file = fTreeE->GetCurrentFile(); | |
497 | ||
aee8290b | 498 | file->cd(); |
2ab0c725 | 499 | |
51e0e89d | 500 | fTreeE->Write(0,TObject::kOverwrite); |
fe4da5cc | 501 | |
2ab0c725 | 502 | // Write AliRun info and all detectors parameters |
d47c658f | 503 | Write(0,TObject::kOverwrite); |
682a4a95 | 504 | |
fe4da5cc | 505 | // Clean tree information |
9e1a0ddb | 506 | |
507 | fStack->FinishRun(); | |
508 | ||
d2ecd553 | 509 | if (fTreeH) { |
510 | delete fTreeH; fTreeH = 0; | |
511 | } | |
aab9c8d5 | 512 | if (fTreeTR) { |
513 | delete fTreeTR; fTreeTR = 0; | |
514 | } | |
d2ecd553 | 515 | if (fTreeD) { |
516 | delete fTreeD; fTreeD = 0; | |
517 | } | |
518 | if (fTreeR) { | |
519 | delete fTreeR; fTreeR = 0; | |
520 | } | |
7e90ff59 | 521 | // if (fTreeE) { |
522 | // delete fTreeE; fTreeE = 0; | |
523 | // } | |
9e1a0ddb | 524 | if (fTreeS) { |
525 | delete fTreeS; fTreeS = 0; | |
526 | } | |
6df200c3 | 527 | fGenerator->FinishRun(); |
528 | ||
fe4da5cc | 529 | // Close output file |
aee8290b | 530 | file->Write(); |
fe4da5cc | 531 | } |
532 | ||
e2afb3b6 | 533 | //_______________________________________________________________________ |
fe4da5cc | 534 | void AliRun::FlagTrack(Int_t track) |
535 | { | |
9e1a0ddb | 536 | // Delegate to stack |
fe4da5cc | 537 | // |
9e1a0ddb | 538 | fStack->FlagTrack(track); |
fe4da5cc | 539 | } |
540 | ||
e2afb3b6 | 541 | //_______________________________________________________________________ |
fe4da5cc | 542 | void AliRun::EnergySummary() |
543 | { | |
544 | // | |
545 | // Print summary of deposited energy | |
546 | // | |
547 | ||
fe4da5cc | 548 | Int_t ndep=0; |
549 | Float_t edtot=0; | |
550 | Float_t ed, ed2; | |
551 | Int_t kn, i, left, j, id; | |
aee8290b | 552 | const Float_t kzero=0; |
9e1a0ddb | 553 | Int_t ievent=fHeader->GetEvent()+1; |
fe4da5cc | 554 | // |
555 | // Energy loss information | |
556 | if(ievent) { | |
557 | printf("***************** Energy Loss Information per event (GEV) *****************\n"); | |
875c717b | 558 | for(kn=1;kn<fEventEnergy.GetSize();kn++) { |
559 | ed=fSummEnergy[kn]; | |
fe4da5cc | 560 | if(ed>0) { |
875c717b | 561 | fEventEnergy[ndep]=kn; |
fe4da5cc | 562 | if(ievent>1) { |
563 | ed=ed/ievent; | |
875c717b | 564 | ed2=fSum2Energy[kn]; |
fe4da5cc | 565 | ed2=ed2/ievent; |
aee8290b | 566 | ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed; |
fe4da5cc | 567 | } else |
568 | ed2=99; | |
875c717b | 569 | fSummEnergy[ndep]=ed; |
e2afb3b6 | 570 | fSum2Energy[ndep]=TMath::Min(static_cast<Float_t>(99.),TMath::Max(ed2,kzero)); |
fe4da5cc | 571 | edtot+=ed; |
572 | ndep++; | |
573 | } | |
574 | } | |
575 | for(kn=0;kn<(ndep-1)/3+1;kn++) { | |
576 | left=ndep-kn*3; | |
577 | for(i=0;i<(3<left?3:left);i++) { | |
578 | j=kn*3+i; | |
875c717b | 579 | id=Int_t (fEventEnergy[j]+0.1); |
580 | printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]); | |
fe4da5cc | 581 | } |
582 | printf("\n"); | |
583 | } | |
584 | // | |
585 | // Relative energy loss in different detectors | |
586 | printf("******************** Relative Energy Loss per event ********************\n"); | |
587 | printf("Total energy loss per event %10.3f GeV\n",edtot); | |
588 | for(kn=0;kn<(ndep-1)/5+1;kn++) { | |
589 | left=ndep-kn*5; | |
590 | for(i=0;i<(5<left?5:left);i++) { | |
591 | j=kn*5+i; | |
875c717b | 592 | id=Int_t (fEventEnergy[j]+0.1); |
593 | printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot); | |
fe4da5cc | 594 | } |
595 | printf("\n"); | |
596 | } | |
597 | for(kn=0;kn<75;kn++) printf("*"); | |
598 | printf("\n"); | |
599 | } | |
600 | // | |
601 | // Reset the TArray's | |
875c717b | 602 | // fEventEnergy.Set(0); |
603 | // fSummEnergy.Set(0); | |
604 | // fSum2Energy.Set(0); | |
fe4da5cc | 605 | } |
606 | ||
eb1b8d29 | 607 | //_______________________________________________________________________ |
608 | void AliRun::Announce() const | |
609 | { | |
610 | // | |
37d06d5b | 611 | // Announce the current version of AliRoot |
612 | // | |
613 | printf("%70s", | |
614 | "****************************************************************\n"); | |
615 | printf("%6s","*");printf("%64s","*\n"); | |
616 | ||
617 | printf("%6s","*"); | |
7683c695 | 618 | printf(" You are running AliRoot version v3-09-06\n"); |
37d06d5b | 619 | |
620 | printf("%6s","*"); | |
621 | printf(" The cvs tag for the current program is $Name$\n"); | |
622 | ||
623 | printf("%6s","*");printf("%64s","*\n"); | |
624 | printf("%70s", | |
625 | "****************************************************************\n"); | |
eb1b8d29 | 626 | } |
627 | ||
e2afb3b6 | 628 | //_______________________________________________________________________ |
94de3818 | 629 | AliModule *AliRun::GetModule(const char *name) const |
fe4da5cc | 630 | { |
631 | // | |
632 | // Return pointer to detector from name | |
633 | // | |
e2afb3b6 | 634 | return dynamic_cast<AliModule*>(fModules->FindObject(name)); |
fe4da5cc | 635 | } |
636 | ||
e2afb3b6 | 637 | //_______________________________________________________________________ |
94de3818 | 638 | AliDetector *AliRun::GetDetector(const char *name) const |
a68348e9 | 639 | { |
640 | // | |
641 | // Return pointer to detector from name | |
642 | // | |
e2afb3b6 | 643 | return dynamic_cast<AliDetector*>(fModules->FindObject(name)); |
a68348e9 | 644 | } |
645 | ||
e2afb3b6 | 646 | //_______________________________________________________________________ |
94de3818 | 647 | Int_t AliRun::GetModuleID(const char *name) const |
fe4da5cc | 648 | { |
649 | // | |
650 | // Return galice internal detector identifier from name | |
651 | // | |
23370b7a | 652 | Int_t i=-1; |
653 | TObject *mod=fModules->FindObject(name); | |
654 | if(mod) i=fModules->IndexOf(mod); | |
655 | return i; | |
fe4da5cc | 656 | } |
657 | ||
e2afb3b6 | 658 | //_______________________________________________________________________ |
fe4da5cc | 659 | Int_t AliRun::GetEvent(Int_t event) |
660 | { | |
661 | // | |
662 | // Connect the Trees Kinematics and Hits for event # event | |
663 | // Set branch addresses | |
664 | // | |
fe4da5cc | 665 | |
666 | // Reset existing structures | |
fe4da5cc | 667 | ResetHits(); |
aab9c8d5 | 668 | ResetTrackReferences(); |
fe4da5cc | 669 | ResetDigits(); |
2ab0c725 | 670 | ResetSDigits(); |
fe4da5cc | 671 | |
672 | // Delete Trees already connected | |
ccf7a81f | 673 | if (fTreeH) { delete fTreeH; fTreeH = 0;} |
aab9c8d5 | 674 | if (fTreeTR) { delete fTreeTR; fTreeTR = 0;} |
ccf7a81f | 675 | if (fTreeD) { delete fTreeD; fTreeD = 0;} |
676 | if (fTreeR) { delete fTreeR; fTreeR = 0;} | |
677 | if (fTreeS) { delete fTreeS; fTreeS = 0;} | |
59fe9bd2 | 678 | |
9e1a0ddb | 679 | // Create the particle stack |
680 | if (fHeader) delete fHeader; | |
681 | fHeader = 0; | |
682 | ||
59fe9bd2 | 683 | // Get header from file |
9e1a0ddb | 684 | if(fTreeE) { |
685 | fTreeE->SetBranchAddress("Header", &fHeader); | |
ccf7a81f | 686 | |
687 | if (!fTreeE->GetEntry(event)) { | |
688 | Error("GetEvent","Cannot find event:%d\n",event); | |
689 | return -1; | |
690 | } | |
9e1a0ddb | 691 | } |
ccf7a81f | 692 | else { |
9e1a0ddb | 693 | Error("GetEvent","Cannot find Header Tree (TE)\n"); |
ccf7a81f | 694 | return -1; |
695 | } | |
9e1a0ddb | 696 | |
ccf7a81f | 697 | // Get the stack from the header, set fStack to 0 if it |
698 | // fails to get event | |
9e1a0ddb | 699 | // |
2ab0c725 | 700 | TFile *file = fTreeE->GetCurrentFile(); |
fe4da5cc | 701 | char treeName[20]; |
6df200c3 | 702 | |
2ab0c725 | 703 | file->cd(); |
704 | ||
50a6540a | 705 | if (fStack) delete fStack; |
706 | fStack = fHeader->Stack(); | |
707 | if (fStack) { | |
708 | if (!fStack->GetEvent(event)) fStack = 0; | |
709 | } | |
710 | ||
fe4da5cc | 711 | // Get Hits Tree header from file |
712 | sprintf(treeName,"TreeH%d",event); | |
e2afb3b6 | 713 | fTreeH = dynamic_cast<TTree*>(gDirectory->Get(treeName)); |
2057d00a | 714 | if (!fTreeH) { |
b9d0a01d | 715 | Warning("GetEvent","cannot find Hits Tree for event:%d\n",event); |
2057d00a | 716 | } |
717 | ||
aab9c8d5 | 718 | // Get TracReferences Tree header from file |
719 | sprintf(treeName,"TreeTR%d",event); | |
e2afb3b6 | 720 | fTreeTR = dynamic_cast<TTree*>(gDirectory->Get(treeName)); |
aab9c8d5 | 721 | if (!fTreeTR) { |
3d8c4988 | 722 | Warning("GetEvent","cannot find TrackReferences Tree for event:%d\n",event); |
aab9c8d5 | 723 | } |
724 | ||
7a16e9cc | 725 | // get current file name and compare with names containing trees S,D,R |
e2afb3b6 | 726 | TString curfilname=static_cast<TString>(fTreeE->GetCurrentFile()->GetName()); |
7a16e9cc | 727 | if(fTreeDFileName==curfilname)fTreeDFileName=""; |
728 | if(fTreeSFileName==curfilname)fTreeSFileName=""; | |
729 | if(fTreeRFileName==curfilname)fTreeRFileName=""; | |
b9d0a01d | 730 | |
fe4da5cc | 731 | // Get Digits Tree header from file |
732 | sprintf(treeName,"TreeD%d",event); | |
b9d0a01d | 733 | |
7a16e9cc | 734 | if (!fTreeDFile && fTreeDFileName != "") { |
735 | InitTreeFile("D",fTreeDFileName); | |
736 | } | |
737 | if (fTreeDFile) { | |
e2afb3b6 | 738 | fTreeD = dynamic_cast<TTree*>(fTreeDFile->Get(treeName)); |
7a16e9cc | 739 | } else { |
e2afb3b6 | 740 | fTreeD = dynamic_cast<TTree*>(file->Get(treeName)); |
7a16e9cc | 741 | } |
fe4da5cc | 742 | if (!fTreeD) { |
2ab0c725 | 743 | // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event); |
fe4da5cc | 744 | } |
7a16e9cc | 745 | if(fTreeDFileName != ""){ |
746 | if(fTreeDFileName==fTreeSFileName) { | |
747 | fTreeSFileName = ""; | |
748 | fTreeSFile = fTreeDFile; | |
749 | } | |
750 | if(fTreeDFileName==fTreeRFileName) { | |
751 | fTreeRFileName = ""; | |
752 | fTreeRFile = fTreeDFile; | |
753 | } | |
754 | } | |
82711e7a | 755 | |
756 | file->cd(); | |
757 | ||
758 | // Get SDigits Tree header from file | |
759 | sprintf(treeName,"TreeS%d",event); | |
7a16e9cc | 760 | if (!fTreeSFile && fTreeSFileName != "") { |
761 | InitTreeFile("S",fTreeSFileName); | |
762 | } | |
763 | if (fTreeSFile) { | |
e2afb3b6 | 764 | fTreeS = dynamic_cast<TTree*>(fTreeSFile->Get(treeName)); |
7a16e9cc | 765 | } else { |
e2afb3b6 | 766 | fTreeS = dynamic_cast<TTree*>(gDirectory->Get(treeName)); |
7a16e9cc | 767 | } |
82711e7a | 768 | if (!fTreeS) { |
769 | // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event); | |
770 | } | |
771 | ||
7a16e9cc | 772 | if(fTreeSFileName != ""){ |
773 | if(fTreeSFileName==fTreeRFileName){ | |
774 | fTreeRFileName = ""; | |
775 | fTreeRFile = fTreeSFile; | |
776 | } | |
777 | } | |
778 | ||
2ab0c725 | 779 | file->cd(); |
fe4da5cc | 780 | |
781 | // Get Reconstruct Tree header from file | |
782 | sprintf(treeName,"TreeR%d",event); | |
7a16e9cc | 783 | if (!fTreeRFile && fTreeRFileName != "") { |
784 | InitTreeFile("R",fTreeRFileName); | |
785 | } | |
786 | if(fTreeRFile) { | |
e2afb3b6 | 787 | fTreeR = dynamic_cast<TTree*>(fTreeRFile->Get(treeName)); |
7a16e9cc | 788 | } else { |
e2afb3b6 | 789 | fTreeR = dynamic_cast<TTree*>(gDirectory->Get(treeName)); |
7a16e9cc | 790 | } |
fe4da5cc | 791 | if (!fTreeR) { |
792 | // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event); | |
793 | } | |
2ab0c725 | 794 | |
795 | file->cd(); | |
fe4da5cc | 796 | |
797 | // Set Trees branch addresses | |
8494b010 | 798 | TIter next(fModules); |
799 | AliModule *detector; | |
e2afb3b6 | 800 | while((detector = dynamic_cast<AliModule*>(next()))) { |
fe4da5cc | 801 | detector->SetTreeAddress(); |
802 | } | |
9e1a0ddb | 803 | |
fa85c972 | 804 | fEvent=event; //MI change |
805 | ||
eef4b160 | 806 | return fHeader->GetNtrack(); |
fe4da5cc | 807 | } |
808 | ||
e2afb3b6 | 809 | //_______________________________________________________________________ |
fe4da5cc | 810 | TGeometry *AliRun::GetGeometry() |
811 | { | |
812 | // | |
813 | // Import Alice geometry from current file | |
814 | // Return pointer to geometry object | |
815 | // | |
e2afb3b6 | 816 | if (!fGeometry) fGeometry = dynamic_cast<TGeometry*>(gDirectory->Get("AliceGeom")); |
fe4da5cc | 817 | // |
818 | // Unlink and relink nodes in detectors | |
819 | // This is bad and there must be a better way... | |
820 | // | |
fe4da5cc | 821 | |
8494b010 | 822 | TIter next(fModules); |
823 | AliModule *detector; | |
e2afb3b6 | 824 | while((detector = dynamic_cast<AliModule*>(next()))) { |
fe4da5cc | 825 | TList *dnodes=detector->Nodes(); |
826 | Int_t j; | |
827 | TNode *node, *node1; | |
828 | for ( j=0; j<dnodes->GetSize(); j++) { | |
e2afb3b6 | 829 | node = dynamic_cast<TNode*>(dnodes->At(j)); |
52d0ab00 | 830 | node1 = fGeometry->GetNode(node->GetName()); |
fe4da5cc | 831 | dnodes->Remove(node); |
832 | dnodes->AddAt(node1,j); | |
833 | } | |
834 | } | |
835 | return fGeometry; | |
836 | } | |
837 | ||
e2afb3b6 | 838 | //_______________________________________________________________________ |
9e1a0ddb | 839 | Int_t AliRun::GetPrimary(Int_t track) const |
fe4da5cc | 840 | { |
841 | // | |
842 | // return number of primary that has generated track | |
843 | // | |
9e1a0ddb | 844 | return fStack->GetPrimary(track); |
fe4da5cc | 845 | } |
846 | ||
e2afb3b6 | 847 | //_______________________________________________________________________ |
fe4da5cc | 848 | void AliRun::MediaTable() |
849 | { | |
850 | // | |
851 | // Built media table to get from the media number to | |
852 | // the detector id | |
853 | // | |
ad51aeb0 | 854 | Int_t kz, nz, idt, lz, i, k, ind; |
855 | // Int_t ibeg; | |
fe4da5cc | 856 | TObjArray &dets = *gAlice->Detectors(); |
8494b010 | 857 | AliModule *det; |
fe4da5cc | 858 | // |
859 | // For all detectors | |
860 | for (kz=0;kz<fNdets;kz++) { | |
861 | // If detector is defined | |
e2afb3b6 | 862 | if((det=dynamic_cast<AliModule*>(dets[kz]))) { |
ad51aeb0 | 863 | TArrayI &idtmed = *(det->GetIdtmed()); |
864 | for(nz=0;nz<100;nz++) { | |
fe4da5cc | 865 | // Find max and min material number |
ad51aeb0 | 866 | if((idt=idtmed[nz])) { |
fe4da5cc | 867 | det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt; |
868 | det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt; | |
869 | } | |
870 | } | |
871 | if(det->LoMedium() > det->HiMedium()) { | |
872 | det->LoMedium() = 0; | |
873 | det->HiMedium() = 0; | |
874 | } else { | |
875 | if(det->HiMedium() > fImedia->GetSize()) { | |
ad51aeb0 | 876 | Error("MediaTable","Increase fImedia from %d to %d", |
877 | fImedia->GetSize(),det->HiMedium()); | |
fe4da5cc | 878 | return; |
879 | } | |
880 | // Tag all materials in rage as belonging to detector kz | |
881 | for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) { | |
882 | (*fImedia)[lz]=kz; | |
883 | } | |
884 | } | |
885 | } | |
886 | } | |
887 | // | |
888 | // Print summary table | |
889 | printf(" Traking media ranges:\n"); | |
890 | for(i=0;i<(fNdets-1)/6+1;i++) { | |
891 | for(k=0;k< (6<fNdets-i*6?6:fNdets-i*6);k++) { | |
892 | ind=i*6+k; | |
e2afb3b6 | 893 | det=dynamic_cast<AliModule*>(dets[ind]); |
fe4da5cc | 894 | if(det) |
895 | printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(), | |
896 | det->HiMedium()); | |
897 | else | |
898 | printf(" %6s: %3d -> %3d;","NULL",0,0); | |
899 | } | |
900 | printf("\n"); | |
901 | } | |
902 | } | |
903 | ||
e2afb3b6 | 904 | //_______________________________________________________________________ |
fe4da5cc | 905 | void AliRun::SetGenerator(AliGenerator *generator) |
ee1dd322 | 906 | { |
907 | // | |
908 | // Load the event generator | |
909 | // | |
910 | if(!fGenerator) fGenerator = generator; | |
911 | } | |
912 | ||
e2afb3b6 | 913 | //_______________________________________________________________________ |
ee1dd322 | 914 | void AliRun::ResetGenerator(AliGenerator *generator) |
fe4da5cc | 915 | { |
916 | // | |
917 | // Load the event generator | |
918 | // | |
b13db077 | 919 | if(fGenerator) |
838edcaf | 920 | if(generator) |
921 | Warning("ResetGenerator","Replacing generator %s with %s\n", | |
922 | fGenerator->GetName(),generator->GetName()); | |
923 | else | |
924 | Warning("ResetGenerator","Replacing generator %s with NULL\n", | |
925 | fGenerator->GetName()); | |
b13db077 | 926 | fGenerator = generator; |
fe4da5cc | 927 | } |
928 | ||
e2afb3b6 | 929 | //_______________________________________________________________________ |
930 | void AliRun::SetTransPar(const char *filename) | |
65fb704d | 931 | { |
37d06d5b | 932 | // |
933 | // Sets the file name for transport parameters | |
934 | // | |
65fb704d | 935 | fTransParName = filename; |
936 | } | |
937 | ||
e2afb3b6 | 938 | //_______________________________________________________________________ |
939 | void AliRun::SetBaseFile(const char *filename) | |
2ab0c725 | 940 | { |
39de14fb | 941 | fBaseFileName = filename; |
2ab0c725 | 942 | } |
943 | ||
e2afb3b6 | 944 | //_______________________________________________________________________ |
65fb704d | 945 | void AliRun::ReadTransPar() |
fe4da5cc | 946 | { |
947 | // | |
948 | // Read filename to set the transport parameters | |
949 | // | |
950 | ||
fe4da5cc | 951 | |
aee8290b | 952 | const Int_t kncuts=10; |
953 | const Int_t knflags=11; | |
954 | const Int_t knpars=kncuts+knflags; | |
955 | const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO", | |
fe4da5cc | 956 | "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI", |
957 | "BREM","COMP","DCAY","DRAY","HADR","LOSS", | |
958 | "MULS","PAIR","PHOT","RAYL"}; | |
959 | char line[256]; | |
ad51aeb0 | 960 | char detName[7]; |
fe4da5cc | 961 | char* filtmp; |
aee8290b | 962 | Float_t cut[kncuts]; |
963 | Int_t flag[knflags]; | |
fe4da5cc | 964 | Int_t i, itmed, iret, ktmed, kz; |
965 | FILE *lun; | |
966 | // | |
967 | // See whether the file is there | |
65fb704d | 968 | filtmp=gSystem->ExpandPathName(fTransParName.Data()); |
fe4da5cc | 969 | lun=fopen(filtmp,"r"); |
970 | delete [] filtmp; | |
971 | if(!lun) { | |
65fb704d | 972 | Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data()); |
fe4da5cc | 973 | return; |
974 | } | |
975 | // | |
9e1a0ddb | 976 | if(fDebug) { |
977 | printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n"); | |
978 | printf(" *%59s\n","*"); | |
979 | printf(" * Please check carefully what you are doing!%10s\n","*"); | |
980 | printf(" *%59s\n","*"); | |
981 | } | |
fe4da5cc | 982 | // |
983 | while(1) { | |
984 | // Initialise cuts and flags | |
aee8290b | 985 | for(i=0;i<kncuts;i++) cut[i]=-99; |
986 | for(i=0;i<knflags;i++) flag[i]=-99; | |
fe4da5cc | 987 | itmed=0; |
988 | for(i=0;i<256;i++) line[i]='\0'; | |
989 | // Read up to the end of line excluded | |
990 | iret=fscanf(lun,"%[^\n]",line); | |
991 | if(iret<0) { | |
992 | //End of file | |
993 | fclose(lun); | |
9e1a0ddb | 994 | if(fDebug){ |
995 | printf(" *%59s\n","*"); | |
996 | printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n"); | |
997 | } | |
fe4da5cc | 998 | return; |
999 | } | |
1000 | // Read the end of line | |
1001 | fscanf(lun,"%*c"); | |
1002 | if(!iret) continue; | |
1003 | if(line[0]=='*') continue; | |
1004 | // Read the numbers | |
ad51aeb0 | 1005 | iret=sscanf(line,"%s %d %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d %d %d %d %d %d %d", |
1006 | detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8], | |
1007 | &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7], | |
1008 | &flag[8],&flag[9],&flag[10]); | |
fe4da5cc | 1009 | if(!iret) continue; |
1010 | if(iret<0) { | |
1011 | //reading error | |
65fb704d | 1012 | Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data()); |
fe4da5cc | 1013 | continue; |
1014 | } | |
ad51aeb0 | 1015 | // Check that the module exist |
1016 | AliModule *mod = GetModule(detName); | |
1017 | if(mod) { | |
1018 | // Get the array of media numbers | |
1019 | TArrayI &idtmed = *mod->GetIdtmed(); | |
1020 | // Check that the tracking medium code is valid | |
1021 | if(0<=itmed && itmed < 100) { | |
1022 | ktmed=idtmed[itmed]; | |
1023 | if(!ktmed) { | |
65fb704d | 1024 | Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName()); |
ad51aeb0 | 1025 | continue; |
fe4da5cc | 1026 | } |
ad51aeb0 | 1027 | // Set energy thresholds |
aee8290b | 1028 | for(kz=0;kz<kncuts;kz++) { |
ad51aeb0 | 1029 | if(cut[kz]>=0) { |
9e1a0ddb | 1030 | if(fDebug) printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n", |
aee8290b | 1031 | kpars[kz],cut[kz],itmed,mod->GetName()); |
1032 | gMC->Gstpar(ktmed,kpars[kz],cut[kz]); | |
ad51aeb0 | 1033 | } |
fe4da5cc | 1034 | } |
ad51aeb0 | 1035 | // Set transport mechanisms |
aee8290b | 1036 | for(kz=0;kz<knflags;kz++) { |
ad51aeb0 | 1037 | if(flag[kz]>=0) { |
9e1a0ddb | 1038 | if(fDebug) printf(" * %-6s set to %10d for tracking medium code %4d for %s\n", |
aee8290b | 1039 | kpars[kncuts+kz],flag[kz],itmed,mod->GetName()); |
1040 | gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz])); | |
ad51aeb0 | 1041 | } |
1042 | } | |
1043 | } else { | |
65fb704d | 1044 | Warning("ReadTransPar","Invalid medium code %d *\n",itmed); |
ad51aeb0 | 1045 | continue; |
fe4da5cc | 1046 | } |
1047 | } else { | |
9e1a0ddb | 1048 | if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName); |
fe4da5cc | 1049 | continue; |
1050 | } | |
1051 | } | |
1052 | } | |
1053 | ||
2ab0c725 | 1054 | |
e2afb3b6 | 1055 | //_______________________________________________________________________ |
9e1a0ddb | 1056 | void AliRun::MakeTree(Option_t *option, const char *file) |
fe4da5cc | 1057 | { |
1058 | // | |
1059 | // Create the ROOT trees | |
1060 | // Loop on all detectors to create the Root branch (if any) | |
1061 | // | |
1062 | ||
b13db077 | 1063 | char hname[30]; |
fe4da5cc | 1064 | // |
1065 | // Analyse options | |
5cf7bbad | 1066 | const char *oK = strstr(option,"K"); |
1067 | const char *oH = strstr(option,"H"); | |
aab9c8d5 | 1068 | const char *oTR = strstr(option,"T"); |
5cf7bbad | 1069 | const char *oE = strstr(option,"E"); |
1070 | const char *oD = strstr(option,"D"); | |
1071 | const char *oR = strstr(option,"R"); | |
1072 | const char *oS = strstr(option,"S"); | |
fe4da5cc | 1073 | // |
9e1a0ddb | 1074 | |
1075 | TDirectory *cwd = gDirectory; | |
1076 | ||
1077 | TBranch *branch = 0; | |
2ab0c725 | 1078 | |
9e1a0ddb | 1079 | if (oK) fStack->MakeTree(fEvent, file); |
1080 | ||
1081 | if (oE && !fTreeE) { | |
1082 | fTreeE = new TTree("TE","Header"); | |
62016442 | 1083 | // branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0); |
21e74529 | 1084 | branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0); |
9e1a0ddb | 1085 | branch->SetAutoDelete(kFALSE); |
e2afb3b6 | 1086 | TFolder *folder = dynamic_cast<TFolder *>(gROOT->FindObjectAny("/Folders/RunMC/Event/Header")); |
9e1a0ddb | 1087 | if (folder) folder->Add(fHeader); |
1088 | // branch = fTreeE->Branch("Stack","AliStack", &fStack, 4000, 0); | |
1089 | // branch->SetAutoDelete(kFALSE); | |
1090 | // if (folder) folder->Add(fStack); | |
1091 | fTreeE->Write(0,TObject::kOverwrite); | |
b13db077 | 1092 | } |
9e1a0ddb | 1093 | |
1094 | if (file && branch) { | |
1095 | char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2]; | |
1096 | sprintf(outFile,"%s/%s",GetBaseFile(),file); | |
1097 | branch->SetFile(outFile); | |
1098 | TIter next( branch->GetListOfBranches()); | |
e2afb3b6 | 1099 | while ((branch=dynamic_cast<TBranch*>(next()))) { |
9e1a0ddb | 1100 | branch->SetFile(outFile); |
1101 | } | |
1102 | if (GetDebug()>1) | |
1103 | printf("* MakeBranch * Diverting Branch %s to file %s\n", branch->GetName(),file); | |
1104 | cwd->cd(); | |
1105 | delete outFile; | |
1106 | } | |
1107 | ||
aee8290b | 1108 | if (oH && !fTreeH) { |
b13db077 | 1109 | sprintf(hname,"TreeH%d",fEvent); |
1110 | fTreeH = new TTree(hname,"Hits"); | |
1111 | fTreeH->SetAutoSave(1000000000); //no autosave | |
9e1a0ddb | 1112 | fTreeH->Write(0,TObject::kOverwrite); |
b13db077 | 1113 | } |
aab9c8d5 | 1114 | |
1115 | if (oTR && !fTreeTR) { | |
1116 | sprintf(hname,"TreeTR%d",fEvent); | |
1117 | fTreeTR = new TTree(hname,"TrackReferences"); | |
1118 | fTreeTR->SetAutoSave(1000000000); //no autosave | |
1119 | fTreeTR->Write(0,TObject::kOverwrite); | |
1120 | } | |
1121 | ||
aee8290b | 1122 | if (oD && !fTreeD) { |
b13db077 | 1123 | sprintf(hname,"TreeD%d",fEvent); |
1124 | fTreeD = new TTree(hname,"Digits"); | |
9e1a0ddb | 1125 | fTreeD->Write(0,TObject::kOverwrite); |
b13db077 | 1126 | } |
2ab0c725 | 1127 | if (oS && !fTreeS) { |
1128 | sprintf(hname,"TreeS%d",fEvent); | |
1129 | fTreeS = new TTree(hname,"SDigits"); | |
9e1a0ddb | 1130 | fTreeS->Write(0,TObject::kOverwrite); |
2ab0c725 | 1131 | } |
aee8290b | 1132 | if (oR && !fTreeR) { |
b13db077 | 1133 | sprintf(hname,"TreeR%d",fEvent); |
1134 | fTreeR = new TTree(hname,"Reconstruction"); | |
9e1a0ddb | 1135 | fTreeR->Write(0,TObject::kOverwrite); |
b13db077 | 1136 | } |
9e1a0ddb | 1137 | |
fe4da5cc | 1138 | // |
1139 | // Create a branch for hits/digits for each detector | |
1140 | // Each branch is a TClonesArray. Each data member of the Hits classes | |
1141 | // will be in turn a subbranch of the detector master branch | |
8494b010 | 1142 | TIter next(fModules); |
1143 | AliModule *detector; | |
e2afb3b6 | 1144 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1145 | if (oH) detector->MakeBranch(option,file); |
aab9c8d5 | 1146 | if (oTR) detector->MakeBranchTR(option,file); |
fe4da5cc | 1147 | } |
fe4da5cc | 1148 | } |
1149 | ||
e2afb3b6 | 1150 | //_______________________________________________________________________ |
37d06d5b | 1151 | TParticle* AliRun::Particle(Int_t i) const |
2ab0c725 | 1152 | { |
37d06d5b | 1153 | // |
1154 | // Returns particle i on the simulation stack | |
1155 | // | |
1156 | return fStack->Particle(i); | |
fe4da5cc | 1157 | } |
1158 | ||
e2afb3b6 | 1159 | //_______________________________________________________________________ |
b9d0a01d | 1160 | void AliRun::ResetDigits() |
fe4da5cc | 1161 | { |
1162 | // | |
b9d0a01d | 1163 | // Reset all Detectors digits |
fe4da5cc | 1164 | // |
b9d0a01d | 1165 | TIter next(fModules); |
1166 | AliModule *detector; | |
e2afb3b6 | 1167 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1168 | detector->ResetDigits(); |
1169 | } | |
1170 | } | |
1171 | ||
e2afb3b6 | 1172 | //_______________________________________________________________________ |
b9d0a01d | 1173 | void AliRun::ResetSDigits() |
1174 | { | |
dffd31ef | 1175 | // |
b9d0a01d | 1176 | // Reset all Detectors digits |
9e1a0ddb | 1177 | // |
b9d0a01d | 1178 | TIter next(fModules); |
1179 | AliModule *detector; | |
e2afb3b6 | 1180 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1181 | detector->ResetSDigits(); |
1182 | } | |
1183 | } | |
dffd31ef | 1184 | |
e2afb3b6 | 1185 | //_______________________________________________________________________ |
b9d0a01d | 1186 | void AliRun::ResetHits() |
1187 | { | |
dffd31ef | 1188 | // |
b9d0a01d | 1189 | // Reset all Detectors hits |
1190 | // | |
1191 | TIter next(fModules); | |
1192 | AliModule *detector; | |
e2afb3b6 | 1193 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1194 | detector->ResetHits(); |
dffd31ef | 1195 | } |
b9d0a01d | 1196 | } |
dffd31ef | 1197 | |
e2afb3b6 | 1198 | //_______________________________________________________________________ |
b9d0a01d | 1199 | void AliRun::ResetTrackReferences() |
1200 | { | |
59fe9bd2 | 1201 | // |
b9d0a01d | 1202 | // Reset all Detectors hits |
1203 | // | |
1204 | TIter next(fModules); | |
1205 | AliModule *detector; | |
e2afb3b6 | 1206 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1207 | detector->ResetTrackReferences(); |
1208 | } | |
1209 | } | |
9e1a0ddb | 1210 | |
e2afb3b6 | 1211 | //_______________________________________________________________________ |
b9d0a01d | 1212 | void AliRun::ResetPoints() |
fe4da5cc | 1213 | { |
1214 | // | |
b9d0a01d | 1215 | // Reset all Detectors points |
fe4da5cc | 1216 | // |
8494b010 | 1217 | TIter next(fModules); |
1218 | AliModule *detector; | |
e2afb3b6 | 1219 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1220 | detector->ResetPoints(); |
fe4da5cc | 1221 | } |
1222 | } | |
1223 | ||
e2afb3b6 | 1224 | //_______________________________________________________________________ |
b9d0a01d | 1225 | void AliRun::InitMC(const char *setup) |
2ab0c725 | 1226 | { |
1227 | // | |
b9d0a01d | 1228 | // Initialize the Alice setup |
2ab0c725 | 1229 | // |
2ab0c725 | 1230 | |
37d06d5b | 1231 | Announce(); |
1232 | ||
b9d0a01d | 1233 | if(fInitDone) { |
1234 | Warning("Init","Cannot initialise AliRun twice!\n"); | |
1235 | return; | |
fe4da5cc | 1236 | } |
b9d0a01d | 1237 | |
1238 | gROOT->LoadMacro(setup); | |
1239 | gInterpreter->ProcessLine(fConfigFunction.Data()); | |
fe4da5cc | 1240 | |
b9d0a01d | 1241 | // Register MC in configuration |
1242 | AliConfig::Instance()->Add(gMC); | |
1243 | gMC->SetStack(fStack); | |
aab9c8d5 | 1244 | |
b9d0a01d | 1245 | gMC->DefineParticles(); //Create standard MC particles |
141f90e3 | 1246 | AliPDG::AddParticlesToPdgDataBase(); |
aab9c8d5 | 1247 | |
b9d0a01d | 1248 | TObject *objfirst, *objlast; |
1249 | ||
1250 | fNdets = fModules->GetLast()+1; | |
aab9c8d5 | 1251 | |
fe4da5cc | 1252 | // |
b9d0a01d | 1253 | //=================Create Materials and geometry |
1254 | gMC->Init(); | |
1255 | ||
1256 | // Added also after in case of interactive initialisation of modules | |
1257 | fNdets = fModules->GetLast()+1; | |
1258 | ||
1259 | TIter next(fModules); | |
1260 | AliModule *detector; | |
e2afb3b6 | 1261 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1262 | detector->SetTreeAddress(); |
1263 | objlast = gDirectory->GetList()->Last(); | |
1264 | ||
1265 | // Add Detector histograms in Detector list of histograms | |
1266 | if (objlast) objfirst = gDirectory->GetList()->After(objlast); | |
1267 | else objfirst = gDirectory->GetList()->First(); | |
1268 | while (objfirst) { | |
1269 | detector->Histograms()->Add(objfirst); | |
1270 | objfirst = gDirectory->GetList()->After(objfirst); | |
1271 | } | |
1272 | } | |
1273 | ReadTransPar(); //Read the cuts for all materials | |
1274 | ||
1275 | MediaTable(); //Build the special IMEDIA table | |
1276 | ||
1277 | //Initialise geometry deposition table | |
1278 | fEventEnergy.Set(gMC->NofVolumes()+1); | |
1279 | fSummEnergy.Set(gMC->NofVolumes()+1); | |
1280 | fSum2Energy.Set(gMC->NofVolumes()+1); | |
1281 | ||
1282 | //Compute cross-sections | |
1283 | gMC->BuildPhysics(); | |
1284 | ||
1285 | //Write Geometry object to current file. | |
1286 | fGeometry->Write(); | |
1287 | ||
1288 | fInitDone = kTRUE; | |
1289 | ||
1290 | fMCQA = new AliMCQA(fNdets); | |
1291 | ||
1292 | AliConfig::Instance(); | |
1293 | // | |
1294 | // Save stuff at the beginning of the file to avoid file corruption | |
1295 | Write(); | |
fe4da5cc | 1296 | } |
1297 | ||
e2afb3b6 | 1298 | //_______________________________________________________________________ |
875c717b | 1299 | void AliRun::RunMC(Int_t nevent, const char *setup) |
fe4da5cc | 1300 | { |
1301 | // | |
1302 | // Main function to be called to process a galice run | |
1303 | // example | |
1304 | // Root > gAlice.Run(); | |
1305 | // a positive number of events will cause the finish routine | |
1306 | // to be called | |
1307 | // | |
6df200c3 | 1308 | fEventsPerRun = nevent; |
fe4da5cc | 1309 | // check if initialisation has been done |
875c717b | 1310 | if (!fInitDone) InitMC(setup); |
fe4da5cc | 1311 | |
fe4da5cc | 1312 | // Create the Root Tree with one branch per detector |
2ab0c725 | 1313 | |
b9d0a01d | 1314 | MakeTree("ESDRT"); |
d47c658f | 1315 | |
2ab0c725 | 1316 | if (gSystem->Getenv("CONFIG_SPLIT_FILE")) { |
39de14fb | 1317 | MakeTree("K","Kine.root"); |
1318 | MakeTree("H","Hits.root"); | |
2ab0c725 | 1319 | } else { |
d47c658f | 1320 | MakeTree("KH"); |
2ab0c725 | 1321 | } |
fe4da5cc | 1322 | |
875c717b | 1323 | gMC->ProcessRun(nevent); |
1324 | ||
fe4da5cc | 1325 | // End of this run, close files |
80762cb1 | 1326 | if(nevent>0) FinishRun(); |
fe4da5cc | 1327 | } |
1328 | ||
e2afb3b6 | 1329 | //_______________________________________________________________________ |
27f087a9 | 1330 | void AliRun::RunReco(const char *selected, Int_t first, Int_t last) |
d47c658f | 1331 | { |
1332 | // | |
1333 | // Main function to be called to reconstruct Alice event | |
27f087a9 | 1334 | // |
1335 | cout << "Found "<< gAlice->TreeE()->GetEntries() << "events" << endl; | |
1336 | Int_t nFirst = first; | |
e2afb3b6 | 1337 | Int_t nLast = (last < 0)? static_cast<Int_t>(gAlice->TreeE()->GetEntries()) : last; |
27f087a9 | 1338 | |
1339 | for (Int_t nevent = nFirst; nevent <= nLast; nevent++) { | |
1340 | cout << "Processing event "<< nevent << endl; | |
9e1a0ddb | 1341 | GetEvent(nevent); |
1342 | // MakeTree("R"); | |
1343 | Digits2Reco(selected); | |
1344 | } | |
d47c658f | 1345 | } |
1346 | ||
e2afb3b6 | 1347 | //_______________________________________________________________________ |
2ab0c725 | 1348 | |
1349 | void AliRun::Hits2Digits(const char *selected) | |
1350 | { | |
9e1a0ddb | 1351 | |
d47c658f | 1352 | // Convert Hits to sumable digits |
1353 | // | |
9e1a0ddb | 1354 | for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) { |
1355 | GetEvent(nevent); | |
1356 | // MakeTree("D"); | |
1357 | Hits2SDigits(selected); | |
1358 | SDigits2Digits(selected); | |
1359 | } | |
2ab0c725 | 1360 | } |
1361 | ||
d47c658f | 1362 | |
e2afb3b6 | 1363 | //_______________________________________________________________________ |
2ab0c725 | 1364 | |
d47c658f | 1365 | void AliRun::Tree2Tree(Option_t *option, const char *selected) |
2ab0c725 | 1366 | { |
1367 | // | |
d47c658f | 1368 | // Function to transform the content of |
1369 | // | |
1370 | // - TreeH to TreeS (option "S") | |
1371 | // - TreeS to TreeD (option "D") | |
1372 | // - TreeD to TreeR (option "R") | |
1373 | // | |
1374 | // If multiple options are specified ("SDR"), transformation will be done in sequence for | |
1375 | // selected detector and for all detectors if none is selected (detector string | |
1376 | // can contain blank separated list of detector names). | |
2ab0c725 | 1377 | |
2ab0c725 | 1378 | |
5cf7bbad | 1379 | const char *oS = strstr(option,"S"); |
1380 | const char *oD = strstr(option,"D"); | |
1381 | const char *oR = strstr(option,"R"); | |
2ab0c725 | 1382 | |
9e1a0ddb | 1383 | TObjArray *detectors = Detectors(); |
2ab0c725 | 1384 | |
1385 | TIter next(detectors); | |
1386 | ||
d47c658f | 1387 | AliDetector *detector = 0; |
2ab0c725 | 1388 | |
1389 | TDirectory *cwd = gDirectory; | |
1390 | ||
3e4186da | 1391 | TObject *obj; |
1392 | ||
d47c658f | 1393 | char outFile[32]; |
2ab0c725 | 1394 | |
3e4186da | 1395 | while((obj = next())) { |
1396 | if (!dynamic_cast<AliModule*>(obj)) | |
1397 | Fatal("Tree2Tree","Wrong type in fModules array\n"); | |
1398 | if (!(detector = dynamic_cast<AliDetector*>(obj))) continue; | |
d47c658f | 1399 | if (selected) |
2ab0c725 | 1400 | if (strcmp(detector->GetName(),selected)) continue; |
3e4186da | 1401 | if (!detector->IsActive()) continue; |
1402 | if (gSystem->Getenv("CONFIG_SPLIT_FILE")) { | |
9e1a0ddb | 1403 | if (oS) { |
3e4186da | 1404 | sprintf(outFile,"SDigits.%s.root",detector->GetName()); |
1405 | detector->MakeBranch("S",outFile); | |
1406 | } | |
9e1a0ddb | 1407 | if (oD) { |
3e4186da | 1408 | sprintf(outFile,"Digits.%s.root",detector->GetName()); |
1409 | detector->MakeBranch("D",outFile); | |
1410 | } | |
9e1a0ddb | 1411 | if (oR) { |
3e4186da | 1412 | sprintf(outFile,"Reco.%s.root",detector->GetName()); |
1413 | detector->MakeBranch("R",outFile); | |
1414 | } | |
1415 | } else { | |
1416 | detector->MakeBranch(option); | |
1417 | } | |
1418 | ||
1419 | cwd->cd(); | |
1420 | ||
1421 | if (oS) { | |
1422 | cout << "Hits2SDigits: Processing " << detector->GetName() << "..." << endl; | |
1423 | detector->Hits2SDigits(); | |
1424 | } | |
1425 | if (oD) { | |
1426 | cout << "SDigits2Digits: Processing " << detector->GetName() << "..." << endl; | |
1427 | detector->SDigits2Digits(); | |
1428 | } | |
1429 | if (oR) { | |
1430 | cout << "Digits2Reco: Processing " << detector->GetName() << "..." << endl; | |
1431 | detector->Digits2Reco(); | |
1432 | } | |
1433 | ||
1434 | cwd->cd(); | |
1435 | } | |
2ab0c725 | 1436 | } |
1437 | ||
e2afb3b6 | 1438 | //_______________________________________________________________________ |
0a520a66 | 1439 | void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min, |
1440 | Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max, | |
1441 | Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener) | |
fe4da5cc | 1442 | { |
1443 | // | |
1444 | // Generates lego plots of: | |
1445 | // - radiation length map phi vs theta | |
1446 | // - radiation length map phi vs eta | |
1447 | // - interaction length map | |
1448 | // - g/cm2 length map | |
1449 | // | |
1450 | // ntheta bins in theta, eta | |
1451 | // themin minimum angle in theta (degrees) | |
1452 | // themax maximum angle in theta (degrees) | |
1453 | // nphi bins in phi | |
1454 | // phimin minimum angle in phi (degrees) | |
1455 | // phimax maximum angle in phi (degrees) | |
1456 | // rmin minimum radius | |
1457 | // rmax maximum radius | |
1458 | // | |
1459 | // | |
1460 | // The number of events generated = ntheta*nphi | |
1461 | // run input parameters in macro setup (default="Config.C") | |
1462 | // | |
1463 | // Use macro "lego.C" to visualize the 3 lego plots in spherical coordinates | |
1464 | //Begin_Html | |
1465 | /* | |
1439f98e | 1466 | <img src="picts/AliRunLego1.gif"> |
fe4da5cc | 1467 | */ |
1468 | //End_Html | |
1469 | //Begin_Html | |
1470 | /* | |
1439f98e | 1471 | <img src="picts/AliRunLego2.gif"> |
fe4da5cc | 1472 | */ |
1473 | //End_Html | |
1474 | //Begin_Html | |
1475 | /* | |
1439f98e | 1476 | <img src="picts/AliRunLego3.gif"> |
fe4da5cc | 1477 | */ |
1478 | //End_Html | |
1479 | // | |
1480 | ||
1481 | // check if initialisation has been done | |
875c717b | 1482 | if (!fInitDone) InitMC(setup); |
838edcaf | 1483 | //Save current generator |
1484 | AliGenerator *gen=Generator(); | |
1485 | ||
0a520a66 | 1486 | // Set new generator |
1487 | if (!gener) gener = new AliLegoGenerator(); | |
1488 | ResetGenerator(gener); | |
1489 | // | |
1490 | // Configure Generator | |
1491 | gener->SetRadiusRange(rmin, rmax); | |
1492 | gener->SetZMax(zmax); | |
1493 | gener->SetCoor1Range(nc1, c1min, c1max); | |
1494 | gener->SetCoor2Range(nc2, c2min, c2max); | |
1495 | ||
1496 | ||
b13db077 | 1497 | //Create Lego object |
0a520a66 | 1498 | fLego = new AliLego("lego",gener); |
b13db077 | 1499 | |
dffd31ef | 1500 | //Prepare MC for Lego Run |
1501 | gMC->InitLego(); | |
1502 | ||
b13db077 | 1503 | //Run Lego Object |
0a520a66 | 1504 | |
b9d0a01d | 1505 | //gMC->ProcessRun(nc1*nc2+1); |
1506 | gMC->ProcessRun(nc1*nc2); | |
fe4da5cc | 1507 | |
1508 | // Create only the Root event Tree | |
80762cb1 | 1509 | MakeTree("E"); |
fe4da5cc | 1510 | |
1511 | // End of this run, close files | |
80762cb1 | 1512 | FinishRun(); |
0a520a66 | 1513 | // Restore current generator |
1514 | ResetGenerator(gen); | |
838edcaf | 1515 | // Delete Lego Object |
1516 | delete fLego; fLego=0; | |
fe4da5cc | 1517 | } |
1518 | ||
e2afb3b6 | 1519 | //_______________________________________________________________________ |
94de3818 | 1520 | void AliRun::SetConfigFunction(const char * config) |
1521 | { | |
1522 | // | |
1523 | // Set the signature of the function contained in Config.C to configure | |
1524 | // the run | |
1525 | // | |
1526 | fConfigFunction=config; | |
1527 | } | |
1528 | ||
e2afb3b6 | 1529 | //_______________________________________________________________________ |
fe4da5cc | 1530 | void AliRun::SetCurrentTrack(Int_t track) |
1531 | { | |
1532 | // | |
1533 | // Set current track number | |
1534 | // | |
9e1a0ddb | 1535 | fStack->SetCurrentTrack(track); |
fe4da5cc | 1536 | } |
1537 | ||
e2afb3b6 | 1538 | //_______________________________________________________________________ |
1578254f | 1539 | void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom, |
fe4da5cc | 1540 | Float_t *vpos, Float_t *polar, Float_t tof, |
98490ea9 | 1541 | TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) |
fe4da5cc | 1542 | { |
9e1a0ddb | 1543 | // Delegate to stack |
1544 | // | |
b9d0a01d | 1545 | |
1546 | fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof, | |
1547 | mech, ntr, weight, is); | |
fe4da5cc | 1548 | } |
1549 | ||
e2afb3b6 | 1550 | //_______________________________________________________________________ |
89bbad6f | 1551 | void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, |
1552 | Double_t px, Double_t py, Double_t pz, Double_t e, | |
1553 | Double_t vx, Double_t vy, Double_t vz, Double_t tof, | |
1554 | Double_t polx, Double_t poly, Double_t polz, | |
98490ea9 | 1555 | TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) |
89bbad6f | 1556 | { |
9e1a0ddb | 1557 | // Delegate to stack |
89bbad6f | 1558 | // |
9e1a0ddb | 1559 | fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof, |
47c8bcbe | 1560 | polx, poly, polz, mech, ntr, weight, is); |
9e1a0ddb | 1561 | |
89bbad6f | 1562 | } |
1563 | ||
e2afb3b6 | 1564 | //_______________________________________________________________________ |
4d69d91e | 1565 | void AliRun::SetHighWaterMark(const Int_t nt) |
1566 | { | |
1567 | // | |
1568 | // Set high water mark for last track in event | |
9e1a0ddb | 1569 | fStack->SetHighWaterMark(nt); |
4d69d91e | 1570 | } |
1571 | ||
e2afb3b6 | 1572 | //_______________________________________________________________________ |
fe4da5cc | 1573 | void AliRun::KeepTrack(const Int_t track) |
1574 | { | |
1575 | // | |
9e1a0ddb | 1576 | // Delegate to stack |
fe4da5cc | 1577 | // |
9e1a0ddb | 1578 | fStack->KeepTrack(track); |
fe4da5cc | 1579 | } |
1580 | ||
b9d0a01d | 1581 | // |
1582 | // MC Application | |
1583 | // | |
1584 | ||
e2afb3b6 | 1585 | //_______________________________________________________________________ |
b9d0a01d | 1586 | void AliRun::ConstructGeometry() |
1587 | { | |
1588 | // | |
1589 | // Create modules, materials, geometry | |
1590 | // | |
1591 | ||
1592 | TStopwatch stw; | |
1593 | TIter next(fModules); | |
1594 | AliModule *detector; | |
1595 | printf("Geometry creation:\n"); | |
e2afb3b6 | 1596 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1597 | stw.Start(); |
1598 | // Initialise detector materials and geometry | |
1599 | detector->CreateMaterials(); | |
1600 | detector->CreateGeometry(); | |
1601 | printf("%10s R:%.2fs C:%.2fs\n", | |
1602 | detector->GetName(),stw.RealTime(),stw.CpuTime()); | |
1603 | } | |
1604 | } | |
1605 | ||
e2afb3b6 | 1606 | //_______________________________________________________________________ |
b9d0a01d | 1607 | void AliRun::InitGeometry() |
1608 | { | |
1609 | // | |
1610 | // Initialize detectors and display geometry | |
1611 | // | |
1612 | ||
1613 | printf("Initialisation:\n"); | |
1614 | TStopwatch stw; | |
1615 | TIter next(fModules); | |
1616 | AliModule *detector; | |
e2afb3b6 | 1617 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1618 | stw.Start(); |
1619 | // Initialise detector and display geometry | |
1620 | detector->Init(); | |
1621 | detector->BuildGeometry(); | |
1622 | printf("%10s R:%.2fs C:%.2fs\n", | |
1623 | detector->GetName(),stw.RealTime(),stw.CpuTime()); | |
1624 | } | |
1625 | ||
1626 | } | |
1627 | ||
e2afb3b6 | 1628 | //_______________________________________________________________________ |
b9d0a01d | 1629 | void AliRun::GeneratePrimaries() |
1630 | { | |
1631 | // | |
1632 | // Generate primary particles and fill them in the stack. | |
1633 | // | |
1634 | ||
1635 | Generator()->Generate(); | |
1636 | } | |
1637 | ||
e2afb3b6 | 1638 | //_______________________________________________________________________ |
b9d0a01d | 1639 | void AliRun::BeginEvent() |
1640 | { | |
1641 | // Clean-up previous event | |
1642 | // Energy scores | |
1643 | fEventEnergy.Reset(); | |
1644 | // Clean detector information | |
1645 | CleanDetectors(); | |
1646 | // Reset stack info | |
1647 | fStack->Reset(); | |
1648 | ||
1649 | ||
1650 | // | |
1651 | // Reset all Detectors & kinematics & trees | |
1652 | // | |
1653 | char hname[30]; | |
1654 | // | |
1655 | // Initialise event header | |
1656 | fHeader->Reset(fRun,fEvent,fEventNrInRun); | |
1657 | // | |
1658 | fStack->BeginEvent(fEvent); | |
1659 | ||
1660 | // | |
1661 | if(fLego) { | |
1662 | fLego->BeginEvent(); | |
1663 | return; | |
1664 | } | |
1665 | ||
1666 | // | |
1667 | ||
1668 | ResetHits(); | |
1669 | ResetTrackReferences(); | |
1670 | ResetDigits(); | |
1671 | ResetSDigits(); | |
1672 | ||
1673 | ||
1674 | if(fTreeH) { | |
1675 | fTreeH->Reset(); | |
1676 | sprintf(hname,"TreeH%d",fEvent); | |
1677 | fTreeH->SetName(hname); | |
1678 | } | |
1679 | ||
1680 | if(fTreeTR) { | |
1681 | fTreeTR->Reset(); | |
1682 | sprintf(hname,"TreeTR%d",fEvent); | |
1683 | fTreeTR->SetName(hname); | |
1684 | } | |
1685 | ||
1686 | if(fTreeD) { | |
1687 | fTreeD->Reset(); | |
1688 | sprintf(hname,"TreeD%d",fEvent); | |
1689 | fTreeD->SetName(hname); | |
1690 | fTreeD->Write(0,TObject::kOverwrite); | |
1691 | } | |
1692 | if(fTreeS) { | |
1693 | fTreeS->Reset(); | |
1694 | sprintf(hname,"TreeS%d",fEvent); | |
1695 | fTreeS->SetName(hname); | |
1696 | fTreeS->Write(0,TObject::kOverwrite); | |
1697 | } | |
1698 | if(fTreeR) { | |
1699 | fTreeR->Reset(); | |
1700 | sprintf(hname,"TreeR%d",fEvent); | |
1701 | fTreeR->SetName(hname); | |
1702 | fTreeR->Write(0,TObject::kOverwrite); | |
1703 | } | |
1704 | } | |
1705 | ||
e2afb3b6 | 1706 | //_______________________________________________________________________ |
b9d0a01d | 1707 | void AliRun::BeginPrimary() |
1708 | { | |
1709 | // | |
1710 | // Called at the beginning of each primary track | |
1711 | // | |
1712 | ||
1713 | // Reset Hits info | |
1714 | gAlice->ResetHits(); | |
1715 | gAlice->ResetTrackReferences(); | |
1716 | ||
1717 | } | |
1718 | ||
e2afb3b6 | 1719 | //_______________________________________________________________________ |
b9d0a01d | 1720 | void AliRun::PreTrack() |
1721 | { | |
116cbefd | 1722 | // |
1723 | // Method called before each track | |
1724 | // | |
1725 | TObjArray &dets = *fModules; | |
1726 | AliModule *module; | |
1727 | ||
1728 | for(Int_t i=0; i<=fNdets; i++) | |
1729 | if((module = dynamic_cast<AliModule*>(dets[i]))) | |
1730 | module->PreTrack(); | |
1731 | ||
1732 | fMCQA->PreTrack(); | |
b9d0a01d | 1733 | } |
1734 | ||
e2afb3b6 | 1735 | //_______________________________________________________________________ |
b9d0a01d | 1736 | void AliRun::Stepping() |
fe4da5cc | 1737 | { |
1738 | // | |
1739 | // Called at every step during transport | |
1740 | // | |
1741 | ||
b9d0a01d | 1742 | Int_t id = DetFromMate(gMC->GetMedium()); |
1743 | if (id < 0) return; | |
1744 | ||
fe4da5cc | 1745 | // |
1746 | // --- If lego option, do it and leave | |
b13db077 | 1747 | if (fLego) |
fe4da5cc | 1748 | fLego->StepManager(); |
b13db077 | 1749 | else { |
1750 | Int_t copy; | |
1751 | //Update energy deposition tables | |
875c717b | 1752 | AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep()); |
fe4da5cc | 1753 | |
b13db077 | 1754 | //Call the appropriate stepping routine; |
e2afb3b6 | 1755 | AliModule *det = dynamic_cast<AliModule*>(fModules->At(id)); |
3f754d83 | 1756 | if(det && det->StepManagerIsEnabled()) { |
65fb704d | 1757 | fMCQA->StepManager(id); |
1758 | det->StepManager(); | |
1759 | } | |
fe4da5cc | 1760 | } |
fe4da5cc | 1761 | } |
1762 | ||
e2afb3b6 | 1763 | //_______________________________________________________________________ |
b9d0a01d | 1764 | void AliRun::PostTrack() |
1765 | { | |
116cbefd | 1766 | // |
1767 | // Called after a track has been trasported | |
1768 | // | |
1769 | TObjArray &dets = *fModules; | |
1770 | AliModule *module; | |
1771 | ||
1772 | for(Int_t i=0; i<=fNdets; i++) | |
1773 | if((module = dynamic_cast<AliModule*>(dets[i]))) | |
1774 | module->PostTrack(); | |
b9d0a01d | 1775 | } |
1776 | ||
e2afb3b6 | 1777 | //_______________________________________________________________________ |
b9d0a01d | 1778 | void AliRun::FinishPrimary() |
1779 | { | |
1780 | // | |
1781 | // Called at the end of each primary track | |
1782 | // | |
1783 | ||
1784 | // static Int_t count=0; | |
1785 | // const Int_t times=10; | |
1786 | // This primary is finished, purify stack | |
1787 | fStack->PurifyKine(); | |
1788 | ||
1789 | TIter next(fModules); | |
1790 | AliModule *detector; | |
e2afb3b6 | 1791 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 1792 | detector->FinishPrimary(); |
1793 | } | |
1794 | ||
1795 | // Write out hits if any | |
1796 | if (gAlice->TreeH()) { | |
1797 | gAlice->TreeH()->Fill(); | |
1798 | } | |
1799 | ||
1800 | // Write out hits if any | |
1801 | if (gAlice->TreeTR()) { | |
1802 | gAlice->TreeTR()->Fill(); | |
1803 | } | |
1804 | ||
1805 | // | |
1806 | // if(++count%times==1) gObjectTable->Print(); | |
1807 | } | |
1808 | ||
e2afb3b6 | 1809 | //_______________________________________________________________________ |
b9d0a01d | 1810 | void AliRun::FinishEvent() |
1811 | { | |
1812 | // | |
1813 | // Called at the end of the event. | |
1814 | // | |
1815 | ||
1816 | // | |
1817 | if(fLego) fLego->FinishEvent(); | |
1818 | ||
1819 | //Update the energy deposit tables | |
1820 | Int_t i; | |
1821 | for(i=0;i<fEventEnergy.GetSize();i++) { | |
1822 | fSummEnergy[i]+=fEventEnergy[i]; | |
1823 | fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i]; | |
1824 | } | |
1825 | ||
1826 | ||
1827 | ||
1828 | // Update Header information | |
1829 | ||
1830 | fHeader->SetNprimary(fStack->GetNprimary()); | |
1831 | fHeader->SetNtrack(fStack->GetNtrack()); | |
1832 | ||
1833 | ||
1834 | // Write out the kinematics | |
1835 | fStack->FinishEvent(); | |
1836 | ||
1837 | // Write out the event Header information | |
1838 | if (fTreeE) { | |
1839 | fHeader->SetStack(fStack); | |
1840 | fTreeE->Fill(); | |
1841 | } | |
1842 | ||
1843 | ||
1844 | // Write Tree headers | |
1845 | TTree* pTreeK = fStack->TreeK(); | |
1846 | if (pTreeK) pTreeK->Write(0,TObject::kOverwrite); | |
1847 | if (fTreeH) fTreeH->Write(0,TObject::kOverwrite); | |
1848 | if (fTreeTR) fTreeTR->Write(0,TObject::kOverwrite); | |
1849 | ||
1850 | ++fEvent; | |
1851 | ++fEventNrInRun; | |
1852 | } | |
1853 | ||
e2afb3b6 | 1854 | //_______________________________________________________________________ |
b9d0a01d | 1855 | void AliRun::Field(const Double_t* x, Double_t *b) const |
1856 | { | |
116cbefd | 1857 | // |
1858 | // Returns the magnetic field at point x[3] | |
1859 | // Units are kGauss | |
1860 | // | |
1861 | Float_t xfloat[3]; | |
1862 | for (Int_t i=0; i<3; i++) xfloat[i] = x[i]; | |
1863 | ||
1864 | if (Field()) { | |
1865 | Float_t bfloat[3]; | |
1866 | Field()->Field(xfloat,bfloat); | |
1867 | for (Int_t j=0; j<3; j++) b[j] = bfloat[j]; | |
1868 | } | |
1869 | else { | |
1870 | printf("No mag field defined!\n"); | |
1871 | b[0]=b[1]=b[2]=0.; | |
1872 | } | |
b9d0a01d | 1873 | |
1874 | } | |
1875 | ||
1876 | // | |
1877 | // End of MC Application | |
1878 | // | |
1879 | ||
e2afb3b6 | 1880 | //_______________________________________________________________________ |
fe4da5cc | 1881 | void AliRun::Streamer(TBuffer &R__b) |
1882 | { | |
eef4b160 | 1883 | // Stream an object of class AliRun. |
2ab0c725 | 1884 | |
7e90ff59 | 1885 | if (R__b.IsReading()) { |
1886 | if (!gAlice) gAlice = this; | |
eef4b160 | 1887 | |
7e90ff59 | 1888 | AliRun::Class()->ReadBuffer(R__b, this); |
1889 | // | |
1890 | gROOT->GetListOfBrowsables()->Add(this,"Run"); | |
eef4b160 | 1891 | |
e2afb3b6 | 1892 | fTreeE = dynamic_cast<TTree*>(gDirectory->Get("TE")); |
7e90ff59 | 1893 | if (fTreeE) { |
eef4b160 | 1894 | fTreeE->SetBranchAddress("Header", &fHeader); |
b9d0a01d | 1895 | } |
7e90ff59 | 1896 | else Error("Streamer","cannot find Header Tree\n"); |
b9d0a01d | 1897 | |
7e90ff59 | 1898 | fTreeE->GetEntry(0); |
7e90ff59 | 1899 | gRandom = fRandom; |
1900 | } else { | |
eef4b160 | 1901 | AliRun::Class()->WriteBuffer(R__b, this); |
1902 | } | |
2ab0c725 | 1903 | } |
1904 | ||
9e1a0ddb | 1905 | |
e2afb3b6 | 1906 | //_______________________________________________________________________ |
9e1a0ddb | 1907 | Int_t AliRun::CurrentTrack() const { |
1908 | // | |
1909 | // Returns current track | |
1910 | // | |
1911 | return fStack->CurrentTrack(); | |
1912 | } | |
1913 | ||
e2afb3b6 | 1914 | //_______________________________________________________________________ |
9e1a0ddb | 1915 | Int_t AliRun::GetNtrack() const { |
1916 | // | |
1917 | // Returns number of tracks in stack | |
1918 | // | |
1919 | return fStack->GetNtrack(); | |
1920 | } | |
1921 | ||
e2afb3b6 | 1922 | //_______________________________________________________________________ |
37d06d5b | 1923 | TObjArray* AliRun::Particles() const { |
9e1a0ddb | 1924 | // |
1925 | // Returns pointer to Particles array | |
1926 | // | |
1927 | return fStack->Particles(); | |
1928 | } | |
1929 | ||
e2afb3b6 | 1930 | //_______________________________________________________________________ |
37d06d5b | 1931 | TTree* AliRun::TreeK() const { |
9e1a0ddb | 1932 | // |
1933 | // Returns pointer to the TreeK array | |
1934 | // | |
1935 | return fStack->TreeK(); | |
1936 | } | |
27f087a9 | 1937 | |
b9d0a01d | 1938 | |
e2afb3b6 | 1939 | //_______________________________________________________________________ |
27f087a9 | 1940 | void AliRun::SetGenEventHeader(AliGenEventHeader* header) |
1941 | { | |
1942 | fHeader->SetGenEventHeader(header); | |
1943 | } | |
b9d0a01d | 1944 | |
e2afb3b6 | 1945 | //_______________________________________________________________________ |
7a16e9cc | 1946 | TFile* AliRun::InitFile(TString fileName) |
1947 | { | |
1948 | // | |
1949 | // create the file where the whole tree will be saved | |
1950 | // | |
1951 | TDirectory *wd = gDirectory; | |
1952 | TFile* file = TFile::Open(fileName,"update"); | |
1953 | gDirectory = wd; | |
1954 | if (!file->IsOpen()) { | |
1955 | Error("Cannot open file, %s\n",fileName); | |
1956 | return 0; | |
1957 | } | |
1958 | return file; | |
1959 | } | |
1960 | ||
e2afb3b6 | 1961 | //_______________________________________________________________________ |
7a16e9cc | 1962 | TFile* AliRun::InitTreeFile(Option_t *option, TString fileName) |
1963 | { | |
1964 | // | |
1965 | // create the file where one of the following trees will be saved | |
1966 | // trees: S,D,R | |
0592d1ca | 1967 | // WARNING: by default these trees are saved on the file on which |
1968 | // hits are stored. If you divert one of these trees, you cannot restore | |
1969 | // it to the original file (usually galice.root) in the same aliroot session | |
7a16e9cc | 1970 | Bool_t oS = (strstr(option,"S")!=0); |
1971 | Bool_t oR = (strstr(option,"R")!=0); | |
1972 | Bool_t oD = (strstr(option,"D")!=0); | |
0592d1ca | 1973 | Int_t choice[3]; |
1974 | for (Int_t i=0; i<3; i++) choice[i] = 0; | |
1975 | if(oS)choice[0] = 1; | |
1976 | if(oD)choice[1] = 1; | |
1977 | if(oR)choice[2] = 1; | |
1978 | ||
7a16e9cc | 1979 | TFile *ptr=0; |
0592d1ca | 1980 | |
1981 | if(!(oS || oR || oD))return ptr; | |
1982 | ||
1983 | Int_t active[3]; | |
1984 | for (Int_t i=0; i<3; i++) active[i] = 0; | |
1985 | if(fTreeSFileName != "") active[0] = 1; | |
1986 | if(fTreeDFileName != "") active[1] = 1; | |
1987 | if(fTreeDFileName != "") active[2] = 1; | |
1988 | ||
1989 | Bool_t alreadyopen1 = kFALSE; | |
1990 | Bool_t alreadyopen2 = kFALSE; | |
1991 | ||
1992 | if(oS){ | |
1993 | // if already active and same name with non-null ptr | |
1994 | if(active[0]==1 && fileName == fTreeSFileName && fTreeSFile){ | |
1995 | Warning("InitTreeFile","File %s already opened",fTreeSFileName.Data()); | |
7a16e9cc | 1996 | ptr = fTreeSFile; |
1997 | } | |
0592d1ca | 1998 | else { |
1999 | // if already active with different name with non-null ptr | |
2000 | if(active[0]==1 && fileName != fTreeSFileName && fTreeSFile){ | |
2001 | // close the active files and also the other possible files in option | |
2002 | CloseTreeFile(option); | |
2003 | } | |
2004 | fTreeSFileName = fileName; | |
2005 | alreadyopen1 = | |
2006 | (active[1] == 1 && fTreeDFileName == fTreeSFileName && fTreeDFile); | |
2007 | alreadyopen2 = | |
2008 | (active[2] == 1 && fTreeRFileName == fTreeSFileName && fTreeRFile); | |
2009 | if(!(alreadyopen1 || alreadyopen2)){ | |
2010 | ptr = InitFile(fileName); | |
2011 | fTreeSFile = ptr; | |
7a16e9cc | 2012 | } |
0592d1ca | 2013 | else { |
2014 | if(alreadyopen1){fTreeSFile = fTreeDFile; ptr = fTreeSFile;} | |
2015 | if(alreadyopen2){fTreeSFile = fTreeRFile; ptr = fTreeSFile;} | |
2016 | } | |
2017 | if(choice[1] == 1) { fTreeDFileName = fileName; fTreeDFile = ptr;} | |
2018 | if(choice[2] == 1) { fTreeRFileName = fileName; fTreeRFile = ptr;} | |
2019 | } | |
2020 | return ptr; | |
2021 | } | |
2022 | ||
2023 | if(oD){ | |
2024 | // if already active and same name with non-null ptr | |
2025 | if(active[1]==1 && fileName == fTreeDFileName && fTreeDFile){ | |
2026 | Warning("InitTreeFile","File %s already opened",fTreeDFileName.Data()); | |
7a16e9cc | 2027 | ptr = fTreeDFile; |
2028 | } | |
0592d1ca | 2029 | else { |
2030 | // if already active with different name with non-null ptr | |
2031 | if(active[1]==1 && fileName != fTreeDFileName && fTreeDFile){ | |
2032 | // close the active files and also the other possible files in option | |
2033 | CloseTreeFile(option); | |
2034 | } | |
2035 | fTreeDFileName = fileName; | |
2036 | alreadyopen1 = | |
2037 | (active[0] == 1 && fTreeSFileName == fTreeDFileName && fTreeSFile); | |
2038 | alreadyopen2 = | |
2039 | (active[2] == 1 && fTreeRFileName == fTreeDFileName && fTreeRFile); | |
2040 | if(!(alreadyopen1 || alreadyopen2)){ | |
2041 | ptr = InitFile(fileName); | |
2042 | fTreeDFile = ptr; | |
2043 | } | |
2044 | else { | |
2045 | if(alreadyopen1){fTreeDFile = fTreeSFile; ptr = fTreeDFile;} | |
2046 | if(alreadyopen2){fTreeDFile = fTreeRFile; ptr = fTreeDFile;} | |
7a16e9cc | 2047 | } |
0592d1ca | 2048 | if(choice[2] == 1) { fTreeRFileName = fileName; fTreeRFile = ptr;} |
2049 | } | |
2050 | return ptr; | |
2051 | } | |
2052 | ||
2053 | if(oR){ | |
2054 | // if already active and same name with non-null ptr | |
2055 | if(active[2]==1 && fileName == fTreeRFileName && fTreeRFile){ | |
2056 | Warning("InitTreeFile","File %s already opened",fTreeRFileName.Data()); | |
7a16e9cc | 2057 | ptr = fTreeRFile; |
2058 | } | |
0592d1ca | 2059 | else { |
2060 | // if already active with different name with non-null ptr | |
2061 | if(active[2]==1 && fileName != fTreeRFileName && fTreeRFile){ | |
2062 | // close the active files and also the other possible files in option | |
2063 | CloseTreeFile(option); | |
2064 | } | |
2065 | fTreeRFileName = fileName; | |
2066 | alreadyopen1 = | |
2067 | (active[1] == 1 && fTreeDFileName == fTreeRFileName && fTreeDFile); | |
2068 | alreadyopen2 = | |
2069 | (active[0]== 1 && fTreeSFileName == fTreeRFileName && fTreeSFile); | |
2070 | if(!(alreadyopen1 || alreadyopen2)){ | |
2071 | ptr = InitFile(fileName); | |
2072 | fTreeRFile = ptr; | |
2073 | } | |
2074 | else { | |
2075 | if(alreadyopen1){fTreeRFile = fTreeDFile; ptr = fTreeRFile;} | |
2076 | if(alreadyopen2){fTreeRFile = fTreeSFile; ptr = fTreeRFile;} | |
2077 | } | |
2078 | } | |
2079 | return ptr; | |
7a16e9cc | 2080 | } |
b16a1b1e | 2081 | return 0; |
0592d1ca | 2082 | } |
b9d0a01d | 2083 | |
e2afb3b6 | 2084 | //_______________________________________________________________________ |
b9d0a01d | 2085 | void AliRun::PrintTreeFile() |
2086 | { | |
2087 | // | |
2088 | // prints the file names and pointer associated to S,D,R trees | |
2089 | // | |
2090 | cout<<"===================================================\n"; | |
2091 | TFile *file = fTreeE->GetCurrentFile(); | |
2092 | TString curfilname=""; | |
e2afb3b6 | 2093 | if(file)curfilname=static_cast<TString>(file->GetName()); |
b9d0a01d | 2094 | cout<<" Current tree file name: "<<curfilname<<endl; |
2095 | cout<<"Pointer: "<<file<<endl; | |
2096 | cout<<" Tree S File name: "<<fTreeSFileName<<endl; | |
2097 | cout<<"Pointer: "<<fTreeSFile<<endl<<endl; | |
2098 | cout<<" Tree D File name: "<<fTreeDFileName<<endl; | |
2099 | cout<<"Pointer: "<<fTreeDFile<<endl<<endl; | |
2100 | cout<<" Tree R File name: "<<fTreeRFileName<<endl; | |
2101 | cout<<"Pointer: "<<fTreeRFile<<endl<<endl; | |
2102 | cout<<"===================================================\n"; | |
2103 | } | |
e2afb3b6 | 2104 | //_______________________________________________________________________ |
0592d1ca | 2105 | void AliRun::CloseTreeFile(Option_t *option) |
2106 | { | |
2107 | // | |
2108 | // closes the file containing the tree specified in option | |
2109 | // (S,D,R) | |
2110 | // | |
2111 | Bool_t oS = (strstr(option,"S")!=0); | |
2112 | Bool_t oR = (strstr(option,"R")!=0); | |
2113 | Bool_t oD = (strstr(option,"D")!=0); | |
2114 | Bool_t none = !(oS || oR || oD); | |
2115 | if(none)return; | |
2116 | if(oS){ | |
2117 | fTreeSFileName = ""; | |
2118 | if(fTreeSFile){ | |
2119 | if(!((fTreeSFile == fTreeDFile) || (fTreeSFile == fTreeRFile)) && | |
2120 | fTreeSFile->IsOpen()){ | |
2121 | fTreeSFile->Close(); | |
2122 | delete fTreeSFile; | |
2123 | } | |
2124 | } | |
2125 | fTreeSFile = 0; | |
2126 | } | |
2127 | if(oD){ | |
2128 | fTreeDFileName = ""; | |
2129 | if(fTreeDFile){ | |
2130 | if(!((fTreeDFile == fTreeRFile) || (fTreeDFile == fTreeSFile)) && | |
2131 | fTreeDFile->IsOpen()){ | |
2132 | fTreeDFile->Close(); | |
2133 | delete fTreeDFile; | |
2134 | } | |
2135 | } | |
2136 | fTreeDFile = 0; | |
2137 | } | |
2138 | if(oR){ | |
2139 | fTreeRFileName = ""; | |
2140 | if(fTreeRFile){ | |
2141 | if(!((fTreeRFile == fTreeSFile) || (fTreeRFile == fTreeDFile)) && | |
2142 | fTreeRFile->IsOpen()){ | |
2143 | fTreeRFile->Close(); | |
2144 | delete fTreeRFile; | |
2145 | } | |
2146 | } | |
2147 | fTreeRFile = 0; | |
2148 | } | |
2149 | } | |
2150 | ||
e2afb3b6 | 2151 | //_______________________________________________________________________ |
7a16e9cc | 2152 | void AliRun::MakeTree(Option_t *option, TFile *file) |
2153 | { | |
2154 | // | |
2155 | // Create some trees in the separate file | |
2156 | // | |
2157 | const char *oD = strstr(option,"D"); | |
2158 | const char *oR = strstr(option,"R"); | |
2159 | const char *oS = strstr(option,"S"); | |
2160 | ||
2161 | TDirectory *cwd = gDirectory; | |
2162 | char hname[30]; | |
2163 | ||
2164 | if (oD) { | |
2165 | delete fTreeD; | |
2166 | sprintf(hname,"TreeD%d",fEvent); | |
2167 | file->cd(); | |
2168 | fTreeD = static_cast<TTree*>(file->Get("hname")); | |
2169 | if (!fTreeD) { | |
2170 | fTreeD = new TTree(hname,"Digits"); | |
2171 | fTreeD->Write(0,TObject::kOverwrite); | |
2172 | } | |
2173 | cwd->cd(); | |
2174 | } | |
2175 | if (oS) { | |
2176 | delete fTreeS; | |
2177 | sprintf(hname,"TreeS%d",fEvent); | |
2178 | file->cd(); | |
2179 | fTreeS = static_cast<TTree*>(file->Get("hname")); | |
2180 | if (!fTreeS) { | |
2181 | fTreeS = new TTree(hname,"SDigits"); | |
2182 | fTreeS->Write(0,TObject::kOverwrite); | |
2183 | } | |
2184 | cwd->cd(); | |
2185 | } | |
2186 | ||
2187 | if (oR) { | |
2188 | delete fTreeR; | |
2189 | sprintf(hname,"TreeR%d",fEvent); | |
2190 | file->cd(); | |
2191 | fTreeR = static_cast<TTree*>(file->Get("hname")); | |
2192 | if (!fTreeR) { | |
2193 | fTreeR = new TTree(hname,"RecPoint"); | |
2194 | fTreeR->Write(0,TObject::kOverwrite); | |
2195 | } | |
2196 | cwd->cd(); | |
2197 | } | |
2198 | } |