]>
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 | ||
16 | /* | |
17 | $Log$ | |
0a520a66 | 18 | Revision 1.43 2000/10/09 09:43:17 fca |
19 | Special remapping of hits for TPC and TRD. End-of-primary action introduced | |
20 | ||
24de2263 | 21 | Revision 1.42 2000/10/02 21:28:14 fca |
22 | Removal of useless dependecies via forward declarations | |
23 | ||
94de3818 | 24 | Revision 1.41 2000/07/13 16:19:09 fca |
25 | Mainly coding conventions + some small bug fixes | |
26 | ||
ef42d733 | 27 | Revision 1.40 2000/07/12 08:56:25 fca |
28 | Coding convention correction and warning removal | |
29 | ||
8918e700 | 30 | Revision 1.39 2000/07/11 18:24:59 fca |
31 | Coding convention corrections + few minor bug fixes | |
32 | ||
aee8290b | 33 | Revision 1.38 2000/06/20 13:05:45 fca |
34 | Writing down the TREE headers before job starts | |
35 | ||
51e0e89d | 36 | Revision 1.37 2000/06/09 20:05:11 morsch |
37 | Introduce possibility to chose magnetic field version 3: AliMagFDM + field02.dat | |
38 | ||
f1b9d7c3 | 39 | Revision 1.36 2000/06/08 14:03:58 hristov |
40 | Only one initializer for a default argument | |
41 | ||
d33c0226 | 42 | Revision 1.35 2000/06/07 10:13:14 hristov |
43 | Delete only existent objects. | |
44 | ||
d2ecd553 | 45 | Revision 1.34 2000/05/18 10:45:38 fca |
46 | Delete Particle Factory properly | |
47 | ||
c222d2b0 | 48 | Revision 1.33 2000/05/16 13:10:40 fca |
49 | New method IsNewTrack and fix for a problem in Father-Daughter relations | |
50 | ||
a01a8b12 | 51 | Revision 1.32 2000/04/27 10:38:21 fca |
52 | Correct termination of Lego Run and introduce Lego getter in AliRun | |
53 | ||
838edcaf | 54 | Revision 1.31 2000/04/26 10:17:32 fca |
55 | Changes in Lego for G4 compatibility | |
56 | ||
dffd31ef | 57 | Revision 1.30 2000/04/18 19:11:40 fca |
58 | Introduce variable Config.C function signature | |
59 | ||
45189757 | 60 | Revision 1.29 2000/04/07 11:12:34 fca |
61 | G4 compatibility changes | |
62 | ||
875c717b | 63 | Revision 1.28 2000/04/05 06:51:06 fca |
64 | Workaround for an HP compiler problem | |
65 | ||
5eb58812 | 66 | Revision 1.27 2000/03/22 18:08:07 fca |
67 | Rationalisation of the virtual MC interfaces | |
68 | ||
80762cb1 | 69 | Revision 1.26 2000/03/22 13:42:26 fca |
70 | SetGenerator does not replace an existing generator, ResetGenerator does | |
71 | ||
ee1dd322 | 72 | Revision 1.25 2000/02/23 16:25:22 fca |
73 | AliVMC and AliGeant3 classes introduced | |
74 | ReadEuclid moved from AliRun to AliModule | |
75 | ||
b13db077 | 76 | Revision 1.24 2000/01/19 17:17:20 fca |
77 | Introducing a list of lists of hits -- more hits allowed for detector now | |
78 | ||
1cedd08a | 79 | Revision 1.23 1999/12/03 11:14:31 fca |
80 | Fixing previous wrong checking | |
81 | ||
00719c1b | 82 | Revision 1.21 1999/11/25 10:40:08 fca |
83 | Fixing daughters information also in primary tracks | |
84 | ||
ae23d366 | 85 | Revision 1.20 1999/10/04 18:08:49 fca |
86 | Adding protection against inconsistent Euclid files | |
87 | ||
3fcc96a1 | 88 | Revision 1.19 1999/09/29 07:50:40 fca |
89 | Introduction of the Copyright and cvs Log | |
90 | ||
99d554c8 | 91 | */ |
92 | ||
fe4da5cc | 93 | /////////////////////////////////////////////////////////////////////////////// |
94 | // // | |
95 | // Control class for Alice C++ // | |
96 | // Only one single instance of this class exists. // | |
97 | // The object is created in main program aliroot // | |
98 | // and is pointed by the global gAlice. // | |
99 | // // | |
8494b010 | 100 | // -Supports the list of all Alice Detectors (fModules). // |
fe4da5cc | 101 | // -Supports the list of particles (fParticles). // |
102 | // -Supports the Trees. // | |
103 | // -Supports the geometry. // | |
104 | // -Supports the event display. // | |
105 | //Begin_Html | |
106 | /* | |
1439f98e | 107 | <img src="picts/AliRunClass.gif"> |
fe4da5cc | 108 | */ |
109 | //End_Html | |
110 | //Begin_Html | |
111 | /* | |
1439f98e | 112 | <img src="picts/alirun.gif"> |
fe4da5cc | 113 | */ |
114 | //End_Html | |
115 | // // | |
116 | /////////////////////////////////////////////////////////////////////////////// | |
117 | ||
94de3818 | 118 | #include <stdlib.h> |
119 | #include <stdio.h> | |
120 | #include <string.h> | |
121 | ||
fe4da5cc | 122 | #include <TFile.h> |
123 | #include <TRandom.h> | |
124 | #include <TBRIK.h> | |
125 | #include <TNode.h> | |
fe4da5cc | 126 | #include <TCint.h> |
127 | #include <TSystem.h> | |
a8f1fb7c | 128 | #include <TObjectTable.h> |
94de3818 | 129 | #include <TTree.h> |
130 | #include <TGeometry.h> | |
131 | #include <TROOT.h> | |
132 | #include "TBrowser.h" | |
fe4da5cc | 133 | |
1578254f | 134 | #include "TParticle.h" |
fe4da5cc | 135 | #include "AliRun.h" |
fe4da5cc | 136 | #include "AliDisplay.h" |
875c717b | 137 | #include "AliMC.h" |
dffd31ef | 138 | #include "AliLego.h" |
aee8290b | 139 | #include "AliMagFC.h" |
140 | #include "AliMagFCM.h" | |
141 | #include "AliMagFDM.h" | |
94de3818 | 142 | #include "AliHit.h" |
143 | ||
144 | #include "AliDetector.h" | |
fe4da5cc | 145 | |
fe4da5cc | 146 | AliRun *gAlice; |
147 | ||
aee8290b | 148 | static AliHeader *gAliHeader; |
fe4da5cc | 149 | |
fe4da5cc | 150 | ClassImp(AliRun) |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | AliRun::AliRun() | |
154 | { | |
155 | // | |
156 | // Default constructor for AliRun | |
157 | // | |
aee8290b | 158 | gAliHeader=&fHeader; |
fe4da5cc | 159 | fRun = 0; |
160 | fEvent = 0; | |
161 | fCurrent = -1; | |
8494b010 | 162 | fModules = 0; |
fe4da5cc | 163 | fGenerator = 0; |
164 | fTreeD = 0; | |
165 | fTreeK = 0; | |
166 | fTreeH = 0; | |
167 | fTreeE = 0; | |
168 | fTreeR = 0; | |
169 | fParticles = 0; | |
170 | fGeometry = 0; | |
171 | fDisplay = 0; | |
172 | fField = 0; | |
875c717b | 173 | fMC = 0; |
fe4da5cc | 174 | fNdets = 0; |
175 | fImedia = 0; | |
176 | fTrRmax = 1.e10; | |
177 | fTrZmax = 1.e10; | |
fe4da5cc | 178 | fInitDone = kFALSE; |
179 | fLego = 0; | |
1578254f | 180 | fPDGDB = 0; //Particle factory object! |
1cedd08a | 181 | fHitLists = 0; |
45189757 | 182 | fConfigFunction = "\0"; |
fe4da5cc | 183 | } |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | AliRun::AliRun(const char *name, const char *title) | |
187 | : TNamed(name,title) | |
188 | { | |
189 | // | |
190 | // Constructor for the main processor. | |
191 | // Creates the geometry | |
192 | // Creates the list of Detectors. | |
193 | // Creates the list of particles. | |
194 | // | |
195 | Int_t i; | |
196 | ||
197 | gAlice = this; | |
198 | fTreeD = 0; | |
199 | fTreeK = 0; | |
200 | fTreeH = 0; | |
201 | fTreeE = 0; | |
202 | fTreeR = 0; | |
203 | fTrRmax = 1.e10; | |
204 | fTrZmax = 1.e10; | |
1141f8e4 | 205 | fGenerator = 0; |
fe4da5cc | 206 | fInitDone = kFALSE; |
207 | fLego = 0; | |
208 | fField = 0; | |
45189757 | 209 | fConfigFunction = "Config();"; |
fe4da5cc | 210 | |
211 | gROOT->GetListOfBrowsables()->Add(this,name); | |
212 | // | |
213 | // create the support list for the various Detectors | |
8494b010 | 214 | fModules = new TObjArray(77); |
fe4da5cc | 215 | // |
216 | // Create the TNode geometry for the event display | |
217 | ||
218 | BuildSimpleGeometry(); | |
219 | ||
220 | ||
221 | fNtrack=0; | |
222 | fHgwmk=0; | |
223 | fCurrent=-1; | |
aee8290b | 224 | gAliHeader=&fHeader; |
fe4da5cc | 225 | fRun = 0; |
226 | fEvent = 0; | |
227 | // | |
228 | // Create the particle stack | |
1578254f | 229 | fParticles = new TClonesArray("TParticle",100); |
fe4da5cc | 230 | |
231 | fDisplay = 0; | |
232 | // | |
233 | // Create default mag field | |
234 | SetField(); | |
235 | // | |
875c717b | 236 | fMC = gMC; |
fe4da5cc | 237 | // |
238 | // Prepare the tracking medium lists | |
239 | fImedia = new TArrayI(1000); | |
240 | for(i=0;i<1000;i++) (*fImedia)[i]=-99; | |
1578254f | 241 | // |
242 | // Make particles | |
243 | fPDGDB = TDatabasePDG::Instance(); //Particle factory object! | |
1cedd08a | 244 | // |
245 | // Create HitLists list | |
246 | fHitLists = new TList(); | |
fe4da5cc | 247 | } |
248 | ||
aee8290b | 249 | |
fe4da5cc | 250 | //_____________________________________________________________________________ |
251 | AliRun::~AliRun() | |
252 | { | |
253 | // | |
254 | // Defaullt AliRun destructor | |
255 | // | |
fe4da5cc | 256 | delete fImedia; |
257 | delete fField; | |
875c717b | 258 | delete fMC; |
fe4da5cc | 259 | delete fGeometry; |
260 | delete fDisplay; | |
261 | delete fGenerator; | |
262 | delete fLego; | |
263 | delete fTreeD; | |
264 | delete fTreeK; | |
265 | delete fTreeH; | |
266 | delete fTreeE; | |
267 | delete fTreeR; | |
8494b010 | 268 | if (fModules) { |
269 | fModules->Delete(); | |
270 | delete fModules; | |
fe4da5cc | 271 | } |
272 | if (fParticles) { | |
273 | fParticles->Delete(); | |
274 | delete fParticles; | |
275 | } | |
1cedd08a | 276 | delete fHitLists; |
c222d2b0 | 277 | delete fPDGDB; |
fe4da5cc | 278 | } |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | void AliRun::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const | |
282 | { | |
283 | // | |
284 | // Add a hit to detector id | |
285 | // | |
8494b010 | 286 | TObjArray &dets = *fModules; |
287 | if(dets[id]) ((AliModule*) dets[id])->AddHit(track,vol,hits); | |
fe4da5cc | 288 | } |
289 | ||
290 | //_____________________________________________________________________________ | |
291 | void AliRun::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const | |
292 | { | |
293 | // | |
294 | // Add digit to detector id | |
295 | // | |
8494b010 | 296 | TObjArray &dets = *fModules; |
297 | if(dets[id]) ((AliModule*) dets[id])->AddDigit(tracks,digits); | |
fe4da5cc | 298 | } |
299 | ||
300 | //_____________________________________________________________________________ | |
301 | void AliRun::Browse(TBrowser *b) | |
302 | { | |
303 | // | |
304 | // Called when the item "Run" is clicked on the left pane | |
305 | // of the Root browser. | |
306 | // It displays the Root Trees and all detectors. | |
307 | // | |
308 | if (fTreeK) b->Add(fTreeK,fTreeK->GetName()); | |
309 | if (fTreeH) b->Add(fTreeH,fTreeH->GetName()); | |
310 | if (fTreeD) b->Add(fTreeD,fTreeD->GetName()); | |
311 | if (fTreeE) b->Add(fTreeE,fTreeE->GetName()); | |
312 | if (fTreeR) b->Add(fTreeR,fTreeR->GetName()); | |
313 | ||
8494b010 | 314 | TIter next(fModules); |
315 | AliModule *detector; | |
316 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 317 | b->Add(detector,detector->GetName()); |
318 | } | |
319 | } | |
320 | ||
321 | //_____________________________________________________________________________ | |
322 | void AliRun::Build() | |
323 | { | |
324 | // | |
325 | // Initialize Alice geometry | |
326 | // Dummy routine | |
327 | // | |
328 | } | |
329 | ||
330 | //_____________________________________________________________________________ | |
331 | void AliRun::BuildSimpleGeometry() | |
332 | { | |
333 | // | |
334 | // Create a simple TNode geometry used by Root display engine | |
335 | // | |
336 | // Initialise geometry | |
337 | // | |
338 | fGeometry = new TGeometry("AliceGeom","Galice Geometry for Hits"); | |
339 | new TMaterial("void","Vacuum",0,0,0); //Everything is void | |
340 | TBRIK *brik = new TBRIK("S_alice","alice volume","void",2000,2000,3000); | |
341 | brik->SetVisibility(0); | |
342 | new TNode("alice","alice","S_alice"); | |
343 | } | |
344 | ||
345 | //_____________________________________________________________________________ | |
346 | void AliRun::CleanDetectors() | |
347 | { | |
348 | // | |
349 | // Clean Detectors at the end of event | |
350 | // | |
8494b010 | 351 | TIter next(fModules); |
352 | AliModule *detector; | |
353 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 354 | detector->FinishEvent(); |
355 | } | |
356 | } | |
357 | ||
358 | //_____________________________________________________________________________ | |
359 | void AliRun::CleanParents() | |
360 | { | |
361 | // | |
362 | // Clean Particles stack. | |
1578254f | 363 | // Set parent/daughter relations |
fe4da5cc | 364 | // |
365 | TClonesArray &particles = *(gAlice->Particles()); | |
1578254f | 366 | TParticle *part; |
fe4da5cc | 367 | int i; |
368 | for(i=0; i<fNtrack; i++) { | |
1578254f | 369 | part = (TParticle *)particles.UncheckedAt(i); |
aee8290b | 370 | if(!part->TestBit(kDaughtersBit)) { |
1578254f | 371 | part->SetFirstDaughter(-1); |
372 | part->SetLastDaughter(-1); | |
fe4da5cc | 373 | } |
374 | } | |
375 | } | |
376 | ||
377 | //_____________________________________________________________________________ | |
378 | Int_t AliRun::DistancetoPrimitive(Int_t, Int_t) | |
379 | { | |
380 | // | |
381 | // Return the distance from the mouse to the AliRun object | |
382 | // Dummy routine | |
383 | // | |
384 | return 9999; | |
385 | } | |
386 | ||
387 | //_____________________________________________________________________________ | |
94de3818 | 388 | void AliRun::DumpPart (Int_t i) const |
fe4da5cc | 389 | { |
390 | // | |
391 | // Dumps particle i in the stack | |
392 | // | |
393 | TClonesArray &particles = *fParticles; | |
1578254f | 394 | ((TParticle*) particles[i])->Print(); |
fe4da5cc | 395 | } |
396 | ||
397 | //_____________________________________________________________________________ | |
94de3818 | 398 | void AliRun::DumpPStack () const |
fe4da5cc | 399 | { |
400 | // | |
401 | // Dumps the particle stack | |
402 | // | |
403 | TClonesArray &particles = *fParticles; | |
404 | printf( | |
405 | "\n\n=======================================================================\n"); | |
406 | for (Int_t i=0;i<fNtrack;i++) | |
407 | { | |
1578254f | 408 | printf("-> %d ",i); ((TParticle*) particles[i])->Print(); |
fe4da5cc | 409 | printf("--------------------------------------------------------------\n"); |
410 | } | |
411 | printf( | |
412 | "\n=======================================================================\n\n"); | |
413 | } | |
414 | ||
415 | //_____________________________________________________________________________ | |
416 | void AliRun::SetField(Int_t type, Int_t version, Float_t scale, | |
417 | Float_t maxField, char* filename) | |
418 | { | |
419 | // | |
420 | // Set magnetic field parameters | |
421 | // type Magnetic field transport flag 0=no field, 2=helix, 3=Runge Kutta | |
422 | // version Magnetic field map version (only 1 active now) | |
423 | // scale Scale factor for the magnetic field | |
424 | // maxField Maximum value for the magnetic field | |
425 | ||
426 | // | |
427 | // --- Sanity check on mag field flags | |
428 | if(type<0 || type > 2) { | |
23370b7a | 429 | Warning("SetField", |
430 | "Invalid magnetic field flag: %5d; Helix tracking chosen instead\n" | |
fe4da5cc | 431 | ,type); |
432 | type=2; | |
433 | } | |
434 | if(fField) delete fField; | |
435 | if(version==1) { | |
436 | fField = new AliMagFC("Map1"," ",type,version,scale,maxField); | |
f1b9d7c3 | 437 | } else if(version<=2) { |
fe4da5cc | 438 | fField = new AliMagFCM("Map2-3",filename,type,version,scale,maxField); |
439 | fField->ReadField(); | |
f1b9d7c3 | 440 | } else if(version==3) { |
441 | fField = new AliMagFDM("Map4",filename,type,version,scale,maxField); | |
442 | fField->ReadField(); | |
fe4da5cc | 443 | } else { |
23370b7a | 444 | Warning("SetField","Invalid map %d\n",version); |
fe4da5cc | 445 | } |
446 | } | |
447 | ||
448 | //_____________________________________________________________________________ | |
449 | void AliRun::FillTree() | |
450 | { | |
451 | // | |
452 | // Fills all AliRun TTrees | |
453 | // | |
454 | if (fTreeK) fTreeK->Fill(); | |
455 | if (fTreeH) fTreeH->Fill(); | |
456 | if (fTreeD) fTreeD->Fill(); | |
457 | if (fTreeR) fTreeR->Fill(); | |
458 | } | |
459 | ||
460 | //_____________________________________________________________________________ | |
461 | void AliRun::FinishPrimary() | |
462 | { | |
463 | // | |
464 | // Called at the end of each primary track | |
465 | // | |
466 | ||
6c9704e6 | 467 | // static Int_t count=0; |
468 | // const Int_t times=10; | |
fe4da5cc | 469 | // This primary is finished, purify stack |
80762cb1 | 470 | PurifyKine(); |
fe4da5cc | 471 | |
24de2263 | 472 | TIter next(fModules); |
473 | AliModule *detector; | |
474 | while((detector = (AliModule*)next())) { | |
475 | detector->FinishPrimary(); | |
476 | } | |
477 | ||
fe4da5cc | 478 | // Write out hits if any |
479 | if (gAlice->TreeH()) { | |
480 | gAlice->TreeH()->Fill(); | |
481 | } | |
482 | ||
483 | // Reset Hits info | |
484 | gAlice->ResetHits(); | |
a8f1fb7c | 485 | |
486 | // | |
487 | // if(++count%times==1) gObjectTable->Print(); | |
fe4da5cc | 488 | } |
489 | ||
490 | //_____________________________________________________________________________ | |
491 | void AliRun::FinishEvent() | |
492 | { | |
493 | // | |
494 | // Called at the end of the event. | |
495 | // | |
7fb01480 | 496 | |
dffd31ef | 497 | // |
498 | if(fLego) fLego->FinishEvent(); | |
499 | ||
fe4da5cc | 500 | //Update the energy deposit tables |
501 | Int_t i; | |
875c717b | 502 | for(i=0;i<fEventEnergy.GetSize();i++) { |
503 | fSummEnergy[i]+=fEventEnergy[i]; | |
504 | fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i]; | |
fe4da5cc | 505 | } |
875c717b | 506 | fEventEnergy.Reset(); |
fe4da5cc | 507 | |
508 | // Clean detector information | |
509 | CleanDetectors(); | |
510 | ||
511 | // Write out the kinematics | |
512 | if (fTreeK) { | |
513 | CleanParents(); | |
514 | fTreeK->Fill(); | |
515 | } | |
516 | ||
517 | // Write out the digits | |
518 | if (fTreeD) { | |
519 | fTreeD->Fill(); | |
520 | ResetDigits(); | |
521 | } | |
522 | ||
523 | // Write out reconstructed clusters | |
524 | if (fTreeR) { | |
525 | fTreeR->Fill(); | |
526 | } | |
527 | ||
528 | // Write out the event Header information | |
529 | if (fTreeE) fTreeE->Fill(); | |
530 | ||
531 | // Reset stack info | |
532 | ResetStack(); | |
533 | ||
534 | // Write Tree headers | |
59fe9bd2 | 535 | // Int_t ievent = fHeader.GetEvent(); |
536 | // char hname[30]; | |
537 | // sprintf(hname,"TreeK%d",ievent); | |
51e0e89d | 538 | if (fTreeK) fTreeK->Write(0,TObject::kOverwrite); |
59fe9bd2 | 539 | // sprintf(hname,"TreeH%d",ievent); |
51e0e89d | 540 | if (fTreeH) fTreeH->Write(0,TObject::kOverwrite); |
59fe9bd2 | 541 | // sprintf(hname,"TreeD%d",ievent); |
51e0e89d | 542 | if (fTreeD) fTreeD->Write(0,TObject::kOverwrite); |
59fe9bd2 | 543 | // sprintf(hname,"TreeR%d",ievent); |
51e0e89d | 544 | if (fTreeR) fTreeR->Write(0,TObject::kOverwrite); |
875c717b | 545 | |
546 | ++fEvent; | |
fe4da5cc | 547 | } |
548 | ||
549 | //_____________________________________________________________________________ | |
550 | void AliRun::FinishRun() | |
551 | { | |
552 | // | |
553 | // Called at the end of the run. | |
554 | // | |
555 | ||
dffd31ef | 556 | // |
557 | if(fLego) fLego->FinishRun(); | |
558 | ||
fe4da5cc | 559 | // Clean detector information |
8494b010 | 560 | TIter next(fModules); |
561 | AliModule *detector; | |
562 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 563 | detector->FinishRun(); |
564 | } | |
565 | ||
566 | //Output energy summary tables | |
567 | EnergySummary(); | |
568 | ||
569 | // file is retrieved from whatever tree | |
aee8290b | 570 | TFile *file = 0; |
571 | if (fTreeK) file = fTreeK->GetCurrentFile(); | |
572 | if ((!file) && (fTreeH)) file = fTreeH->GetCurrentFile(); | |
573 | if ((!file) && (fTreeD)) file = fTreeD->GetCurrentFile(); | |
574 | if ((!file) && (fTreeE)) file = fTreeE->GetCurrentFile(); | |
575 | if( NULL==file ) { | |
fe4da5cc | 576 | Error("FinishRun","There isn't root file!"); |
577 | exit(1); | |
578 | } | |
aee8290b | 579 | file->cd(); |
51e0e89d | 580 | fTreeE->Write(0,TObject::kOverwrite); |
fe4da5cc | 581 | |
582 | // Clean tree information | |
d2ecd553 | 583 | if (fTreeK) { |
584 | delete fTreeK; fTreeK = 0; | |
585 | } | |
586 | if (fTreeH) { | |
587 | delete fTreeH; fTreeH = 0; | |
588 | } | |
589 | if (fTreeD) { | |
590 | delete fTreeD; fTreeD = 0; | |
591 | } | |
592 | if (fTreeR) { | |
593 | delete fTreeR; fTreeR = 0; | |
594 | } | |
595 | if (fTreeE) { | |
596 | delete fTreeE; fTreeE = 0; | |
597 | } | |
fe4da5cc | 598 | |
599 | // Write AliRun info and all detectors parameters | |
600 | Write(); | |
601 | ||
602 | // Close output file | |
aee8290b | 603 | file->Write(); |
fe4da5cc | 604 | } |
605 | ||
606 | //_____________________________________________________________________________ | |
607 | void AliRun::FlagTrack(Int_t track) | |
608 | { | |
609 | // | |
610 | // Flags a track and all its family tree to be kept | |
611 | // | |
612 | int curr; | |
1578254f | 613 | TParticle *particle; |
fe4da5cc | 614 | |
615 | curr=track; | |
616 | while(1) { | |
1578254f | 617 | particle=(TParticle*)fParticles->UncheckedAt(curr); |
fe4da5cc | 618 | |
619 | // If the particle is flagged the three from here upward is saved already | |
aee8290b | 620 | if(particle->TestBit(kKeepBit)) return; |
fe4da5cc | 621 | |
622 | // Save this particle | |
aee8290b | 623 | particle->SetBit(kKeepBit); |
fe4da5cc | 624 | |
625 | // Move to father if any | |
1578254f | 626 | if((curr=particle->GetFirstMother())==-1) return; |
fe4da5cc | 627 | } |
628 | } | |
629 | ||
630 | //_____________________________________________________________________________ | |
631 | void AliRun::EnergySummary() | |
632 | { | |
633 | // | |
634 | // Print summary of deposited energy | |
635 | // | |
636 | ||
fe4da5cc | 637 | Int_t ndep=0; |
638 | Float_t edtot=0; | |
639 | Float_t ed, ed2; | |
640 | Int_t kn, i, left, j, id; | |
aee8290b | 641 | const Float_t kzero=0; |
fe4da5cc | 642 | Int_t ievent=fHeader.GetEvent()+1; |
643 | // | |
644 | // Energy loss information | |
645 | if(ievent) { | |
646 | printf("***************** Energy Loss Information per event (GEV) *****************\n"); | |
875c717b | 647 | for(kn=1;kn<fEventEnergy.GetSize();kn++) { |
648 | ed=fSummEnergy[kn]; | |
fe4da5cc | 649 | if(ed>0) { |
875c717b | 650 | fEventEnergy[ndep]=kn; |
fe4da5cc | 651 | if(ievent>1) { |
652 | ed=ed/ievent; | |
875c717b | 653 | ed2=fSum2Energy[kn]; |
fe4da5cc | 654 | ed2=ed2/ievent; |
aee8290b | 655 | ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed; |
fe4da5cc | 656 | } else |
657 | ed2=99; | |
875c717b | 658 | fSummEnergy[ndep]=ed; |
aee8290b | 659 | fSum2Energy[ndep]=TMath::Min((Float_t) 99.,TMath::Max(ed2,kzero)); |
fe4da5cc | 660 | edtot+=ed; |
661 | ndep++; | |
662 | } | |
663 | } | |
664 | for(kn=0;kn<(ndep-1)/3+1;kn++) { | |
665 | left=ndep-kn*3; | |
666 | for(i=0;i<(3<left?3:left);i++) { | |
667 | j=kn*3+i; | |
875c717b | 668 | id=Int_t (fEventEnergy[j]+0.1); |
669 | printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]); | |
fe4da5cc | 670 | } |
671 | printf("\n"); | |
672 | } | |
673 | // | |
674 | // Relative energy loss in different detectors | |
675 | printf("******************** Relative Energy Loss per event ********************\n"); | |
676 | printf("Total energy loss per event %10.3f GeV\n",edtot); | |
677 | for(kn=0;kn<(ndep-1)/5+1;kn++) { | |
678 | left=ndep-kn*5; | |
679 | for(i=0;i<(5<left?5:left);i++) { | |
680 | j=kn*5+i; | |
875c717b | 681 | id=Int_t (fEventEnergy[j]+0.1); |
682 | printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot); | |
fe4da5cc | 683 | } |
684 | printf("\n"); | |
685 | } | |
686 | for(kn=0;kn<75;kn++) printf("*"); | |
687 | printf("\n"); | |
688 | } | |
689 | // | |
690 | // Reset the TArray's | |
875c717b | 691 | // fEventEnergy.Set(0); |
692 | // fSummEnergy.Set(0); | |
693 | // fSum2Energy.Set(0); | |
fe4da5cc | 694 | } |
695 | ||
696 | //_____________________________________________________________________________ | |
94de3818 | 697 | AliModule *AliRun::GetModule(const char *name) const |
fe4da5cc | 698 | { |
699 | // | |
700 | // Return pointer to detector from name | |
701 | // | |
8494b010 | 702 | return (AliModule*)fModules->FindObject(name); |
fe4da5cc | 703 | } |
704 | ||
a68348e9 | 705 | //_____________________________________________________________________________ |
94de3818 | 706 | AliDetector *AliRun::GetDetector(const char *name) const |
a68348e9 | 707 | { |
708 | // | |
709 | // Return pointer to detector from name | |
710 | // | |
711 | return (AliDetector*)fModules->FindObject(name); | |
712 | } | |
713 | ||
fe4da5cc | 714 | //_____________________________________________________________________________ |
94de3818 | 715 | Int_t AliRun::GetModuleID(const char *name) const |
fe4da5cc | 716 | { |
717 | // | |
718 | // Return galice internal detector identifier from name | |
719 | // | |
23370b7a | 720 | Int_t i=-1; |
721 | TObject *mod=fModules->FindObject(name); | |
722 | if(mod) i=fModules->IndexOf(mod); | |
723 | return i; | |
fe4da5cc | 724 | } |
725 | ||
726 | //_____________________________________________________________________________ | |
727 | Int_t AliRun::GetEvent(Int_t event) | |
728 | { | |
729 | // | |
730 | // Connect the Trees Kinematics and Hits for event # event | |
731 | // Set branch addresses | |
732 | // | |
fe4da5cc | 733 | |
734 | // Reset existing structures | |
735 | ResetStack(); | |
736 | ResetHits(); | |
737 | ResetDigits(); | |
738 | ||
739 | // Delete Trees already connected | |
740 | if (fTreeK) delete fTreeK; | |
741 | if (fTreeH) delete fTreeH; | |
742 | if (fTreeD) delete fTreeD; | |
743 | if (fTreeR) delete fTreeR; | |
59fe9bd2 | 744 | |
745 | // Get header from file | |
746 | if(fTreeE) fTreeE->GetEntry(event); | |
747 | else Error("GetEvent","Cannot file Header Tree\n"); | |
fe4da5cc | 748 | |
749 | // Get Kine Tree from file | |
750 | char treeName[20]; | |
751 | sprintf(treeName,"TreeK%d",event); | |
752 | fTreeK = (TTree*)gDirectory->Get(treeName); | |
753 | if (fTreeK) fTreeK->SetBranchAddress("Particles", &fParticles); | |
23370b7a | 754 | else Error("GetEvent","cannot find Kine Tree for event:%d\n",event); |
fe4da5cc | 755 | |
756 | // Get Hits Tree header from file | |
757 | sprintf(treeName,"TreeH%d",event); | |
758 | fTreeH = (TTree*)gDirectory->Get(treeName); | |
759 | if (!fTreeH) { | |
23370b7a | 760 | Error("GetEvent","cannot find Hits Tree for event:%d\n",event); |
fe4da5cc | 761 | } |
762 | ||
763 | // Get Digits Tree header from file | |
764 | sprintf(treeName,"TreeD%d",event); | |
765 | fTreeD = (TTree*)gDirectory->Get(treeName); | |
766 | if (!fTreeD) { | |
07a68c1d | 767 | Warning("GetEvent","cannot find Digits Tree for event:%d\n",event); |
fe4da5cc | 768 | } |
769 | ||
770 | ||
771 | // Get Reconstruct Tree header from file | |
772 | sprintf(treeName,"TreeR%d",event); | |
773 | fTreeR = (TTree*)gDirectory->Get(treeName); | |
774 | if (!fTreeR) { | |
775 | // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event); | |
776 | } | |
777 | ||
778 | // Set Trees branch addresses | |
8494b010 | 779 | TIter next(fModules); |
780 | AliModule *detector; | |
781 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 782 | detector->SetTreeAddress(); |
783 | } | |
784 | ||
785 | if (fTreeK) fTreeK->GetEvent(0); | |
786 | fNtrack = Int_t (fParticles->GetEntries()); | |
787 | return fNtrack; | |
788 | } | |
789 | ||
790 | //_____________________________________________________________________________ | |
791 | TGeometry *AliRun::GetGeometry() | |
792 | { | |
793 | // | |
794 | // Import Alice geometry from current file | |
795 | // Return pointer to geometry object | |
796 | // | |
797 | if (!fGeometry) fGeometry = (TGeometry*)gDirectory->Get("AliceGeom"); | |
798 | // | |
799 | // Unlink and relink nodes in detectors | |
800 | // This is bad and there must be a better way... | |
801 | // | |
fe4da5cc | 802 | |
8494b010 | 803 | TIter next(fModules); |
804 | AliModule *detector; | |
805 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 806 | detector->SetTreeAddress(); |
807 | TList *dnodes=detector->Nodes(); | |
808 | Int_t j; | |
809 | TNode *node, *node1; | |
810 | for ( j=0; j<dnodes->GetSize(); j++) { | |
811 | node = (TNode*) dnodes->At(j); | |
52d0ab00 | 812 | node1 = fGeometry->GetNode(node->GetName()); |
fe4da5cc | 813 | dnodes->Remove(node); |
814 | dnodes->AddAt(node1,j); | |
815 | } | |
816 | } | |
817 | return fGeometry; | |
818 | } | |
819 | ||
820 | //_____________________________________________________________________________ | |
821 | void AliRun::GetNextTrack(Int_t &mtrack, Int_t &ipart, Float_t *pmom, | |
822 | Float_t &e, Float_t *vpos, Float_t *polar, | |
823 | Float_t &tof) | |
824 | { | |
825 | // | |
826 | // Return next track from stack of particles | |
827 | // | |
a8f1fb7c | 828 | TVector3 pol; |
fe4da5cc | 829 | fCurrent=-1; |
1578254f | 830 | TParticle *track; |
fe4da5cc | 831 | for(Int_t i=fNtrack-1; i>=0; i--) { |
1578254f | 832 | track=(TParticle*) fParticles->UncheckedAt(i); |
aee8290b | 833 | if(!track->TestBit(kDoneBit)) { |
fe4da5cc | 834 | // |
835 | // The track has not yet been processed | |
836 | fCurrent=i; | |
1578254f | 837 | ipart=track->GetPdgCode(); |
838 | pmom[0]=track->Px(); | |
839 | pmom[1]=track->Py(); | |
840 | pmom[2]=track->Pz(); | |
841 | e =track->Energy(); | |
842 | vpos[0]=track->Vx(); | |
843 | vpos[1]=track->Vy(); | |
844 | vpos[2]=track->Vz(); | |
a8f1fb7c | 845 | track->GetPolarisation(pol); |
846 | polar[0]=pol.X(); | |
847 | polar[1]=pol.Y(); | |
848 | polar[2]=pol.Z(); | |
1578254f | 849 | tof=track->T(); |
aee8290b | 850 | track->SetBit(kDoneBit); |
fe4da5cc | 851 | break; |
852 | } | |
853 | } | |
854 | mtrack=fCurrent; | |
855 | // | |
856 | // stop and start timer when we start a primary track | |
857 | Int_t nprimaries = fHeader.GetNprimary(); | |
858 | if (fCurrent >= nprimaries) return; | |
859 | if (fCurrent < nprimaries-1) { | |
860 | fTimer.Stop(); | |
1578254f | 861 | track=(TParticle*) fParticles->UncheckedAt(fCurrent+1); |
862 | // track->SetProcessTime(fTimer.CpuTime()); | |
fe4da5cc | 863 | } |
864 | fTimer.Start(); | |
865 | } | |
866 | ||
867 | //_____________________________________________________________________________ | |
94de3818 | 868 | Int_t AliRun::GetPrimary(Int_t track) const |
fe4da5cc | 869 | { |
870 | // | |
871 | // return number of primary that has generated track | |
872 | // | |
873 | int current, parent; | |
1578254f | 874 | TParticle *part; |
fe4da5cc | 875 | // |
876 | parent=track; | |
877 | while (1) { | |
878 | current=parent; | |
1578254f | 879 | part = (TParticle *)fParticles->UncheckedAt(current); |
880 | parent=part->GetFirstMother(); | |
fe4da5cc | 881 | if(parent<0) return current; |
882 | } | |
883 | } | |
884 | ||
885 | //_____________________________________________________________________________ | |
875c717b | 886 | void AliRun::InitMC(const char *setup) |
fe4da5cc | 887 | { |
888 | // | |
889 | // Initialize the Alice setup | |
890 | // | |
891 | ||
51e0e89d | 892 | if(fInitDone) { |
893 | Warning("Init","Cannot initialise AliRun twice!\n"); | |
894 | return; | |
895 | } | |
896 | ||
fe4da5cc | 897 | gROOT->LoadMacro(setup); |
45189757 | 898 | gInterpreter->ProcessLine(fConfigFunction.Data()); |
fe4da5cc | 899 | |
cfce8870 | 900 | gMC->DefineParticles(); //Create standard MC particles |
fe4da5cc | 901 | |
902 | TObject *objfirst, *objlast; | |
903 | ||
23370b7a | 904 | fNdets = fModules->GetLast()+1; |
905 | ||
fe4da5cc | 906 | // |
875c717b | 907 | //=================Create Materials and geometry |
908 | gMC->Init(); | |
909 | ||
8494b010 | 910 | TIter next(fModules); |
911 | AliModule *detector; | |
912 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 913 | detector->SetTreeAddress(); |
914 | objlast = gDirectory->GetList()->Last(); | |
915 | ||
fe4da5cc | 916 | // Add Detector histograms in Detector list of histograms |
917 | if (objlast) objfirst = gDirectory->GetList()->After(objlast); | |
918 | else objfirst = gDirectory->GetList()->First(); | |
919 | while (objfirst) { | |
920 | detector->Histograms()->Add(objfirst); | |
921 | objfirst = gDirectory->GetList()->After(objfirst); | |
922 | } | |
923 | } | |
924 | SetTransPar(); //Read the cuts for all materials | |
925 | ||
926 | MediaTable(); //Build the special IMEDIA table | |
927 | ||
fe4da5cc | 928 | //Initialise geometry deposition table |
875c717b | 929 | fEventEnergy.Set(gMC->NofVolumes()+1); |
930 | fSummEnergy.Set(gMC->NofVolumes()+1); | |
931 | fSum2Energy.Set(gMC->NofVolumes()+1); | |
fe4da5cc | 932 | |
fe4da5cc | 933 | //Compute cross-sections |
875c717b | 934 | gMC->BuildPhysics(); |
fe4da5cc | 935 | |
936 | //Write Geometry object to current file. | |
937 | fGeometry->Write(); | |
938 | ||
939 | fInitDone = kTRUE; | |
51e0e89d | 940 | |
941 | // | |
942 | // Save stuff at the beginning of the file to avoid file corruption | |
943 | Write(); | |
fe4da5cc | 944 | } |
945 | ||
946 | //_____________________________________________________________________________ | |
947 | void AliRun::MediaTable() | |
948 | { | |
949 | // | |
950 | // Built media table to get from the media number to | |
951 | // the detector id | |
952 | // | |
ad51aeb0 | 953 | Int_t kz, nz, idt, lz, i, k, ind; |
954 | // Int_t ibeg; | |
fe4da5cc | 955 | TObjArray &dets = *gAlice->Detectors(); |
8494b010 | 956 | AliModule *det; |
fe4da5cc | 957 | // |
958 | // For all detectors | |
959 | for (kz=0;kz<fNdets;kz++) { | |
960 | // If detector is defined | |
8494b010 | 961 | if((det=(AliModule*) dets[kz])) { |
ad51aeb0 | 962 | TArrayI &idtmed = *(det->GetIdtmed()); |
963 | for(nz=0;nz<100;nz++) { | |
fe4da5cc | 964 | // Find max and min material number |
ad51aeb0 | 965 | if((idt=idtmed[nz])) { |
fe4da5cc | 966 | det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt; |
967 | det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt; | |
968 | } | |
969 | } | |
970 | if(det->LoMedium() > det->HiMedium()) { | |
971 | det->LoMedium() = 0; | |
972 | det->HiMedium() = 0; | |
973 | } else { | |
974 | if(det->HiMedium() > fImedia->GetSize()) { | |
ad51aeb0 | 975 | Error("MediaTable","Increase fImedia from %d to %d", |
976 | fImedia->GetSize(),det->HiMedium()); | |
fe4da5cc | 977 | return; |
978 | } | |
979 | // Tag all materials in rage as belonging to detector kz | |
980 | for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) { | |
981 | (*fImedia)[lz]=kz; | |
982 | } | |
983 | } | |
984 | } | |
985 | } | |
986 | // | |
987 | // Print summary table | |
988 | printf(" Traking media ranges:\n"); | |
989 | for(i=0;i<(fNdets-1)/6+1;i++) { | |
990 | for(k=0;k< (6<fNdets-i*6?6:fNdets-i*6);k++) { | |
991 | ind=i*6+k; | |
8494b010 | 992 | det=(AliModule*)dets[ind]; |
fe4da5cc | 993 | if(det) |
994 | printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(), | |
995 | det->HiMedium()); | |
996 | else | |
997 | printf(" %6s: %3d -> %3d;","NULL",0,0); | |
998 | } | |
999 | printf("\n"); | |
1000 | } | |
1001 | } | |
1002 | ||
1003 | //____________________________________________________________________________ | |
1004 | void AliRun::SetGenerator(AliGenerator *generator) | |
ee1dd322 | 1005 | { |
1006 | // | |
1007 | // Load the event generator | |
1008 | // | |
1009 | if(!fGenerator) fGenerator = generator; | |
1010 | } | |
1011 | ||
1012 | //____________________________________________________________________________ | |
1013 | void AliRun::ResetGenerator(AliGenerator *generator) | |
fe4da5cc | 1014 | { |
1015 | // | |
1016 | // Load the event generator | |
1017 | // | |
b13db077 | 1018 | if(fGenerator) |
838edcaf | 1019 | if(generator) |
1020 | Warning("ResetGenerator","Replacing generator %s with %s\n", | |
1021 | fGenerator->GetName(),generator->GetName()); | |
1022 | else | |
1023 | Warning("ResetGenerator","Replacing generator %s with NULL\n", | |
1024 | fGenerator->GetName()); | |
b13db077 | 1025 | fGenerator = generator; |
fe4da5cc | 1026 | } |
1027 | ||
1028 | //____________________________________________________________________________ | |
1029 | void AliRun::SetTransPar(char* filename) | |
1030 | { | |
1031 | // | |
1032 | // Read filename to set the transport parameters | |
1033 | // | |
1034 | ||
fe4da5cc | 1035 | |
aee8290b | 1036 | const Int_t kncuts=10; |
1037 | const Int_t knflags=11; | |
1038 | const Int_t knpars=kncuts+knflags; | |
1039 | const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO", | |
fe4da5cc | 1040 | "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI", |
1041 | "BREM","COMP","DCAY","DRAY","HADR","LOSS", | |
1042 | "MULS","PAIR","PHOT","RAYL"}; | |
1043 | char line[256]; | |
ad51aeb0 | 1044 | char detName[7]; |
fe4da5cc | 1045 | char* filtmp; |
aee8290b | 1046 | Float_t cut[kncuts]; |
1047 | Int_t flag[knflags]; | |
fe4da5cc | 1048 | Int_t i, itmed, iret, ktmed, kz; |
1049 | FILE *lun; | |
1050 | // | |
1051 | // See whether the file is there | |
1052 | filtmp=gSystem->ExpandPathName(filename); | |
1053 | lun=fopen(filtmp,"r"); | |
1054 | delete [] filtmp; | |
1055 | if(!lun) { | |
ad51aeb0 | 1056 | Warning("SetTransPar","File %s does not exist!\n",filename); |
fe4da5cc | 1057 | return; |
1058 | } | |
1059 | // | |
1060 | printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n"); | |
1061 | printf(" *%59s\n","*"); | |
1062 | printf(" * Please check carefully what you are doing!%10s\n","*"); | |
1063 | printf(" *%59s\n","*"); | |
1064 | // | |
1065 | while(1) { | |
1066 | // Initialise cuts and flags | |
aee8290b | 1067 | for(i=0;i<kncuts;i++) cut[i]=-99; |
1068 | for(i=0;i<knflags;i++) flag[i]=-99; | |
fe4da5cc | 1069 | itmed=0; |
1070 | for(i=0;i<256;i++) line[i]='\0'; | |
1071 | // Read up to the end of line excluded | |
1072 | iret=fscanf(lun,"%[^\n]",line); | |
1073 | if(iret<0) { | |
1074 | //End of file | |
1075 | fclose(lun); | |
1076 | printf(" *%59s\n","*"); | |
1077 | printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n"); | |
1078 | return; | |
1079 | } | |
1080 | // Read the end of line | |
1081 | fscanf(lun,"%*c"); | |
1082 | if(!iret) continue; | |
1083 | if(line[0]=='*') continue; | |
1084 | // Read the numbers | |
ad51aeb0 | 1085 | 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", |
1086 | detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8], | |
1087 | &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7], | |
1088 | &flag[8],&flag[9],&flag[10]); | |
fe4da5cc | 1089 | if(!iret) continue; |
1090 | if(iret<0) { | |
1091 | //reading error | |
ad51aeb0 | 1092 | Warning("SetTransPar","Error reading file %s\n",filename); |
fe4da5cc | 1093 | continue; |
1094 | } | |
ad51aeb0 | 1095 | // Check that the module exist |
1096 | AliModule *mod = GetModule(detName); | |
1097 | if(mod) { | |
1098 | // Get the array of media numbers | |
1099 | TArrayI &idtmed = *mod->GetIdtmed(); | |
1100 | // Check that the tracking medium code is valid | |
1101 | if(0<=itmed && itmed < 100) { | |
1102 | ktmed=idtmed[itmed]; | |
1103 | if(!ktmed) { | |
1104 | Warning("SetTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName()); | |
1105 | continue; | |
fe4da5cc | 1106 | } |
ad51aeb0 | 1107 | // Set energy thresholds |
aee8290b | 1108 | for(kz=0;kz<kncuts;kz++) { |
ad51aeb0 | 1109 | if(cut[kz]>=0) { |
23370b7a | 1110 | printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n", |
aee8290b | 1111 | kpars[kz],cut[kz],itmed,mod->GetName()); |
1112 | gMC->Gstpar(ktmed,kpars[kz],cut[kz]); | |
ad51aeb0 | 1113 | } |
fe4da5cc | 1114 | } |
ad51aeb0 | 1115 | // Set transport mechanisms |
aee8290b | 1116 | for(kz=0;kz<knflags;kz++) { |
ad51aeb0 | 1117 | if(flag[kz]>=0) { |
1118 | printf(" * %-6s set to %10d for tracking medium code %4d for %s\n", | |
aee8290b | 1119 | kpars[kncuts+kz],flag[kz],itmed,mod->GetName()); |
1120 | gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz])); | |
ad51aeb0 | 1121 | } |
1122 | } | |
1123 | } else { | |
1124 | Warning("SetTransPar","Invalid medium code %d *\n",itmed); | |
1125 | continue; | |
fe4da5cc | 1126 | } |
1127 | } else { | |
ad51aeb0 | 1128 | Warning("SetTransPar","Module %s not present\n",detName); |
fe4da5cc | 1129 | continue; |
1130 | } | |
1131 | } | |
1132 | } | |
1133 | ||
1134 | //_____________________________________________________________________________ | |
1135 | void AliRun::MakeTree(Option_t *option) | |
1136 | { | |
1137 | // | |
1138 | // Create the ROOT trees | |
1139 | // Loop on all detectors to create the Root branch (if any) | |
1140 | // | |
1141 | ||
b13db077 | 1142 | char hname[30]; |
fe4da5cc | 1143 | // |
1144 | // Analyse options | |
aee8290b | 1145 | char *oK = strstr(option,"K"); |
1146 | char *oH = strstr(option,"H"); | |
1147 | char *oE = strstr(option,"E"); | |
1148 | char *oD = strstr(option,"D"); | |
1149 | char *oR = strstr(option,"R"); | |
fe4da5cc | 1150 | // |
aee8290b | 1151 | if (oK && !fTreeK) { |
b13db077 | 1152 | sprintf(hname,"TreeK%d",fEvent); |
1153 | fTreeK = new TTree(hname,"Kinematics"); | |
1154 | // Create a branch for particles | |
1155 | fTreeK->Branch("Particles",&fParticles,4000); | |
51e0e89d | 1156 | fTreeK->Write(); |
b13db077 | 1157 | } |
aee8290b | 1158 | if (oH && !fTreeH) { |
b13db077 | 1159 | sprintf(hname,"TreeH%d",fEvent); |
1160 | fTreeH = new TTree(hname,"Hits"); | |
1161 | fTreeH->SetAutoSave(1000000000); //no autosave | |
51e0e89d | 1162 | fTreeH->Write(); |
b13db077 | 1163 | } |
aee8290b | 1164 | if (oD && !fTreeD) { |
b13db077 | 1165 | sprintf(hname,"TreeD%d",fEvent); |
1166 | fTreeD = new TTree(hname,"Digits"); | |
51e0e89d | 1167 | fTreeD->Write(); |
b13db077 | 1168 | } |
aee8290b | 1169 | if (oR && !fTreeR) { |
b13db077 | 1170 | sprintf(hname,"TreeR%d",fEvent); |
1171 | fTreeR = new TTree(hname,"Reconstruction"); | |
51e0e89d | 1172 | fTreeR->Write(); |
b13db077 | 1173 | } |
aee8290b | 1174 | if (oE && !fTreeE) { |
b13db077 | 1175 | fTreeE = new TTree("TE","Header"); |
1176 | // Create a branch for Header | |
aee8290b | 1177 | fTreeE->Branch("Header","AliHeader",&gAliHeader,4000); |
51e0e89d | 1178 | fTreeE->Write(); |
b13db077 | 1179 | } |
fe4da5cc | 1180 | // |
1181 | // Create a branch for hits/digits for each detector | |
1182 | // Each branch is a TClonesArray. Each data member of the Hits classes | |
1183 | // will be in turn a subbranch of the detector master branch | |
8494b010 | 1184 | TIter next(fModules); |
1185 | AliModule *detector; | |
1186 | while((detector = (AliModule*)next())) { | |
aee8290b | 1187 | if (oH || oD || oR) detector->MakeBranch(option); |
fe4da5cc | 1188 | } |
fe4da5cc | 1189 | } |
1190 | ||
1191 | //_____________________________________________________________________________ | |
1192 | Int_t AliRun::PurifyKine(Int_t lastSavedTrack, Int_t nofTracks) | |
1193 | { | |
1194 | // | |
1195 | // PurifyKine with external parameters | |
1196 | // | |
1197 | fHgwmk = lastSavedTrack; | |
1198 | fNtrack = nofTracks; | |
1199 | PurifyKine(); | |
1200 | return fHgwmk; | |
1201 | } | |
1202 | ||
1203 | //_____________________________________________________________________________ | |
1204 | void AliRun::PurifyKine() | |
1205 | { | |
1206 | // | |
1207 | // Compress kinematic tree keeping only flagged particles | |
1208 | // and renaming the particle id's in all the hits | |
1209 | // | |
1210 | TClonesArray &particles = *fParticles; | |
1211 | int nkeep=fHgwmk+1, parent, i; | |
1578254f | 1212 | TParticle *part, *partnew, *father; |
fe4da5cc | 1213 | int *map = new int[particles.GetEntries()]; |
1214 | ||
1215 | // Save in Header total number of tracks before compression | |
1216 | fHeader.SetNtrack(fHeader.GetNtrack()+fNtrack-fHgwmk); | |
1217 | ||
a01a8b12 | 1218 | // First pass, invalid Daughter information |
fe4da5cc | 1219 | for(i=0; i<fNtrack; i++) { |
a01a8b12 | 1220 | // Preset map, to be removed later |
1221 | if(i<=fHgwmk) map[i]=i ; else map[i] = -99; | |
aee8290b | 1222 | ((TParticle *)particles.UncheckedAt(i))->ResetBit(kDaughtersBit); |
a01a8b12 | 1223 | } |
fe4da5cc | 1224 | // Second pass, build map between old and new numbering |
1225 | for(i=fHgwmk+1; i<fNtrack; i++) { | |
1578254f | 1226 | part = (TParticle *)particles.UncheckedAt(i); |
aee8290b | 1227 | if(part->TestBit(kKeepBit)) { |
fe4da5cc | 1228 | |
1229 | // This particle has to be kept | |
1230 | map[i]=nkeep; | |
1231 | if(i!=nkeep) { | |
1232 | ||
1233 | // Old and new are different, have to copy | |
1578254f | 1234 | partnew = (TParticle *)particles.UncheckedAt(nkeep); |
5eb58812 | 1235 | // Change due to a bug in the HP compiler |
1236 | // *partnew = *part; | |
1237 | memcpy(partnew,part,sizeof(TParticle)); | |
fe4da5cc | 1238 | } else partnew = part; |
1239 | ||
1240 | // as the parent is always *before*, it must be already | |
1241 | // in place. This is what we are checking anyway! | |
1578254f | 1242 | if((parent=partnew->GetFirstMother())>fHgwmk) { |
fe4da5cc | 1243 | if(map[parent]==-99) printf("map[%d] = -99!\n",parent); |
1578254f | 1244 | partnew->SetFirstMother(map[parent]); |
fe4da5cc | 1245 | } |
1246 | nkeep++; | |
1247 | } | |
1248 | } | |
1249 | fNtrack=nkeep; | |
1250 | ||
1578254f | 1251 | // Fix daughters information |
ae23d366 | 1252 | for (i=0; i<fNtrack; i++) { |
1578254f | 1253 | part = (TParticle *)particles.UncheckedAt(i); |
1254 | parent = part->GetFirstMother(); | |
ae23d366 | 1255 | if(parent>=0) { |
1256 | father = (TParticle *)particles.UncheckedAt(parent); | |
aee8290b | 1257 | if(father->TestBit(kDaughtersBit)) { |
fe4da5cc | 1258 | |
ae23d366 | 1259 | if(i<father->GetFirstDaughter()) father->SetFirstDaughter(i); |
1260 | if(i>father->GetLastDaughter()) father->SetLastDaughter(i); | |
1261 | } else { | |
1262 | // Iitialise daughters info for first pass | |
1263 | father->SetFirstDaughter(i); | |
1264 | father->SetLastDaughter(i); | |
aee8290b | 1265 | father->SetBit(kDaughtersBit); |
ae23d366 | 1266 | } |
fe4da5cc | 1267 | } |
1268 | } | |
1269 | ||
1cedd08a | 1270 | #ifdef old |
fe4da5cc | 1271 | // Now loop on all detectors and reset the hits |
b13db077 | 1272 | AliHit *OneHit; |
8494b010 | 1273 | TIter next(fModules); |
1274 | AliModule *detector; | |
1275 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 1276 | if (!detector->Hits()) continue; |
1277 | TClonesArray &vHits=*(detector->Hits()); | |
1278 | if(vHits.GetEntries() != detector->GetNhits()) | |
1279 | printf("vHits.GetEntries()!=detector->GetNhits(): %d != %d\n", | |
1280 | vHits.GetEntries(),detector->GetNhits()); | |
1281 | for (i=0; i<detector->GetNhits(); i++) { | |
1282 | OneHit = (AliHit *)vHits.UncheckedAt(i); | |
1283 | OneHit->SetTrack(map[OneHit->GetTrack()]); | |
1284 | } | |
1285 | } | |
1cedd08a | 1286 | #else |
1287 | ||
1288 | // Now loop on all registered hit lists | |
1289 | TIter next(fHitLists); | |
1290 | TCollection *hitList; | |
1291 | while((hitList = (TCollection*)next())) { | |
1292 | TIter nexthit(hitList); | |
1293 | AliHit *hit; | |
1294 | while((hit = (AliHit*)nexthit())) { | |
1295 | hit->SetTrack(map[hit->GetTrack()]); | |
1296 | } | |
1297 | } | |
1298 | #endif | |
fe4da5cc | 1299 | |
24de2263 | 1300 | // |
1301 | // This for detectors which have a special mapping mechanism | |
1302 | // for hits, such as TPC and TRD | |
1303 | // | |
1304 | ||
1305 | TIter nextmod(fModules); | |
1306 | AliModule *detector; | |
1307 | while((detector = (AliModule*)nextmod())) { | |
1308 | detector->RemapTrackHitIDs(map); | |
1309 | } | |
1310 | ||
1311 | ||
fe4da5cc | 1312 | fHgwmk=nkeep-1; |
1313 | particles.SetLast(fHgwmk); | |
1314 | delete [] map; | |
1315 | } | |
1316 | ||
1317 | //_____________________________________________________________________________ | |
dffd31ef | 1318 | void AliRun::BeginEvent() |
fe4da5cc | 1319 | { |
1320 | // | |
1321 | // Reset all Detectors & kinematics & trees | |
1322 | // | |
59fe9bd2 | 1323 | char hname[30]; |
dffd31ef | 1324 | // |
1325 | ||
1326 | // | |
1327 | if(fLego) { | |
1328 | fLego->BeginEvent(); | |
1329 | return; | |
1330 | } | |
1331 | ||
59fe9bd2 | 1332 | // |
fe4da5cc | 1333 | ResetStack(); |
1334 | ResetHits(); | |
1335 | ResetDigits(); | |
1336 | ||
1337 | // Initialise event header | |
875c717b | 1338 | fHeader.Reset(fRun,fEvent); |
fe4da5cc | 1339 | |
59fe9bd2 | 1340 | if(fTreeK) { |
1341 | fTreeK->Reset(); | |
875c717b | 1342 | sprintf(hname,"TreeK%d",fEvent); |
59fe9bd2 | 1343 | fTreeK->SetName(hname); |
1344 | } | |
1345 | if(fTreeH) { | |
1346 | fTreeH->Reset(); | |
875c717b | 1347 | sprintf(hname,"TreeH%d",fEvent); |
59fe9bd2 | 1348 | fTreeH->SetName(hname); |
1349 | } | |
1350 | if(fTreeD) { | |
1351 | fTreeD->Reset(); | |
875c717b | 1352 | sprintf(hname,"TreeD%d",fEvent); |
59fe9bd2 | 1353 | fTreeD->SetName(hname); |
1354 | } | |
1355 | if(fTreeR) { | |
1356 | fTreeR->Reset(); | |
875c717b | 1357 | sprintf(hname,"TreeR%d",fEvent); |
59fe9bd2 | 1358 | fTreeR->SetName(hname); |
1359 | } | |
fe4da5cc | 1360 | } |
1361 | ||
1362 | //_____________________________________________________________________________ | |
1363 | void AliRun::ResetDigits() | |
1364 | { | |
1365 | // | |
1366 | // Reset all Detectors digits | |
1367 | // | |
8494b010 | 1368 | TIter next(fModules); |
1369 | AliModule *detector; | |
1370 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 1371 | detector->ResetDigits(); |
1372 | } | |
1373 | } | |
1374 | ||
1375 | //_____________________________________________________________________________ | |
1376 | void AliRun::ResetHits() | |
1377 | { | |
1378 | // | |
1379 | // Reset all Detectors hits | |
1380 | // | |
8494b010 | 1381 | TIter next(fModules); |
1382 | AliModule *detector; | |
1383 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 1384 | detector->ResetHits(); |
1385 | } | |
1386 | } | |
1387 | ||
1388 | //_____________________________________________________________________________ | |
1389 | void AliRun::ResetPoints() | |
1390 | { | |
1391 | // | |
1392 | // Reset all Detectors points | |
1393 | // | |
8494b010 | 1394 | TIter next(fModules); |
1395 | AliModule *detector; | |
1396 | while((detector = (AliModule*)next())) { | |
fe4da5cc | 1397 | detector->ResetPoints(); |
1398 | } | |
1399 | } | |
1400 | ||
1401 | //_____________________________________________________________________________ | |
875c717b | 1402 | void AliRun::RunMC(Int_t nevent, const char *setup) |
fe4da5cc | 1403 | { |
1404 | // | |
1405 | // Main function to be called to process a galice run | |
1406 | // example | |
1407 | // Root > gAlice.Run(); | |
1408 | // a positive number of events will cause the finish routine | |
1409 | // to be called | |
1410 | // | |
1411 | ||
fe4da5cc | 1412 | // check if initialisation has been done |
875c717b | 1413 | if (!fInitDone) InitMC(setup); |
fe4da5cc | 1414 | |
fe4da5cc | 1415 | // Create the Root Tree with one branch per detector |
80762cb1 | 1416 | MakeTree("KHDER"); |
fe4da5cc | 1417 | |
875c717b | 1418 | gMC->ProcessRun(nevent); |
1419 | ||
fe4da5cc | 1420 | // End of this run, close files |
80762cb1 | 1421 | if(nevent>0) FinishRun(); |
fe4da5cc | 1422 | } |
1423 | ||
1424 | //_____________________________________________________________________________ | |
0a520a66 | 1425 | void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min, |
1426 | Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max, | |
1427 | Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener) | |
fe4da5cc | 1428 | { |
1429 | // | |
1430 | // Generates lego plots of: | |
1431 | // - radiation length map phi vs theta | |
1432 | // - radiation length map phi vs eta | |
1433 | // - interaction length map | |
1434 | // - g/cm2 length map | |
1435 | // | |
1436 | // ntheta bins in theta, eta | |
1437 | // themin minimum angle in theta (degrees) | |
1438 | // themax maximum angle in theta (degrees) | |
1439 | // nphi bins in phi | |
1440 | // phimin minimum angle in phi (degrees) | |
1441 | // phimax maximum angle in phi (degrees) | |
1442 | // rmin minimum radius | |
1443 | // rmax maximum radius | |
1444 | // | |
1445 | // | |
1446 | // The number of events generated = ntheta*nphi | |
1447 | // run input parameters in macro setup (default="Config.C") | |
1448 | // | |
1449 | // Use macro "lego.C" to visualize the 3 lego plots in spherical coordinates | |
1450 | //Begin_Html | |
1451 | /* | |
1439f98e | 1452 | <img src="picts/AliRunLego1.gif"> |
fe4da5cc | 1453 | */ |
1454 | //End_Html | |
1455 | //Begin_Html | |
1456 | /* | |
1439f98e | 1457 | <img src="picts/AliRunLego2.gif"> |
fe4da5cc | 1458 | */ |
1459 | //End_Html | |
1460 | //Begin_Html | |
1461 | /* | |
1439f98e | 1462 | <img src="picts/AliRunLego3.gif"> |
fe4da5cc | 1463 | */ |
1464 | //End_Html | |
1465 | // | |
1466 | ||
1467 | // check if initialisation has been done | |
875c717b | 1468 | if (!fInitDone) InitMC(setup); |
838edcaf | 1469 | //Save current generator |
1470 | AliGenerator *gen=Generator(); | |
1471 | ||
0a520a66 | 1472 | // Set new generator |
1473 | if (!gener) gener = new AliLegoGenerator(); | |
1474 | ResetGenerator(gener); | |
1475 | // | |
1476 | // Configure Generator | |
1477 | gener->SetRadiusRange(rmin, rmax); | |
1478 | gener->SetZMax(zmax); | |
1479 | gener->SetCoor1Range(nc1, c1min, c1max); | |
1480 | gener->SetCoor2Range(nc2, c2min, c2max); | |
1481 | ||
1482 | ||
b13db077 | 1483 | //Create Lego object |
0a520a66 | 1484 | fLego = new AliLego("lego",gener); |
b13db077 | 1485 | |
dffd31ef | 1486 | //Prepare MC for Lego Run |
1487 | gMC->InitLego(); | |
1488 | ||
b13db077 | 1489 | //Run Lego Object |
0a520a66 | 1490 | |
1491 | gMC->ProcessRun(nc1*nc2+1); | |
fe4da5cc | 1492 | |
1493 | // Create only the Root event Tree | |
80762cb1 | 1494 | MakeTree("E"); |
fe4da5cc | 1495 | |
1496 | // End of this run, close files | |
80762cb1 | 1497 | FinishRun(); |
0a520a66 | 1498 | // Restore current generator |
1499 | ResetGenerator(gen); | |
838edcaf | 1500 | // Delete Lego Object |
1501 | delete fLego; fLego=0; | |
fe4da5cc | 1502 | } |
1503 | ||
94de3818 | 1504 | //_____________________________________________________________________________ |
1505 | void AliRun::SetConfigFunction(const char * config) | |
1506 | { | |
1507 | // | |
1508 | // Set the signature of the function contained in Config.C to configure | |
1509 | // the run | |
1510 | // | |
1511 | fConfigFunction=config; | |
1512 | } | |
1513 | ||
fe4da5cc | 1514 | //_____________________________________________________________________________ |
1515 | void AliRun::SetCurrentTrack(Int_t track) | |
1516 | { | |
1517 | // | |
1518 | // Set current track number | |
1519 | // | |
1520 | fCurrent = track; | |
1521 | } | |
1522 | ||
1523 | //_____________________________________________________________________________ | |
1578254f | 1524 | void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom, |
fe4da5cc | 1525 | Float_t *vpos, Float_t *polar, Float_t tof, |
8918e700 | 1526 | const char* /* mecha */, Int_t &ntr, Float_t weight) |
fe4da5cc | 1527 | { |
1528 | // | |
1529 | // Load a track on the stack | |
1530 | // | |
1531 | // done 0 if the track has to be transported | |
1532 | // 1 if not | |
1533 | // parent identifier of the parent track. -1 for a primary | |
1578254f | 1534 | // pdg particle code |
fe4da5cc | 1535 | // pmom momentum GeV/c |
1536 | // vpos position | |
1537 | // polar polarisation | |
1538 | // tof time of flight in seconds | |
1539 | // mecha production mechanism | |
1540 | // ntr on output the number of the track stored | |
1541 | // | |
1542 | TClonesArray &particles = *fParticles; | |
1578254f | 1543 | TParticle *particle; |
fe4da5cc | 1544 | Float_t mass; |
aee8290b | 1545 | const Int_t kfirstdaughter=-1; |
1546 | const Int_t klastdaughter=-1; | |
1547 | const Int_t kS=0; | |
1578254f | 1548 | // const Float_t tlife=0; |
fe4da5cc | 1549 | |
1578254f | 1550 | // |
1551 | // Here we get the static mass | |
1552 | // For MC is ok, but a more sophisticated method could be necessary | |
1553 | // if the calculated mass is required | |
1554 | // also, this method is potentially dangerous if the mass | |
1555 | // used in the MC is not the same of the PDG database | |
1556 | // | |
1557 | mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass(); | |
fe4da5cc | 1558 | Float_t e=TMath::Sqrt(mass*mass+pmom[0]*pmom[0]+ |
1559 | pmom[1]*pmom[1]+pmom[2]*pmom[2]); | |
1560 | ||
aee8290b | 1561 | //printf("Loading particle %s mass %f ene %f No %d ip %d pos %f %f %f mom %f %f %f kS %d m %s\n", |
1562 | //pname,mass,e,fNtrack,pdg,vpos[0],vpos[1],vpos[2],pmom[0],pmom[1],pmom[2],kS,mecha); | |
fe4da5cc | 1563 | |
aee8290b | 1564 | particle=new(particles[fNtrack]) TParticle(pdg,kS,parent,-1,kfirstdaughter, |
1565 | klastdaughter,pmom[0],pmom[1],pmom[2], | |
1578254f | 1566 | e,vpos[0],vpos[1],vpos[2],tof); |
1567 | // polar[0],polar[1],polar[2],tof, | |
1568 | // mecha,weight); | |
1569 | ((TParticle*)particles[fNtrack])->SetPolarisation(TVector3(polar[0],polar[1],polar[2])); | |
1570 | ((TParticle*)particles[fNtrack])->SetWeight(weight); | |
aee8290b | 1571 | if(!done) particle->SetBit(kDoneBit); |
a01a8b12 | 1572 | //Declare that the daughter information is valid |
aee8290b | 1573 | ((TParticle*)particles[fNtrack])->SetBit(kDaughtersBit); |
fe4da5cc | 1574 | |
1575 | if(parent>=0) { | |
1578254f | 1576 | particle=(TParticle*) fParticles->UncheckedAt(parent); |
1577 | particle->SetLastDaughter(fNtrack); | |
1578 | if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack); | |
fe4da5cc | 1579 | } else { |
1580 | // | |
1581 | // This is a primary track. Set high water mark for this event | |
1582 | fHgwmk=fNtrack; | |
1583 | // | |
1584 | // Set also number if primary tracks | |
1585 | fHeader.SetNprimary(fHgwmk+1); | |
1586 | fHeader.SetNtrack(fHgwmk+1); | |
1587 | } | |
1588 | ntr = fNtrack++; | |
1589 | } | |
1590 | ||
1591 | //_____________________________________________________________________________ | |
1592 | void AliRun::KeepTrack(const Int_t track) | |
1593 | { | |
1594 | // | |
1595 | // flags a track to be kept | |
1596 | // | |
1597 | TClonesArray &particles = *fParticles; | |
aee8290b | 1598 | ((TParticle*)particles[track])->SetBit(kKeepBit); |
fe4da5cc | 1599 | } |
1600 | ||
1601 | //_____________________________________________________________________________ | |
875c717b | 1602 | void AliRun::StepManager(Int_t id) |
fe4da5cc | 1603 | { |
1604 | // | |
1605 | // Called at every step during transport | |
1606 | // | |
1607 | ||
fe4da5cc | 1608 | // |
1609 | // --- If lego option, do it and leave | |
b13db077 | 1610 | if (fLego) |
fe4da5cc | 1611 | fLego->StepManager(); |
b13db077 | 1612 | else { |
1613 | Int_t copy; | |
1614 | //Update energy deposition tables | |
875c717b | 1615 | AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep()); |
fe4da5cc | 1616 | |
b13db077 | 1617 | //Call the appropriate stepping routine; |
1618 | AliModule *det = (AliModule*)fModules->At(id); | |
1619 | if(det) det->StepManager(); | |
fe4da5cc | 1620 | } |
fe4da5cc | 1621 | } |
1622 | ||
fe4da5cc | 1623 | //_____________________________________________________________________________ |
1624 | void AliRun::Streamer(TBuffer &R__b) | |
1625 | { | |
1626 | // | |
1627 | // Stream an object of class AliRun. | |
1628 | // | |
1629 | if (R__b.IsReading()) { | |
1630 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
1631 | TNamed::Streamer(R__b); | |
1632 | if (!gAlice) gAlice = this; | |
1633 | gROOT->GetListOfBrowsables()->Add(this,"Run"); | |
59fe9bd2 | 1634 | fTreeE = (TTree*)gDirectory->Get("TE"); |
aee8290b | 1635 | if (fTreeE) fTreeE->SetBranchAddress("Header", &gAliHeader); |
59fe9bd2 | 1636 | else Error("Streamer","cannot find Header Tree\n"); |
fe4da5cc | 1637 | R__b >> fNtrack; |
1638 | R__b >> fHgwmk; | |
1639 | R__b >> fDebug; | |
1640 | fHeader.Streamer(R__b); | |
8494b010 | 1641 | R__b >> fModules; |
fe4da5cc | 1642 | R__b >> fParticles; |
1643 | R__b >> fField; | |
875c717b | 1644 | // R__b >> fMC; |
fe4da5cc | 1645 | R__b >> fNdets; |
1646 | R__b >> fTrRmax; | |
1647 | R__b >> fTrZmax; | |
1648 | R__b >> fGenerator; | |
59fe9bd2 | 1649 | if(R__v>1) { |
1650 | R__b >> fPDGDB; //Particle factory object! | |
1651 | fTreeE->GetEntry(0); | |
1652 | } else { | |
1653 | fHeader.SetEvent(0); | |
1654 | fPDGDB = TDatabasePDG::Instance(); //Particle factory object! | |
1655 | } | |
45189757 | 1656 | if(R__v>2) { |
1657 | fConfigFunction.Streamer(R__b); | |
1658 | } else { | |
1659 | fConfigFunction="Config();"; | |
1660 | } | |
fe4da5cc | 1661 | } else { |
1662 | R__b.WriteVersion(AliRun::IsA()); | |
1663 | TNamed::Streamer(R__b); | |
1664 | R__b << fNtrack; | |
1665 | R__b << fHgwmk; | |
1666 | R__b << fDebug; | |
1667 | fHeader.Streamer(R__b); | |
8494b010 | 1668 | R__b << fModules; |
fe4da5cc | 1669 | R__b << fParticles; |
1670 | R__b << fField; | |
875c717b | 1671 | // R__b << fMC; |
fe4da5cc | 1672 | R__b << fNdets; |
1673 | R__b << fTrRmax; | |
1674 | R__b << fTrZmax; | |
1675 | R__b << fGenerator; | |
1578254f | 1676 | R__b << fPDGDB; //Particle factory object! |
45189757 | 1677 | fConfigFunction.Streamer(R__b); |
fe4da5cc | 1678 | } |
1679 | } |