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()
128 if (fgRunLoader == this) fgRunLoader = 0x0;
134 fLoaders->SetOwner();
138 delete fKineDataLoader;
139 delete fTrackRefsDataLoader;
144 //fEventFolder is deleted by the way of removing - TopAliceFolder owns it
145 if( fCTrigger ) delete fCTrigger;
150 /**************************************************************************/
152 AliRunLoader::AliRunLoader(TFolder* topfolder):
153 TNamed(fgkRunLoaderName,fgkRunLoaderName),
154 fLoaders(new TObjArray()),
155 fEventFolder(topfolder),
161 fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
162 fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
169 TString errmsg("Parameter is NULL");
170 AliError(errmsg.Data());
175 TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
177 { //if it is, then sth. is going wrong... exits aliroot session
178 TString errmsg("In Event Folder Named ");
179 errmsg+=fEventFolder->GetName();
180 errmsg+=" object named "+fgkRunLoaderName+" already exists. I am confused ...";
182 AliError(errmsg.Data());
184 return;//never reached
187 if (!fgRunLoader) fgRunLoader = this;
189 fEventFolder->Add(this);//put myself to the folder to accessible for all
192 /**************************************************************************/
194 void AliRunLoader::Copy(TObject &) const
196 AliFatal("Not implemented");
198 /**************************************************************************/
200 Int_t AliRunLoader::GetEvent(Int_t evno)
202 //Gets event number evno
203 //Reloads all data properly
204 //PH if (fCurrentEvent == evno) return 0;
208 AliError("Can not give the event with negative number");
212 if (evno >= GetNumberOfEvents())
214 AliError(Form("There is no event with number %d",evno));
218 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
219 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
220 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
221 AliDebug(1, Form(" GETTING EVENT %d",evno));
222 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
223 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
224 AliDebug(1, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
226 fCurrentEvent = evno;
230 //Reload header (If header was loaded)
233 retval = TreeE()->GetEvent(fCurrentEvent);
236 AliError(Form("Cannot find event: %d\n ",fCurrentEvent));
240 //Reload stack (If header was loaded)
241 if (TreeE()) fStack = GetHeader()->Stack();
242 //Set event folder in stack (it does not mean that we read kinematics from file)
243 if( GetTrigger() && TreeCT() ) {
244 retval = TreeCT()->GetEvent(fCurrentEvent);
246 AliError(Form("Error occured while GetEvent for Trigger. Event %d",evno));
254 AliError(Form("Error occured while setting event %d",evno));
258 //Post Track References
259 retval = fTrackRefsDataLoader->GetEvent();
262 AliError(Form("Error occured while GetEvent for Track References. Event %d",evno));
266 //Read Kinematics if loaded
267 retval = fKineDataLoader->GetEvent();
270 AliError(Form("Error occured while GetEvent for Kinematics. Event %d",evno));
274 if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded())
276 fStack->ConnectTree(TreeK());
278 if (fStack->GetEvent() == kFALSE)
280 AliError(Form("Error occured while GetEvent for Stack. Event %d",evno));
285 //Trigger data reloading in all loaders
286 TIter next(fLoaders);
288 while((loader = (AliLoader*)next()))
290 retval = loader->GetEvent();
293 AliError(Form("Error occured while getting event for %s. Event %d.",
294 loader->GetDetectorName().Data(), evno));
299 SetDetectorAddresses();
303 /**************************************************************************/
304 Int_t AliRunLoader::SetEvent()
306 //if kinematics was loaded Cleans folder data
310 retval = fKineDataLoader->SetEvent();
313 AliError("SetEvent for Kinamtics Data Loader retutned error.");
316 retval = fTrackRefsDataLoader->SetEvent();
319 AliError("SetEvent for Track References Data Loader retutned error.");
323 TIter next(fLoaders);
325 while((loader = (AliLoader*)next()))
327 retval = loader->SetEvent();
330 AliError(Form("SetEvent for %s Data Loader retutned error.",loader->GetName()));
337 /**************************************************************************/
339 Int_t AliRunLoader::SetEventNumber(Int_t evno)
341 //cleans folders and sets the root dirs in files
342 if (fCurrentEvent == evno) return 0;
343 fCurrentEvent = evno;
347 /**************************************************************************/
348 AliCDBEntry* AliRunLoader::GetCDBEntry(const char* name) const
350 //Get an AliCDBEntry from the run data storage
352 if ( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) {
353 AliError("No run data storage defined!");
356 return AliCDBManager::Instance()->GetDefaultStorage()->Get(name, GetHeader()->GetRun());
360 /**************************************************************************/
361 AliRunLoader* AliRunLoader::Open
362 (const char* filename, const char* eventfoldername, Option_t* option)
364 //Opens a desired file 'filename'
365 //gets the the run-Loader and mounts it desired folder
366 //returns the pointer to run Loader which can be further used for accessing data
367 //in case of error returns NULL
369 static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
370 AliDebugClass(1,Form("\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data()));
372 AliRunLoader* result = 0x0;
374 /* ************************************************ */
375 /* Chceck if folder with given name already exists */
376 /* ************************************************ */
378 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
381 TFolder* fold = dynamic_cast<TFolder*>(obj);
384 AliErrorClass("Such a obejct already exists in top alice folder and it is not a folder.");
388 //check if we can get RL from that folder
389 result = AliRunLoader::GetRunLoader(eventfoldername);
392 AliErrorClass(Form("Folder %s already exists, and can not find session there. Can not mount.",eventfoldername));
396 if (result->GetFileName().CompareTo(filename) != 0)
398 AliErrorClass("Other file is mounted in demanded folder. Can not mount.");
402 //check if now is demanded (re)creation
403 if ( AliLoader::TestFileOption(option) == kFALSE)
405 AliErrorClass(Form("Session already exists in folder %s and this session option is %s. Unable to proceed.",
406 eventfoldername,option));
410 //check if demanded option is update and existing one
411 TString tmpstr(option);
412 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
413 (result->fGAFile->IsWritable() == kFALSE) )
415 AliErrorClass(Form("Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
416 eventfoldername,option));
420 AliWarningClass("Session is already opened and mounted in demanded folder");
421 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
423 } //end of checking in case of existance of object named identically that folder session is being opened
426 TFile * gAliceFile = TFile::Open(filename,option);//open a file
428 {//null pointer returned
429 AliFatalClass(Form("Can not open file %s.",filename));
433 if (gAliceFile->IsOpen() == kFALSE)
434 {//pointer to valid object returned but file is not opened
435 AliErrorClass(Form("Can not open file %s.",filename));
439 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
440 //else create new AliRunLoader
441 if ( AliLoader::TestFileOption(option) )
443 AliDebugClass(1, "Reading RL from file");
445 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
448 AliErrorClass(Form("Can not find run-Loader in file %s.",filename));
449 delete gAliceFile;//close the file
452 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
453 if (tmp)//if SetEvent returned error
455 AliErrorClass(Form("Can not mount event in folder %s.",eventfoldername));
456 delete result; //delete run-Loader
457 delete gAliceFile;//close the file
463 AliDebugClass(1, Form("Creating new AliRunLoader. Folder name is %s",eventfoldername));
466 result = new AliRunLoader(eventfoldername);
468 catch (TString& errmsg)
470 AliErrorClass(Form("AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data()));
472 delete gAliceFile;//close the file
477 //procedure for extracting dir name from the file name
478 TString fname(filename);
479 Int_t nsl = fname.Last('#');//look for hash in file name
481 if (nsl < 0) {//hash not found
482 nsl = fname.Last('/');// look for slash
484 nsl = fname.Last(':');// look for colon e.g. rfio:galice.root
487 if (nsl < 0) dirname = "./"; // no directory path, use "."
488 else dirname = fname.Remove(nsl+1);// directory path
490 AliDebugClass(1, Form("Dir name is : %s",dirname.Data()));
492 result->SetDirName(dirname);
493 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
494 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
497 /**************************************************************************/
498 Int_t AliRunLoader::GetNumberOfEvents()
500 //returns number of events in Run
504 retval = LoadHeader();
507 AliError("Error occured while loading header");
511 return (Int_t)TreeE()->GetEntries();
513 /**************************************************************************/
515 void AliRunLoader::MakeHeader()
517 //Makes header and connects it to header tree (if it exists)
521 AliDebug(1, "Creating new Header Object");
522 fHeader= new AliHeader();
524 TTree* tree = TreeE();
527 AliDebug(1, "Got Tree from folder.");
528 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
531 AliDebug(1, "Creating new branch");
532 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
533 branch->SetAutoDelete(kFALSE);
537 AliDebug(1, "Got Branch from Tree");
538 branch->SetAddress(&fHeader);
539 tree->GetEvent(fCurrentEvent);
540 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
544 fStack->ConnectTree(TreeK());
550 AliDebug(1, "Header does not have a stack.");
554 AliDebug(1, "Exiting MakeHeader method");
556 /**************************************************************************/
558 void AliRunLoader::MakeStack()
560 //Creates the stack object - do not connect the tree
563 fStack = new AliStack(10000);
566 /**************************************************************************/
568 void AliRunLoader::MakeTrigger()
570 // Makes trigger object and connects it to trigger tree (if it exists)
572 if( fCTrigger == 0x0 ) {
573 AliDebug( 1, "Creating new Trigger Object" );
574 fCTrigger = new AliCentralTrigger();
576 TTree* tree = TreeCT();
578 fCTrigger->MakeBranch( fgkTriggerBranchName, tree );
579 tree->GetEvent( fCurrentEvent );
582 AliDebug( 1, "Exiting MakeTrigger method" );
584 /**************************************************************************/
586 void AliRunLoader::MakeTree(Option_t *option)
589 const char *oK = strstr(option,"K"); //Kine
590 const char *oE = strstr(option,"E"); //Header
591 const char *oGG = strstr(option,"GG"); //Central TriGGer
595 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
597 AliError("Load Kinematics first");
602 fKineDataLoader->MakeTree();
605 fStack->ConnectTree(TreeK());
606 WriteKinematics("OVERWRITE");
613 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
614 GetEventFolder()->Add(tree);
616 WriteHeader("OVERWRITE");
621 // create the CTP Trigger output file and tree
622 TFile* file = gROOT->GetFile( fgkDefaultTriggerFileName );
624 file = TFile::Open( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ), "RECREATE" ) ;
628 TTree* tree = new TTree( fgkTriggerContainerName, "Tree with Central Trigger Mask" );
629 GetEventFolder()->Add(tree);
631 // WriteHeader("OVERWRITE");
634 TIter next(fLoaders);
636 while((loader = (AliLoader*)next()))
638 loader->MakeTree(option);
642 /**************************************************************************/
644 Int_t AliRunLoader::LoadgAlice()
646 //Loads gAlice from file
649 AliWarning("AliRun is already in folder. Unload first.");
652 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
655 AliError(Form("Can not find gAlice in file %s",fGAFile->GetName()));
658 alirun->SetRunLoader(this);
661 AliWarning(Form("gAlice already exists. Putting retrived object in folder named %s",
662 GetEventFolder()->GetName()));
668 SetDetectorAddresses();//calls SetTreeAddress for all detectors
671 /**************************************************************************/
673 Int_t AliRunLoader::LoadHeader()
675 //loads treeE and reads header object for current event
678 AliWarning("Header is already loaded. Use ReloadHeader to force reload. Nothing done");
682 if (GetEventFolder() == 0x0)
684 AliError("Event folder not specified yet");
690 AliError("Session not opened. Use AliRunLoader::Open");
694 if (fGAFile->IsOpen() == kFALSE)
696 AliError("Session not opened. Use AliRunLoader::Open");
700 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
703 AliError(Form("Can not find header tree named %s in file %s",
704 fgkHeaderContainerName.Data(),fGAFile->GetName()));
708 if (tree == TreeE()) return 0;
711 GetEventFolder()->Add(tree);
712 MakeHeader();//creates header object and connects to tree
716 /**************************************************************************/
718 Int_t AliRunLoader::LoadTrigger(Option_t* option)
723 AliWarning("Trigger is already loaded. Nothing done");
727 if( GetEventFolder() == 0x0 ) {
728 AliError("Event folder not specified yet");
731 // get the CTP Trigger output file and tree
732 TString trgfile = gSystem->ConcatFileName( fUnixDirName.Data(),
733 fgkDefaultTriggerFileName.Data() );
734 TFile* file = gROOT->GetFile( trgfile );
736 file = TFile::Open( trgfile, option ) ;
737 if (!file || file->IsOpen() == kFALSE ) {
738 AliError( Form( "Can not open trigger file %s", trgfile.Data() ) );
744 TTree* tree = dynamic_cast<TTree*>(file->Get( fgkTriggerContainerName ));
746 AliError( Form( "Can not find trigger tree named %s in file %s",
747 fgkTriggerContainerName.Data(), file->GetName() ) );
753 fCTrigger = dynamic_cast<AliCentralTrigger*>(file->Get( "AliCentralTrigger" ));
754 GetEventFolder()->Add( tree );
760 /**************************************************************************/
762 Int_t AliRunLoader::LoadKinematics(Option_t* option)
764 //Loads the kinematics
765 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
768 AliError("Error occured while loading kinamatics tree.");
773 fStack->ConnectTree(TreeK());
774 retval = fStack->GetEvent();
775 if ( retval == kFALSE)
777 AliError("Error occured while loading kinamatics tree.");
784 /**************************************************************************/
786 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
788 //Opens File with kinematics
791 if (file->IsOpen() == kFALSE)
792 {//pointer is not null but file is not opened
793 AliWarning("Pointer to file is not null, but file is not opened");//risky any way
795 file = 0x0; //proceed with opening procedure
799 AliWarning(Form("File %s already opened",filename.Data()));
803 //try to find if that file is opened somewere else
804 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
807 if(file->IsOpen() == kTRUE)
809 AliWarning(Form("File %s already opened by sombody else.",file->GetName()));
814 file = TFile::Open(filename,opt);
817 AliError(Form("Can not open file %s",filename.Data()));
820 if (file->IsOpen() == kFALSE)
821 {//file is not opened
822 AliError(Form("Can not open file %s",filename.Data()));
826 file->SetCompressionLevel(cl);
828 dir = AliLoader::ChangeDir(file,fCurrentEvent);
831 AliError(Form("Can not change to root directory in file %s",filename.Data()));
836 /**************************************************************************/
838 TTree* AliRunLoader::TreeE() const
840 //returns the tree from folder; shortcut method
841 if (AliDebugLevel() > 10) fEventFolder->ls();
842 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
843 return (obj)?dynamic_cast<TTree*>(obj):0x0;
845 /**************************************************************************/
847 TTree* AliRunLoader::TreeCT() const
849 //returns the tree from folder; shortcut method
850 if (AliDebugLevel() > 10) fEventFolder->ls();
851 TObject *obj = fEventFolder->FindObject(fgkTriggerContainerName);
852 return (obj)?dynamic_cast<TTree*>(obj):0x0;
854 /**************************************************************************/
856 AliHeader* AliRunLoader::GetHeader() const
858 //returns pointer header object
861 /**************************************************************************/
863 AliCentralTrigger* AliRunLoader::GetTrigger() const
865 //returns pointer trigger object
869 /**************************************************************************/
871 TTree* AliRunLoader::TreeK() const
873 //returns the tree from folder; shortcut method
874 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
875 return (obj)?dynamic_cast<TTree*>(obj):0x0;
877 /**************************************************************************/
879 TTree* AliRunLoader::TreeTR() const
881 //returns the tree from folder; shortcut method
882 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
883 return (obj)?dynamic_cast<TTree*>(obj):0x0;
885 /**************************************************************************/
887 AliRun* AliRunLoader::GetAliRun() const
889 //returns AliRun which sits in the folder
890 if (fEventFolder == 0x0) return 0x0;
891 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
892 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
894 /**************************************************************************/
896 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
898 //writes geometry to the file
900 TGeometry* geo = GetAliRun()->GetGeometry();
903 AliError("Can not get geometry from gAlice");
909 /**************************************************************************/
911 Int_t AliRunLoader::WriteHeader(Option_t* opt)
914 AliDebug(1, "WRITING HEADER");
916 TTree* tree = TreeE();
919 AliWarning("Can not find Header Tree in Folder");
922 if (fGAFile->IsWritable() == kFALSE)
924 AliError(Form("File %s is not writable",fGAFile->GetName()));
928 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
930 { //if they exist, see if option OVERWRITE is used
932 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
933 {//if it is not used - give an error message and return an error code
934 AliError("Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
939 tree->SetDirectory(fGAFile);
940 tree->Write(0,TObject::kOverwrite);
942 AliDebug(1, "WRITTEN\n\n");
947 /**************************************************************************/
949 Int_t AliRunLoader::WriteTrigger(Option_t* opt)
952 AliDebug( 1, "WRITING TRIGGER" );
954 TTree* tree = TreeCT();
956 AliWarning("Can not find Trigger Tree in Folder");
960 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
961 if( !file || !file->IsOpen() ) {
962 AliError( "can't write Trigger, file is not open" );
966 TObject* obj = file->Get( fgkTriggerContainerName );
967 if( obj ) { //if they exist, see if option OVERWRITE is used
969 if( tmp.Contains( "OVERWRITE", TString::kIgnoreCase ) == 0) {
970 //if it is not used - give an error message and return an error code
971 AliError( "Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data" );
976 fCTrigger->Write( 0, TObject::kOverwrite );
977 tree->Write( 0, TObject::kOverwrite );
980 AliDebug(1, "WRITTEN\n\n");
984 /**************************************************************************/
986 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
988 //writes AliRun object to the file
990 if (GetAliRun()) GetAliRun()->Write();
993 /**************************************************************************/
995 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
998 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
1000 /**************************************************************************/
1001 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
1003 //writes Track References tree
1004 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
1006 /**************************************************************************/
1008 Int_t AliRunLoader::WriteHits(Option_t* opt)
1010 //Calls WriteHits for all loaders
1013 TIter next(fLoaders);
1015 while((loader = (AliLoader*)next()))
1017 res = loader->WriteHits(opt);
1020 AliError(Form("Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res));
1026 /**************************************************************************/
1028 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
1030 //Calls WriteSDigits for all loaders
1033 TIter next(fLoaders);
1035 while((loader = (AliLoader*)next()))
1037 res = loader->WriteSDigits(opt);
1040 AliError(Form("Failed to write summable digits for %s.",loader->GetDetectorName().Data()));
1046 /**************************************************************************/
1048 Int_t AliRunLoader::WriteDigits(Option_t* opt)
1050 //Calls WriteDigits for all loaders
1053 TIter next(fLoaders);
1055 while((loader = (AliLoader*)next()))
1057 res = loader->WriteDigits(opt);
1060 AliError(Form("Failed to write digits for %s.",loader->GetDetectorName().Data()));
1066 /**************************************************************************/
1068 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
1070 //Calls WriteRecPoints for all loaders
1073 TIter next(fLoaders);
1075 while((loader = (AliLoader*)next()))
1077 res = loader->WriteRecPoints(opt);
1080 AliError(Form("Failed to write Reconstructed Points for %s.",
1081 loader->GetDetectorName().Data()));
1087 /**************************************************************************/
1089 Int_t AliRunLoader::WriteTracks(Option_t* opt)
1091 //Calls WriteTracks for all loaders
1094 TIter next(fLoaders);
1096 while((loader = (AliLoader*)next()))
1098 res = loader->WriteTracks(opt);
1101 AliError(Form("Failed to write Tracks for %s.",
1102 loader->GetDetectorName().Data()));
1108 /**************************************************************************/
1110 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
1112 //Writes itself to the file
1114 this->Write(0,TObject::kOverwrite);
1117 /**************************************************************************/
1119 Int_t AliRunLoader::SetEventFolderName(const TString& name)
1121 //sets top folder name for this run; of alread
1124 AliError("Name is empty");
1128 //check if such a folder already exists - try to find it in alice top folder
1129 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
1132 TFolder* fold = dynamic_cast<TFolder*>(obj);
1135 AliError("Such a obejct already exists in top alice folder and it is not a folder.");
1138 //folder which was found is our folder
1139 if (fEventFolder == fold)
1145 AliError("Such a folder already exists in top alice folder. Can not mount.");
1150 //event is alredy connected, just change name of the folder
1153 fEventFolder->SetName(name);
1157 if (fKineDataLoader == 0x0)
1158 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1160 if ( fTrackRefsDataLoader == 0x0)
1161 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1163 //build the event folder structure
1164 AliDebug(1, Form("Creating new event folder named %s",name.Data()));
1165 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1166 fEventFolder->Add(this);//put myself to the folder to accessible for all
1168 TIter next(fLoaders);
1170 while((loader = (AliLoader*)next()))
1172 loader->Register(fEventFolder);//build folder structure for this detector
1175 fKineDataLoader->SetEventFolder(GetEventFolder());
1176 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1177 fKineDataLoader->SetFolder(GetEventFolder());
1178 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1180 fEventFolder->SetOwner();
1183 /**************************************************************************/
1185 void AliRunLoader::AddLoader(AliLoader* loader)
1187 //Adds the Loader for given detector
1188 if (loader == 0x0) //if null shout and exit
1190 AliError("Parameter is NULL");
1193 loader->SetDirName(fUnixDirName);
1194 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1195 //pass information to the Loader
1196 fLoaders->Add(loader);//add the Loader to the array
1198 /**************************************************************************/
1200 void AliRunLoader::AddLoader(AliDetector* det)
1202 //Asks module (detector) ro make a Loader and stores in the array
1203 if (det == 0x0) return;
1204 AliLoader* get = det->GetLoader();//try to get loader
1205 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1209 AliDebug(1, Form("Detector: %s Loader : %s",det->GetName(),get->GetName()));
1214 /**************************************************************************/
1216 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1218 //returns loader for given detector
1219 //note that naming convention is TPCLoader not just TPC
1220 return (AliLoader*)fLoaders->FindObject(detname);
1223 /**************************************************************************/
1225 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1227 //get loader for detector det
1228 if(det == 0x0) return 0x0;
1229 TString getname(det->GetName());
1231 AliDebug(1, Form(" Loader name is %s",getname.Data()));
1232 return GetLoader(getname);
1235 /**************************************************************************/
1237 void AliRunLoader::CleanFolders()
1239 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1246 /**************************************************************************/
1248 void AliRunLoader::CleanDetectors()
1250 //Calls CleanFolders for all detectors
1251 TIter next(fLoaders);
1253 while((loader = (AliLoader*)next()))
1255 loader->CleanFolders();
1258 /**************************************************************************/
1260 void AliRunLoader::RemoveEventFolder()
1262 //remove all the tree of event
1263 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1265 if (fEventFolder == 0x0) return;
1266 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1267 fEventFolder->Remove(this);//remove us drom folder
1269 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1270 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1271 delete fEventFolder;
1273 /**************************************************************************/
1275 void AliRunLoader::SetGAliceFile(TFile* gafile)
1277 //sets pointer to galice.root file
1281 /**************************************************************************/
1283 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1285 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1287 AliDebug(1, "Loading Hits");
1291 const char* oAll = strstr(detectors,"all");
1294 AliDebug(1, "Option is All");
1299 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1300 loaders = &arr;//get the pointer array
1303 AliDebug(1, Form("For detectors. Number of detectors chosen for loading %d",loaders->GetEntries()));
1305 TIter next(loaders);
1307 while((loader = (AliLoader*)next()))
1309 AliDebug(1, Form(" Calling LoadHits(%s) for %s",opt,loader->GetName()));
1310 loader->LoadHits(opt);
1312 AliDebug(1, "Done");
1316 /**************************************************************************/
1318 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1320 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1325 const char* oAll = strstr(detectors,"all");
1332 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1333 loaders = &arr;//get the pointer to array
1336 TIter next(loaders);
1338 while((loader = (AliLoader*)next()))
1340 loader->LoadSDigits(opt);
1345 /**************************************************************************/
1347 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1349 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1354 const char* oAll = strstr(detectors,"all");
1361 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1362 loaders = &arr;//get the pointer array
1365 TIter next(loaders);
1367 while((loader = (AliLoader*)next()))
1369 loader->LoadDigits(opt);
1373 /**************************************************************************/
1375 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1377 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1382 const char* oAll = strstr(detectors,"all");
1389 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1390 loaders = &arr;//get the pointer array
1393 TIter next(loaders);
1395 while((loader = (AliLoader*)next()))
1397 loader->LoadRecPoints(opt);
1401 /**************************************************************************/
1403 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1405 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
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 array
1421 TIter next(loaders);
1423 while((loader = (AliLoader*)next()))
1425 loader->LoadRecParticles(opt);
1429 /**************************************************************************/
1431 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1433 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1438 const char* oAll = strstr(detectors,"all");
1445 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1446 loaders = &arr;//get the pointer array
1449 TIter next(loaders);
1451 while((loader = (AliLoader*)next()))
1453 loader->LoadTracks(opt);
1457 /**************************************************************************/
1459 void AliRunLoader::UnloadHits(Option_t* detectors)
1461 //unloads hits for detectors specified in parameter
1465 const char* oAll = strstr(detectors,"all");
1472 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1473 loaders = &arr;//get the pointer to array
1476 TIter next(loaders);
1478 while((loader = (AliLoader*)next()))
1480 loader->UnloadHits();
1483 /**************************************************************************/
1485 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1487 //unloads SDigits for detectors specified in parameter
1491 const char* oAll = strstr(detectors,"all");
1498 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1499 loaders = &arr;//get the pointer to array
1502 TIter next(loaders);
1504 while((loader = (AliLoader*)next()))
1506 loader->UnloadSDigits();
1509 /**************************************************************************/
1511 void AliRunLoader::UnloadDigits(Option_t* detectors)
1513 //unloads Digits for detectors specified in parameter
1517 const char* oAll = strstr(detectors,"all");
1524 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1525 loaders = &arr;//get the pointer to array
1528 TIter next(loaders);
1530 while((loader = (AliLoader*)next()))
1532 loader->UnloadDigits();
1535 /**************************************************************************/
1537 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1539 //unloads RecPoints for detectors specified in parameter
1543 const char* oAll = strstr(detectors,"all");
1550 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1551 loaders = &arr;//get the pointer to array
1554 TIter next(loaders);
1556 while((loader = (AliLoader*)next()))
1558 loader->UnloadRecPoints();
1561 /**************************************************************************/
1563 void AliRunLoader::UnloadAll(Option_t* detectors)
1565 //calls UnloadAll for detectors names specified in parameter
1566 // option "all" passed can be passed
1570 const char* oAll = strstr(detectors,"all");
1577 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1578 loaders = &arr;//get the pointer to array
1581 TIter next(loaders);
1583 while((loader = (AliLoader*)next()))
1585 loader->UnloadAll();
1588 /**************************************************************************/
1590 void AliRunLoader::UnloadTracks(Option_t* detectors)
1592 //unloads Tracks for detectors specified in parameter
1596 const char* oAll = strstr(detectors,"all");
1603 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1604 loaders = &arr;//get the pointer to array
1607 TIter next(loaders);
1609 while((loader = (AliLoader*)next()))
1611 loader->UnloadTracks();
1614 /**************************************************************************/
1616 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1618 //unloads Particles for detectors specified in parameter
1622 const char* oAll = strstr(detectors,"all");
1629 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1630 loaders = &arr;//get the pointer to array
1633 TIter next(loaders);
1635 while((loader = (AliLoader*)next()))
1637 loader->UnloadRecParticles();
1640 /**************************************************************************/
1642 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1644 //returns RunLoader from folder named eventfoldername
1645 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1650 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1654 /**************************************************************************/
1656 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1658 //get the loader of the detector with the given name from the global
1660 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1662 AliErrorClass("No run loader found");
1665 return runLoader->GetDetectorLoader(detname);
1667 /**************************************************************************/
1669 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1671 //get the loader of the detector with the given name from the global
1674 char loadername[256];
1675 sprintf(loadername, "%sLoader", detname);
1676 AliLoader* loader = GetLoader(loadername);
1678 AliError(Form("No loader for %s found", detname));
1683 /**************************************************************************/
1685 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1687 //get the tree with hits of the detector with the given name
1688 //if maketree is true and the tree does not exist, the tree is created
1689 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1690 if (!loader) return NULL;
1691 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1692 return loader->TreeH();
1695 /**************************************************************************/
1697 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1699 //get the tree with hits of the detector with the given name
1700 //if maketree is true and the tree does not exist, the tree is created
1701 AliLoader* loader = GetDetectorLoader(detname);
1702 if (!loader) return NULL;
1703 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1704 return loader->TreeH();
1706 /**************************************************************************/
1708 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1710 //get the tree with summable digits of the detector with the given name
1711 //if maketree is true and the tree does not exist, the tree is created
1712 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1713 if (!loader) return NULL;
1714 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1715 return loader->TreeS();
1717 /**************************************************************************/
1719 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1721 //get the tree with summable digits of the detector with the given name
1722 //if maketree is true and the tree does not exist, the tree is created
1723 AliLoader* loader = GetDetectorLoader(detname);
1724 if (!loader) return NULL;
1725 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1726 return loader->TreeS();
1728 /**************************************************************************/
1730 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1732 //get the tree with digits of the detector with the given name
1733 //if maketree is true and the tree does not exist, the tree is created
1734 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1735 if (!loader) return NULL;
1736 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1737 return loader->TreeD();
1739 /**************************************************************************/
1741 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1743 //get the tree with digits of the detector with the given name
1744 //if maketree is true and the tree does not exist, the tree is created
1745 AliLoader* loader = GetDetectorLoader(detname);
1746 if (!loader) return NULL;
1747 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1748 return loader->TreeD();
1750 /**************************************************************************/
1751 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1753 //get the tree with clusters of the detector with the given name
1754 //if maketree is true and the tree does not exist, the tree is created
1755 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1756 if (!loader) return NULL;
1757 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1758 return loader->TreeR();
1760 /**************************************************************************/
1762 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1764 //get the tree with clusters of the detector with the given name
1765 //if maketree is true and the tree does not exist, the tree is created
1766 AliLoader* loader = GetDetectorLoader(detname);
1767 if (!loader) return NULL;
1768 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1769 return loader->TreeR();
1771 /**************************************************************************/
1773 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1775 //get the tree with tracks of the detector with the given name
1776 //if maketree is true and the tree does not exist, the tree is created
1777 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1778 if (!loader) return NULL;
1779 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1780 return loader->TreeT();
1782 /**************************************************************************/
1784 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1786 //get the tree with tracks of the detector with the given name
1787 //if maketree is true and the tree does not exist, the tree is created
1788 AliLoader* loader = GetDetectorLoader(detname);
1789 if (!loader) return NULL;
1790 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1791 return loader->TreeT();
1793 /**************************************************************************/
1795 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1797 //get the tree with particles of the detector with the given name
1798 //if maketree is true and the tree does not exist, the tree is created
1799 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1800 if (!loader) return NULL;
1801 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1802 return loader->TreeP();
1804 /**************************************************************************/
1806 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1808 //get the tree with particles of the detector with the given name
1809 //if maketree is true and the tree does not exist, the tree is created
1810 AliLoader* loader = GetDetectorLoader(detname);
1811 if (!loader) return NULL;
1812 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1813 return loader->TreeP();
1816 /**************************************************************************/
1818 void AliRunLoader::CdGAFile()
1820 //sets gDirectory to galice file
1822 if(fGAFile) fGAFile->cd();
1825 /**************************************************************************/
1827 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1829 //this method looks for all Loaders corresponding
1830 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1834 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1835 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1840 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1841 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1843 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1844 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1845 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1846 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1847 //construct the Loader name
1848 TString getname(buff);
1850 AliLoader* loader = GetLoader(getname);//get the Loader
1853 pointerarray.Add(loader);
1857 AliError(Form("Can not find Loader for %s",buff));
1863 /*****************************************************************************/
1865 void AliRunLoader::Clean(const TString& name)
1867 //removes object with given name from event folder and deletes it
1868 if (GetEventFolder() == 0x0) return;
1869 TObject* obj = GetEventFolder()->FindObject(name);
1872 AliDebug(1, Form("name=%s, cleaning %s.",GetName(),name.Data()));
1873 GetEventFolder()->Remove(obj);
1879 /*****************************************************************************/
1881 TTask* AliRunLoader::GetRunDigitizer()
1883 //returns Run Digitizer from folder
1885 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1886 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1887 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1889 /*****************************************************************************/
1891 TTask* AliRunLoader::GetRunSDigitizer()
1893 //returns SDigitizer Task from folder
1895 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1896 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1897 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1899 /*****************************************************************************/
1901 TTask* AliRunLoader::GetRunReconstructioner()
1903 //returns Reconstructioner Task from folder
1904 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1905 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1906 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1908 /*****************************************************************************/
1910 TTask* AliRunLoader::GetRunTracker()
1912 //returns Tracker Task from folder
1913 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1914 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1915 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1917 /*****************************************************************************/
1919 TTask* AliRunLoader::GetRunPIDTask()
1921 //returns Tracker Task from folder
1922 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1923 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1924 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1926 /*****************************************************************************/
1928 TTask* AliRunLoader::GetRunQATask()
1930 //returns Quality Assurance Task from folder
1931 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1934 AliErrorClass("Can not get task folder from AliConfig");
1937 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1938 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1941 /*****************************************************************************/
1943 void AliRunLoader::SetCompressionLevel(Int_t cl)
1945 //Sets Compression Level in all files
1946 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1947 SetKineComprLevel(cl);
1948 SetTrackRefsComprLevel(cl);
1949 TIter next(fLoaders);
1951 while((loader = (AliLoader*)next()))
1953 loader->SetCompressionLevel(cl);
1956 /**************************************************************************/
1958 void AliRunLoader::SetKineComprLevel(Int_t cl)
1960 //Sets comression level in Kine File
1961 fKineDataLoader->SetCompressionLevel(cl);
1963 /**************************************************************************/
1965 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1967 //Sets comression level in Track Refences File
1968 fTrackRefsDataLoader->SetCompressionLevel(cl);
1970 /**************************************************************************/
1972 void AliRunLoader::UnloadHeader()
1974 //removes TreeE from folder and deletes it
1975 // as well as fHeader object
1980 /**************************************************************************/
1982 void AliRunLoader::UnloadTrigger()
1984 //removes TreeCT from folder and deletes it
1985 // as well as fHeader object
1991 /**************************************************************************/
1993 void AliRunLoader::UnloadKinematics()
1995 //Unloads Kinematics
1996 fKineDataLoader->GetBaseLoader(0)->Unload();
1998 /**************************************************************************/
2000 void AliRunLoader::UnloadTrackRefs()
2002 //Unloads Track Refernces
2003 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
2005 /**************************************************************************/
2007 void AliRunLoader::UnloadgAlice()
2010 if (gAlice == GetAliRun())
2012 AliDebug(1, "Set gAlice = 0x0");
2013 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
2015 AliRun* alirun = GetAliRun();
2016 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
2019 /**************************************************************************/
2021 void AliRunLoader::MakeTrackRefsContainer()
2023 // Makes a tree for Track References
2024 fTrackRefsDataLoader->MakeTree();
2026 /**************************************************************************/
2028 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
2030 //Load track references from file (opens file and posts tree to folder)
2032 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
2034 /**************************************************************************/
2036 void AliRunLoader::SetDirName(TString& dirname)
2038 //sets directory name
2039 if (dirname.IsNull()) return;
2040 fUnixDirName = dirname;
2041 fKineDataLoader->SetDirName(dirname);
2042 fTrackRefsDataLoader->SetDirName(dirname);
2044 TIter next(fLoaders);
2046 while((loader = (AliLoader*)next()))
2048 loader->SetDirName(dirname);
2052 /*****************************************************************************/
2054 Int_t AliRunLoader::GetFileOffset() const
2056 //returns the file number that is added to the file name for current event
2057 return Int_t(fCurrentEvent/fNEventsPerFile);
2060 /*****************************************************************************/
2061 const TString AliRunLoader::SetFileOffset(const TString& fname)
2063 //adds the the number to the file name at proper place for current event
2064 Long_t offset = (Long_t)GetFileOffset();
2065 if (offset < 1) return fname;
2067 soffset += offset;//automatic conversion to string
2068 TString dotroot(".root");
2069 const TString& offfsetdotroot = offset + dotroot;
2070 TString out = fname;
2071 out = out.ReplaceAll(dotroot,offfsetdotroot);
2072 AliDebug(1, Form(" in=%s out=%s",fname.Data(),out.Data()));
2075 /*****************************************************************************/
2077 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
2079 //adds the suffix before ".root",
2080 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
2081 //made on Jiri Chudoba demand
2083 TIter next(fLoaders);
2085 while((loader = (AliLoader*)next()))
2087 loader->SetDigitsFileNameSuffix(suffix);
2090 /*****************************************************************************/
2092 TString AliRunLoader::GetFileName() const
2094 //returns name of galice file
2096 if (fGAFile == 0x0) return result;
2097 result = fGAFile->GetName();
2100 /*****************************************************************************/
2102 void AliRunLoader::SetDetectorAddresses()
2104 //calls SetTreeAddress for all detectors
2105 if (GetAliRun()==0x0) return;
2106 TIter next(GetAliRun()->Modules());
2108 while((mod = (AliModule*)next()))
2110 AliDetector* det = dynamic_cast<AliDetector*>(mod);
2111 if (det) det->SetTreeAddress();
2114 /*****************************************************************************/
2116 void AliRunLoader::Synchronize()
2118 //synchrinizes all writtable files
2119 TIter next(fLoaders);
2121 while((loader = (AliLoader*)next()))
2123 loader->Synchronize();
2126 fKineDataLoader->Synchronize();
2127 fTrackRefsDataLoader->Synchronize();
2129 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
2130 if( file ) file->Flush();
2132 if (fGAFile) fGAFile->Flush();
2134 /*****************************************************************************/
2135 /*****************************************************************************/