]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliRunLoader.h
RemoveDaughters() added. (A. Dainese)
[u/mrichter/AliRoot.git] / STEER / AliRunLoader.h
CommitLineData
88cb7938 1#ifndef ALIRUNLoader_H
2#define ALIRUNLoader_H
3
4//___________________________________________________________________
5/////////////////////////////////////////////////////////////////////
6// //
7// class AliRunLoader //
8// //
9// This class aims to be the only one interface for manging data //
10// It stores Loaders for all modules which knows the filenames //
11// of the data files to be stored. //
12// It aims to substitude AliRun in automatic managing of data //
13// positioning thus there won't be necessity of loading gAlice //
14// from file in order to get fast access to the data //
15// //
16// Logical place to put the specific Loader to the given //
17// detector is detector itself (i.e ITSLoader in ITS). //
18// But, to load detector object one need to load gAlice, and //
19// by the way all other detectors with their geometrieces and //
20// so on. So, if one need to open TPC clusters there is no //
21// principal nedd to read everything. //
22// //
23/////////////////////////////////////////////////////////////////////
24
25#include <TNamed.h>
024a7e64 26
88cb7938 27#include "AliConfig.h"
28#include "AliLoader.h"
29#include "AliDataLoader.h"
4951e003 30#include "AliLog.h"
88cb7938 31
024a7e64 32class TFile;
88cb7938 33class TString;
34class TFolder;
35class TObjArray;
36class TTree;
37class TTask;
38class TParticle;
39
40class AliRun;
41class AliLoader;
42class AliDetector;
43class AliHeader;
44class AliStack;
45class AliRunDigitizer;
9e1ceb13 46class AliCDBEntry;
bacbe0fd 47class AliCentralTrigger;
88cb7938 48
49class AliRunLoader: public TNamed
50{
51 public:
52
53 AliRunLoader();
54 AliRunLoader(const char* topfoldername);
55 AliRunLoader(TFolder* topfolder);
56
57 virtual ~AliRunLoader();
58
59 static AliRunLoader* Open(const char* filename = "galice.root",
e191bb57 60 const char* eventfoldername = AliConfig::GetDefaultEventFolderName(),
88cb7938 61 Option_t* option = "READ");
62
63 Int_t GetEventNumber() const {return fCurrentEvent;}
64
65 Int_t GetEvent(Int_t evno);//sets the event number and reloads data in folders properly
66 Int_t GetNextEvent(){return GetEvent(fCurrentEvent+1);}//gets next event
67 Int_t SetEventNumber(Int_t evno); //cleans folders and sets the root dirs in files (do not reload data)
68 Int_t SetNextEvent(){return SetEventNumber(fCurrentEvent+1);}
69
70 Int_t GetNumberOfEvents();
71
9e1ceb13 72 AliCDBEntry* GetCDBEntry(const char* name) const;
2c8628dd 73
88cb7938 74 void MakeTree(Option_t *option);
75 void MakeHeader();
bacbe0fd 76 void MakeTrigger();
88cb7938 77 void MakeStack();
78
79 Int_t LoadgAlice();
80 Int_t LoadHeader();
81 Int_t LoadKinematics(Option_t* option = "READ");
bacbe0fd 82 Int_t LoadTrigger(Option_t* option = "READ");
88cb7938 83 Int_t LoadTrackRefs(Option_t* option = "READ");
84
85 void UnloadHeader();
bacbe0fd 86 void UnloadTrigger();
88cb7938 87 void UnloadKinematics();
88 void UnloadgAlice();
89 void UnloadTrackRefs();
90
91 void SetKineFileName(const TString& fname){fKineDataLoader->SetFileName(fname);}
92 void SetTrackRefsFileName(const TString& fname){fTrackRefsDataLoader->SetFileName(fname);}
93
94 TTree* TreeE() const; //returns the tree from folder; shortcut method
bacbe0fd 95 TTree* TreeCT() const; //returns the tree from folder; shortcut method
88cb7938 96 AliHeader* GetHeader() const;
bacbe0fd 97 AliCentralTrigger* GetTrigger() const;
88cb7938 98
99 AliStack* Stack() const {return fStack;}
100
101 TTree* TreeK() const; //returns the tree from folder; shortcut method
102 TTree* TreeTR() const; //returns the tree from folder; shortcut method
103
104 AliRun* GetAliRun()const;
105
88cb7938 106 Int_t WriteHeader(Option_t* opt="");
bacbe0fd 107 Int_t WriteTrigger(Option_t* opt="");
88cb7938 108 Int_t WriteAliRun(Option_t* opt="");
109 Int_t WriteKinematics(Option_t* opt="");
110 Int_t WriteTrackRefs(Option_t* opt="");
111 Int_t WriteRunLoader(Option_t* opt="");
112
113 Int_t WriteHits(Option_t* opt="");
114 Int_t WriteSDigits(Option_t* opt="");
115 Int_t WriteDigits(Option_t* opt="");
116 Int_t WriteRecPoints(Option_t* opt="");
117 Int_t WriteTracks(Option_t* opt="");
118
f49dcb04 119 Int_t LoadHits(Option_t* detectors = "all",Option_t* opt = "READ");
120 Int_t LoadSDigits(Option_t* detectors = "all",Option_t* opt = "READ");
121 Int_t LoadDigits(Option_t* detectors = "all",Option_t* opt = "READ");
122 Int_t LoadRecPoints(Option_t* detectors = "all",Option_t* opt = "READ");
123 Int_t LoadTracks(Option_t* detectors = "all",Option_t* opt = "READ");
124 Int_t LoadRecParticles(Option_t* detectors = "all",Option_t* opt = "READ");
88cb7938 125
1bb20a37 126 void UnloadHits(Option_t* detectors = "all");
127 void UnloadSDigits(Option_t* detectors = "all");
128 void UnloadDigits(Option_t* detectors = "all");
129 void UnloadRecPoints(Option_t* detectors = "all");
130 void UnloadTracks(Option_t* detectors = "all");
131 void UnloadRecParticles(Option_t* detectors = "all");
132 void UnloadAll(Option_t* detectors = "all");
88cb7938 133
134 void AddLoader(AliLoader* loader);
135 void AddLoader(AliDetector* det);
136 AliLoader* GetLoader(const char* detname) const;
137 AliLoader* GetLoader(AliDetector* det) const;
e191bb57 138 Int_t SetEventFolderName(const TString& name = AliConfig::GetDefaultEventFolderName());//sets top folder name for this run; of alread
88cb7938 139 void CleanFolders();//removes all abjects from folder structure
140 void CleanDetectors();
141 void CleanKinematics(){Clean(fgkKineContainerName);}
142 void CleanTrackRefs(){Clean(fgkTrackRefsContainerName);}
143
144 void RemoveEventFolder(); //remove folder structure from top folder
145 void SetCompressionLevel(Int_t cl);
146 void SetKineComprLevel(Int_t cl);
147 void SetTrackRefsComprLevel(Int_t cl);
148
149 TFolder* GetEventFolder() const {return fEventFolder;}
150 void CdGAFile();
151
152 void MakeTrackRefsContainer();
153 void SetDirName(TString& dirname);
154 Int_t GetFileOffset() const;
155 void SetNumberOfEventsPerFile(Int_t nevpf){fNEventsPerFile = nevpf;}
156
157 void SetDigitsFileNameSuffix(const TString& suffix);//adds the suffix before ".root",
158 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
159 //made on Jiri Chudoba demand
160 TString GetFileName() const;//returns name of galice file
161 const TObjArray* GetArrayOfLoaders() const {return fLoaders;}
024a7e64 162 void Cd(){fgRunLoader = this;}
f0f6f856 163 void Synchronize();
164
1bb20a37 165 AliLoader* GetDetectorLoader(const char* detname);
166 TTree* GetTreeH(const char* detname, Bool_t maketree);
167 TTree* GetTreeS(const char* detname, Bool_t maketree);
168 TTree* GetTreeD(const char* detname, Bool_t maketree);
169 TTree* GetTreeR(const char* detname, Bool_t maketree);
170 TTree* GetTreeT(const char* detname, Bool_t maketree);
171 TTree* GetTreeP(const char* detname, Bool_t maketree);
d0d4a6b3 172
173 /******************************************/
174 /***** Public S T A T I C Stuff *******/
175 /******************************************/
176 static AliRunLoader* GetRunLoader(const char* eventfoldername);
177 static AliRunLoader* GetRunLoader(){return fgRunLoader;}
178 static AliLoader* GetDetectorLoader(const char* detname, const char* eventfoldername);
179 static TTree* GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername);
180 static TTree* GetTreeS(const char* detname, Bool_t maketree, const char* eventfoldername);
181 static TTree* GetTreeD(const char* detname, Bool_t maketree, const char* eventfoldername);
182 static TTree* GetTreeR(const char* detname, Bool_t maketree, const char* eventfoldername);
183 static TTree* GetTreeT(const char* detname, Bool_t maketree, const char* eventfoldername);
184 static TTree* GetTreeP(const char* detname, Bool_t maketree, const char* eventfoldername);
185
186// static AliRunDigitizer* GetRunDigitizer();
187// Tasks are supposed to be singletons, that is why following methods are static
188 static TTask* GetRunDigitizer(); //
189 static TTask* GetRunSDigitizer(); //
190 static TTask* GetRunReconstructioner(); //
191 static TTask* GetRunTracker(); //
192 static TTask* GetRunPIDTask(); //
193 static TTask* GetRunQATask(); //
024a7e64 194
195 static TString GetRunLoaderName () {return fgkRunLoaderName;}
196 static TString GetHeaderContainerName () {return fgkHeaderContainerName;}
bacbe0fd 197 static TString GetTriggerContainerName () {return fgkTriggerContainerName;}
024a7e64 198 static TString GetKineContainerName () {return fgkKineContainerName;}
199 static TString GetTrackRefsContainerName () {return fgkTrackRefsContainerName;}
200 static TString GetHeaderBranchName () {return fgkHeaderBranchName;}
bacbe0fd 201 static TString GetTriggerBranchName () {return fgkTriggerBranchName;}
024a7e64 202 static TString GetKineBranchName () {return fgkKineBranchName;}
bacbe0fd 203 static TString GetTriggerFileName() { return fgkDefaultTriggerFileName; }
024a7e64 204 static TString GetGAliceName () {return fgkGAliceName;}
d0d4a6b3 205
024a7e64 206protected:
88cb7938 207 /**********************************************/
208 /************ PROTECTED ***************/
209 /********* D A T A ************/
210 /**********************************************/
211
212 TObjArray *fLoaders; // List of Detectors
213 TFolder *fEventFolder; //!top folder for this run
214
215 Int_t fCurrentEvent;//!Number of current event
216
bacbe0fd 217 TFile *fGAFile;//! pointer to main file with AliRun and Run Loader -> galice.root
218 AliHeader *fHeader;//! pointer to header
219 AliStack *fStack; //! pointer to stack
220 AliCentralTrigger *fCTrigger; //! pointer to CEntral Trigger Processor
88cb7938 221
222 AliDataLoader *fKineDataLoader;// kinematics data loader
223 AliDataLoader *fTrackRefsDataLoader;//track reference data loader
224
225 Int_t fNEventsPerFile; //defines number of events stored per one file
226 TString fUnixDirName; //! name of unix path to directory that contains event
227 static const TString fgkDefaultKineFileName;//default file name with kinamatics
228 static const TString fgkDefaultTrackRefsFileName;//default file name with kinamatics
bacbe0fd 229 static const TString fgkDefaultTriggerFileName;//default file name with trigger
88cb7938 230
231
232 /*********************************************/
233 /************ PROTECTED **************/
234 /********* M E T H O D S ***********/
235 /*********************************************/
236
237 void SetGAliceFile(TFile* gafile);//sets the pointer to gAlice file
238 Int_t OpenKineFile(Option_t* opt);
239 Int_t OpenTrackRefsFile(Option_t* opt);
240
241 Int_t OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl);
242 void SetUnixDir(const TString& udirname);
243 const TString SetFileOffset(const TString& fname);//adds the proper number before .root
244 void SetDetectorAddresses();
245
246 private:
dc86eb51 247 AliRunLoader(const AliRunLoader &r); //Not implemented
248 AliRunLoader & operator = (const AliRunLoader &); //Not implemented
249
88cb7938 250 void GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const;
251
252 void CleanHeader(){Clean(fgkHeaderContainerName);}
bacbe0fd 253 void CleanTrigger(){Clean(fgkTriggerContainerName);}
88cb7938 254 void Clean(const TString& name);
255
256 Int_t SetEvent();
257
d0d4a6b3 258 static AliRunLoader* fgRunLoader; //pointer to the AliRunLoader instance
88cb7938 259
024a7e64 260private:
024a7e64 261
262 static const TString fgkRunLoaderName; //default name of the run loader
263 static const TString fgkHeaderContainerName; //default name of the kinematics container (TREE) name - TreeE
bacbe0fd 264 static const TString fgkTriggerContainerName; //default name of the trigger container (TREE) name - TreeCT
024a7e64 265 static const TString fgkKineContainerName; //default name of the kinematics container (TREE) name - TreeK
266 static const TString fgkTrackRefsContainerName; //default name of the track references container (TREE) name - TreeTR
267 static const TString fgkHeaderBranchName; //default name of the branch containing the header
bacbe0fd 268 static const TString fgkTriggerBranchName; //default name of the branch containing the trigger
024a7e64 269 static const TString fgkKineBranchName; //default name of the branch with kinematics
270 static const TString fgkGAliceName; //default name for gAlice file
88cb7938 271
bacbe0fd 272 ClassDef(AliRunLoader,2)
88cb7938 273};
274
275#endif