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