1 //____________________________________________________________________
2 //////////////////////////////////////////////////////////////////////
4 // class AliRunLoader //
6 // This class aims to be the unque interface for managing data I/O. //
7 // It stores Loaders for all modules which, knows names //
8 // of the files were data are to be stored. //
10 // It aims to substitud AliRun in automatic data managing //
11 // thus there is no necessity of loading gAlice from file in order //
12 // to get access to the data. //
14 // Logical place to put the specific Loader to the given //
15 // detector is detector itself (i.e ITSLoader in ITS). //
16 // But, to load detector object one need to load gAlice, and //
17 // by the way all other detectors with their geometrieces and //
18 // so on. So, if one need to open TPC clusters there is no //
19 // principal need to read everything. //
22 // When RunLoader is read from the file it does not connect to //
23 // the folder structure automatically. It must be connected //
24 // (mounted) manualy. Default event folder is defined by //
25 // AliConfig::GetDefaultEventFolderName() //
26 // but can be mounted elsewhere. Usefull specially in merging case, //
27 // when more than pone session needs to be loaded //
29 //////////////////////////////////////////////////////////////////////
35 #include <TGeometry.h>
36 #include <TObjArray.h>
42 #include "AliConfig.h"
43 #include "AliLoader.h"
44 #include "AliHeader.h"
46 #include "AliDetector.h"
47 #include "AliRunLoader.h"
49 ClassImp(AliRunLoader)
51 AliRunLoader* AliRunLoader::fgRunLoader = 0x0;
53 const TString AliRunLoader::fgkRunLoaderName("RunLoader");
55 const TString AliRunLoader::fgkHeaderBranchName("Header");
56 const TString AliRunLoader::fgkHeaderContainerName("TE");
57 const TString AliRunLoader::fgkKineContainerName("TreeK");
58 const TString AliRunLoader::fgkTrackRefsContainerName("TreeTR");
59 const TString AliRunLoader::fgkKineBranchName("Particles");
60 const TString AliRunLoader::fgkDefaultKineFileName("Kinematics.root");
61 const TString AliRunLoader::fgkDefaultTrackRefsFileName("TrackRefs.root");
62 const TString AliRunLoader::fgkGAliceName("gAlice");
63 /**************************************************************************/
65 AliRunLoader::AliRunLoader():
73 fTrackRefsDataLoader(0x0),
77 AliConfig::Instance();//force to build the folder structure
78 if (!fgRunLoader) fgRunLoader = this;
80 /**************************************************************************/
82 AliRunLoader::AliRunLoader(const char* eventfoldername):
83 TNamed(fgkRunLoaderName,fgkRunLoaderName),
84 fLoaders(new TObjArray()),
90 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
91 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
96 SetEventFolderName(eventfoldername);
97 if (!fgRunLoader) fgRunLoader = this;
99 /**************************************************************************/
101 AliRunLoader::AliRunLoader(const AliRunLoader &rl):
109 fKineDataLoader(0x0),
110 fTrackRefsDataLoader(0x0),
119 /**************************************************************************/
121 AliRunLoader::~AliRunLoader()
124 if (fgRunLoader == this) fgRunLoader = 0x0;
130 fLoaders->SetOwner();
134 delete fKineDataLoader;
135 delete fTrackRefsDataLoader;
140 //fEventFolder is deleted by the way of removing - TopAliceFolder owns it
145 /**************************************************************************/
147 AliRunLoader::AliRunLoader(TFolder* topfolder):
148 TNamed(fgkRunLoaderName,fgkRunLoaderName),
149 fLoaders(new TObjArray()),
150 fEventFolder(topfolder),
155 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
156 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
163 TString errmsg("Parameter is NULL");
164 Error("AliRunLoader(TFolder*)","%s",errmsg.Data());
169 TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
171 { //if it is, then sth. is going wrong... exits aliroot session
172 TString errmsg("In Event Folder Named ");
173 errmsg+=fEventFolder->GetName();
174 errmsg+=" object named "+fgkRunLoaderName+" already exists. I am confused ...";
176 Error("AliRunLoader(const char*)","%s",errmsg.Data());
178 return;//never reached
181 if (!fgRunLoader) fgRunLoader = this;
183 fEventFolder->Add(this);//put myself to the folder to accessible for all
186 /**************************************************************************/
188 void AliRunLoader::Copy(TObject &) const
190 Fatal("Copy","Not implemented");
192 /**************************************************************************/
194 Int_t AliRunLoader::GetEvent(Int_t evno)
196 //Gets event number evno
197 //Reloads all data properly
198 if (fCurrentEvent == evno) return 0;
202 Error("GetEvent","Can not give the event with negative number");
206 if (evno >= GetNumberOfEvents())
208 Error("GetEvent","There is no event with number %d",evno);
214 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
215 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
216 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
217 Info("GetEvent"," GETTING EVENT %d",evno);
218 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
219 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
220 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
223 fCurrentEvent = evno;
227 //Reload header (If header was loaded)
230 retval = TreeE()->GetEvent(fCurrentEvent);
233 Error("GetEvent","Cannot find event: %d\n ",fCurrentEvent);
237 //Reload stack (If header was loaded)
238 if (TreeE()) fStack = GetHeader()->Stack();
239 //Set event folder in stack (it does not mean that we read kinematics from file)
242 fStack->SetEventFolderName(fEventFolder->GetName());
246 Warning("GetEvent","Stack not found in header");
252 Error("GetEvent","Error occured while setting event %d",evno);
256 //Post Track References
257 retval = fTrackRefsDataLoader->GetEvent();
260 Error("GetEvent","Error occured while GetEvent for Track References. Event %d",evno);
264 //Read Kinematics if loaded
265 fKineDataLoader->GetEvent();
268 Error("GetEvent","Error occured while GetEvent for Kinematics. Event %d",evno);
272 if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded()) fStack->GetEvent();
274 //Trigger data reloading in all loaders
275 TIter next(fLoaders);
277 while((loader = (AliLoader*)next()))
279 retval = loader->GetEvent();
282 Error("GetEvent","Error occured while getting event for %s. Event %d.",
283 loader->GetDetectorName().Data(), evno);
288 SetDetectorAddresses();
292 /**************************************************************************/
293 Int_t AliRunLoader::SetEvent()
295 //if kinematics was loaded Cleans folder data
299 retval = fKineDataLoader->SetEvent();
302 Error("SetEvent","SetEvent for Kinamtics Data Loader retutned error.");
305 retval = fTrackRefsDataLoader->SetEvent();
308 Error("SetEvent","SetEvent for Track References Data Loader retutned error.");
312 TIter next(fLoaders);
314 while((loader = (AliLoader*)next()))
316 retval = loader->SetEvent();
319 Error("SetEvent","SetEvent for %s Data Loader retutned error.",loader->GetName());
326 /**************************************************************************/
328 Int_t AliRunLoader::SetEventNumber(Int_t evno)
330 //cleans folders and sets the root dirs in files
331 if (fCurrentEvent == evno) return 0;
332 fCurrentEvent = evno;
336 /**************************************************************************/
337 AliRunLoader* AliRunLoader::Open
338 (const char* filename, const char* eventfoldername, Option_t* option)
340 //Opens a desired file 'filename'
341 //gets the the run-Loader and mounts it desired folder
342 //returns the pointer to run Loader which can be further used for accessing data
343 //in case of error returns NULL
345 static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
346 if (AliLoader::GetDebug())
347 ::Info("AliRunLoader::Open",
348 "\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data());
350 AliRunLoader* result = 0x0;
352 /* ************************************************ */
353 /* Chceck if folder with given name already exists */
354 /* ************************************************ */
356 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
359 TFolder* fold = dynamic_cast<TFolder*>(obj);
362 ::Error("AliRunLoader::Open","Such a obejct already exists in top alice folder and it is not a folder.");
366 //check if we can get RL from that folder
367 result = AliRunLoader::GetRunLoader(eventfoldername);
370 ::Error("AliRunLoader::Open",
371 "Folder %s already exists, and can not find session there. Can not mount.",eventfoldername);
375 if (result->GetFileName().CompareTo(filename) != 0)
377 ::Error("AliRunLoader::Open","Other file is mounted in demanded folder. Can not mount.");
381 //check if now is demanded (re)creation
382 if ( AliLoader::TestFileOption(option) == kFALSE)
384 ::Error("AliRunLoader::Open",
385 "Session already exists in folder %s and this session option is %s. Unable to proceed.",
386 eventfoldername,option);
390 //check if demanded option is update and existing one
391 TString tmpstr(option);
392 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
393 (result->fGAFile->IsWritable() == kFALSE) )
395 ::Error("AliRunLoader::Open",
396 "Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
397 eventfoldername,option);
401 ::Warning("AliRunLoader::Open","Session is already opened and mounted in demanded folder");
403 } //end of checking in case of existance of object named identically that folder session is being opened
406 TFile * gAliceFile = TFile::Open(filename,option);//open a file
408 {//null pointer returned
409 ::Error("AliRunLoader::Open","Can not open file %s.",filename);
413 if (gAliceFile->IsOpen() == kFALSE)
414 {//pointer to valid object returned but file is not opened
415 ::Error("AliRunLoader::Open","Can not open file %s.",filename);
419 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
420 //else create new AliRunLoader
421 if ( AliLoader::TestFileOption(option) )
423 if (AliLoader::GetDebug())
424 ::Info("AliRunLoader::Open","Reading RL from file");
426 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
429 ::Error("AliRunLoader::Open","Can not find run-Loader in file %s.",filename);
430 delete gAliceFile;//close the file
433 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
434 if (tmp)//if SetEvent returned error
436 ::Error("AliRunLoader::Open","Can not mount event in folder %s.",eventfoldername);
437 delete result; //delete run-Loader
438 delete gAliceFile;//close the file
444 if (AliLoader::GetDebug())
445 ::Info("AliRunLoader::Open","Creating new AliRunLoader. Folder name is %s",eventfoldername);
448 result = new AliRunLoader(eventfoldername);
450 catch (TString& errmsg)
452 ::Error("Open","AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data());
454 delete gAliceFile;//close the file
459 //procedure for extracting dir name from the file name
460 TString fname(filename);
461 Int_t nsl = fname.Last('/');//look for slash in file name
465 Int_t nsl = fname.Last(':');//look for colon e.g. rfio:galice.root
466 if (nsl < 0) dirname = ".";//not found
467 else dirname = fname.Remove(nsl);//found
469 else dirname = fname.Remove(nsl);//slash found
471 if (AliLoader::GetDebug())
472 ::Info("AliRunLoader::Open","Dir name is : %s",dirname.Data());
474 result->SetDirName(dirname);
475 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
476 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
479 /**************************************************************************/
480 Int_t AliRunLoader::GetNumberOfEvents()
482 //returns number of events in Run
486 retval = LoadHeader();
489 Error("GetNumberOfEvents","Error occured while loading header");
493 return (Int_t)TreeE()->GetEntries();
495 /**************************************************************************/
497 void AliRunLoader::MakeHeader()
499 //Makes header and connects it to header tree (if it exists)
500 if (GetDebug()) Info("MakeHeader","");
503 if (GetDebug()) Info("MakeHeader","Creating new Header Object");
504 fHeader= new AliHeader();
506 TTree* tree = TreeE();
509 if (GetDebug()) Info("MakeHeader","Got Tree from folder.");
510 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
513 if (GetDebug()) Info("MakeHeader","Creating new branch");
514 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
515 branch->SetAutoDelete(kFALSE);
519 if (GetDebug()) Info("MakeHeader","Got Branch from Tree");
520 branch->SetAddress(&fHeader);
521 tree->GetEvent(fCurrentEvent);
522 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
525 fStack->SetEventFolderName(fEventFolder->GetName());
526 if (TreeK()) fStack->GetEvent();
530 if (GetDebug()) Info("MakeHeader","Haeder do not have a stack.");
534 if (GetDebug()) Info("MakeHeader","Exiting MakeHeader method");
536 /**************************************************************************/
538 void AliRunLoader::MakeStack()
540 //Creates the stack object - do not connect the tree
543 fStack = new AliStack(10000);
544 fStack->SetEventFolderName(fEventFolder->GetName());
548 /**************************************************************************/
550 void AliRunLoader::MakeTree(Option_t *option)
553 const char *oK = strstr(option,"K"); //Kine
554 const char *oE = strstr(option,"E"); //Header
558 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
560 Error("MakeTree(\"K\")","Load Kinematics first");
564 fKineDataLoader->MakeTree();
566 fStack->ConnectTree();
567 WriteKinematics("OVERWRITE");
574 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
575 GetEventFolder()->Add(tree);
577 WriteHeader("OVERWRITE");
580 TIter next(fLoaders);
582 while((loader = (AliLoader*)next()))
584 loader->MakeTree(option);
588 /**************************************************************************/
590 Int_t AliRunLoader::LoadgAlice()
592 //Loads gAlice from file
595 Warning("LoadgAlice","AliRun is already in folder. Unload first.");
598 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
601 Error("LoadgAlice"," Can not find gAlice in file %s",fGAFile->GetName());
604 alirun->SetRunLoader(this);
607 Warning("LoadgAlice","gAlice already exists. Putting retrived object in folder named %s",
608 GetEventFolder()->GetName());
614 SetDetectorAddresses();//calls SetTreeAddress for all detectors
617 /**************************************************************************/
619 Int_t AliRunLoader::LoadHeader()
621 //loads treeE and reads header object for current event
624 Warning("LoadHeader","Header is already loaded. Use ReloadHeader to force reload. Nothing done");
628 if (GetEventFolder() == 0x0)
630 Error("LoadHeader","Event folder not specified yet");
636 Error("LoadHeader","Session not opened. Use AliRunLoader::Open");
640 if (fGAFile->IsOpen() == kFALSE)
642 Error("LoadHeader","Session not opened. Use AliRunLoader::Open");
646 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
649 Error("LoadHeader","Can not find header tree named %s in file %s",
650 fgkHeaderContainerName.Data(),fGAFile->GetName());
654 if (tree == TreeE()) return 0;
657 GetEventFolder()->Add(tree);
658 MakeHeader();//creates header object and connects to tree
662 /**************************************************************************/
664 Int_t AliRunLoader::LoadKinematics(Option_t* option)
666 //Loads the kinematics
667 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
670 Error("LoadKinematics","Error occured while loading kinamatics tree.");
675 retval = fStack->GetEvent();
676 if ( retval == kFALSE)
678 Error("LoadKinematics","Error occured while loading kinamatics tree.");
685 /**************************************************************************/
687 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
689 //Opens File with kinematics
692 if (file->IsOpen() == kFALSE)
693 {//pointer is not null but file is not opened
694 Warning("OpenDataFile","Pointer to file is not null, but file is not opened");//risky any way
696 file = 0x0; //proceed with opening procedure
700 Warning("OpenDataFile","File %s already opened",filename.Data());
704 //try to find if that file is opened somewere else
705 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
708 if(file->IsOpen() == kTRUE)
710 Warning("OpenDataFile","File %s already opened by sombody else.",file->GetName());
715 file = TFile::Open(filename,opt);
718 Error("LoadKinematics","Can not open file %s",filename.Data());
721 if (file->IsOpen() == kFALSE)
722 {//file is not opened
723 Error("LoadKinematics","Can not open file %s",filename.Data());
727 file->SetCompressionLevel(cl);
729 dir = AliLoader::ChangeDir(file,fCurrentEvent);
732 Error("OpenKineFile","Can not change to root directory in file %s",filename.Data());
737 /**************************************************************************/
739 TTree* AliRunLoader::TreeE() const
741 //returns the tree from folder; shortcut method
742 if (GetDebug() > 10) fEventFolder->ls();
743 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
744 return (obj)?dynamic_cast<TTree*>(obj):0x0;
746 /**************************************************************************/
748 AliHeader* AliRunLoader::GetHeader() const
750 //returns pointer header object
753 /**************************************************************************/
755 TTree* AliRunLoader::TreeK() const
757 //returns the tree from folder; shortcut method
758 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
759 return (obj)?dynamic_cast<TTree*>(obj):0x0;
761 /**************************************************************************/
763 TTree* AliRunLoader::TreeTR() const
765 //returns the tree from folder; shortcut method
766 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
767 return (obj)?dynamic_cast<TTree*>(obj):0x0;
769 /**************************************************************************/
771 AliRun* AliRunLoader::GetAliRun() const
773 //returns AliRun which sits in the folder
774 if (fEventFolder == 0x0) return 0x0;
775 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
776 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
778 /**************************************************************************/
780 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
782 //writes geometry to the file
784 TGeometry* geo = GetAliRun()->GetGeometry();
787 Error("WriteGeometry","Can not get geometry from gAlice");
793 /**************************************************************************/
795 Int_t AliRunLoader::WriteHeader(Option_t* opt)
798 if (GetDebug()) Info("WriteHeader"," WRITING HEADER");
800 TTree* tree = TreeE();
803 Warning("WriteHeader","Can not find Header Tree in Folder");
806 if (fGAFile->IsWritable() == kFALSE)
808 Error("WriteHeader","File %s is not writable",fGAFile->GetName());
812 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
814 { //if they exist, see if option OVERWRITE is used
816 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
817 {//if it is not used - give an error message and return an error code
818 Error("WriteHeader","Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
823 tree->SetDirectory(fGAFile);
824 tree->Write(0,TObject::kOverwrite);
826 if (GetDebug()) Info("WriteHeader","WRITTEN\n\n");
830 /**************************************************************************/
832 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
834 //writes AliRun object to the file
836 if (GetAliRun()) GetAliRun()->Write();
839 /**************************************************************************/
841 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
844 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
846 /**************************************************************************/
847 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
849 //writes Track References tree
850 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
852 /**************************************************************************/
854 Int_t AliRunLoader::WriteHits(Option_t* opt)
856 //Calls WriteHits for all loaders
859 TIter next(fLoaders);
861 while((loader = (AliLoader*)next()))
863 res = loader->WriteHits(opt);
866 Error("WriteHits","Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res);
872 /**************************************************************************/
874 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
876 //Calls WriteSDigits for all loaders
879 TIter next(fLoaders);
881 while((loader = (AliLoader*)next()))
883 res = loader->WriteSDigits(opt);
886 Error("WriteSDigits","Failed to write summable digits for %s.",loader->GetDetectorName().Data());
892 /**************************************************************************/
894 Int_t AliRunLoader::WriteDigits(Option_t* opt)
896 //Calls WriteDigits for all loaders
899 TIter next(fLoaders);
901 while((loader = (AliLoader*)next()))
903 res = loader->WriteDigits(opt);
906 Error("WriteDigits","Failed to write digits for %s.",loader->GetDetectorName().Data());
912 /**************************************************************************/
914 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
916 //Calls WriteRecPoints for all loaders
919 TIter next(fLoaders);
921 while((loader = (AliLoader*)next()))
923 res = loader->WriteRecPoints(opt);
926 Error("WriteRecPoints","Failed to write Reconstructed Points for %s.",
927 loader->GetDetectorName().Data());
933 /**************************************************************************/
935 Int_t AliRunLoader::WriteTracks(Option_t* opt)
937 //Calls WriteTracks for all loaders
940 TIter next(fLoaders);
942 while((loader = (AliLoader*)next()))
944 res = loader->WriteTracks(opt);
947 Error("WriteTracks","Failed to write Tracks for %s.",
948 loader->GetDetectorName().Data());
954 /**************************************************************************/
956 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
958 //Writes itself to the file
960 this->Write(0,TObject::kOverwrite);
963 /**************************************************************************/
965 Int_t AliRunLoader::SetEventFolderName(const TString& name)
967 //sets top folder name for this run; of alread
970 Error("SetTopFolderName","Name is empty");
974 //check if such a folder already exists - try to find it in alice top folder
975 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
978 TFolder* fold = dynamic_cast<TFolder*>(obj);
981 Error("SetTopFolderName","Such a obejct already exists in top alice folder and it is not a folder.");
984 //folder which was found is our folder
985 if (fEventFolder == fold)
991 Error("SetTopFolderName","Such a folder already exists in top alice folder. Can not mount.");
996 //event is alredy connected, just change name of the folder
999 fEventFolder->SetName(name);
1003 if (fKineDataLoader == 0x0)
1004 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1006 if ( fTrackRefsDataLoader == 0x0)
1007 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1009 //build the event folder structure
1010 if (GetDebug()) Info("SetEventFolderName","Creating new event folder named %s",name.Data());
1011 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1012 fEventFolder->Add(this);//put myself to the folder to accessible for all
1014 if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName());
1015 TIter next(fLoaders);
1017 while((loader = (AliLoader*)next()))
1019 loader->Register(fEventFolder);//build folder structure for this detector
1022 fKineDataLoader->SetEventFolder(GetEventFolder());
1023 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1024 fKineDataLoader->SetFolder(GetEventFolder());
1025 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1027 fEventFolder->SetOwner();
1030 /**************************************************************************/
1032 void AliRunLoader::AddLoader(AliLoader* loader)
1034 //Adds the Loader for given detector
1035 if (loader == 0x0) //if null shout and exit
1037 Error("AddLoader","Parameter is NULL");
1040 loader->SetDirName(fUnixDirName);
1041 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1042 //pass information to the Loader
1043 fLoaders->Add(loader);//add the Loader to the array
1045 /**************************************************************************/
1047 void AliRunLoader::AddLoader(AliDetector* det)
1049 //Asks module (detector) ro make a Loader and stores in the array
1050 if (det == 0x0) return;
1051 AliLoader* get = det->GetLoader();//try to get loader
1052 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1056 if (GetDebug()) Info("AddLoader","Detector: %s Loader : %s",det->GetName(),get->GetName());
1061 /**************************************************************************/
1063 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1065 //returns loader for given detector
1066 //note that naming convention is TPCLoader not just TPC
1067 return (AliLoader*)fLoaders->FindObject(detname);
1070 /**************************************************************************/
1072 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1074 //get loader for detector det
1075 if(det == 0x0) return 0x0;
1076 TString getname(det->GetName());
1078 if (GetDebug()) Info("GetLoader(AliDetector* det)"," Loader name is %s",getname.Data());
1079 return GetLoader(getname);
1082 /**************************************************************************/
1084 void AliRunLoader::CleanFolders()
1086 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1092 /**************************************************************************/
1094 void AliRunLoader::CleanDetectors()
1096 //Calls CleanFolders for all detectors
1097 TIter next(fLoaders);
1099 while((loader = (AliLoader*)next()))
1101 loader->CleanFolders();
1104 /**************************************************************************/
1106 void AliRunLoader::RemoveEventFolder()
1108 //remove all the tree of event
1109 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1111 if (fEventFolder == 0x0) return;
1112 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1113 fEventFolder->Remove(this);//remove us drom folder
1115 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1116 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1117 delete fEventFolder;
1119 /**************************************************************************/
1121 void AliRunLoader::SetGAliceFile(TFile* gafile)
1123 //sets pointer to galice.root file
1127 /**************************************************************************/
1129 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1131 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1133 if (GetDebug()) Info("LoadHits","Loading Hits");
1137 const char* oAll = strstr(detectors,"all");
1140 if (GetDebug()) Info("LoadHits","Option is All");
1145 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1146 loaders = &arr;//get the pointer array
1149 if (GetDebug()) Info("LoadHits","For detectors. Number of detectors chosen for loading %d",loaders->GetEntries());
1151 TIter next(loaders);
1153 while((loader = (AliLoader*)next()))
1155 if (GetDebug()) Info("LoadHits"," Calling LoadHits(%s) for %s",opt,loader->GetName());
1156 loader->LoadHits(opt);
1158 if (GetDebug()) Info("LoadHits","Done");
1162 /**************************************************************************/
1164 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1166 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1171 const char* oAll = strstr(detectors,"all");
1178 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1179 loaders = &arr;//get the pointer to array
1182 TIter next(loaders);
1184 while((loader = (AliLoader*)next()))
1186 loader->LoadSDigits(opt);
1191 /**************************************************************************/
1193 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1195 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1200 const char* oAll = strstr(detectors,"all");
1207 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1208 loaders = &arr;//get the pointer array
1211 TIter next(loaders);
1213 while((loader = (AliLoader*)next()))
1215 loader->LoadDigits(opt);
1219 /**************************************************************************/
1221 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1223 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1228 const char* oAll = strstr(detectors,"all");
1235 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1236 loaders = &arr;//get the pointer array
1239 TIter next(loaders);
1241 while((loader = (AliLoader*)next()))
1243 loader->LoadRecPoints(opt);
1247 /**************************************************************************/
1249 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1251 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1256 const char* oAll = strstr(detectors,"all");
1263 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1264 loaders = &arr;//get the pointer array
1267 TIter next(loaders);
1269 while((loader = (AliLoader*)next()))
1271 loader->LoadRecParticles(opt);
1275 /**************************************************************************/
1277 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1279 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1284 const char* oAll = strstr(detectors,"all");
1291 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1292 loaders = &arr;//get the pointer array
1295 TIter next(loaders);
1297 while((loader = (AliLoader*)next()))
1299 loader->LoadTracks(opt);
1303 /**************************************************************************/
1305 void AliRunLoader::UnloadHits(Option_t* detectors)
1307 //unloads hits for detectors specified in parameter
1311 const char* oAll = strstr(detectors,"all");
1318 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1319 loaders = &arr;//get the pointer to array
1322 TIter next(loaders);
1324 while((loader = (AliLoader*)next()))
1326 loader->UnloadHits();
1329 /**************************************************************************/
1331 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1333 //unloads SDigits for detectors specified in parameter
1337 const char* oAll = strstr(detectors,"all");
1344 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1345 loaders = &arr;//get the pointer to array
1348 TIter next(loaders);
1350 while((loader = (AliLoader*)next()))
1352 loader->UnloadSDigits();
1355 /**************************************************************************/
1357 void AliRunLoader::UnloadDigits(Option_t* detectors)
1359 //unloads Digits for detectors specified in parameter
1363 const char* oAll = strstr(detectors,"all");
1370 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1371 loaders = &arr;//get the pointer to array
1374 TIter next(loaders);
1376 while((loader = (AliLoader*)next()))
1378 loader->UnloadDigits();
1381 /**************************************************************************/
1383 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1385 //unloads RecPoints for detectors specified in parameter
1389 const char* oAll = strstr(detectors,"all");
1396 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1397 loaders = &arr;//get the pointer to array
1400 TIter next(loaders);
1402 while((loader = (AliLoader*)next()))
1404 loader->UnloadRecPoints();
1407 /**************************************************************************/
1409 void AliRunLoader::UnloadAll(Option_t* detectors)
1411 //calls UnloadAll for detectors names specified in parameter
1412 // option "all" passed can be passed
1416 const char* oAll = strstr(detectors,"all");
1423 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1424 loaders = &arr;//get the pointer to array
1427 TIter next(loaders);
1429 while((loader = (AliLoader*)next()))
1431 loader->UnloadAll();
1434 /**************************************************************************/
1436 void AliRunLoader::UnloadTracks(Option_t* detectors)
1438 //unloads Tracks for detectors specified in parameter
1442 const char* oAll = strstr(detectors,"all");
1449 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1450 loaders = &arr;//get the pointer to array
1453 TIter next(loaders);
1455 while((loader = (AliLoader*)next()))
1457 loader->UnloadTracks();
1460 /**************************************************************************/
1462 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1464 //unloads Particles for detectors specified in parameter
1468 const char* oAll = strstr(detectors,"all");
1475 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1476 loaders = &arr;//get the pointer to array
1479 TIter next(loaders);
1481 while((loader = (AliLoader*)next()))
1483 loader->UnloadRecParticles();
1486 /**************************************************************************/
1488 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1490 //returns RunLoader from folder named eventfoldername
1491 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1496 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1500 /**************************************************************************/
1502 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1504 //get the loader of the detector with the given name from the global
1506 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1508 ::Error("AliRunLoader::GetDetectorLoader","No run loader found");
1511 return runLoader->GetDetectorLoader(detname);
1513 /**************************************************************************/
1515 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1517 //get the loader of the detector with the given name from the global
1520 char loadername[256];
1521 sprintf(loadername, "%sLoader", detname);
1522 AliLoader* loader = GetLoader(loadername);
1524 Error("GetDetectorLoader", "No loader for %s found", detname);
1529 /**************************************************************************/
1531 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1533 //get the tree with hits of the detector with the given name
1534 //if maketree is true and the tree does not exist, the tree is created
1535 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1536 if (!loader) return NULL;
1537 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1538 return loader->TreeH();
1541 /**************************************************************************/
1543 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1545 //get the tree with hits of the detector with the given name
1546 //if maketree is true and the tree does not exist, the tree is created
1547 AliLoader* loader = GetDetectorLoader(detname);
1548 if (!loader) return NULL;
1549 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1550 return loader->TreeH();
1552 /**************************************************************************/
1554 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1556 //get the tree with summable digits of the detector with the given name
1557 //if maketree is true and the tree does not exist, the tree is created
1558 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1559 if (!loader) return NULL;
1560 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1561 return loader->TreeS();
1563 /**************************************************************************/
1565 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1567 //get the tree with summable digits of the detector with the given name
1568 //if maketree is true and the tree does not exist, the tree is created
1569 AliLoader* loader = GetDetectorLoader(detname);
1570 if (!loader) return NULL;
1571 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1572 return loader->TreeS();
1574 /**************************************************************************/
1576 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1578 //get the tree with digits of the detector with the given name
1579 //if maketree is true and the tree does not exist, the tree is created
1580 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1581 if (!loader) return NULL;
1582 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1583 return loader->TreeD();
1585 /**************************************************************************/
1587 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1589 //get the tree with digits of the detector with the given name
1590 //if maketree is true and the tree does not exist, the tree is created
1591 AliLoader* loader = GetDetectorLoader(detname);
1592 if (!loader) return NULL;
1593 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1594 return loader->TreeD();
1596 /**************************************************************************/
1597 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1599 //get the tree with clusters of the detector with the given name
1600 //if maketree is true and the tree does not exist, the tree is created
1601 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1602 if (!loader) return NULL;
1603 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1604 return loader->TreeR();
1606 /**************************************************************************/
1608 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1610 //get the tree with clusters of the detector with the given name
1611 //if maketree is true and the tree does not exist, the tree is created
1612 AliLoader* loader = GetDetectorLoader(detname);
1613 if (!loader) return NULL;
1614 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1615 return loader->TreeR();
1617 /**************************************************************************/
1619 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1621 //get the tree with tracks of the detector with the given name
1622 //if maketree is true and the tree does not exist, the tree is created
1623 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1624 if (!loader) return NULL;
1625 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1626 return loader->TreeT();
1628 /**************************************************************************/
1630 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1632 //get the tree with tracks of the detector with the given name
1633 //if maketree is true and the tree does not exist, the tree is created
1634 AliLoader* loader = GetDetectorLoader(detname);
1635 if (!loader) return NULL;
1636 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1637 return loader->TreeT();
1639 /**************************************************************************/
1641 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1643 //get the tree with particles of the detector with the given name
1644 //if maketree is true and the tree does not exist, the tree is created
1645 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1646 if (!loader) return NULL;
1647 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1648 return loader->TreeP();
1650 /**************************************************************************/
1652 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1654 //get the tree with particles of the detector with the given name
1655 //if maketree is true and the tree does not exist, the tree is created
1656 AliLoader* loader = GetDetectorLoader(detname);
1657 if (!loader) return NULL;
1658 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1659 return loader->TreeP();
1662 /**************************************************************************/
1664 void AliRunLoader::CdGAFile()
1666 //sets gDirectory to galice file
1668 if(fGAFile) fGAFile->cd();
1671 /**************************************************************************/
1673 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1675 //this method looks for all Loaders corresponding
1676 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1680 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1681 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1686 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1687 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1689 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1690 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1691 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1692 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1693 //construct the Loader name
1694 TString getname(buff);
1696 AliLoader* loader = GetLoader(getname);//get the Loader
1699 pointerarray.Add(loader);
1703 Error("GetListOfDetectors","Can not find Loader for %s",buff);
1709 /*****************************************************************************/
1711 void AliRunLoader::Clean(const TString& name)
1713 //removes object with given name from event folder and deletes it
1714 if (GetEventFolder() == 0x0) return;
1715 TObject* obj = GetEventFolder()->FindObject(name);
1718 if (GetDebug()) Info("Clean(const TString&)","name=%s, cleaning %s.",GetName(),name.Data());
1719 GetEventFolder()->Remove(obj);
1724 /*****************************************************************************/
1726 TTask* AliRunLoader::GetRunDigitizer()
1728 //returns Run Digitizer from folder
1730 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1731 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1732 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1734 /*****************************************************************************/
1736 TTask* AliRunLoader::GetRunSDigitizer()
1738 //returns SDigitizer Task from folder
1740 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1741 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1742 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1744 /*****************************************************************************/
1746 TTask* AliRunLoader::GetRunReconstructioner()
1748 //returns Reconstructioner Task from folder
1749 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1750 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1751 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1753 /*****************************************************************************/
1755 TTask* AliRunLoader::GetRunTracker()
1757 //returns Tracker Task from folder
1758 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1759 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1760 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1762 /*****************************************************************************/
1764 TTask* AliRunLoader::GetRunPIDTask()
1766 //returns Tracker Task from folder
1767 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1768 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1769 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1771 /*****************************************************************************/
1773 TTask* AliRunLoader::GetRunQATask()
1775 //returns Quality Assurance Task from folder
1776 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1779 ::Error("AliRunLoader::GetRunQATask","Can not get task folder from AliConfig");
1782 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1783 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1786 /*****************************************************************************/
1788 void AliRunLoader::SetCompressionLevel(Int_t cl)
1790 //Sets Compression Level in all files
1791 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1792 SetKineComprLevel(cl);
1793 SetTrackRefsComprLevel(cl);
1794 TIter next(fLoaders);
1796 while((loader = (AliLoader*)next()))
1798 loader->SetCompressionLevel(cl);
1801 /**************************************************************************/
1803 void AliRunLoader::SetKineComprLevel(Int_t cl)
1805 //Sets comression level in Kine File
1806 fKineDataLoader->SetCompressionLevel(cl);
1808 /**************************************************************************/
1810 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1812 //Sets comression level in Track Refences File
1813 fTrackRefsDataLoader->SetCompressionLevel(cl);
1815 /**************************************************************************/
1817 void AliRunLoader::UnloadHeader()
1819 //removes TreeE from folder and deletes it
1820 // as well as fHeader object
1825 /**************************************************************************/
1827 void AliRunLoader::UnloadKinematics()
1829 //Unloads Kinematics
1830 fKineDataLoader->GetBaseLoader(0)->Unload();
1832 /**************************************************************************/
1834 void AliRunLoader::UnloadTrackRefs()
1836 //Unloads Track Refernces
1837 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
1839 /**************************************************************************/
1841 void AliRunLoader::UnloadgAlice()
1844 if (gAlice == GetAliRun())
1846 if (GetDebug()) Info("UnloadgAlice","Set gAlice = 0x0");
1847 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
1849 AliRun* alirun = GetAliRun();
1850 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
1853 /**************************************************************************/
1855 void AliRunLoader::MakeTrackRefsContainer()
1857 // Makes a tree for Track References
1858 fTrackRefsDataLoader->MakeTree();
1860 /**************************************************************************/
1862 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
1864 //Load track references from file (opens file and posts tree to folder)
1866 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
1868 /**************************************************************************/
1870 void AliRunLoader::SetDirName(TString& dirname)
1872 //sets directory name
1873 if (dirname.IsNull()) return;
1874 fUnixDirName = dirname;
1875 fKineDataLoader->SetDirName(dirname);
1876 fTrackRefsDataLoader->SetDirName(dirname);
1878 TIter next(fLoaders);
1880 while((loader = (AliLoader*)next()))
1882 loader->SetDirName(dirname);
1886 /*****************************************************************************/
1888 Int_t AliRunLoader::GetFileOffset() const
1890 //returns the file number that is added to the file name for current event
1891 return Int_t(fCurrentEvent/fNEventsPerFile);
1894 /*****************************************************************************/
1895 const TString AliRunLoader::SetFileOffset(const TString& fname)
1897 //adds the the number to the file name at proper place for current event
1898 Long_t offset = (Long_t)GetFileOffset();
1899 if (offset < 1) return fname;
1901 soffset += offset;//automatic conversion to string
1902 TString dotroot(".root");
1903 const TString& offfsetdotroot = offset + dotroot;
1904 TString out = fname;
1905 out = out.ReplaceAll(dotroot,offfsetdotroot);
1906 if (GetDebug()) Info("SetFileOffset"," in=%s out=%s",fname.Data(),out.Data());
1909 /*****************************************************************************/
1911 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
1913 //adds the suffix before ".root",
1914 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
1915 //made on Jiri Chudoba demand
1917 TIter next(fLoaders);
1919 while((loader = (AliLoader*)next()))
1921 loader->SetDigitsFileNameSuffix(suffix);
1924 /*****************************************************************************/
1926 TString AliRunLoader::GetFileName() const
1928 //returns name of galice file
1930 if (fGAFile == 0x0) return result;
1931 result = fGAFile->GetName();
1934 /*****************************************************************************/
1936 void AliRunLoader::SetDetectorAddresses()
1938 //calls SetTreeAddress for all detectors
1939 if (GetAliRun()==0x0) return;
1940 TIter next(GetAliRun()->Modules());
1942 while((mod = (AliModule*)next()))
1944 AliDetector* det = dynamic_cast<AliDetector*>(mod);
1945 if (det) det->SetTreeAddress();
1948 /*****************************************************************************/
1950 void AliRunLoader::Synchronize()
1952 //synchrinizes all writtable files
1953 TIter next(fLoaders);
1955 while((loader = (AliLoader*)next()))
1957 loader->Synchronize();
1960 fKineDataLoader->Synchronize();
1961 fTrackRefsDataLoader->Synchronize();
1963 if (fGAFile) fGAFile->Flush();
1965 /*****************************************************************************/
1966 /*****************************************************************************/