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