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