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