88cb7938 |
1 | #ifndef ALIRUNLoader_H |
2 | #define ALIRUNLoader_H |
3 | |
4 | //___________________________________________________________________ |
5 | ///////////////////////////////////////////////////////////////////// |
6 | // // |
7 | // class AliRunLoader // |
8 | // // |
9 | // This class aims to be the only one interface for manging data // |
10 | // It stores Loaders for all modules which knows the filenames // |
11 | // of the data files to be stored. // |
12 | // It aims to substitude AliRun in automatic managing of data // |
13 | // positioning thus there won't be necessity of loading gAlice // |
14 | // from file in order to get fast access to the data // |
15 | // // |
16 | // Logical place to put the specific Loader to the given // |
17 | // detector is detector itself (i.e ITSLoader in ITS). // |
18 | // But, to load detector object one need to load gAlice, and // |
19 | // by the way all other detectors with their geometrieces and // |
20 | // so on. So, if one need to open TPC clusters there is no // |
21 | // principal nedd to read everything. // |
22 | // // |
23 | ///////////////////////////////////////////////////////////////////// |
24 | |
25 | #include <TNamed.h> |
26 | #include <TFile.h> |
27 | #include "AliConfig.h" |
28 | #include "AliLoader.h" |
29 | #include "AliDataLoader.h" |
30 | |
31 | class TString; |
32 | class TFolder; |
33 | class TObjArray; |
34 | class TTree; |
35 | class TTask; |
36 | class TParticle; |
37 | |
38 | class AliRun; |
39 | class AliLoader; |
40 | class AliDetector; |
41 | class AliHeader; |
42 | class AliStack; |
43 | class AliRunDigitizer; |
44 | |
45 | |
46 | class AliRunLoader: public TNamed |
47 | { |
48 | public: |
49 | |
50 | AliRunLoader(); |
51 | AliRunLoader(const char* topfoldername); |
52 | AliRunLoader(TFolder* topfolder); |
53 | |
54 | virtual ~AliRunLoader(); |
55 | |
56 | static AliRunLoader* Open(const char* filename = "galice.root", |
57 | const char* eventfoldername = AliConfig::fgkDefaultEventFolderName, |
58 | Option_t* option = "READ"); |
59 | |
60 | Int_t GetEventNumber() const {return fCurrentEvent;} |
61 | |
62 | Int_t GetEvent(Int_t evno);//sets the event number and reloads data in folders properly |
63 | Int_t GetNextEvent(){return GetEvent(fCurrentEvent+1);}//gets next event |
64 | Int_t SetEventNumber(Int_t evno); //cleans folders and sets the root dirs in files (do not reload data) |
65 | Int_t SetNextEvent(){return SetEventNumber(fCurrentEvent+1);} |
66 | |
67 | Int_t GetNumberOfEvents(); |
68 | |
69 | void MakeTree(Option_t *option); |
70 | void MakeHeader(); |
71 | void MakeStack(); |
72 | |
73 | Int_t LoadgAlice(); |
74 | Int_t LoadHeader(); |
75 | Int_t LoadKinematics(Option_t* option = "READ"); |
76 | Int_t LoadTrackRefs(Option_t* option = "READ"); |
77 | |
78 | void UnloadHeader(); |
79 | void UnloadKinematics(); |
80 | void UnloadgAlice(); |
81 | void UnloadTrackRefs(); |
82 | |
83 | void SetKineFileName(const TString& fname){fKineDataLoader->SetFileName(fname);} |
84 | void SetTrackRefsFileName(const TString& fname){fTrackRefsDataLoader->SetFileName(fname);} |
85 | |
86 | TTree* TreeE() const; //returns the tree from folder; shortcut method |
87 | AliHeader* GetHeader() const; |
88 | |
89 | AliStack* Stack() const {return fStack;} |
90 | |
91 | TTree* TreeK() const; //returns the tree from folder; shortcut method |
92 | TTree* TreeTR() const; //returns the tree from folder; shortcut method |
93 | |
94 | AliRun* GetAliRun()const; |
95 | |
96 | Int_t WriteGeometry(Option_t* opt=""); |
97 | Int_t WriteHeader(Option_t* opt=""); |
98 | Int_t WriteAliRun(Option_t* opt=""); |
99 | Int_t WriteKinematics(Option_t* opt=""); |
100 | Int_t WriteTrackRefs(Option_t* opt=""); |
101 | Int_t WriteRunLoader(Option_t* opt=""); |
102 | |
103 | Int_t WriteHits(Option_t* opt=""); |
104 | Int_t WriteSDigits(Option_t* opt=""); |
105 | Int_t WriteDigits(Option_t* opt=""); |
106 | Int_t WriteRecPoints(Option_t* opt=""); |
107 | Int_t WriteTracks(Option_t* opt=""); |
108 | |
109 | Int_t LoadHits(Option_t* detectors = "all",Option_t* opt = "RAED"); |
110 | Int_t LoadSDigits(Option_t* detectors = "all",Option_t* opt = "RAED"); |
111 | Int_t LoadDigits(Option_t* detectors = "all",Option_t* opt = "RAED"); |
112 | Int_t LoadRecPoints(Option_t* detectors = "all",Option_t* opt = "RAED"); |
113 | Int_t LoadTracks(Option_t* detectors = "all",Option_t* opt = "RAED"); |
114 | |
115 | |
116 | void AddLoader(AliLoader* loader); |
117 | void AddLoader(AliDetector* det); |
118 | AliLoader* GetLoader(const char* detname) const; |
119 | AliLoader* GetLoader(AliDetector* det) const; |
120 | Int_t SetEventFolderName(const TString& name = AliConfig::fgkDefaultEventFolderName);//sets top folder name for this run; of alread |
121 | void CleanFolders();//removes all abjects from folder structure |
122 | void CleanDetectors(); |
123 | void CleanKinematics(){Clean(fgkKineContainerName);} |
124 | void CleanTrackRefs(){Clean(fgkTrackRefsContainerName);} |
125 | |
126 | void RemoveEventFolder(); //remove folder structure from top folder |
127 | void SetCompressionLevel(Int_t cl); |
128 | void SetKineComprLevel(Int_t cl); |
129 | void SetTrackRefsComprLevel(Int_t cl); |
130 | |
131 | TFolder* GetEventFolder() const {return fEventFolder;} |
132 | void CdGAFile(); |
133 | |
134 | void MakeTrackRefsContainer(); |
135 | void SetDirName(TString& dirname); |
136 | Int_t GetFileOffset() const; |
137 | void SetNumberOfEventsPerFile(Int_t nevpf){fNEventsPerFile = nevpf;} |
138 | |
139 | void SetDigitsFileNameSuffix(const TString& suffix);//adds the suffix before ".root", |
140 | //e.g. TPC.Digits.root -> TPC.DigitsMerged.root |
141 | //made on Jiri Chudoba demand |
142 | TString GetFileName() const;//returns name of galice file |
143 | const TObjArray* GetArrayOfLoaders() const {return fLoaders;} |
144 | Int_t GetDebug() const {return AliLoader::GetDebug();} |
145 | void cd(){fgRunLoader = this;} |
f0f6f856 |
146 | void Synchronize(); |
147 | |
88cb7938 |
148 | protected: |
149 | /**********************************************/ |
150 | /************ PROTECTED ***************/ |
151 | /********* D A T A ************/ |
152 | /**********************************************/ |
153 | |
154 | TObjArray *fLoaders; // List of Detectors |
155 | TFolder *fEventFolder; //!top folder for this run |
156 | |
157 | Int_t fCurrentEvent;//!Number of current event |
158 | |
159 | TFile *fGAFile;//! pointer to main file with AliRun and Run Loader -> galice.root |
160 | AliHeader *fHeader;//! pointer to header |
161 | AliStack *fStack; //! pointer to stack |
162 | |
163 | AliDataLoader *fKineDataLoader;// kinematics data loader |
164 | AliDataLoader *fTrackRefsDataLoader;//track reference data loader |
165 | |
166 | Int_t fNEventsPerFile; //defines number of events stored per one file |
167 | TString fUnixDirName; //! name of unix path to directory that contains event |
168 | static const TString fgkDefaultKineFileName;//default file name with kinamatics |
169 | static const TString fgkDefaultTrackRefsFileName;//default file name with kinamatics |
170 | |
171 | |
172 | /*********************************************/ |
173 | /************ PROTECTED **************/ |
174 | /********* M E T H O D S ***********/ |
175 | /*********************************************/ |
176 | |
177 | void SetGAliceFile(TFile* gafile);//sets the pointer to gAlice file |
178 | Int_t OpenKineFile(Option_t* opt); |
179 | Int_t OpenTrackRefsFile(Option_t* opt); |
180 | |
181 | Int_t OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl); |
182 | void SetUnixDir(const TString& udirname); |
183 | const TString SetFileOffset(const TString& fname);//adds the proper number before .root |
184 | void SetDetectorAddresses(); |
185 | |
186 | private: |
187 | void GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const; |
188 | |
189 | void CleanHeader(){Clean(fgkHeaderContainerName);} |
190 | void Clean(const TString& name); |
191 | |
192 | Int_t SetEvent(); |
193 | |
194 | static AliRunLoader* fgRunLoader; |
195 | |
196 | public: |
197 | /******************************************/ |
198 | /***** Public S T A T I C Stuff *******/ |
199 | /******************************************/ |
200 | static AliRunLoader* GetRunLoader(const char* eventfoldername); |
201 | static AliRunLoader* GetRunLoader(){return fgRunLoader;} |
8de97894 |
202 | static AliLoader* GetDetectorLoader(const char* detname); |
203 | static TTree* GetTreeH(const char* detname, Bool_t maketree); |
204 | static TTree* GetTreeS(const char* detname, Bool_t maketree); |
205 | static TTree* GetTreeD(const char* detname, Bool_t maketree); |
206 | static TTree* GetTreeR(const char* detname, Bool_t maketree); |
207 | static TTree* GetTreeT(const char* detname, Bool_t maketree); |
208 | static TTree* GetTreeP(const char* detname, Bool_t maketree); |
88cb7938 |
209 | |
210 | // static AliRunDigitizer* GetRunDigitizer(); |
211 | // Tasks are supposed to be singletons, that is why following methods are static |
212 | static TTask* GetRunDigitizer(); // |
213 | static TTask* GetRunSDigitizer(); // |
214 | static TTask* GetRunReconstructioner(); // |
215 | static TTask* GetRunTracker(); // |
216 | static TTask* GetRunPIDTask(); // |
217 | static TTask* GetRunQATask(); // |
218 | |
219 | static const TString fgkRunLoaderName; |
220 | static const TString fgkHeaderContainerName; //default name of the kinematics container (TREE) name - TreeE |
221 | static const TString fgkKineContainerName; //default name of the kinematics container (TREE) name - TreeK |
222 | static const TString fgkTrackRefsContainerName; //default name of the track references container (TREE) name - TreeTR |
223 | static const TString fgkHeaderBranchName; |
224 | static const TString fgkKineBranchName; |
225 | static const TString fgkGAliceName; |
226 | |
227 | ClassDef(AliRunLoader,1) |
228 | }; |
229 | |
230 | #endif |