]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliLoader.h
Correct initialization of static data members
[u/mrichter/AliRoot.git] / STEER / AliLoader.h
CommitLineData
88cb7938 1#ifndef ALILOADER_H
2#define ALILOADER_H
3
4#include <TFolder.h>
5#include <TObjArray.h>
6
d0d4a6b3 7//#include <AliConfig.h>
88cb7938 8#include "AliDataLoader.h"
9
10class TString;
11class TFile;
12class TTree;
13class TTask;
14class AliRunLoader;
15class AliDigitizer;
16class TDirectory;
17
18
19//___________________________________________________________________
20/////////////////////////////////////////////////////////////////////
21// //
22// class AliLoader //
23// //
24// Base class for Loaders. //
25// Loader provides base I/O fascilities for "standard" data. //
26// Each detector has a laoder data member. //
27// Loader is always accessible via folder structure as well //
28// //
29/////////////////////////////////////////////////////////////////////
30
31class AliLoader: public TNamed
32 {
33 public:
34 AliLoader();
35 AliLoader(const Char_t *detname,const Char_t *eventfoldername); //contructor with name of the top folder of the tree
36 AliLoader(const Char_t *detname,TFolder* eventfolder);
d0d4a6b3 37 AliLoader(const AliLoader& source); //copy constructor
38 AliLoader& operator=(const AliLoader& source); //assignment operator
88cb7938 39
40 virtual ~AliLoader();//-----------------
41
42 virtual Int_t GetEvent();//changes to root directory
43 //relies on the event number defined in gAlice
44 virtual Int_t SetEvent();//basically the same that GetEvent but do not post data to folders
45 virtual void MakeTree(Option_t* opt);
46
47 //these methods are responsible for reading data
48 // 1. Opens the file (accordingly to gAlice->GetEvNumber()/Nevents per File
49 // 2. Changes to proper ROOT directory
50 // 3. Retrives data and posts to folders
51 //options:
52 // "" - readonly file
53 // "update" - update file
54 // "recreate"
55 AliDataLoader* GetHitsDataLoader() const {return (AliDataLoader*)fDataLoaders->At(kHits);}
56 AliDataLoader* GetSDigitsDataLoader() const {return (AliDataLoader*)fDataLoaders->At(kSDigits);}
57 AliDataLoader* GetDigitsDataLoader() const {return (AliDataLoader*)fDataLoaders->At(kDigits);}
58 AliDataLoader* GetRecPointsDataLoader()const {return (AliDataLoader*)fDataLoaders->At(kRecPoints);}
59 AliDataLoader* GetTracksDataLoader() const {return (AliDataLoader*)fDataLoaders->At(kTracks);}
60 AliDataLoader* GetRecParticlesDataLoader()const {return (AliDataLoader*)fDataLoaders->At(kRecParticles);}
61
62 AliDataLoader* GetDataLoader(const char* name);
63
64
65 Int_t SetEventFolder(TFolder* eventfolder);//sets the event folder
66 Int_t Register(TFolder* eventFolder);//triggers creation of subfolders for a given detector
67
68 TFolder* GetTopFolder(); //returns top aliroot folder
69 TFolder* GetEventFolder();//returns the folder that event is sitting
70 TFolder* GetDataFolder(); //returns the folder that hits, sdigits, etc are sitting (this contains folders named like detectors)
71 TFolder* GetDetectorDataFolder();//returns the folder that hits, sdigits, etc
72 //are sitting for a given detector (subfolder of Data Folder)
73 TFolder* GetModulesFolder();
74 TFolder* GetTasksFolder();
75 TFolder* GetQAFolder();
76
d0d4a6b3 77 TTask* SDigitizer() const;//return detector SDigitizer()
78 AliDigitizer* Digitizer() const;
79 TTask* Reconstructioner() const;
80 TTask* Tracker() const;
81 TTask* PIDTask() const;
82 TTask* QAtask(const char* name = 0x0) const;
88cb7938 83
84 TObject** SDigitizerRef();
85 TObject** DigitizerRef();
86 TObject** ReconstructionerRef();
87 TObject** TrackerRef();
88 TObject** PIDTaskRef();
89
f2a509af 90 virtual void MakeHitsContainer(){GetHitsDataLoader()->MakeTree();}
91 virtual void MakeSDigitsContainer(){GetSDigitsDataLoader()->MakeTree();}
92 virtual void MakeDigitsContainer(){GetDigitsDataLoader()->MakeTree();}
88cb7938 93 virtual void MakeRecPointsContainer(){GetRecPointsDataLoader()->MakeTree();}
94 virtual void MakeTracksContainer(){GetTracksDataLoader()->MakeTree();}
95 virtual void MakeRecParticlesContainer(){GetRecParticlesDataLoader()->MakeTree();}
96
97 virtual void CleanFolders();
98 virtual void CloseFiles();
99
100 virtual Int_t PostSDigitizer(TTask* sdzer);//adds it to Run SDigitizer
101 virtual Int_t PostDigitizer(AliDigitizer* task);
102 virtual Int_t PostReconstructioner(TTask* task);
103 virtual Int_t PostTracker(TTask* task);
104 virtual Int_t PostPIDTask(TTask* task);
105
106 virtual Int_t WriteSDigitizer(Option_t* opt=""){return GetSDigitsDataLoader()->GetBaseTaskLoader()->WriteData(opt);}
107 virtual Int_t WriteDigitizer(Option_t* opt=""){return GetDigitsDataLoader()->GetBaseTaskLoader()->WriteData(opt);}
108 virtual Int_t WriteReconstructioner(Option_t* opt=""){return GetRecPointsDataLoader()->GetBaseTaskLoader()->WriteData(opt);}
109 virtual Int_t WriteTracker(Option_t* opt=""){return GetTracksDataLoader()->GetBaseTaskLoader()->WriteData(opt);}
110 virtual Int_t WritePIDTask(Option_t* opt=""){return GetRecParticlesDataLoader()->GetBaseTaskLoader()->WriteData(opt);}
111
d0d4a6b3 112 TTree* TreeH() const
113 {return GetHitsDataLoader()->Tree();} //returns the tree from folder; shortcut method
114 TTree* TreeS() const
115 {return GetSDigitsDataLoader()->Tree();} //returns the tree from folder; shortcut method
116 TTree* TreeD() const
117 {return GetDigitsDataLoader()->Tree();} //returns the tree from folder; shortcut method
118 TTree* TreeR() const
119 {return GetRecPointsDataLoader()->Tree();} //returns the tree from folder; shortcut method
120 TTree* TreeT() const
121 {return GetTracksDataLoader()->Tree();} //returns the tree from folder; shortcut method
122 TTree* TreeP() const
123 {return GetRecParticlesDataLoader()->Tree();} //returns the tree from folder; shortcut method
88cb7938 124
0798b21e 125 Int_t LoadHits(Option_t* opt=""){Int_t status = GetHitsDataLoader()->Load(opt);SetTAddrInDet();return status;}
126 Int_t LoadSDigits(Option_t* opt=""){Int_t status = GetSDigitsDataLoader()->Load(opt);SetTAddrInDet(); return status;}
127 Int_t LoadDigits(Option_t* opt=""){Int_t status = GetDigitsDataLoader()->Load(opt);SetTAddrInDet();return status;}
88cb7938 128 Int_t LoadRecPoints(Option_t* opt=""){return GetRecPointsDataLoader()->Load(opt);}
129 Int_t LoadTracks(Option_t* opt=""){return GetTracksDataLoader()->Load(opt);}
130 Int_t LoadRecParticles(Option_t* opt=""){return GetRecParticlesDataLoader()->Load(opt);}
131
132 Int_t LoadSDigitizer(Option_t* opt=""){return GetSDigitsDataLoader()->GetBaseTaskLoader()->Load(opt);}
133 Int_t LoadDigitizer(Option_t* opt=""){return GetDigitsDataLoader()->GetBaseTaskLoader()->Load(opt);}
134 Int_t LoadReconstructioner(Option_t* opt=""){return GetRecPointsDataLoader()->GetBaseTaskLoader()->Load(opt);}
135 Int_t LoadTracker(Option_t* opt=""){return GetTracksDataLoader()->GetBaseTaskLoader()->Load(opt);}
136 Int_t LoadPIDTask(Option_t* opt=""){return GetRecParticlesDataLoader()->GetBaseTaskLoader()->Load(opt);}
137
138 void UnloadHits(){GetHitsDataLoader()->Unload();}
139 void UnloadSDigits(){GetSDigitsDataLoader()->Unload();}
140 void UnloadDigits(){GetDigitsDataLoader()->Unload();}
141 void UnloadRecPoints(){GetRecPointsDataLoader()->Unload();}
142 void UnloadTracks(){GetTracksDataLoader()->Unload();}
143 void UnloadRecParticles(){GetRecParticlesDataLoader()->Unload();}
1bb20a37 144 void UnloadAll();
88cb7938 145
146 virtual Int_t ReloadHits(){return GetHitsDataLoader()->Reload();} //unload and load again Hits
147 virtual Int_t ReloadSDigits(){return GetSDigitsDataLoader()->Reload();} //unload and load again
148 virtual Int_t ReloadDigits(){return GetDigitsDataLoader()->Reload();} //unload and load again
149 virtual Int_t ReloadRecPoints(){return GetRecPointsDataLoader()->Reload();} //unload and load again
150 virtual Int_t ReloadTracks(){return GetTracksDataLoader()->Reload();} //unload and load again
151 virtual Int_t ReloadRecParticles(){return GetRecParticlesDataLoader()->Reload();} //unload and load again
152 virtual Int_t ReloadAll(); //unload and load again everything that was loaded
153
154 //these methods writes object from folder to proper file
155 virtual Int_t WriteHits(Option_t* opt="");
156 virtual Int_t WriteSDigits(Option_t* opt="");
157 virtual Int_t WriteDigits(Option_t* opt=""){return GetDigitsDataLoader()->WriteData(opt);}
158 virtual Int_t WriteRecPoints(Option_t* opt=""){return GetRecPointsDataLoader()->WriteData(opt);}
159 virtual Int_t WriteTracks(Option_t* opt=""){return GetTracksDataLoader()->WriteData(opt);}
160 virtual Int_t WriteRecParticles(Option_t* opt=""){return GetRecParticlesDataLoader()->WriteData(opt);}
161
162
163 //void SetTopFolder(TString& str){}; //Sets root top folder for the run
164
165 void SetHitsFileName(const TString& fname){GetHitsDataLoader()->SetFileName(fname);}
166 void SetSDigitsFileName(const TString& fname){GetSDigitsDataLoader()->SetFileName(fname);}
167 void SetDigitsFileName(const TString& fname){GetDigitsDataLoader()->SetFileName(fname);}
168 void SetRecPointsFileName(const TString& fname){GetRecPointsDataLoader()->SetFileName(fname);}
169 void SetTracksFileName(const TString& fname){GetTracksDataLoader()->SetFileName(fname);}
170 void SetRecParticlesFileName(const TString& fname){GetRecParticlesDataLoader()->SetFileName(fname);}
171
d0d4a6b3 172 const TString& GetHitsFileName() const
173 {return GetHitsDataLoader()->GetFileName();}
174 const TString& GetSDigitsFileName() const
175 {return GetSDigitsDataLoader()->GetFileName();}
176 const TString& GetDigitsFileName() const
177 {return GetDigitsDataLoader()->GetFileName();}
178 const TString& GetRecPointsFileName() const
179 {return GetRecPointsDataLoader()->GetFileName();}
180 const TString& GetTracksFileName() const
181 {return GetTracksDataLoader()->GetFileName();}
182 const TString& GetRecParticlesFileName() const
183 {return GetRecParticlesDataLoader()->GetFileName();}
88cb7938 184
185 virtual void CleanHits() {GetHitsDataLoader()->Clean();} //cleans hits from folder
186 virtual void CleanSDigits() {GetSDigitsDataLoader()->Clean();} //cleans digits from folder
187 virtual void CleanDigits() {GetDigitsDataLoader()->Clean();} //cleans sdigits from folder
188 virtual void CleanRecPoints(){GetRecPointsDataLoader()->Clean();} //cleans rec. points from folder
189 virtual void CleanTracks() {GetTracksDataLoader()->Clean();} //cleans tracks from folder
190
191 virtual void CleanSDigitizer(); //cleans SDigitizer from folder
192 virtual void CleanDigitizer(); //cleans Digitizer from folder
193 virtual void CleanReconstructioner(); //cleans Reconstructions (clusterizer) from folder
194 virtual void CleanTracker(); //cleans tracker from folder
195 virtual void CleanPIDTask(); //cleans Reconstructions (clusterizer) from folder
196
197 virtual void SetHitsFileOption(Option_t* newopt){GetHitsDataLoader()->SetFileOption(newopt);} //Sets Hits File Option in open
198 virtual void SetSDigitsFileOption(Option_t* newopt){GetSDigitsDataLoader()->SetFileOption(newopt);} //Sets S. Digits File Option in open
199 virtual void SetDigitsFileOption(Option_t* newopt){GetDigitsDataLoader()->SetFileOption(newopt);} //Sets Digits File Option in open
200 virtual void SetRecPointsFileOption(Option_t* newopt){GetRecPointsDataLoader()->SetFileOption(newopt);}//Sets Rec Ponoints File Option in open
201 virtual void SetTracksFileOption(Option_t* newopt){GetTracksDataLoader()->SetFileOption(newopt);} //Sets Tracks File Option in open
202 virtual void SetRecParticlesFileOption(Option_t* newopt){GetRecParticlesDataLoader()->SetFileOption(newopt);}//Sets Rec Ponoints File Option in open
203
204 virtual void SetHitsComprLevel(Int_t cl){GetHitsDataLoader()->SetCompressionLevel(cl);}
205 virtual void SetDigitsComprLevel(Int_t cl){GetSDigitsDataLoader()->SetCompressionLevel(cl);}
206 virtual void SetSDigitsComprLevel(Int_t cl){GetDigitsDataLoader()->SetCompressionLevel(cl);}
207 virtual void SetRecPointsComprLevel(Int_t cl){GetRecPointsDataLoader()->SetCompressionLevel(cl);}
208 virtual void SetTracksComprLevel(Int_t cl){GetTracksDataLoader()->SetCompressionLevel(cl);}
209 virtual void SetRecParticlesComprLevel(Int_t cl){GetRecParticlesDataLoader()->SetCompressionLevel(cl);}
210
211 virtual void SetCompressionLevel(Int_t cl);//Sets compression level in all the files
212 void SetDirName(TString& name);//sets the directory name for all the I/O environment
213
214 const TString& GetDetectorName() const{return fDetectorName;}//returns the name of the detector
215 AliRunLoader* GetRunLoader();//gets the run-getter from event folder
216
217 void SetDigitsFileNameSuffix(const TString& suffix);//adds the suffix before ".root",
218 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
219 //made on Jiri Chudoba demand
f0f6f856 220 void Synchronize();
d0d4a6b3 221
222 /**********************************************/
223 /*********** P U B L I C **************/
224 /********* S T A T I C ************/
225 /********* METHODS ************/
226 /********* They are used by ************/
227 /*********** AliRunLoader as well**************/
228 /**********************************************/
229 static TDirectory* ChangeDir(TFile* file, Int_t eventno); //changes the root directory in "file" to directory corresponing to eventno
230 static Bool_t TestFileOption(Option_t* opt);//checks is file is created from scratch
231 static Bool_t IsOptionWritable(const TString& opt);
232
233 static Int_t GetDebug() {return fgDebug;}
234 static void SetDebug(Int_t deb = 1){fgDebug = deb;}//Sets debugging information
f0f6f856 235
88cb7938 236 protected:
237
238 /*********************************************/
239 /************ PROTECTED **************/
240 /********* M E T H O D S ***********/
241 /*********************************************/
242 enum EDataTypes{kHits = 0,kSDigits,kDigits,kRecPoints,kTracks,kRecParticles,kNDataTypes};
243
244 //Opens hits file and jumps to directory cooresponding to current event.
245 //If dir does not exists try to create it
246 //opt is passed to TFile::Open
247 //reads data from the file and posts them into folder
248
249
250 virtual Int_t PostHits(){return GetHitsDataLoader()->GetBaseLoader(0)->Load();}
251 virtual Int_t PostSDigits(){return GetSDigitsDataLoader()->GetBaseLoader(0)->Load();}
252 virtual Int_t PostDigits(){return GetDigitsDataLoader()->GetBaseLoader(0)->Load();}
253 virtual Int_t PostRecPoints(){return GetRecPointsDataLoader()->GetBaseLoader(0)->Load();}
254 virtual Int_t PostTracks(){return GetTracksDataLoader()->GetBaseLoader(0)->Load();}
255 virtual Int_t PostRecParticles(){return GetRecParticlesDataLoader()->GetBaseLoader(0)->Load();}
256
257 void Clean();//calls clean for data loaders
258 void Clean(const TString& name);//removes and deletes object from data folder
259
260
d0d4a6b3 261 TString GetUnixDir() const;
88cb7938 262 TObject* GetDetectorData(const char* name){return GetDetectorDataFolder()->FindObject(name);}
263 TObject** GetDetectorDataRef(TObject* obj);
264
265 void InitDefaults();
266 void ResetDataInfo();
267
268 void SetTAddrInDet();//Call SetTreeAddress for corresponding detector
269
270 /**********************************************/
271 /************ PROTECTED ***************/
272 /********* D A T A ************/
273 /**********************************************/
274
d0d4a6b3 275 TObjArray* fDataLoaders; // array with data loaders each corresponds to
276 // one data type (Hits, Digits, ...)
88cb7938 277
278 TString fDetectorName;//detector name that this loader belongs to
279
280 TFolder* fEventFolder; //! Folder with data that changes from event to event, even in single run
281 TFolder* fDataFolder; //! Folder with data (hits, sdigits, etc, grouped in folders named like detectors
282 TFolder* fDetectorDataFolder;//!Folder that contains the detector data
283 TFolder* fModuleFolder; //!Folder that contains the modules
284
285 TFolder* fTasksFolder; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
286 TFolder* fQAFolder; //!Folder that contains the QA objects
287
288 // file option varible was introduced because if TFile is created with "recreate"
289 // stored option in TFile is "CREATE". We need to remeber "recreate" for
290 // Max events per file functionality
291
292 static const TString fgkDefaultHitsContainerName;//default name of conatiner (TREE) for hits
293 static const TString fgkDefaultDigitsContainerName;//default name of conatiner (TREE) for digits
294 static const TString fgkDefaultSDigitsContainerName;//default name of conatiner (TREE) for Sdigits
295 static const TString fgkDefaultRecPointsContainerName;//default name of conatiner (TREE) for Rec Points
296 static const TString fgkDefaultTracksContainerName;//default name of conatiner (TREE) for Tracks
297 static const TString fgkDefaultRecParticlesContainerName;//default name of conatiner (TREE) for Reconstructed Particles
298 static const TString fgkLoaderBaseName;//base name of Loader: fDetectorName+fgkLoaderBaseName. i.e. PHOSLoader
299
300 private:
301 //descendant classes should
302 //use protected interface methods to access these folders
303
88cb7938 304 static Int_t fgDebug; //debug flag for loaders
305
306 ClassDef(AliLoader,2)
307 };
308/******************************************************************/
309/************************ I N L I N E S ***************************/
310/******************************************************************/
311
312inline TFolder* AliLoader::GetDetectorDataFolder()
313 {
314 //helper function which returns the folder of name "name" in data folder
315 if(!fDetectorDataFolder)
316 {
317 fDetectorDataFolder = dynamic_cast<TFolder*>(GetDataFolder()->FindObject(fDetectorName.Data()));
318 if(!fDetectorDataFolder)
319 {
320 Fatal("GetDetectorDataFolder",
321 "Can not find folder %s in folder %s. Aborting",
322 fDetectorName.Data(),GetDataFolder()->GetName());
323 return 0x0;
324 }
325
326 }
327 return fDetectorDataFolder;
328 }
329
330#endif