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