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