1 #include <AliDataLoader.h>
2 //__________________________________________
3 /////////////////////////////////////////////////////////////////////////////////////////////
5 // class AliDataLoader //
7 // Container of all data needed for full //
8 // description of each data type //
9 // (Hits, Kine, ...) //
11 // Each data loader has a basic standard setup of BaseLoaders //
12 // which can be identuified by indexes (defined by EStdBasicLoaders) //
13 // Data managed by these standard base loaders has fixed naming convention //
14 // e.g. - tree with hits is always named TreeH //
15 // (defined in AliLoader::fgkDefaultHitsContainerName) //
16 // - task DtectorName+Name defined //
18 // EStdBasicLoaders idx Object Type Description //
19 // kData 0 TTree or TObject main data itself (hits,digits,...) //
20 // kTask 1 TTask object producing main data //
21 // kQA 2 TTree quality assurance tree //
22 // kQATask 3 TTask task producing QA object //
25 // User can define and add more basic loaders even Run Time. //
26 // Caution: in order to save information about added base loader //
27 // user must rewrite Run Loader to galice.file, overwriting old setup //
29 /////////////////////////////////////////////////////////////////////////////////////////////
37 #include "AliRunLoader.h"
39 ClassImp(AliDataLoader)
41 AliDataLoader::AliDataLoader():
56 /*****************************************************************************/
58 AliDataLoader::AliDataLoader(const char* filename, const char* contname, const char* name, Option_t* opt):
65 fBaseLoaders(new TObjArray(4)),
73 // creates a 0 loader, depending on option, default "T" is specialized loader for trees
74 // else standard object loader
75 // trees needs special care, becouse we need to set dir before writing
77 Info("AliDataLoader","File name is %s",fFileName.Data());
81 if (option.CompareTo("T",TString::kIgnoreCase) == 0)
82 bl = new AliTreeLoader(contname,this);
84 bl = new AliObjectLoader(contname,this);
85 fBaseLoaders->AddAt(bl,kData);
88 /*****************************************************************************/
90 AliDataLoader::~AliDataLoader()
95 /*****************************************************************************/
97 Int_t AliDataLoader::SetEvent()
99 //basically the same that GetEvent but do not post data to folders
100 AliRunLoader* rl = GetRunLoader();
103 Error("SetEvent","Can not get RunGettr");
107 Int_t evno = rl->GetEventNumber();
109 TIter next(fBaseLoaders);
111 while ((bl = (AliBaseLoader*)next()))
113 if (bl->DoNotReload() == kFALSE) bl->Clean();
122 if (GetDebug()) Info("SetEvent","Reloading new file. File opt is %s",fFileOption.Data());
123 OpenFile(fFileOption);
126 fDirectory = AliLoader::ChangeDir(fFile,evno);
127 if (fDirectory == 0x0)
129 Error("SetEvent","Can not chage directory in file %s",fFile->GetName());
135 /*****************************************************************************/
137 Int_t AliDataLoader::GetEvent()
139 // posts all loaded data from files to White Board
140 // event number is defined in RunLoader
143 // 0 - in case of no error
144 // 1 - event not found
146 //for each base laoder post, if was loaded before GetEvent
148 //call set event to switch to new directory in file
151 //post all data that were loaded before
152 // ->SetEvent does not call Unload, but only cleans White Board
153 // such IsLoaded flag stays untached
155 if ( AliLoader::TestFileOption(fFileOption) == kTRUE ) //if file is read or update mode try to post
156 { //in other case there is no sense to post: file is new
157 TIter nextbl(fBaseLoaders);
159 while ((bl = (AliBaseLoader*)nextbl()))
163 if (bl->DoNotReload() == kFALSE) bl->Post();
169 /*****************************************************************************/
171 Int_t AliDataLoader::OpenFile(Option_t* opt)
173 //Opens file named 'filename', and assigns pointer to it to 'file'
174 //jumps to fDirectoryectory corresponding to current event and stores the pointer to it in 'fDirectory'
175 //option 'opt' is passed to TFile::Open
178 if(fFile->IsOpen() == kTRUE)
180 Warning("OpenFile"," File %s already opened. First close it.",fFile->GetName());
185 Warning("OpenFile","Pointer to file %s is not null, but file is not opened",
192 TString fname(SetFileOffset(fFileName));
194 fFile = (TFile *)(gROOT->GetListOfFiles()->FindObject(fname));
197 if(fFile->IsOpen() == kTRUE)
199 Warning("OpenFile","File %s already opened by sombody else. First close it.",
206 fFile = TFile::Open(fname,fFileOption);//open the file
209 Error("OpenFile","Can not open file %s",fname.Data());
212 if (fFile->IsOpen() == kFALSE)
214 Error("OpenFile","Can not open file %s",fname.Data());
218 fFile->SetCompressionLevel(fCompressionLevel);
220 AliRunLoader* rg = GetRunLoader();
223 Error("OpenFile","Can not find Run-Loader in folder.");
226 Int_t evno = rg->GetEventNumber();
228 fDirectory = AliLoader::ChangeDir(fFile,evno);
229 if (fDirectory == 0x0)
231 Error("OpenFile","Can not chage fDirectory in file %s.",fFile->GetName());
236 /*****************************************************************************/
238 void AliDataLoader::Unload()
240 //unloads main data - shortcut method
241 GetBaseLoader(0)->Unload();
243 /*****************************************************************************/
245 void AliDataLoader::UnloadAll()
247 //Unloads all data and tasks
248 TIter next(fBaseLoaders);
250 while ((bl = (AliBaseLoader*)next()))
255 /*****************************************************************************/
257 Int_t AliDataLoader::Reload()
259 //Unloads and loads data again
260 if ( fFile == 0x0 ) return 0;
262 TBits loaded(fBaseLoaders->GetEntries());
263 TIter next(fBaseLoaders);
267 while ((bl = (AliBaseLoader*)next()))
271 loaded.SetBitNumber(i++,kTRUE);
279 while ((bl = (AliBaseLoader*)next()))
281 if (loaded.TestBitNumber(i++))
283 retval = bl->Load(fFileOption);
286 Error("Reload","Error occur while loading %s",bl->GetName());
295 /*****************************************************************************/
296 Int_t AliDataLoader::WriteData(Option_t* opt)
298 //Writes primary data == first BaseLoader
300 Info("WriteData","Writing %s container for %s data. Option is %s.",
301 GetBaseLoader(0)->GetName(),GetName(),opt);
302 return GetBaseLoader(0)->WriteData(opt);
304 /*****************************************************************************/
306 Int_t AliDataLoader::Load(Option_t* opt)
308 //Writes primary data == first BaseLoader
309 return GetBaseLoader(0)->Load(opt);
311 /*****************************************************************************/
313 Int_t AliDataLoader::SetEventFolder(TFolder* eventfolder)
315 //sets the event folder
316 if (eventfolder == 0x0)
318 Error("SetEventFolder","Stupid joke. Argument is NULL");
322 Info("SetFolder","name = %s Setting Event Folder named %s.",
323 GetName(),eventfolder->GetName());
325 fEventFolder = eventfolder;
328 /*****************************************************************************/
330 Int_t AliDataLoader::SetFolder(TFolder* folder)
335 Error("SetFolder","Stupid joke. Argument is NULL");
339 if (GetDebug()) Info("SetFolder","name = %s Setting folder named %s.",GetName(),folder->GetName());
342 TIter next(fBaseLoaders);
345 while ((bl = (AliBaseLoader*)next()))
347 bl->SetDataLoader(this);
352 /******************************************************************/
354 TFolder* AliDataLoader::GetEventFolder()
356 //get EVENT folder (data that are changing from event to event, even in single run)
357 if (GetDebug()) Info("GetEventFolder","EF = %#x");
360 /*****************************************************************************/
362 AliRunLoader* AliDataLoader::GetRunLoader()
364 //gets the run-loader from event folder
365 AliRunLoader* rg = 0x0;
366 TFolder* ef = GetEventFolder();
369 Error("GetRunLoader","Can not get event folder.");
372 rg = dynamic_cast<AliRunLoader*>(ef->FindObject(AliRunLoader::fgkRunLoaderName));
376 /*****************************************************************************/
377 void AliDataLoader::CloseFile()
380 TIter next(fBaseLoaders);
382 while ((bl = (AliBaseLoader*)next()))
384 if (bl->IsLoaded()) return;
388 Info("CloseFile","Closing and deleting (object) file.");
394 /*****************************************************************************/
396 void AliDataLoader::Clean()
399 GetBaseLoader(0)->Clean();
401 /*****************************************************************************/
403 void AliDataLoader::CleanAll()
405 //Cleans all folders and tasks
406 TIter next(fBaseLoaders);
408 while ((bl = (AliBaseLoader*)next()))
413 /*****************************************************************************/
415 void AliDataLoader::SetFileNameSuffix(const TString& suffix)
417 //adds the suffix before ".root",
418 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
419 //made on Jiri Chudoba demand
422 Info("SetFileNameSuffix","suffix=%s",suffix.Data());
423 Info("SetFileNameSuffix"," Digits File Name before: %s",fFileName.Data());
426 static TString dotroot(".root");
427 const TString& suffixdotroot = suffix + dotroot;
428 fFileName = fFileName.ReplaceAll(dotroot,suffixdotroot);
431 Info("SetDigitsFileNameSuffix"," after : %s",fFileName.Data());
433 /*****************************************************************************/
435 Bool_t AliDataLoader::CheckReload()
437 //checks if we have to reload given file
438 if (fFile == 0x0) return kFALSE;
439 TString tmp = SetFileOffset(fFileName);
440 if (tmp.CompareTo(fFile->GetName())) return kTRUE; //file must be reloaded
443 /*****************************************************************************/
445 const TString AliDataLoader::SetFileOffset(const TString& fname)
449 Long_t offset = (Long_t)GetRunLoader()->GetFileOffset();
450 if (offset < 1) return fname;
453 soffset += offset;//automatic conversion to string
454 TString dotroot(".root");
455 const TString& offfsetdotroot = offset + dotroot;
457 out = out.ReplaceAll(dotroot,offfsetdotroot);
458 if (GetDebug()) Info("SetFileOffset","in=%s out=%s.",fname.Data(),out.Data());
462 /*****************************************************************************/
464 void AliDataLoader::SetFileOption(Option_t* newopt)
467 if (fFileOption.CompareTo(newopt) == 0) return;
468 fFileOption = newopt;
471 /*****************************************************************************/
473 void AliDataLoader::SetCompressionLevel(Int_t cl)
475 //sets comression level for data defined by di
476 fCompressionLevel = cl;
477 if (fFile) fFile->SetCompressionLevel(cl);
479 /*****************************************************************************/
481 Int_t AliDataLoader::GetDebug() const
483 //it is not inline bacause AliLoader.h includes AliDataLoaer.h
484 //and there is circular depenedence
485 return AliLoader::GetDebug();
487 /*****************************************************************************/
489 void AliDataLoader::MakeTree()
491 AliTreeLoader* tl = dynamic_cast<AliTreeLoader*>(fBaseLoaders->At(0));
494 Error("MakeTree","Can not make a tree because main base loader is not a tree loader");
499 /*****************************************************************************/
501 Bool_t AliDataLoader::IsFileWritable() const
503 //returns true if file is writable
504 return (fFile)?fFile->IsWritable():kFALSE;
506 /*****************************************************************************/
508 Bool_t AliDataLoader::IsFileOpen() const
510 //returns true if file is writable
511 return (fFile)?fFile->IsOpen():kFALSE;
513 /*****************************************************************************/
515 Bool_t AliDataLoader::IsOptionContrary(const TString& option) const
517 //Checks if passed option is contrary with file open option
518 //which is passed option "writable" and existing option not wriable
519 //in reverse case it is no harm so it is NOT contrary
520 if (fFile == 0x0) return kFALSE; //file is not opened - no problem
522 if ( ( AliLoader::IsOptionWritable(option) == kTRUE ) && // passed option is writable and
523 ( AliLoader::IsOptionWritable(fFileOption) == kFALSE ) ) // existing one is not writable
530 /*****************************************************************************/
531 void AliDataLoader::AddBaseLoader(AliBaseLoader* bl)
533 //Adds a base loader to lits of base loaders managed by this data loader
534 //Managed data/task will be stored in proper root directory,
536 // - in case of tree/object - data folder connected with detector associated with this data loader
537 // - in case of task - parental task which defined in this AliTaskLoader
541 Warning("AddBaseLoader","Pointer is null.");
545 TObject* obj = fBaseLoaders->FindObject(bl->GetName());
548 Error("AddBaseLoader","Can not add this base loader.");
549 Error("AddBaseLoader","There exists already base loader which manages data named %s for this detector.");
554 fBaseLoaders->Add(bl);
557 /*****************************************************************************/
559 AliBaseLoader* AliDataLoader::GetBaseLoader(const TString& name) const
561 return dynamic_cast<AliBaseLoader*>(fBaseLoaders->FindObject(name));
563 /*****************************************************************************/
565 AliBaseLoader* AliDataLoader::GetBaseLoader(Int_t n) const
567 return dynamic_cast<AliBaseLoader*>(fBaseLoaders->At(n));
569 /*****************************************************************************/
571 TTree* AliDataLoader::Tree() const
573 //returns tree from the main base loader
574 //it is just shortcut method for comfort of user
575 //main storage object does not have to be Tree -
576 //that is why first we need to check if it is a TreeLoader
577 AliTreeLoader* tl = dynamic_cast<AliTreeLoader*>(GetBaseLoader(0));
578 if (tl == 0x0) return 0x0;
581 /*****************************************************************************/
583 void AliDataLoader::SetDirName(TString& dirname)
585 if (GetDebug()>9) Info("SetDirName","FileName before %s",fFileName.Data());
587 Int_t n = fFileName.Last('/');
589 if (GetDebug()>9) Info("SetDirName","Slash found on pos %d",n);
591 if (n > 0) fFileName = fFileName.Remove(0,n+1);
593 if (GetDebug()>9) Info("SetDirName","Core FileName %s",fFileName.Data());
595 fFileName = dirname + "/" + fFileName;
597 if (GetDebug()>9) Info("SetDirName","FileName after %s",fFileName.Data());
599 /*****************************************************************************/
600 AliObjectLoader* AliDataLoader::GetBaseDataLoader()
602 return dynamic_cast<AliObjectLoader*>(GetBaseLoader(kData));
604 /*****************************************************************************/
605 AliTaskLoader* AliDataLoader::GetBaseTaskLoader()
607 return dynamic_cast<AliTaskLoader*>(GetBaseLoader(kTask));
609 /*****************************************************************************/
610 AliBaseLoader* AliDataLoader::GetBaseQALoader()
612 return GetBaseLoader(kQA);
614 /*****************************************************************************/
615 AliTaskLoader* AliDataLoader::GetBaseQATaskLoader()
617 //returns pointer to QA base loader
618 return dynamic_cast<AliTaskLoader*>(GetBaseLoader(kQATask));
620 /*****************************************************************************/
621 void AliDataLoader::SetBaseDataLoader(AliBaseLoader* bl)
623 //sets data base loader
626 Error("SetBaseDataLoader","Parameter is null");
629 if (GetBaseDataLoader()) delete GetBaseDataLoader();
630 fBaseLoaders->AddAt(bl,kData);
632 /*****************************************************************************/
633 void AliDataLoader::SetBaseTaskLoader(AliTaskLoader* bl)
635 //sets Task base loader
638 Error("SetBaseTaskLoader","Parameter is null");
641 if (GetBaseTaskLoader()) delete GetBaseTaskLoader();
642 fBaseLoaders->AddAt(bl,kTask);
644 /*****************************************************************************/
645 void AliDataLoader::SetBaseQALoader(AliBaseLoader* bl)
647 //sets QA base loader
650 Error("SetBaseQALoader","Parameter is null");
653 if (GetBaseQALoader()) delete GetBaseQALoader();
654 fBaseLoaders->AddAt(bl,kQA);
656 /*****************************************************************************/
657 void AliDataLoader::SetBaseQATaskLoader(AliTaskLoader* bl)
659 //sets QA Task base loader
662 Error("SetBaseQATaskLoader","Parameter is null");
665 if (GetBaseQATaskLoader()) delete GetBaseQATaskLoader();
666 fBaseLoaders->AddAt(bl,kQATask);
669 /*****************************************************************************/
670 /*****************************************************************************/
671 /*****************************************************************************/
672 //__________________________________________
673 ///////////////////////////////////////////////////////////////////////////////
675 // class AliBaseLoader //
678 ///////////////////////////////////////////////////////////////////////////////
679 ClassImp(AliBaseLoader)
681 AliBaseLoader::AliBaseLoader():
683 fStoreInTopOfFile(kFALSE),
684 fDoNotReload(kFALSE),
688 /*****************************************************************************/
690 AliBaseLoader::AliBaseLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop):
691 TNamed(name,name+" Base Loader"),
693 fStoreInTopOfFile(storeontop),
694 fDoNotReload(storeontop),//if stored on top of file - this object is loaded ones pe
699 /*****************************************************************************/
701 Int_t AliBaseLoader::Load(Option_t* opt)
704 Info("Load","data type = %s, option = %s",GetName(),opt);
708 Warning("Load","Data <<%s>> are already loaded. Use ReloadData to force reload. Nothing done",GetName());
714 if (GetDataLoader()->IsFileOpen() == kTRUE)
716 if (GetDataLoader()->IsOptionContrary(opt) == kTRUE)
718 Error("Load","Data Type %s, Container Name %s", GetDataLoader()->GetName(),GetName());
719 Error("Load","File was already opened in READ-ONLY mode, while now WRITEABLE access is requested.");
720 Error("Load","Use AliDataLoader::SetOption to enforce change of access mode OR");
721 Error("Load","Load previosly loaded data with coherent option.");
727 retval = GetDataLoader()->OpenFile(opt);
730 Error("Load","Error occured while opening <<%s>> file",GetName());
734 //if file is recreated there is no sense to search for data to post and get Error message
735 if (AliLoader::TestFileOption(opt) == kFALSE)
737 AliTreeLoader* tl = dynamic_cast<AliTreeLoader*>(this);
738 if (tl) tl->MakeTree();
746 Error("Load","Error occured while posting %s from file to folder.",GetName());
753 /*****************************************************************************/
755 Int_t AliBaseLoader::Post()
757 //Posts data container to proper folders
759 if ( GetDirectory() == 0x0)
761 Error("Post","%s directory is NULL. Load before.",GetDataLoader()->GetName());
765 TObject* data = GetFromDirectory(fName);
768 //if such an obejct already exists - remove it first
773 //check if file is in update mode
774 Int_t fileupdate = GetDataLoader()->GetFileOption().CompareTo("update",TString::kIgnoreCase);
775 if ( fileupdate == 0)
776 { //if it is, it is normal that there is no data yet
779 Info("Post","Can not find %s in file %s (file is opened in UPDATE mode).",
780 GetName(),GetDataLoader()->GetFile()->GetName());
785 Warning("Post","Can not find %s in file %s", GetName(),GetDataLoader()->GetFile()->GetName());
790 /*****************************************************************************/
792 Int_t AliBaseLoader::Post(TObject* data)
794 //Posts data container to proper folders
797 Error("Post","Pointer to object is NULL");
800 TObject* obj = Get();
803 if (GetDebug()) Warning("Post","This object was already posted.");
808 Warning("PostData","Object named %s already exitsts in data folder. Removing it",GetName());
811 return AddToBoard(data);
813 /*****************************************************************************/
815 Int_t AliBaseLoader::WriteData(Option_t* opt)
817 //Writes data defined by di object
818 //opt might be "OVERWRITE" in case of forcing overwriting
820 Info("WriteData","Writing %s container for %s data. Option is %s.",
821 GetName(),GetDataLoader()->GetName(),opt);
823 TObject *data = Get();
825 {//did not get, nothing to write
826 Warning("WriteData","Tree named %s not found in folder. Nothing to write.",GetName());
830 //check if file is opened
831 if (GetDirectory() == 0x0)
834 GetDataLoader()->SetFileOption("UPDATE");
835 if (GetDataLoader()->OpenFile("UPDATE"))
837 //oops, can not open the file, give an error message and return error code
838 Error("WriteData","Can not open hits file. %s ARE NOT WRITTEN",GetName());
843 if (GetDataLoader()->IsFileWritable() == kFALSE)
845 Error("WriteData","File %s is not writable",GetDataLoader()->GetFileName().Data());
849 GetDirectory()->cd(); //set the proper directory active
851 //see if hits container already exists in this (root) directory
852 TObject* obj = GetFromDirectory(GetName());
854 { //if they exist, see if option OVERWRITE is used
855 const char *oOverWrite = strstr(opt,"OVERWRITE");
857 {//if it is not used - give an error message and return an error code
858 Error("WriteData","Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
863 if (GetDebug()) Info("WriteData","DataName = %s, opt = %s, data object name = %s",
864 GetName(),opt,data->GetName());
865 if (GetDebug()) Info("WriteData","File Name = %s, Directory Name = %s Directory's File Name = %s",
866 GetDataLoader()->GetFile()->GetName(),GetDirectory()->GetName(),
867 GetDirectory()->GetFile()->GetName());
869 if (GetDebug()) Info("WriteData","Writing data");
870 data->Write(0,TObject::kOverwrite);
872 fIsLoaded = kTRUE; // Just to ensure flag is on. Object can be posted manually to folder structure, not using loader.
877 /*****************************************************************************/
879 Int_t AliBaseLoader::Reload()
881 //Unloads and loads datat again - if loaded before
885 return Load(GetDataLoader()->GetFileOption());
889 /*****************************************************************************/
891 void AliBaseLoader::Clean()
893 //removes objects from folder/task
894 if (GetDebug()) Info("Clean","%s %s",GetName(),GetDataLoader()->GetName());
895 TObject* obj = Get();
899 Info("Clean","cleaning %s.",GetName());
900 RemoveFromBoard(obj);
904 /*****************************************************************************/
906 void AliBaseLoader::Unload()
910 GetDataLoader()->CloseFile();
912 /*****************************************************************************/
913 AliDataLoader* AliBaseLoader::GetDataLoader() const
915 if (fDataLoader == 0x0)
917 Fatal("GetDataLoader","Pointer to Data Loader is NULL");
921 /*****************************************************************************/
923 Int_t AliBaseLoader::GetDebug() const
925 return (Int_t)AliLoader::fgDebug;
928 TDirectory* AliBaseLoader::GetDirectory()
930 // returnd TDirectory where data are to be saved
931 //if fStoreInTopOfFile flag is true - returns pointer to file
932 return (fStoreInTopOfFile)?GetDataLoader()->GetFile():GetDataLoader()->GetDirectory();
934 /*****************************************************************************/
935 /*****************************************************************************/
936 /*****************************************************************************/
937 //__________________________________________
938 ///////////////////////////////////////////////////////////////////////////////
940 // class AliObjectLoader //
943 ///////////////////////////////////////////////////////////////////////////////
945 ClassImp(AliObjectLoader)
947 AliObjectLoader::AliObjectLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop):
948 AliBaseLoader(name,dl,storeontop)
952 /*****************************************************************************/
954 TFolder* AliObjectLoader::GetFolder() const
956 TFolder* df = GetDataLoader()->GetFolder();
959 Fatal("GetFolder","Data Folder is NULL");
963 /*****************************************************************************/
965 void AliObjectLoader::RemoveFromBoard(TObject* obj)
967 GetFolder()->Remove(obj);
969 /*****************************************************************************/
970 Int_t AliObjectLoader::AddToBoard(TObject* obj)
972 GetFolder()->Add(obj);
975 /*****************************************************************************/
977 TObject* AliObjectLoader::Get() const
979 return (GetFolder()) ? GetFolder()->FindObject(GetName()) : 0x0;
982 /*****************************************************************************/
983 /*****************************************************************************/
984 /*****************************************************************************/
985 //__________________________________________
986 ///////////////////////////////////////////////////////////////////////////////
988 // class AliTreeLoader //
991 ///////////////////////////////////////////////////////////////////////////////
993 ClassImp(AliTreeLoader)
995 AliTreeLoader::AliTreeLoader(const TString& name, AliDataLoader* dl,Bool_t storeontop):
996 AliObjectLoader(name,dl,storeontop)
1001 /*****************************************************************************/
1003 Int_t AliTreeLoader::WriteData(Option_t* opt)
1005 //Writes data defined by di object
1006 //opt might be "OVERWRITE" in case of forcing overwriting
1009 Info("WriteData","Writing %s container for %s data. Option is %s.",
1010 GetName(),GetDataLoader()->GetName(),opt);
1012 TObject *data = Get();
1014 {//did not get, nothing to write
1015 Warning("WriteData","Tree named %s not found in folder. Nothing to write.",GetName());
1019 //check if file is opened
1020 if (GetDirectory() == 0x0)
1022 //if not try to open
1023 GetDataLoader()->SetFileOption("UPDATE");
1024 if (GetDataLoader()->OpenFile("UPDATE"))
1026 //oops, can not open the file, give an error message and return error code
1027 Error("WriteData","Can not open hits file. %s ARE NOT WRITTEN",GetName());
1032 if (GetDataLoader()->IsFileWritable() == kFALSE)
1034 Error("WriteData","File %s is not writable",GetDataLoader()->GetFileName().Data());
1038 GetDirectory()->cd(); //set the proper directory active
1040 //see if hits container already exists in this (root) directory
1041 TObject* obj = GetFromDirectory(GetName());
1043 { //if they exist, see if option OVERWRITE is used
1044 const char *oOverWrite = strstr(opt,"OVERWRITE");
1046 {//if it is not used - give an error message and return an error code
1047 Error("WriteData","Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
1052 if (GetDebug()) Info("WriteData","DataName = %s, opt = %s, data object name = %s",
1053 GetName(),opt,data->GetName());
1054 if (GetDebug()) Info("WriteData","File Name = %s, Directory Name = %s Directory's File Name = %s",
1055 GetDataLoader()->GetFile()->GetName(),GetDirectory()->GetName(),
1056 GetDirectory()->GetFile()->GetName());
1058 //if a data object is a tree set the directory
1059 TTree* tree = dynamic_cast<TTree*>(data);
1060 if (tree) tree->SetDirectory(GetDirectory()); //forces setting the directory to this directory (we changed dir few lines above)
1062 if (GetDebug()) Info("WriteData","Writing tree");
1063 data->Write(0,TObject::kOverwrite);
1065 fIsLoaded = kTRUE; // Just to ensure flag is on. Object can be posted manually to folder structure, not using loader.
1070 /*****************************************************************************/
1072 void AliTreeLoader::MakeTree()
1074 //this virtual method creates the tree in the file
1078 Info("MakeTree","name = %s, Data Name = %s Tree already exists.",
1079 GetName(),GetDataLoader()->GetName());
1080 return;//tree already made
1083 Info("MakeTree","Making Tree named %s.",GetName());
1085 TString dtypename(GetDataLoader()->GetName());
1086 TTree* tree = new TTree(GetName(), dtypename + " Container"); //make a tree
1089 Error("MakeTree","Can not create %s tree.",GetName());
1092 tree->SetAutoSave(1000000000); //no autosave
1093 GetFolder()->Add(tree);
1094 WriteData("OVERWRITE");//write tree to the file
1098 /*****************************************************************************/
1099 /*****************************************************************************/
1100 /*****************************************************************************/
1101 //__________________________________________
1102 ///////////////////////////////////////////////////////////////////////////////
1104 // class AliTaskLoader //
1107 ///////////////////////////////////////////////////////////////////////////////
1109 ClassImp(AliTaskLoader)
1111 AliTaskLoader::AliTaskLoader(const TString& name, AliDataLoader* dl, TTask* parentaltask, Bool_t storeontop):
1112 AliBaseLoader(name,dl,storeontop),
1113 fParentalTask(parentaltask)
1118 /*****************************************************************************/
1120 void AliTaskLoader::RemoveFromBoard(TObject* obj)
1122 GetParentalTask()->GetListOfTasks()->Remove(obj);
1124 /*****************************************************************************/
1126 Int_t AliTaskLoader::AddToBoard(TObject* obj)
1128 TTask* task = dynamic_cast<TTask*>(obj);
1131 Error("AddToBoard","To TTask board can be added only tasks.");
1134 GetParentalTask()->Add(task);
1137 /*****************************************************************************/
1139 TObject* AliTaskLoader::Get() const
1141 return (GetParentalTask()) ? GetParentalTask()->GetListOfTasks()->FindObject(GetName()) : 0x0;
1143 /*****************************************************************************/
1145 TTask* AliTaskLoader::GetParentalTask() const
1147 //returns parental tasks for this task
1148 return fParentalTask;
1151 /*****************************************************************************/
1153 /*****************************************************************************/
1154 /*****************************************************************************/
1155 /*****************************************************************************/