1 #ifndef ALIDATALOADER_H
2 #define ALIDATALOADER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 //__________________________________________
9 ////////////////////////////////////////////
11 // class AliDataLoader //
13 // Loader responsible for one data type //
14 // i.e. Hits, Kine, etc. //
15 // many objects type can be assciated //
16 // with one data type: storing object //
17 // (usually tree), task producing it, //
18 // Quality Assurance(QA), QA Task, and //
22 ////////////////////////////////////////////
24 #include <TDirectory.h>
34 class AliObjectLoader;
39 class AliDataLoader: public TNamed
43 AliDataLoader(const char* filename, const char* contname, const char* name, Option_t* opt = "t");
44 AliDataLoader(const AliDataLoader& source);
45 AliDataLoader& operator=(const AliDataLoader& source);
46 virtual ~AliDataLoader();
48 virtual Int_t SetEvent();
49 virtual Int_t GetEvent();
51 //shrtcuts method to basic data base loader 0
52 virtual Int_t Load(Option_t* opt="");
53 virtual void Unload();
54 virtual Int_t Reload();
55 virtual Int_t WriteData(Option_t* opt="");
56 virtual TTree* Tree() const;
58 virtual void MakeTree();
59 virtual Int_t OpenFile(Option_t* opt);
61 virtual void CloseFile();
64 const TString& GetFileName() const {return fFileName;}
65 TFile* GetFile() const {return fFile;}
66 TDirectory* GetDirectory() const {return fDirectory;}
67 const TString& GetFileOption() const {return fFileOption;}
68 const Int_t& GetCompressionLevel() const {return fCompressionLevel;}
70 Bool_t Cd(){return (fDirectory)?fDirectory->cd():kFALSE;}
72 virtual void SetFileName(const TString& filename){fFileName = filename;}
73 virtual void SetFileOption(const Option_t* fileopt);
74 virtual void SetCompressionLevel(Int_t cl);
76 Int_t SetEventFolder(TFolder* eventfolder);//sets the event folder
77 Int_t SetFolder(TFolder* folder);//sets the data folder ??????
78 TFolder* GetEventFolder();
79 TFolder* GetFolder() const {return fFolder;}
81 // TObject* GetFromDirectory(const char *name){return (fDirectory)?fDirectory->Get(name):0x0;}
82 void SetFileNameSuffix(const TString& suffix);//adds the suffix before ".root",
83 //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
84 //made on Jiri Chudoba demand
85 void SetNumberOfEventsPerFile(Int_t nevpf)
86 {fNEventsPerFile = nevpf;}
87 const TString SetFileOffset(const TString& fname);//adds the proper number before .root extension suffix
88 void SetDirName(TString& dirname);
90 void AddBaseLoader(AliBaseLoader* bl);
91 enum EStdBasicLoaders {kData = 0,kTask,kQA,kQATask};//standard basic loaders identifiers
93 AliBaseLoader* GetBaseLoader(const TString& name) const;
94 AliBaseLoader* GetBaseLoader(Int_t n) const;
95 AliObjectLoader* GetBaseDataLoader();
96 AliTaskLoader* GetBaseTaskLoader();
97 AliBaseLoader* GetBaseQALoader();
98 AliTaskLoader* GetBaseQATaskLoader();
100 void SetBaseDataLoader(AliBaseLoader* bl);
101 void SetBaseTaskLoader(AliTaskLoader* bl);
102 void SetBaseQALoader(AliBaseLoader* bl);
103 void SetBaseQATaskLoader(AliTaskLoader* bl);
105 Bool_t CheckReload();//checks if we have to reload given file
106 Bool_t IsFileWritable() const;
107 Bool_t IsFileOpen() const;
108 Bool_t IsOptionContrary(const TString& option) const;
113 AliRunLoader* GetRunLoader();//gets the run-loader from event folder
117 TString fFileName; //name of the file
118 TFile* fFile; //! pointer to file
119 TDirectory* fDirectory; //!pointer to TDirectory
120 TString fFileOption; //!file option while opened
121 Int_t fCompressionLevel; //Compression Level of File
122 Int_t fNEventsPerFile; //defines number of events stored per one file
124 TObjArray* fBaseLoaders;//base loaders
125 Bool_t fHasTask;// flag if has a task
126 TString fTaskName;// name of the task
127 TTask* fParentalTask;//Parental task
129 TFolder* fEventFolder;//!event folder
130 TFolder* fFolder;//! folder with data
132 ClassDef(AliDataLoader,2)
136 //__________________________________________
137 ////////////////////////////////////////////
139 // class AliBaseLoader //
142 ////////////////////////////////////////////
145 class AliBaseLoader: public TNamed
149 AliBaseLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE);
150 AliBaseLoader(const AliBaseLoader& source);
151 AliBaseLoader& operator=(const AliBaseLoader& source);
153 virtual ~AliBaseLoader(){};
155 virtual Int_t Load(Option_t* opt="");
156 virtual void Unload();
157 virtual Int_t Reload();
158 virtual Int_t WriteData(Option_t* opt="");
159 virtual void Clean();
160 virtual Int_t Post();//Takes from file and sends to proper TFolder (Data Folder)
161 virtual Int_t Post(TObject* data);//Sends to proper TFolder (Data Folder)
162 virtual TObject* Get() const = 0;
163 Bool_t IsLoaded()const{return fIsLoaded;}
164 void SetDataLoader(AliDataLoader* dl){fDataLoader = dl;}
165 void SetEventFolder(TFolder* /*ef*/){;}
166 void SetDoNotReload(Bool_t flag){fDoNotReload = flag;}
167 Bool_t DoNotReload() const {return fDoNotReload;}
168 TDirectory* GetDirectory() const;//returns pointer to directory where data are stored.
169 TObject* GetFromDirectory(const char *name) const
170 {return (GetDirectory())?GetDirectory()->Get(name):0x0;}
173 virtual Int_t AddToBoard(TObject* obj) = 0;//add to white board - board can be TTask or TFolder
174 virtual void RemoveFromBoard(TObject* obj) = 0;
176 AliDataLoader* GetDataLoader() const;
178 Bool_t fIsLoaded; //! flag indicating if data are loaded
179 Bool_t fStoreInTopOfFile;// if true, data are stored in top of file ->Indicates fDoNotReload == kTRUE
182 Bool_t fDoNotReload; // if this flag is on object is not reloaded while GetEvent is called.
183 //Specially important for tasks. Task loops over events while producing data,
184 //and has a base loader which writes it to file every processed event.
185 //If this flag is not on, while taking next event, loader deletes task
186 // and tries to get new one from file
187 AliDataLoader* fDataLoader; //! pointer to Data Loader this Base Loader belongs to
189 ClassDef(AliBaseLoader,1)
192 //__________________________________________
193 ////////////////////////////////////////////
195 // class AliObjectLoader //
198 ////////////////////////////////////////////
200 class AliObjectLoader: public AliBaseLoader
204 AliObjectLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE);
205 AliObjectLoader(const AliObjectLoader& source);
206 AliObjectLoader& operator=(const AliObjectLoader& source);
207 virtual ~AliObjectLoader(){};
208 TObject* Get() const;
211 TFolder* GetFolder() const;
212 Int_t AddToBoard(TObject* obj);
213 void RemoveFromBoard(TObject* obj);
215 ClassDef(AliObjectLoader,1)
219 //__________________________________________
220 ////////////////////////////////////////////
222 // class AliTreeLoader //
225 ////////////////////////////////////////////
227 class AliTreeLoader: public AliObjectLoader
231 AliTreeLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE);
232 AliTreeLoader(const AliTreeLoader& source);
233 AliTreeLoader& operator=(const AliTreeLoader& source);
234 virtual ~AliTreeLoader(){};
236 virtual TTree* Tree() const {return dynamic_cast<TTree*>(Get());}
237 virtual void MakeTree();
238 virtual Int_t WriteData(Option_t* opt="");
240 ClassDef(AliTreeLoader,1)
243 //__________________________________________
244 ////////////////////////////////////////////
246 // class AliTaskLoader //
249 ////////////////////////////////////////////
251 class AliTaskLoader: public AliBaseLoader
254 AliTaskLoader():fParentalTask(0x0){};
255 AliTaskLoader(const TString& name, AliDataLoader* dl, TTask* parentaltask, Bool_t storeontop = kFALSE);
256 AliTaskLoader(const AliTaskLoader& source);
257 AliTaskLoader& operator=(const AliTaskLoader& source);
258 virtual ~AliTaskLoader(){};
260 TObject* Get() const;
261 virtual TTask* Task() const {return dynamic_cast<TTask*>(Get());}
262 virtual void Clean();
265 Int_t AddToBoard(TObject* obj);
266 void RemoveFromBoard(TObject* obj);
267 TTask* GetParentalTask() const;
270 TTask* fParentalTask; // Parental task
272 ClassDef(AliTaskLoader,1)