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>
60 #include "AliConfig.h"
61 #include "AliLoader.h"
62 #include "AliHeader.h"
64 #include "AliDetector.h"
65 #include "AliRunDataStorage.h"
66 #include "AliRunDataFile.h"
67 #include "AliRunLoader.h"
69 ClassImp(AliRunLoader)
71 AliRunLoader* AliRunLoader::fgRunLoader = 0x0;
73 const TString AliRunLoader::fgkRunLoaderName("RunLoader");
75 const TString AliRunLoader::fgkHeaderBranchName("Header");
76 const TString AliRunLoader::fgkHeaderContainerName("TE");
77 const TString AliRunLoader::fgkKineContainerName("TreeK");
78 const TString AliRunLoader::fgkTrackRefsContainerName("TreeTR");
79 const TString AliRunLoader::fgkKineBranchName("Particles");
80 const TString AliRunLoader::fgkDefaultKineFileName("Kinematics.root");
81 const TString AliRunLoader::fgkDefaultTrackRefsFileName("TrackRefs.root");
82 const TString AliRunLoader::fgkGAliceName("gAlice");
83 /**************************************************************************/
85 AliRunLoader::AliRunLoader():
93 fTrackRefsDataLoader(0x0),
97 AliConfig::Instance();//force to build the folder structure
98 if (!fgRunLoader) fgRunLoader = this;
100 /**************************************************************************/
102 AliRunLoader::AliRunLoader(const char* eventfoldername):
103 TNamed(fgkRunLoaderName,fgkRunLoaderName),
104 fLoaders(new TObjArray()),
110 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
111 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
116 SetEventFolderName(eventfoldername);
117 if (!fgRunLoader) fgRunLoader = this;
119 /**************************************************************************/
121 AliRunLoader::AliRunLoader(const AliRunLoader &rl):
129 fKineDataLoader(0x0),
130 fTrackRefsDataLoader(0x0),
139 /**************************************************************************/
141 AliRunLoader::~AliRunLoader()
144 if (fgRunLoader == this) fgRunLoader = 0x0;
150 fLoaders->SetOwner();
154 delete fKineDataLoader;
155 delete fTrackRefsDataLoader;
160 //fEventFolder is deleted by the way of removing - TopAliceFolder owns it
165 /**************************************************************************/
167 AliRunLoader::AliRunLoader(TFolder* topfolder):
168 TNamed(fgkRunLoaderName,fgkRunLoaderName),
169 fLoaders(new TObjArray()),
170 fEventFolder(topfolder),
175 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
176 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
183 TString errmsg("Parameter is NULL");
184 AliError(errmsg.Data());
189 TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
191 { //if it is, then sth. is going wrong... exits aliroot session
192 TString errmsg("In Event Folder Named ");
193 errmsg+=fEventFolder->GetName();
194 errmsg+=" object named "+fgkRunLoaderName+" already exists. I am confused ...";
196 AliError(errmsg.Data());
198 return;//never reached
201 if (!fgRunLoader) fgRunLoader = this;
203 fEventFolder->Add(this);//put myself to the folder to accessible for all
206 /**************************************************************************/
208 void AliRunLoader::Copy(TObject &) const
210 AliFatal("Not implemented");
212 /**************************************************************************/
214 Int_t AliRunLoader::GetEvent(Int_t evno)
216 //Gets event number evno
217 //Reloads all data properly
218 if (fCurrentEvent == evno) return 0;
222 AliError("Can not give the event with negative number");
226 if (evno >= GetNumberOfEvents())
228 AliError(Form("There is no event with number %d",evno));
232 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
233 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
234 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
235 AliDebug(1, Form(" GETTING EVENT %d",evno));
236 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
237 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
238 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
240 fCurrentEvent = evno;
244 //Reload header (If header was loaded)
247 retval = TreeE()->GetEvent(fCurrentEvent);
250 AliError(Form("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 AliWarning("Stack not found in header");
269 AliError(Form("Error occured while setting event %d",evno));
273 //Post Track References
274 retval = fTrackRefsDataLoader->GetEvent();
277 AliError(Form("Error occured while GetEvent for Track References. Event %d",evno));
281 //Read Kinematics if loaded
282 fKineDataLoader->GetEvent();
285 AliError(Form("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 AliError(Form("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 AliError("SetEvent for Kinamtics Data Loader retutned error.");
322 retval = fTrackRefsDataLoader->SetEvent();
325 AliError("SetEvent for Track References Data Loader retutned error.");
329 TIter next(fLoaders);
331 while((loader = (AliLoader*)next()))
333 retval = loader->SetEvent();
336 AliError(Form("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 const TObject* AliRunLoader::GetRunObject(const char* name) const
356 //Get an object from the run data storage
358 if (!AliRunDataStorage::Instance()) {
359 AliWarning("No run data storage defined. Using AliRunDataFile.");
362 return AliRunDataStorage::Instance()->Get(name, GetEventNumber());
365 /**************************************************************************/
366 AliRunLoader* AliRunLoader::Open
367 (const char* filename, const char* eventfoldername, Option_t* option)
369 //Opens a desired file 'filename'
370 //gets the the run-Loader and mounts it desired folder
371 //returns the pointer to run Loader which can be further used for accessing data
372 //in case of error returns NULL
374 static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
375 AliDebugClass(1,Form("\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data()));
377 AliRunLoader* result = 0x0;
379 /* ************************************************ */
380 /* Chceck if folder with given name already exists */
381 /* ************************************************ */
383 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
386 TFolder* fold = dynamic_cast<TFolder*>(obj);
389 AliErrorClass("Such a obejct already exists in top alice folder and it is not a folder.");
393 //check if we can get RL from that folder
394 result = AliRunLoader::GetRunLoader(eventfoldername);
397 AliErrorClass(Form("Folder %s already exists, and can not find session there. Can not mount.",eventfoldername));
401 if (result->GetFileName().CompareTo(filename) != 0)
403 AliErrorClass("Other file is mounted in demanded folder. Can not mount.");
407 //check if now is demanded (re)creation
408 if ( AliLoader::TestFileOption(option) == kFALSE)
410 AliErrorClass(Form("Session already exists in folder %s and this session option is %s. Unable to proceed.",
411 eventfoldername,option));
415 //check if demanded option is update and existing one
416 TString tmpstr(option);
417 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
418 (result->fGAFile->IsWritable() == kFALSE) )
420 AliErrorClass(Form("Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
421 eventfoldername,option));
425 AliWarningClass("Session is already opened and mounted in demanded folder");
427 } //end of checking in case of existance of object named identically that folder session is being opened
430 TFile * gAliceFile = TFile::Open(filename,option);//open a file
432 {//null pointer returned
433 AliFatalClass(Form("Can not open file %s.",filename));
437 if (gAliceFile->IsOpen() == kFALSE)
438 {//pointer to valid object returned but file is not opened
439 AliErrorClass(Form("Can not open file %s.",filename));
443 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
444 //else create new AliRunLoader
445 if ( AliLoader::TestFileOption(option) )
447 AliDebugClass(1, "Reading RL from file");
449 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
452 AliErrorClass(Form("Can not find run-Loader in file %s.",filename));
453 delete gAliceFile;//close the file
456 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
457 if (tmp)//if SetEvent returned error
459 AliErrorClass(Form("Can not mount event in folder %s.",eventfoldername));
460 delete result; //delete run-Loader
461 delete gAliceFile;//close the file
467 AliDebugClass(1, Form("Creating new AliRunLoader. Folder name is %s",eventfoldername));
470 result = new AliRunLoader(eventfoldername);
472 catch (TString& errmsg)
474 AliErrorClass(Form("AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data()));
476 delete gAliceFile;//close the file
481 //procedure for extracting dir name from the file name
482 TString fname(filename);
483 Int_t nsl = fname.Last('/');//look for slash in file name
487 Int_t nsl = fname.Last(':');//look for colon e.g. rfio:galice.root
488 if (nsl < 0) dirname = ".";//not found
489 else dirname = fname.Remove(nsl);//found
491 else dirname = fname.Remove(nsl);//slash found
493 AliDebugClass(1, Form("Dir name is : %s",dirname.Data()));
495 result->SetDirName(dirname);
496 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
497 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
500 /**************************************************************************/
501 Int_t AliRunLoader::GetNumberOfEvents()
503 //returns number of events in Run
507 retval = LoadHeader();
510 AliError("Error occured while loading header");
514 return (Int_t)TreeE()->GetEntries();
516 /**************************************************************************/
518 void AliRunLoader::MakeHeader()
520 //Makes header and connects it to header tree (if it exists)
524 AliDebug(1, "Creating new Header Object");
525 fHeader= new AliHeader();
527 TTree* tree = TreeE();
530 AliDebug(1, "Got Tree from folder.");
531 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
534 AliDebug(1, "Creating new branch");
535 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
536 branch->SetAutoDelete(kFALSE);
540 AliDebug(1, "Got Branch from Tree");
541 branch->SetAddress(&fHeader);
542 tree->GetEvent(fCurrentEvent);
543 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
546 fStack->SetEventFolderName(fEventFolder->GetName());
547 if (TreeK()) fStack->GetEvent();
551 AliDebug(1, "Header does not have a stack.");
555 AliDebug(1, "Exiting MakeHeader method");
557 /**************************************************************************/
559 void AliRunLoader::MakeStack()
561 //Creates the stack object - do not connect the tree
564 fStack = new AliStack(10000);
565 fStack->SetEventFolderName(fEventFolder->GetName());
569 /**************************************************************************/
571 void AliRunLoader::MakeTree(Option_t *option)
574 const char *oK = strstr(option,"K"); //Kine
575 const char *oE = strstr(option,"E"); //Header
579 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
581 AliError("Load Kinematics first");
585 fKineDataLoader->MakeTree();
587 fStack->ConnectTree();
588 WriteKinematics("OVERWRITE");
595 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
596 GetEventFolder()->Add(tree);
598 WriteHeader("OVERWRITE");
601 TIter next(fLoaders);
603 while((loader = (AliLoader*)next()))
605 loader->MakeTree(option);
609 /**************************************************************************/
611 Int_t AliRunLoader::LoadgAlice()
613 //Loads gAlice from file
616 AliWarning("AliRun is already in folder. Unload first.");
619 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
622 AliError(Form("Can not find gAlice in file %s",fGAFile->GetName()));
625 alirun->SetRunLoader(this);
628 AliWarning(Form("gAlice already exists. Putting retrived object in folder named %s",
629 GetEventFolder()->GetName()));
635 SetDetectorAddresses();//calls SetTreeAddress for all detectors
638 /**************************************************************************/
640 Int_t AliRunLoader::LoadHeader()
642 //loads treeE and reads header object for current event
645 AliWarning("Header is already loaded. Use ReloadHeader to force reload. Nothing done");
649 if (GetEventFolder() == 0x0)
651 AliError("Event folder not specified yet");
657 AliError("Session not opened. Use AliRunLoader::Open");
661 if (fGAFile->IsOpen() == kFALSE)
663 AliError("Session not opened. Use AliRunLoader::Open");
667 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
670 AliError(Form("Can not find header tree named %s in file %s",
671 fgkHeaderContainerName.Data(),fGAFile->GetName()));
675 if (tree == TreeE()) return 0;
678 GetEventFolder()->Add(tree);
679 MakeHeader();//creates header object and connects to tree
683 /**************************************************************************/
685 Int_t AliRunLoader::LoadKinematics(Option_t* option)
687 //Loads the kinematics
688 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
691 AliError("Error occured while loading kinamatics tree.");
696 retval = fStack->GetEvent();
697 if ( retval == kFALSE)
699 AliError("Error occured while loading kinamatics tree.");
706 /**************************************************************************/
708 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
710 //Opens File with kinematics
713 if (file->IsOpen() == kFALSE)
714 {//pointer is not null but file is not opened
715 AliWarning("Pointer to file is not null, but file is not opened");//risky any way
717 file = 0x0; //proceed with opening procedure
721 AliWarning(Form("File %s already opened",filename.Data()));
725 //try to find if that file is opened somewere else
726 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
729 if(file->IsOpen() == kTRUE)
731 AliWarning(Form("File %s already opened by sombody else.",file->GetName()));
736 file = TFile::Open(filename,opt);
739 AliError(Form("Can not open file %s",filename.Data()));
742 if (file->IsOpen() == kFALSE)
743 {//file is not opened
744 AliError(Form("Can not open file %s",filename.Data()));
748 file->SetCompressionLevel(cl);
750 dir = AliLoader::ChangeDir(file,fCurrentEvent);
753 AliError(Form("Can not change to root directory in file %s",filename.Data()));
758 /**************************************************************************/
760 TTree* AliRunLoader::TreeE() const
762 //returns the tree from folder; shortcut method
763 if (AliDebugLevel() > 10) fEventFolder->ls();
764 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
765 return (obj)?dynamic_cast<TTree*>(obj):0x0;
767 /**************************************************************************/
769 AliHeader* AliRunLoader::GetHeader() const
771 //returns pointer header object
774 /**************************************************************************/
776 TTree* AliRunLoader::TreeK() const
778 //returns the tree from folder; shortcut method
779 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
780 return (obj)?dynamic_cast<TTree*>(obj):0x0;
782 /**************************************************************************/
784 TTree* AliRunLoader::TreeTR() const
786 //returns the tree from folder; shortcut method
787 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
788 return (obj)?dynamic_cast<TTree*>(obj):0x0;
790 /**************************************************************************/
792 AliRun* AliRunLoader::GetAliRun() const
794 //returns AliRun which sits in the folder
795 if (fEventFolder == 0x0) return 0x0;
796 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
797 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
799 /**************************************************************************/
801 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
803 //writes geometry to the file
805 TGeometry* geo = GetAliRun()->GetGeometry();
808 AliError("Can not get geometry from gAlice");
814 /**************************************************************************/
816 Int_t AliRunLoader::WriteHeader(Option_t* opt)
819 AliDebug(1, "WRITING HEADER");
821 TTree* tree = TreeE();
824 AliWarning("Can not find Header Tree in Folder");
827 if (fGAFile->IsWritable() == kFALSE)
829 AliError(Form("File %s is not writable",fGAFile->GetName()));
833 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
835 { //if they exist, see if option OVERWRITE is used
837 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
838 {//if it is not used - give an error message and return an error code
839 AliError("Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
844 tree->SetDirectory(fGAFile);
845 tree->Write(0,TObject::kOverwrite);
847 AliDebug(1, "WRITTEN\n\n");
851 /**************************************************************************/
853 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
855 //writes AliRun object to the file
857 if (GetAliRun()) GetAliRun()->Write();
860 /**************************************************************************/
862 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
865 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
867 /**************************************************************************/
868 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
870 //writes Track References tree
871 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
873 /**************************************************************************/
875 Int_t AliRunLoader::WriteHits(Option_t* opt)
877 //Calls WriteHits for all loaders
880 TIter next(fLoaders);
882 while((loader = (AliLoader*)next()))
884 res = loader->WriteHits(opt);
887 AliError(Form("Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res));
893 /**************************************************************************/
895 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
897 //Calls WriteSDigits for all loaders
900 TIter next(fLoaders);
902 while((loader = (AliLoader*)next()))
904 res = loader->WriteSDigits(opt);
907 AliError(Form("Failed to write summable digits for %s.",loader->GetDetectorName().Data()));
913 /**************************************************************************/
915 Int_t AliRunLoader::WriteDigits(Option_t* opt)
917 //Calls WriteDigits for all loaders
920 TIter next(fLoaders);
922 while((loader = (AliLoader*)next()))
924 res = loader->WriteDigits(opt);
927 AliError(Form("Failed to write digits for %s.",loader->GetDetectorName().Data()));
933 /**************************************************************************/
935 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
937 //Calls WriteRecPoints for all loaders
940 TIter next(fLoaders);
942 while((loader = (AliLoader*)next()))
944 res = loader->WriteRecPoints(opt);
947 AliError(Form("Failed to write Reconstructed Points for %s.",
948 loader->GetDetectorName().Data()));
954 /**************************************************************************/
956 Int_t AliRunLoader::WriteTracks(Option_t* opt)
958 //Calls WriteTracks for all loaders
961 TIter next(fLoaders);
963 while((loader = (AliLoader*)next()))
965 res = loader->WriteTracks(opt);
968 AliError(Form("Failed to write Tracks for %s.",
969 loader->GetDetectorName().Data()));
975 /**************************************************************************/
977 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
979 //Writes itself to the file
981 this->Write(0,TObject::kOverwrite);
984 /**************************************************************************/
986 Int_t AliRunLoader::SetEventFolderName(const TString& name)
988 //sets top folder name for this run; of alread
991 AliError("Name is empty");
995 //check if such a folder already exists - try to find it in alice top folder
996 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
999 TFolder* fold = dynamic_cast<TFolder*>(obj);
1002 AliError("Such a obejct already exists in top alice folder and it is not a folder.");
1005 //folder which was found is our folder
1006 if (fEventFolder == fold)
1012 AliError("Such a folder already exists in top alice folder. Can not mount.");
1017 //event is alredy connected, just change name of the folder
1020 fEventFolder->SetName(name);
1024 if (fKineDataLoader == 0x0)
1025 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1027 if ( fTrackRefsDataLoader == 0x0)
1028 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1030 //build the event folder structure
1031 AliDebug(1, Form("Creating new event folder named %s",name.Data()));
1032 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1033 fEventFolder->Add(this);//put myself to the folder to accessible for all
1035 if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName());
1036 TIter next(fLoaders);
1038 while((loader = (AliLoader*)next()))
1040 loader->Register(fEventFolder);//build folder structure for this detector
1043 fKineDataLoader->SetEventFolder(GetEventFolder());
1044 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1045 fKineDataLoader->SetFolder(GetEventFolder());
1046 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1048 fEventFolder->SetOwner();
1051 /**************************************************************************/
1053 void AliRunLoader::AddLoader(AliLoader* loader)
1055 //Adds the Loader for given detector
1056 if (loader == 0x0) //if null shout and exit
1058 AliError("Parameter is NULL");
1061 loader->SetDirName(fUnixDirName);
1062 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1063 //pass information to the Loader
1064 fLoaders->Add(loader);//add the Loader to the array
1066 /**************************************************************************/
1068 void AliRunLoader::AddLoader(AliDetector* det)
1070 //Asks module (detector) ro make a Loader and stores in the array
1071 if (det == 0x0) return;
1072 AliLoader* get = det->GetLoader();//try to get loader
1073 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1077 AliDebug(1, Form("Detector: %s Loader : %s",det->GetName(),get->GetName()));
1082 /**************************************************************************/
1084 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1086 //returns loader for given detector
1087 //note that naming convention is TPCLoader not just TPC
1088 return (AliLoader*)fLoaders->FindObject(detname);
1091 /**************************************************************************/
1093 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1095 //get loader for detector det
1096 if(det == 0x0) return 0x0;
1097 TString getname(det->GetName());
1099 AliDebug(1, Form(" Loader name is %s",getname.Data()));
1100 return GetLoader(getname);
1103 /**************************************************************************/
1105 void AliRunLoader::CleanFolders()
1107 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1113 /**************************************************************************/
1115 void AliRunLoader::CleanDetectors()
1117 //Calls CleanFolders for all detectors
1118 TIter next(fLoaders);
1120 while((loader = (AliLoader*)next()))
1122 loader->CleanFolders();
1125 /**************************************************************************/
1127 void AliRunLoader::RemoveEventFolder()
1129 //remove all the tree of event
1130 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1132 if (fEventFolder == 0x0) return;
1133 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1134 fEventFolder->Remove(this);//remove us drom folder
1136 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1137 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1138 delete fEventFolder;
1140 /**************************************************************************/
1142 void AliRunLoader::SetGAliceFile(TFile* gafile)
1144 //sets pointer to galice.root file
1148 /**************************************************************************/
1150 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1152 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1154 AliDebug(1, "Loading Hits");
1158 const char* oAll = strstr(detectors,"all");
1161 AliDebug(1, "Option is All");
1166 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1167 loaders = &arr;//get the pointer array
1170 AliDebug(1, Form("For detectors. Number of detectors chosen for loading %d",loaders->GetEntries()));
1172 TIter next(loaders);
1174 while((loader = (AliLoader*)next()))
1176 AliDebug(1, Form(" Calling LoadHits(%s) for %s",opt,loader->GetName()));
1177 loader->LoadHits(opt);
1179 AliDebug(1, "Done");
1183 /**************************************************************************/
1185 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1187 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1192 const char* oAll = strstr(detectors,"all");
1199 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1200 loaders = &arr;//get the pointer to array
1203 TIter next(loaders);
1205 while((loader = (AliLoader*)next()))
1207 loader->LoadSDigits(opt);
1212 /**************************************************************************/
1214 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1216 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1221 const char* oAll = strstr(detectors,"all");
1228 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1229 loaders = &arr;//get the pointer array
1232 TIter next(loaders);
1234 while((loader = (AliLoader*)next()))
1236 loader->LoadDigits(opt);
1240 /**************************************************************************/
1242 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1244 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1249 const char* oAll = strstr(detectors,"all");
1256 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1257 loaders = &arr;//get the pointer array
1260 TIter next(loaders);
1262 while((loader = (AliLoader*)next()))
1264 loader->LoadRecPoints(opt);
1268 /**************************************************************************/
1270 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1272 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1277 const char* oAll = strstr(detectors,"all");
1284 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1285 loaders = &arr;//get the pointer array
1288 TIter next(loaders);
1290 while((loader = (AliLoader*)next()))
1292 loader->LoadRecParticles(opt);
1296 /**************************************************************************/
1298 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1300 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1305 const char* oAll = strstr(detectors,"all");
1312 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1313 loaders = &arr;//get the pointer array
1316 TIter next(loaders);
1318 while((loader = (AliLoader*)next()))
1320 loader->LoadTracks(opt);
1324 /**************************************************************************/
1326 void AliRunLoader::UnloadHits(Option_t* detectors)
1328 //unloads hits for detectors specified in parameter
1332 const char* oAll = strstr(detectors,"all");
1339 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1340 loaders = &arr;//get the pointer to array
1343 TIter next(loaders);
1345 while((loader = (AliLoader*)next()))
1347 loader->UnloadHits();
1350 /**************************************************************************/
1352 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1354 //unloads SDigits for detectors specified in parameter
1358 const char* oAll = strstr(detectors,"all");
1365 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1366 loaders = &arr;//get the pointer to array
1369 TIter next(loaders);
1371 while((loader = (AliLoader*)next()))
1373 loader->UnloadSDigits();
1376 /**************************************************************************/
1378 void AliRunLoader::UnloadDigits(Option_t* detectors)
1380 //unloads Digits for detectors specified in parameter
1384 const char* oAll = strstr(detectors,"all");
1391 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1392 loaders = &arr;//get the pointer to array
1395 TIter next(loaders);
1397 while((loader = (AliLoader*)next()))
1399 loader->UnloadDigits();
1402 /**************************************************************************/
1404 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1406 //unloads RecPoints for detectors specified in parameter
1410 const char* oAll = strstr(detectors,"all");
1417 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1418 loaders = &arr;//get the pointer to array
1421 TIter next(loaders);
1423 while((loader = (AliLoader*)next()))
1425 loader->UnloadRecPoints();
1428 /**************************************************************************/
1430 void AliRunLoader::UnloadAll(Option_t* detectors)
1432 //calls UnloadAll for detectors names specified in parameter
1433 // option "all" passed can be passed
1437 const char* oAll = strstr(detectors,"all");
1444 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1445 loaders = &arr;//get the pointer to array
1448 TIter next(loaders);
1450 while((loader = (AliLoader*)next()))
1452 loader->UnloadAll();
1455 /**************************************************************************/
1457 void AliRunLoader::UnloadTracks(Option_t* detectors)
1459 //unloads Tracks for detectors specified in parameter
1463 const char* oAll = strstr(detectors,"all");
1470 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1471 loaders = &arr;//get the pointer to array
1474 TIter next(loaders);
1476 while((loader = (AliLoader*)next()))
1478 loader->UnloadTracks();
1481 /**************************************************************************/
1483 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1485 //unloads Particles for detectors specified in parameter
1489 const char* oAll = strstr(detectors,"all");
1496 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1497 loaders = &arr;//get the pointer to array
1500 TIter next(loaders);
1502 while((loader = (AliLoader*)next()))
1504 loader->UnloadRecParticles();
1507 /**************************************************************************/
1509 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1511 //returns RunLoader from folder named eventfoldername
1512 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1517 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1521 /**************************************************************************/
1523 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1525 //get the loader of the detector with the given name from the global
1527 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1529 AliErrorClass("No run loader found");
1532 return runLoader->GetDetectorLoader(detname);
1534 /**************************************************************************/
1536 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1538 //get the loader of the detector with the given name from the global
1541 char loadername[256];
1542 sprintf(loadername, "%sLoader", detname);
1543 AliLoader* loader = GetLoader(loadername);
1545 AliError(Form("No loader for %s found", detname));
1550 /**************************************************************************/
1552 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1554 //get the tree with hits of the detector with the given name
1555 //if maketree is true and the tree does not exist, the tree is created
1556 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1557 if (!loader) return NULL;
1558 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1559 return loader->TreeH();
1562 /**************************************************************************/
1564 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1566 //get the tree with hits of the detector with the given name
1567 //if maketree is true and the tree does not exist, the tree is created
1568 AliLoader* loader = GetDetectorLoader(detname);
1569 if (!loader) return NULL;
1570 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1571 return loader->TreeH();
1573 /**************************************************************************/
1575 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1577 //get the tree with summable digits of the detector with the given name
1578 //if maketree is true and the tree does not exist, the tree is created
1579 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1580 if (!loader) return NULL;
1581 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1582 return loader->TreeS();
1584 /**************************************************************************/
1586 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1588 //get the tree with summable digits of the detector with the given name
1589 //if maketree is true and the tree does not exist, the tree is created
1590 AliLoader* loader = GetDetectorLoader(detname);
1591 if (!loader) return NULL;
1592 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1593 return loader->TreeS();
1595 /**************************************************************************/
1597 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1599 //get the tree with digits 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->TreeD() && maketree) loader->MakeTree("D");
1604 return loader->TreeD();
1606 /**************************************************************************/
1608 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1610 //get the tree with digits 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->TreeD() && maketree) loader->MakeTree("D");
1615 return loader->TreeD();
1617 /**************************************************************************/
1618 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1620 //get the tree with clusters of the detector with the given name
1621 //if maketree is true and the tree does not exist, the tree is created
1622 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1623 if (!loader) return NULL;
1624 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1625 return loader->TreeR();
1627 /**************************************************************************/
1629 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1631 //get the tree with clusters of the detector with the given name
1632 //if maketree is true and the tree does not exist, the tree is created
1633 AliLoader* loader = GetDetectorLoader(detname);
1634 if (!loader) return NULL;
1635 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1636 return loader->TreeR();
1638 /**************************************************************************/
1640 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1642 //get the tree with tracks of the detector with the given name
1643 //if maketree is true and the tree does not exist, the tree is created
1644 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1645 if (!loader) return NULL;
1646 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1647 return loader->TreeT();
1649 /**************************************************************************/
1651 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1653 //get the tree with tracks of the detector with the given name
1654 //if maketree is true and the tree does not exist, the tree is created
1655 AliLoader* loader = GetDetectorLoader(detname);
1656 if (!loader) return NULL;
1657 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1658 return loader->TreeT();
1660 /**************************************************************************/
1662 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1664 //get the tree with particles of the detector with the given name
1665 //if maketree is true and the tree does not exist, the tree is created
1666 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1667 if (!loader) return NULL;
1668 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1669 return loader->TreeP();
1671 /**************************************************************************/
1673 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1675 //get the tree with particles of the detector with the given name
1676 //if maketree is true and the tree does not exist, the tree is created
1677 AliLoader* loader = GetDetectorLoader(detname);
1678 if (!loader) return NULL;
1679 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1680 return loader->TreeP();
1683 /**************************************************************************/
1685 void AliRunLoader::CdGAFile()
1687 //sets gDirectory to galice file
1689 if(fGAFile) fGAFile->cd();
1692 /**************************************************************************/
1694 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1696 //this method looks for all Loaders corresponding
1697 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1701 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1702 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1707 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1708 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1710 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1711 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1712 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1713 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1714 //construct the Loader name
1715 TString getname(buff);
1717 AliLoader* loader = GetLoader(getname);//get the Loader
1720 pointerarray.Add(loader);
1724 AliError(Form("Can not find Loader for %s",buff));
1730 /*****************************************************************************/
1732 void AliRunLoader::Clean(const TString& name)
1734 //removes object with given name from event folder and deletes it
1735 if (GetEventFolder() == 0x0) return;
1736 TObject* obj = GetEventFolder()->FindObject(name);
1739 AliDebug(1, Form("name=%s, cleaning %s.",GetName(),name.Data()));
1740 GetEventFolder()->Remove(obj);
1745 /*****************************************************************************/
1747 TTask* AliRunLoader::GetRunDigitizer()
1749 //returns Run Digitizer from folder
1751 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1752 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1753 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1755 /*****************************************************************************/
1757 TTask* AliRunLoader::GetRunSDigitizer()
1759 //returns SDigitizer Task from folder
1761 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1762 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1763 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1765 /*****************************************************************************/
1767 TTask* AliRunLoader::GetRunReconstructioner()
1769 //returns Reconstructioner Task from folder
1770 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1771 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1772 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1774 /*****************************************************************************/
1776 TTask* AliRunLoader::GetRunTracker()
1778 //returns Tracker Task from folder
1779 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1780 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1781 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1783 /*****************************************************************************/
1785 TTask* AliRunLoader::GetRunPIDTask()
1787 //returns Tracker Task from folder
1788 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1789 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1790 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1792 /*****************************************************************************/
1794 TTask* AliRunLoader::GetRunQATask()
1796 //returns Quality Assurance Task from folder
1797 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1800 AliErrorClass("Can not get task folder from AliConfig");
1803 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1804 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1807 /*****************************************************************************/
1809 void AliRunLoader::SetCompressionLevel(Int_t cl)
1811 //Sets Compression Level in all files
1812 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1813 SetKineComprLevel(cl);
1814 SetTrackRefsComprLevel(cl);
1815 TIter next(fLoaders);
1817 while((loader = (AliLoader*)next()))
1819 loader->SetCompressionLevel(cl);
1822 /**************************************************************************/
1824 void AliRunLoader::SetKineComprLevel(Int_t cl)
1826 //Sets comression level in Kine File
1827 fKineDataLoader->SetCompressionLevel(cl);
1829 /**************************************************************************/
1831 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1833 //Sets comression level in Track Refences File
1834 fTrackRefsDataLoader->SetCompressionLevel(cl);
1836 /**************************************************************************/
1838 void AliRunLoader::UnloadHeader()
1840 //removes TreeE from folder and deletes it
1841 // as well as fHeader object
1846 /**************************************************************************/
1848 void AliRunLoader::UnloadKinematics()
1850 //Unloads Kinematics
1851 fKineDataLoader->GetBaseLoader(0)->Unload();
1853 /**************************************************************************/
1855 void AliRunLoader::UnloadTrackRefs()
1857 //Unloads Track Refernces
1858 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
1860 /**************************************************************************/
1862 void AliRunLoader::UnloadgAlice()
1865 if (gAlice == GetAliRun())
1867 AliDebug(1, "Set gAlice = 0x0");
1868 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
1870 AliRun* alirun = GetAliRun();
1871 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
1874 /**************************************************************************/
1876 void AliRunLoader::MakeTrackRefsContainer()
1878 // Makes a tree for Track References
1879 fTrackRefsDataLoader->MakeTree();
1881 /**************************************************************************/
1883 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
1885 //Load track references from file (opens file and posts tree to folder)
1887 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
1889 /**************************************************************************/
1891 void AliRunLoader::SetDirName(TString& dirname)
1893 //sets directory name
1894 if (dirname.IsNull()) return;
1895 fUnixDirName = dirname;
1896 fKineDataLoader->SetDirName(dirname);
1897 fTrackRefsDataLoader->SetDirName(dirname);
1899 TIter next(fLoaders);
1901 while((loader = (AliLoader*)next()))
1903 loader->SetDirName(dirname);
1907 /*****************************************************************************/
1909 Int_t AliRunLoader::GetFileOffset() const
1911 //returns the file number that is added to the file name for current event
1912 return Int_t(fCurrentEvent/fNEventsPerFile);
1915 /*****************************************************************************/
1916 const TString AliRunLoader::SetFileOffset(const TString& fname)
1918 //adds the the number to the file name at proper place for current event
1919 Long_t offset = (Long_t)GetFileOffset();
1920 if (offset < 1) return fname;
1922 soffset += offset;//automatic conversion to string
1923 TString dotroot(".root");
1924 const TString& offfsetdotroot = offset + dotroot;
1925 TString out = fname;
1926 out = out.ReplaceAll(dotroot,offfsetdotroot);
1927 AliDebug(1, Form(" in=%s out=%s",fname.Data(),out.Data()));
1930 /*****************************************************************************/
1932 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
1934 //adds the suffix before ".root",
1935 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
1936 //made on Jiri Chudoba demand
1938 TIter next(fLoaders);
1940 while((loader = (AliLoader*)next()))
1942 loader->SetDigitsFileNameSuffix(suffix);
1945 /*****************************************************************************/
1947 TString AliRunLoader::GetFileName() const
1949 //returns name of galice file
1951 if (fGAFile == 0x0) return result;
1952 result = fGAFile->GetName();
1955 /*****************************************************************************/
1957 void AliRunLoader::SetDetectorAddresses()
1959 //calls SetTreeAddress for all detectors
1960 if (GetAliRun()==0x0) return;
1961 TIter next(GetAliRun()->Modules());
1963 while((mod = (AliModule*)next()))
1965 AliDetector* det = dynamic_cast<AliDetector*>(mod);
1966 if (det) det->SetTreeAddress();
1969 /*****************************************************************************/
1971 void AliRunLoader::Synchronize()
1973 //synchrinizes all writtable files
1974 TIter next(fLoaders);
1976 while((loader = (AliLoader*)next()))
1978 loader->Synchronize();
1981 fKineDataLoader->Synchronize();
1982 fTrackRefsDataLoader->Synchronize();
1984 if (fGAFile) fGAFile->Flush();
1986 /*****************************************************************************/
1987 /*****************************************************************************/