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