]>
Commit | Line | Data |
---|---|---|
88cb7938 | 1 | #ifndef ALIDATALOADER_H |
2 | #define ALIDATALOADER_H | |
f82d8b8c | 3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
88cb7938 | 8 | //__________________________________________ |
9 | //////////////////////////////////////////// | |
10 | // // | |
11 | // class AliDataLoader // | |
12 | // // | |
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 // | |
19 | // others. // | |
20 | // // | |
21 | // // | |
22 | //////////////////////////////////////////// | |
5772083d | 23 | |
24 | #include <TDirectory.h> | |
88cb7938 | 25 | #include <TNamed.h> |
26 | #include <TString.h> | |
88cb7938 | 27 | #include <TTask.h> |
5772083d | 28 | #include <TTree.h> |
88cb7938 | 29 | class TFile; |
30 | class TFolder; | |
5772083d | 31 | |
88cb7938 | 32 | class AliBaseLoader; |
5772083d | 33 | class AliLoader; |
88cb7938 | 34 | class AliObjectLoader; |
5772083d | 35 | class AliRunLoader; |
88cb7938 | 36 | class AliTaskLoader; |
5772083d | 37 | class AliTreeLoader; |
88cb7938 | 38 | |
39 | class AliDataLoader: public TNamed | |
40 | { | |
41 | public: | |
42 | AliDataLoader(); | |
43 | AliDataLoader(const char* filename, const char* contname, const char* name, Option_t* opt = "t"); | |
d0d4a6b3 | 44 | AliDataLoader(const AliDataLoader& source); |
45 | AliDataLoader& operator=(const AliDataLoader& source); | |
88cb7938 | 46 | virtual ~AliDataLoader(); |
47 | ||
48 | virtual Int_t SetEvent(); | |
49 | virtual Int_t GetEvent(); | |
50 | ||
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; | |
57 | virtual void Clean(); | |
58 | virtual void MakeTree(); | |
59 | virtual Int_t OpenFile(Option_t* opt); | |
60 | ||
61 | virtual void CloseFile(); | |
62 | void UnloadAll(); | |
63 | void CleanAll(); | |
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;} | |
69 | ||
5772083d | 70 | Bool_t Cd(){return (fDirectory)?fDirectory->cd():kFALSE;} |
88cb7938 | 71 | |
72 | virtual void SetFileName(const TString& filename){fFileName = filename;} | |
73 | virtual void SetFileOption(const Option_t* fileopt); | |
74 | virtual void SetCompressionLevel(Int_t cl); | |
75 | ||
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;} | |
80 | ||
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 | const TString SetFileOffset(const TString& fname);//adds the proper number before .root extension suffix | |
86 | void SetDirName(TString& dirname); | |
87 | ||
88 | void AddBaseLoader(AliBaseLoader* bl); | |
89 | enum EStdBasicLoaders {kData = 0,kTask,kQA,kQATask};//standard basic loaders identifiers | |
90 | ||
91 | AliBaseLoader* GetBaseLoader(const TString& name) const; | |
92 | AliBaseLoader* GetBaseLoader(Int_t n) const; | |
93 | AliObjectLoader* GetBaseDataLoader(); | |
94 | AliTaskLoader* GetBaseTaskLoader(); | |
95 | AliBaseLoader* GetBaseQALoader(); | |
96 | AliTaskLoader* GetBaseQATaskLoader(); | |
97 | ||
98 | void SetBaseDataLoader(AliBaseLoader* bl); | |
99 | void SetBaseTaskLoader(AliTaskLoader* bl); | |
100 | void SetBaseQALoader(AliBaseLoader* bl); | |
101 | void SetBaseQATaskLoader(AliTaskLoader* bl); | |
102 | ||
103 | Bool_t CheckReload();//checks if we have to reload given file | |
104 | Bool_t IsFileWritable() const; | |
105 | Bool_t IsFileOpen() const; | |
106 | Bool_t IsOptionContrary(const TString& option) const; | |
f0f6f856 | 107 | |
108 | void Synchronize(); | |
109 | ||
88cb7938 | 110 | protected: |
111 | Int_t GetDebug() const; | |
112 | AliRunLoader* GetRunLoader();//gets the run-loader from event folder | |
113 | ||
114 | private: | |
115 | ||
116 | TString fFileName; //name of the file | |
117 | TFile* fFile; //! pointer to file | |
118 | TDirectory* fDirectory; //!pointer to TDirectory | |
119 | TString fFileOption; //!file option while opened | |
120 | Int_t fCompressionLevel; //Compression Level of File | |
121 | ||
122 | TObjArray* fBaseLoaders;//base loaders | |
123 | Bool_t fHasTask;// flag if has a task | |
124 | TString fTaskName;// name of the task | |
125 | TTask* fParentalTask;//Parental task | |
126 | ||
127 | TFolder* fEventFolder;//!event folder | |
128 | TFolder* fFolder;//! folder with data | |
129 | ||
88cb7938 | 130 | ClassDef(AliDataLoader,1) |
131 | }; | |
132 | ||
133 | ||
134 | //__________________________________________ | |
135 | //////////////////////////////////////////// | |
136 | // // | |
137 | // class AliBaseLoader // | |
138 | // // | |
139 | // // | |
140 | //////////////////////////////////////////// | |
141 | ||
142 | ||
143 | class AliBaseLoader: public TNamed | |
144 | { | |
145 | public: | |
146 | AliBaseLoader(); | |
147 | AliBaseLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE); | |
d0d4a6b3 | 148 | AliBaseLoader(const AliBaseLoader& source); |
149 | AliBaseLoader& operator=(const AliBaseLoader& source); | |
88cb7938 | 150 | |
151 | virtual ~AliBaseLoader(){}; | |
152 | ||
153 | virtual Int_t Load(Option_t* opt=""); | |
154 | virtual void Unload(); | |
155 | virtual Int_t Reload(); | |
156 | virtual Int_t WriteData(Option_t* opt=""); | |
157 | virtual void Clean(); | |
c3983217 | 158 | virtual Int_t Post();//Takes from file and sends to proper TFolder (Data Folder) |
159 | virtual Int_t Post(TObject* data);//Sends to proper TFolder (Data Folder) | |
88cb7938 | 160 | virtual TObject* Get() const = 0; |
161 | Bool_t IsLoaded()const{return fIsLoaded;} | |
162 | void SetDataLoader(AliDataLoader* dl){fDataLoader = dl;} | |
d1898505 | 163 | void SetEventFolder(TFolder* /*ef*/){;} |
88cb7938 | 164 | void SetDoNotReload(Bool_t flag){fDoNotReload = flag;} |
165 | Bool_t DoNotReload() const {return fDoNotReload;} | |
d0d4a6b3 | 166 | TDirectory* GetDirectory() const;//returns pointer to directory where data are stored. |
167 | TObject* GetFromDirectory(const char *name) const | |
168 | {return (GetDirectory())?GetDirectory()->Get(name):0x0;} | |
88cb7938 | 169 | protected: |
170 | ||
171 | virtual Int_t AddToBoard(TObject* obj) = 0;//add to white board - board can be TTask or TFolder | |
172 | virtual void RemoveFromBoard(TObject* obj) = 0; | |
173 | ||
174 | AliDataLoader* GetDataLoader() const; | |
175 | Int_t GetDebug() const; | |
176 | ||
177 | Bool_t fIsLoaded; //! flag indicating if data are loaded | |
178 | Bool_t fStoreInTopOfFile;// if true, data are stored in top of file ->Indicates fDoNotReload == kTRUE | |
179 | ||
180 | private: | |
181 | Bool_t fDoNotReload; // if this flag is on object is not reloaded while GetEvent is called. | |
182 | //Specially important for tasks. Task loops over events while producing data, | |
183 | //and has a base loader which writes it to file every processed event. | |
184 | //If this flag is not on, while taking next event, loader deletes task | |
185 | // and tries to get new one from file | |
186 | AliDataLoader* fDataLoader; //! pointer to Data Loader this Base Loader belongs to | |
187 | ||
188 | ClassDef(AliBaseLoader,1) | |
189 | }; | |
190 | ||
191 | //__________________________________________ | |
192 | //////////////////////////////////////////// | |
193 | // // | |
194 | // class AliObjectLoader // | |
195 | // // | |
196 | // // | |
197 | //////////////////////////////////////////// | |
198 | ||
199 | class AliObjectLoader: public AliBaseLoader | |
200 | { | |
201 | public: | |
202 | AliObjectLoader(){}; | |
203 | AliObjectLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE); | |
d0d4a6b3 | 204 | AliObjectLoader(const AliObjectLoader& source); |
205 | AliObjectLoader& operator=(const AliObjectLoader& source); | |
88cb7938 | 206 | virtual ~AliObjectLoader(){}; |
207 | TObject* Get() const; | |
208 | ||
209 | protected: | |
210 | TFolder* GetFolder() const; | |
211 | Int_t AddToBoard(TObject* obj); | |
212 | void RemoveFromBoard(TObject* obj); | |
213 | ||
214 | ClassDef(AliObjectLoader,1) | |
215 | ||
216 | }; | |
217 | ||
218 | //__________________________________________ | |
219 | //////////////////////////////////////////// | |
220 | // // | |
221 | // class AliTreeLoader // | |
222 | // // | |
223 | // // | |
224 | //////////////////////////////////////////// | |
225 | ||
226 | class AliTreeLoader: public AliObjectLoader | |
227 | { | |
228 | public: | |
229 | AliTreeLoader(){}; | |
230 | AliTreeLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE); | |
d0d4a6b3 | 231 | AliTreeLoader(const AliTreeLoader& source); |
232 | AliTreeLoader& operator=(const AliTreeLoader& source); | |
88cb7938 | 233 | virtual ~AliTreeLoader(){}; |
234 | ||
235 | virtual TTree* Tree() const {return dynamic_cast<TTree*>(Get());} | |
236 | virtual void MakeTree(); | |
237 | virtual Int_t WriteData(Option_t* opt=""); | |
238 | ||
239 | ClassDef(AliTreeLoader,1) | |
240 | }; | |
241 | ||
242 | //__________________________________________ | |
243 | //////////////////////////////////////////// | |
244 | // // | |
245 | // class AliTaskLoader // | |
246 | // // | |
247 | // // | |
248 | //////////////////////////////////////////// | |
249 | ||
250 | class AliTaskLoader: public AliBaseLoader | |
251 | { | |
252 | public: | |
253 | AliTaskLoader():fParentalTask(0x0){}; | |
254 | AliTaskLoader(const TString& name, AliDataLoader* dl, TTask* parentaltask, Bool_t storeontop = kFALSE); | |
d0d4a6b3 | 255 | AliTaskLoader(const AliTaskLoader& source); |
256 | AliTaskLoader& operator=(const AliTaskLoader& source); | |
88cb7938 | 257 | virtual ~AliTaskLoader(){}; |
258 | ||
259 | TObject* Get() const; | |
260 | virtual TTask* Task() const {return dynamic_cast<TTask*>(Get());} | |
3637d19d | 261 | virtual void Clean(); |
88cb7938 | 262 | |
263 | protected: | |
264 | Int_t AddToBoard(TObject* obj); | |
265 | void RemoveFromBoard(TObject* obj); | |
266 | TTask* GetParentalTask() const; | |
267 | ||
268 | private: | |
d0d4a6b3 | 269 | TTask* fParentalTask; // Parental task |
88cb7938 | 270 | |
271 | ClassDef(AliTaskLoader,1) | |
272 | }; | |
273 | ||
274 | #endif | |
275 | ||
276 |