]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliRunLoader.h
Updates (A. Toia)
[u/mrichter/AliRoot.git] / STEER / AliRunLoader.h
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
27 #include "AliConfig.h"
28 #include "AliLoader.h"
29 #include "AliDataLoader.h"
30 #include "AliLog.h"
31
32 class TFile;
33 class TString;
34 class TFolder;
35 class TObjArray;
36 class TTree;
37 class TTask;
38 class TParticle;
39
40 class AliRun;
41 class AliLoader;
42 class AliDetector;
43 class AliHeader;
44 class AliStack;
45 class AliRunDigitizer;
46 class AliCDBEntry;
47 class AliCentralTrigger;
48
49 class AliRunLoader: public TNamed
50 {
51   public:
52     
53     AliRunLoader();
54     AliRunLoader(const char* topfoldername);
55     AliRunLoader(TFolder* topfolder);
56     
57     virtual ~AliRunLoader();
58     
59     static AliRunLoader* Open(const char* filename = "galice.root",
60                               const char* eventfoldername = AliConfig::GetDefaultEventFolderName(),
61                   Option_t* option = "READ");
62
63     Int_t       GetEventNumber() const {return fCurrentEvent;}
64
65     Int_t       GetEvent(Int_t evno);//sets the event number and reloads data in folders properly
66     Int_t       GetNextEvent(){return GetEvent(fCurrentEvent+1);}//gets next event 
67     Int_t       SetEventNumber(Int_t evno); //cleans folders and sets the root dirs in files (do not reload data)
68     Int_t       SetNextEvent(){return SetEventNumber(fCurrentEvent+1);}
69     
70     Int_t       GetNumberOfEvents();
71     
72     AliCDBEntry* GetCDBEntry(const char* name) const;
73
74     void        MakeTree(Option_t *option);
75     void        MakeHeader();
76     void        MakeTrigger();
77     void        MakeStack();
78     
79     Int_t       LoadgAlice();
80     Int_t       LoadHeader();
81     Int_t       LoadKinematics(Option_t* option = "READ");
82     Int_t       LoadTrigger(Option_t* option = "READ");
83     Int_t       LoadTrackRefs(Option_t* option = "READ");
84     
85     void        UnloadHeader();
86     void        UnloadTrigger();
87     void        UnloadKinematics();
88     void        UnloadgAlice();
89     void        UnloadTrackRefs();
90     
91     void        SetKineFileName(const TString& fname){fKineDataLoader->SetFileName(fname);}
92     void        SetTrackRefsFileName(const TString& fname){fTrackRefsDataLoader->SetFileName(fname);}
93     
94     TTree*      TreeE() const; //returns the tree from folder; shortcut method
95     TTree*      TreeCT() const; //returns the tree from folder; shortcut method
96     AliHeader*  GetHeader() const;
97     AliCentralTrigger*  GetTrigger() const;
98     
99     AliStack*   Stack() const {return fStack;}
100     
101     TTree*      TreeK() const; //returns the tree from folder; shortcut method
102     TTree*      TreeTR() const; //returns the tree from folder; shortcut method    
103     
104     AliRun*     GetAliRun()const;
105     Int_t       GetRunNumber() const {return fRun;}
106     void        SetRunNumber(Int_t run) {fRun=run;}
107         
108     Int_t       WriteHeader(Option_t* opt="");
109     Int_t       WriteTrigger(Option_t* opt="");
110     Int_t       WriteAliRun(Option_t* opt="");
111     Int_t       WriteKinematics(Option_t* opt="");
112     Int_t       WriteTrackRefs(Option_t* opt="");
113     Int_t       WriteRunLoader(Option_t* opt="");
114     
115     Int_t       WriteHits(Option_t* opt=""); 
116     Int_t       WriteSDigits(Option_t* opt="");
117     Int_t       WriteDigits(Option_t* opt="");
118     Int_t       WriteRecPoints(Option_t* opt="");
119     Int_t       WriteTracks(Option_t* opt="");
120     
121     Int_t       LoadHits(Option_t* detectors = "all",Option_t* opt = "READ");
122     Int_t       LoadSDigits(Option_t* detectors = "all",Option_t* opt = "READ");
123     Int_t       LoadDigits(Option_t* detectors = "all",Option_t* opt = "READ");
124     Int_t       LoadRecPoints(Option_t* detectors = "all",Option_t* opt = "READ");
125     Int_t       LoadTracks(Option_t* detectors = "all",Option_t* opt = "READ");
126     Int_t       LoadRecParticles(Option_t* detectors = "all",Option_t* opt = "READ");
127     
128     void        UnloadHits(Option_t* detectors = "all");
129     void        UnloadSDigits(Option_t* detectors = "all");
130     void        UnloadDigits(Option_t* detectors = "all");
131     void        UnloadRecPoints(Option_t* detectors = "all");
132     void        UnloadTracks(Option_t* detectors = "all");
133     void        UnloadRecParticles(Option_t* detectors = "all");
134     void        UnloadAll(Option_t* detectors = "all");    
135     
136     void        AddLoader(AliLoader* loader);
137     void        AddLoader(AliDetector* det);
138     AliLoader*  GetLoader(const char* detname) const;
139     AliLoader*  GetLoader(AliDetector* det) const;
140     Int_t       SetEventFolderName(const TString& name = AliConfig::GetDefaultEventFolderName());//sets top folder name for this run; of alread
141     void        CleanFolders();//removes all abjects from folder structure
142     void        CleanDetectors();
143     void        CleanKinematics(){Clean(fgkKineContainerName);}
144     void        CleanTrackRefs(){Clean(fgkTrackRefsContainerName);}
145     
146     void        RemoveEventFolder(); //remove folder structure from top folder 
147     void        SetCompressionLevel(Int_t cl);
148     void        SetKineComprLevel(Int_t cl);
149     void        SetTrackRefsComprLevel(Int_t cl);
150
151     TFolder*    GetEventFolder() const {return fEventFolder;}
152     void        CdGAFile();
153
154     void        MakeTrackRefsContainer();
155     void        SetDirName(TString& dirname);
156     Int_t       GetFileOffset() const;
157     void        SetNumberOfEventsPerFile(Int_t nevpf){fNEventsPerFile = nevpf;}
158     void        SetNumberOfEventsPerRun(Int_t nevpr) {fNEventsPerRun = nevpr;}
159     Int_t       GetNumberOfEventsPerRun()            {return fNEventsPerRun;}
160     void        SetDigitsFileNameSuffix(const TString& suffix);//adds the suffix before ".root", 
161                                                                //e.g. TPC.Digits.root -> TPC.DigitsMerged.root
162                                                                //made on Jiri Chudoba demand
163     TString     GetFileName() const;//returns name of galice file
164     const TObjArray* GetArrayOfLoaders() const {return fLoaders;}
165     void Cd(){fgRunLoader = this;}
166     void Synchronize();
167     
168     AliLoader*    GetDetectorLoader(const char* detname);
169     TTree*        GetTreeH(const char* detname, Bool_t maketree);
170     TTree*        GetTreeS(const char* detname, Bool_t maketree);
171     TTree*        GetTreeD(const char* detname, Bool_t maketree);
172     TTree*        GetTreeR(const char* detname, Bool_t maketree);
173     TTree*        GetTreeT(const char* detname, Bool_t maketree);
174     TTree*        GetTreeP(const char* detname, Bool_t maketree);
175
176   /******************************************/
177   /*****   Public S T A T I C Stuff   *******/
178   /******************************************/
179     static AliRunLoader* GetRunLoader(const char* eventfoldername);
180     static AliRunLoader* Instance(){return fgRunLoader;}
181     static AliLoader*    GetDetectorLoader(const char* detname, const char* eventfoldername);
182     static TTree*        GetTreeH(const char* detname, Bool_t maketree, const char* eventfoldername);
183     static TTree*        GetTreeS(const char* detname, Bool_t maketree, const char* eventfoldername);
184     static TTree*        GetTreeD(const char* detname, Bool_t maketree, const char* eventfoldername);
185     static TTree*        GetTreeR(const char* detname, Bool_t maketree, const char* eventfoldername);
186     static TTree*        GetTreeT(const char* detname, Bool_t maketree, const char* eventfoldername);
187     static TTree*        GetTreeP(const char* detname, Bool_t maketree, const char* eventfoldername);
188
189 //  Tasks are supposed to be singletons, that is why following methods are static
190     static TTask*           GetRunDigitizer();        //
191     static TTask*           GetRunSDigitizer();       //
192     static TTask*           GetRunReconstructioner(); //
193     static TTask*           GetRunTracker();          //
194     static TTask*           GetRunPIDTask();          // 
195     static TTask*           GetRunQATask();           //
196
197     static TString GetRunLoaderName () {return fgkRunLoaderName;}
198     static TString GetHeaderContainerName () {return fgkHeaderContainerName;}
199     static TString GetTriggerContainerName () {return fgkTriggerContainerName;}
200     static TString GetKineContainerName () {return fgkKineContainerName;}
201     static TString GetTrackRefsContainerName () {return fgkTrackRefsContainerName;}
202     static TString GetHeaderBranchName () {return fgkHeaderBranchName;}
203     static TString GetTriggerBranchName () {return fgkTriggerBranchName;}
204     static TString GetKineBranchName () {return fgkKineBranchName;}
205     static TString GetTriggerFileName() { return fgkDefaultTriggerFileName; }
206     static TString GetGAliceName () {return fgkGAliceName;}
207      
208 protected:
209     void               SetGAliceFile(TFile* gafile);//sets the pointer to gAlice file
210     Int_t              OpenKineFile(Option_t* opt);
211     Int_t              OpenTrackRefsFile(Option_t* opt);
212
213     Int_t              OpenDataFile(const TString& filename,TFile*& file,TDirectory*& dir,Option_t* opt,Int_t cl);
214     void               SetUnixDir(const TString& udirname);
215     const TString      SetFileOffset(const TString& fname);//adds the proper number before .root
216     void               SetDetectorAddresses();
217
218     TObjArray         *fLoaders;          //  List of Detectors
219     TFolder           *fEventFolder;      //!top folder for this run
220     
221     Int_t              fRun;               //! Current run number
222     Int_t              fCurrentEvent;//!Number of current event
223     
224     TFile             *fGAFile;//!  pointer to main file with AliRun and Run Loader -> galice.root 
225     AliHeader         *fHeader;//!  pointer to header
226     AliStack          *fStack; //!  pointer to stack
227     AliCentralTrigger *fCTrigger; //! pointer to CEntral Trigger Processor
228     
229     AliDataLoader     *fKineDataLoader;// kinematics data loader
230     AliDataLoader     *fTrackRefsDataLoader;//track reference data loader
231     
232     Int_t              fNEventsPerFile;  //defines number of events stored per one file
233     Int_t              fNEventsPerRun;   //defines number of event per run
234     TString            fUnixDirName;     //! name of unix path to directory that contains event
235     static const TString   fgkDefaultKineFileName;//default file name with kinamatics
236     static const TString   fgkDefaultTrackRefsFileName;//default file name with kinamatics
237     static const TString   fgkDefaultTriggerFileName;//default file name with trigger
238
239         
240   private:
241     AliRunLoader(const AliRunLoader &r);      //Not implemented
242     AliRunLoader & operator = (const AliRunLoader &); //Not implemented 
243     void  GetListOfDetectors(const char * namelist,TObjArray& pointerarray) const;
244     void  CleanHeader(){Clean(fgkHeaderContainerName);}
245     void  CleanTrigger(){Clean(fgkTriggerContainerName);}
246     void  Clean(const TString& name);
247     Int_t SetEvent();
248    
249     static AliRunLoader*   fgRunLoader; //pointer to the AliRunLoader instance
250
251     static const TString   fgkRunLoaderName;          //default name of the run loader
252     static const TString   fgkHeaderContainerName;    //default name of the kinematics container (TREE) name - TreeE
253     static const TString   fgkTriggerContainerName;   //default name of the trigger container (TREE) name - TreeCT
254     static const TString   fgkKineContainerName;      //default name of the kinematics container (TREE) name - TreeK
255     static const TString   fgkTrackRefsContainerName; //default name of the track references container (TREE) name - TreeTR
256     static const TString   fgkHeaderBranchName;       //default name of the branch containing the header
257     static const TString   fgkTriggerBranchName;      //default name of the branch containing the trigger
258     static const TString   fgkKineBranchName;         //default name of the branch with kinematics
259     static const TString   fgkGAliceName;             //default name for gAlice file    
260     
261     ClassDef(AliRunLoader,3)
262 };
263
264 #endif