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()) fStack->GetEvent();
306 //Trigger data reloading in all loaders
307 TIter next(fLoaders);
309 while((loader = (AliLoader*)next()))
311 retval = loader->GetEvent();
314 AliError(Form("Error occured while getting event for %s. Event %d.",
315 loader->GetDetectorName().Data(), evno));
320 SetDetectorAddresses();
324 /**************************************************************************/
325 Int_t AliRunLoader::SetEvent()
327 //if kinematics was loaded Cleans folder data
331 retval = fKineDataLoader->SetEvent();
334 AliError("SetEvent for Kinamtics Data Loader retutned error.");
337 retval = fTrackRefsDataLoader->SetEvent();
340 AliError("SetEvent for Track References Data Loader retutned error.");
344 TIter next(fLoaders);
346 while((loader = (AliLoader*)next()))
348 retval = loader->SetEvent();
351 AliError(Form("SetEvent for %s Data Loader retutned error.",loader->GetName()));
358 /**************************************************************************/
360 Int_t AliRunLoader::SetEventNumber(Int_t evno)
362 //cleans folders and sets the root dirs in files
363 if (fCurrentEvent == evno) return 0;
364 fCurrentEvent = evno;
368 /**************************************************************************/
369 AliCDBEntry* AliRunLoader::GetCDBEntry(const char* name) const
371 //Get an AliCDBEntry from the run data storage
373 if ( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) {
374 AliError("No run data storage defined!");
377 return AliCDBManager::Instance()->GetDefaultStorage()->Get(name, GetHeader()->GetRun());
381 /**************************************************************************/
382 AliRunLoader* AliRunLoader::Open
383 (const char* filename, const char* eventfoldername, Option_t* option)
385 //Opens a desired file 'filename'
386 //gets the the run-Loader and mounts it desired folder
387 //returns the pointer to run Loader which can be further used for accessing data
388 //in case of error returns NULL
390 static const TString kwebaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
391 AliDebugClass(1,Form("\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",kwebaddress.Data()));
393 AliRunLoader* result = 0x0;
395 /* ************************************************ */
396 /* Chceck if folder with given name already exists */
397 /* ************************************************ */
399 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername);
402 TFolder* fold = dynamic_cast<TFolder*>(obj);
405 AliErrorClass("Such a obejct already exists in top alice folder and it is not a folder.");
409 //check if we can get RL from that folder
410 result = AliRunLoader::GetRunLoader(eventfoldername);
413 AliErrorClass(Form("Folder %s already exists, and can not find session there. Can not mount.",eventfoldername));
417 if (result->GetFileName().CompareTo(filename) != 0)
419 AliErrorClass("Other file is mounted in demanded folder. Can not mount.");
423 //check if now is demanded (re)creation
424 if ( AliLoader::TestFileOption(option) == kFALSE)
426 AliErrorClass(Form("Session already exists in folder %s and this session option is %s. Unable to proceed.",
427 eventfoldername,option));
431 //check if demanded option is update and existing one
432 TString tmpstr(option);
433 if ( (tmpstr.CompareTo("update",TString::kIgnoreCase) == 0) &&
434 (result->fGAFile->IsWritable() == kFALSE) )
436 AliErrorClass(Form("Session already exists in folder %s and is not writable while this session option is %s. Unable to proceed.",
437 eventfoldername,option));
441 AliWarningClass("Session is already opened and mounted in demanded folder");
442 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
444 } //end of checking in case of existance of object named identically that folder session is being opened
447 TFile * gAliceFile = TFile::Open(filename,option);//open a file
449 {//null pointer returned
450 AliFatalClass(Form("Can not open file %s.",filename));
454 if (gAliceFile->IsOpen() == kFALSE)
455 {//pointer to valid object returned but file is not opened
456 AliErrorClass(Form("Can not open file %s.",filename));
460 //if file is "read" or "update" than we try to find AliRunLoader there - if not found cry and exit
461 //else create new AliRunLoader
462 if ( AliLoader::TestFileOption(option) )
464 AliDebugClass(1, "Reading RL from file");
466 result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
469 AliErrorClass(Form("Can not find run-Loader in file %s.",filename));
470 delete gAliceFile;//close the file
473 Int_t tmp = result->SetEventFolderName(eventfoldername);//mount a event folder
474 if (tmp)//if SetEvent returned error
476 AliErrorClass(Form("Can not mount event in folder %s.",eventfoldername));
477 delete result; //delete run-Loader
478 delete gAliceFile;//close the file
484 AliDebugClass(1, Form("Creating new AliRunLoader. Folder name is %s",eventfoldername));
487 result = new AliRunLoader(eventfoldername);
489 catch (TString& errmsg)
491 AliErrorClass(Form("AliRunLoader constrcutor has thrown exception: %s\n",errmsg.Data()));
493 delete gAliceFile;//close the file
498 //procedure for extracting dir name from the file name
499 TString fname(filename);
500 Int_t nsl = fname.Last('#');//look for hash in file name
502 if (nsl < 0) {//hash not found
503 nsl = fname.Last('/');// look for slash
505 nsl = fname.Last(':');// look for colon e.g. rfio:galice.root
508 if (nsl < 0) dirname = "./"; // no directory path, use "."
509 else dirname = fname.Remove(nsl+1);// directory path
511 AliDebugClass(1, Form("Dir name is : %s",dirname.Data()));
513 result->SetDirName(dirname);
514 result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
515 if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
518 /**************************************************************************/
519 Int_t AliRunLoader::GetNumberOfEvents()
521 //returns number of events in Run
525 retval = LoadHeader();
528 AliError("Error occured while loading header");
532 return (Int_t)TreeE()->GetEntries();
534 /**************************************************************************/
536 void AliRunLoader::MakeHeader()
538 //Makes header and connects it to header tree (if it exists)
542 AliDebug(1, "Creating new Header Object");
543 fHeader= new AliHeader();
545 TTree* tree = TreeE();
548 AliDebug(1, "Got Tree from folder.");
549 TBranch* branch = tree->GetBranch(fgkHeaderBranchName);
552 AliDebug(1, "Creating new branch");
553 branch = tree->Branch(fgkHeaderBranchName, "AliHeader", &fHeader, 4000, 0);
554 branch->SetAutoDelete(kFALSE);
558 AliDebug(1, "Got Branch from Tree");
559 branch->SetAddress(&fHeader);
560 tree->GetEvent(fCurrentEvent);
561 fStack = fHeader->Stack(); //should be safe - if we created Stack, header returns pointer to the same object
564 fStack->SetEventFolderName(fEventFolder->GetName());
565 if (TreeK()) fStack->GetEvent();
569 AliDebug(1, "Header does not have a stack.");
573 AliDebug(1, "Exiting MakeHeader method");
575 /**************************************************************************/
577 void AliRunLoader::MakeStack()
579 //Creates the stack object - do not connect the tree
582 fStack = new AliStack(10000);
583 fStack->SetEventFolderName(fEventFolder->GetName());
586 /**************************************************************************/
588 void AliRunLoader::MakeTrigger()
590 // Makes trigger object and connects it to trigger tree (if it exists)
592 if( fCTrigger == 0x0 ) {
593 AliDebug( 1, "Creating new Trigger Object" );
594 fCTrigger = new AliCentralTrigger();
596 TTree* tree = TreeCT();
598 fCTrigger->MakeBranch( fgkTriggerBranchName, tree );
599 tree->GetEvent( fCurrentEvent );
602 AliDebug( 1, "Exiting MakeTrigger method" );
604 /**************************************************************************/
606 void AliRunLoader::MakeTree(Option_t *option)
609 const char *oK = strstr(option,"K"); //Kine
610 const char *oE = strstr(option,"E"); //Header
611 const char *oCT = strstr(option,"CT"); //Central Trigger
615 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
617 AliError("Load Kinematics first");
621 fKineDataLoader->MakeTree();
623 fStack->ConnectTree();
624 WriteKinematics("OVERWRITE");
631 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
632 GetEventFolder()->Add(tree);
634 WriteHeader("OVERWRITE");
639 // create the CTP Trigger output file and tree
640 TFile* file = gROOT->GetFile( fgkDefaultTriggerFileName );
642 file = TFile::Open( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ), "RECREATE" ) ;
646 TTree* tree = new TTree( fgkTriggerContainerName, "Tree with Central Trigger Mask" );
647 GetEventFolder()->Add(tree);
649 // WriteHeader("OVERWRITE");
652 TIter next(fLoaders);
654 while((loader = (AliLoader*)next()))
656 loader->MakeTree(option);
660 /**************************************************************************/
662 Int_t AliRunLoader::LoadgAlice()
664 //Loads gAlice from file
667 AliWarning("AliRun is already in folder. Unload first.");
670 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
673 AliError(Form("Can not find gAlice in file %s",fGAFile->GetName()));
676 alirun->SetRunLoader(this);
679 AliWarning(Form("gAlice already exists. Putting retrived object in folder named %s",
680 GetEventFolder()->GetName()));
686 SetDetectorAddresses();//calls SetTreeAddress for all detectors
689 /**************************************************************************/
691 Int_t AliRunLoader::LoadHeader()
693 //loads treeE and reads header object for current event
696 AliWarning("Header is already loaded. Use ReloadHeader to force reload. Nothing done");
700 if (GetEventFolder() == 0x0)
702 AliError("Event folder not specified yet");
708 AliError("Session not opened. Use AliRunLoader::Open");
712 if (fGAFile->IsOpen() == kFALSE)
714 AliError("Session not opened. Use AliRunLoader::Open");
718 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
721 AliError(Form("Can not find header tree named %s in file %s",
722 fgkHeaderContainerName.Data(),fGAFile->GetName()));
726 if (tree == TreeE()) return 0;
729 GetEventFolder()->Add(tree);
730 MakeHeader();//creates header object and connects to tree
734 /**************************************************************************/
736 Int_t AliRunLoader::LoadTrigger(Option_t* option)
741 AliWarning("Trigger is already loaded. Nothing done");
745 if( GetEventFolder() == 0x0 ) {
746 AliError("Event folder not specified yet");
749 // get the CTP Trigger output file and tree
750 TString trgfile = gSystem->ConcatFileName( fUnixDirName.Data(),
751 fgkDefaultTriggerFileName.Data() );
752 TFile* file = gROOT->GetFile( trgfile );
754 file = TFile::Open( trgfile, option ) ;
755 if (!file || file->IsOpen() == kFALSE ) {
756 AliError( Form( "Can not open trigger file %s", trgfile.Data() ) );
762 TTree* tree = dynamic_cast<TTree*>(file->Get( fgkTriggerContainerName ));
764 AliError( Form( "Can not find trigger tree named %s in file %s",
765 fgkTriggerContainerName.Data(), file->GetName() ) );
771 fCTrigger = dynamic_cast<AliCentralTrigger*>(file->Get( "AliCentralTrigger" ));
772 GetEventFolder()->Add( tree );
778 /**************************************************************************/
780 Int_t AliRunLoader::LoadKinematics(Option_t* option)
782 //Loads the kinematics
783 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
786 AliError("Error occured while loading kinamatics tree.");
791 retval = fStack->GetEvent();
792 if ( retval == kFALSE)
794 AliError("Error occured while loading kinamatics tree.");
801 /**************************************************************************/
803 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
805 //Opens File with kinematics
808 if (file->IsOpen() == kFALSE)
809 {//pointer is not null but file is not opened
810 AliWarning("Pointer to file is not null, but file is not opened");//risky any way
812 file = 0x0; //proceed with opening procedure
816 AliWarning(Form("File %s already opened",filename.Data()));
820 //try to find if that file is opened somewere else
821 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
824 if(file->IsOpen() == kTRUE)
826 AliWarning(Form("File %s already opened by sombody else.",file->GetName()));
831 file = TFile::Open(filename,opt);
834 AliError(Form("Can not open file %s",filename.Data()));
837 if (file->IsOpen() == kFALSE)
838 {//file is not opened
839 AliError(Form("Can not open file %s",filename.Data()));
843 file->SetCompressionLevel(cl);
845 dir = AliLoader::ChangeDir(file,fCurrentEvent);
848 AliError(Form("Can not change to root directory in file %s",filename.Data()));
853 /**************************************************************************/
855 TTree* AliRunLoader::TreeE() const
857 //returns the tree from folder; shortcut method
858 if (AliDebugLevel() > 10) fEventFolder->ls();
859 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
860 return (obj)?dynamic_cast<TTree*>(obj):0x0;
862 /**************************************************************************/
864 TTree* AliRunLoader::TreeCT() const
866 //returns the tree from folder; shortcut method
867 if (AliDebugLevel() > 10) fEventFolder->ls();
868 TObject *obj = fEventFolder->FindObject(fgkTriggerContainerName);
869 return (obj)?dynamic_cast<TTree*>(obj):0x0;
871 /**************************************************************************/
873 AliHeader* AliRunLoader::GetHeader() const
875 //returns pointer header object
878 /**************************************************************************/
880 AliCentralTrigger* AliRunLoader::GetTrigger() const
882 //returns pointer trigger object
886 /**************************************************************************/
888 TTree* AliRunLoader::TreeK() const
890 //returns the tree from folder; shortcut method
891 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
892 return (obj)?dynamic_cast<TTree*>(obj):0x0;
894 /**************************************************************************/
896 TTree* AliRunLoader::TreeTR() const
898 //returns the tree from folder; shortcut method
899 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
900 return (obj)?dynamic_cast<TTree*>(obj):0x0;
902 /**************************************************************************/
904 AliRun* AliRunLoader::GetAliRun() const
906 //returns AliRun which sits in the folder
907 if (fEventFolder == 0x0) return 0x0;
908 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
909 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
911 /**************************************************************************/
913 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
915 //writes geometry to the file
917 TGeometry* geo = GetAliRun()->GetGeometry();
920 AliError("Can not get geometry from gAlice");
926 /**************************************************************************/
928 Int_t AliRunLoader::WriteHeader(Option_t* opt)
931 AliDebug(1, "WRITING HEADER");
933 TTree* tree = TreeE();
936 AliWarning("Can not find Header Tree in Folder");
939 if (fGAFile->IsWritable() == kFALSE)
941 AliError(Form("File %s is not writable",fGAFile->GetName()));
945 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
947 { //if they exist, see if option OVERWRITE is used
949 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
950 {//if it is not used - give an error message and return an error code
951 AliError("Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
956 tree->SetDirectory(fGAFile);
957 tree->Write(0,TObject::kOverwrite);
959 AliDebug(1, "WRITTEN\n\n");
964 /**************************************************************************/
966 Int_t AliRunLoader::WriteTrigger(Option_t* opt)
969 AliDebug( 1, "WRITING TRIGGER" );
971 TTree* tree = TreeCT();
973 AliWarning("Can not find Trigger Tree in Folder");
977 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
978 if( !file || !file->IsOpen() ) {
979 AliError( "can't write Trigger, file is not open" );
983 TObject* obj = file->Get( fgkTriggerContainerName );
984 if( obj ) { //if they exist, see if option OVERWRITE is used
986 if( tmp.Contains( "OVERWRITE", TString::kIgnoreCase ) == 0) {
987 //if it is not used - give an error message and return an error code
988 AliError( "Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data" );
993 fCTrigger->Write( 0, TObject::kOverwrite );
994 tree->Write( 0, TObject::kOverwrite );
997 AliDebug(1, "WRITTEN\n\n");
1001 /**************************************************************************/
1003 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
1005 //writes AliRun object to the file
1007 if (GetAliRun()) GetAliRun()->Write();
1010 /**************************************************************************/
1012 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
1015 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
1017 /**************************************************************************/
1018 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
1020 //writes Track References tree
1021 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
1023 /**************************************************************************/
1025 Int_t AliRunLoader::WriteHits(Option_t* opt)
1027 //Calls WriteHits for all loaders
1030 TIter next(fLoaders);
1032 while((loader = (AliLoader*)next()))
1034 res = loader->WriteHits(opt);
1037 AliError(Form("Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res));
1043 /**************************************************************************/
1045 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
1047 //Calls WriteSDigits for all loaders
1050 TIter next(fLoaders);
1052 while((loader = (AliLoader*)next()))
1054 res = loader->WriteSDigits(opt);
1057 AliError(Form("Failed to write summable digits for %s.",loader->GetDetectorName().Data()));
1063 /**************************************************************************/
1065 Int_t AliRunLoader::WriteDigits(Option_t* opt)
1067 //Calls WriteDigits for all loaders
1070 TIter next(fLoaders);
1072 while((loader = (AliLoader*)next()))
1074 res = loader->WriteDigits(opt);
1077 AliError(Form("Failed to write digits for %s.",loader->GetDetectorName().Data()));
1083 /**************************************************************************/
1085 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
1087 //Calls WriteRecPoints for all loaders
1090 TIter next(fLoaders);
1092 while((loader = (AliLoader*)next()))
1094 res = loader->WriteRecPoints(opt);
1097 AliError(Form("Failed to write Reconstructed Points for %s.",
1098 loader->GetDetectorName().Data()));
1104 /**************************************************************************/
1106 Int_t AliRunLoader::WriteTracks(Option_t* opt)
1108 //Calls WriteTracks for all loaders
1111 TIter next(fLoaders);
1113 while((loader = (AliLoader*)next()))
1115 res = loader->WriteTracks(opt);
1118 AliError(Form("Failed to write Tracks for %s.",
1119 loader->GetDetectorName().Data()));
1125 /**************************************************************************/
1127 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
1129 //Writes itself to the file
1131 this->Write(0,TObject::kOverwrite);
1134 /**************************************************************************/
1136 Int_t AliRunLoader::SetEventFolderName(const TString& name)
1138 //sets top folder name for this run; of alread
1141 AliError("Name is empty");
1145 //check if such a folder already exists - try to find it in alice top folder
1146 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
1149 TFolder* fold = dynamic_cast<TFolder*>(obj);
1152 AliError("Such a obejct already exists in top alice folder and it is not a folder.");
1155 //folder which was found is our folder
1156 if (fEventFolder == fold)
1162 AliError("Such a folder already exists in top alice folder. Can not mount.");
1167 //event is alredy connected, just change name of the folder
1170 fEventFolder->SetName(name);
1174 if (fKineDataLoader == 0x0)
1175 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1177 if ( fTrackRefsDataLoader == 0x0)
1178 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1180 //build the event folder structure
1181 AliDebug(1, Form("Creating new event folder named %s",name.Data()));
1182 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1183 fEventFolder->Add(this);//put myself to the folder to accessible for all
1185 if (Stack()) Stack()->SetEventFolderName(fEventFolder->GetName());
1186 TIter next(fLoaders);
1188 while((loader = (AliLoader*)next()))
1190 loader->Register(fEventFolder);//build folder structure for this detector
1193 fKineDataLoader->SetEventFolder(GetEventFolder());
1194 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1195 fKineDataLoader->SetFolder(GetEventFolder());
1196 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1198 fEventFolder->SetOwner();
1201 /**************************************************************************/
1203 void AliRunLoader::AddLoader(AliLoader* loader)
1205 //Adds the Loader for given detector
1206 if (loader == 0x0) //if null shout and exit
1208 AliError("Parameter is NULL");
1211 loader->SetDirName(fUnixDirName);
1212 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1213 //pass information to the Loader
1214 fLoaders->Add(loader);//add the Loader to the array
1216 /**************************************************************************/
1218 void AliRunLoader::AddLoader(AliDetector* det)
1220 //Asks module (detector) ro make a Loader and stores in the array
1221 if (det == 0x0) return;
1222 AliLoader* get = det->GetLoader();//try to get loader
1223 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1227 AliDebug(1, Form("Detector: %s Loader : %s",det->GetName(),get->GetName()));
1232 /**************************************************************************/
1234 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1236 //returns loader for given detector
1237 //note that naming convention is TPCLoader not just TPC
1238 return (AliLoader*)fLoaders->FindObject(detname);
1241 /**************************************************************************/
1243 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1245 //get loader for detector det
1246 if(det == 0x0) return 0x0;
1247 TString getname(det->GetName());
1249 AliDebug(1, Form(" Loader name is %s",getname.Data()));
1250 return GetLoader(getname);
1253 /**************************************************************************/
1255 void AliRunLoader::CleanFolders()
1257 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1264 /**************************************************************************/
1266 void AliRunLoader::CleanDetectors()
1268 //Calls CleanFolders for all detectors
1269 TIter next(fLoaders);
1271 while((loader = (AliLoader*)next()))
1273 loader->CleanFolders();
1276 /**************************************************************************/
1278 void AliRunLoader::RemoveEventFolder()
1280 //remove all the tree of event
1281 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1283 if (fEventFolder == 0x0) return;
1284 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1285 fEventFolder->Remove(this);//remove us drom folder
1287 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1288 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1289 delete fEventFolder;
1291 /**************************************************************************/
1293 void AliRunLoader::SetGAliceFile(TFile* gafile)
1295 //sets pointer to galice.root file
1299 /**************************************************************************/
1301 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1303 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1305 AliDebug(1, "Loading Hits");
1309 const char* oAll = strstr(detectors,"all");
1312 AliDebug(1, "Option is All");
1317 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1318 loaders = &arr;//get the pointer array
1321 AliDebug(1, Form("For detectors. Number of detectors chosen for loading %d",loaders->GetEntries()));
1323 TIter next(loaders);
1325 while((loader = (AliLoader*)next()))
1327 AliDebug(1, Form(" Calling LoadHits(%s) for %s",opt,loader->GetName()));
1328 loader->LoadHits(opt);
1330 AliDebug(1, "Done");
1334 /**************************************************************************/
1336 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1338 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1343 const char* oAll = strstr(detectors,"all");
1350 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1351 loaders = &arr;//get the pointer to array
1354 TIter next(loaders);
1356 while((loader = (AliLoader*)next()))
1358 loader->LoadSDigits(opt);
1363 /**************************************************************************/
1365 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1367 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1372 const char* oAll = strstr(detectors,"all");
1379 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1380 loaders = &arr;//get the pointer array
1383 TIter next(loaders);
1385 while((loader = (AliLoader*)next()))
1387 loader->LoadDigits(opt);
1391 /**************************************************************************/
1393 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1395 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1400 const char* oAll = strstr(detectors,"all");
1407 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1408 loaders = &arr;//get the pointer array
1411 TIter next(loaders);
1413 while((loader = (AliLoader*)next()))
1415 loader->LoadRecPoints(opt);
1419 /**************************************************************************/
1421 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1423 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1428 const char* oAll = strstr(detectors,"all");
1435 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1436 loaders = &arr;//get the pointer array
1439 TIter next(loaders);
1441 while((loader = (AliLoader*)next()))
1443 loader->LoadRecParticles(opt);
1447 /**************************************************************************/
1449 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1451 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1456 const char* oAll = strstr(detectors,"all");
1463 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1464 loaders = &arr;//get the pointer array
1467 TIter next(loaders);
1469 while((loader = (AliLoader*)next()))
1471 loader->LoadTracks(opt);
1475 /**************************************************************************/
1477 void AliRunLoader::UnloadHits(Option_t* detectors)
1479 //unloads hits for detectors specified in parameter
1483 const char* oAll = strstr(detectors,"all");
1490 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1491 loaders = &arr;//get the pointer to array
1494 TIter next(loaders);
1496 while((loader = (AliLoader*)next()))
1498 loader->UnloadHits();
1501 /**************************************************************************/
1503 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1505 //unloads SDigits for detectors specified in parameter
1509 const char* oAll = strstr(detectors,"all");
1516 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1517 loaders = &arr;//get the pointer to array
1520 TIter next(loaders);
1522 while((loader = (AliLoader*)next()))
1524 loader->UnloadSDigits();
1527 /**************************************************************************/
1529 void AliRunLoader::UnloadDigits(Option_t* detectors)
1531 //unloads Digits for detectors specified in parameter
1535 const char* oAll = strstr(detectors,"all");
1542 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1543 loaders = &arr;//get the pointer to array
1546 TIter next(loaders);
1548 while((loader = (AliLoader*)next()))
1550 loader->UnloadDigits();
1553 /**************************************************************************/
1555 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1557 //unloads RecPoints for detectors specified in parameter
1561 const char* oAll = strstr(detectors,"all");
1568 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1569 loaders = &arr;//get the pointer to array
1572 TIter next(loaders);
1574 while((loader = (AliLoader*)next()))
1576 loader->UnloadRecPoints();
1579 /**************************************************************************/
1581 void AliRunLoader::UnloadAll(Option_t* detectors)
1583 //calls UnloadAll for detectors names specified in parameter
1584 // option "all" passed can be passed
1588 const char* oAll = strstr(detectors,"all");
1595 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1596 loaders = &arr;//get the pointer to array
1599 TIter next(loaders);
1601 while((loader = (AliLoader*)next()))
1603 loader->UnloadAll();
1606 /**************************************************************************/
1608 void AliRunLoader::UnloadTracks(Option_t* detectors)
1610 //unloads Tracks for detectors specified in parameter
1614 const char* oAll = strstr(detectors,"all");
1621 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1622 loaders = &arr;//get the pointer to array
1625 TIter next(loaders);
1627 while((loader = (AliLoader*)next()))
1629 loader->UnloadTracks();
1632 /**************************************************************************/
1634 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1636 //unloads Particles for detectors specified in parameter
1640 const char* oAll = strstr(detectors,"all");
1647 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1648 loaders = &arr;//get the pointer to array
1651 TIter next(loaders);
1653 while((loader = (AliLoader*)next()))
1655 loader->UnloadRecParticles();
1658 /**************************************************************************/
1660 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1662 //returns RunLoader from folder named eventfoldername
1663 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1668 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1672 /**************************************************************************/
1674 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1676 //get the loader of the detector with the given name from the global
1678 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1680 AliErrorClass("No run loader found");
1683 return runLoader->GetDetectorLoader(detname);
1685 /**************************************************************************/
1687 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1689 //get the loader of the detector with the given name from the global
1692 char loadername[256];
1693 sprintf(loadername, "%sLoader", detname);
1694 AliLoader* loader = GetLoader(loadername);
1696 AliError(Form("No loader for %s found", detname));
1701 /**************************************************************************/
1703 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1705 //get the tree with hits of the detector with the given name
1706 //if maketree is true and the tree does not exist, the tree is created
1707 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1708 if (!loader) return NULL;
1709 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1710 return loader->TreeH();
1713 /**************************************************************************/
1715 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1717 //get the tree with hits of the detector with the given name
1718 //if maketree is true and the tree does not exist, the tree is created
1719 AliLoader* loader = GetDetectorLoader(detname);
1720 if (!loader) return NULL;
1721 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1722 return loader->TreeH();
1724 /**************************************************************************/
1726 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1728 //get the tree with summable digits of the detector with the given name
1729 //if maketree is true and the tree does not exist, the tree is created
1730 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1731 if (!loader) return NULL;
1732 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1733 return loader->TreeS();
1735 /**************************************************************************/
1737 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1739 //get the tree with summable digits of the detector with the given name
1740 //if maketree is true and the tree does not exist, the tree is created
1741 AliLoader* loader = GetDetectorLoader(detname);
1742 if (!loader) return NULL;
1743 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1744 return loader->TreeS();
1746 /**************************************************************************/
1748 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1750 //get the tree with digits of the detector with the given name
1751 //if maketree is true and the tree does not exist, the tree is created
1752 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1753 if (!loader) return NULL;
1754 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1755 return loader->TreeD();
1757 /**************************************************************************/
1759 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1761 //get the tree with digits of the detector with the given name
1762 //if maketree is true and the tree does not exist, the tree is created
1763 AliLoader* loader = GetDetectorLoader(detname);
1764 if (!loader) return NULL;
1765 if (!loader->TreeD() && maketree) loader->MakeTree("D");
1766 return loader->TreeD();
1768 /**************************************************************************/
1769 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1771 //get the tree with clusters of the detector with the given name
1772 //if maketree is true and the tree does not exist, the tree is created
1773 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1774 if (!loader) return NULL;
1775 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1776 return loader->TreeR();
1778 /**************************************************************************/
1780 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1782 //get the tree with clusters of the detector with the given name
1783 //if maketree is true and the tree does not exist, the tree is created
1784 AliLoader* loader = GetDetectorLoader(detname);
1785 if (!loader) return NULL;
1786 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1787 return loader->TreeR();
1789 /**************************************************************************/
1791 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1793 //get the tree with tracks of the detector with the given name
1794 //if maketree is true and the tree does not exist, the tree is created
1795 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1796 if (!loader) return NULL;
1797 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1798 return loader->TreeT();
1800 /**************************************************************************/
1802 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1804 //get the tree with tracks of the detector with the given name
1805 //if maketree is true and the tree does not exist, the tree is created
1806 AliLoader* loader = GetDetectorLoader(detname);
1807 if (!loader) return NULL;
1808 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1809 return loader->TreeT();
1811 /**************************************************************************/
1813 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1815 //get the tree with particles of the detector with the given name
1816 //if maketree is true and the tree does not exist, the tree is created
1817 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1818 if (!loader) return NULL;
1819 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1820 return loader->TreeP();
1822 /**************************************************************************/
1824 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1826 //get the tree with particles of the detector with the given name
1827 //if maketree is true and the tree does not exist, the tree is created
1828 AliLoader* loader = GetDetectorLoader(detname);
1829 if (!loader) return NULL;
1830 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1831 return loader->TreeP();
1834 /**************************************************************************/
1836 void AliRunLoader::CdGAFile()
1838 //sets gDirectory to galice file
1840 if(fGAFile) fGAFile->cd();
1843 /**************************************************************************/
1845 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1847 //this method looks for all Loaders corresponding
1848 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1852 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1853 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1858 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1859 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1861 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1862 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1863 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1864 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1865 //construct the Loader name
1866 TString getname(buff);
1868 AliLoader* loader = GetLoader(getname);//get the Loader
1871 pointerarray.Add(loader);
1875 AliError(Form("Can not find Loader for %s",buff));
1881 /*****************************************************************************/
1883 void AliRunLoader::Clean(const TString& name)
1885 //removes object with given name from event folder and deletes it
1886 if (GetEventFolder() == 0x0) return;
1887 TObject* obj = GetEventFolder()->FindObject(name);
1890 AliDebug(1, Form("name=%s, cleaning %s.",GetName(),name.Data()));
1891 GetEventFolder()->Remove(obj);
1897 /*****************************************************************************/
1899 TTask* AliRunLoader::GetRunDigitizer()
1901 //returns Run Digitizer from folder
1903 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1904 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1905 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1907 /*****************************************************************************/
1909 TTask* AliRunLoader::GetRunSDigitizer()
1911 //returns SDigitizer Task from folder
1913 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1914 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1915 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1917 /*****************************************************************************/
1919 TTask* AliRunLoader::GetRunReconstructioner()
1921 //returns Reconstructioner Task from folder
1922 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1923 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1924 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1926 /*****************************************************************************/
1928 TTask* AliRunLoader::GetRunTracker()
1930 //returns Tracker Task from folder
1931 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1932 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1933 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1935 /*****************************************************************************/
1937 TTask* AliRunLoader::GetRunPIDTask()
1939 //returns Tracker Task from folder
1940 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1941 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1942 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1944 /*****************************************************************************/
1946 TTask* AliRunLoader::GetRunQATask()
1948 //returns Quality Assurance Task from folder
1949 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1952 AliErrorClass("Can not get task folder from AliConfig");
1955 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1956 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1959 /*****************************************************************************/
1961 void AliRunLoader::SetCompressionLevel(Int_t cl)
1963 //Sets Compression Level in all files
1964 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1965 SetKineComprLevel(cl);
1966 SetTrackRefsComprLevel(cl);
1967 TIter next(fLoaders);
1969 while((loader = (AliLoader*)next()))
1971 loader->SetCompressionLevel(cl);
1974 /**************************************************************************/
1976 void AliRunLoader::SetKineComprLevel(Int_t cl)
1978 //Sets comression level in Kine File
1979 fKineDataLoader->SetCompressionLevel(cl);
1981 /**************************************************************************/
1983 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1985 //Sets comression level in Track Refences File
1986 fTrackRefsDataLoader->SetCompressionLevel(cl);
1988 /**************************************************************************/
1990 void AliRunLoader::UnloadHeader()
1992 //removes TreeE from folder and deletes it
1993 // as well as fHeader object
1998 /**************************************************************************/
2000 void AliRunLoader::UnloadTrigger()
2002 //removes TreeCT from folder and deletes it
2003 // as well as fHeader object
2009 /**************************************************************************/
2011 void AliRunLoader::UnloadKinematics()
2013 //Unloads Kinematics
2014 fKineDataLoader->GetBaseLoader(0)->Unload();
2016 /**************************************************************************/
2018 void AliRunLoader::UnloadTrackRefs()
2020 //Unloads Track Refernces
2021 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
2023 /**************************************************************************/
2025 void AliRunLoader::UnloadgAlice()
2028 if (gAlice == GetAliRun())
2030 AliDebug(1, "Set gAlice = 0x0");
2031 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
2033 AliRun* alirun = GetAliRun();
2034 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
2037 /**************************************************************************/
2039 void AliRunLoader::MakeTrackRefsContainer()
2041 // Makes a tree for Track References
2042 fTrackRefsDataLoader->MakeTree();
2044 /**************************************************************************/
2046 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
2048 //Load track references from file (opens file and posts tree to folder)
2050 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
2052 /**************************************************************************/
2054 void AliRunLoader::SetDirName(TString& dirname)
2056 //sets directory name
2057 if (dirname.IsNull()) return;
2058 fUnixDirName = dirname;
2059 fKineDataLoader->SetDirName(dirname);
2060 fTrackRefsDataLoader->SetDirName(dirname);
2062 TIter next(fLoaders);
2064 while((loader = (AliLoader*)next()))
2066 loader->SetDirName(dirname);
2070 /*****************************************************************************/
2072 Int_t AliRunLoader::GetFileOffset() const
2074 //returns the file number that is added to the file name for current event
2075 return Int_t(fCurrentEvent/fNEventsPerFile);
2078 /*****************************************************************************/
2079 const TString AliRunLoader::SetFileOffset(const TString& fname)
2081 //adds the the number to the file name at proper place for current event
2082 Long_t offset = (Long_t)GetFileOffset();
2083 if (offset < 1) return fname;
2085 soffset += offset;//automatic conversion to string
2086 TString dotroot(".root");
2087 const TString& offfsetdotroot = offset + dotroot;
2088 TString out = fname;
2089 out = out.ReplaceAll(dotroot,offfsetdotroot);
2090 AliDebug(1, Form(" in=%s out=%s",fname.Data(),out.Data()));
2093 /*****************************************************************************/
2095 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
2097 //adds the suffix before ".root",
2098 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
2099 //made on Jiri Chudoba demand
2101 TIter next(fLoaders);
2103 while((loader = (AliLoader*)next()))
2105 loader->SetDigitsFileNameSuffix(suffix);
2108 /*****************************************************************************/
2110 TString AliRunLoader::GetFileName() const
2112 //returns name of galice file
2114 if (fGAFile == 0x0) return result;
2115 result = fGAFile->GetName();
2118 /*****************************************************************************/
2120 void AliRunLoader::SetDetectorAddresses()
2122 //calls SetTreeAddress for all detectors
2123 if (GetAliRun()==0x0) return;
2124 TIter next(GetAliRun()->Modules());
2126 while((mod = (AliModule*)next()))
2128 AliDetector* det = dynamic_cast<AliDetector*>(mod);
2129 if (det) det->SetTreeAddress();
2132 /*****************************************************************************/
2134 void AliRunLoader::Synchronize()
2136 //synchrinizes all writtable files
2137 TIter next(fLoaders);
2139 while((loader = (AliLoader*)next()))
2141 loader->Synchronize();
2144 fKineDataLoader->Synchronize();
2145 fTrackRefsDataLoader->Synchronize();
2147 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
2148 if( file ) file->Flush();
2150 if (fGAFile) fGAFile->Flush();
2152 /*****************************************************************************/
2153 /*****************************************************************************/