]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliReconstruction.h
Undo previous commit
[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 <TSelector.h>
21 #include <TString.h>
22 #include <TUrl.h>
23 #include <TObjArray.h>
24
25 class AliReconstructor;
26 class AliRunLoader;
27 class AliRawReader;
28 class AliLoader;
29 class AliTracker;
30 class AliMagF;
31 class AliVertexer;
32 class AliESDVertex;
33 class AliESDEvent;
34 class AliESDfriend;
35 class AliVertexerTracks;
36 class TFile;
37 class TTree;
38 class TList;
39 class AliQAManager; 
40 class TMap;
41 class AliRecoParam;
42 class AliDetectorRecoParam;
43 class AliRunInfo;
44 class AliGRPObject;
45 class THashTable;
46 class AliTriggerRunScalers;
47 class AliCTPTimeParams;
48
49 #include "AliQAv1.h"
50 #include "AliEventInfo.h"
51 #include "AliRecoParam.h"
52
53 class AliReconstruction: public TSelector {
54 public:
55   AliReconstruction(const char* gAliceFilename = "galice.root");
56   virtual ~AliReconstruction();
57
58   void           SetGAliceFile(const char* fileName);
59   void           SetInput(const char* input);
60   void           SetOutput(const char* output);
61
62   void           SetEquipmentIdMap(const char *mapFile) {fEquipIdMap = mapFile;};
63   void           SetEventRange(Int_t firstEvent = 0, Int_t lastEvent = -1) 
64     {fFirstEvent = firstEvent; fLastEvent = lastEvent;};
65   void           SetNumberOfEventsPerFile(UInt_t nEvents)
66     {fNumberOfEventsPerFile = nEvents;};
67   void           SetOption(const char* detector, const char* option);
68   void           SetRecoParam(const char* detector, AliDetectorRecoParam *par);
69
70   void           SetRunLocalReconstruction(const char* detectors) {
71     fRunLocalReconstruction = detectors;};
72   void           SetRunTracking(const char* detectors) {
73     fRunTracking = detectors;};
74   void           SetFillESD(const char* detectors) {fFillESD = detectors;};
75   void           SetRunReconstruction(const char* detectors) {
76     SetRunLocalReconstruction(detectors); 
77     SetRunTracking(detectors);
78     SetFillESD(detectors);};
79   void           SetUseTrackingErrorsForAlignment(const char* detectors) 
80     {fUseTrackingErrorsForAlignment = detectors;};
81   void           SetLoadAlignFromCDB(Bool_t load)  {fLoadAlignFromCDB = load;};
82   void           SetLoadAlignData(const char* detectors) 
83     {fLoadAlignData = detectors;};
84
85   //*** Global reconstruction flag setters
86   void SetRunVertexFinder(Bool_t flag=kTRUE) {fRunVertexFinder=flag;};
87   void SetRunVertexFinderTracks(Bool_t flag=kTRUE) {fRunVertexFinderTracks=flag;};
88   void SetRunHLTTracking(Bool_t flag=kTRUE) {fRunHLTTracking=flag;};
89   void SetRunV0Finder(Bool_t flag=kTRUE) {fRunV0Finder=flag;};
90   void SetRunCascadeFinder(Bool_t flag=kTRUE) {fRunCascadeFinder=flag;};
91   void SetStopOnError(Bool_t flag=kTRUE) {fStopOnError=flag;}
92   void SetWriteAlignmentData(Bool_t flag=kTRUE){fWriteAlignmentData=flag;}
93   void SetWriteESDfriend(Bool_t flag=kTRUE){fWriteESDfriend=flag;}
94   void SetFillTriggerESD(Bool_t flag=kTRUE){fFillTriggerESD=flag;}
95   void SetDiamondProfileSPD(AliESDVertex *dp) {fDiamondProfileSPD=dp;}
96   void SetDiamondProfile(AliESDVertex *dp) {fDiamondProfile=dp;}
97   void SetDiamondProfileTPC(AliESDVertex *dp) {fDiamondProfileTPC=dp;}
98                    
99   void SetCleanESD(Bool_t flag=kTRUE){fCleanESD=flag;}
100   void SetUseHLTData(const char* detectors){fUseHLTData=detectors;}
101   void SetV0DCAmax(Float_t d) {fV0DCAmax=d;}
102   void SetV0CsPmin(Float_t d) {fV0CsPmin=d;}
103   void SetDmax(Float_t d) {fDmax=d;}
104   void SetZmax(Float_t z) {fZmax=z;}
105   Float_t GetV0DCAmax() const {return fV0DCAmax;}
106   Float_t GetV0CsPmin() const {return fV0CsPmin;}
107   Float_t GetDmax() const {return fDmax;}
108   Float_t GetZmax() const {return fZmax;}
109   
110   // CDB storage activation
111   void SetDefaultStorage(const char* uri);
112   void SetSpecificStorage(const char* calibType, const char* uri);
113
114   Bool_t MisalignGeometry(const TString& detectors);
115
116   void           SetAlignObjArray(TObjArray *array)
117                    {fAlignObjArray = array;
118                    fLoadAlignFromCDB = kFALSE;}
119
120   virtual Int_t  Version() const {return 2;}
121   virtual void   Begin(TTree*);
122   virtual void   SlaveBegin(TTree*);
123   virtual void   Init(TTree *tree);
124   virtual Bool_t Process(Long64_t entry);
125   virtual Bool_t ProcessEvent(Int_t iEvent);
126   virtual void   SlaveTerminate();
127   virtual void   Terminate();
128   virtual Bool_t Run(const char* input = NULL);
129   void           Abort(const char *method, EAbort what);
130   virtual void   SetOption(const char* option) {
131     TSelector::SetOption(option);
132   }
133
134   // Trackers
135   AliTracker* GetTracker(Int_t idx) const { return fTracker[idx]; }
136   Bool_t      CreateTrackers(const TString& detectors);
137   void        ImportRunLoader(AliRunLoader* rl) { fRunLoader = rl; }
138
139   // Quality Assurance 
140   void    SetQACycles(AliQAv1::DETECTORINDEX_t det, Int_t cycles) { fQACycles[det] = cycles ; }
141   void    SetQAWriteExpert(AliQAv1::DETECTORINDEX_t det) { fQAWriteExpert[det] = kTRUE ; }
142   Bool_t  SetRunQA(TString detAndAction="ALL:ALL") ; 
143   void    SetRunGlobalQA(Bool_t flag=kTRUE){fRunGlobalQA = flag;}
144   void    SetQARefDefaultStorage(const char* uri);
145   void    InitQA();
146   void    MergeQA(const char *fileName = NULL); 
147   void    SetWriteQAExpert() { fWriteQAExpertData = kTRUE ; }
148
149   // Plane Efficiency Evaluation
150   void    SetRunPlaneEff(Bool_t flag=kFALSE)  {fRunPlaneEff = flag;}
151
152   enum {
153     kNDetectors = 15   // number of detectors
154   };
155   static Int_t   GetDetIndex(const char * detector);
156
157 protected:
158   virtual Bool_t ProcessEvent(void* event);
159   void           InitRun(const char* input);
160
161 private:
162   AliReconstruction(const AliReconstruction& rec);
163   AliReconstruction& operator = (const AliReconstruction& rec);
164
165   void           InitRawReader(const char* input);
166   void           InitCDB();
167   Bool_t         InitGRP();
168   void           SetCDBLock();
169   Bool_t         SetRunNumberFromData();
170   Bool_t         LoadCDB();
171   Bool_t         LoadTriggerScalersCDB();
172   Bool_t         LoadCTPTimeParamsCDB();
173   Bool_t         RunLocalEventReconstruction(const TString& detectors);
174   Bool_t         RunVertexFinder(AliESDEvent*& esd);
175   Bool_t         RunHLTTracking(AliESDEvent*& esd);
176   Bool_t         RunMuonTracking(AliESDEvent*& esd);
177   Bool_t         RunSPDTrackleting(AliESDEvent*& esd);
178   Bool_t         RunTracking(AliESDEvent*& esd);
179   Bool_t         CleanESD(AliESDEvent *esd);
180   Bool_t         FillESD(AliESDEvent*& esd, const TString& detectors);
181   Bool_t         FillTriggerESD(AliESDEvent*& esd);
182   Bool_t         FillTriggerScalers(AliESDEvent*& esd);
183   Bool_t         FillRawEventHeaderESD(AliESDEvent*& esd);
184
185   Bool_t         IsSelected(TString detName, TString& detectors) const;
186   Bool_t         InitRunLoader();
187   AliReconstructor* GetReconstructor(Int_t iDet);
188   AliVertexer*   CreateVertexer();
189   void           CleanUp();
190
191   Bool_t         ParseOutput();
192
193   //==========================================//
194   void           WriteAlignmentData(AliESDEvent* esd);
195
196   void           FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd);
197
198   //Quality Assurance
199   void                 CheckQA() ;
200
201   // Plane Efficiency evaluation
202   Bool_t  FinishPlaneEff(); //ultimate tasks related to Plane Eff. evaluation 
203   Bool_t  InitPlaneEff();   // initialize what is needed for Plane Eff. evaluation
204
205   Bool_t               InitAliEVE();
206   void                 RunAliEVE();
207
208   Bool_t         InitRecoParams(); // init the array with the reconstruciton parameters
209   Bool_t         GetEventInfo();   // fill the event info inside the event loop
210
211   const char    *MatchDetectorList(const char *detectorList, UInt_t detectorMask);
212
213   //*** Global reconstruction flags *******************
214   Bool_t         fRunVertexFinder;    // run the vertex finder
215   Bool_t         fRunVertexFinderTracks;    // run the vertex finder with tracks
216   Bool_t         fRunHLTTracking;     // run the HLT tracking
217   Bool_t         fRunMuonTracking;    // run the HLT tracking
218   Bool_t         fRunV0Finder;        // run the ESD V0 finder
219   Bool_t         fRunCascadeFinder;   // run the ESD cascade finder
220   Bool_t         fStopOnError;        // stop or continue on errors
221   Bool_t         fWriteAlignmentData; // write track space-points flag
222   Bool_t         fWriteESDfriend;     // write ESD friend flag
223   Bool_t         fFillTriggerESD;     // fill trigger info into ESD
224
225   //*** Clean ESD flag and parameters *******************
226   Bool_t         fCleanESD;      // clean ESD flag
227   Float_t        fV0DCAmax;      // max. allowed DCA between V0 daugthers 
228   Float_t        fV0CsPmin;      // min. allowed cosine of V0 pointing angle 
229   Float_t        fDmax;          // max. allowed transverse impact parameter 
230   Float_t        fZmax;          // max. allowed longitudinal impact parameter 
231
232   TString        fRunLocalReconstruction; // run the local reconstruction for these detectors
233   TString        fRunTracking;        // run the tracking for these detectors
234   TString        fFillESD;            // fill ESD for these detectors
235   TString        fLoadCDB;            // prefetch CDB entries and init reco-params for these detectors
236   TString        fUseTrackingErrorsForAlignment; // for these detectors
237   TString        fGAliceFileName;     // name of the galice file
238   TString        fRawInput;           // name of input raw-data file or directory
239   TString        fESDOutput;          //! name of output ESD file
240   TString        fProofOutputFileName;//! name of output file in PROOF mode
241   TString        fProofOutputLocation;//! output location in PROOF mode
242   Bool_t         fProofOutputDataset; //! keep output file in PROOF mode in dataset or merge
243   TString        fProofOutputArchive; //! list of file to be kept in output zip archive in PROOF mode
244   TString        fEquipIdMap;         // name of file with equipment id map
245   Int_t          fFirstEvent;         // index of first event to be reconstr.
246   Int_t          fLastEvent;          // index of last event to be reconstr.
247   UInt_t         fNumberOfEventsPerFile; // number of events per file in case of raw-data reconstruction
248   TObjArray      fOptions;            // options for reconstructor objects
249   Bool_t         fLoadAlignFromCDB;   // Load alignment data from CDB and apply it to geometry or not
250   TString        fLoadAlignData;      // Load alignment data from CDB for these detectors
251   TString        fUseHLTData;        // Detectors for which the HLT data is used as input
252   AliRunInfo*    fRunInfo;            // an object which contains essential global conditions information
253   AliEventInfo   fEventInfo;          // an object which contains essential event information
254   AliTriggerRunScalers* fRunScalers;  // an object which contains the trigger counters for xsection
255   AliCTPTimeParams* fCTPTimeParams;   // an object which contains the trigger delays
256   AliRunLoader*  fRunLoader;          //! current run loader object
257   AliRawReader*  fRawReader;          //! current raw data reader
258   AliRawReader*  fParentRawReader;    //! parent raw data reader in case of AliRawReaderHLT
259
260   static const char* fgkDetectorName[kNDetectors]; //! names of detectors
261   AliReconstructor*  fReconstructor[kNDetectors];  //! array of reconstructor objects
262   AliRecoParam   fRecoParam;                      // container for the reco-param objects for detectors
263   AliLoader*     fLoader[kNDetectors];   //! detector loaders
264   AliTracker*    fTracker[kNDetectors];  //! trackers
265   AliTracker*    fSPDTrackleter;           //! trackleter [for SPD Plane Efficiency purposes]
266   AliESDVertex*  fDiamondProfileSPD;       // (x,y) diamond profile from SPD for AliITSVertexer3D(Z)
267   AliESDVertex*  fDiamondProfile;          // (x,y) diamond profile for AliVertexerTracks (ITS+TPC)
268   AliESDVertex*  fDiamondProfileTPC;       // (x,y) diamond profile from TPC for AliVertexerTracks
269   THashTable*    fListOfCosmicTriggers;    // list of cosmic triggers as defined by trigger coordination
270
271   AliGRPObject*  fGRPData;              // Data from the GRP/GRP/Data CDB folder
272
273   TObjArray*     fAlignObjArray;      //! array with the alignment objects to be applied to the geometry
274
275   TString        fCDBUri;             //! Uri of the default CDB storage
276   TString        fQARefUri;         //! Uri of the default QA reference storage
277   TObjArray      fSpecCDBUri;         //! Array with detector specific CDB storages
278   Bool_t         fInitCDBCalled;               //! flag to check if CDB storages are already initialized
279   Bool_t         fSetRunNumberFromDataCalled;  //! flag to check if run number is already loaded from run loader
280
281   //Quality Assurance
282   Int_t  fQACycles[     AliQAv1::kNDET];  // # events over which QA data are accumulated
283   Bool_t fQAWriteExpert[AliQAv1::kNDET];  // Flag to save or not expert QA data
284   TString               fQADetectors ;  // list of detectors to be QA'ed        
285   TString               fQATasks ;      // list of QA tasks to be performed     
286   Bool_t                fRunQA ;        // Run QA flag
287   Bool_t                fRunGlobalQA;   // Run global QA flag
288   Bool_t                fSameQACycle;   //! open a new QA data file or not
289   Bool_t                fInitQACalled;  //! control of QA intialisation
290   Bool_t                fWriteQAExpertData ; //! decides wheter or not to write experts QA data; true by default
291
292   // Plane Efficiency Evaluation
293   Bool_t         fRunPlaneEff ;      // Evaluate Plane Efficiency
294
295   // New members needed in order to split Run method
296   // into InitRun,RunEvent,FinishRun methods
297   AliESDEvent*         fesd;        //! Pointer to the ESD event object
298   AliESDEvent*         fhltesd;     //! Pointer to the HLT ESD event object
299   AliESDfriend*        fesdf;       //! Pointer to the ESD friend object
300   TFile*               ffile;       //! Pointer to the ESD file
301   TTree*               ftree;       //! Pointer to the ESD tree
302   TTree*               fhlttree;    //! Pointer to the HLT ESD tree
303   AliVertexerTracks*   ftVertexer;  //! Pointer to the vertexer based on ESD tracks
304   Bool_t               fIsNewRunLoader; // galice.root created from scratch (real raw data case)
305   Bool_t               fRunAliEVE;  // Run AliEVE or not
306
307   TTree*              fChain;      //! The raw-data chain in case of AliRawReaderChain
308
309   ClassDef(AliReconstruction, 34)      // class for running the reconstruction
310 };
311
312 #endif