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