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