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