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 "AliCDBManager.h"
66 #include "AliCDBLocal.h"
67 #include "AliCentralTrigger.h"
69 ClassImp(AliRunLoader)
71 AliRunLoader* AliRunLoader::fgRunLoader = 0x0;
73 const TString AliRunLoader::fgkRunLoaderName("RunLoader");
74 const TString AliRunLoader::fgkHeaderBranchName("Header");
75 const TString AliRunLoader::fgkTriggerBranchName("ClassMask");
76 const TString AliRunLoader::fgkHeaderContainerName("TE");
77 const TString AliRunLoader::fgkTriggerContainerName("TreeCT");
78 const TString AliRunLoader::fgkKineContainerName("TreeK");
79 const TString AliRunLoader::fgkTrackRefsContainerName("TreeTR");
80 const TString AliRunLoader::fgkKineBranchName("Particles");
81 const TString AliRunLoader::fgkDefaultKineFileName("Kinematics.root");
82 const TString AliRunLoader::fgkDefaultTrackRefsFileName("TrackRefs.root");
83 const TString AliRunLoader::fgkGAliceName("gAlice");
84 const TString AliRunLoader::fgkDefaultTriggerFileName("Trigger.root");
85 /**************************************************************************/
87 AliRunLoader::AliRunLoader():
96 fTrackRefsDataLoader(0x0),
100 AliConfig::Instance();//force to build the folder structure
101 if (!fgRunLoader) fgRunLoader = this;
103 /**************************************************************************/
105 AliRunLoader::AliRunLoader(const char* eventfoldername):
106 TNamed(fgkRunLoaderName,fgkRunLoaderName),
107 fLoaders(new TObjArray()),
114 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
115 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
120 SetEventFolderName(eventfoldername);
121 if (!fgRunLoader) fgRunLoader = this;
123 /**************************************************************************/
125 AliRunLoader::AliRunLoader(const AliRunLoader &rl):
134 fKineDataLoader(0x0),
135 fTrackRefsDataLoader(0x0),
144 /**************************************************************************/
146 AliRunLoader::~AliRunLoader()
149 if (fgRunLoader == this) fgRunLoader = 0x0;
155 fLoaders->SetOwner();
159 delete fKineDataLoader;
160 delete fTrackRefsDataLoader;
165 //fEventFolder is deleted by the way of removing - TopAliceFolder owns it
166 if( fCTrigger ) delete fCTrigger;
171 /**************************************************************************/
173 AliRunLoader::AliRunLoader(TFolder* topfolder):
174 TNamed(fgkRunLoaderName,fgkRunLoaderName),
175 fLoaders(new TObjArray()),
176 fEventFolder(topfolder),
182 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
183 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
190 TString errmsg("Parameter is NULL");
191 AliError(errmsg.Data());
196 TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
198 { //if it is, then sth. is going wrong... exits aliroot session
199 TString errmsg("In Event Folder Named ");
200 errmsg+=fEventFolder->GetName();
201 errmsg+=" object named "+fgkRunLoaderName+" already exists. I am confused ...";
203 AliError(errmsg.Data());
205 return;//never reached
208 if (!fgRunLoader) fgRunLoader = this;
210 fEventFolder->Add(this);//put myself to the folder to accessible for all
213 /**************************************************************************/
215 void AliRunLoader::Copy(TObject &) const
217 AliFatal("Not implemented");
219 /**************************************************************************/
221 Int_t AliRunLoader::GetEvent(Int_t evno)
223 //Gets event number evno
224 //Reloads all data properly
225 //PH if (fCurrentEvent == evno) return 0;
229 AliError("Can not give the event with negative number");
233 if (evno >= GetNumberOfEvents())
235 AliError(Form("There is no event with number %d",evno));
239 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
240 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
241 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
242 AliDebug(1, Form(" GETTING EVENT %d",evno));
243 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
244 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
245 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
247 fCurrentEvent = evno;
251 //Reload header (If header was loaded)
254 retval = TreeE()->GetEvent(fCurrentEvent);
257 AliError(Form("Cannot find event: %d\n ",fCurrentEvent));
261 //Reload stack (If header was loaded)
262 if (TreeE()) fStack = GetHeader()->Stack();
263 //Set event folder in stack (it does not mean that we read kinematics from file)
266 fStack->SetEventFolderName(fEventFolder->GetName());
270 AliWarning("Stack not found in header");
273 if( GetTrigger() && TreeCT() ) {
274 retval = TreeCT()->GetEvent(fCurrentEvent);
276 AliError(Form("Error occured while GetEvent for Trigger. Event %d",evno));
284 AliError(Form("Error occured while setting event %d",evno));
288 //Post Track References
289 retval = fTrackRefsDataLoader->GetEvent();
292 AliError(Form("Error occured while GetEvent for Track References. Event %d",evno));
296 //Read Kinematics if loaded
297 fKineDataLoader->GetEvent();
300 AliError(Form("Error occured while GetEvent for Kinematics. Event %d",evno));
304 if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded())
306 if (fStack->GetEvent() == kFALSE)
308 AliError(Form("Error occured while GetEvent for Stack. Event %d",evno));
313 //Trigger data reloading in all loaders
314 TIter next(fLoaders);
316 while((loader = (AliLoader*)next()))
318 retval = loader->GetEvent();
321 AliError(Form("Error occured while getting event for %s. Event %d.",
322 loader->GetDetectorName().Data(), evno));
327 SetDetectorAddresses();
331 /**************************************************************************/
332 Int_t AliRunLoader::SetEvent()
334 //if kinematics was loaded Cleans folder data
338 retval = fKineDataLoader->SetEvent();
341 AliError("SetEvent for Kinamtics Data Loader retutned error.");
344 retval = fTrackRefsDataLoader->SetEvent();
347 AliError("SetEvent for Track References Data Loader retutned error.");
351 TIter next(fLoaders);
353 while((loader = (AliLoader*)next()))
355 retval = loader->SetEvent();
358 AliError(Form("SetEvent for %s Data Loader retutned error.",loader->GetName()));
365 /**************************************************************************/
367 Int_t AliRunLoader::SetEventNumber(Int_t evno)
369 //cleans folders and sets the root dirs in files
370 if (fCurrentEvent == evno) return 0;
371 fCurrentEvent = evno;
375 /**************************************************************************/
376 AliCDBEntry* AliRunLoader::GetCDBEntry(const char* name) const
378 //Get an AliCDBEntry from the run data storage
380 if ( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) {
381 AliError("No run data storage defined!");
384 return AliCDBManager::Instance()->GetDefaultStorage()->Get(name, GetHeader()->GetRun());
388 /**************************************************************************/
389 AliRunLoader* AliRunLoader::Open
390 (const char* filename, const char* eventfoldername, Option_t* option)
392 //Opens a desired file 'filename'
393 //gets the the run-Loader and mounts it desired folder
394 //returns the pointer to run Loader which can be further used for accessing data
395 //in case of error returns NULL
397 static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
398 AliDebugClass(1,Form("\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data()));
400 AliRunLoader* result = 0x0;
402 /* ************************************************ */
403 /* Chceck if folder with given name already exists */
404 /* ************************************************ */
406 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
409 TFolder* fold = dynamic_cast<TFolder*>(obj);
412 AliErrorClass("Such a obejct already exists in top alice folder and it is not a folder.");
416 //check if we can get RL from that folder
417 result = AliRunLoader::GetRunLoader(eventfoldername);
420 AliErrorClass(Form("Folder %s already exists, and can not find session there. Can not mount.",eventfoldername));
424 if (result->GetFileName().CompareTo(filename) != 0)
426 AliErrorClass("Other file is mounted in demanded folder. Can not mount.");
430 //check if now is demanded (re)creation
431 if ( AliLoader::TestFileOption(option) == kFALSE)
433 AliErrorClass(Form("Session already exists in folder %s and this session option is %s. Unable to proceed.",
434 eventfoldername,option));
438 //check if demanded option is update and existing one
439 TString tmpstr(option);
440 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
441 (result->fGAFile->IsWritable() == kFALSE) )
443 AliErrorClass(Form("Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
444 eventfoldername,option));
448 AliWarningClass("Session is already opened and mounted in demanded folder");
449 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
451 } //end of checking in case of existance of object named identically that folder session is being opened
454 TFile * gAliceFile = TFile::Open(filename,option);//open a file
456 {//null pointer returned
457 AliFatalClass(Form("Can not open file %s.",filename));
461 if (gAliceFile->IsOpen() == kFALSE)
462 {//pointer to valid object returned but file is not opened
463 AliErrorClass(Form("Can not open file %s.",filename));
467 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
468 //else create new AliRunLoader
469 if ( AliLoader::TestFileOption(option) )
471 AliDebugClass(1, "Reading RL from file");
473 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
476 AliErrorClass(Form("Can not find run-Loader in file %s.",filename));
477 delete gAliceFile;//close the file
480 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
481 if (tmp)//if SetEvent returned error
483 AliErrorClass(Form("Can not mount event in folder %s.",eventfoldername));
484 delete result; //delete run-Loader
485 delete gAliceFile;//close the file
491 AliDebugClass(1, Form("Creating new AliRunLoader. Folder name is %s",eventfoldername));
494 result = new AliRunLoader(eventfoldername);
496 catch (TString& errmsg)
498 AliErrorClass(Form("AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data()));
500 delete gAliceFile;//close the file
505 //procedure for extracting dir name from the file name
506 TString fname(filename);
507 Int_t nsl = fname.Last('#');//look for hash in file name
509 if (nsl < 0) {//hash not found
510 nsl = fname.Last('/');// look for slash
512 nsl = fname.Last(':');// look for colon e.g. rfio:galice.root
515 if (nsl < 0) dirname = "./"; // no directory path, use "."
516 else dirname = fname.Remove(nsl+1);// directory path
518 AliDebugClass(1, Form("Dir name is : %s",dirname.Data()));
520 result->SetDirName(dirname);
521 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
522 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
525 /**************************************************************************/
526 Int_t AliRunLoader::GetNumberOfEvents()
528 //returns number of events in Run
532 retval = LoadHeader();
535 AliError("Error occured while loading header");
539 return (Int_t)TreeE()->GetEntries();
541 /**************************************************************************/
543 void AliRunLoader::MakeHeader()
545 //Makes header and connects it to header tree (if it exists)
549 AliDebug(1, "Creating new Header Object");
550 fHeader= new AliHeader();
552 TTree* tree = TreeE();
555 AliDebug(1, "Got Tree from folder.");
556 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
559 AliDebug(1, "Creating new branch");
560 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
561 branch->SetAutoDelete(kFALSE);
565 AliDebug(1, "Got Branch from Tree");
566 branch->SetAddress(&fHeader);
567 tree->GetEvent(fCurrentEvent);
568 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
571 fStack->SetEventFolderName(fEventFolder->GetName());
572 if (TreeK()) fStack->GetEvent();
576 AliDebug(1, "Header does not have a stack.");
580 AliDebug(1, "Exiting MakeHeader method");
582 /**************************************************************************/
584 void AliRunLoader::MakeStack()
586 //Creates the stack object - do not connect the tree
589 fStack = new AliStack(10000);
590 fStack->SetEventFolderName(fEventFolder->GetName());
593 /**************************************************************************/
595 void AliRunLoader::MakeTrigger()
597 // Makes trigger object and connects it to trigger tree (if it exists)
599 if( fCTrigger == 0x0 ) {
600 AliDebug( 1, "Creating new Trigger Object" );
601 fCTrigger = new AliCentralTrigger();
603 TTree* tree = TreeCT();
605 fCTrigger->MakeBranch( fgkTriggerBranchName, tree );
606 tree->GetEvent( fCurrentEvent );
609 AliDebug( 1, "Exiting MakeTrigger method" );
611 /**************************************************************************/
613 void AliRunLoader::MakeTree(Option_t *option)
616 const char *oK = strstr(option,"K"); //Kine
617 const char *oE = strstr(option,"E"); //Header
618 const char *oGG = strstr(option,"GG"); //Central TriGGer
622 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
624 AliError("Load Kinematics first");
628 fKineDataLoader->MakeTree();
630 fStack->ConnectTree();
631 WriteKinematics("OVERWRITE");
638 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
639 GetEventFolder()->Add(tree);
641 WriteHeader("OVERWRITE");
646 // create the CTP Trigger output file and tree
647 TFile* file = gROOT->GetFile( fgkDefaultTriggerFileName );
649 file = TFile::Open( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ), "RECREATE" ) ;
653 TTree* tree = new TTree( fgkTriggerContainerName, "Tree with Central Trigger Mask" );
654 GetEventFolder()->Add(tree);
656 // WriteHeader("OVERWRITE");
659 TIter next(fLoaders);
661 while((loader = (AliLoader*)next()))
663 loader->MakeTree(option);
667 /**************************************************************************/
669 Int_t AliRunLoader::LoadgAlice()
671 //Loads gAlice from file
674 AliWarning("AliRun is already in folder. Unload first.");
677 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
680 AliError(Form("Can not find gAlice in file %s",fGAFile->GetName()));
683 alirun->SetRunLoader(this);
686 AliWarning(Form("gAlice already exists. Putting retrived object in folder named %s",
687 GetEventFolder()->GetName()));
693 SetDetectorAddresses();//calls SetTreeAddress for all detectors
696 /**************************************************************************/
698 Int_t AliRunLoader::LoadHeader()
700 //loads treeE and reads header object for current event
703 AliWarning("Header is already loaded. Use ReloadHeader to force reload. Nothing done");
707 if (GetEventFolder() == 0x0)
709 AliError("Event folder not specified yet");
715 AliError("Session not opened. Use AliRunLoader::Open");
719 if (fGAFile->IsOpen() == kFALSE)
721 AliError("Session not opened. Use AliRunLoader::Open");
725 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
728 AliError(Form("Can not find header tree named %s in file %s",
729 fgkHeaderContainerName.Data(),fGAFile->GetName()));
733 if (tree == TreeE()) return 0;
736 GetEventFolder()->Add(tree);
737 MakeHeader();//creates header object and connects to tree
741 /**************************************************************************/
743 Int_t AliRunLoader::LoadTrigger(Option_t* option)
748 AliWarning("Trigger is already loaded. Nothing done");
752 if( GetEventFolder() == 0x0 ) {
753 AliError("Event folder not specified yet");
756 // get the CTP Trigger output file and tree
757 TString trgfile = gSystem->ConcatFileName( fUnixDirName.Data(),
758 fgkDefaultTriggerFileName.Data() );
759 TFile* file = gROOT->GetFile( trgfile );
761 file = TFile::Open( trgfile, option ) ;
762 if (!file || file->IsOpen() == kFALSE ) {
763 AliError( Form( "Can not open trigger file %s", trgfile.Data() ) );
769 TTree* tree = dynamic_cast<TTree*>(file->Get( fgkTriggerContainerName ));
771 AliError( Form( "Can not find trigger tree named %s in file %s",
772 fgkTriggerContainerName.Data(), file->GetName() ) );
778 fCTrigger = dynamic_cast<AliCentralTrigger*>(file->Get( "AliCentralTrigger" ));
779 GetEventFolder()->Add( tree );
785 /**************************************************************************/
787 Int_t AliRunLoader::LoadKinematics(Option_t* option)
789 //Loads the kinematics
790 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
793 AliError("Error occured while loading kinamatics tree.");
798 retval = fStack->GetEvent();
799 if ( retval == kFALSE)
801 AliError("Error occured while loading kinamatics tree.");
808 /**************************************************************************/
810 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
812 //Opens File with kinematics
815 if (file->IsOpen() == kFALSE)
816 {//pointer is not null but file is not opened
817 AliWarning("Pointer to file is not null, but file is not opened");//risky any way
819 file = 0x0; //proceed with opening procedure
823 AliWarning(Form("File %s already opened",filename.Data()));
827 //try to find if that file is opened somewere else
828 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
831 if(file->IsOpen() == kTRUE)
833 AliWarning(Form("File %s already opened by sombody else.",file->GetName()));
838 file = TFile::Open(filename,opt);
841 AliError(Form("Can not open file %s",filename.Data()));
844 if (file->IsOpen() == kFALSE)
845 {//file is not opened
846 AliError(Form("Can not open file %s",filename.Data()));
850 file->SetCompressionLevel(cl);
852 dir = AliLoader::ChangeDir(file,fCurrentEvent);
855 AliError(Form("Can not change to root directory in file %s",filename.Data()));
860 /**************************************************************************/
862 TTree* AliRunLoader::TreeE() const
864 //returns the tree from folder; shortcut method
865 if (AliDebugLevel() > 10) fEventFolder->ls();
866 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
867 return (obj)?dynamic_cast<TTree*>(obj):0x0;
869 /**************************************************************************/
871 TTree* AliRunLoader::TreeCT() const
873 //returns the tree from folder; shortcut method
874 if (AliDebugLevel() > 10) fEventFolder->ls();
875 TObject *obj = fEventFolder->FindObject(fgkTriggerContainerName);
876 return (obj)?dynamic_cast<TTree*>(obj):0x0;
878 /**************************************************************************/
880 AliHeader* AliRunLoader::GetHeader() const
882 //returns pointer header object
885 /**************************************************************************/
887 AliCentralTrigger* AliRunLoader::GetTrigger() const
889 //returns pointer trigger object
893 /**************************************************************************/
895 TTree* AliRunLoader::TreeK() const
897 //returns the tree from folder; shortcut method
898 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
899 return (obj)?dynamic_cast<TTree*>(obj):0x0;
901 /**************************************************************************/
903 TTree* AliRunLoader::TreeTR() const
905 //returns the tree from folder; shortcut method
906 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
907 return (obj)?dynamic_cast<TTree*>(obj):0x0;
909 /**************************************************************************/
911 AliRun* AliRunLoader::GetAliRun() const
913 //returns AliRun which sits in the folder
914 if (fEventFolder == 0x0) return 0x0;
915 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
916 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
918 /**************************************************************************/
920 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
922 //writes geometry to the file
924 TGeometry* geo = GetAliRun()->GetGeometry();
927 AliError("Can not get geometry from gAlice");
933 /**************************************************************************/
935 Int_t AliRunLoader::WriteHeader(Option_t* opt)
938 AliDebug(1, "WRITING HEADER");
940 TTree* tree = TreeE();
943 AliWarning("Can not find Header Tree in Folder");
946 if (fGAFile->IsWritable() == kFALSE)
948 AliError(Form("File %s is not writable",fGAFile->GetName()));
952 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
954 { //if they exist, see if option OVERWRITE is used
956 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
957 {//if it is not used - give an error message and return an error code
958 AliError("Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
963 tree->SetDirectory(fGAFile);
964 tree->Write(0,TObject::kOverwrite);
966 AliDebug(1, "WRITTEN\n\n");
971 /**************************************************************************/
973 Int_t AliRunLoader::WriteTrigger(Option_t* opt)
976 AliDebug( 1, "WRITING TRIGGER" );
978 TTree* tree = TreeCT();
980 AliWarning("Can not find Trigger Tree in Folder");
984 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
985 if( !file || !file->IsOpen() ) {
986 AliError( "can't write Trigger, file is not open" );
990 TObject* obj = file->Get( fgkTriggerContainerName );
991 if( obj ) { //if they exist, see if option OVERWRITE is used
993 if( tmp.Contains( "OVERWRITE", TString::kIgnoreCase ) == 0) {
994 //if it is not used - give an error message and return an error code
995 AliError( "Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data" );
1000 fCTrigger->Write( 0, TObject::kOverwrite );
1001 tree->Write( 0, TObject::kOverwrite );
1004 AliDebug(1, "WRITTEN\n\n");
1008 /**************************************************************************/
1010 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
1012 //writes AliRun object to the file
1014 if (GetAliRun()) GetAliRun()->Write();
1017 /**************************************************************************/
1019 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
1022 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
1024 /**************************************************************************/
1025 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
1027 //writes Track References tree
1028 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
1030 /**************************************************************************/
1032 Int_t AliRunLoader::WriteHits(Option_t* opt)
1034 //Calls WriteHits for all loaders
1037 TIter next(fLoaders);
1039 while((loader = (AliLoader*)next()))
1041 res = loader->WriteHits(opt);
1044 AliError(Form("Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res));
1050 /**************************************************************************/
1052 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
1054 //Calls WriteSDigits for all loaders
1057 TIter next(fLoaders);
1059 while((loader = (AliLoader*)next()))
1061 res = loader->WriteSDigits(opt);
1064 AliError(Form("Failed to write summable digits for %s.",loader->GetDetectorName().Data()));
1070 /**************************************************************************/
1072 Int_t AliRunLoader::WriteDigits(Option_t* opt)
1074 //Calls WriteDigits for all loaders
1077 TIter next(fLoaders);
1079 while((loader = (AliLoader*)next()))
1081 res = loader->WriteDigits(opt);
1084 AliError(Form("Failed to write digits for %s.",loader->GetDetectorName().Data()));
1090 /**************************************************************************/
1092 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
1094 //Calls WriteRecPoints for all loaders
1097 TIter next(fLoaders);
1099 while((loader = (AliLoader*)next()))
1101 res = loader->WriteRecPoints(opt);
1104 AliError(Form("Failed to write Reconstructed Points for %s.",
1105 loader->GetDetectorName().Data()));
1111 /**************************************************************************/
1113 Int_t AliRunLoader::WriteTracks(Option_t* opt)
1115 //Calls WriteTracks for all loaders
1118 TIter next(fLoaders);
1120 while((loader = (AliLoader*)next()))
1122 res = loader->WriteTracks(opt);
1125 AliError(Form("Failed to write Tracks for %s.",
1126 loader->GetDetectorName().Data()));
1132 /**************************************************************************/
1134 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
1136 //Writes itself to the file
1138 this->Write(0,TObject::kOverwrite);
1141 /**************************************************************************/
1143 Int_t AliRunLoader::SetEventFolderName(const TString& name)
1145 //sets top folder name for this run; of alread
1148 AliError("Name is empty");
1152 //check if such a folder already exists - try to find it in alice top folder
1153 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
1156 TFolder* fold = dynamic_cast<TFolder*>(obj);
1159 AliError("Such a obejct already exists in top alice folder and it is not a folder.");
1162 //folder which was found is our folder
1163 if (fEventFolder == fold)
1169 AliError("Such a folder already exists in top alice folder. Can not mount.");
1174 //event is alredy connected, just change name of the folder
1177 fEventFolder->SetName(name);
1181 if (fKineDataLoader == 0x0)
1182 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1184 if ( fTrackRefsDataLoader == 0x0)
1185 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1187 //build the event folder structure
1188 AliDebug(1, Form("Creating new event folder named %s",name.Data()));
1189 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1190 fEventFolder->Add(this);//put myself to the folder to accessible for all
1192 if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName());
1193 TIter next(fLoaders);
1195 while((loader = (AliLoader*)next()))
1197 loader->Register(fEventFolder);//build folder structure for this detector
1200 fKineDataLoader->SetEventFolder(GetEventFolder());
1201 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1202 fKineDataLoader->SetFolder(GetEventFolder());
1203 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1205 fEventFolder->SetOwner();
1208 /**************************************************************************/
1210 void AliRunLoader::AddLoader(AliLoader* loader)
1212 //Adds the Loader for given detector
1213 if (loader == 0x0) //if null shout and exit
1215 AliError("Parameter is NULL");
1218 loader->SetDirName(fUnixDirName);
1219 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1220 //pass information to the Loader
1221 fLoaders->Add(loader);//add the Loader to the array
1223 /**************************************************************************/
1225 void AliRunLoader::AddLoader(AliDetector* det)
1227 //Asks module (detector) ro make a Loader and stores in the array
1228 if (det == 0x0) return;
1229 AliLoader* get = det->GetLoader();//try to get loader
1230 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1234 AliDebug(1, Form("Detector: %s Loader : %s",det->GetName(),get->GetName()));
1239 /**************************************************************************/
1241 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1243 //returns loader for given detector
1244 //note that naming convention is TPCLoader not just TPC
1245 return (AliLoader*)fLoaders->FindObject(detname);
1248 /**************************************************************************/
1250 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1252 //get loader for detector det
1253 if(det == 0x0) return 0x0;
1254 TString getname(det->GetName());
1256 AliDebug(1, Form(" Loader name is %s",getname.Data()));
1257 return GetLoader(getname);
1260 /**************************************************************************/
1262 void AliRunLoader::CleanFolders()
1264 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1271 /**************************************************************************/
1273 void AliRunLoader::CleanDetectors()
1275 //Calls CleanFolders for all detectors
1276 TIter next(fLoaders);
1278 while((loader = (AliLoader*)next()))
1280 loader->CleanFolders();
1283 /**************************************************************************/
1285 void AliRunLoader::RemoveEventFolder()
1287 //remove all the tree of event
1288 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1290 if (fEventFolder == 0x0) return;
1291 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1292 fEventFolder->Remove(this);//remove us drom folder
1294 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1295 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1296 delete fEventFolder;
1298 /**************************************************************************/
1300 void AliRunLoader::SetGAliceFile(TFile* gafile)
1302 //sets pointer to galice.root file
1306 /**************************************************************************/
1308 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1310 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1312 AliDebug(1, "Loading Hits");
1316 const char* oAll = strstr(detectors,"all");
1319 AliDebug(1, "Option is All");
1324 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1325 loaders = &arr;//get the pointer array
1328 AliDebug(1, Form("For detectors. Number of detectors chosen for loading %d",loaders->GetEntries()));
1330 TIter next(loaders);
1332 while((loader = (AliLoader*)next()))
1334 AliDebug(1, Form(" Calling LoadHits(%s) for %s",opt,loader->GetName()));
1335 loader->LoadHits(opt);
1337 AliDebug(1, "Done");
1341 /**************************************************************************/
1343 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1345 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1350 const char* oAll = strstr(detectors,"all");
1357 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1358 loaders = &arr;//get the pointer to array
1361 TIter next(loaders);
1363 while((loader = (AliLoader*)next()))
1365 loader->LoadSDigits(opt);
1370 /**************************************************************************/
1372 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1374 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1379 const char* oAll = strstr(detectors,"all");
1386 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1387 loaders = &arr;//get the pointer array
1390 TIter next(loaders);
1392 while((loader = (AliLoader*)next()))
1394 loader->LoadDigits(opt);
1398 /**************************************************************************/
1400 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1402 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1407 const char* oAll = strstr(detectors,"all");
1414 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1415 loaders = &arr;//get the pointer array
1418 TIter next(loaders);
1420 while((loader = (AliLoader*)next()))
1422 loader->LoadRecPoints(opt);
1426 /**************************************************************************/
1428 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1430 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1435 const char* oAll = strstr(detectors,"all");
1442 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1443 loaders = &arr;//get the pointer array
1446 TIter next(loaders);
1448 while((loader = (AliLoader*)next()))
1450 loader->LoadRecParticles(opt);
1454 /**************************************************************************/
1456 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1458 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
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 array
1474 TIter next(loaders);
1476 while((loader = (AliLoader*)next()))
1478 loader->LoadTracks(opt);
1482 /**************************************************************************/
1484 void AliRunLoader::UnloadHits(Option_t* detectors)
1486 //unloads hits for detectors specified in parameter
1490 const char* oAll = strstr(detectors,"all");
1497 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1498 loaders = &arr;//get the pointer to array
1501 TIter next(loaders);
1503 while((loader = (AliLoader*)next()))
1505 loader->UnloadHits();
1508 /**************************************************************************/
1510 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1512 //unloads SDigits for detectors specified in parameter
1516 const char* oAll = strstr(detectors,"all");
1523 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1524 loaders = &arr;//get the pointer to array
1527 TIter next(loaders);
1529 while((loader = (AliLoader*)next()))
1531 loader->UnloadSDigits();
1534 /**************************************************************************/
1536 void AliRunLoader::UnloadDigits(Option_t* detectors)
1538 //unloads Digits for detectors specified in parameter
1542 const char* oAll = strstr(detectors,"all");
1549 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1550 loaders = &arr;//get the pointer to array
1553 TIter next(loaders);
1555 while((loader = (AliLoader*)next()))
1557 loader->UnloadDigits();
1560 /**************************************************************************/
1562 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1564 //unloads RecPoints for detectors specified in parameter
1568 const char* oAll = strstr(detectors,"all");
1575 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1576 loaders = &arr;//get the pointer to array
1579 TIter next(loaders);
1581 while((loader = (AliLoader*)next()))
1583 loader->UnloadRecPoints();
1586 /**************************************************************************/
1588 void AliRunLoader::UnloadAll(Option_t* detectors)
1590 //calls UnloadAll for detectors names specified in parameter
1591 // option "all" passed can be passed
1595 const char* oAll = strstr(detectors,"all");
1602 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1603 loaders = &arr;//get the pointer to array
1606 TIter next(loaders);
1608 while((loader = (AliLoader*)next()))
1610 loader->UnloadAll();
1613 /**************************************************************************/
1615 void AliRunLoader::UnloadTracks(Option_t* detectors)
1617 //unloads Tracks for detectors specified in parameter
1621 const char* oAll = strstr(detectors,"all");
1628 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1629 loaders = &arr;//get the pointer to array
1632 TIter next(loaders);
1634 while((loader = (AliLoader*)next()))
1636 loader->UnloadTracks();
1639 /**************************************************************************/
1641 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1643 //unloads Particles for detectors specified in parameter
1647 const char* oAll = strstr(detectors,"all");
1654 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1655 loaders = &arr;//get the pointer to array
1658 TIter next(loaders);
1660 while((loader = (AliLoader*)next()))
1662 loader->UnloadRecParticles();
1665 /**************************************************************************/
1667 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1669 //returns RunLoader from folder named eventfoldername
1670 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1675 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1679 /**************************************************************************/
1681 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1683 //get the loader of the detector with the given name from the global
1685 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1687 AliErrorClass("No run loader found");
1690 return runLoader->GetDetectorLoader(detname);
1692 /**************************************************************************/
1694 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1696 //get the loader of the detector with the given name from the global
1699 char loadername[256];
1700 sprintf(loadername, "%sLoader", detname);
1701 AliLoader* loader = GetLoader(loadername);
1703 AliError(Form("No loader for %s found", detname));
1708 /**************************************************************************/
1710 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1712 //get the tree with hits of the detector with the given name
1713 //if maketree is true and the tree does not exist, the tree is created
1714 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1715 if (!loader) return NULL;
1716 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1717 return loader->TreeH();
1720 /**************************************************************************/
1722 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1724 //get the tree with hits of the detector with the given name
1725 //if maketree is true and the tree does not exist, the tree is created
1726 AliLoader* loader = GetDetectorLoader(detname);
1727 if (!loader) return NULL;
1728 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1729 return loader->TreeH();
1731 /**************************************************************************/
1733 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1735 //get the tree with summable digits of the detector with the given name
1736 //if maketree is true and the tree does not exist, the tree is created
1737 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1738 if (!loader) return NULL;
1739 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1740 return loader->TreeS();
1742 /**************************************************************************/
1744 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1746 //get the tree with summable digits of the detector with the given name
1747 //if maketree is true and the tree does not exist, the tree is created
1748 AliLoader* loader = GetDetectorLoader(detname);
1749 if (!loader) return NULL;
1750 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1751 return loader->TreeS();
1753 /**************************************************************************/
1755 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1757 //get the tree with digits of the detector with the given name
1758 //if maketree is true and the tree does not exist, the tree is created
1759 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1760 if (!loader) return NULL;
1761 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1762 return loader->TreeD();
1764 /**************************************************************************/
1766 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1768 //get the tree with digits of the detector with the given name
1769 //if maketree is true and the tree does not exist, the tree is created
1770 AliLoader* loader = GetDetectorLoader(detname);
1771 if (!loader) return NULL;
1772 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1773 return loader->TreeD();
1775 /**************************************************************************/
1776 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1778 //get the tree with clusters of the detector with the given name
1779 //if maketree is true and the tree does not exist, the tree is created
1780 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1781 if (!loader) return NULL;
1782 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1783 return loader->TreeR();
1785 /**************************************************************************/
1787 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1789 //get the tree with clusters of the detector with the given name
1790 //if maketree is true and the tree does not exist, the tree is created
1791 AliLoader* loader = GetDetectorLoader(detname);
1792 if (!loader) return NULL;
1793 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1794 return loader->TreeR();
1796 /**************************************************************************/
1798 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1800 //get the tree with tracks of the detector with the given name
1801 //if maketree is true and the tree does not exist, the tree is created
1802 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1803 if (!loader) return NULL;
1804 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1805 return loader->TreeT();
1807 /**************************************************************************/
1809 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1811 //get the tree with tracks of the detector with the given name
1812 //if maketree is true and the tree does not exist, the tree is created
1813 AliLoader* loader = GetDetectorLoader(detname);
1814 if (!loader) return NULL;
1815 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1816 return loader->TreeT();
1818 /**************************************************************************/
1820 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1822 //get the tree with particles of the detector with the given name
1823 //if maketree is true and the tree does not exist, the tree is created
1824 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1825 if (!loader) return NULL;
1826 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1827 return loader->TreeP();
1829 /**************************************************************************/
1831 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1833 //get the tree with particles of the detector with the given name
1834 //if maketree is true and the tree does not exist, the tree is created
1835 AliLoader* loader = GetDetectorLoader(detname);
1836 if (!loader) return NULL;
1837 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1838 return loader->TreeP();
1841 /**************************************************************************/
1843 void AliRunLoader::CdGAFile()
1845 //sets gDirectory to galice file
1847 if(fGAFile) fGAFile->cd();
1850 /**************************************************************************/
1852 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1854 //this method looks for all Loaders corresponding
1855 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1859 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1860 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1865 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1866 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1868 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1869 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1870 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1871 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1872 //construct the Loader name
1873 TString getname(buff);
1875 AliLoader* loader = GetLoader(getname);//get the Loader
1878 pointerarray.Add(loader);
1882 AliError(Form("Can not find Loader for %s",buff));
1888 /*****************************************************************************/
1890 void AliRunLoader::Clean(const TString& name)
1892 //removes object with given name from event folder and deletes it
1893 if (GetEventFolder() == 0x0) return;
1894 TObject* obj = GetEventFolder()->FindObject(name);
1897 AliDebug(1, Form("name=%s, cleaning %s.",GetName(),name.Data()));
1898 GetEventFolder()->Remove(obj);
1904 /*****************************************************************************/
1906 TTask* AliRunLoader::GetRunDigitizer()
1908 //returns Run Digitizer from folder
1910 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1911 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1912 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1914 /*****************************************************************************/
1916 TTask* AliRunLoader::GetRunSDigitizer()
1918 //returns SDigitizer Task from folder
1920 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1921 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1922 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1924 /*****************************************************************************/
1926 TTask* AliRunLoader::GetRunReconstructioner()
1928 //returns Reconstructioner Task from folder
1929 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1930 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1931 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1933 /*****************************************************************************/
1935 TTask* AliRunLoader::GetRunTracker()
1937 //returns Tracker Task from folder
1938 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1939 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1940 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1942 /*****************************************************************************/
1944 TTask* AliRunLoader::GetRunPIDTask()
1946 //returns Tracker Task from folder
1947 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1948 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1949 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1951 /*****************************************************************************/
1953 TTask* AliRunLoader::GetRunQATask()
1955 //returns Quality Assurance Task from folder
1956 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1959 AliErrorClass("Can not get task folder from AliConfig");
1962 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1963 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1966 /*****************************************************************************/
1968 void AliRunLoader::SetCompressionLevel(Int_t cl)
1970 //Sets Compression Level in all files
1971 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1972 SetKineComprLevel(cl);
1973 SetTrackRefsComprLevel(cl);
1974 TIter next(fLoaders);
1976 while((loader = (AliLoader*)next()))
1978 loader->SetCompressionLevel(cl);
1981 /**************************************************************************/
1983 void AliRunLoader::SetKineComprLevel(Int_t cl)
1985 //Sets comression level in Kine File
1986 fKineDataLoader->SetCompressionLevel(cl);
1988 /**************************************************************************/
1990 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1992 //Sets comression level in Track Refences File
1993 fTrackRefsDataLoader->SetCompressionLevel(cl);
1995 /**************************************************************************/
1997 void AliRunLoader::UnloadHeader()
1999 //removes TreeE from folder and deletes it
2000 // as well as fHeader object
2005 /**************************************************************************/
2007 void AliRunLoader::UnloadTrigger()
2009 //removes TreeCT from folder and deletes it
2010 // as well as fHeader object
2016 /**************************************************************************/
2018 void AliRunLoader::UnloadKinematics()
2020 //Unloads Kinematics
2021 fKineDataLoader->GetBaseLoader(0)->Unload();
2023 /**************************************************************************/
2025 void AliRunLoader::UnloadTrackRefs()
2027 //Unloads Track Refernces
2028 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
2030 /**************************************************************************/
2032 void AliRunLoader::UnloadgAlice()
2035 if (gAlice == GetAliRun())
2037 AliDebug(1, "Set gAlice = 0x0");
2038 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
2040 AliRun* alirun = GetAliRun();
2041 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
2044 /**************************************************************************/
2046 void AliRunLoader::MakeTrackRefsContainer()
2048 // Makes a tree for Track References
2049 fTrackRefsDataLoader->MakeTree();
2051 /**************************************************************************/
2053 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
2055 //Load track references from file (opens file and posts tree to folder)
2057 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
2059 /**************************************************************************/
2061 void AliRunLoader::SetDirName(TString& dirname)
2063 //sets directory name
2064 if (dirname.IsNull()) return;
2065 fUnixDirName = dirname;
2066 fKineDataLoader->SetDirName(dirname);
2067 fTrackRefsDataLoader->SetDirName(dirname);
2069 TIter next(fLoaders);
2071 while((loader = (AliLoader*)next()))
2073 loader->SetDirName(dirname);
2077 /*****************************************************************************/
2079 Int_t AliRunLoader::GetFileOffset() const
2081 //returns the file number that is added to the file name for current event
2082 return Int_t(fCurrentEvent/fNEventsPerFile);
2085 /*****************************************************************************/
2086 const TString AliRunLoader::SetFileOffset(const TString& fname)
2088 //adds the the number to the file name at proper place for current event
2089 Long_t offset = (Long_t)GetFileOffset();
2090 if (offset < 1) return fname;
2092 soffset += offset;//automatic conversion to string
2093 TString dotroot(".root");
2094 const TString& offfsetdotroot = offset + dotroot;
2095 TString out = fname;
2096 out = out.ReplaceAll(dotroot,offfsetdotroot);
2097 AliDebug(1, Form(" in=%s out=%s",fname.Data(),out.Data()));
2100 /*****************************************************************************/
2102 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
2104 //adds the suffix before ".root",
2105 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
2106 //made on Jiri Chudoba demand
2108 TIter next(fLoaders);
2110 while((loader = (AliLoader*)next()))
2112 loader->SetDigitsFileNameSuffix(suffix);
2115 /*****************************************************************************/
2117 TString AliRunLoader::GetFileName() const
2119 //returns name of galice file
2121 if (fGAFile == 0x0) return result;
2122 result = fGAFile->GetName();
2125 /*****************************************************************************/
2127 void AliRunLoader::SetDetectorAddresses()
2129 //calls SetTreeAddress for all detectors
2130 if (GetAliRun()==0x0) return;
2131 TIter next(GetAliRun()->Modules());
2133 while((mod = (AliModule*)next()))
2135 AliDetector* det = dynamic_cast<AliDetector*>(mod);
2136 if (det) det->SetTreeAddress();
2139 /*****************************************************************************/
2141 void AliRunLoader::Synchronize()
2143 //synchrinizes all writtable files
2144 TIter next(fLoaders);
2146 while((loader = (AliLoader*)next()))
2148 loader->Synchronize();
2151 fKineDataLoader->Synchronize();
2152 fTrackRefsDataLoader->Synchronize();
2154 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
2155 if( file ) file->Flush();
2157 if (fGAFile) fGAFile->Flush();
2159 /*****************************************************************************/
2160 /*****************************************************************************/