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)
264 if( GetTrigger() && TreeCT() ) {
265 retval = TreeCT()->GetEvent(fCurrentEvent);
267 AliError(Form("Error occured while GetEvent for Trigger. Event %d",evno));
275 AliError(Form("Error occured while setting event %d",evno));
279 //Post Track References
280 retval = fTrackRefsDataLoader->GetEvent();
283 AliError(Form("Error occured while GetEvent for Track References. Event %d",evno));
287 //Read Kinematics if loaded
288 retval = fKineDataLoader->GetEvent();
291 AliError(Form("Error occured while GetEvent for Kinematics. Event %d",evno));
295 if (fStack && fKineDataLoader->GetBaseLoader(0)->IsLoaded())
297 fStack->ConnectTree(TreeK());
299 if (fStack->GetEvent() == kFALSE)
301 AliError(Form("Error occured while GetEvent for Stack. Event %d",evno));
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
565 fStack->ConnectTree(TreeK());
571 AliDebug(1, "Header does not have a stack.");
575 AliDebug(1, "Exiting MakeHeader method");
577 /**************************************************************************/
579 void AliRunLoader::MakeStack()
581 //Creates the stack object - do not connect the tree
584 fStack = new AliStack(10000);
587 /**************************************************************************/
589 void AliRunLoader::MakeTrigger()
591 // Makes trigger object and connects it to trigger tree (if it exists)
593 if( fCTrigger == 0x0 ) {
594 AliDebug( 1, "Creating new Trigger Object" );
595 fCTrigger = new AliCentralTrigger();
597 TTree* tree = TreeCT();
599 fCTrigger->MakeBranch( fgkTriggerBranchName, tree );
600 tree->GetEvent( fCurrentEvent );
603 AliDebug( 1, "Exiting MakeTrigger method" );
605 /**************************************************************************/
607 void AliRunLoader::MakeTree(Option_t *option)
610 const char *oK = strstr(option,"K"); //Kine
611 const char *oE = strstr(option,"E"); //Header
612 const char *oGG = strstr(option,"GG"); //Central TriGGer
616 if (fKineDataLoader->GetBaseLoader(0)->IsLoaded() == kFALSE)
618 AliError("Load Kinematics first");
623 fKineDataLoader->MakeTree();
626 fStack->ConnectTree(TreeK());
627 WriteKinematics("OVERWRITE");
634 TTree* tree = new TTree(fgkHeaderContainerName,"Tree with Headers");
635 GetEventFolder()->Add(tree);
637 WriteHeader("OVERWRITE");
642 // create the CTP Trigger output file and tree
643 TFile* file = gROOT->GetFile( fgkDefaultTriggerFileName );
645 file = TFile::Open( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ), "RECREATE" ) ;
649 TTree* tree = new TTree( fgkTriggerContainerName, "Tree with Central Trigger Mask" );
650 GetEventFolder()->Add(tree);
652 // WriteHeader("OVERWRITE");
655 TIter next(fLoaders);
657 while((loader = (AliLoader*)next()))
659 loader->MakeTree(option);
663 /**************************************************************************/
665 Int_t AliRunLoader::LoadgAlice()
667 //Loads gAlice from file
670 AliWarning("AliRun is already in folder. Unload first.");
673 AliRun* alirun = dynamic_cast<AliRun*>(fGAFile->Get(fgkGAliceName));
676 AliError(Form("Can not find gAlice in file %s",fGAFile->GetName()));
679 alirun->SetRunLoader(this);
682 AliWarning(Form("gAlice already exists. Putting retrived object in folder named %s",
683 GetEventFolder()->GetName()));
689 SetDetectorAddresses();//calls SetTreeAddress for all detectors
692 /**************************************************************************/
694 Int_t AliRunLoader::LoadHeader()
696 //loads treeE and reads header object for current event
699 AliWarning("Header is already loaded. Use ReloadHeader to force reload. Nothing done");
703 if (GetEventFolder() == 0x0)
705 AliError("Event folder not specified yet");
711 AliError("Session not opened. Use AliRunLoader::Open");
715 if (fGAFile->IsOpen() == kFALSE)
717 AliError("Session not opened. Use AliRunLoader::Open");
721 TTree* tree = dynamic_cast<TTree*>(fGAFile->Get(fgkHeaderContainerName));
724 AliError(Form("Can not find header tree named %s in file %s",
725 fgkHeaderContainerName.Data(),fGAFile->GetName()));
729 if (tree == TreeE()) return 0;
732 GetEventFolder()->Add(tree);
733 MakeHeader();//creates header object and connects to tree
737 /**************************************************************************/
739 Int_t AliRunLoader::LoadTrigger(Option_t* option)
744 AliWarning("Trigger is already loaded. Nothing done");
748 if( GetEventFolder() == 0x0 ) {
749 AliError("Event folder not specified yet");
752 // get the CTP Trigger output file and tree
753 TString trgfile = gSystem->ConcatFileName( fUnixDirName.Data(),
754 fgkDefaultTriggerFileName.Data() );
755 TFile* file = gROOT->GetFile( trgfile );
757 file = TFile::Open( trgfile, option ) ;
758 if (!file || file->IsOpen() == kFALSE ) {
759 AliError( Form( "Can not open trigger file %s", trgfile.Data() ) );
765 TTree* tree = dynamic_cast<TTree*>(file->Get( fgkTriggerContainerName ));
767 AliError( Form( "Can not find trigger tree named %s in file %s",
768 fgkTriggerContainerName.Data(), file->GetName() ) );
774 fCTrigger = dynamic_cast<AliCentralTrigger*>(file->Get( "AliCentralTrigger" ));
775 GetEventFolder()->Add( tree );
781 /**************************************************************************/
783 Int_t AliRunLoader::LoadKinematics(Option_t* option)
785 //Loads the kinematics
786 Int_t retval = fKineDataLoader->GetBaseLoader(0)->Load(option);
789 AliError("Error occured while loading kinamatics tree.");
794 fStack->ConnectTree(TreeK());
795 retval = fStack->GetEvent();
796 if ( retval == kFALSE)
798 AliError("Error occured while loading kinamatics tree.");
805 /**************************************************************************/
807 Int_t AliRunLoader::OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl)
809 //Opens File with kinematics
812 if (file->IsOpen() == kFALSE)
813 {//pointer is not null but file is not opened
814 AliWarning("Pointer to file is not null, but file is not opened");//risky any way
816 file = 0x0; //proceed with opening procedure
820 AliWarning(Form("File %s already opened",filename.Data()));
824 //try to find if that file is opened somewere else
825 file = (TFile *)( gROOT->GetListOfFiles()->FindObject(filename) );
828 if(file->IsOpen() == kTRUE)
830 AliWarning(Form("File %s already opened by sombody else.",file->GetName()));
835 file = TFile::Open(filename,opt);
838 AliError(Form("Can not open file %s",filename.Data()));
841 if (file->IsOpen() == kFALSE)
842 {//file is not opened
843 AliError(Form("Can not open file %s",filename.Data()));
847 file->SetCompressionLevel(cl);
849 dir = AliLoader::ChangeDir(file,fCurrentEvent);
852 AliError(Form("Can not change to root directory in file %s",filename.Data()));
857 /**************************************************************************/
859 TTree* AliRunLoader::TreeE() const
861 //returns the tree from folder; shortcut method
862 if (AliDebugLevel() > 10) fEventFolder->ls();
863 TObject *obj = fEventFolder->FindObject(fgkHeaderContainerName);
864 return (obj)?dynamic_cast<TTree*>(obj):0x0;
866 /**************************************************************************/
868 TTree* AliRunLoader::TreeCT() const
870 //returns the tree from folder; shortcut method
871 if (AliDebugLevel() > 10) fEventFolder->ls();
872 TObject *obj = fEventFolder->FindObject(fgkTriggerContainerName);
873 return (obj)?dynamic_cast<TTree*>(obj):0x0;
875 /**************************************************************************/
877 AliHeader* AliRunLoader::GetHeader() const
879 //returns pointer header object
882 /**************************************************************************/
884 AliCentralTrigger* AliRunLoader::GetTrigger() const
886 //returns pointer trigger object
890 /**************************************************************************/
892 TTree* AliRunLoader::TreeK() const
894 //returns the tree from folder; shortcut method
895 TObject *obj = GetEventFolder()->FindObject(fgkKineContainerName);
896 return (obj)?dynamic_cast<TTree*>(obj):0x0;
898 /**************************************************************************/
900 TTree* AliRunLoader::TreeTR() const
902 //returns the tree from folder; shortcut method
903 TObject* obj = GetEventFolder()->FindObject(fgkTrackRefsContainerName);
904 return (obj)?dynamic_cast<TTree*>(obj):0x0;
906 /**************************************************************************/
908 AliRun* AliRunLoader::GetAliRun() const
910 //returns AliRun which sits in the folder
911 if (fEventFolder == 0x0) return 0x0;
912 TObject *obj = fEventFolder->FindObject(fgkGAliceName);
913 return (obj)?dynamic_cast<AliRun*>(obj):0x0;
915 /**************************************************************************/
917 Int_t AliRunLoader::WriteGeometry(Option_t* /*opt*/)
919 //writes geometry to the file
921 TGeometry* geo = GetAliRun()->GetGeometry();
924 AliError("Can not get geometry from gAlice");
930 /**************************************************************************/
932 Int_t AliRunLoader::WriteHeader(Option_t* opt)
935 AliDebug(1, "WRITING HEADER");
937 TTree* tree = TreeE();
940 AliWarning("Can not find Header Tree in Folder");
943 if (fGAFile->IsWritable() == kFALSE)
945 AliError(Form("File %s is not writable",fGAFile->GetName()));
949 TObject* obj = fGAFile->Get(fgkHeaderContainerName);
951 { //if they exist, see if option OVERWRITE is used
953 if(tmp.Contains("OVERWRITE",TString::kIgnoreCase) == 0)
954 {//if it is not used - give an error message and return an error code
955 AliError("Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data");
960 tree->SetDirectory(fGAFile);
961 tree->Write(0,TObject::kOverwrite);
963 AliDebug(1, "WRITTEN\n\n");
968 /**************************************************************************/
970 Int_t AliRunLoader::WriteTrigger(Option_t* opt)
973 AliDebug( 1, "WRITING TRIGGER" );
975 TTree* tree = TreeCT();
977 AliWarning("Can not find Trigger Tree in Folder");
981 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
982 if( !file || !file->IsOpen() ) {
983 AliError( "can't write Trigger, file is not open" );
987 TObject* obj = file->Get( fgkTriggerContainerName );
988 if( obj ) { //if they exist, see if option OVERWRITE is used
990 if( tmp.Contains( "OVERWRITE", TString::kIgnoreCase ) == 0) {
991 //if it is not used - give an error message and return an error code
992 AliError( "Tree already exisists. Use option \"OVERWRITE\" to overwrite previous data" );
997 fCTrigger->Write( 0, TObject::kOverwrite );
998 tree->Write( 0, TObject::kOverwrite );
1001 AliDebug(1, "WRITTEN\n\n");
1005 /**************************************************************************/
1007 Int_t AliRunLoader::WriteAliRun(Option_t* /*opt*/)
1009 //writes AliRun object to the file
1011 if (GetAliRun()) GetAliRun()->Write();
1014 /**************************************************************************/
1016 Int_t AliRunLoader::WriteKinematics(Option_t* opt)
1019 return fKineDataLoader->GetBaseLoader(0)->WriteData(opt);
1021 /**************************************************************************/
1022 Int_t AliRunLoader::WriteTrackRefs(Option_t* opt)
1024 //writes Track References tree
1025 return fTrackRefsDataLoader->GetBaseLoader(0)->WriteData(opt);
1027 /**************************************************************************/
1029 Int_t AliRunLoader::WriteHits(Option_t* opt)
1031 //Calls WriteHits for all loaders
1034 TIter next(fLoaders);
1036 while((loader = (AliLoader*)next()))
1038 res = loader->WriteHits(opt);
1041 AliError(Form("Failed to write hits for %s (%d)",loader->GetDetectorName().Data(),res));
1047 /**************************************************************************/
1049 Int_t AliRunLoader::WriteSDigits(Option_t* opt)
1051 //Calls WriteSDigits for all loaders
1054 TIter next(fLoaders);
1056 while((loader = (AliLoader*)next()))
1058 res = loader->WriteSDigits(opt);
1061 AliError(Form("Failed to write summable digits for %s.",loader->GetDetectorName().Data()));
1067 /**************************************************************************/
1069 Int_t AliRunLoader::WriteDigits(Option_t* opt)
1071 //Calls WriteDigits for all loaders
1074 TIter next(fLoaders);
1076 while((loader = (AliLoader*)next()))
1078 res = loader->WriteDigits(opt);
1081 AliError(Form("Failed to write digits for %s.",loader->GetDetectorName().Data()));
1087 /**************************************************************************/
1089 Int_t AliRunLoader::WriteRecPoints(Option_t* opt)
1091 //Calls WriteRecPoints for all loaders
1094 TIter next(fLoaders);
1096 while((loader = (AliLoader*)next()))
1098 res = loader->WriteRecPoints(opt);
1101 AliError(Form("Failed to write Reconstructed Points for %s.",
1102 loader->GetDetectorName().Data()));
1108 /**************************************************************************/
1110 Int_t AliRunLoader::WriteTracks(Option_t* opt)
1112 //Calls WriteTracks for all loaders
1115 TIter next(fLoaders);
1117 while((loader = (AliLoader*)next()))
1119 res = loader->WriteTracks(opt);
1122 AliError(Form("Failed to write Tracks for %s.",
1123 loader->GetDetectorName().Data()));
1129 /**************************************************************************/
1131 Int_t AliRunLoader::WriteRunLoader(Option_t* /*opt*/)
1133 //Writes itself to the file
1135 this->Write(0,TObject::kOverwrite);
1138 /**************************************************************************/
1140 Int_t AliRunLoader::SetEventFolderName(const TString& name)
1142 //sets top folder name for this run; of alread
1145 AliError("Name is empty");
1149 //check if such a folder already exists - try to find it in alice top folder
1150 TObject* obj = AliConfig::Instance()->GetTopFolder()->FindObject(name);
1153 TFolder* fold = dynamic_cast<TFolder*>(obj);
1156 AliError("Such a obejct already exists in top alice folder and it is not a folder.");
1159 //folder which was found is our folder
1160 if (fEventFolder == fold)
1166 AliError("Such a folder already exists in top alice folder. Can not mount.");
1171 //event is alredy connected, just change name of the folder
1174 fEventFolder->SetName(name);
1178 if (fKineDataLoader == 0x0)
1179 fKineDataLoader = new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics");
1181 if ( fTrackRefsDataLoader == 0x0)
1182 fTrackRefsDataLoader = new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References");
1184 //build the event folder structure
1185 AliDebug(1, Form("Creating new event folder named %s",name.Data()));
1186 fEventFolder = AliConfig::Instance()->BuildEventFolder(name,"Event Folder");
1187 fEventFolder->Add(this);//put myself to the folder to accessible for all
1189 TIter next(fLoaders);
1191 while((loader = (AliLoader*)next()))
1193 loader->Register(fEventFolder);//build folder structure for this detector
1196 fKineDataLoader->SetEventFolder(GetEventFolder());
1197 fTrackRefsDataLoader->SetEventFolder(GetEventFolder());
1198 fKineDataLoader->SetFolder(GetEventFolder());
1199 fTrackRefsDataLoader->SetFolder(GetEventFolder());
1201 fEventFolder->SetOwner();
1204 /**************************************************************************/
1206 void AliRunLoader::AddLoader(AliLoader* loader)
1208 //Adds the Loader for given detector
1209 if (loader == 0x0) //if null shout and exit
1211 AliError("Parameter is NULL");
1214 loader->SetDirName(fUnixDirName);
1215 if (fEventFolder) loader->SetEventFolder(fEventFolder); //if event folder is already defined,
1216 //pass information to the Loader
1217 fLoaders->Add(loader);//add the Loader to the array
1219 /**************************************************************************/
1221 void AliRunLoader::AddLoader(AliDetector* det)
1223 //Asks module (detector) ro make a Loader and stores in the array
1224 if (det == 0x0) return;
1225 AliLoader* get = det->GetLoader();//try to get loader
1226 if (get == 0x0) get = det->MakeLoader(fEventFolder->GetName());//if did not obtain, ask to make it
1230 AliDebug(1, Form("Detector: %s Loader : %s",det->GetName(),get->GetName()));
1235 /**************************************************************************/
1237 AliLoader* AliRunLoader::GetLoader(const char* detname) const
1239 //returns loader for given detector
1240 //note that naming convention is TPCLoader not just TPC
1241 return (AliLoader*)fLoaders->FindObject(detname);
1244 /**************************************************************************/
1246 AliLoader* AliRunLoader::GetLoader(AliDetector* det) const
1248 //get loader for detector det
1249 if(det == 0x0) return 0x0;
1250 TString getname(det->GetName());
1252 AliDebug(1, Form(" Loader name is %s",getname.Data()));
1253 return GetLoader(getname);
1256 /**************************************************************************/
1258 void AliRunLoader::CleanFolders()
1260 // fEventFolder->Add(this);//put myself to the folder to accessible for all
1267 /**************************************************************************/
1269 void AliRunLoader::CleanDetectors()
1271 //Calls CleanFolders for all detectors
1272 TIter next(fLoaders);
1274 while((loader = (AliLoader*)next()))
1276 loader->CleanFolders();
1279 /**************************************************************************/
1281 void AliRunLoader::RemoveEventFolder()
1283 //remove all the tree of event
1284 //all the stuff changing EbE stays untached (PDGDB, tasks, etc.)
1286 if (fEventFolder == 0x0) return;
1287 fEventFolder->SetOwner(kFALSE);//don't we want to deleted while removing the folder that we are sitting in
1288 fEventFolder->Remove(this);//remove us drom folder
1290 AliConfig::Instance()->GetTopFolder()->SetOwner(); //brings ownership back for fEventFolder since it sits in top folder
1291 AliConfig::Instance()->GetTopFolder()->Remove(fEventFolder); //remove the event tree
1292 delete fEventFolder;
1294 /**************************************************************************/
1296 void AliRunLoader::SetGAliceFile(TFile* gafile)
1298 //sets pointer to galice.root file
1302 /**************************************************************************/
1304 Int_t AliRunLoader::LoadHits(Option_t* detectors,Option_t* opt)
1306 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1308 AliDebug(1, "Loading Hits");
1312 const char* oAll = strstr(detectors,"all");
1315 AliDebug(1, "Option is All");
1320 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1321 loaders = &arr;//get the pointer array
1324 AliDebug(1, Form("For detectors. Number of detectors chosen for loading %d",loaders->GetEntries()));
1326 TIter next(loaders);
1328 while((loader = (AliLoader*)next()))
1330 AliDebug(1, Form(" Calling LoadHits(%s) for %s",opt,loader->GetName()));
1331 loader->LoadHits(opt);
1333 AliDebug(1, "Done");
1337 /**************************************************************************/
1339 Int_t AliRunLoader::LoadSDigits(Option_t* detectors,Option_t* opt)
1341 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1346 const char* oAll = strstr(detectors,"all");
1353 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1354 loaders = &arr;//get the pointer to array
1357 TIter next(loaders);
1359 while((loader = (AliLoader*)next()))
1361 loader->LoadSDigits(opt);
1366 /**************************************************************************/
1368 Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
1370 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1375 const char* oAll = strstr(detectors,"all");
1382 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1383 loaders = &arr;//get the pointer array
1386 TIter next(loaders);
1388 while((loader = (AliLoader*)next()))
1390 loader->LoadDigits(opt);
1394 /**************************************************************************/
1396 Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
1398 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1403 const char* oAll = strstr(detectors,"all");
1410 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1411 loaders = &arr;//get the pointer array
1414 TIter next(loaders);
1416 while((loader = (AliLoader*)next()))
1418 loader->LoadRecPoints(opt);
1422 /**************************************************************************/
1424 Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
1426 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1431 const char* oAll = strstr(detectors,"all");
1438 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1439 loaders = &arr;//get the pointer array
1442 TIter next(loaders);
1444 while((loader = (AliLoader*)next()))
1446 loader->LoadRecParticles(opt);
1450 /**************************************************************************/
1452 Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
1454 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
1459 const char* oAll = strstr(detectors,"all");
1466 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1467 loaders = &arr;//get the pointer array
1470 TIter next(loaders);
1472 while((loader = (AliLoader*)next()))
1474 loader->LoadTracks(opt);
1478 /**************************************************************************/
1480 void AliRunLoader::UnloadHits(Option_t* detectors)
1482 //unloads hits for detectors specified in parameter
1486 const char* oAll = strstr(detectors,"all");
1493 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1494 loaders = &arr;//get the pointer to array
1497 TIter next(loaders);
1499 while((loader = (AliLoader*)next()))
1501 loader->UnloadHits();
1504 /**************************************************************************/
1506 void AliRunLoader::UnloadSDigits(Option_t* detectors)
1508 //unloads SDigits for detectors specified in parameter
1512 const char* oAll = strstr(detectors,"all");
1519 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1520 loaders = &arr;//get the pointer to array
1523 TIter next(loaders);
1525 while((loader = (AliLoader*)next()))
1527 loader->UnloadSDigits();
1530 /**************************************************************************/
1532 void AliRunLoader::UnloadDigits(Option_t* detectors)
1534 //unloads Digits for detectors specified in parameter
1538 const char* oAll = strstr(detectors,"all");
1545 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1546 loaders = &arr;//get the pointer to array
1549 TIter next(loaders);
1551 while((loader = (AliLoader*)next()))
1553 loader->UnloadDigits();
1556 /**************************************************************************/
1558 void AliRunLoader::UnloadRecPoints(Option_t* detectors)
1560 //unloads RecPoints for detectors specified in parameter
1564 const char* oAll = strstr(detectors,"all");
1571 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1572 loaders = &arr;//get the pointer to array
1575 TIter next(loaders);
1577 while((loader = (AliLoader*)next()))
1579 loader->UnloadRecPoints();
1582 /**************************************************************************/
1584 void AliRunLoader::UnloadAll(Option_t* detectors)
1586 //calls UnloadAll for detectors names specified in parameter
1587 // option "all" passed can be passed
1591 const char* oAll = strstr(detectors,"all");
1598 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1599 loaders = &arr;//get the pointer to array
1602 TIter next(loaders);
1604 while((loader = (AliLoader*)next()))
1606 loader->UnloadAll();
1609 /**************************************************************************/
1611 void AliRunLoader::UnloadTracks(Option_t* detectors)
1613 //unloads Tracks for detectors specified in parameter
1617 const char* oAll = strstr(detectors,"all");
1624 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1625 loaders = &arr;//get the pointer to array
1628 TIter next(loaders);
1630 while((loader = (AliLoader*)next()))
1632 loader->UnloadTracks();
1635 /**************************************************************************/
1637 void AliRunLoader::UnloadRecParticles(Option_t* detectors)
1639 //unloads Particles for detectors specified in parameter
1643 const char* oAll = strstr(detectors,"all");
1650 GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
1651 loaders = &arr;//get the pointer to array
1654 TIter next(loaders);
1656 while((loader = (AliLoader*)next()))
1658 loader->UnloadRecParticles();
1661 /**************************************************************************/
1663 AliRunLoader* AliRunLoader::GetRunLoader(const char* eventfoldername)
1665 //returns RunLoader from folder named eventfoldername
1666 TFolder* evfold= dynamic_cast<TFolder*>(AliConfig::Instance()->GetTopFolder()->FindObject(eventfoldername));
1671 AliRunLoader* runget = dynamic_cast<AliRunLoader*>(evfold->FindObject(AliRunLoader::fgkRunLoaderName));
1675 /**************************************************************************/
1677 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname, const char* eventfoldername)
1679 //get the loader of the detector with the given name from the global
1681 AliRunLoader* runLoader = GetRunLoader(eventfoldername);
1683 AliErrorClass("No run loader found");
1686 return runLoader->GetDetectorLoader(detname);
1688 /**************************************************************************/
1690 AliLoader* AliRunLoader::GetDetectorLoader(const char* detname)
1692 //get the loader of the detector with the given name from the global
1695 char loadername[256];
1696 sprintf(loadername, "%sLoader", detname);
1697 AliLoader* loader = GetLoader(loadername);
1699 AliError(Form("No loader for %s found", detname));
1704 /**************************************************************************/
1706 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername)
1708 //get the tree with hits of the detector with the given name
1709 //if maketree is true and the tree does not exist, the tree is created
1710 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1711 if (!loader) return NULL;
1712 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1713 return loader->TreeH();
1716 /**************************************************************************/
1718 TTree* AliRunLoader::GetTreeH(const char* detname, Bool_t maketree)
1720 //get the tree with hits of the detector with the given name
1721 //if maketree is true and the tree does not exist, the tree is created
1722 AliLoader* loader = GetDetectorLoader(detname);
1723 if (!loader) return NULL;
1724 if (!loader->TreeH() && maketree) loader->MakeTree("H");
1725 return loader->TreeH();
1727 /**************************************************************************/
1729 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree,const char* eventfoldername)
1731 //get the tree with summable digits of the detector with the given name
1732 //if maketree is true and the tree does not exist, the tree is created
1733 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1734 if (!loader) return NULL;
1735 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1736 return loader->TreeS();
1738 /**************************************************************************/
1740 TTree* AliRunLoader::GetTreeS(const char* detname, Bool_t maketree)
1742 //get the tree with summable digits of the detector with the given name
1743 //if maketree is true and the tree does not exist, the tree is created
1744 AliLoader* loader = GetDetectorLoader(detname);
1745 if (!loader) return NULL;
1746 if (!loader->TreeS() && maketree) loader->MakeTree("S");
1747 return loader->TreeS();
1749 /**************************************************************************/
1751 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree,const char* eventfoldername)
1753 //get the tree with digits 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->TreeD() && maketree) loader->MakeTree("D");
1758 return loader->TreeD();
1760 /**************************************************************************/
1762 TTree* AliRunLoader::GetTreeD(const char* detname, Bool_t maketree)
1764 //get the tree with digits 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->TreeD() && maketree) loader->MakeTree("D");
1769 return loader->TreeD();
1771 /**************************************************************************/
1772 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree,const char* eventfoldername)
1774 //get the tree with clusters of the detector with the given name
1775 //if maketree is true and the tree does not exist, the tree is created
1776 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1777 if (!loader) return NULL;
1778 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1779 return loader->TreeR();
1781 /**************************************************************************/
1783 TTree* AliRunLoader::GetTreeR(const char* detname, Bool_t maketree)
1785 //get the tree with clusters of the detector with the given name
1786 //if maketree is true and the tree does not exist, the tree is created
1787 AliLoader* loader = GetDetectorLoader(detname);
1788 if (!loader) return NULL;
1789 if (!loader->TreeR() && maketree) loader->MakeTree("R");
1790 return loader->TreeR();
1792 /**************************************************************************/
1794 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree,const char* eventfoldername)
1796 //get the tree with tracks of the detector with the given name
1797 //if maketree is true and the tree does not exist, the tree is created
1798 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1799 if (!loader) return NULL;
1800 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1801 return loader->TreeT();
1803 /**************************************************************************/
1805 TTree* AliRunLoader::GetTreeT(const char* detname, Bool_t maketree)
1807 //get the tree with tracks of the detector with the given name
1808 //if maketree is true and the tree does not exist, the tree is created
1809 AliLoader* loader = GetDetectorLoader(detname);
1810 if (!loader) return NULL;
1811 if (!loader->TreeT() && maketree) loader->MakeTree("T");
1812 return loader->TreeT();
1814 /**************************************************************************/
1816 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree,const char* eventfoldername)
1818 //get the tree with particles of the detector with the given name
1819 //if maketree is true and the tree does not exist, the tree is created
1820 AliLoader* loader = GetDetectorLoader(detname,eventfoldername);
1821 if (!loader) return NULL;
1822 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1823 return loader->TreeP();
1825 /**************************************************************************/
1827 TTree* AliRunLoader::GetTreeP(const char* detname, Bool_t maketree)
1829 //get the tree with particles of the detector with the given name
1830 //if maketree is true and the tree does not exist, the tree is created
1831 AliLoader* loader = GetDetectorLoader(detname);
1832 if (!loader) return NULL;
1833 if (!loader->TreeP() && maketree) loader->MakeTree("P");
1834 return loader->TreeP();
1837 /**************************************************************************/
1839 void AliRunLoader::CdGAFile()
1841 //sets gDirectory to galice file
1843 if(fGAFile) fGAFile->cd();
1846 /**************************************************************************/
1848 void AliRunLoader::GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const
1850 //this method looks for all Loaders corresponding
1851 //to names (many) specified in namelist i.e. namelist ("ITS TPC TRD")
1855 strcpy(dets,namelist);//compiler cries when char* = const Option_t*;
1856 dets[strlen(dets)+1] = '\n';//set endl at the end of string
1861 tmp = sscanf(pdet,"%s",buff);//read the string from the input string pdet into buff
1862 if ( (buff[0] == 0) || (tmp == 0) ) break; //if not read
1864 pdet = strstr(pdet,buff) + strlen(buff);//move the input pointer about number of bytes (letters) read
1865 //I am aware that is a little complicated. I don't know the number of spaces between detector names
1866 //so I read the string, than I find where it starts (strstr) and move the pointer about length of a string
1867 //If there is a better way, please write me (Piotr.Skowronski@cern.ch)
1868 //construct the Loader name
1869 TString getname(buff);
1871 AliLoader* loader = GetLoader(getname);//get the Loader
1874 pointerarray.Add(loader);
1878 AliError(Form("Can not find Loader for %s",buff));
1884 /*****************************************************************************/
1886 void AliRunLoader::Clean(const TString& name)
1888 //removes object with given name from event folder and deletes it
1889 if (GetEventFolder() == 0x0) return;
1890 TObject* obj = GetEventFolder()->FindObject(name);
1893 AliDebug(1, Form("name=%s, cleaning %s.",GetName(),name.Data()));
1894 GetEventFolder()->Remove(obj);
1900 /*****************************************************************************/
1902 TTask* AliRunLoader::GetRunDigitizer()
1904 //returns Run Digitizer from folder
1906 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1907 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetDigitizerTaskName());
1908 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1910 /*****************************************************************************/
1912 TTask* AliRunLoader::GetRunSDigitizer()
1914 //returns SDigitizer Task from folder
1916 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1917 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetSDigitizerTaskName());
1918 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1920 /*****************************************************************************/
1922 TTask* AliRunLoader::GetRunReconstructioner()
1924 //returns Reconstructioner Task from folder
1925 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1926 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetReconstructionerTaskName());
1927 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1929 /*****************************************************************************/
1931 TTask* AliRunLoader::GetRunTracker()
1933 //returns Tracker Task from folder
1934 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1935 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetTrackerTaskName());
1936 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1938 /*****************************************************************************/
1940 TTask* AliRunLoader::GetRunPIDTask()
1942 //returns Tracker Task from folder
1943 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1944 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetPIDTaskName());
1945 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1947 /*****************************************************************************/
1949 TTask* AliRunLoader::GetRunQATask()
1951 //returns Quality Assurance Task from folder
1952 TFolder* topf = AliConfig::Instance()->GetTaskFolder();
1955 AliErrorClass("Can not get task folder from AliConfig");
1958 TObject* obj = topf->FindObjectAny(AliConfig::Instance()->GetQATaskName());
1959 return (obj)?dynamic_cast<TTask*>(obj):0x0;
1962 /*****************************************************************************/
1964 void AliRunLoader::SetCompressionLevel(Int_t cl)
1966 //Sets Compression Level in all files
1967 if (fGAFile) fGAFile->SetCompressionLevel(cl);
1968 SetKineComprLevel(cl);
1969 SetTrackRefsComprLevel(cl);
1970 TIter next(fLoaders);
1972 while((loader = (AliLoader*)next()))
1974 loader->SetCompressionLevel(cl);
1977 /**************************************************************************/
1979 void AliRunLoader::SetKineComprLevel(Int_t cl)
1981 //Sets comression level in Kine File
1982 fKineDataLoader->SetCompressionLevel(cl);
1984 /**************************************************************************/
1986 void AliRunLoader::SetTrackRefsComprLevel(Int_t cl)
1988 //Sets comression level in Track Refences File
1989 fTrackRefsDataLoader->SetCompressionLevel(cl);
1991 /**************************************************************************/
1993 void AliRunLoader::UnloadHeader()
1995 //removes TreeE from folder and deletes it
1996 // as well as fHeader object
2001 /**************************************************************************/
2003 void AliRunLoader::UnloadTrigger()
2005 //removes TreeCT from folder and deletes it
2006 // as well as fHeader object
2012 /**************************************************************************/
2014 void AliRunLoader::UnloadKinematics()
2016 //Unloads Kinematics
2017 fKineDataLoader->GetBaseLoader(0)->Unload();
2019 /**************************************************************************/
2021 void AliRunLoader::UnloadTrackRefs()
2023 //Unloads Track Refernces
2024 fTrackRefsDataLoader->GetBaseLoader(0)->Unload();
2026 /**************************************************************************/
2028 void AliRunLoader::UnloadgAlice()
2031 if (gAlice == GetAliRun())
2033 AliDebug(1, "Set gAlice = 0x0");
2034 gAlice = 0x0;//if gAlice is the same that in folder (to be deleted by the way of folder)
2036 AliRun* alirun = GetAliRun();
2037 if (GetEventFolder()) GetEventFolder()->Remove(alirun);
2040 /**************************************************************************/
2042 void AliRunLoader::MakeTrackRefsContainer()
2044 // Makes a tree for Track References
2045 fTrackRefsDataLoader->MakeTree();
2047 /**************************************************************************/
2049 Int_t AliRunLoader::LoadTrackRefs(Option_t* option)
2051 //Load track references from file (opens file and posts tree to folder)
2053 return fTrackRefsDataLoader->GetBaseLoader(0)->Load(option);
2055 /**************************************************************************/
2057 void AliRunLoader::SetDirName(TString& dirname)
2059 //sets directory name
2060 if (dirname.IsNull()) return;
2061 fUnixDirName = dirname;
2062 fKineDataLoader->SetDirName(dirname);
2063 fTrackRefsDataLoader->SetDirName(dirname);
2065 TIter next(fLoaders);
2067 while((loader = (AliLoader*)next()))
2069 loader->SetDirName(dirname);
2073 /*****************************************************************************/
2075 Int_t AliRunLoader::GetFileOffset() const
2077 //returns the file number that is added to the file name for current event
2078 return Int_t(fCurrentEvent/fNEventsPerFile);
2081 /*****************************************************************************/
2082 const TString AliRunLoader::SetFileOffset(const TString& fname)
2084 //adds the the number to the file name at proper place for current event
2085 Long_t offset = (Long_t)GetFileOffset();
2086 if (offset < 1) return fname;
2088 soffset += offset;//automatic conversion to string
2089 TString dotroot(".root");
2090 const TString& offfsetdotroot = offset + dotroot;
2091 TString out = fname;
2092 out = out.ReplaceAll(dotroot,offfsetdotroot);
2093 AliDebug(1, Form(" in=%s out=%s",fname.Data(),out.Data()));
2096 /*****************************************************************************/
2098 void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
2100 //adds the suffix before ".root",
2101 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
2102 //made on Jiri Chudoba demand
2104 TIter next(fLoaders);
2106 while((loader = (AliLoader*)next()))
2108 loader->SetDigitsFileNameSuffix(suffix);
2111 /*****************************************************************************/
2113 TString AliRunLoader::GetFileName() const
2115 //returns name of galice file
2117 if (fGAFile == 0x0) return result;
2118 result = fGAFile->GetName();
2121 /*****************************************************************************/
2123 void AliRunLoader::SetDetectorAddresses()
2125 //calls SetTreeAddress for all detectors
2126 if (GetAliRun()==0x0) return;
2127 TIter next(GetAliRun()->Modules());
2129 while((mod = (AliModule*)next()))
2131 AliDetector* det = dynamic_cast<AliDetector*>(mod);
2132 if (det) det->SetTreeAddress();
2135 /*****************************************************************************/
2137 void AliRunLoader::Synchronize()
2139 //synchrinizes all writtable files
2140 TIter next(fLoaders);
2142 while((loader = (AliLoader*)next()))
2144 loader->Synchronize();
2147 fKineDataLoader->Synchronize();
2148 fTrackRefsDataLoader->Synchronize();
2150 TFile* file = gROOT->GetFile( gSystem->ConcatFileName( fUnixDirName.Data(), fgkDefaultTriggerFileName.Data() ) ) ;
2151 if( file ) file->Flush();
2153 if (fGAFile) fGAFile->Flush();
2155 /*****************************************************************************/
2156 /*****************************************************************************/