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