AliRoot Core  3dc7879 (3dc7879)
Go to the documentation of this file.
1 #ifndef ALILOADER_H
2 #define ALILOADER_H
4 class TDirectory;
5 class TFile;
6 class TString;
7 class TTree;
9 #include <TFolder.h>
10 #include <TObjArray.h>
12 class AliRunLoader;
14 #include "AliDataLoader.h"
15 #include "AliBaseLoader.h"
18 //___________________________________________________________________
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 // //
30 class 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);
37  virtual ~AliLoader();//-----------------
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);
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"
59  AliDataLoader* GetDataLoader(const char* name);
60  void AddDataLoader(AliDataLoader* dl);
63  Int_t SetEventFolder(TFolder* eventfolder);//sets the event folder
64  Int_t Register(TFolder* eventFolder);//triggers creation of subfolders for a given detector
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();
73  virtual void MakeHitsContainer() const {GetHitsDataLoader()->MakeTree();}
74  virtual void MakeSDigitsContainer() const {GetSDigitsDataLoader()->MakeTree();}
75  virtual void MakeDigitsContainer() const {GetDigitsDataLoader()->MakeTree();}
77  virtual void MakeTracksContainer() const {GetTracksDataLoader()->MakeTree();}
80  virtual void CleanFolders();
81  virtual void CloseFiles();
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
96  Int_t LoadHits(Option_t* opt=""){
97  Int_t status = GetHitsDataLoader()->Load(opt);
98  SetTAddrInDet();
99  return status;
100  }
101  Int_t LoadSDigits(Option_t* opt=""){
102  Int_t status = GetSDigitsDataLoader()->Load(opt);
103  SetTAddrInDet();
104  return status;
105  }
106  Int_t LoadDigits(Option_t* opt=""){
107  Int_t status = GetDigitsDataLoader()->Load(opt);
108  SetTAddrInDet();
109  return status;
110  }
113  Int_t LoadRecPoints(Option_t* opt="") {
114  Int_t status = GetRecPointsDataLoader()->Load(opt);
115  SetTAddrInDet();
116  return status;
117  }
118  Int_t LoadTracks(Option_t* opt="") {
119  Int_t status = GetTracksDataLoader()->Load(opt);
120  SetTAddrInDet();
121  return status;
122  }
123  Int_t LoadRecParticles(Option_t* opt="") {
124  Int_t status = GetRecParticlesDataLoader()->Load(opt);
125  SetTAddrInDet();
126  return status;
127  }
129  void UnloadHits() const {GetHitsDataLoader()->Unload();}
135  void UnloadAll();
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
143  virtual Int_t ReloadAll(); //unload and load again everything that was loaded
145  //these methods writes object from folder to proper file
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);}
154  //void SetTopFolder(TString& str){}; //Sets root top folder for the run
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
164  void SetTracksFileName(const TString& fname) const
165  {GetTracksDataLoader()->SetFileName(fname);}
166  void SetRecParticlesFileName(const TString& fname) const
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
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
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
206  virtual void SetHitsComprLevel(Int_t cl) const
208  virtual void SetDigitsComprLevel(Int_t cl) const
210  virtual void SetSDigitsComprLevel(Int_t cl) const
212  virtual void SetRecPointsComprLevel(Int_t cl) const
214  virtual void SetTracksComprLevel(Int_t cl) const
216  virtual void SetRecParticlesComprLevel(Int_t cl) const
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
222  const TString& GetDetectorName() const{return fDetectorName;}//returns the name of the detector
223  AliRunLoader* GetRunLoader();//gets the run-getter from event folder
225  void SetDigitsFileNameSuffix(const TString& suffix) const;//adds the suffix before ".root",
226  //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
227  //made on Jiri Chudoba demand
228  void Synchronize();
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);
241  static void SetDebug(Int_t deb = 1);//Sets debugging information
243  protected:
245  /*********************************************/
246  /************ PROTECTED **************/
247  /********* M E T H O D S ***********/
248  /*********************************************/
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
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();}
270  void Clean();//calls clean for data loaders
271  void Clean(const TString& name);//removes and deletes object from data folder
274  TString GetUnixDir() const;
275  TObject* GetDetectorData(const char* name){return GetDetectorDataFolder()->FindObject(name);}
276  TObject** GetDetectorDataRef(TObject* obj);
278  virtual void InitDefaults();
279  void ResetDataInfo();
281  void SetTAddrInDet();//Call SetTreeAddress for corresponding detector
283  /**********************************************/
284  /************ PROTECTED ***************/
285  /********* D A T A ************/
286  /**********************************************/
288  TObjArray* fDataLoaders; // array with data loaders each corresponds to
289  // one data type (Hits, Digits, ...)
291  TString fDetectorName;//detector name that this loader belongs to
293  TFolder* fEventFolder;
294  TFolder* fDataFolder;
296  TFolder* fModuleFolder;
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
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
310  private:
311  //descendant classes should
312  //use protected interface methods to access these folders
313  AliLoader(const AliLoader&); //Not implemented
314  AliLoader& operator=(const AliLoader&); //Not implemented
316  ClassDef(AliLoader,3)
317  };
318 /******************************************************************/
319 /************************ I N L I N E S ***************************/
320 /******************************************************************/
323  {
324  //helper function which returns the folder of name "name" in data folder
326  {
327  fDetectorDataFolder = dynamic_cast<TFolder*>(GetDataFolder()->FindObject(fDetectorName.Data()));
329  {
330  Fatal("GetDetectorDataFolder",
331  "Can not find folder %s in folder %s. Aborting",
332  fDetectorName.Data(),GetDataFolder()->GetName());
333  return 0x0;
334  }
336  }
337  return fDetectorDataFolder;
338  }
340 #endif
static const TString fgkDefaultTracksContainerName
Definition: AliLoader.h:306
virtual void CleanRecPoints() const
Definition: AliLoader.h:188
static const TString fgkDefaultDigitsContainerName
Definition: AliLoader.h:303
virtual void CleanFolders()
Definition: AliLoader.cxx:401
TFolder * fModuleFolder
Folder that contains the detector data.
Definition: AliLoader.h:296
TFolder * GetDetectorDataFolder()
Definition: AliLoader.h:322
virtual void SetRecParticlesFileOption(Option_t *newopt) const
Definition: AliLoader.h:203
TObjArray * fDataLoaders
Definition: AliLoader.h:288
void UnloadRecPoints() const
Definition: AliLoader.h:132
void UnloadRecParticles() const
Definition: AliLoader.h:134
virtual void SetSDigitsFileOption(Option_t *newopt) const
Definition: AliLoader.h:195
AliBaseLoader * GetBaseLoader(const TString &name) const
virtual void SetTracksFileOption(Option_t *newopt) const
Definition: AliLoader.h:201
static const TString fgkLoaderBaseName
Definition: AliLoader.h:308
virtual void MakeTree(Option_t *opt)
Definition: AliLoader.cxx:346
#define TObjArray
virtual Int_t ReloadTracks() const
Definition: AliLoader.h:141
const TString & GetRecParticlesFileName() const
Definition: AliLoader.h:179
void SetTAddrInDet()
Definition: AliLoader.cxx:602
TString GetUnixDir() const
Definition: AliLoader.cxx:334
static Bool_t TestFileOption(Option_t *opt)
Definition: AliLoader.cxx:504
virtual void SetDigitsComprLevel(Int_t cl) const
Definition: AliLoader.h:208
virtual Int_t PostTracks() const
Definition: AliLoader.h:265
virtual void MakeHitsContainer() const
Definition: AliLoader.h:73
static Bool_t IsOptionWritable(const TString &opt)
Definition: AliLoader.cxx:577
TTree * TreeD() const
Definition: AliLoader.h:87
virtual Int_t Load(Option_t *opt="")
virtual void SetRecParticlesComprLevel(Int_t cl) const
Definition: AliLoader.h:216
virtual void SetDigitsFileOption(Option_t *newopt) const
Definition: AliLoader.h:197
void SetSDigitsFileName(const TString &fname) const
Definition: AliLoader.h:158
const TString & GetTracksFileName() const
Definition: AliLoader.h:177
void SetDigitsFileNameSuffix(const TString &suffix) const
Definition: AliLoader.cxx:529
virtual void SetHitsComprLevel(Int_t cl) const
Definition: AliLoader.h:206
TTree * TreeS() const
Definition: AliLoader.h:85
AliDataLoader * GetDataLoader(const char *name)
Definition: AliLoader.cxx:142
virtual Int_t ReloadHits() const
Definition: AliLoader.h:137
Int_t LoadRecPoints(Option_t *opt="")
Definition: AliLoader.h:113
virtual Int_t PostDigits() const
Definition: AliLoader.h:261
virtual Int_t SetEvent()
Definition: AliLoader.cxx:169
virtual void MakeTree()
const TString & GetRecPointsFileName() const
Definition: AliLoader.h:175
virtual void CleanSDigits() const
Definition: AliLoader.h:184
TObject * GetDetectorData(const char *name)
Definition: AliLoader.h:275
TObject ** GetDetectorDataRef(TObject *obj)
Definition: AliLoader.cxx:390
virtual ~AliLoader()
Definition: AliLoader.cxx:103
TTree * TreeP() const
Definition: AliLoader.h:93
static const TString fgkDefaultRecPointsContainerName
Definition: AliLoader.h:305
static const TString fgkDefaultSDigitsContainerName
Definition: AliLoader.h:304
virtual void MakeRecParticlesContainer() const
Definition: AliLoader.h:78
void Clean()
Definition: AliLoader.cxx:550
virtual Int_t PostHits() const
Definition: AliLoader.h:257
TTree * TreeR() const
Definition: AliLoader.h:89
AliDataLoader * GetTracksDataLoader() const
Definition: AliLoader.h:56
virtual void CleanDigits() const
Definition: AliLoader.h:186
virtual void Unload()
Int_t LoadSDigits(Option_t *opt="")
Definition: AliLoader.h:101
AliDataLoader * GetDigitsDataLoader() const
Definition: AliLoader.h:54
Int_t LoadRecParticles(Option_t *opt="")
Definition: AliLoader.h:123
virtual void MakeSDigitsContainer() const
Definition: AliLoader.h:74
virtual Int_t WriteSDigits(Option_t *opt="") const
Definition: AliLoader.cxx:380
void UnloadDigits() const
Definition: AliLoader.h:131
virtual Int_t PostRecParticles() const
Definition: AliLoader.h:267
static void SetDebug(Int_t deb=1)
Definition: AliLoader.cxx:589
virtual void SetCompressionLevel(Int_t cl)
virtual Int_t GetEvent()
Definition: AliLoader.cxx:195
Int_t SetEventFolder(TFolder *eventfolder)
Definition: AliLoader.cxx:446
virtual void SetSDigitsComprLevel(Int_t cl) const
Definition: AliLoader.h:210
virtual Int_t WriteRecPoints(Option_t *opt="") const
Definition: AliLoader.h:149
TFolder * GetDataFolder()
Definition: AliLoader.cxx:237
virtual void CleanHits() const
Definition: AliLoader.h:182
AliDataLoader * GetSDigitsDataLoader() const
Definition: AliLoader.h:53
virtual void SetRecPointsFileOption(Option_t *newopt) const
Definition: AliLoader.h:199
virtual void CleanTracks() const
Definition: AliLoader.h:190
virtual void MakeRecPointsContainer() const
Definition: AliLoader.h:76
AliRunLoader * GetRunLoader()
Definition: AliLoader.cxx:495
virtual Int_t ReloadSDigits() const
Definition: AliLoader.h:138
void SetRecParticlesFileName(const TString &fname) const
Definition: AliLoader.h:166
virtual TTree * Tree() const
virtual void MakeDigitsContainer() const
Definition: AliLoader.h:75
static const TString fgkDefaultHitsContainerName
Folder that contains the modules.
Definition: AliLoader.h:302
virtual void MakeTracksContainer() const
Definition: AliLoader.h:77
virtual Int_t WriteRecParticles(Option_t *opt="") const
Definition: AliLoader.h:151
AliDataLoader * GetHitsDataLoader() const
Definition: AliLoader.h:52
TFolder * fDetectorDataFolder
Folder with data (hits, sdigits, etc, grouped in folders named like detectors.
Definition: AliLoader.h:295
virtual void SetFileName(const TString &filename)
Definition: AliDataLoader.h:64
virtual Int_t ReloadDigits() const
Definition: AliLoader.h:139
virtual Int_t ReloadRecParticles() const
Definition: AliLoader.h:142
Int_t LoadHits(Option_t *opt="")
Definition: AliLoader.h:96
void UnloadTracks() const
Definition: AliLoader.h:133
void SetHitsFileName(const TString &fname) const
Definition: AliLoader.h:156
TFolder * GetTopFolder()
Definition: AliLoader.cxx:223
TString fDetectorName
Definition: AliLoader.h:291
virtual void SetFileOption(const Option_t *fileopt)
void UnloadAll()
Definition: AliLoader.cxx:182
virtual Int_t PostSDigits() const
Definition: AliLoader.h:259
const TString & GetDigitsFileName() const
Definition: AliLoader.h:173
virtual Int_t WriteDigits(Option_t *opt="") const
Definition: AliLoader.h:148
void UnloadHits() const
Definition: AliLoader.h:129
virtual Int_t WriteData(Option_t *opt="")
void SetDigitsFileName(const TString &fname) const
Definition: AliLoader.h:160
virtual void Clean()
TTree * TreeH() const
Definition: AliLoader.h:83
const TString & GetSDigitsFileName() const
Definition: AliLoader.h:171
void ResetDataInfo()
virtual Int_t WriteTracks(Option_t *opt="") const
Definition: AliLoader.h:150
virtual void SetRecPointsComprLevel(Int_t cl) const
Definition: AliLoader.h:212
void UnloadSDigits() const
Definition: AliLoader.h:130
void SetRecPointsFileName(const TString &fname) const
Definition: AliLoader.h:162
void SetDirName(TString &name)
Definition: AliLoader.cxx:516
virtual void SetTracksComprLevel(Int_t cl) const
Definition: AliLoader.h:214
virtual void InitDefaults()
Definition: AliLoader.cxx:111
void AddDataLoader(AliDataLoader *dl)
Definition: AliLoader.cxx:148
AliLoader & operator=(const AliLoader &)
const TString & GetDetectorName() const
Definition: AliLoader.h:222
AliDataLoader * GetRecParticlesDataLoader() const
Definition: AliLoader.h:57
virtual Int_t Reload()
TFolder * fDataFolder
Folder with data that changes from event to event, even in single run.
Definition: AliLoader.h:294
Int_t LoadDigits(Option_t *opt="")
Definition: AliLoader.h:106
Int_t Register(TFolder *eventFolder)
Definition: AliLoader.cxx:469
const TString & GetFileName() const
Definition: AliDataLoader.h:56
static const TString fgkDefaultRecParticlesContainerName
Definition: AliLoader.h:307
virtual Int_t ReloadAll()
Definition: AliLoader.cxx:415
void SetTracksFileName(const TString &fname) const
Definition: AliLoader.h:164
virtual Int_t Load(Option_t *opt="")
char * fname
TFolder * GetEventFolder()
Definition: AliLoader.cxx:231
virtual void SetCompressionLevel(Int_t cl)
Definition: AliLoader.cxx:538
void Synchronize()
Definition: AliLoader.cxx:615
virtual Int_t PostRecPoints() const
Definition: AliLoader.h:263
TFolder * GetModulesFolder()
Definition: AliLoader.cxx:255
virtual Int_t ReloadRecPoints() const
Definition: AliLoader.h:140
virtual void SetHitsFileOption(Option_t *newopt) const
Definition: AliLoader.h:193
Int_t LoadTracks(Option_t *opt="")
Definition: AliLoader.h:118
TTree * TreeT() const
Definition: AliLoader.h:91
virtual void CloseFiles()
Definition: AliLoader.cxx:434
static TDirectory * ChangeDir(TFile *file, Int_t eventno)
Definition: AliLoader.cxx:274
TFolder * fEventFolder
Definition: AliLoader.h:293
AliDataLoader * GetRecPointsDataLoader() const
Definition: AliLoader.h:55
const TString & GetHitsFileName() const
Definition: AliLoader.h:169
virtual Int_t WriteHits(Option_t *opt="") const
Definition: AliLoader.cxx:371