]>
Commit | Line | Data |
---|---|---|
88cb7938 | 1 | // |
2 | //Class (base) responsible for management of data: | |
3 | // - opening and closing proper files | |
4 | // - posting data to folders | |
5 | // - writing data from folders to proper files | |
6 | // | |
7 | //Author: Alice Offline Group http://alisoft.cern.ch | |
8 | //Responsible: Piotr.Skowronski@cern.ch | |
9 | // | |
10 | #include <AliLoader.h> | |
11 | ||
12 | //Root includes | |
13 | #include <TROOT.h> | |
14 | #include <TFolder.h> | |
15 | #include <TFile.h> | |
16 | #include <TTree.h> | |
17 | #include <TTask.h> | |
18 | #include <TString.h> | |
19 | #include <TError.h> | |
20 | ||
21 | //AliRoot includes | |
21bf7095 | 22 | #include <AliLog.h> |
88cb7938 | 23 | #include <AliRun.h> |
24 | #include <AliRunLoader.h> | |
25 | #include <AliRunDigitizer.h> | |
26 | #include <AliDigitizer.h> | |
27 | #include <AliDetector.h> | |
d0d4a6b3 | 28 | #include "AliConfig.h" |
88cb7938 | 29 | |
88cb7938 | 30 | const TString AliLoader::fgkDefaultHitsContainerName("TreeH"); |
31 | const TString AliLoader::fgkDefaultDigitsContainerName = "TreeD"; | |
32 | const TString AliLoader::fgkDefaultSDigitsContainerName = "TreeS"; | |
33 | const TString AliLoader::fgkDefaultRecPointsContainerName = "TreeR"; | |
34 | const TString AliLoader::fgkDefaultTracksContainerName = "TreeT"; | |
35 | const TString AliLoader::fgkDefaultRecParticlesContainerName = "TreeP"; | |
36 | const TString AliLoader::fgkLoaderBaseName("Loader"); | |
37 | ||
38 | ClassImp(AliLoader) | |
39 | //___________________________________________________________________ | |
40 | ///////////////////////////////////////////////////////////////////// | |
41 | // // | |
42 | // class AliLoader // | |
43 | // // | |
44 | // Base class for Loaders. // | |
45 | // Loader provides base I/O fascilities for "standard" data. // | |
46 | // Each detector has a laoder data member // | |
47 | // loader is accessible via folder structure as well // | |
48 | // // | |
49 | ///////////////////////////////////////////////////////////////////// | |
50 | ||
51 | /*****************************************************************************/ | |
52 | ||
53 | AliLoader::AliLoader(): | |
54 | fDataLoaders(0x0), | |
55 | fDetectorName(""), | |
56 | fEventFolder(0x0), | |
57 | fDataFolder(0x0), | |
58 | fDetectorDataFolder(0x0), | |
59 | fModuleFolder(0x0), | |
60 | fTasksFolder(0x0), | |
61 | fQAFolder(0x0) | |
90e48c0c | 62 | { |
88cb7938 | 63 | //default constructor |
64 | ||
65 | } | |
66 | /******************************************************************/ | |
67 | ||
68 | AliLoader::AliLoader(const Char_t* detname,const Char_t* eventfoldername): | |
69 | fDataLoaders(new TObjArray(kNDataTypes)), | |
70 | fDetectorName(""), | |
71 | fEventFolder(0x0), | |
72 | fDataFolder(0x0), | |
73 | fDetectorDataFolder(0x0), | |
74 | fModuleFolder(0x0), | |
75 | fTasksFolder(0x0), | |
76 | fQAFolder(0x0) | |
77 | { | |
78 | //ctor | |
21bf7095 | 79 | AliDebug(1, Form("detname = %s eventfoldername = %s",detname,eventfoldername)); |
88cb7938 | 80 | |
81 | //try to find folder eventfoldername in top alice folder | |
82 | //safe because GetTopFolder will abort in case of failure | |
83 | ||
84 | fDetectorName = detname; | |
85 | fName = fDetectorName+"Loader"; | |
86 | InitDefaults(); | |
87 | ||
88 | TObject* fobj = GetTopFolder()->FindObject(eventfoldername); | |
89 | fEventFolder = (fobj)?dynamic_cast<TFolder*>(fobj):0x0;//in case FindObject returns NULL dynamic cast cause seg. fault | |
90 | SetEventFolder(fEventFolder); | |
91 | ||
92 | } | |
93 | /*****************************************************************************/ | |
94 | ||
95 | AliLoader::AliLoader(const Char_t * detname,TFolder* eventfolder): | |
96 | fDataLoaders(new TObjArray(kNDataTypes)), | |
97 | fDetectorName(detname), | |
98 | fEventFolder(0x0), | |
99 | fDataFolder(0x0), | |
100 | fDetectorDataFolder(0x0), | |
101 | fModuleFolder(0x0), | |
102 | fTasksFolder(0x0), | |
103 | fQAFolder(0x0) | |
104 | { | |
105 | //constructor | |
106 | fDetectorName = detname; | |
107 | fName = fDetectorName+"Loader"; | |
108 | InitDefaults(); | |
109 | SetEventFolder(eventfolder); | |
110 | //fileoption's don't need to initialized because default TString ctor does it correctly | |
111 | } | |
112 | /*****************************************************************************/ | |
90e48c0c | 113 | AliLoader::AliLoader(const AliLoader& source) : |
114 | TNamed(source), | |
115 | fDataLoaders(source.fDataLoaders), | |
116 | fDetectorName(source.fDetectorName), | |
117 | fEventFolder(source.fEventFolder), | |
118 | fDataFolder(source.fDataFolder), | |
119 | fDetectorDataFolder(source.fDetectorDataFolder), | |
120 | fModuleFolder(source.fModuleFolder), | |
121 | fTasksFolder(source.fTasksFolder), | |
122 | fQAFolder(source.fQAFolder) | |
123 | { | |
d0d4a6b3 | 124 | // dummy copy constructor |
125 | if(&source==this)return; | |
126 | ||
21bf7095 | 127 | AliFatal("Copy constructor not implemented. Aborting"); |
d0d4a6b3 | 128 | return; |
129 | } | |
88cb7938 | 130 | |
d0d4a6b3 | 131 | /*****************************************************************************/ |
132 | AliLoader& AliLoader::operator=(const AliLoader& source) { | |
133 | // dummy assignment operator | |
134 | if(&source==this) return *this; | |
135 | ||
21bf7095 | 136 | AliFatal("Assignment operator not implemented. Aborting"); |
d0d4a6b3 | 137 | return *this; |
138 | } | |
139 | ||
140 | /*****************************************************************************/ | |
88cb7938 | 141 | AliLoader::~AliLoader() |
142 | { | |
143 | //detructor | |
144 | if (fDataLoaders) fDataLoaders->SetOwner(); | |
145 | delete fDataLoaders; | |
146 | } | |
147 | /*****************************************************************************/ | |
148 | ||
149 | void AliLoader::InitDefaults() | |
150 | { | |
151 | // H I T S | |
152 | AliDataLoader* dl; | |
153 | dl = new AliDataLoader(fDetectorName + ".Hits.root",fgkDefaultHitsContainerName, "Hits" ); | |
154 | fDataLoaders->AddAt(dl,kHits); | |
155 | ||
156 | ||
157 | // S U M M A B L E D I G I T S | |
158 | dl = new AliDataLoader(fDetectorName + ".SDigits.root",fgkDefaultSDigitsContainerName, "Summable Digits"); | |
159 | AliTaskLoader* tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetSDigitizerTaskName(), | |
160 | dl,AliRunLoader::GetRunSDigitizer(),kTRUE); | |
161 | dl->SetBaseTaskLoader(tl); | |
162 | fDataLoaders->AddAt(dl,kSDigits); | |
163 | ||
164 | // D I G I T S | |
165 | dl = new AliDataLoader(fDetectorName + ".Digits.root",fgkDefaultDigitsContainerName, "Digits"); | |
166 | tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetDigitizerTaskName(), | |
167 | dl,AliRunLoader::GetRunDigitizer(),kTRUE); | |
168 | dl->SetBaseTaskLoader(tl); | |
169 | fDataLoaders->AddAt(dl,kDigits); | |
170 | ||
171 | // R E C O N S T R U C T E D P O I N T S aka C L U S T E R S | |
172 | dl = new AliDataLoader(fDetectorName + ".RecPoints.root",fgkDefaultRecPointsContainerName, "Reconstructed Points"); | |
173 | tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetReconstructionerTaskName(), | |
174 | dl,AliRunLoader::GetRunReconstructioner(),kTRUE); | |
175 | dl->SetBaseTaskLoader(tl); | |
176 | fDataLoaders->AddAt(dl,kRecPoints); | |
177 | ||
178 | // T R A C K S | |
179 | dl = new AliDataLoader(fDetectorName + ".Tracks.root",fgkDefaultTracksContainerName, "Tracks"); | |
180 | tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetTrackerTaskName(), | |
181 | dl,AliRunLoader::GetRunTracker(),kTRUE); | |
182 | dl->SetBaseTaskLoader(tl); | |
183 | fDataLoaders->AddAt(dl,kTracks); | |
184 | ||
185 | // R E C O N S T R U C T E D P O I N T S aka C L U S T E R S | |
186 | dl = new AliDataLoader(fDetectorName + ".RecParticles.root",fgkDefaultRecParticlesContainerName, "Reconstructed Particles"); | |
187 | tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetPIDTaskName(), | |
188 | dl,AliRunLoader::GetRunPIDTask(),kTRUE); | |
189 | dl->SetBaseTaskLoader(tl); | |
190 | fDataLoaders->AddAt(dl,kRecParticles); | |
191 | ||
192 | } | |
193 | /*****************************************************************************/ | |
194 | ||
195 | AliDataLoader* AliLoader::GetDataLoader(const char* name) | |
196 | { | |
197 | //returns Data Loader with specified name | |
198 | return dynamic_cast<AliDataLoader*>(fDataLoaders->FindObject(name)); | |
199 | } | |
200 | /*****************************************************************************/ | |
deee9e3b | 201 | void AliLoader::AddDataLoader(AliDataLoader* dl) |
202 | { | |
8364b0ef | 203 | // |
204 | // Adds a data loader | |
205 | // | |
deee9e3b | 206 | if (dl == 0x0) |
207 | { | |
21bf7095 | 208 | AliError("Pointer is NULL"); |
deee9e3b | 209 | return; |
210 | } | |
211 | if (fDataLoaders->FindObject(dl->GetName())) | |
212 | { | |
21bf7095 | 213 | AliError("Such a loader exists"); |
deee9e3b | 214 | return; |
215 | } | |
216 | fDataLoaders->AddLast(dl); | |
217 | dl->SetEventFolder(fEventFolder); | |
218 | dl->SetFolder(GetDetectorDataFolder()); //Must exists - ensure register is called before | |
219 | } | |
220 | /*****************************************************************************/ | |
88cb7938 | 221 | |
222 | Int_t AliLoader::SetEvent() | |
223 | { | |
224 | //basically the same that GetEvent but do not post data to folders | |
225 | TIter next(fDataLoaders); | |
226 | AliDataLoader* dl; | |
227 | while ((dl = (AliDataLoader*)next())) | |
228 | { | |
229 | dl->SetEvent(); | |
230 | } | |
231 | return 0; | |
232 | } | |
233 | /******************************************************************/ | |
234 | ||
1bb20a37 | 235 | void AliLoader::UnloadAll() |
236 | { | |
237 | //calls UnloadAll for all base laoders | |
238 | //Unloads everything | |
239 | TIter next(fDataLoaders); | |
240 | AliDataLoader* dl; | |
241 | while ((dl = (AliDataLoader*)next())) | |
242 | { | |
243 | dl->UnloadAll(); | |
244 | } | |
245 | } | |
246 | /******************************************************************/ | |
247 | ||
88cb7938 | 248 | Int_t AliLoader::GetEvent() |
249 | { | |
250 | //changes to proper root directory and tries to load data from files to folders | |
251 | // event number is defined in RunLoader | |
252 | // | |
253 | //returns: | |
254 | // 0 - in case of no error | |
255 | // 1 - event not found | |
256 | // | |
257 | ||
258 | Int_t retval; | |
259 | TIter next(fDataLoaders); | |
260 | AliDataLoader* dl; | |
261 | while ((dl = (AliDataLoader*)next())) | |
262 | { | |
263 | retval = dl->GetEvent(); | |
264 | if (retval) | |
265 | { | |
21bf7095 | 266 | AliError(Form("Error occured while GetEvent for %s",dl->GetName())); |
88cb7938 | 267 | return retval; |
268 | } | |
269 | } | |
270 | ||
271 | return 0; | |
272 | } | |
273 | ||
274 | /******************************************************************/ | |
275 | ||
276 | TFolder* AliLoader::GetTopFolder() | |
277 | { | |
278 | //returns TOP aliroot folder, just a simple interface to AliConfig (gives shorter notation) | |
279 | return AliConfig::Instance()->GetTopFolder(); | |
280 | } | |
281 | ||
282 | /******************************************************************/ | |
283 | ||
284 | TFolder* AliLoader::GetEventFolder() | |
285 | { | |
286 | //get EVENT folder (data that are changing from event to event, even in single run) | |
287 | return fEventFolder; | |
288 | } | |
289 | /******************************************************************/ | |
290 | TFolder* AliLoader::GetDataFolder() | |
291 | { | |
292 | //returns the folder speciofic to given detector e.g. /Folders/Event/Data/ | |
293 | if (!fDataFolder) | |
294 | { | |
e191bb57 | 295 | fDataFolder = dynamic_cast<TFolder*>(GetEventFolder()->FindObject(AliConfig::Instance()->GetDataFolderName())); |
88cb7938 | 296 | |
297 | if (!fDataFolder) | |
298 | { | |
21bf7095 | 299 | AliFatal("Can not find AliRoot data folder. Aborting"); |
88cb7938 | 300 | return 0x0; |
301 | } | |
302 | } | |
303 | return fDataFolder; | |
304 | } | |
305 | ||
306 | /*****************************************************************************/ | |
307 | ||
308 | TFolder* AliLoader::GetTasksFolder() | |
309 | { | |
310 | //Returns pointer to Folder with Alice Tasks | |
311 | if (!fTasksFolder) | |
312 | { | |
e191bb57 | 313 | fTasksFolder = dynamic_cast<TFolder*>(GetTopFolder()->FindObject(AliConfig::GetTasksFolderName())); |
88cb7938 | 314 | |
315 | if (!fTasksFolder) | |
316 | { | |
21bf7095 | 317 | AliFatal("Can not find tasks folder. Aborting"); |
88cb7938 | 318 | return 0x0; |
319 | } | |
320 | } | |
321 | return fTasksFolder; | |
322 | ||
323 | } | |
324 | /*****************************************************************************/ | |
325 | ||
326 | TFolder* AliLoader::GetModulesFolder() | |
327 | { | |
d0d4a6b3 | 328 | //returns pointer to the folder containing modules |
88cb7938 | 329 | if (!fModuleFolder) |
330 | { | |
331 | fModuleFolder = dynamic_cast<TFolder*>(GetEventFolder()->FindObjectAny(AliConfig::GetModulesFolderName())); | |
332 | ||
333 | if (!fModuleFolder) | |
334 | { | |
21bf7095 | 335 | AliFatal("Can not find modules folder. Aborting"); |
88cb7938 | 336 | return 0x0; |
337 | } | |
338 | } | |
339 | return fModuleFolder; | |
340 | ||
341 | } | |
342 | /*****************************************************************************/ | |
343 | ||
344 | TFolder* AliLoader::GetQAFolder() | |
345 | { | |
346 | //returns folder with Quality assurance | |
347 | if (fQAFolder == 0x0) | |
348 | { | |
349 | TObject *obj = GetEventFolder()->FindObjectAny(AliConfig::Instance()->GetQAFolderName()); | |
350 | fQAFolder = (obj)?dynamic_cast<TFolder*>(obj):0x0; | |
351 | ||
352 | if (fQAFolder == 0x0) | |
353 | { | |
21bf7095 | 354 | AliFatal("Can not find Quality Assurance folder. Aborting"); |
88cb7938 | 355 | return 0x0; |
356 | } | |
357 | } | |
358 | return fQAFolder; | |
359 | ||
360 | } | |
361 | /*****************************************************************************/ | |
d0d4a6b3 | 362 | TTask* AliLoader::SDigitizer() const |
88cb7938 | 363 | { |
364 | //returns SDigitizer task for this detector | |
365 | return GetSDigitsDataLoader()->GetBaseTaskLoader()->Task(); | |
366 | ||
367 | } | |
368 | /*****************************************************************************/ | |
369 | ||
d0d4a6b3 | 370 | AliDigitizer* AliLoader::Digitizer() const |
88cb7938 | 371 | { |
372 | //returns Digitizer task for this detector | |
373 | return dynamic_cast<AliDigitizer*>(GetDigitsDataLoader()->GetBaseTaskLoader()->Task()); | |
374 | } | |
375 | /*****************************************************************************/ | |
376 | ||
d0d4a6b3 | 377 | TTask* AliLoader::Reconstructioner() const |
88cb7938 | 378 | { |
379 | //returns Recontructioner (Cluster Finder, Cluster Maker, | |
380 | //or whatever you want to call it) task for this detector | |
381 | return GetRecPointsDataLoader()->GetBaseTaskLoader()->Task(); | |
382 | } | |
383 | /*****************************************************************************/ | |
384 | ||
d0d4a6b3 | 385 | TTask* AliLoader::Tracker() const |
88cb7938 | 386 | { |
387 | //returns tracker | |
388 | return dynamic_cast<TTask*>(GetTracksDataLoader()->GetBaseTaskLoader()->Task()); | |
389 | } | |
390 | ||
391 | /*****************************************************************************/ | |
d0d4a6b3 | 392 | TTask* AliLoader::PIDTask() const |
88cb7938 | 393 | { |
394 | //returns tracker | |
395 | return dynamic_cast<TTask*>(GetRecParticlesDataLoader()->GetBaseTaskLoader()->Task()); | |
396 | } | |
397 | ||
398 | /*****************************************************************************/ | |
399 | ||
d0d4a6b3 | 400 | TTask* AliLoader::QAtask(const char* name) const |
88cb7938 | 401 | { |
d0d4a6b3 | 402 | // Returns pointer to the quality assurance task |
88cb7938 | 403 | TTask* qat = AliRunLoader::GetRunQATask(); |
404 | if ( qat == 0x0 ) | |
405 | { | |
21bf7095 | 406 | AliError(Form("Can not get RunQATask. (Name:%s)",GetName())); |
88cb7938 | 407 | return 0x0; |
408 | } | |
409 | ||
410 | TString dqatname(fDetectorName + AliConfig::Instance()->GetQATaskName()); | |
411 | TTask* dqat = dynamic_cast<TTask*>(qat->GetListOfTasks()->FindObject(dqatname)); | |
412 | ||
413 | if ( dqat == 0x0 ) | |
414 | { | |
21bf7095 | 415 | AliError(Form("Can not find QATask in RunQATask for %s",GetDetectorName().Data())); |
88cb7938 | 416 | return 0x0; |
417 | } | |
418 | ||
419 | if (strlen(name) == 0) return dqat; | |
420 | ||
421 | TList* list = dqat->GetListOfTasks(); | |
422 | ||
423 | TIter it(list) ; | |
424 | TTask * task = 0 ; | |
425 | while((task = static_cast<TTask *>(it.Next()) )) | |
426 | { | |
427 | TString taskname(task->GetName()) ; | |
428 | if(taskname.BeginsWith(name)) | |
429 | return task ; | |
430 | } | |
21bf7095 | 431 | AliError(Form("Can not find sub-task with name starting with %s in task %s",name,dqat->GetName())); |
88cb7938 | 432 | return 0x0; |
433 | } | |
434 | /*****************************************************************************/ | |
435 | ||
436 | TDirectory* AliLoader::ChangeDir(TFile* file, Int_t eventno) | |
437 | { | |
438 | //changes the root directory in "file" to "dirname" which corresponds to event 'eventno' | |
439 | //in case of success returns the pointer to directory | |
440 | //else NULL | |
441 | ||
442 | if (file == 0x0) | |
443 | { | |
21bf7095 | 444 | AliErrorClass("File is null"); |
88cb7938 | 445 | return 0x0; |
446 | } | |
447 | if (file->IsOpen() == kFALSE) | |
448 | { | |
21bf7095 | 449 | AliErrorClass("File is not opened"); |
88cb7938 | 450 | return 0x0; |
451 | } | |
452 | ||
453 | TString dirname("Event"); | |
454 | dirname+=eventno; | |
21bf7095 | 455 | AliDebugClass(1, Form("Changing Dir to %s in file %s.",dirname.Data(),file->GetName())); |
88cb7938 | 456 | |
457 | Bool_t result; | |
458 | ||
459 | TDirectory* dir = dynamic_cast<TDirectory*>(file->Get(dirname)); | |
460 | ||
461 | if (dir == 0x0) | |
462 | { | |
21bf7095 | 463 | AliDebugClass(1, Form("Can not find directory %s in file %s, creating...", |
464 | dirname.Data(),file->GetName())); | |
88cb7938 | 465 | |
466 | if (file->IsWritable() == kFALSE) | |
467 | { | |
21bf7095 | 468 | AliErrorClass(Form("Can not create directory. File %s in not writable.", |
469 | file->GetName())); | |
88cb7938 | 470 | return 0x0; |
471 | } | |
472 | ||
473 | TDirectory* newdir = file->mkdir(dirname); | |
474 | if (newdir == 0x0) | |
475 | { | |
21bf7095 | 476 | AliErrorClass(Form("Failed to create new directory in file %s.", |
477 | file->GetName())); | |
88cb7938 | 478 | return 0x0; |
479 | } | |
480 | result = file->cd(dirname); | |
481 | if (result == kFALSE) | |
482 | { | |
483 | return 0x0; | |
484 | } | |
485 | } | |
486 | else | |
487 | { | |
488 | file->cd();//make a file active | |
489 | file->cd(dirname);//cd event dir | |
490 | } | |
491 | ||
492 | return gDirectory; | |
493 | } | |
494 | /*****************************************************************************/ | |
495 | ||
d0d4a6b3 | 496 | TString AliLoader::GetUnixDir() const |
88cb7938 | 497 | { |
498 | //This Method will manage jumping through unix directories in case of | |
499 | //run with more events per run than defined in gAlice | |
500 | ||
501 | TString dir; | |
502 | ||
503 | return dir; | |
504 | } | |
505 | /*****************************************************************************/ | |
506 | /************************************************************/ | |
507 | ||
508 | void AliLoader::MakeTree(Option_t *option) | |
509 | { | |
510 | //Makes a tree depending on option | |
511 | // H: - Hits | |
512 | // D: - Digits | |
513 | // S: - Summable Digits | |
514 | // R: - Reconstructed Points (clusters) | |
515 | // T: - Tracks (tracklets) | |
516 | ||
517 | const char *oH = strstr(option,"H"); | |
518 | const char *oD = strstr(option,"D"); | |
519 | const char *oS = strstr(option,"S"); | |
520 | const char *oR = strstr(option,"R"); | |
521 | const char *oT = strstr(option,"T"); | |
522 | const char *oP = strstr(option,"P"); | |
523 | ||
524 | if (oH) MakeHitsContainer(); | |
525 | if (oD) MakeDigitsContainer(); | |
526 | if (oS) MakeSDigitsContainer(); | |
527 | if (oR) MakeRecPointsContainer(); | |
528 | if (oT) MakeTracksContainer(); | |
529 | if (oP) MakeRecParticlesContainer(); | |
530 | } | |
531 | ||
532 | /*****************************************************************************/ | |
9bb30bcb | 533 | Int_t AliLoader::WriteHits(Option_t* opt) const |
88cb7938 | 534 | { |
d0d4a6b3 | 535 | // Writes hits |
88cb7938 | 536 | AliDataLoader* dl = GetHitsDataLoader(); |
537 | Int_t ret = dl->WriteData(opt); | |
538 | return ret; | |
539 | } | |
540 | /*****************************************************************************/ | |
541 | ||
9bb30bcb | 542 | Int_t AliLoader::WriteSDigits(Option_t* opt) const |
88cb7938 | 543 | { |
d0d4a6b3 | 544 | // Writes summable digits |
88cb7938 | 545 | AliDataLoader* dl = GetSDigitsDataLoader(); |
546 | Int_t ret = dl->WriteData(opt); | |
547 | return ret; | |
548 | } | |
549 | ||
550 | /*****************************************************************************/ | |
551 | ||
9bb30bcb | 552 | Int_t AliLoader::PostSDigitizer(TTask* sdzer) const |
88cb7938 | 553 | { |
d0d4a6b3 | 554 | // Posts sdigitizer |
88cb7938 | 555 | return GetSDigitsDataLoader()->GetBaseTaskLoader()->Post(sdzer); |
556 | } | |
557 | /*****************************************************************************/ | |
558 | ||
9bb30bcb | 559 | Int_t AliLoader::PostDigitizer(AliDigitizer* task) const |
88cb7938 | 560 | { |
d0d4a6b3 | 561 | // Posts digitizer |
88cb7938 | 562 | return GetDigitsDataLoader()->GetBaseTaskLoader()->Post(task); |
563 | } | |
564 | /*****************************************************************************/ | |
565 | ||
9bb30bcb | 566 | Int_t AliLoader::PostReconstructioner(TTask* task) const |
88cb7938 | 567 | { |
d0d4a6b3 | 568 | // Posts Reconstructioner |
88cb7938 | 569 | return GetRecPointsDataLoader()->GetBaseTaskLoader()->Post(task); |
570 | } | |
571 | /*****************************************************************************/ | |
572 | ||
9bb30bcb | 573 | Int_t AliLoader::PostTracker(TTask* task) const |
88cb7938 | 574 | { |
d0d4a6b3 | 575 | // Posts a tracker |
88cb7938 | 576 | return GetTracksDataLoader()->GetBaseTaskLoader()->Post(task); |
577 | } | |
578 | /*****************************************************************************/ | |
579 | ||
9bb30bcb | 580 | Int_t AliLoader::PostPIDTask(TTask* task) const |
88cb7938 | 581 | { |
d0d4a6b3 | 582 | // Posts particle identification task |
88cb7938 | 583 | return GetRecParticlesDataLoader()->GetBaseTaskLoader()->Post(task); |
584 | } | |
585 | /*****************************************************************************/ | |
586 | ||
587 | TObject** AliLoader::GetDetectorDataRef(TObject *obj) | |
588 | { | |
d0d4a6b3 | 589 | // Returns pointer to an entry in the list of folders pointing to "obj" |
88cb7938 | 590 | if (obj == 0x0) |
591 | { | |
592 | return 0x0; | |
593 | } | |
594 | return GetDetectorDataFolder()->GetListOfFolders()->GetObjectRef(obj) ; | |
595 | } | |
596 | /*****************************************************************************/ | |
597 | ||
598 | TObject** AliLoader::SDigitizerRef() | |
599 | { | |
d0d4a6b3 | 600 | // Returns pointer to a Runloader's task-list entry pointing to SDigitizer |
88cb7938 | 601 | TTask* rsd = AliRunLoader::GetRunSDigitizer(); |
602 | if (rsd == 0x0) | |
603 | { | |
604 | return 0x0; | |
605 | } | |
606 | return rsd->GetListOfTasks()->GetObjectRef(SDigitizer()); | |
607 | } | |
608 | /*****************************************************************************/ | |
609 | ||
610 | TObject** AliLoader::DigitizerRef() | |
611 | { | |
d0d4a6b3 | 612 | // Returns pointer to a Runloader's task-list entry pointing to Digitizer |
88cb7938 | 613 | TTask* rd = AliRunLoader::GetRunDigitizer(); |
614 | if (rd == 0x0) | |
615 | { | |
616 | return 0x0; | |
617 | } | |
618 | return rd->GetListOfTasks()->GetObjectRef(Digitizer()) ; | |
619 | } | |
620 | /*****************************************************************************/ | |
621 | ||
622 | TObject** AliLoader::ReconstructionerRef() | |
623 | { | |
d0d4a6b3 | 624 | // Returns pointer to a Runloader's task-list entry pointing to Reconstructioner |
88cb7938 | 625 | TTask* rrec = AliRunLoader::GetRunReconstructioner(); |
626 | if (rrec == 0x0) | |
627 | { | |
628 | return 0x0; | |
629 | } | |
630 | return rrec->GetListOfTasks()->GetObjectRef(Reconstructioner()); | |
631 | } | |
632 | /*****************************************************************************/ | |
633 | ||
634 | TObject** AliLoader::TrackerRef() | |
635 | { | |
d0d4a6b3 | 636 | // Returns pointer to a Runloader's task-list entry pointing to Tracker |
88cb7938 | 637 | TTask* rrec = AliRunLoader::GetRunTracker(); |
638 | if (rrec == 0x0) | |
639 | { | |
640 | return 0x0; | |
641 | } | |
642 | return rrec->GetListOfTasks()->GetObjectRef(Tracker()); | |
643 | } | |
644 | /*****************************************************************************/ | |
645 | ||
646 | TObject** AliLoader::PIDTaskRef() | |
647 | { | |
d0d4a6b3 | 648 | // Returns pointer to a Runloader's task-list entry pointing to PIDTask |
88cb7938 | 649 | TTask* rrec = AliRunLoader::GetRunPIDTask(); |
650 | if (rrec == 0x0) | |
651 | { | |
652 | return 0x0; | |
653 | } | |
654 | return rrec->GetListOfTasks()->GetObjectRef(PIDTask()); | |
655 | } | |
656 | ||
657 | /*****************************************************************************/ | |
658 | void AliLoader::CleanFolders() | |
659 | { | |
660 | //Cleans all posted objects == removes from folders and deletes them | |
661 | TIter next(fDataLoaders); | |
662 | AliDataLoader* dl; | |
663 | while ((dl = (AliDataLoader*)next())) | |
664 | { | |
21bf7095 | 665 | AliDebug(1, Form("name = %s cleaning",dl->GetName())); |
88cb7938 | 666 | dl->Clean(); |
667 | } | |
668 | } | |
669 | /*****************************************************************************/ | |
670 | ||
671 | /*****************************************************************************/ | |
672 | ||
673 | void AliLoader::CleanSDigitizer() | |
674 | { | |
675 | //removes and deletes detector task from Run Task | |
3637d19d | 676 | if ( GetSDigitsDataLoader()->GetBaseTaskLoader() == 0x0 ) |
677 | { | |
21bf7095 | 678 | AliWarning("Task Loader for SDigits does not exist"); |
3637d19d | 679 | return; |
680 | } | |
681 | GetSDigitsDataLoader()->GetBaseTaskLoader()->Clean(); | |
88cb7938 | 682 | } |
683 | /*****************************************************************************/ | |
684 | ||
685 | void AliLoader::CleanDigitizer() | |
686 | { | |
687 | //removes and deletes detector task from Run Task | |
3637d19d | 688 | if ( GetDigitsDataLoader()->GetBaseTaskLoader() == 0x0 ) |
689 | { | |
21bf7095 | 690 | AliWarning("Task Loader for Digits does not exist"); |
3637d19d | 691 | return; |
692 | } | |
693 | GetDigitsDataLoader()->GetBaseTaskLoader()->Clean(); | |
88cb7938 | 694 | } |
695 | /*****************************************************************************/ | |
696 | ||
697 | void AliLoader::CleanReconstructioner() | |
698 | { | |
699 | //removes and deletes detector Reconstructioner from Run Reconstructioner | |
3637d19d | 700 | if ( GetRecPointsDataLoader()->GetBaseTaskLoader() == 0x0 ) |
701 | { | |
21bf7095 | 702 | AliWarning("Task Loader for SDigits does not exist"); |
3637d19d | 703 | return; |
704 | } | |
705 | GetRecPointsDataLoader()->GetBaseTaskLoader()->Clean(); | |
88cb7938 | 706 | } |
707 | /*****************************************************************************/ | |
708 | ||
709 | void AliLoader::CleanTracker() | |
710 | { | |
3637d19d | 711 | //removes and deletes detector task from Run Task |
712 | if ( GetTracksDataLoader()->GetBaseTaskLoader() == 0x0 ) | |
713 | { | |
21bf7095 | 714 | AliWarning("Task Loader for Tracks does not exist"); |
3637d19d | 715 | return; |
716 | } | |
717 | GetTracksDataLoader()->GetBaseTaskLoader()->Clean(); | |
88cb7938 | 718 | } |
719 | /*****************************************************************************/ | |
720 | ||
721 | void AliLoader::CleanPIDTask() | |
722 | { | |
723 | //removes and deletes detector Reconstructioner from Run Reconstructioner | |
88cb7938 | 724 | |
3637d19d | 725 | if ( GetRecParticlesDataLoader()->GetBaseTaskLoader() == 0x0 ) |
726 | { | |
21bf7095 | 727 | AliWarning("Task Loader for Reconstructed Particles does not exist"); |
3637d19d | 728 | return; |
729 | } | |
730 | GetRecParticlesDataLoader()->GetBaseTaskLoader()->Clean(); | |
88cb7938 | 731 | } |
732 | /*****************************************************************************/ | |
733 | ||
734 | Int_t AliLoader::ReloadAll() | |
735 | { | |
d0d4a6b3 | 736 | // Calling Reload function for all the data loaders |
88cb7938 | 737 | TIter next(fDataLoaders); |
738 | AliDataLoader* dl; | |
739 | ||
740 | while((dl = (AliDataLoader*)next())) | |
741 | { | |
742 | Int_t err = dl->Reload(); | |
743 | if (err) | |
744 | { | |
21bf7095 | 745 | AliError(Form("Reload returned error for %s",dl->GetName())); |
88cb7938 | 746 | return err; |
747 | } | |
748 | } | |
749 | return 0; | |
750 | } | |
751 | /*****************************************************************************/ | |
752 | ||
753 | void AliLoader::CloseFiles() | |
754 | { | |
755 | //close files for data loaders | |
756 | TIter next(fDataLoaders); | |
757 | AliDataLoader* dl; | |
758 | while((dl = (AliDataLoader*)next())) | |
759 | { | |
760 | dl->CloseFile(); | |
761 | } | |
762 | } | |
763 | /*****************************************************************************/ | |
764 | ||
765 | Int_t AliLoader::SetEventFolder(TFolder* eventfolder) | |
766 | { | |
d0d4a6b3 | 767 | //sets the event folder |
88cb7938 | 768 | if (eventfolder == 0x0) |
769 | { | |
21bf7095 | 770 | AliError("Stupid joke. Argument is NULL"); |
88cb7938 | 771 | return 1; |
772 | } | |
773 | ||
774 | fEventFolder = eventfolder; | |
775 | TIter next(fDataLoaders); | |
776 | AliDataLoader* dl; | |
777 | ||
778 | while((dl = (AliDataLoader*)next())) | |
779 | { | |
780 | dl->SetEventFolder(fEventFolder); | |
781 | dl->SetFolder(GetDetectorDataFolder()); //Must exists - ensure register is called before | |
782 | } | |
783 | ||
784 | return 0; | |
785 | }//sets the event folder | |
786 | /*****************************************************************************/ | |
787 | ||
788 | Int_t AliLoader::Register(TFolder* eventFolder) | |
789 | { | |
790 | //triggers creation of subfolders for a given detector | |
791 | //this method is called when session is read from disk | |
792 | // | |
793 | //warning: AliDetector in constructor (not default) calls | |
794 | //creation of folder structure as well (some detectors needs folders | |
795 | //alrady in constructors) | |
796 | ||
21bf7095 | 797 | AliDebug(1, Form("Name is %s.",GetName())); |
88cb7938 | 798 | if (eventFolder == 0x0) |
799 | { | |
21bf7095 | 800 | AliError("Event folder is not set."); |
88cb7938 | 801 | return 1; |
802 | } | |
803 | Int_t retval = AliConfig::Instance()->AddDetector(eventFolder,fDetectorName,fDetectorName); | |
804 | if(retval) | |
805 | { | |
21bf7095 | 806 | AliError(Form("Can not create tasks and/or folders for %s. Event folder name is %s", |
807 | fDetectorName.Data(),eventFolder->GetName())); | |
88cb7938 | 808 | return retval; |
809 | } | |
810 | SetEventFolder(eventFolder); | |
811 | return 0; | |
812 | } | |
813 | /*****************************************************************************/ | |
814 | AliRunLoader* AliLoader::GetRunLoader() | |
815 | { | |
816 | //gets the run-loader from event folder | |
817 | AliRunLoader* rg = 0x0; | |
024a7e64 | 818 | TObject * obj = GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName()); |
88cb7938 | 819 | if (obj) rg = dynamic_cast<AliRunLoader*>(obj); |
820 | return rg; | |
821 | } | |
822 | /*****************************************************************************/ | |
823 | Bool_t AliLoader::TestFileOption(Option_t* opt) | |
824 | { | |
825 | //tests the TFile::Option | |
826 | //if file is truncated at opening moment ("recreate", "new" or "create") returns kFALSE; | |
827 | //else kTRUE (means opened with "read" or "update" mode) | |
828 | TString option(opt); | |
829 | if (option.CompareTo("recreate",TString::kIgnoreCase) == 0) return kFALSE; | |
830 | if (option.CompareTo("new",TString::kIgnoreCase) == 0) return kFALSE; | |
831 | if (option.CompareTo("create",TString::kIgnoreCase) == 0) return kFALSE; | |
832 | return kTRUE; | |
833 | } | |
834 | /*****************************************************************************/ | |
835 | void AliLoader::SetDirName(TString& dirname) | |
836 | { | |
837 | //adds "dirname/" to each file | |
838 | TIter next(fDataLoaders); | |
839 | AliDataLoader* dl; | |
840 | while((dl = (AliDataLoader*)next())) | |
841 | { | |
842 | dl->SetDirName(dirname); | |
843 | } | |
844 | } | |
845 | ||
846 | /*****************************************************************************/ | |
847 | ||
9bb30bcb | 848 | void AliLoader::SetDigitsFileNameSuffix(const TString& suffix) const |
88cb7938 | 849 | { |
850 | //adds the suffix before ".root", | |
851 | //e.g. TPC.Digits.root -> TPC.DigitsMerged.root | |
852 | //made on Jiri Chudoba demand | |
853 | GetDigitsDataLoader()->SetFileNameSuffix(suffix); | |
854 | } | |
855 | /*****************************************************************************/ | |
856 | ||
857 | void AliLoader::SetCompressionLevel(Int_t cl) | |
858 | { | |
859 | //sets comression level for data defined by di | |
860 | TIter next(fDataLoaders); | |
861 | AliDataLoader* dl; | |
862 | while((dl = (AliDataLoader*)next())) | |
863 | { | |
864 | dl->SetCompressionLevel(cl); | |
865 | } | |
866 | } | |
867 | /*****************************************************************************/ | |
868 | ||
869 | void AliLoader::Clean() | |
870 | { | |
871 | //Cleans all data loaders | |
872 | TIter next(fDataLoaders); | |
873 | AliDataLoader* dl; | |
874 | while((dl = (AliDataLoader*)next())) | |
875 | { | |
876 | dl->Clean(); | |
877 | } | |
878 | } | |
879 | /*****************************************************************************/ | |
880 | ||
881 | void AliLoader::Clean(const TString& name) | |
882 | { | |
d0d4a6b3 | 883 | // Removes object with "name" from the detector's data folder |
884 | // and from the memory | |
88cb7938 | 885 | TObject* obj = GetDetectorDataFolder()->FindObject(name); |
886 | if(obj) | |
887 | { | |
21bf7095 | 888 | AliDebug(1, Form("name=%s, cleaning %s.",GetName(),name.Data())); |
88cb7938 | 889 | GetDetectorDataFolder()->Remove(obj); |
890 | delete obj; | |
891 | } | |
892 | } | |
893 | ||
894 | /*****************************************************************************/ | |
895 | ||
896 | Bool_t AliLoader::IsOptionWritable(const TString& opt) | |
897 | { | |
d0d4a6b3 | 898 | // Returns "true" if the option means also "writable" |
88cb7938 | 899 | if (opt.CompareTo("recreate",TString::kIgnoreCase)) return kTRUE; |
900 | if (opt.CompareTo("new",TString::kIgnoreCase)) return kTRUE; | |
901 | if (opt.CompareTo("create",TString::kIgnoreCase)) return kTRUE; | |
902 | if (opt.CompareTo("update",TString::kIgnoreCase)) return kTRUE; | |
903 | return kFALSE; | |
904 | } | |
905 | /*****************************************************************************/ | |
906 | ||
21bf7095 | 907 | Int_t AliLoader::GetDebug() |
908 | { | |
909 | AliWarningClass("Don't use this method any more, use AliDebug instead"); | |
910 | return AliDebugLevelClass(); | |
911 | } | |
912 | /*****************************************************************************/ | |
913 | ||
914 | void AliLoader::SetDebug(Int_t deb) | |
915 | { | |
916 | // Sets debug level | |
917 | AliLog::SetClassDebugLevel("AliRunLoader", deb); | |
918 | AliLog::SetClassDebugLevel("AliLoader", deb); | |
919 | AliLog::SetClassDebugLevel("AliDataLoader", deb); | |
920 | AliLog::SetClassDebugLevel("AliBaseLoader", deb); | |
921 | AliLog::SetClassDebugLevel("AliObjectLoader", deb); | |
922 | AliLog::SetClassDebugLevel("AliTreeLoader", deb); | |
923 | AliLog::SetClassDebugLevel("AliTaskLoader", deb); | |
924 | AliLog::SetClassDebugLevel("AliConfig", deb); | |
925 | } | |
926 | /*****************************************************************************/ | |
927 | ||
88cb7938 | 928 | void AliLoader::SetTAddrInDet() |
929 | { | |
930 | //calls SetTreeAddress for corresponding detector | |
931 | AliRunLoader* rl = GetRunLoader(); | |
932 | if (rl == 0x0) return; | |
933 | AliRun* ar = rl->GetAliRun(); | |
934 | if (ar == 0x0) return; | |
935 | AliDetector* det = ar->GetDetector(fDetectorName); | |
936 | if (det == 0x0) return; | |
937 | det->SetTreeAddress(); | |
938 | } | |
939 | /*****************************************************************************/ | |
f0f6f856 | 940 | |
941 | void AliLoader::Synchronize() | |
942 | { | |
943 | //synchrinizes all writtable files | |
944 | TIter next(fDataLoaders); | |
945 | AliDataLoader* dl; | |
946 | while ((dl = (AliDataLoader*)next())) | |
947 | { | |
948 | dl->Synchronize(); | |
949 | } | |
950 | ||
951 | } | |
952 | /*****************************************************************************/ | |
88cb7938 | 953 | /*****************************************************************************/ |
954 | /*****************************************************************************/ | |
955 |