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