1 #include "AliRunLoader.h"
2 //____________________________________________________________________
3 //////////////////////////////////////////////////////////////////////
5 // class AliRunLoader //
7 // This class aims to be the unque interface for managing data I/O. //
8 // It stores Loaders for all modules which, knows names //
9 // of the files were data are to be stored. //
11 // It aims to substitud AliRun in automatic data managing //
12 // thus there is no necessity of loading gAlice from file in order //
13 // to get access to the data. //
15 // Logical place to put the specific Loader to the given //
16 // detector is detector itself (i.e ITSLoader in ITS). //
17 // But, to load detector object one need to load gAlice, and //
18 // by the way all other detectors with their geometrieces and //
19 // so on. So, if one need to open TPC clusters there is no //
20 // principal need to read everything. //
23 // When RunLoader is read from the file it does not connect to //
24 // the folder structure automatically. It must be connected //
25 // (mounted) manualy. Default event folder is defined by //
26 // AliConfig::GetDefaultEventFolderName() //
27 // but can be mounted elsewhere. Usefull specially in merging case, //
28 // when more than pone session needs to be loaded //
30 //////////////////////////////////////////////////////////////////////
36 #include <TGeometry.h>
37 #include <TObjArray.h>
44 #include "AliConfig.h"
45 #include "AliLoader.h"
46 #include "AliHeader.h"
48 #include "AliDetector.h"
49 #include "AliRunDigitizer.h"
51 ClassImp(AliRunLoader)
53 AliRunLoader* AliRunLoader::fgRunLoader = 0x0;
55 const TString AliRunLoader::fgkRunLoaderName("RunLoader");
57 const TString AliRunLoader::fgkHeaderBranchName("Header");
58 const TString AliRunLoader::fgkHeaderContainerName("TE");
59 const TString AliRunLoader::fgkKineContainerName("TreeK");
60 const TString AliRunLoader::fgkTrackRefsContainerName("TreeTR");
61 const TString AliRunLoader::fgkKineBranchName("Particles");
62 const TString AliRunLoader::fgkDefaultKineFileName("Kinematics.root");
63 const TString AliRunLoader::fgkDefaultTrackRefsFileName("TrackRefs.root");
64 const TString AliRunLoader::fgkGAliceName("gAlice");
65 /**************************************************************************/
67 AliRunLoader::AliRunLoader():
75 fTrackRefsDataLoader(0x0),
79 AliConfig::Instance();//force to build the folder structure
80 if (!fgRunLoader) fgRunLoader = this;
82 /**************************************************************************/
84 AliRunLoader::AliRunLoader(const char* eventfoldername):
85 TNamed(fgkRunLoaderName,fgkRunLoaderName),
86 fLoaders(new TObjArray()),
92 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
93 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
98 SetEventFolderName(eventfoldername);
99 if (!fgRunLoader) fgRunLoader = this;
101 /**************************************************************************/
103 AliRunLoader::~AliRunLoader()
106 if (fgRunLoader == this) fgRunLoader = 0x0;
112 fLoaders->SetOwner();
116 delete fKineDataLoader;
117 delete fTrackRefsDataLoader;
122 //fEventFolder is deleted by the way of removing - TopAliceFolder owns it
127 /**************************************************************************/
129 AliRunLoader::AliRunLoader(TFolder* topfolder):
130 TNamed(fgkRunLoaderName,fgkRunLoaderName),
131 fLoaders(new TObjArray()),
132 fEventFolder(topfolder),
137 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
138 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
143 if (!fgRunLoader) fgRunLoader = this;
146 Fatal("AliRunLoader(TFolder*)","Parameter is NULL");
150 TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
152 { //if it is, then sth. is going wrong... exits aliroot session
153 Fatal("AliRunLoader(const char*)",
154 "In Event Folder Named %s object named %s already exists. I am confused ...",
155 fEventFolder->GetName(),fgkRunLoaderName.Data());
156 return;//never reached
159 fEventFolder->Add(this);//put myself to the folder to accessible for all
162 /**************************************************************************/
164 Int_t AliRunLoader::GetEvent(Int_t evno)
166 //Gets event number evno
167 //Reloads all data properly
168 if (fCurrentEvent == evno) return 0;
172 Error("GetEvent","Can not give the event with negative number");
176 if (evno >= GetNumberOfEvents())
178 Error("GetEvent","There is no event with number %d",evno);
184 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
185 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
186 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
187 Info("GetEvent"," GETTING EVENT %d",evno);
188 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
189 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
190 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
193 fCurrentEvent = evno;
197 //Reload header (If header was loaded)
200 retval = TreeE()->GetEvent(fCurrentEvent);
203 Error("GetEvent","Cannot find event: %d\n ",fCurrentEvent);
207 //Reload stack (If header was loaded)
208 if (TreeE()) fStack = GetHeader()->Stack();
209 //Set event folder in stack (it does not mean that we read kinematics from file)
212 fStack->SetEventFolderName(fEventFolder->GetName());
216 Warning("GetEvent","Stack not found in header");
222 Error("GetEvent","Error occured while setting event %d",evno);
226 //Post Track References
227 retval = fTrackRefsDataLoader->GetEvent();
230 Error("GetEvent","Error occured while GetEvent for Track References. Event %d",evno);
234 //Read Kinematics if loaded
235 fKineDataLoader->GetEvent();
238 Error("GetEvent","Error occured while GetEvent for Kinematics. Event %d",evno);
242 if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded()) fStack->GetEvent();
244 //Trigger data reloading in all loaders
245 TIter next(fLoaders);
247 while((loader = (AliLoader*)next()))
249 retval = loader->GetEvent();
252 Error("GetEvent","Error occured while getting event for %s. Event %d.",
253 loader->GetDetectorName().Data(), evno);
258 SetDetectorAddresses();
262 /**************************************************************************/
263 Int_t AliRunLoader::SetEvent()
265 //if kinematics was loaded Cleans folder data
269 retval = fKineDataLoader->SetEvent();
272 Error("SetEvent","SetEvent for Kinamtics Data Loader retutned error.");
275 retval = fTrackRefsDataLoader->SetEvent();
278 Error("SetEvent","SetEvent for Track References Data Loader retutned error.");
282 TIter next(fLoaders);
284 while((loader = (AliLoader*)next()))
286 retval = loader->SetEvent();
289 Error("SetEvent","SetEvent for %s Data Loader retutned error.",loader->GetName());
296 /**************************************************************************/
298 Int_t AliRunLoader::SetEventNumber(Int_t evno)
300 //cleans folders and sets the root dirs in files
301 if (fCurrentEvent == evno) return 0;
302 fCurrentEvent = evno;
306 /**************************************************************************/
307 AliRunLoader* AliRunLoader::Open
308 (const char* filename, const char* eventfoldername, Option_t* option)
310 //Opens a desired file 'filename'
311 //gets the the run-Loader and mounts it desired folder
312 //returns the pointer to run Loader which can be further used for accessing data
313 //in case of error returns NULL
315 static const TString webaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
316 if (AliLoader::GetDebug())
317 ::Info("AliRunLoader::Open",
318 "\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",webaddress.Data());
320 AliRunLoader* result = 0x0;
322 /* ************************************************ */
323 /* Chceck if folder with given name already exists */
324 /* ************************************************ */
326 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
329 TFolder* fold = dynamic_cast<TFolder*>(obj);
332 ::Error("AliRunLoader::Open","Such a obejct already exists in top alice folder and it is not a folder.");
336 //check if we can get RL from that folder
337 result = AliRunLoader::GetRunLoader(eventfoldername);
340 ::Error("AliRunLoader::Open",
341 "Folder %s already exists, and can not find session there. Can not mount.",eventfoldername);
345 if (result->GetFileName().CompareTo(filename) != 0)
347 ::Error("AliRunLoader::Open","Other file is mounted in demanded folder. Can not mount.");
351 //check if now is demanded (re)creation
352 if ( AliLoader::TestFileOption(option) == kFALSE)
354 ::Error("AliRunLoader::Open",
355 "Session already exists in folder %s and this session option is %s. Unable to proceed.",
356 eventfoldername,option);
360 //check if demanded option is update and existing one
361 TString tmpstr(option);
362 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
363 (result->fGAFile->IsWritable() == kFALSE) )
365 ::Error("AliRunLoader::Open",
366 "Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
367 eventfoldername,option);
371 ::Warning("AliRunLoader::Open","Session is already opened and mounted in demanded folder");
373 } //end of checking in case of existance of object named identically that folder session is being opened
376 TFile * gAliceFile = TFile::Open(filename,option);//open a file
378 {//null pointer returned
379 ::Error("AliRunLoader::Open","Can not open file %s.",filename);
383 if (gAliceFile->IsOpen() == kFALSE)
384 {//pointer to valid object returned but file is not opened
385 ::Error("AliRunLoader::Open","Can not open file %s.",filename);
389 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
390 //else create new AliRunLoader
391 if ( AliLoader::TestFileOption(option) )
393 if (AliLoader::GetDebug())
394 ::Info("AliRunLoader::Open","Reading RL from file");
396 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
399 ::Error("AliRunLoader::Open","Can not find run-Loader in file %s.",filename);
400 delete gAliceFile;//close the file
403 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
404 if (tmp)//if SetEvent returned error
406 ::Error("AliRunLoader::Open","Can not mount event in folder %s.",eventfoldername);
407 delete result; //delete run-Loader
408 delete gAliceFile;//close the file
414 if (AliLoader::GetDebug())
415 ::Info("AliRunLoader::Open","Creating new AliRunLoader. Folder name is %s",eventfoldername);
416 result = new AliRunLoader(eventfoldername);
419 //procedure for extracting dir name from the file name
420 TString fname(filename);
421 Int_t nsl = fname.Last('/');//look for slash in file name
425 Int_t nsl = fname.Last(':');//look for colon e.g. rfio:galice.root
426 if (nsl < 0) dirname = ".";//not found
427 else dirname = fname.Remove(nsl);//found
429 else dirname = fname.Remove(nsl);//slash found
431 if (AliLoader::GetDebug())
432 ::Info("AliRunLoader::Open","Dir name is : %s",dirname.Data());
434 result->SetDirName(dirname);
435 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
436 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
439 /**************************************************************************/
440 Int_t AliRunLoader::GetNumberOfEvents()
442 //returns number of events in Run
446 retval = LoadHeader();
449 Error("GetNumberOfEvents","Error occured while loading header");
453 return (Int_t)TreeE()->GetEntries();
455 /**************************************************************************/
457 void AliRunLoader::MakeHeader()
459 //Makes header and connects it to header tree (if it exists)
460 if (GetDebug()) Info("MakeHeader","");
463 if (GetDebug()) Info("MakeHeader","Creating new Header Object");
464 fHeader= new AliHeader();
466 TTree* tree = TreeE();
469 if (GetDebug()) Info("MakeHeader","Got Tree from folder.");
470 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
473 if (GetDebug()) Info("MakeHeader","Creating new branch");
474 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
475 branch->SetAutoDelete(kFALSE);
479 if (GetDebug()) Info("MakeHeader","Got Branch from Tree");
480 branch->SetAddress(&fHeader);
481 tree->GetEvent(fCurrentEvent);
482 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
485 fStack->SetEventFolderName(fEventFolder->GetName());
486 if (TreeK()) fStack->GetEvent();
490 if (GetDebug()) Info("MakeHeader","Haeder do not have a stack.");
494 if (GetDebug()) Info("MakeHeader","Exiting MakeHeader method");
496 /**************************************************************************/
498 void AliRunLoader::MakeStack()
500 //Creates the stack object - do not connect the tree
503 fStack = new AliStack(10000);
504 fStack->SetEventFolderName(fEventFolder->GetName());
508 /**************************************************************************/
510 void AliRunLoader::MakeTree(Option_t *option)
513 const char *oK = strstr(option,"K"); //Kine
514 const char *oE = strstr(option,"E"); //Header
518 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
520 Error("MakeTree(\"K\")","Load Kinematics first");
524 fKineDataLoader->MakeTree();
526 fStack->ConnectTree();
527 WriteKinematics("OVERWRITE");
534 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
535 GetEventFolder()->Add(tree);
537 WriteHeader("OVERWRITE");
540 TIter next(fLoaders);
542 while((loader = (AliLoader*)next()))
544 loader->MakeTree(option);
548 /**************************************************************************/
550 Int_t AliRunLoader::LoadgAlice()
552 //Loads gAlice from file
555 Warning("LoadgAlice","AliRun is already in folder. Unload first.");
558 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
561 Error("LoadgAlice"," Can not find gAlice in file %s",fGAFile->GetName());
564 alirun->SetRunLoader(this);
567 Warning("LoadgAlice","gAlice already exists. Putting retrived object in folder named %s",
568 GetEventFolder()->GetName());
574 SetDetectorAddresses();//calls SetTreeAddress for all detectors
577 /**************************************************************************/
579 Int_t AliRunLoader::LoadHeader()
581 //loads treeE and reads header object for current event
584 Warning("LoadHeader","Header is already loaded. Use ReloadHeader to force reload. Nothing done");
588 if (GetEventFolder() == 0x0)
590 Error("LoadHeader","Event folder not specified yet");
596 Error("LoadHeader","Session not opened. Use AliRunLoader::Open");
600 if (fGAFile->IsOpen() == kFALSE)
602 Error("LoadHeader","Session not opened. Use AliRunLoader::Open");
606 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
609 Fatal("LoadHeader","Can not find header tree named %s in file %s",
610 fgkHeaderContainerName.Data(),fGAFile->GetName());
614 if (tree == TreeE()) return 0;
617 GetEventFolder()->Add(tree);
618 MakeHeader();//creates header object and connects to tree
622 /**************************************************************************/
624 Int_t AliRunLoader::LoadKinematics(Option_t* option)
626 //Loads the kinematics
627 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
630 Error("LoadKinematics","Error occured while loading kinamatics tree.");
635 retval = fStack->GetEvent();
636 if ( retval == kFALSE)
638 Error("LoadKinematics","Error occured while loading kinamatics tree.");
645 /**************************************************************************/
647 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
649 //Opens File with kinematics
652 if (file->IsOpen() == kFALSE)
653 {//pointer is not null but file is not opened
654 Warning("OpenDataFile","Pointer to file is not null, but file is not opened");//risky any way
656 file = 0x0; //proceed with opening procedure
660 Warning("OpenDataFile","File %s already opened",filename.Data());
664 //try to find if that file is opened somewere else
665 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
668 if(file->IsOpen() == kTRUE)
670 Warning("OpenDataFile","File %s already opened by sombody else.",file->GetName());
675 file = TFile::Open(filename,opt);
678 Error("LoadKinematics","Can not open file %s",filename.Data());
681 if (file->IsOpen() == kFALSE)
682 {//file is not opened
683 Error("LoadKinematics","Can not open file %s",filename.Data());
687 file->SetCompressionLevel(cl);
689 dir = AliLoader::ChangeDir(file,fCurrentEvent);
692 Error("OpenKineFile","Can not change to root directory in file %s",filename.Data());
697 /**************************************************************************/
699 TTree* AliRunLoader::TreeE() const
701 //returns the tree from folder; shortcut method
702 if (GetDebug() > 10) fEventFolder->ls();
703 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
704 return (obj)?dynamic_cast<TTree*>(obj):0x0;
706 /**************************************************************************/
708 AliHeader* AliRunLoader::GetHeader() const
710 //returns pointer header object
713 /**************************************************************************/
715 TTree* AliRunLoader::TreeK() const
717 //returns the tree from folder; shortcut method
718 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
719 return (obj)?dynamic_cast<TTree*>(obj):0x0;
721 /**************************************************************************/
723 TTree* AliRunLoader::TreeTR() const
725 //returns the tree from folder; shortcut method
726 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
727 return (obj)?dynamic_cast<TTree*>(obj):0x0;
729 /**************************************************************************/
731 AliRun* AliRunLoader::GetAliRun() const
733 //returns AliRun which sits in the folder
734 if (fEventFolder == 0x0) return 0x0;
735 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
736 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
738 /**************************************************************************/
740 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
742 //writes geometry to the file
744 TGeometry* geo = GetAliRun()->GetGeometry();
747 Error("WriteGeometry","Can not get geometry from gAlice");
753 /**************************************************************************/
755 Int_t AliRunLoader::WriteHeader(Option_t* opt)
758 if (GetDebug()) Info("WriteHeader"," WRITING HEADER");
760 TTree* tree = TreeE();
763 Warning("WriteHeader","Can not find Header Tree in Folder");
766 if (fGAFile->IsWritable() == kFALSE)
768 Error("WriteHeader","File %s is not writable",fGAFile->GetName());
772 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
774 { //if they exist, see if option OVERWRITE is used
776 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
777 {//if it is not used - give an error message and return an error code
778 Error("WriteHeader","Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
783 tree->SetDirectory(fGAFile);
784 tree->Write(0,TObject::kOverwrite);
786 if (GetDebug()) Info("WriteHeader","WRITTEN\n\n");
790 /**************************************************************************/
792 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
794 //writes AliRun object to the file
796 if (GetAliRun()) GetAliRun()->Write();
799 /**************************************************************************/
801 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
804 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
806 /**************************************************************************/
807 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
809 //writes Track References tree
810 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
812 /**************************************************************************/
814 Int_t AliRunLoader::WriteHits(Option_t* opt)
816 //Calls WriteHits for all loaders
819 TIter next(fLoaders);
821 while((loader = (AliLoader*)next()))
823 res = loader->WriteHits(opt);
826 Error("WriteHits","Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res);
832 /**************************************************************************/
834 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
836 //Calls WriteSDigits for all loaders
839 TIter next(fLoaders);
841 while((loader = (AliLoader*)next()))
843 res = loader->WriteSDigits(opt);
846 Error("WriteSDigits","Failed to write summable digits for %s.",loader->GetDetectorName().Data());
852 /**************************************************************************/
854 Int_t AliRunLoader::WriteDigits(Option_t* opt)
856 //Calls WriteDigits for all loaders
859 TIter next(fLoaders);
861 while((loader = (AliLoader*)next()))
863 res = loader->WriteDigits(opt);
866 Error("WriteDigits","Failed to write digits for %s.",loader->GetDetectorName().Data());
872 /**************************************************************************/
874 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
876 //Calls WriteRecPoints for all loaders
879 TIter next(fLoaders);
881 while((loader = (AliLoader*)next()))
883 res = loader->WriteRecPoints(opt);
886 Error("WriteRecPoints","Failed to write Reconstructed Points for %s.",
887 loader->GetDetectorName().Data());
893 /**************************************************************************/
895 Int_t AliRunLoader::WriteTracks(Option_t* opt)
897 //Calls WriteTracks for all loaders
900 TIter next(fLoaders);
902 while((loader = (AliLoader*)next()))
904 res = loader->WriteTracks(opt);
907 Error("WriteTracks","Failed to write Tracks for %s.",
908 loader->GetDetectorName().Data());
914 /**************************************************************************/
916 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
918 //Writes itself to the file
920 this->Write(0,TObject::kOverwrite);
923 /**************************************************************************/
925 Int_t AliRunLoader::SetEventFolderName(const TString& name)
927 //sets top folder name for this run; of alread
930 Error("SetTopFolderName","Name is empty");
934 //check if such a folder already exists - try to find it in alice top folder
935 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
938 TFolder* fold = dynamic_cast<TFolder*>(obj);
941 Error("SetTopFolderName","Such a obejct already exists in top alice folder and it is not a folder.");
944 //folder which was found is our folder
945 if (fEventFolder == fold)
951 Error("SetTopFolderName","Such a folder already exists in top alice folder. Can not mount.");
956 //event is alredy connected, just change name of the folder
959 fEventFolder->SetName(name);
963 if (fKineDataLoader == 0x0)
964 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
966 if ( fTrackRefsDataLoader == 0x0)
967 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
969 //build the event folder structure
970 if (GetDebug()) Info("SetEventFolderName","Creating new event folder named %s",name.Data());
971 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
972 fEventFolder->Add(this);//put myself to the folder to accessible for all
974 if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName());
975 TIter next(fLoaders);
977 while((loader = (AliLoader*)next()))
979 loader->Register(fEventFolder);//build folder structure for this detector
982 fKineDataLoader->SetEventFolder(GetEventFolder());
983 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
984 fKineDataLoader->SetFolder(GetEventFolder());
985 fTrackRefsDataLoader->SetFolder(GetEventFolder());
987 fEventFolder->SetOwner();
990 /**************************************************************************/
992 void AliRunLoader::AddLoader(AliLoader* loader)
994 //Adds the Loader for given detector
995 if (loader == 0x0) //if null shout and exit
997 Error("AddLoader","Parameter is NULL");
1000 loader->SetDirName(fUnixDirName);
1001 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1002 //pass information to the Loader
1003 fLoaders->Add(loader);//add the Loader to the array
1005 /**************************************************************************/
1007 void AliRunLoader::AddLoader(AliDetector* det)
1009 //Asks module (detector) ro make a Loader and stores in the array
1010 if (det == 0x0) return;
1011 AliLoader* get = det->GetLoader();//try to get loader
1012 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1016 if (GetDebug()) Info("AddLoader","Detector: %s Loader : %s",det->GetName(),get->GetName());
1021 /**************************************************************************/
1023 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1025 //returns loader for given detector
1026 //note that naming convention is TPCLoader not just TPC
1027 return (AliLoader*)fLoaders->FindObject(detname);
1030 /**************************************************************************/
1032 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1034 //get loader for detector det
1035 if(det == 0x0) return 0x0;
1036 TString getname(det->GetName());
1038 if (GetDebug()) Info("GetLoader(AliDetector* det)"," Loader name is %s",getname.Data());
1039 return GetLoader(getname);
1042 /**************************************************************************/
1044 void AliRunLoader::CleanFolders()
1046 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1052 /**************************************************************************/
1054 void AliRunLoader::CleanDetectors()
1056 //Calls CleanFolders for all detectors
1057 TIter next(fLoaders);
1059 while((loader = (AliLoader*)next()))
1061 loader->CleanFolders();
1064 /**************************************************************************/
1066 void AliRunLoader::RemoveEventFolder()
1068 //remove all the tree of event
1069 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1071 if (fEventFolder == 0x0) return;
1072 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1073 fEventFolder->Remove(this);//remove us drom folder
1075 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1076 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1077 delete fEventFolder;
1079 /**************************************************************************/
1081 void AliRunLoader::SetGAliceFile(TFile* gafile)
1083 //sets pointer to galice.root file
1087 /**************************************************************************/
1089 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1091 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1093 if (GetDebug()) Info("LoadHits","Loading Hits");
1097 const char* oAll = strstr(detectors,"all");
1100 if (GetDebug()) Info("LoadHits","Option is All");
1105 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1106 loaders = &arr;//get the pointer array
1109 if (GetDebug()) Info("LoadHits","For detectors. Number of detectors chosen for loading %d",loaders->GetEntries());
1111 TIter next(loaders);
1113 while((loader = (AliLoader*)next()))
1115 if (GetDebug()) Info("LoadHits"," Calling LoadHits(%s) for %s",opt,loader->GetName());
1116 loader->LoadHits(opt);
1118 if (GetDebug()) Info("LoadHits","Done");
1122 /**************************************************************************/
1124 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1126 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1131 const char* oAll = strstr(detectors,"all");
1138 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1139 loaders = &arr;//get the pointer to array
1142 TIter next(loaders);
1144 while((loader = (AliLoader*)next()))
1146 loader->LoadSDigits(opt);
1151 /**************************************************************************/
1153 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1155 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1160 const char* oAll = strstr(detectors,"all");
1167 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1168 loaders = &arr;//get the pointer array
1171 TIter next(loaders);
1173 while((loader = (AliLoader*)next()))
1175 loader->LoadDigits(opt);
1179 /**************************************************************************/
1181 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1183 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1188 const char* oAll = strstr(detectors,"all");
1195 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1196 loaders = &arr;//get the pointer array
1199 TIter next(loaders);
1201 while((loader = (AliLoader*)next()))
1203 loader->LoadRecPoints(opt);
1207 /**************************************************************************/
1209 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1211 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1216 const char* oAll = strstr(detectors,"all");
1223 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1224 loaders = &arr;//get the pointer array
1227 TIter next(loaders);
1229 while((loader = (AliLoader*)next()))
1231 loader->LoadRecParticles(opt);
1235 /**************************************************************************/
1237 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1239 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1244 const char* oAll = strstr(detectors,"all");
1251 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1252 loaders = &arr;//get the pointer array
1255 TIter next(loaders);
1257 while((loader = (AliLoader*)next()))
1259 loader->LoadTracks(opt);
1263 /**************************************************************************/
1265 void AliRunLoader::UnloadHits(Option_t* detectors)
1267 //unloads hits for detectors specified in parameter
1271 const char* oAll = strstr(detectors,"all");
1278 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1279 loaders = &arr;//get the pointer to array
1282 TIter next(loaders);
1284 while((loader = (AliLoader*)next()))
1286 loader->UnloadHits();
1289 /**************************************************************************/
1291 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1293 //unloads SDigits for detectors specified in parameter
1297 const char* oAll = strstr(detectors,"all");
1304 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1305 loaders = &arr;//get the pointer to array
1308 TIter next(loaders);
1310 while((loader = (AliLoader*)next()))
1312 loader->UnloadSDigits();
1315 /**************************************************************************/
1317 void AliRunLoader::UnloadDigits(Option_t* detectors)
1319 //unloads Digits for detectors specified in parameter
1323 const char* oAll = strstr(detectors,"all");
1330 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1331 loaders = &arr;//get the pointer to array
1334 TIter next(loaders);
1336 while((loader = (AliLoader*)next()))
1338 loader->UnloadDigits();
1341 /**************************************************************************/
1343 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1345 //unloads RecPoints for detectors specified in parameter
1349 const char* oAll = strstr(detectors,"all");
1356 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1357 loaders = &arr;//get the pointer to array
1360 TIter next(loaders);
1362 while((loader = (AliLoader*)next()))
1364 loader->UnloadRecPoints();
1367 /**************************************************************************/
1369 void AliRunLoader::UnloadAll(Option_t* detectors)
1371 //calls UnloadAll for detectors names specified in parameter
1372 // option "all" passed can be passed
1376 const char* oAll = strstr(detectors,"all");
1383 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1384 loaders = &arr;//get the pointer to array
1387 TIter next(loaders);
1389 while((loader = (AliLoader*)next()))
1391 loader->UnloadAll();
1394 /**************************************************************************/
1396 void AliRunLoader::UnloadTracks(Option_t* detectors)
1398 //unloads Tracks for detectors specified in parameter
1402 const char* oAll = strstr(detectors,"all");
1409 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1410 loaders = &arr;//get the pointer to array
1413 TIter next(loaders);
1415 while((loader = (AliLoader*)next()))
1417 loader->UnloadTracks();
1420 /**************************************************************************/
1422 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1424 //unloads Particles for detectors specified in parameter
1428 const char* oAll = strstr(detectors,"all");
1435 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1436 loaders = &arr;//get the pointer to array
1439 TIter next(loaders);
1441 while((loader = (AliLoader*)next()))
1443 loader->UnloadRecParticles();
1446 /**************************************************************************/
1448 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1450 //returns RunLoader from folder named eventfoldername
1451 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1456 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1460 /**************************************************************************/
1462 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1464 //get the loader of the detector with the given name from the global
1466 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1468 ::Error("AliRunLoader::GetDetectorLoader","No run loader found");
1471 return runLoader->GetDetectorLoader(detname);
1473 /**************************************************************************/
1475 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1477 //get the loader of the detector with the given name from the global
1480 char loadername[256];
1481 sprintf(loadername, "%sLoader", detname);
1482 AliLoader* loader = GetLoader(loadername);
1484 Error("GetDetectorLoader", "No loader for %s found", detname);
1489 /**************************************************************************/
1491 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1493 //get the tree with hits of the detector with the given name
1494 //if maketree is true and the tree does not exist, the tree is created
1495 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1496 if (!loader) return NULL;
1497 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1498 return loader->TreeH();
1501 /**************************************************************************/
1503 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1505 //get the tree with hits of the detector with the given name
1506 //if maketree is true and the tree does not exist, the tree is created
1507 AliLoader* loader = GetDetectorLoader(detname);
1508 if (!loader) return NULL;
1509 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1510 return loader->TreeH();
1512 /**************************************************************************/
1514 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1516 //get the tree with summable digits of the detector with the given name
1517 //if maketree is true and the tree does not exist, the tree is created
1518 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1519 if (!loader) return NULL;
1520 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1521 return loader->TreeS();
1523 /**************************************************************************/
1525 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1527 //get the tree with summable digits of the detector with the given name
1528 //if maketree is true and the tree does not exist, the tree is created
1529 AliLoader* loader = GetDetectorLoader(detname);
1530 if (!loader) return NULL;
1531 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1532 return loader->TreeS();
1534 /**************************************************************************/
1536 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1538 //get the tree with digits of the detector with the given name
1539 //if maketree is true and the tree does not exist, the tree is created
1540 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1541 if (!loader) return NULL;
1542 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1543 return loader->TreeD();
1545 /**************************************************************************/
1547 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1549 //get the tree with digits of the detector with the given name
1550 //if maketree is true and the tree does not exist, the tree is created
1551 AliLoader* loader = GetDetectorLoader(detname);
1552 if (!loader) return NULL;
1553 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1554 return loader->TreeD();
1556 /**************************************************************************/
1557 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1559 //get the tree with clusters of the detector with the given name
1560 //if maketree is true and the tree does not exist, the tree is created
1561 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1562 if (!loader) return NULL;
1563 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1564 return loader->TreeR();
1566 /**************************************************************************/
1568 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1570 //get the tree with clusters of the detector with the given name
1571 //if maketree is true and the tree does not exist, the tree is created
1572 AliLoader* loader = GetDetectorLoader(detname);
1573 if (!loader) return NULL;
1574 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1575 return loader->TreeR();
1577 /**************************************************************************/
1579 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1581 //get the tree with tracks of the detector with the given name
1582 //if maketree is true and the tree does not exist, the tree is created
1583 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1584 if (!loader) return NULL;
1585 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1586 return loader->TreeT();
1588 /**************************************************************************/
1590 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1592 //get the tree with tracks of the detector with the given name
1593 //if maketree is true and the tree does not exist, the tree is created
1594 AliLoader* loader = GetDetectorLoader(detname);
1595 if (!loader) return NULL;
1596 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1597 return loader->TreeT();
1599 /**************************************************************************/
1601 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1603 //get the tree with particles of the detector with the given name
1604 //if maketree is true and the tree does not exist, the tree is created
1605 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1606 if (!loader) return NULL;
1607 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1608 return loader->TreeP();
1610 /**************************************************************************/
1612 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1614 //get the tree with particles of the detector with the given name
1615 //if maketree is true and the tree does not exist, the tree is created
1616 AliLoader* loader = GetDetectorLoader(detname);
1617 if (!loader) return NULL;
1618 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1619 return loader->TreeP();
1622 /**************************************************************************/
1624 void AliRunLoader::CdGAFile()
1626 //sets gDirectory to galice file
1628 if(fGAFile) fGAFile->cd();
1631 /**************************************************************************/
1633 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1635 //this method looks for all Loaders corresponding
1636 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1640 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1641 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1646 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1647 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1649 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1650 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1651 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1652 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1653 //construct the Loader name
1654 TString getname(buff);
1656 AliLoader* loader = GetLoader(getname);//get the Loader
1659 pointerarray.Add(loader);
1663 Error("GetListOfDetectors","Can not find Loader for %s",buff);
1669 /*****************************************************************************/
1671 void AliRunLoader::Clean(const TString& name)
1673 //removes object with given name from event folder and deletes it
1674 if (GetEventFolder() == 0x0) return;
1675 TObject* obj = GetEventFolder()->FindObject(name);
1678 if (GetDebug()) Info("Clean(const TString&)","name=%s, cleaning %s.",GetName(),name.Data());
1679 GetEventFolder()->Remove(obj);
1684 /*****************************************************************************/
1686 TTask* AliRunLoader::GetRunDigitizer()
1688 //returns Run Digitizer from folder
1690 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1691 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1692 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1694 /*****************************************************************************/
1696 TTask* AliRunLoader::GetRunSDigitizer()
1698 //returns SDigitizer Task from folder
1700 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1701 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1702 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1704 /*****************************************************************************/
1706 TTask* AliRunLoader::GetRunReconstructioner()
1708 //returns Reconstructioner Task from folder
1709 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1710 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1711 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1713 /*****************************************************************************/
1715 TTask* AliRunLoader::GetRunTracker()
1717 //returns Tracker Task from folder
1718 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1719 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1720 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1722 /*****************************************************************************/
1724 TTask* AliRunLoader::GetRunPIDTask()
1726 //returns Tracker Task from folder
1727 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1728 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1729 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1731 /*****************************************************************************/
1733 TTask* AliRunLoader::GetRunQATask()
1735 //returns Quality Assurance Task from folder
1736 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1739 ::Error("AliRunLoader::GetRunQATask","Can not get task folder from AliConfig");
1742 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1743 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1746 /*****************************************************************************/
1748 void AliRunLoader::SetCompressionLevel(Int_t cl)
1750 //Sets Compression Level in all files
1751 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1752 SetKineComprLevel(cl);
1753 SetTrackRefsComprLevel(cl);
1754 TIter next(fLoaders);
1756 while((loader = (AliLoader*)next()))
1758 loader->SetCompressionLevel(cl);
1761 /**************************************************************************/
1763 void AliRunLoader::SetKineComprLevel(Int_t cl)
1765 //Sets comression level in Kine File
1766 fKineDataLoader->SetCompressionLevel(cl);
1768 /**************************************************************************/
1770 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1772 //Sets comression level in Track Refences File
1773 fTrackRefsDataLoader->SetCompressionLevel(cl);
1775 /**************************************************************************/
1777 void AliRunLoader::UnloadHeader()
1779 //removes TreeE from folder and deletes it
1780 // as well as fHeader object
1785 /**************************************************************************/
1787 void AliRunLoader::UnloadKinematics()
1789 //Unloads Kinematics
1790 fKineDataLoader->GetBaseLoader(0)->Unload();
1792 /**************************************************************************/
1794 void AliRunLoader::UnloadTrackRefs()
1796 //Unloads Track Refernces
1797 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
1799 /**************************************************************************/
1801 void AliRunLoader::UnloadgAlice()
1804 if (gAlice == GetAliRun())
1806 if (GetDebug()) Info("UnloadgAlice","Set gAlice = 0x0");
1807 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
1809 AliRun* alirun = GetAliRun();
1810 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
1813 /**************************************************************************/
1815 void AliRunLoader::MakeTrackRefsContainer()
1817 // Makes a tree for Track References
1818 fTrackRefsDataLoader->MakeTree();
1820 /**************************************************************************/
1822 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
1824 //Load track references from file (opens file and posts tree to folder)
1826 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
1828 /**************************************************************************/
1830 void AliRunLoader::SetDirName(TString& dirname)
1832 //sets directory name
1833 if (dirname.IsNull()) return;
1834 fUnixDirName = dirname;
1835 fKineDataLoader->SetDirName(dirname);
1836 fTrackRefsDataLoader->SetDirName(dirname);
1838 TIter next(fLoaders);
1840 while((loader = (AliLoader*)next()))
1842 loader->SetDirName(dirname);
1846 /*****************************************************************************/
1848 Int_t AliRunLoader::GetFileOffset() const
1850 //returns the file number that is added to the file name for current event
1851 return Int_t(fCurrentEvent/fNEventsPerFile);
1854 /*****************************************************************************/
1855 const TString AliRunLoader::SetFileOffset(const TString& fname)
1857 //adds the the number to the file name at proper place for current event
1858 Long_t offset = (Long_t)GetFileOffset();
1859 if (offset < 1) return fname;
1861 soffset += offset;//automatic conversion to string
1862 TString dotroot(".root");
1863 const TString& offfsetdotroot = offset + dotroot;
1864 TString out = fname;
1865 out = out.ReplaceAll(dotroot,offfsetdotroot);
1866 if (GetDebug()) Info("SetFileOffset"," in=%s out=%s",fname.Data(),out.Data());
1869 /*****************************************************************************/
1871 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
1873 //adds the suffix before ".root",
1874 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
1875 //made on Jiri Chudoba demand
1877 TIter next(fLoaders);
1879 while((loader = (AliLoader*)next()))
1881 loader->SetDigitsFileNameSuffix(suffix);
1884 /*****************************************************************************/
1886 TString AliRunLoader::GetFileName() const
1888 //returns name of galice file
1890 if (fGAFile == 0x0) return result;
1891 result = fGAFile->GetName();
1894 /*****************************************************************************/
1896 void AliRunLoader::SetDetectorAddresses()
1898 //calls SetTreeAddress for all detectors
1899 if (GetAliRun()==0x0) return;
1900 TIter next(GetAliRun()->Modules());
1902 while((mod = (AliModule*)next()))
1904 AliDetector* det = dynamic_cast<AliDetector*>(mod);
1905 if (det) det->SetTreeAddress();
1908 /*****************************************************************************/
1910 void AliRunLoader::Synchronize()
1912 //synchrinizes all writtable files
1913 TIter next(fLoaders);
1915 while((loader = (AliLoader*)next()))
1917 loader->Synchronize();
1920 fKineDataLoader->Synchronize();
1921 fTrackRefsDataLoader->Synchronize();
1923 if (fGAFile) fGAFile->Flush();
1925 /*****************************************************************************/
1926 /*****************************************************************************/