]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliReconstruction.h
Using the recently introduced raw-reader factory method and the new uri scheme for...
[u/mrichter/AliRoot.git] / STEER / AliReconstruction.h
1 #ifndef ALIRECONSTRUCTION_H
2 #define ALIRECONSTRUCTION_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////////
9 //                                                                           //
10 // class for running the reconstruction                                      //
11 // Clusters and tracks are created for all detectors and all events by       //
12 // typing:                                                                   //
13 //                                                                           //
14 //   AliReconstruction rec;                                                  //
15 //   rec.Run();                                                              //
16 //                                                                           //
17 ///////////////////////////////////////////////////////////////////////////////
18
19
20 #include <TNamed.h>
21 #include <TString.h>
22 #include <TObjArray.h>
23
24 class AliReconstructor;
25 class AliRunLoader;
26 class AliRawReader;
27 class AliLoader;
28 class AliTracker;
29 class AliVertexer;
30 class AliESDVertex;
31 class AliESDEvent;
32 class AliESDfriend;
33 class AliVertexerTracks;
34 class TFile;
35 class TTree;
36 class TList;
37 class AliQADataMakerRec;
38
39 class AliReconstruction: public TNamed {
40 public:
41   AliReconstruction(const char* gAliceFilename = "galice.root",
42                     const char* name = "AliReconstruction", 
43                     const char* title = "reconstruction");
44   AliReconstruction(const AliReconstruction& rec);
45   AliReconstruction& operator = (const AliReconstruction& rec);
46   virtual ~AliReconstruction();
47
48   void           SetGAliceFile(const char* fileName);
49   void           SetInput(const char* input);
50
51   void           SetEquipmentIdMap(const char *mapFile) {fEquipIdMap = mapFile;};
52   void           SetEventRange(Int_t firstEvent = 0, Int_t lastEvent = -1) 
53     {fFirstEvent = firstEvent; fLastEvent = lastEvent;};
54   void           SetNumberOfEventsPerFile(UInt_t nEvents)
55     {fNumberOfEventsPerFile = nEvents;};
56   void           SetOption(const char* detector, const char* option);
57
58   void           SetRunLocalReconstruction(const char* detectors) {
59     fRunLocalReconstruction = detectors;};
60   void           SetRunTracking(const char* detectors) {
61     fRunTracking = detectors;};
62   void           SetFillESD(const char* detectors) {fFillESD = detectors;};
63   void           SetRunReconstruction(const char* detectors) {
64     SetRunLocalReconstruction(detectors); 
65     SetRunTracking(detectors);
66     SetFillESD(detectors);};
67   void           SetUseTrackingErrorsForAlignment(const char* detectors) 
68     {fUseTrackingErrorsForAlignment = detectors;};
69   void           SetLoadAlignFromCDB(Bool_t load)  {fLoadAlignFromCDB = load;};
70   void           SetLoadAlignData(const char* detectors) 
71     {fLoadAlignData = detectors;};
72   void           SetESDParLocation(const char *c){fESDPar = c;}
73   TNamed *CopyFileToTNamed(TString fPath,TString fName);
74   void  TNamedToFile(TTree* fTree, TString fName);
75
76   //*** Global reconstruction flag setters
77   void SetUniformFieldTracking(Bool_t flag=kTRUE){fUniformField=flag;} 
78   void SetRunVertexFinder(Bool_t flag=kTRUE) {fRunVertexFinder=flag;};
79   void SetRunVertexFinderTracks(Bool_t flag=kTRUE) {fRunVertexFinderTracks=flag;};
80   void SetRunHLTTracking(Bool_t flag=kTRUE) {fRunHLTTracking=flag;};
81   void SetRunV0Finder(Bool_t flag=kTRUE) {fRunV0Finder=flag;};
82   void SetRunCascadeFinder(Bool_t flag=kTRUE) {fRunCascadeFinder=flag;};
83   void SetStopOnError(Bool_t flag=kTRUE) {fStopOnError=flag;}
84   void SetWriteAlignmentData(Bool_t flag=kTRUE){fWriteAlignmentData=flag;}
85   void SetWriteESDfriend(Bool_t flag=kTRUE){fWriteESDfriend=flag;}
86   void SetWriteAOD(Bool_t flag=kTRUE){fWriteAOD=flag;}
87   void SetFillTriggerESD(Bool_t flag=kTRUE){fFillTriggerESD=flag;}
88   void SetDiamondProfile(AliESDVertex *dp) {fDiamondProfile=dp;}
89   void SetDiamondProfileTPC(AliESDVertex *dp) {fDiamondProfileTPC=dp;}
90   void SetMeanVertexConstraint(Bool_t flag=kTRUE){fMeanVertexConstraint=flag;}
91                    
92   void SetCleanESD(Bool_t flag=kTRUE){fCleanESD=flag;}
93   void SetUseHLTData(const char* detectors){fUseHLTData=detectors;}
94   void SetV0DCAmax(Float_t d) {fV0DCAmax=d;}
95   void SetV0CsPmin(Float_t d) {fV0CsPmin=d;}
96   void SetDmax(Float_t d) {fDmax=d;}
97   void SetZmax(Float_t z) {fZmax=z;}
98   Float_t GetV0DCAmax() const {return fV0DCAmax;}
99   Float_t GetV0CsPmin() const {return fV0CsPmin;}
100   Float_t GetDmax() const {return fDmax;}
101   Float_t GetZmax() const {return fZmax;}
102
103   void           SetCheckPointLevel(Int_t checkPointLevel)
104     {fCheckPointLevel = checkPointLevel;}
105   
106   // CDB storage activation
107   void SetDefaultStorage(const char* uri);
108   void SetSpecificStorage(const char* calibType, const char* uri);
109
110   Bool_t MisalignGeometry(const TString& detectors);
111
112   void           SetAlignObjArray(TObjArray *array)
113                    {fAlignObjArray = array;
114                    fLoadAlignFromCDB = kFALSE;}
115
116   virtual Bool_t InitRun(const char* input);
117   virtual Bool_t RunEvent(Int_t iEvent);
118   virtual Bool_t FinishRun();
119   virtual Bool_t Run(const char* input = NULL);
120
121   // Quality Assurance 
122   virtual Bool_t RunQA(const char* detectors, AliESDEvent *& esd);
123   void    SetQACycles(const char * detector, const Int_t cycles) { fQACycles[GetDetIndex(detector)] = cycles ; }
124   void    SetRunQA(Bool_t flag=kTRUE)      {fRunQA = flag ;} 
125   void    SetRunGlobalQA(Bool_t flag=kTRUE){fRunGlobalQA = flag;}
126   void    SetInLoopQA(Bool_t flag=kTRUE)   {fInLoopQA    = flag;} 
127
128   // Plane Efficiency Evaluation
129   void    SetRunPlaneEff(Bool_t flag=kFALSE)  {fRunPlaneEff = flag;}
130
131 private:
132   void           InitCDB();
133   void           SetCDBLock();
134   Bool_t         SetRunNumberFromData();
135   Bool_t         RunLocalReconstruction(const TString& detectors);
136   Bool_t         RunLocalEventReconstruction(const TString& detectors);
137   Bool_t         RunVertexFinder(AliESDEvent*& esd);
138   Bool_t         RunHLTTracking(AliESDEvent*& esd);
139   Bool_t         RunMuonTracking(AliESDEvent*& esd);
140   Bool_t         RunTracking(AliESDEvent*& esd);
141   Bool_t         CleanESD(AliESDEvent *esd);
142   Bool_t         FillESD(AliESDEvent*& esd, const TString& detectors);
143   Bool_t         FillTriggerESD(AliESDEvent*& esd);
144   Bool_t         FillRawEventHeaderESD(AliESDEvent*& esd);
145
146   Bool_t         IsSelected(TString detName, TString& detectors) const;
147   Bool_t         InitRunLoader();
148   AliReconstructor* GetReconstructor(Int_t iDet);
149   Bool_t         CreateVertexer();
150   Bool_t         CreateTrackers(const TString& detectors);
151   void           CleanUp(TFile* file = NULL, TFile* fileOld = NULL);
152
153   Bool_t         ReadESD(AliESDEvent*& esd, const char* recStep) const;
154   void           WriteESD(AliESDEvent* esd, const char* recStep) const;
155
156   //==========================================//
157   void           WriteAlignmentData(AliESDEvent* esd);
158
159   void           FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd);
160
161   //Quality Assurance
162   Int_t                GetDetIndex(const char * detector);
163   AliQADataMakerRec*   GetQADataMaker(Int_t iDet);
164   const Int_t          GetQACycles(const char * detector) { return fQACycles[GetDetIndex(detector)] ; }
165   void                 CheckQA() ;
166
167   // Plane Efficiency evaluation
168   Bool_t  FinishPlaneEff(); //ultimate tasks related to Plane Eff. evaluation 
169   Bool_t  InitPlaneEff();   // initialize what is needed for Plane Eff. evaluation
170
171   //*** Global reconstruction flags *******************
172   Bool_t         fUniformField;       // uniform field tracking flag
173   Bool_t         fRunVertexFinder;    // run the vertex finder
174   Bool_t         fRunVertexFinderTracks;    // run the vertex finder with tracks
175   Bool_t         fRunHLTTracking;     // run the HLT tracking
176   Bool_t         fRunMuonTracking;    // run the HLT tracking
177   Bool_t         fRunV0Finder;        // run the ESD V0 finder
178   Bool_t         fRunCascadeFinder;   // run the ESD cascade finder
179   Bool_t         fStopOnError;        // stop or continue on errors
180   Bool_t         fWriteAlignmentData; // write track space-points flag
181   Bool_t         fWriteESDfriend;     // write ESD friend flag
182   Bool_t         fWriteAOD;           // write AOD flag
183   Bool_t         fFillTriggerESD;     // fill trigger info into ESD
184
185   //*** Clean ESD flag and parameters *******************
186   Bool_t         fCleanESD;      // clean ESD flag
187   Float_t        fV0DCAmax;      // max. allowed DCA between V0 daugthers 
188   Float_t        fV0CsPmin;      // min. allowed cosine of V0 pointing angle 
189   Float_t        fDmax;          // max. allowed transverse impact parameter 
190   Float_t        fZmax;          // max. allowed longitudinal impact parameter 
191
192   TString        fRunLocalReconstruction; // run the local reconstruction for these detectors
193   TString        fRunTracking;        // run the tracking for these detectors
194   TString        fFillESD;            // fill ESD for these detectors
195   TString        fUseTrackingErrorsForAlignment; // for these detectors
196   TString        fGAliceFileName;     // name of the galice file
197   TString        fInput;              // name of input file or directory
198   TString        fEquipIdMap;         // name of file with equipment id map
199   Int_t          fFirstEvent;         // index of first event to be reconstr.
200   Int_t          fLastEvent;          // index of last event to be reconstr.
201   UInt_t         fNumberOfEventsPerFile; // number of events per file in case of raw-data reconstruction
202   Int_t          fCheckPointLevel;    // level of ESD check points
203   TObjArray      fOptions;            // options for reconstructor objects
204   Bool_t         fLoadAlignFromCDB;   // Load alignment data from CDB and apply it to geometry or not
205   TString        fLoadAlignData;      // Load alignment data from CDB for these detectors
206   TString        fESDPar;             // String where the esd.par is stored, will be attached to the tree         
207   TString        fUseHLTData;        // Detectors for which the HLT data is used as input
208
209   AliRunLoader*  fRunLoader;          //! current run loader object
210   AliRawReader*  fRawReader;          //! current raw data reader
211   AliRawReader*  fParentRawReader;    //! parent raw data reader in case of AliRawReaderHLT
212
213   static const Int_t fgkNDetectors = 15;   //! number of detectors
214   static const char* fgkDetectorName[fgkNDetectors]; //! names of detectors
215   AliReconstructor*  fReconstructor[fgkNDetectors];  //! array of reconstructor objects
216   AliLoader*     fLoader[fgkNDetectors];   //! detector loaders
217   AliVertexer*   fVertexer;                //! vertexer for ITS
218   AliTracker*    fTracker[fgkNDetectors];  //! trackers
219   AliESDVertex*  fDiamondProfile;          // (x,y) diamond profile for AliVertexerTracks
220   AliESDVertex*  fDiamondProfileTPC;       // (x,y) diamond profile from TPC for AliVertexerTracks
221   Bool_t         fMeanVertexConstraint; // use fDiamondProfile in AliVertexerTracks
222
223   TList*         fGRPList;            // TList from the GRP/GRP/Data CDB folder
224
225   TObjArray*     fAlignObjArray;      // array with the alignment objects to be applied to the geometry
226
227   TString        fCDBUri;             // Uri of the default CDB storage
228   TObjArray      fSpecCDBUri;         // Array with detector specific CDB storages
229   Bool_t         fInitCDBCalled;               //! flag to check if CDB storages are already initialized
230   Bool_t         fSetRunNumberFromDataCalled;  //! flag to check if run number is already loaded from run loader
231
232   //Quality Assurance
233   AliQADataMakerRec *fQADataMaker[fgkNDetectors+1];  //! array of QA data makers
234   Int_t fQACycles[   fgkNDetectors];// # events over which QA data are accumulated
235   Bool_t             fRunQA ;        // Run QA flag
236   Bool_t             fRunGlobalQA;   // Run global QA flag
237   Bool_t             fInLoopQA;      // In-loop QA flag
238   Bool_t             fSameQACycle;   //! open a vew QA data file or not
239   // Plane Efficiency Evaluation
240   Bool_t         fRunPlaneEff ;      // Evaluate Plane Efficiency
241
242   // New members needed in order to split Run method
243   // into InitRun,RunEvent,FinishRun methods
244   AliESDEvent*         fesd;        //! Pointer to the ESD event object
245   AliESDEvent*         fhltesd;     //! Pointer to the HLT ESD event object
246   AliESDfriend*        fesdf;       //! Pointer to the ESD friend object
247   TFile*               ffile;       //! Pointer to the ESD file
248   TTree*               ftree;       //! Pointer to the ESD tree
249   TTree*               fhlttree;    //! Pointer to the HLT ESD tree
250   TFile*               ffileOld;    //! Pointer to the previous ESD file
251   TTree*               ftreeOld;    //! Pointer to the previous ESD tree
252   TTree*               fhlttreeOld; //! Pointer to the previous HLT ESD tree
253   AliVertexerTracks*   ftVertexer;  //! Pointer to the vertexer based on ESD tracks
254   Bool_t               fIsNewRunLoader; // galice.root created from scratch (real raw data case)
255
256   ClassDef(AliReconstruction, 22)      // class for running the reconstruction
257 };
258
259 #endif