7 //#include <AliConfig.h>
8 #include "AliDataLoader.h"
19 //___________________________________________________________________
20 /////////////////////////////////////////////////////////////////////
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 //
29 /////////////////////////////////////////////////////////////////////
31 class AliLoader: public TNamed
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 AliLoader(const AliLoader& source); //copy constructor
38 AliLoader& operator=(const AliLoader& source); //assignment operator
40 virtual ~AliLoader();//-----------------
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);
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
53 // "update" - update file
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);}
62 AliDataLoader* GetDataLoader(const char* name);
65 Int_t SetEventFolder(TFolder* eventfolder);//sets the event folder
66 Int_t Register(TFolder* eventFolder);//triggers creation of subfolders for a given detector
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();
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;
84 TObject** SDigitizerRef();
85 TObject** DigitizerRef();
86 TObject** ReconstructionerRef();
87 TObject** TrackerRef();
88 TObject** PIDTaskRef();
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();}
97 virtual void CleanFolders();
98 virtual void CloseFiles();
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;
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);}
118 {return GetHitsDataLoader()->Tree();} //returns the tree from folder; shortcut method
120 {return GetSDigitsDataLoader()->Tree();} //returns the tree from folder; shortcut method
122 {return GetDigitsDataLoader()->Tree();} //returns the tree from folder; shortcut method
124 {return GetRecPointsDataLoader()->Tree();} //returns the tree from folder; shortcut method
126 {return GetTracksDataLoader()->Tree();} //returns the tree from folder; shortcut method
128 {return GetRecParticlesDataLoader()->Tree();} //returns the tree from folder; shortcut method
130 Int_t LoadHits(Option_t* opt=""){
131 Int_t status = GetHitsDataLoader()->Load(opt);
135 Int_t LoadSDigits(Option_t* opt=""){
136 Int_t status = GetSDigitsDataLoader()->Load(opt);
140 Int_t LoadDigits(Option_t* opt=""){
141 Int_t status = GetDigitsDataLoader()->Load(opt);
145 Int_t LoadRecPoints(Option_t* opt="") const {
146 return GetRecPointsDataLoader()->Load(opt);
148 Int_t LoadTracks(Option_t* opt="") const {
149 return GetTracksDataLoader()->Load(opt);
151 Int_t LoadRecParticles(Option_t* opt="") const {
152 return GetRecParticlesDataLoader()->Load(opt);
155 Int_t LoadSDigitizer(Option_t* opt="") const {
156 return GetSDigitsDataLoader()->GetBaseTaskLoader()->Load(opt);
158 Int_t LoadDigitizer(Option_t* opt="") const {
159 return GetDigitsDataLoader()->GetBaseTaskLoader()->Load(opt);
161 Int_t LoadReconstructioner(Option_t* opt="") const {
162 return GetRecPointsDataLoader()->GetBaseTaskLoader()->Load(opt);
164 Int_t LoadTracker(Option_t* opt="") const {
165 return GetTracksDataLoader()->GetBaseTaskLoader()->Load(opt);
167 Int_t LoadPIDTask(Option_t* opt="") const {
168 return GetRecParticlesDataLoader()->GetBaseTaskLoader()->Load(opt);
171 void UnloadHits() const {GetHitsDataLoader()->Unload();}
172 void UnloadSDigits() const {GetSDigitsDataLoader()->Unload();}
173 void UnloadDigits() const {GetDigitsDataLoader()->Unload();}
174 void UnloadRecPoints() const{GetRecPointsDataLoader()->Unload();}
175 void UnloadTracks() const {GetTracksDataLoader()->Unload();}
176 void UnloadRecParticles() const {GetRecParticlesDataLoader()->Unload();}
179 virtual Int_t ReloadHits() const {return GetHitsDataLoader()->Reload();} //unload and load again Hits
180 virtual Int_t ReloadSDigits() const {return GetSDigitsDataLoader()->Reload();} //unload and load again
181 virtual Int_t ReloadDigits() const {return GetDigitsDataLoader()->Reload();} //unload and load again
182 virtual Int_t ReloadRecPoints() const {return GetRecPointsDataLoader()->Reload();} //unload and load again
183 virtual Int_t ReloadTracks() const {return GetTracksDataLoader()->Reload();} //unload and load again
184 virtual Int_t ReloadRecParticles() const {return GetRecParticlesDataLoader()->Reload();} //unload and load again
185 virtual Int_t ReloadAll(); //unload and load again everything that was loaded
187 //these methods writes object from folder to proper file
188 virtual Int_t WriteHits(Option_t* opt="") const;
189 virtual Int_t WriteSDigits(Option_t* opt="") const;
190 virtual Int_t WriteDigits(Option_t* opt="") const {return GetDigitsDataLoader()->WriteData(opt);}
191 virtual Int_t WriteRecPoints(Option_t* opt="") const {return GetRecPointsDataLoader()->WriteData(opt);}
192 virtual Int_t WriteTracks(Option_t* opt="") const {return GetTracksDataLoader()->WriteData(opt);}
193 virtual Int_t WriteRecParticles(Option_t* opt="") const {return GetRecParticlesDataLoader()->WriteData(opt);}
196 //void SetTopFolder(TString& str){}; //Sets root top folder for the run
198 void SetHitsFileName(const TString& fname) const
199 {GetHitsDataLoader()->SetFileName(fname);}
200 void SetSDigitsFileName(const TString& fname) const
201 {GetSDigitsDataLoader()->SetFileName(fname);}
202 void SetDigitsFileName(const TString& fname) const
203 {GetDigitsDataLoader()->SetFileName(fname);}
204 void SetRecPointsFileName(const TString& fname) const
205 {GetRecPointsDataLoader()->SetFileName(fname);}
206 void SetTracksFileName(const TString& fname) const
207 {GetTracksDataLoader()->SetFileName(fname);}
208 void SetRecParticlesFileName(const TString& fname) const
209 {GetRecParticlesDataLoader()->SetFileName(fname);}
211 const TString& GetHitsFileName() const
212 {return GetHitsDataLoader()->GetFileName();}
213 const TString& GetSDigitsFileName() const
214 {return GetSDigitsDataLoader()->GetFileName();}
215 const TString& GetDigitsFileName() const
216 {return GetDigitsDataLoader()->GetFileName();}
217 const TString& GetRecPointsFileName() const
218 {return GetRecPointsDataLoader()->GetFileName();}
219 const TString& GetTracksFileName() const
220 {return GetTracksDataLoader()->GetFileName();}
221 const TString& GetRecParticlesFileName() const
222 {return GetRecParticlesDataLoader()->GetFileName();}
224 virtual void CleanHits() const
225 {GetHitsDataLoader()->Clean();} //cleans hits from folder
226 virtual void CleanSDigits() const
227 {GetSDigitsDataLoader()->Clean();} //cleans digits from folder
228 virtual void CleanDigits() const
229 {GetDigitsDataLoader()->Clean();} //cleans sdigits from folder
230 virtual void CleanRecPoints() const
231 {GetRecPointsDataLoader()->Clean();} //cleans rec. points from folder
232 virtual void CleanTracks() const
233 {GetTracksDataLoader()->Clean();} //cleans tracks from folder
235 virtual void CleanSDigitizer(); //cleans SDigitizer from folder
236 virtual void CleanDigitizer(); //cleans Digitizer from folder
237 virtual void CleanReconstructioner(); //cleans Reconstructions (clusterizer) from folder
238 virtual void CleanTracker(); //cleans tracker from folder
239 virtual void CleanPIDTask(); //cleans Reconstructions (clusterizer) from folder
241 virtual void SetHitsFileOption(Option_t* newopt) const
242 {GetHitsDataLoader()->SetFileOption(newopt);} //Sets Hits File Option in open
243 virtual void SetSDigitsFileOption(Option_t* newopt) const
244 {GetSDigitsDataLoader()->SetFileOption(newopt);} //Sets S. Digits File Option in open
245 virtual void SetDigitsFileOption(Option_t* newopt) const
246 {GetDigitsDataLoader()->SetFileOption(newopt);} //Sets Digits File Option in open
247 virtual void SetRecPointsFileOption(Option_t* newopt) const
248 {GetRecPointsDataLoader()->SetFileOption(newopt);}//Sets Rec Ponoints File Option in open
249 virtual void SetTracksFileOption(Option_t* newopt) const
250 {GetTracksDataLoader()->SetFileOption(newopt);} //Sets Tracks File Option in open
251 virtual void SetRecParticlesFileOption(Option_t* newopt) const
252 {GetRecParticlesDataLoader()->SetFileOption(newopt);}//Sets Rec Ponoints File Option in open
254 virtual void SetHitsComprLevel(Int_t cl) const
255 {GetHitsDataLoader()->SetCompressionLevel(cl);}
256 virtual void SetDigitsComprLevel(Int_t cl) const
257 {GetSDigitsDataLoader()->SetCompressionLevel(cl);}
258 virtual void SetSDigitsComprLevel(Int_t cl) const
259 {GetDigitsDataLoader()->SetCompressionLevel(cl);}
260 virtual void SetRecPointsComprLevel(Int_t cl) const
261 {GetRecPointsDataLoader()->SetCompressionLevel(cl);}
262 virtual void SetTracksComprLevel(Int_t cl) const
263 {GetTracksDataLoader()->SetCompressionLevel(cl);}
264 virtual void SetRecParticlesComprLevel(Int_t cl) const
265 {GetRecParticlesDataLoader()->SetCompressionLevel(cl);}
267 virtual void SetCompressionLevel(Int_t cl);//Sets compression level in all the files
268 void SetDirName(TString& name);//sets the directory name for all the I/O environment
270 const TString& GetDetectorName() const{return fDetectorName;}//returns the name of the detector
271 AliRunLoader* GetRunLoader();//gets the run-getter from event folder
273 void SetDigitsFileNameSuffix(const TString& suffix) const;//adds the suffix before ".root",
274 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
275 //made on Jiri Chudoba demand
278 /**********************************************/
279 /*********** P U B L I C **************/
280 /********* S T A T I C ************/
281 /********* METHODS ************/
282 /********* They are used by ************/
283 /*********** AliRunLoader as well**************/
284 /**********************************************/
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);
289 static Int_t GetDebug() {return fgDebug;}
290 static void SetDebug(Int_t deb = 1){fgDebug = deb;}//Sets debugging information
294 /*********************************************/
295 /************ PROTECTED **************/
296 /********* M E T H O D S ***********/
297 /*********************************************/
298 enum EDataTypes{kHits = 0,kSDigits,kDigits,kRecPoints,kTracks,kRecParticles,kNDataTypes};
300 //Opens hits file and jumps to directory cooresponding to current event.
301 //If dir does not exists try to create it
302 //opt is passed to TFile::Open
303 //reads data from the file and posts them into folder
306 virtual Int_t PostHits() const
307 {return GetHitsDataLoader()->GetBaseLoader(0)->Load();}
308 virtual Int_t PostSDigits() const
309 {return GetSDigitsDataLoader()->GetBaseLoader(0)->Load();}
310 virtual Int_t PostDigits() const
311 {return GetDigitsDataLoader()->GetBaseLoader(0)->Load();}
312 virtual Int_t PostRecPoints() const
313 {return GetRecPointsDataLoader()->GetBaseLoader(0)->Load();}
314 virtual Int_t PostTracks() const
315 {return GetTracksDataLoader()->GetBaseLoader(0)->Load();}
316 virtual Int_t PostRecParticles() const
317 {return GetRecParticlesDataLoader()->GetBaseLoader(0)->Load();}
319 void Clean();//calls clean for data loaders
320 void Clean(const TString& name);//removes and deletes object from data folder
323 TString GetUnixDir() const;
324 TObject* GetDetectorData(const char* name){return GetDetectorDataFolder()->FindObject(name);}
325 TObject** GetDetectorDataRef(TObject* obj);
328 void ResetDataInfo();
330 void SetTAddrInDet();//Call SetTreeAddress for corresponding detector
332 /**********************************************/
333 /************ PROTECTED ***************/
334 /********* D A T A ************/
335 /**********************************************/
337 TObjArray* fDataLoaders; // array with data loaders each corresponds to
338 // one data type (Hits, Digits, ...)
340 TString fDetectorName;//detector name that this loader belongs to
342 TFolder* fEventFolder; //! Folder with data that changes from event to event, even in single run
343 TFolder* fDataFolder; //! Folder with data (hits, sdigits, etc, grouped in folders named like detectors
344 TFolder* fDetectorDataFolder;//!Folder that contains the detector data
345 TFolder* fModuleFolder; //!Folder that contains the modules
347 TFolder* fTasksFolder; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
348 TFolder* fQAFolder; //!Folder that contains the QA objects
350 // file option varible was introduced because if TFile is created with "recreate"
351 // stored option in TFile is "CREATE". We need to remeber "recreate" for
352 // Max events per file functionality
354 static const TString fgkDefaultHitsContainerName;//default name of conatiner (TREE) for hits
355 static const TString fgkDefaultDigitsContainerName;//default name of conatiner (TREE) for digits
356 static const TString fgkDefaultSDigitsContainerName;//default name of conatiner (TREE) for Sdigits
357 static const TString fgkDefaultRecPointsContainerName;//default name of conatiner (TREE) for Rec Points
358 static const TString fgkDefaultTracksContainerName;//default name of conatiner (TREE) for Tracks
359 static const TString fgkDefaultRecParticlesContainerName;//default name of conatiner (TREE) for Reconstructed Particles
360 static const TString fgkLoaderBaseName;//base name of Loader: fDetectorName+fgkLoaderBaseName. i.e. PHOSLoader
363 //descendant classes should
364 //use protected interface methods to access these folders
366 static Int_t fgDebug; //debug flag for loaders
368 ClassDef(AliLoader,2)
370 /******************************************************************/
371 /************************ I N L I N E S ***************************/
372 /******************************************************************/
374 inline TFolder* AliLoader::GetDetectorDataFolder()
376 //helper function which returns the folder of name "name" in data folder
377 if(!fDetectorDataFolder)
379 fDetectorDataFolder = dynamic_cast<TFolder*>(GetDataFolder()->FindObject(fDetectorName.Data()));
380 if(!fDetectorDataFolder)
382 Fatal("GetDetectorDataFolder",
383 "Can not find folder %s in folder %s. Aborting",
384 fDetectorName.Data(),GetDataFolder()->GetName());
389 return fDetectorDataFolder;