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