]>
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; | |
99 | protected: | |
100 | Int_t GetDebug() const; | |
101 | AliRunLoader* GetRunLoader();//gets the run-loader from event folder | |
102 | ||
103 | private: | |
104 | ||
105 | TString fFileName; //name of the file | |
106 | TFile* fFile; //! pointer to file | |
107 | TDirectory* fDirectory; //!pointer to TDirectory | |
108 | TString fFileOption; //!file option while opened | |
109 | Int_t fCompressionLevel; //Compression Level of File | |
110 | ||
111 | TObjArray* fBaseLoaders;//base loaders | |
112 | Bool_t fHasTask;// flag if has a task | |
113 | TString fTaskName;// name of the task | |
114 | TTask* fParentalTask;//Parental task | |
115 | ||
116 | TFolder* fEventFolder;//!event folder | |
117 | TFolder* fFolder;//! folder with data | |
118 | ||
119 | public: | |
120 | ClassDef(AliDataLoader,1) | |
121 | }; | |
122 | ||
123 | ||
124 | //__________________________________________ | |
125 | //////////////////////////////////////////// | |
126 | // // | |
127 | // class AliBaseLoader // | |
128 | // // | |
129 | // // | |
130 | //////////////////////////////////////////// | |
131 | ||
132 | ||
133 | class AliBaseLoader: public TNamed | |
134 | { | |
135 | public: | |
136 | AliBaseLoader(); | |
137 | AliBaseLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE); | |
138 | ||
139 | virtual ~AliBaseLoader(){}; | |
140 | ||
141 | virtual Int_t Load(Option_t* opt=""); | |
142 | virtual void Unload(); | |
143 | virtual Int_t Reload(); | |
144 | virtual Int_t WriteData(Option_t* opt=""); | |
145 | virtual void Clean(); | |
146 | virtual Int_t Post(); | |
147 | virtual Int_t Post(TObject* data); | |
148 | virtual TObject* Get() const = 0; | |
149 | Bool_t IsLoaded()const{return fIsLoaded;} | |
150 | void SetDataLoader(AliDataLoader* dl){fDataLoader = dl;} | |
151 | void SetEventFolder(TFolder* ef){;} | |
152 | void SetDoNotReload(Bool_t flag){fDoNotReload = flag;} | |
153 | Bool_t DoNotReload() const {return fDoNotReload;} | |
154 | TDirectory* GetDirectory();//returns pointer to directory where data are stored. | |
155 | TObject* GetFromDirectory(const char *name){return (GetDirectory())?GetDirectory()->Get(name):0x0;} | |
156 | protected: | |
157 | ||
158 | virtual Int_t AddToBoard(TObject* obj) = 0;//add to white board - board can be TTask or TFolder | |
159 | virtual void RemoveFromBoard(TObject* obj) = 0; | |
160 | ||
161 | AliDataLoader* GetDataLoader() const; | |
162 | Int_t GetDebug() const; | |
163 | ||
164 | Bool_t fIsLoaded; //! flag indicating if data are loaded | |
165 | Bool_t fStoreInTopOfFile;// if true, data are stored in top of file ->Indicates fDoNotReload == kTRUE | |
166 | ||
167 | private: | |
168 | Bool_t fDoNotReload; // if this flag is on object is not reloaded while GetEvent is called. | |
169 | //Specially important for tasks. Task loops over events while producing data, | |
170 | //and has a base loader which writes it to file every processed event. | |
171 | //If this flag is not on, while taking next event, loader deletes task | |
172 | // and tries to get new one from file | |
173 | AliDataLoader* fDataLoader; //! pointer to Data Loader this Base Loader belongs to | |
174 | ||
175 | ClassDef(AliBaseLoader,1) | |
176 | }; | |
177 | ||
178 | //__________________________________________ | |
179 | //////////////////////////////////////////// | |
180 | // // | |
181 | // class AliObjectLoader // | |
182 | // // | |
183 | // // | |
184 | //////////////////////////////////////////// | |
185 | ||
186 | class AliObjectLoader: public AliBaseLoader | |
187 | { | |
188 | public: | |
189 | AliObjectLoader(){}; | |
190 | AliObjectLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE); | |
191 | virtual ~AliObjectLoader(){}; | |
192 | TObject* Get() const; | |
193 | ||
194 | protected: | |
195 | TFolder* GetFolder() const; | |
196 | Int_t AddToBoard(TObject* obj); | |
197 | void RemoveFromBoard(TObject* obj); | |
198 | ||
199 | ClassDef(AliObjectLoader,1) | |
200 | ||
201 | }; | |
202 | ||
203 | //__________________________________________ | |
204 | //////////////////////////////////////////// | |
205 | // // | |
206 | // class AliTreeLoader // | |
207 | // // | |
208 | // // | |
209 | //////////////////////////////////////////// | |
210 | ||
211 | class AliTreeLoader: public AliObjectLoader | |
212 | { | |
213 | public: | |
214 | AliTreeLoader(){}; | |
215 | AliTreeLoader(const TString& name, AliDataLoader* dl, Bool_t storeontop = kFALSE); | |
216 | virtual ~AliTreeLoader(){}; | |
217 | ||
218 | virtual TTree* Tree() const {return dynamic_cast<TTree*>(Get());} | |
219 | virtual void MakeTree(); | |
220 | virtual Int_t WriteData(Option_t* opt=""); | |
221 | ||
222 | ClassDef(AliTreeLoader,1) | |
223 | }; | |
224 | ||
225 | //__________________________________________ | |
226 | //////////////////////////////////////////// | |
227 | // // | |
228 | // class AliTaskLoader // | |
229 | // // | |
230 | // // | |
231 | //////////////////////////////////////////// | |
232 | ||
233 | class AliTaskLoader: public AliBaseLoader | |
234 | { | |
235 | public: | |
236 | AliTaskLoader():fParentalTask(0x0){}; | |
237 | AliTaskLoader(const TString& name, AliDataLoader* dl, TTask* parentaltask, Bool_t storeontop = kFALSE); | |
238 | virtual ~AliTaskLoader(){}; | |
239 | ||
240 | TObject* Get() const; | |
241 | virtual TTask* Task() const {return dynamic_cast<TTask*>(Get());} | |
242 | ||
243 | protected: | |
244 | Int_t AddToBoard(TObject* obj); | |
245 | void RemoveFromBoard(TObject* obj); | |
246 | TTask* GetParentalTask() const; | |
247 | ||
248 | private: | |
249 | TTask* fParentalTask; | |
250 | ||
251 | ClassDef(AliTaskLoader,1) | |
252 | }; | |
253 | ||
254 | #endif | |
255 | ||
256 |