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