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