]>
Commit | Line | Data |
---|---|---|
99d554c8 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
acd84897 | 16 | /* $Id$ */ |
99d554c8 | 17 | |
fe4da5cc | 18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Control class for Alice C++ // | |
21 | // Only one single instance of this class exists. // | |
22 | // The object is created in main program aliroot // | |
23 | // and is pointed by the global gAlice. // | |
24 | // // | |
8494b010 | 25 | // -Supports the list of all Alice Detectors (fModules). // |
fe4da5cc | 26 | // -Supports the list of particles (fParticles). // |
27 | // -Supports the Trees. // | |
28 | // -Supports the geometry. // | |
29 | // -Supports the event display. // | |
30 | //Begin_Html | |
31 | /* | |
1439f98e | 32 | <img src="picts/AliRunClass.gif"> |
fe4da5cc | 33 | */ |
34 | //End_Html | |
35 | //Begin_Html | |
36 | /* | |
1439f98e | 37 | <img src="picts/alirun.gif"> |
fe4da5cc | 38 | */ |
39 | //End_Html | |
40 | // // | |
41 | /////////////////////////////////////////////////////////////////////////////// | |
42 | ||
88cb7938 | 43 | #include <TBRIK.h> |
88cb7938 | 44 | #include <TCint.h> |
5d12ce38 | 45 | #include <TDatabasePDG.h> |
88cb7938 | 46 | #include <TGeometry.h> |
88cb7938 | 47 | #include <TROOT.h> |
88cb7938 | 48 | #include <TRandom3.h> |
49 | #include <TSystem.h> | |
88cb7938 | 50 | #include <TVirtualMC.h> |
178a256c | 51 | #include <TGeoManager.h> |
5d12ce38 | 52 | // |
21bf7095 | 53 | #include "AliLog.h" |
98490ea9 | 54 | #include "AliDetector.h" |
98490ea9 | 55 | #include "AliHeader.h" |
dffd31ef | 56 | #include "AliLego.h" |
98490ea9 | 57 | #include "AliLegoGenerator.h" |
5d12ce38 | 58 | #include "AliMC.h" |
aee8290b | 59 | #include "AliMagFC.h" |
60 | #include "AliMagFCM.h" | |
61 | #include "AliMagFDM.h" | |
141f90e3 | 62 | #include "AliPDG.h" |
98490ea9 | 63 | #include "AliRun.h" |
64 | #include "AliStack.h" | |
b3276c04 | 65 | #include "AliCDBManager.h" |
995ad051 | 66 | #include "AliAlignObj.h" |
fe4da5cc | 67 | |
fe4da5cc | 68 | AliRun *gAlice; |
69 | ||
fe4da5cc | 70 | ClassImp(AliRun) |
71 | ||
e2afb3b6 | 72 | //_______________________________________________________________________ |
73 | AliRun::AliRun(): | |
3d45e923 | 74 | fRun(-1), |
e2afb3b6 | 75 | fEvent(0), |
76 | fEventNrInRun(0), | |
77 | fEventsPerRun(0), | |
e2afb3b6 | 78 | fModules(0), |
5d12ce38 | 79 | fMCApp(0), |
e2afb3b6 | 80 | fField(0), |
e2afb3b6 | 81 | fNdets(0), |
e2afb3b6 | 82 | fInitDone(kFALSE), |
83 | fLego(0), | |
84 | fPDGDB(0), //Particle factory object | |
4539539b | 85 | fConfigFunction(""), |
e2afb3b6 | 86 | fRandom(0), |
fe12e09c | 87 | fBaseFileName(""), |
4a9de4af | 88 | fIsRootGeometry(kFALSE), |
ced249e6 | 89 | fGeometryFromCDB(kFALSE), |
4539539b | 90 | fGeometryFileName(""), |
91 | fTriggerDescriptor(""), | |
5d12ce38 | 92 | fRunLoader(0x0) |
fe4da5cc | 93 | { |
94 | // | |
95 | // Default constructor for AliRun | |
96 | // | |
88cb7938 | 97 | AliConfig::Instance();//skowron 29 Feb 2002 |
98 | //ensures that the folder structure is build | |
3d45e923 | 99 | |
e2afb3b6 | 100 | } |
101 | ||
fe4da5cc | 102 | //_____________________________________________________________________________ |
e2afb3b6 | 103 | AliRun::AliRun(const char *name, const char *title): |
5d12ce38 | 104 | TNamed(name,title), |
3d45e923 | 105 | fRun(-1), |
e2afb3b6 | 106 | fEvent(0), |
107 | fEventNrInRun(0), | |
108 | fEventsPerRun(0), | |
e2afb3b6 | 109 | fModules(new TObjArray(77)), // Support list for the Detectors |
5d12ce38 | 110 | fMCApp(0), |
e2afb3b6 | 111 | fField(0), |
e2afb3b6 | 112 | fNdets(0), |
e2afb3b6 | 113 | fInitDone(kFALSE), |
114 | fLego(0), | |
115 | fPDGDB(TDatabasePDG::Instance()), //Particle factory object! | |
e2afb3b6 | 116 | fConfigFunction("Config();"), |
117 | fRandom(new TRandom3()), | |
fe12e09c | 118 | fBaseFileName(""), |
4a9de4af | 119 | fIsRootGeometry(kFALSE), |
ced249e6 | 120 | fGeometryFromCDB(kFALSE), |
4539539b | 121 | fGeometryFileName(""), |
122 | fTriggerDescriptor(""), | |
b60e0f5e | 123 | fRunLoader(0x0) |
fe4da5cc | 124 | { |
125 | // | |
126 | // Constructor for the main processor. | |
127 | // Creates the geometry | |
128 | // Creates the list of Detectors. | |
129 | // Creates the list of particles. | |
130 | // | |
e2afb3b6 | 131 | |
fe4da5cc | 132 | gAlice = this; |
65fb704d | 133 | |
134 | // Set random number generator | |
e2afb3b6 | 135 | gRandom = fRandom; |
2ab0c725 | 136 | |
137 | if (gSystem->Getenv("CONFIG_SEED")) { | |
e2afb3b6 | 138 | gRandom->SetSeed(static_cast<UInt_t>(atoi(gSystem->Getenv("CONFIG_SEED")))); |
2ab0c725 | 139 | } |
e2afb3b6 | 140 | |
141 | // Add to list of browsable | |
fe4da5cc | 142 | gROOT->GetListOfBrowsables()->Add(this,name); |
fe4da5cc | 143 | |
fe4da5cc | 144 | // Create default mag field |
145 | SetField(); | |
e2afb3b6 | 146 | |
e2afb3b6 | 147 | // Add particle list to configuration |
9e1a0ddb | 148 | AliConfig::Instance()->Add(fPDGDB); |
e2afb3b6 | 149 | |
fe4da5cc | 150 | } |
151 | ||
aee8290b | 152 | |
e2afb3b6 | 153 | //_______________________________________________________________________ |
fe4da5cc | 154 | AliRun::~AliRun() |
155 | { | |
156 | // | |
2ab0c725 | 157 | // Default AliRun destructor |
fe4da5cc | 158 | // |
88cb7938 | 159 | gROOT->GetListOfBrowsables()->Remove(this); |
160 | ||
161 | if (fRunLoader) | |
162 | { | |
163 | TFolder* evfold = fRunLoader->GetEventFolder(); | |
164 | TFolder* modfold = dynamic_cast<TFolder*>(evfold->FindObjectAny(AliConfig::GetModulesFolderName())); | |
165 | TIter next(fModules); | |
166 | AliModule *mod; | |
167 | while((mod = (AliModule*)next())) | |
168 | { | |
169 | modfold->Remove(mod); | |
170 | } | |
171 | } | |
5d12ce38 | 172 | |
173 | ||
fe4da5cc | 174 | delete fField; |
5d12ce38 | 175 | delete fMCApp; |
f5bc1485 | 176 | delete gMC; gMC=0; |
fe4da5cc | 177 | delete fLego; |
8494b010 | 178 | if (fModules) { |
179 | fModules->Delete(); | |
180 | delete fModules; | |
fe4da5cc | 181 | } |
88cb7938 | 182 | |
c222d2b0 | 183 | delete fPDGDB; |
fe4da5cc | 184 | } |
185 | ||
e2afb3b6 | 186 | //_______________________________________________________________________ |
5d12ce38 | 187 | void AliRun::ResetHits() |
fe4da5cc | 188 | { |
5d12ce38 | 189 | fMCApp->ResetHits(); |
fe4da5cc | 190 | } |
191 | ||
e2afb3b6 | 192 | //_______________________________________________________________________ |
5d12ce38 | 193 | AliGenerator* AliRun::Generator() const |
fe4da5cc | 194 | { |
5d12ce38 | 195 | return fMCApp->Generator(); |
fe4da5cc | 196 | } |
197 | ||
e2afb3b6 | 198 | //_______________________________________________________________________ |
d8408e76 | 199 | void AliRun::SetField(AliMagF* magField) |
200 | { | |
2057aecb | 201 | // |
202 | // Set Magnetic Field Map | |
203 | // | |
204 | fField = magField; | |
205 | fField->ReadField(); | |
d8408e76 | 206 | } |
207 | ||
4a9de4af | 208 | //_______________________________________________________________________ |
209 | void AliRun::SetRootGeometry(Bool_t flag) | |
210 | { | |
211 | // Instruct application that the geometry is to be retreived from a root file. | |
212 | fIsRootGeometry = flag; | |
e8572077 | 213 | if (flag && gMC) gMC->SetRootGeometry(); |
4a9de4af | 214 | } |
ced249e6 | 215 | |
216 | //_______________________________________________________________________ | |
217 | void AliRun::SetGeometryFromCDB() | |
218 | { | |
219 | // Set the loading of geometry from cdb instead of creating it | |
220 | // A default CDB storage needs to be set before this method is called | |
3d45e923 | 221 | if(AliCDBManager::Instance()->IsDefaultStorageSet() && |
222 | AliCDBManager::Instance()->GetRun() >= 0){ | |
ced249e6 | 223 | SetRootGeometry(); |
224 | fGeometryFromCDB = kTRUE; | |
225 | }else{ | |
226 | AliError("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
227 | AliError("Loading of geometry from CDB ignored. First set a default CDB storage!"); | |
228 | AliError("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
229 | } | |
230 | } | |
231 | ||
e2afb3b6 | 232 | //_______________________________________________________________________ |
fe4da5cc | 233 | void AliRun::SetField(Int_t type, Int_t version, Float_t scale, |
07c4aae4 | 234 | Float_t maxField, const char* filename) |
fe4da5cc | 235 | { |
236 | // | |
237 | // Set magnetic field parameters | |
238 | // type Magnetic field transport flag 0=no field, 2=helix, 3=Runge Kutta | |
239 | // version Magnetic field map version (only 1 active now) | |
240 | // scale Scale factor for the magnetic field | |
241 | // maxField Maximum value for the magnetic field | |
242 | ||
243 | // | |
244 | // --- Sanity check on mag field flags | |
fe4da5cc | 245 | if(fField) delete fField; |
246 | if(version==1) { | |
d8408e76 | 247 | fField = new AliMagFC("Map1"," ",type,scale,maxField); |
f1b9d7c3 | 248 | } else if(version<=2) { |
d8408e76 | 249 | fField = new AliMagFCM("Map2-3",filename,type,scale,maxField); |
fe4da5cc | 250 | fField->ReadField(); |
f1b9d7c3 | 251 | } else if(version==3) { |
d8408e76 | 252 | fField = new AliMagFDM("Map4",filename,type,scale,maxField); |
f1b9d7c3 | 253 | fField->ReadField(); |
fe4da5cc | 254 | } else { |
21bf7095 | 255 | AliWarning(Form("Invalid map %d",version)); |
fe4da5cc | 256 | } |
257 | } | |
88cb7938 | 258 | |
259 | //_____________________________________________________________________________ | |
260 | ||
261 | void AliRun::InitLoaders() | |
262 | { | |
263 | //creates list of getters | |
21bf7095 | 264 | AliDebug(1, ""); |
88cb7938 | 265 | TIter next(fModules); |
266 | AliModule *mod; | |
267 | while((mod = (AliModule*)next())) | |
268 | { | |
1d6fbf6e | 269 | mod->SetRunLoader(fRunLoader); |
88cb7938 | 270 | AliDetector *det = dynamic_cast<AliDetector*>(mod); |
271 | if (det) | |
272 | { | |
21bf7095 | 273 | AliDebug(2, Form("Adding %s", det->GetName())); |
88cb7938 | 274 | fRunLoader->AddLoader(det); |
275 | } | |
276 | } | |
21bf7095 | 277 | AliDebug(1, "Done"); |
88cb7938 | 278 | } |
279 | //_____________________________________________________________________________ | |
280 | ||
fe4da5cc | 281 | void AliRun::FinishRun() |
282 | { | |
283 | // | |
284 | // Called at the end of the run. | |
285 | // | |
07d55def | 286 | |
88cb7938 | 287 | if(fLego) |
288 | { | |
21bf7095 | 289 | AliDebug(1, "Finish Lego"); |
7dd2cbe4 | 290 | AliRunLoader::GetRunLoader()->CdGAFile(); |
88cb7938 | 291 | fLego->FinishRun(); |
292 | } | |
8e70f139 | 293 | |
fe4da5cc | 294 | // Clean detector information |
8494b010 | 295 | TIter next(fModules); |
296 | AliModule *detector; | |
e2afb3b6 | 297 | while((detector = dynamic_cast<AliModule*>(next()))) { |
21bf7095 | 298 | AliDebug(2, Form("%s->FinishRun()", detector->GetName())); |
fe4da5cc | 299 | detector->FinishRun(); |
300 | } | |
301 | ||
7dd2cbe4 | 302 | AliDebug(1, "AliRunLoader::GetRunLoader()->WriteHeader(OVERWRITE)"); |
303 | AliRunLoader::GetRunLoader()->WriteHeader("OVERWRITE"); | |
682a4a95 | 304 | |
88cb7938 | 305 | // Write AliRun info and all detectors parameters |
7dd2cbe4 | 306 | AliRunLoader::GetRunLoader()->CdGAFile(); |
88cb7938 | 307 | Write(0,TObject::kOverwrite);//write AliRun |
7dd2cbe4 | 308 | AliRunLoader::GetRunLoader()->Write(0,TObject::kOverwrite);//write RunLoader itself |
88cb7938 | 309 | |
07d55def | 310 | if(fMCApp) fMCApp->FinishRun(); |
7dd2cbe4 | 311 | AliRunLoader::GetRunLoader()->Synchronize(); |
fe4da5cc | 312 | } |
313 | ||
eb1b8d29 | 314 | //_______________________________________________________________________ |
315 | void AliRun::Announce() const | |
316 | { | |
317 | // | |
37d06d5b | 318 | // Announce the current version of AliRoot |
319 | // | |
320 | printf("%70s", | |
321 | "****************************************************************\n"); | |
322 | printf("%6s","*");printf("%64s","*\n"); | |
323 | ||
324 | printf("%6s","*"); | |
88cb7938 | 325 | printf(" You are running AliRoot version NewIO\n"); |
37d06d5b | 326 | |
327 | printf("%6s","*"); | |
5960f18d | 328 | printf(" The SVN version for the current program is $Id$\n"); |
37d06d5b | 329 | |
330 | printf("%6s","*");printf("%64s","*\n"); | |
331 | printf("%70s", | |
332 | "****************************************************************\n"); | |
eb1b8d29 | 333 | } |
334 | ||
e2afb3b6 | 335 | //_______________________________________________________________________ |
94de3818 | 336 | AliModule *AliRun::GetModule(const char *name) const |
fe4da5cc | 337 | { |
338 | // | |
339 | // Return pointer to detector from name | |
340 | // | |
e2afb3b6 | 341 | return dynamic_cast<AliModule*>(fModules->FindObject(name)); |
fe4da5cc | 342 | } |
343 | ||
e2afb3b6 | 344 | //_______________________________________________________________________ |
94de3818 | 345 | AliDetector *AliRun::GetDetector(const char *name) const |
a68348e9 | 346 | { |
347 | // | |
348 | // Return pointer to detector from name | |
349 | // | |
e2afb3b6 | 350 | return dynamic_cast<AliDetector*>(fModules->FindObject(name)); |
a68348e9 | 351 | } |
352 | ||
e2afb3b6 | 353 | //_______________________________________________________________________ |
94de3818 | 354 | Int_t AliRun::GetModuleID(const char *name) const |
fe4da5cc | 355 | { |
356 | // | |
357 | // Return galice internal detector identifier from name | |
358 | // | |
23370b7a | 359 | Int_t i=-1; |
360 | TObject *mod=fModules->FindObject(name); | |
361 | if(mod) i=fModules->IndexOf(mod); | |
362 | return i; | |
fe4da5cc | 363 | } |
364 | ||
e2afb3b6 | 365 | //_______________________________________________________________________ |
fe4da5cc | 366 | Int_t AliRun::GetEvent(Int_t event) |
367 | { | |
88cb7938 | 368 | // |
369 | // Reloads data containers in folders # event | |
370 | // Set branch addresses | |
371 | // | |
372 | if (fRunLoader == 0x0) | |
373 | { | |
21bf7095 | 374 | AliError("RunLoader is not set. Can not load data."); |
88cb7938 | 375 | return -1; |
376 | } | |
377 | /*****************************************/ | |
378 | /**** P R E R E L O A D I N G ****/ | |
379 | /*****************************************/ | |
380 | // Reset existing structures | |
5d12ce38 | 381 | fMCApp->ResetHits(); |
382 | fMCApp->ResetTrackReferences(); | |
fe4da5cc | 383 | ResetDigits(); |
2ab0c725 | 384 | ResetSDigits(); |
50a6540a | 385 | |
88cb7938 | 386 | /*****************************************/ |
387 | /**** R E L O A D ****/ | |
388 | /*****************************************/ | |
aab9c8d5 | 389 | |
7dd2cbe4 | 390 | AliRunLoader::GetRunLoader()->GetEvent(event); |
b9d0a01d | 391 | |
88cb7938 | 392 | /*****************************************/ |
393 | /**** P O S T R E L O A D I N G ****/ | |
394 | /*****************************************/ | |
82711e7a | 395 | |
fe4da5cc | 396 | // Set Trees branch addresses |
8494b010 | 397 | TIter next(fModules); |
07d55def | 398 | AliDetector *detector; |
399 | while((detector = dynamic_cast<AliDetector*>(next()))) | |
88cb7938 | 400 | { |
401 | detector->SetTreeAddress(); | |
402 | } | |
403 | ||
7dd2cbe4 | 404 | return AliRunLoader::GetRunLoader()->GetHeader()->GetNtrack(); |
fe4da5cc | 405 | } |
406 | ||
e2afb3b6 | 407 | //_______________________________________________________________________ |
408 | void AliRun::SetBaseFile(const char *filename) | |
2ab0c725 | 409 | { |
39de14fb | 410 | fBaseFileName = filename; |
2ab0c725 | 411 | } |
412 | ||
e2afb3b6 | 413 | //_______________________________________________________________________ |
b9d0a01d | 414 | void AliRun::ResetDigits() |
fe4da5cc | 415 | { |
416 | // | |
b9d0a01d | 417 | // Reset all Detectors digits |
fe4da5cc | 418 | // |
b9d0a01d | 419 | TIter next(fModules); |
420 | AliModule *detector; | |
e2afb3b6 | 421 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 422 | detector->ResetDigits(); |
423 | } | |
424 | } | |
425 | ||
e2afb3b6 | 426 | //_______________________________________________________________________ |
b9d0a01d | 427 | void AliRun::ResetSDigits() |
428 | { | |
dffd31ef | 429 | // |
b9d0a01d | 430 | // Reset all Detectors digits |
9e1a0ddb | 431 | // |
b9d0a01d | 432 | TIter next(fModules); |
433 | AliModule *detector; | |
e2afb3b6 | 434 | while((detector = dynamic_cast<AliModule*>(next()))) { |
b9d0a01d | 435 | detector->ResetSDigits(); |
436 | } | |
437 | } | |
dffd31ef | 438 | |
2b22f272 | 439 | |
e2afb3b6 | 440 | //_______________________________________________________________________ |
88cb7938 | 441 | |
b9d0a01d | 442 | void AliRun::InitMC(const char *setup) |
2ab0c725 | 443 | { |
444 | // | |
5d12ce38 | 445 | // Initialize ALICE Simulation run |
2ab0c725 | 446 | // |
37d06d5b | 447 | Announce(); |
448 | ||
b9d0a01d | 449 | if(fInitDone) { |
21bf7095 | 450 | AliWarning("Cannot initialise AliRun twice!"); |
b9d0a01d | 451 | return; |
fe4da5cc | 452 | } |
b9d0a01d | 453 | |
67d736ee | 454 | if (!fMCApp) |
455 | fMCApp=new AliMC(GetName(),GetTitle()); | |
5d12ce38 | 456 | |
b9d0a01d | 457 | gROOT->LoadMacro(setup); |
458 | gInterpreter->ProcessLine(fConfigFunction.Data()); | |
fe4da5cc | 459 | |
3d45e923 | 460 | if(AliCDBManager::Instance()->GetRun() >= 0) { |
461 | SetRunNumber(AliCDBManager::Instance()->GetRun()); | |
462 | } else { | |
463 | AliWarning("Run number not initialized!!"); | |
464 | } | |
b3276c04 | 465 | |
7dd2cbe4 | 466 | AliRunLoader::GetRunLoader()->CdGAFile(); |
07d55def | 467 | |
7dd2cbe4 | 468 | AliPDG::AddParticlesToPdgDataBase(); |
aab9c8d5 | 469 | |
5d12ce38 | 470 | fMCApp->Init(); |
b9d0a01d | 471 | |
504b172d | 472 | //Must be here because some MCs (G4) adds detectors here and not in Config.C |
473 | InitLoaders(); | |
7dd2cbe4 | 474 | AliRunLoader::GetRunLoader()->MakeTree("E"); |
504b172d | 475 | if (fLego == 0x0) |
476 | { | |
7dd2cbe4 | 477 | AliRunLoader::GetRunLoader()->LoadKinematics("RECREATE"); |
478 | AliRunLoader::GetRunLoader()->LoadTrackRefs("RECREATE"); | |
479 | AliRunLoader::GetRunLoader()->LoadHits("all","RECREATE"); | |
504b172d | 480 | } |
b9d0a01d | 481 | fInitDone = kTRUE; |
b9d0a01d | 482 | // |
483 | // Save stuff at the beginning of the file to avoid file corruption | |
7dd2cbe4 | 484 | AliRunLoader::GetRunLoader()->CdGAFile(); |
b9d0a01d | 485 | Write(); |
88cb7938 | 486 | fEventNrInRun = -1; //important - we start Begin event from increasing current number in run |
fe4da5cc | 487 | } |
488 | ||
e2afb3b6 | 489 | //_______________________________________________________________________ |
88cb7938 | 490 | |
875c717b | 491 | void AliRun::RunMC(Int_t nevent, const char *setup) |
fe4da5cc | 492 | { |
493 | // | |
494 | // Main function to be called to process a galice run | |
495 | // example | |
496 | // Root > gAlice.Run(); | |
497 | // a positive number of events will cause the finish routine | |
498 | // to be called | |
499 | // | |
88cb7938 | 500 | fEventsPerRun = nevent; |
fe4da5cc | 501 | // check if initialisation has been done |
875c717b | 502 | if (!fInitDone) InitMC(setup); |
fe4da5cc | 503 | |
fe4da5cc | 504 | // Create the Root Tree with one branch per detector |
88cb7938 | 505 | //Hits moved to begin event -> now we are crating separate tree for each event |
fe4da5cc | 506 | |
875c717b | 507 | gMC->ProcessRun(nevent); |
508 | ||
fe4da5cc | 509 | // End of this run, close files |
80762cb1 | 510 | if(nevent>0) FinishRun(); |
fe4da5cc | 511 | } |
512 | ||
e2afb3b6 | 513 | //_______________________________________________________________________ |
2ab0c725 | 514 | |
515 | void AliRun::Hits2Digits(const char *selected) | |
516 | { | |
9e1a0ddb | 517 | |
d47c658f | 518 | // Convert Hits to sumable digits |
519 | // | |
7dd2cbe4 | 520 | for (Int_t nevent=0; nevent<AliRunLoader::GetRunLoader()->TreeE()->GetEntries(); nevent++) { |
9e1a0ddb | 521 | GetEvent(nevent); |
9e1a0ddb | 522 | Hits2SDigits(selected); |
523 | SDigits2Digits(selected); | |
524 | } | |
2ab0c725 | 525 | } |
526 | ||
d47c658f | 527 | |
e2afb3b6 | 528 | //_______________________________________________________________________ |
2ab0c725 | 529 | |
d47c658f | 530 | void AliRun::Tree2Tree(Option_t *option, const char *selected) |
2ab0c725 | 531 | { |
532 | // | |
d47c658f | 533 | // Function to transform the content of |
534 | // | |
535 | // - TreeH to TreeS (option "S") | |
536 | // - TreeS to TreeD (option "D") | |
537 | // - TreeD to TreeR (option "R") | |
538 | // | |
539 | // If multiple options are specified ("SDR"), transformation will be done in sequence for | |
540 | // selected detector and for all detectors if none is selected (detector string | |
541 | // can contain blank separated list of detector names). | |
2ab0c725 | 542 | |
2ab0c725 | 543 | |
5cf7bbad | 544 | const char *oS = strstr(option,"S"); |
545 | const char *oD = strstr(option,"D"); | |
546 | const char *oR = strstr(option,"R"); | |
2ab0c725 | 547 | |
9e1a0ddb | 548 | TObjArray *detectors = Detectors(); |
2ab0c725 | 549 | |
550 | TIter next(detectors); | |
551 | ||
d47c658f | 552 | AliDetector *detector = 0; |
2ab0c725 | 553 | |
88cb7938 | 554 | while((detector = dynamic_cast<AliDetector*>(next()))) { |
d47c658f | 555 | if (selected) |
2ab0c725 | 556 | if (strcmp(detector->GetName(),selected)) continue; |
88cb7938 | 557 | if (detector->IsActive()) |
558 | { | |
559 | ||
560 | AliLoader* loader = detector->GetLoader(); | |
561 | if (loader == 0x0) continue; | |
562 | ||
563 | if (oS) | |
564 | { | |
21bf7095 | 565 | AliDebug(1, Form("Processing Hits2SDigits for %s ...", detector->GetName())); |
88cb7938 | 566 | loader->LoadHits("read"); |
567 | if (loader->TreeS() == 0x0) loader->MakeTree("S"); | |
568 | detector->MakeBranch(option); | |
569 | detector->SetTreeAddress(); | |
570 | detector->Hits2SDigits(); | |
571 | loader->UnloadHits(); | |
572 | loader->UnloadSDigits(); | |
573 | } | |
574 | if (oD) | |
575 | { | |
21bf7095 | 576 | AliDebug(1, Form("Processing SDigits2Digits for %s ...", detector->GetName())); |
88cb7938 | 577 | loader->LoadSDigits("read"); |
578 | if (loader->TreeD() == 0x0) loader->MakeTree("D"); | |
579 | detector->MakeBranch(option); | |
580 | detector->SetTreeAddress(); | |
581 | detector->SDigits2Digits(); | |
582 | loader->UnloadSDigits(); | |
583 | loader->UnloadDigits(); | |
584 | } | |
585 | if (oR) | |
586 | { | |
21bf7095 | 587 | AliDebug(1, Form("Processing Digits2Reco for %s ...", detector->GetName())); |
88cb7938 | 588 | loader->LoadDigits("read"); |
589 | if (loader->TreeR() == 0x0) loader->MakeTree("R"); | |
590 | detector->MakeBranch(option); | |
591 | detector->SetTreeAddress(); | |
592 | detector->Digits2Reco(); | |
593 | loader->UnloadDigits(); | |
594 | loader->UnloadRecPoints(); | |
595 | ||
596 | } | |
597 | } | |
598 | } | |
2ab0c725 | 599 | } |
600 | ||
e2afb3b6 | 601 | //_______________________________________________________________________ |
0a520a66 | 602 | void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min, |
603 | Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max, | |
93dccc77 | 604 | Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener, Int_t nev) |
fe4da5cc | 605 | { |
606 | // | |
607 | // Generates lego plots of: | |
608 | // - radiation length map phi vs theta | |
609 | // - radiation length map phi vs eta | |
610 | // - interaction length map | |
611 | // - g/cm2 length map | |
612 | // | |
613 | // ntheta bins in theta, eta | |
614 | // themin minimum angle in theta (degrees) | |
615 | // themax maximum angle in theta (degrees) | |
616 | // nphi bins in phi | |
617 | // phimin minimum angle in phi (degrees) | |
618 | // phimax maximum angle in phi (degrees) | |
619 | // rmin minimum radius | |
620 | // rmax maximum radius | |
621 | // | |
622 | // | |
623 | // The number of events generated = ntheta*nphi | |
624 | // run input parameters in macro setup (default="Config.C") | |
625 | // | |
626 | // Use macro "lego.C" to visualize the 3 lego plots in spherical coordinates | |
627 | //Begin_Html | |
628 | /* | |
1439f98e | 629 | <img src="picts/AliRunLego1.gif"> |
fe4da5cc | 630 | */ |
631 | //End_Html | |
632 | //Begin_Html | |
633 | /* | |
1439f98e | 634 | <img src="picts/AliRunLego2.gif"> |
fe4da5cc | 635 | */ |
636 | //End_Html | |
637 | //Begin_Html | |
638 | /* | |
1439f98e | 639 | <img src="picts/AliRunLego3.gif"> |
fe4da5cc | 640 | */ |
641 | //End_Html | |
642 | // | |
93dccc77 | 643 | // Number of events |
644 | if (nev == -1) nev = nc1 * nc2; | |
645 | ||
fe4da5cc | 646 | // check if initialisation has been done |
2cacde38 | 647 | // If runloader has been initialized, set the number of events per file to nc1 * nc2 |
93dccc77 | 648 | |
0a520a66 | 649 | // Set new generator |
650 | if (!gener) gener = new AliLegoGenerator(); | |
0a520a66 | 651 | // |
652 | // Configure Generator | |
07d55def | 653 | |
0a520a66 | 654 | gener->SetRadiusRange(rmin, rmax); |
655 | gener->SetZMax(zmax); | |
656 | gener->SetCoor1Range(nc1, c1min, c1max); | |
657 | gener->SetCoor2Range(nc2, c2min, c2max); | |
658 | ||
659 | ||
b13db077 | 660 | //Create Lego object |
0a520a66 | 661 | fLego = new AliLego("lego",gener); |
b13db077 | 662 | |
504b172d | 663 | if (!fInitDone) InitMC(setup); |
664 | //Save current generator | |
665 | ||
666 | AliGenerator *gen=fMCApp->Generator(); | |
667 | fMCApp->ResetGenerator(gener); | |
dffd31ef | 668 | //Prepare MC for Lego Run |
669 | gMC->InitLego(); | |
670 | ||
b13db077 | 671 | //Run Lego Object |
0a520a66 | 672 | |
07d55def | 673 | |
93dccc77 | 674 | if (fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nev); |
93dccc77 | 675 | gMC->ProcessRun(nev); |
fe4da5cc | 676 | |
fe4da5cc | 677 | // End of this run, close files |
80762cb1 | 678 | FinishRun(); |
0a520a66 | 679 | // Restore current generator |
5d12ce38 | 680 | fMCApp->ResetGenerator(gen); |
838edcaf | 681 | // Delete Lego Object |
682 | delete fLego; fLego=0; | |
fe4da5cc | 683 | } |
684 | ||
e2afb3b6 | 685 | //_______________________________________________________________________ |
94de3818 | 686 | void AliRun::SetConfigFunction(const char * config) |
687 | { | |
688 | // | |
689 | // Set the signature of the function contained in Config.C to configure | |
690 | // the run | |
691 | // | |
692 | fConfigFunction=config; | |
693 | } | |
694 | ||
b9d0a01d | 695 | // |
696 | // MC Application | |
697 | // | |
698 | ||
e2afb3b6 | 699 | //_______________________________________________________________________ |
b9d0a01d | 700 | void AliRun::Field(const Double_t* x, Double_t *b) const |
701 | { | |
2057aecb | 702 | // |
703 | // Return the value of the magnetic field | |
704 | // | |
07d55def | 705 | |
2057aecb | 706 | Float_t xfloat[3]; |
707 | for (Int_t i=0; i<3; i++) xfloat[i] = x[i]; | |
708 | ||
709 | if (Field()) { | |
07d55def | 710 | |
2057aecb | 711 | Float_t bfloat[3]; |
712 | Field()->Field(xfloat,bfloat); | |
713 | for (Int_t j=0; j<3; j++) b[j] = bfloat[j]; | |
714 | } | |
715 | else { | |
21bf7095 | 716 | AliError("No mag field defined!"); |
2057aecb | 717 | b[0]=b[1]=b[2]=0.; |
718 | } | |
07d55def | 719 | |
720 | ||
b9d0a01d | 721 | } |
722 | ||
723 | // | |
724 | // End of MC Application | |
725 | // | |
726 | ||
e2afb3b6 | 727 | //_______________________________________________________________________ |
fe4da5cc | 728 | void AliRun::Streamer(TBuffer &R__b) |
729 | { | |
eef4b160 | 730 | // Stream an object of class AliRun. |
2ab0c725 | 731 | |
7e90ff59 | 732 | if (R__b.IsReading()) { |
733 | if (!gAlice) gAlice = this; | |
7e90ff59 | 734 | AliRun::Class()->ReadBuffer(R__b, this); |
7e90ff59 | 735 | gROOT->GetListOfBrowsables()->Add(this,"Run"); |
eef4b160 | 736 | |
7e90ff59 | 737 | gRandom = fRandom; |
738 | } else { | |
eef4b160 | 739 | AliRun::Class()->WriteBuffer(R__b, this); |
740 | } | |
2ab0c725 | 741 | } |
e2afb3b6 | 742 | //_______________________________________________________________________ |
b9d0a01d | 743 | |
27f087a9 | 744 | void AliRun::SetGenEventHeader(AliGenEventHeader* header) |
745 | { | |
7dd2cbe4 | 746 | AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header); |
27f087a9 | 747 | } |
7dd2cbe4 | 748 | |
749 | ||
504b172d | 750 | //_______________________________________________________________________ |
0592d1ca | 751 | |
88cb7938 | 752 | Int_t AliRun::GetEvNumber() const |
753 | { | |
754 | //Returns number of current event | |
755 | if (fRunLoader == 0x0) | |
756 | { | |
21bf7095 | 757 | AliError("RunLoader is not set. Can not load data."); |
88cb7938 | 758 | return -1; |
759 | } | |
0592d1ca | 760 | |
88cb7938 | 761 | return fRunLoader->GetEventNumber(); |
0592d1ca | 762 | } |
504b172d | 763 | //_______________________________________________________________________ |
b9d0a01d | 764 | |
88cb7938 | 765 | void AliRun::SetRunLoader(AliRunLoader* rloader) |
0592d1ca | 766 | { |
2057aecb | 767 | // |
768 | // Set the loader of the run | |
769 | // | |
88cb7938 | 770 | fRunLoader = rloader; |
771 | if (fRunLoader == 0x0) return; | |
772 | ||
773 | TString evfoldname; | |
774 | TFolder* evfold = fRunLoader->GetEventFolder(); | |
775 | if (evfold) evfoldname = evfold->GetName(); | |
21bf7095 | 776 | else AliWarning("Did not get Event Folder from Run Loader"); |
88cb7938 | 777 | |
778 | if ( fRunLoader->GetAliRun() ) | |
779 | {//if alrun already exists in folder | |
780 | if (fRunLoader->GetAliRun() != this ) | |
781 | {//and is different than this - crash | |
21bf7095 | 782 | AliFatal("AliRun is already in Folder and it is not this object"); |
88cb7938 | 783 | return;//pro forma |
784 | }//else do nothing | |
785 | } | |
786 | else | |
787 | { | |
788 | evfold->Add(this);//Post this AliRun to Folder | |
789 | } | |
790 | ||
791 | TIter next(fModules); | |
792 | AliModule *module; | |
793 | while((module = (AliModule*)next())) | |
794 | { | |
795 | if (evfold) AliConfig::Instance()->Add(module,evfoldname); | |
1d6fbf6e | 796 | module->SetRunLoader(fRunLoader); |
88cb7938 | 797 | AliDetector* detector = dynamic_cast<AliDetector*>(module); |
798 | if (detector) | |
799 | { | |
800 | AliLoader* loader = fRunLoader->GetLoader(detector); | |
801 | if (loader == 0x0) | |
802 | { | |
21bf7095 | 803 | AliError(Form("Can not get loader for detector %s", detector->GetName())); |
88cb7938 | 804 | } |
805 | else | |
806 | { | |
21bf7095 | 807 | AliDebug(1, Form("Setting loader for detector %s", detector->GetName())); |
88cb7938 | 808 | detector->SetLoader(loader); |
809 | } | |
0592d1ca | 810 | } |
88cb7938 | 811 | } |
0592d1ca | 812 | } |
813 | ||
88cb7938 | 814 | void AliRun::AddModule(AliModule* mod) |
7a16e9cc | 815 | { |
2057aecb | 816 | // |
817 | // Add a module to the module list | |
818 | // | |
88cb7938 | 819 | if (mod == 0x0) return; |
820 | if (strlen(mod->GetName()) == 0) return; | |
821 | if (GetModuleID(mod->GetName()) >= 0) return; | |
822 | ||
21bf7095 | 823 | AliDebug(1, mod->GetName()); |
88cb7938 | 824 | if (fRunLoader == 0x0) AliConfig::Instance()->Add(mod); |
825 | else AliConfig::Instance()->Add(mod,fRunLoader->GetEventFolder()->GetName()); | |
7a16e9cc | 826 | |
88cb7938 | 827 | Modules()->Add(mod); |
67d736ee | 828 | |
829 | fNdets++; | |
7a16e9cc | 830 | } |
21bf7095 | 831 | |
4d81e5e7 | 832 | //_____________________________________________________________________________ |
833 | /*inline*/ Bool_t AliRun::IsFileAccessible(const char* fnam, EAccessMode mode) | |
834 | { return !gSystem->AccessPathName(fnam,mode);} | |
835 | ||
836 | //______________________________________________________ | |
837 | /*inline*/ Bool_t AliRun::IsFileAccessible(Char_t* name,EAccessMode mode) | |
838 | { | |
839 | TString str = name; gSystem->ExpandPathName(str); | |
840 | return !gSystem->AccessPathName(str.Data(),mode); | |
841 | } |