1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //____________________________________________________________________
19 //////////////////////////////////////////////////////////////////////
21 // class AliRunLoader //
23 // This class aims to be the unque interface for managing data I/O. //
24 // It stores Loaders for all modules which, knows names //
25 // of the files were data are to be stored. //
27 // It aims to substitud AliRun in automatic data managing //
28 // thus there is no necessity of loading gAlice from file in order //
29 // to get access to the data. //
31 // Logical place to put the specific Loader to the given //
32 // detector is detector itself (i.e ITSLoader in ITS). //
33 // But, to load detector object one need to load gAlice, and //
34 // by the way all other detectors with their geometrieces and //
35 // so on. So, if one need to open TPC clusters there is no //
36 // principal need to read everything. //
39 // When RunLoader is read from the file it does not connect to //
40 // the folder structure automatically. It must be connected //
41 // (mounted) manualy. Default event folder is defined by //
42 // AliConfig::GetDefaultEventFolderName() //
43 // but can be mounted elsewhere. Usefull specially in merging case, //
44 // when more than pone session needs to be loaded //
46 //////////////////////////////////////////////////////////////////////
52 #include <TGeometry.h>
53 #include <TObjArray.h>
59 #include "AliConfig.h"
60 #include "AliLoader.h"
61 #include "AliHeader.h"
63 #include "AliDetector.h"
64 #include "AliRunLoader.h"
66 ClassImp(AliRunLoader)
68 AliRunLoader* AliRunLoader::fgRunLoader = 0x0;
70 const TString AliRunLoader::fgkRunLoaderName("RunLoader");
72 const TString AliRunLoader::fgkHeaderBranchName("Header");
73 const TString AliRunLoader::fgkHeaderContainerName("TE");
74 const TString AliRunLoader::fgkKineContainerName("TreeK");
75 const TString AliRunLoader::fgkTrackRefsContainerName("TreeTR");
76 const TString AliRunLoader::fgkKineBranchName("Particles");
77 const TString AliRunLoader::fgkDefaultKineFileName("Kinematics.root");
78 const TString AliRunLoader::fgkDefaultTrackRefsFileName("TrackRefs.root");
79 const TString AliRunLoader::fgkGAliceName("gAlice");
80 /**************************************************************************/
82 AliRunLoader::AliRunLoader():
90 fTrackRefsDataLoader(0x0),
94 AliConfig::Instance();//force to build the folder structure
95 if (!fgRunLoader) fgRunLoader = this;
97 /**************************************************************************/
99 AliRunLoader::AliRunLoader(const char* eventfoldername):
100 TNamed(fgkRunLoaderName,fgkRunLoaderName),
101 fLoaders(new TObjArray()),
107 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
108 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
113 SetEventFolderName(eventfoldername);
114 if (!fgRunLoader) fgRunLoader = this;
116 /**************************************************************************/
118 AliRunLoader::AliRunLoader(const AliRunLoader &rl):
126 fKineDataLoader(0x0),
127 fTrackRefsDataLoader(0x0),
136 /**************************************************************************/
138 AliRunLoader::~AliRunLoader()
141 if (fgRunLoader == this) fgRunLoader = 0x0;
147 fLoaders->SetOwner();
151 delete fKineDataLoader;
152 delete fTrackRefsDataLoader;
157 //fEventFolder is deleted by the way of removing - TopAliceFolder owns it
162 /**************************************************************************/
164 AliRunLoader::AliRunLoader(TFolder* topfolder):
165 TNamed(fgkRunLoaderName,fgkRunLoaderName),
166 fLoaders(new TObjArray()),
167 fEventFolder(topfolder),
172 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
173 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
180 TString errmsg("Parameter is NULL");
181 Error("AliRunLoader(TFolder*)","%s",errmsg.Data());
186 TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
188 { //if it is, then sth. is going wrong... exits aliroot session
189 TString errmsg("In Event Folder Named ");
190 errmsg+=fEventFolder->GetName();
191 errmsg+=" object named "+fgkRunLoaderName+" already exists. I am confused ...";
193 Error("AliRunLoader(const char*)","%s",errmsg.Data());
195 return;//never reached
198 if (!fgRunLoader) fgRunLoader = this;
200 fEventFolder->Add(this);//put myself to the folder to accessible for all
203 /**************************************************************************/
205 void AliRunLoader::Copy(TObject &) const
207 Fatal("Copy","Not implemented");
209 /**************************************************************************/
211 Int_t AliRunLoader::GetEvent(Int_t evno)
213 //Gets event number evno
214 //Reloads all data properly
215 if (fCurrentEvent == evno) return 0;
219 Error("GetEvent","Can not give the event with negative number");
223 if (evno >= GetNumberOfEvents())
225 Error("GetEvent","There is no event with number %d",evno);
231 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
232 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
233 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
234 Info("GetEvent"," GETTING EVENT %d",evno);
235 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
236 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
237 Info("GetEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
240 fCurrentEvent = evno;
244 //Reload header (If header was loaded)
247 retval = TreeE()->GetEvent(fCurrentEvent);
250 Error("GetEvent","Cannot find event: %d\n ",fCurrentEvent);
254 //Reload stack (If header was loaded)
255 if (TreeE()) fStack = GetHeader()->Stack();
256 //Set event folder in stack (it does not mean that we read kinematics from file)
259 fStack->SetEventFolderName(fEventFolder->GetName());
263 Warning("GetEvent","Stack not found in header");
269 Error("GetEvent","Error occured while setting event %d",evno);
273 //Post Track References
274 retval = fTrackRefsDataLoader->GetEvent();
277 Error("GetEvent","Error occured while GetEvent for Track References. Event %d",evno);
281 //Read Kinematics if loaded
282 fKineDataLoader->GetEvent();
285 Error("GetEvent","Error occured while GetEvent for Kinematics. Event %d",evno);
289 if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded()) fStack->GetEvent();
291 //Trigger data reloading in all loaders
292 TIter next(fLoaders);
294 while((loader = (AliLoader*)next()))
296 retval = loader->GetEvent();
299 Error("GetEvent","Error occured while getting event for %s. Event %d.",
300 loader->GetDetectorName().Data(), evno);
305 SetDetectorAddresses();
309 /**************************************************************************/
310 Int_t AliRunLoader::SetEvent()
312 //if kinematics was loaded Cleans folder data
316 retval = fKineDataLoader->SetEvent();
319 Error("SetEvent","SetEvent for Kinamtics Data Loader retutned error.");
322 retval = fTrackRefsDataLoader->SetEvent();
325 Error("SetEvent","SetEvent for Track References Data Loader retutned error.");
329 TIter next(fLoaders);
331 while((loader = (AliLoader*)next()))
333 retval = loader->SetEvent();
336 Error("SetEvent","SetEvent for %s Data Loader retutned error.",loader->GetName());
343 /**************************************************************************/
345 Int_t AliRunLoader::SetEventNumber(Int_t evno)
347 //cleans folders and sets the root dirs in files
348 if (fCurrentEvent == evno) return 0;
349 fCurrentEvent = evno;
353 /**************************************************************************/
354 AliRunLoader* AliRunLoader::Open
355 (const char* filename, const char* eventfoldername, Option_t* option)
357 //Opens a desired file 'filename'
358 //gets the the run-Loader and mounts it desired folder
359 //returns the pointer to run Loader which can be further used for accessing data
360 //in case of error returns NULL
362 static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
363 if (AliLoader::GetDebug())
364 ::Info("AliRunLoader::Open",
365 "\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data());
367 AliRunLoader* result = 0x0;
369 /* ************************************************ */
370 /* Chceck if folder with given name already exists */
371 /* ************************************************ */
373 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
376 TFolder* fold = dynamic_cast<TFolder*>(obj);
379 ::Error("AliRunLoader::Open","Such a obejct already exists in top alice folder and it is not a folder.");
383 //check if we can get RL from that folder
384 result = AliRunLoader::GetRunLoader(eventfoldername);
387 ::Error("AliRunLoader::Open",
388 "Folder %s already exists, and can not find session there. Can not mount.",eventfoldername);
392 if (result->GetFileName().CompareTo(filename) != 0)
394 ::Error("AliRunLoader::Open","Other file is mounted in demanded folder. Can not mount.");
398 //check if now is demanded (re)creation
399 if ( AliLoader::TestFileOption(option) == kFALSE)
401 ::Error("AliRunLoader::Open",
402 "Session already exists in folder %s and this session option is %s. Unable to proceed.",
403 eventfoldername,option);
407 //check if demanded option is update and existing one
408 TString tmpstr(option);
409 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
410 (result->fGAFile->IsWritable() == kFALSE) )
412 ::Error("AliRunLoader::Open",
413 "Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
414 eventfoldername,option);
418 ::Warning("AliRunLoader::Open","Session is already opened and mounted in demanded folder");
420 } //end of checking in case of existance of object named identically that folder session is being opened
423 TFile * gAliceFile = TFile::Open(filename,option);//open a file
425 {//null pointer returned
426 ::Fatal("AliRunLoader::Open","Can not open file %s.",filename);
430 if (gAliceFile->IsOpen() == kFALSE)
431 {//pointer to valid object returned but file is not opened
432 ::Error("AliRunLoader::Open","Can not open file %s.",filename);
436 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
437 //else create new AliRunLoader
438 if ( AliLoader::TestFileOption(option) )
440 if (AliLoader::GetDebug())
441 ::Info("AliRunLoader::Open","Reading RL from file");
443 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
446 ::Error("AliRunLoader::Open","Can not find run-Loader in file %s.",filename);
447 delete gAliceFile;//close the file
450 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
451 if (tmp)//if SetEvent returned error
453 ::Error("AliRunLoader::Open","Can not mount event in folder %s.",eventfoldername);
454 delete result; //delete run-Loader
455 delete gAliceFile;//close the file
461 if (AliLoader::GetDebug())
462 ::Info("AliRunLoader::Open","Creating new AliRunLoader. Folder name is %s",eventfoldername);
465 result = new AliRunLoader(eventfoldername);
467 catch (TString& errmsg)
469 ::Error("Open","AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data());
471 delete gAliceFile;//close the file
476 //procedure for extracting dir name from the file name
477 TString fname(filename);
478 Int_t nsl = fname.Last('/');//look for slash in file name
482 Int_t nsl = fname.Last(':');//look for colon e.g. rfio:galice.root
483 if (nsl < 0) dirname = ".";//not found
484 else dirname = fname.Remove(nsl);//found
486 else dirname = fname.Remove(nsl);//slash found
488 if (AliLoader::GetDebug())
489 ::Info("AliRunLoader::Open","Dir name is : %s",dirname.Data());
491 result->SetDirName(dirname);
492 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
493 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
496 /**************************************************************************/
497 Int_t AliRunLoader::GetNumberOfEvents()
499 //returns number of events in Run
503 retval = LoadHeader();
506 Error("GetNumberOfEvents","Error occured while loading header");
510 return (Int_t)TreeE()->GetEntries();
512 /**************************************************************************/
514 void AliRunLoader::MakeHeader()
516 //Makes header and connects it to header tree (if it exists)
517 if (GetDebug()) Info("MakeHeader","");
520 if (GetDebug()) Info("MakeHeader","Creating new Header Object");
521 fHeader= new AliHeader();
523 TTree* tree = TreeE();
526 if (GetDebug()) Info("MakeHeader","Got Tree from folder.");
527 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
530 if (GetDebug()) Info("MakeHeader","Creating new branch");
531 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
532 branch->SetAutoDelete(kFALSE);
536 if (GetDebug()) Info("MakeHeader","Got Branch from Tree");
537 branch->SetAddress(&fHeader);
538 tree->GetEvent(fCurrentEvent);
539 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
542 fStack->SetEventFolderName(fEventFolder->GetName());
543 if (TreeK()) fStack->GetEvent();
547 if (GetDebug()) Info("MakeHeader","Haeder do not have a stack.");
551 if (GetDebug()) Info("MakeHeader","Exiting MakeHeader method");
553 /**************************************************************************/
555 void AliRunLoader::MakeStack()
557 //Creates the stack object - do not connect the tree
560 fStack = new AliStack(10000);
561 fStack->SetEventFolderName(fEventFolder->GetName());
565 /**************************************************************************/
567 void AliRunLoader::MakeTree(Option_t *option)
570 const char *oK = strstr(option,"K"); //Kine
571 const char *oE = strstr(option,"E"); //Header
575 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
577 Error("MakeTree(\"K\")","Load Kinematics first");
581 fKineDataLoader->MakeTree();
583 fStack->ConnectTree();
584 WriteKinematics("OVERWRITE");
591 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
592 GetEventFolder()->Add(tree);
594 WriteHeader("OVERWRITE");
597 TIter next(fLoaders);
599 while((loader = (AliLoader*)next()))
601 loader->MakeTree(option);
605 /**************************************************************************/
607 Int_t AliRunLoader::LoadgAlice()
609 //Loads gAlice from file
612 Warning("LoadgAlice","AliRun is already in folder. Unload first.");
615 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
618 Error("LoadgAlice"," Can not find gAlice in file %s",fGAFile->GetName());
621 alirun->SetRunLoader(this);
624 Warning("LoadgAlice","gAlice already exists. Putting retrived object in folder named %s",
625 GetEventFolder()->GetName());
631 SetDetectorAddresses();//calls SetTreeAddress for all detectors
634 /**************************************************************************/
636 Int_t AliRunLoader::LoadHeader()
638 //loads treeE and reads header object for current event
641 Warning("LoadHeader","Header is already loaded. Use ReloadHeader to force reload. Nothing done");
645 if (GetEventFolder() == 0x0)
647 Error("LoadHeader","Event folder not specified yet");
653 Error("LoadHeader","Session not opened. Use AliRunLoader::Open");
657 if (fGAFile->IsOpen() == kFALSE)
659 Error("LoadHeader","Session not opened. Use AliRunLoader::Open");
663 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
666 Error("LoadHeader","Can not find header tree named %s in file %s",
667 fgkHeaderContainerName.Data(),fGAFile->GetName());
671 if (tree == TreeE()) return 0;
674 GetEventFolder()->Add(tree);
675 MakeHeader();//creates header object and connects to tree
679 /**************************************************************************/
681 Int_t AliRunLoader::LoadKinematics(Option_t* option)
683 //Loads the kinematics
684 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
687 Error("LoadKinematics","Error occured while loading kinamatics tree.");
692 retval = fStack->GetEvent();
693 if ( retval == kFALSE)
695 Error("LoadKinematics","Error occured while loading kinamatics tree.");
702 /**************************************************************************/
704 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
706 //Opens File with kinematics
709 if (file->IsOpen() == kFALSE)
710 {//pointer is not null but file is not opened
711 Warning("OpenDataFile","Pointer to file is not null, but file is not opened");//risky any way
713 file = 0x0; //proceed with opening procedure
717 Warning("OpenDataFile","File %s already opened",filename.Data());
721 //try to find if that file is opened somewere else
722 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
725 if(file->IsOpen() == kTRUE)
727 Warning("OpenDataFile","File %s already opened by sombody else.",file->GetName());
732 file = TFile::Open(filename,opt);
735 Error("LoadKinematics","Can not open file %s",filename.Data());
738 if (file->IsOpen() == kFALSE)
739 {//file is not opened
740 Error("LoadKinematics","Can not open file %s",filename.Data());
744 file->SetCompressionLevel(cl);
746 dir = AliLoader::ChangeDir(file,fCurrentEvent);
749 Error("OpenKineFile","Can not change to root directory in file %s",filename.Data());
754 /**************************************************************************/
756 TTree* AliRunLoader::TreeE() const
758 //returns the tree from folder; shortcut method
759 if (GetDebug() > 10) fEventFolder->ls();
760 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
761 return (obj)?dynamic_cast<TTree*>(obj):0x0;
763 /**************************************************************************/
765 AliHeader* AliRunLoader::GetHeader() const
767 //returns pointer header object
770 /**************************************************************************/
772 TTree* AliRunLoader::TreeK() const
774 //returns the tree from folder; shortcut method
775 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
776 return (obj)?dynamic_cast<TTree*>(obj):0x0;
778 /**************************************************************************/
780 TTree* AliRunLoader::TreeTR() const
782 //returns the tree from folder; shortcut method
783 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
784 return (obj)?dynamic_cast<TTree*>(obj):0x0;
786 /**************************************************************************/
788 AliRun* AliRunLoader::GetAliRun() const
790 //returns AliRun which sits in the folder
791 if (fEventFolder == 0x0) return 0x0;
792 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
793 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
795 /**************************************************************************/
797 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
799 //writes geometry to the file
801 TGeometry* geo = GetAliRun()->GetGeometry();
804 Error("WriteGeometry","Can not get geometry from gAlice");
810 /**************************************************************************/
812 Int_t AliRunLoader::WriteHeader(Option_t* opt)
815 if (GetDebug()) Info("WriteHeader"," WRITING HEADER");
817 TTree* tree = TreeE();
820 Warning("WriteHeader","Can not find Header Tree in Folder");
823 if (fGAFile->IsWritable() == kFALSE)
825 Error("WriteHeader","File %s is not writable",fGAFile->GetName());
829 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
831 { //if they exist, see if option OVERWRITE is used
833 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
834 {//if it is not used - give an error message and return an error code
835 Error("WriteHeader","Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
840 tree->SetDirectory(fGAFile);
841 tree->Write(0,TObject::kOverwrite);
843 if (GetDebug()) Info("WriteHeader","WRITTEN\n\n");
847 /**************************************************************************/
849 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
851 //writes AliRun object to the file
853 if (GetAliRun()) GetAliRun()->Write();
856 /**************************************************************************/
858 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
861 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
863 /**************************************************************************/
864 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
866 //writes Track References tree
867 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
869 /**************************************************************************/
871 Int_t AliRunLoader::WriteHits(Option_t* opt)
873 //Calls WriteHits for all loaders
876 TIter next(fLoaders);
878 while((loader = (AliLoader*)next()))
880 res = loader->WriteHits(opt);
883 Error("WriteHits","Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res);
889 /**************************************************************************/
891 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
893 //Calls WriteSDigits for all loaders
896 TIter next(fLoaders);
898 while((loader = (AliLoader*)next()))
900 res = loader->WriteSDigits(opt);
903 Error("WriteSDigits","Failed to write summable digits for %s.",loader->GetDetectorName().Data());
909 /**************************************************************************/
911 Int_t AliRunLoader::WriteDigits(Option_t* opt)
913 //Calls WriteDigits for all loaders
916 TIter next(fLoaders);
918 while((loader = (AliLoader*)next()))
920 res = loader->WriteDigits(opt);
923 Error("WriteDigits","Failed to write digits for %s.",loader->GetDetectorName().Data());
929 /**************************************************************************/
931 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
933 //Calls WriteRecPoints for all loaders
936 TIter next(fLoaders);
938 while((loader = (AliLoader*)next()))
940 res = loader->WriteRecPoints(opt);
943 Error("WriteRecPoints","Failed to write Reconstructed Points for %s.",
944 loader->GetDetectorName().Data());
950 /**************************************************************************/
952 Int_t AliRunLoader::WriteTracks(Option_t* opt)
954 //Calls WriteTracks for all loaders
957 TIter next(fLoaders);
959 while((loader = (AliLoader*)next()))
961 res = loader->WriteTracks(opt);
964 Error("WriteTracks","Failed to write Tracks for %s.",
965 loader->GetDetectorName().Data());
971 /**************************************************************************/
973 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
975 //Writes itself to the file
977 this->Write(0,TObject::kOverwrite);
980 /**************************************************************************/
982 Int_t AliRunLoader::SetEventFolderName(const TString& name)
984 //sets top folder name for this run; of alread
987 Error("SetTopFolderName","Name is empty");
991 //check if such a folder already exists - try to find it in alice top folder
992 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
995 TFolder* fold = dynamic_cast<TFolder*>(obj);
998 Error("SetTopFolderName","Such a obejct already exists in top alice folder and it is not a folder.");
1001 //folder which was found is our folder
1002 if (fEventFolder == fold)
1008 Error("SetTopFolderName","Such a folder already exists in top alice folder. Can not mount.");
1013 //event is alredy connected, just change name of the folder
1016 fEventFolder->SetName(name);
1020 if (fKineDataLoader == 0x0)
1021 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1023 if ( fTrackRefsDataLoader == 0x0)
1024 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1026 //build the event folder structure
1027 if (GetDebug()) Info("SetEventFolderName","Creating new event folder named %s",name.Data());
1028 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1029 fEventFolder->Add(this);//put myself to the folder to accessible for all
1031 if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName());
1032 TIter next(fLoaders);
1034 while((loader = (AliLoader*)next()))
1036 loader->Register(fEventFolder);//build folder structure for this detector
1039 fKineDataLoader->SetEventFolder(GetEventFolder());
1040 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1041 fKineDataLoader->SetFolder(GetEventFolder());
1042 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1044 fEventFolder->SetOwner();
1047 /**************************************************************************/
1049 void AliRunLoader::AddLoader(AliLoader* loader)
1051 //Adds the Loader for given detector
1052 if (loader == 0x0) //if null shout and exit
1054 Error("AddLoader","Parameter is NULL");
1057 loader->SetDirName(fUnixDirName);
1058 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1059 //pass information to the Loader
1060 fLoaders->Add(loader);//add the Loader to the array
1062 /**************************************************************************/
1064 void AliRunLoader::AddLoader(AliDetector* det)
1066 //Asks module (detector) ro make a Loader and stores in the array
1067 if (det == 0x0) return;
1068 AliLoader* get = det->GetLoader();//try to get loader
1069 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1073 if (GetDebug()) Info("AddLoader","Detector: %s Loader : %s",det->GetName(),get->GetName());
1078 /**************************************************************************/
1080 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1082 //returns loader for given detector
1083 //note that naming convention is TPCLoader not just TPC
1084 return (AliLoader*)fLoaders->FindObject(detname);
1087 /**************************************************************************/
1089 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1091 //get loader for detector det
1092 if(det == 0x0) return 0x0;
1093 TString getname(det->GetName());
1095 if (GetDebug()) Info("GetLoader(AliDetector* det)"," Loader name is %s",getname.Data());
1096 return GetLoader(getname);
1099 /**************************************************************************/
1101 void AliRunLoader::CleanFolders()
1103 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1109 /**************************************************************************/
1111 void AliRunLoader::CleanDetectors()
1113 //Calls CleanFolders for all detectors
1114 TIter next(fLoaders);
1116 while((loader = (AliLoader*)next()))
1118 loader->CleanFolders();
1121 /**************************************************************************/
1123 void AliRunLoader::RemoveEventFolder()
1125 //remove all the tree of event
1126 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1128 if (fEventFolder == 0x0) return;
1129 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1130 fEventFolder->Remove(this);//remove us drom folder
1132 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1133 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1134 delete fEventFolder;
1136 /**************************************************************************/
1138 void AliRunLoader::SetGAliceFile(TFile* gafile)
1140 //sets pointer to galice.root file
1144 /**************************************************************************/
1146 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1148 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1150 if (GetDebug()) Info("LoadHits","Loading Hits");
1154 const char* oAll = strstr(detectors,"all");
1157 if (GetDebug()) Info("LoadHits","Option is All");
1162 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1163 loaders = &arr;//get the pointer array
1166 if (GetDebug()) Info("LoadHits","For detectors. Number of detectors chosen for loading %d",loaders->GetEntries());
1168 TIter next(loaders);
1170 while((loader = (AliLoader*)next()))
1172 if (GetDebug()) Info("LoadHits"," Calling LoadHits(%s) for %s",opt,loader->GetName());
1173 loader->LoadHits(opt);
1175 if (GetDebug()) Info("LoadHits","Done");
1179 /**************************************************************************/
1181 Int_t AliRunLoader::LoadSDigits(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 to array
1199 TIter next(loaders);
1201 while((loader = (AliLoader*)next()))
1203 loader->LoadSDigits(opt);
1208 /**************************************************************************/
1210 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1212 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1217 const char* oAll = strstr(detectors,"all");
1224 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1225 loaders = &arr;//get the pointer array
1228 TIter next(loaders);
1230 while((loader = (AliLoader*)next()))
1232 loader->LoadDigits(opt);
1236 /**************************************************************************/
1238 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1240 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1245 const char* oAll = strstr(detectors,"all");
1252 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1253 loaders = &arr;//get the pointer array
1256 TIter next(loaders);
1258 while((loader = (AliLoader*)next()))
1260 loader->LoadRecPoints(opt);
1264 /**************************************************************************/
1266 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1268 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1273 const char* oAll = strstr(detectors,"all");
1280 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1281 loaders = &arr;//get the pointer array
1284 TIter next(loaders);
1286 while((loader = (AliLoader*)next()))
1288 loader->LoadRecParticles(opt);
1292 /**************************************************************************/
1294 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1296 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1301 const char* oAll = strstr(detectors,"all");
1308 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1309 loaders = &arr;//get the pointer array
1312 TIter next(loaders);
1314 while((loader = (AliLoader*)next()))
1316 loader->LoadTracks(opt);
1320 /**************************************************************************/
1322 void AliRunLoader::UnloadHits(Option_t* detectors)
1324 //unloads hits for detectors specified in parameter
1328 const char* oAll = strstr(detectors,"all");
1335 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1336 loaders = &arr;//get the pointer to array
1339 TIter next(loaders);
1341 while((loader = (AliLoader*)next()))
1343 loader->UnloadHits();
1346 /**************************************************************************/
1348 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1350 //unloads SDigits for detectors specified in parameter
1354 const char* oAll = strstr(detectors,"all");
1361 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1362 loaders = &arr;//get the pointer to array
1365 TIter next(loaders);
1367 while((loader = (AliLoader*)next()))
1369 loader->UnloadSDigits();
1372 /**************************************************************************/
1374 void AliRunLoader::UnloadDigits(Option_t* detectors)
1376 //unloads Digits for detectors specified in parameter
1380 const char* oAll = strstr(detectors,"all");
1387 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1388 loaders = &arr;//get the pointer to array
1391 TIter next(loaders);
1393 while((loader = (AliLoader*)next()))
1395 loader->UnloadDigits();
1398 /**************************************************************************/
1400 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1402 //unloads RecPoints for detectors specified in parameter
1406 const char* oAll = strstr(detectors,"all");
1413 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1414 loaders = &arr;//get the pointer to array
1417 TIter next(loaders);
1419 while((loader = (AliLoader*)next()))
1421 loader->UnloadRecPoints();
1424 /**************************************************************************/
1426 void AliRunLoader::UnloadAll(Option_t* detectors)
1428 //calls UnloadAll for detectors names specified in parameter
1429 // option "all" passed can be passed
1433 const char* oAll = strstr(detectors,"all");
1440 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1441 loaders = &arr;//get the pointer to array
1444 TIter next(loaders);
1446 while((loader = (AliLoader*)next()))
1448 loader->UnloadAll();
1451 /**************************************************************************/
1453 void AliRunLoader::UnloadTracks(Option_t* detectors)
1455 //unloads Tracks for detectors specified in parameter
1459 const char* oAll = strstr(detectors,"all");
1466 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1467 loaders = &arr;//get the pointer to array
1470 TIter next(loaders);
1472 while((loader = (AliLoader*)next()))
1474 loader->UnloadTracks();
1477 /**************************************************************************/
1479 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1481 //unloads Particles for detectors specified in parameter
1485 const char* oAll = strstr(detectors,"all");
1492 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1493 loaders = &arr;//get the pointer to array
1496 TIter next(loaders);
1498 while((loader = (AliLoader*)next()))
1500 loader->UnloadRecParticles();
1503 /**************************************************************************/
1505 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1507 //returns RunLoader from folder named eventfoldername
1508 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1513 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1517 /**************************************************************************/
1519 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1521 //get the loader of the detector with the given name from the global
1523 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1525 ::Error("AliRunLoader::GetDetectorLoader","No run loader found");
1528 return runLoader->GetDetectorLoader(detname);
1530 /**************************************************************************/
1532 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1534 //get the loader of the detector with the given name from the global
1537 char loadername[256];
1538 sprintf(loadername, "%sLoader", detname);
1539 AliLoader* loader = GetLoader(loadername);
1541 Error("GetDetectorLoader", "No loader for %s found", detname);
1546 /**************************************************************************/
1548 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1550 //get the tree with hits of the detector with the given name
1551 //if maketree is true and the tree does not exist, the tree is created
1552 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1553 if (!loader) return NULL;
1554 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1555 return loader->TreeH();
1558 /**************************************************************************/
1560 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1562 //get the tree with hits of the detector with the given name
1563 //if maketree is true and the tree does not exist, the tree is created
1564 AliLoader* loader = GetDetectorLoader(detname);
1565 if (!loader) return NULL;
1566 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1567 return loader->TreeH();
1569 /**************************************************************************/
1571 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1573 //get the tree with summable digits of the detector with the given name
1574 //if maketree is true and the tree does not exist, the tree is created
1575 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1576 if (!loader) return NULL;
1577 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1578 return loader->TreeS();
1580 /**************************************************************************/
1582 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1584 //get the tree with summable digits of the detector with the given name
1585 //if maketree is true and the tree does not exist, the tree is created
1586 AliLoader* loader = GetDetectorLoader(detname);
1587 if (!loader) return NULL;
1588 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1589 return loader->TreeS();
1591 /**************************************************************************/
1593 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1595 //get the tree with digits of the detector with the given name
1596 //if maketree is true and the tree does not exist, the tree is created
1597 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1598 if (!loader) return NULL;
1599 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1600 return loader->TreeD();
1602 /**************************************************************************/
1604 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1606 //get the tree with digits of the detector with the given name
1607 //if maketree is true and the tree does not exist, the tree is created
1608 AliLoader* loader = GetDetectorLoader(detname);
1609 if (!loader) return NULL;
1610 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1611 return loader->TreeD();
1613 /**************************************************************************/
1614 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1616 //get the tree with clusters of the detector with the given name
1617 //if maketree is true and the tree does not exist, the tree is created
1618 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1619 if (!loader) return NULL;
1620 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1621 return loader->TreeR();
1623 /**************************************************************************/
1625 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1627 //get the tree with clusters of the detector with the given name
1628 //if maketree is true and the tree does not exist, the tree is created
1629 AliLoader* loader = GetDetectorLoader(detname);
1630 if (!loader) return NULL;
1631 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1632 return loader->TreeR();
1634 /**************************************************************************/
1636 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1638 //get the tree with tracks of the detector with the given name
1639 //if maketree is true and the tree does not exist, the tree is created
1640 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1641 if (!loader) return NULL;
1642 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1643 return loader->TreeT();
1645 /**************************************************************************/
1647 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1649 //get the tree with tracks of the detector with the given name
1650 //if maketree is true and the tree does not exist, the tree is created
1651 AliLoader* loader = GetDetectorLoader(detname);
1652 if (!loader) return NULL;
1653 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1654 return loader->TreeT();
1656 /**************************************************************************/
1658 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1660 //get the tree with particles of the detector with the given name
1661 //if maketree is true and the tree does not exist, the tree is created
1662 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1663 if (!loader) return NULL;
1664 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1665 return loader->TreeP();
1667 /**************************************************************************/
1669 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1671 //get the tree with particles of the detector with the given name
1672 //if maketree is true and the tree does not exist, the tree is created
1673 AliLoader* loader = GetDetectorLoader(detname);
1674 if (!loader) return NULL;
1675 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1676 return loader->TreeP();
1679 /**************************************************************************/
1681 void AliRunLoader::CdGAFile()
1683 //sets gDirectory to galice file
1685 if(fGAFile) fGAFile->cd();
1688 /**************************************************************************/
1690 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1692 //this method looks for all Loaders corresponding
1693 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1697 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1698 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1703 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1704 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1706 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1707 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1708 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1709 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1710 //construct the Loader name
1711 TString getname(buff);
1713 AliLoader* loader = GetLoader(getname);//get the Loader
1716 pointerarray.Add(loader);
1720 Error("GetListOfDetectors","Can not find Loader for %s",buff);
1726 /*****************************************************************************/
1728 void AliRunLoader::Clean(const TString& name)
1730 //removes object with given name from event folder and deletes it
1731 if (GetEventFolder() == 0x0) return;
1732 TObject* obj = GetEventFolder()->FindObject(name);
1735 if (GetDebug()) Info("Clean(const TString&)","name=%s, cleaning %s.",GetName(),name.Data());
1736 GetEventFolder()->Remove(obj);
1741 /*****************************************************************************/
1743 TTask* AliRunLoader::GetRunDigitizer()
1745 //returns Run Digitizer from folder
1747 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1748 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1749 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1751 /*****************************************************************************/
1753 TTask* AliRunLoader::GetRunSDigitizer()
1755 //returns SDigitizer Task from folder
1757 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1758 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1759 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1761 /*****************************************************************************/
1763 TTask* AliRunLoader::GetRunReconstructioner()
1765 //returns Reconstructioner Task from folder
1766 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1767 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1768 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1770 /*****************************************************************************/
1772 TTask* AliRunLoader::GetRunTracker()
1774 //returns Tracker Task from folder
1775 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1776 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1777 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1779 /*****************************************************************************/
1781 TTask* AliRunLoader::GetRunPIDTask()
1783 //returns Tracker Task from folder
1784 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1785 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1786 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1788 /*****************************************************************************/
1790 TTask* AliRunLoader::GetRunQATask()
1792 //returns Quality Assurance Task from folder
1793 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1796 ::Error("AliRunLoader::GetRunQATask","Can not get task folder from AliConfig");
1799 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1800 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1803 /*****************************************************************************/
1805 void AliRunLoader::SetCompressionLevel(Int_t cl)
1807 //Sets Compression Level in all files
1808 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1809 SetKineComprLevel(cl);
1810 SetTrackRefsComprLevel(cl);
1811 TIter next(fLoaders);
1813 while((loader = (AliLoader*)next()))
1815 loader->SetCompressionLevel(cl);
1818 /**************************************************************************/
1820 void AliRunLoader::SetKineComprLevel(Int_t cl)
1822 //Sets comression level in Kine File
1823 fKineDataLoader->SetCompressionLevel(cl);
1825 /**************************************************************************/
1827 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1829 //Sets comression level in Track Refences File
1830 fTrackRefsDataLoader->SetCompressionLevel(cl);
1832 /**************************************************************************/
1834 void AliRunLoader::UnloadHeader()
1836 //removes TreeE from folder and deletes it
1837 // as well as fHeader object
1842 /**************************************************************************/
1844 void AliRunLoader::UnloadKinematics()
1846 //Unloads Kinematics
1847 fKineDataLoader->GetBaseLoader(0)->Unload();
1849 /**************************************************************************/
1851 void AliRunLoader::UnloadTrackRefs()
1853 //Unloads Track Refernces
1854 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
1856 /**************************************************************************/
1858 void AliRunLoader::UnloadgAlice()
1861 if (gAlice == GetAliRun())
1863 if (GetDebug()) Info("UnloadgAlice","Set gAlice = 0x0");
1864 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
1866 AliRun* alirun = GetAliRun();
1867 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
1870 /**************************************************************************/
1872 void AliRunLoader::MakeTrackRefsContainer()
1874 // Makes a tree for Track References
1875 fTrackRefsDataLoader->MakeTree();
1877 /**************************************************************************/
1879 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
1881 //Load track references from file (opens file and posts tree to folder)
1883 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
1885 /**************************************************************************/
1887 void AliRunLoader::SetDirName(TString& dirname)
1889 //sets directory name
1890 if (dirname.IsNull()) return;
1891 fUnixDirName = dirname;
1892 fKineDataLoader->SetDirName(dirname);
1893 fTrackRefsDataLoader->SetDirName(dirname);
1895 TIter next(fLoaders);
1897 while((loader = (AliLoader*)next()))
1899 loader->SetDirName(dirname);
1903 /*****************************************************************************/
1905 Int_t AliRunLoader::GetFileOffset() const
1907 //returns the file number that is added to the file name for current event
1908 return Int_t(fCurrentEvent/fNEventsPerFile);
1911 /*****************************************************************************/
1912 const TString AliRunLoader::SetFileOffset(const TString& fname)
1914 //adds the the number to the file name at proper place for current event
1915 Long_t offset = (Long_t)GetFileOffset();
1916 if (offset < 1) return fname;
1918 soffset += offset;//automatic conversion to string
1919 TString dotroot(".root");
1920 const TString& offfsetdotroot = offset + dotroot;
1921 TString out = fname;
1922 out = out.ReplaceAll(dotroot,offfsetdotroot);
1923 if (GetDebug()) Info("SetFileOffset"," in=%s out=%s",fname.Data(),out.Data());
1926 /*****************************************************************************/
1928 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
1930 //adds the suffix before ".root",
1931 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
1932 //made on Jiri Chudoba demand
1934 TIter next(fLoaders);
1936 while((loader = (AliLoader*)next()))
1938 loader->SetDigitsFileNameSuffix(suffix);
1941 /*****************************************************************************/
1943 TString AliRunLoader::GetFileName() const
1945 //returns name of galice file
1947 if (fGAFile == 0x0) return result;
1948 result = fGAFile->GetName();
1951 /*****************************************************************************/
1953 void AliRunLoader::SetDetectorAddresses()
1955 //calls SetTreeAddress for all detectors
1956 if (GetAliRun()==0x0) return;
1957 TIter next(GetAliRun()->Modules());
1959 while((mod = (AliModule*)next()))
1961 AliDetector* det = dynamic_cast<AliDetector*>(mod);
1962 if (det) det->SetTreeAddress();
1965 /*****************************************************************************/
1967 void AliRunLoader::Synchronize()
1969 //synchrinizes all writtable files
1970 TIter next(fLoaders);
1972 while((loader = (AliLoader*)next()))
1974 loader->Synchronize();
1977 fKineDataLoader->Synchronize();
1978 fTrackRefsDataLoader->Synchronize();
1980 if (fGAFile) fGAFile->Flush();
1982 /*****************************************************************************/
1983 /*****************************************************************************/