]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TRD/AliTRDresolution.h
General macro for QA checks
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDresolution.h
1 #ifndef ALITRDRESOLUTION_H
2 #define ALITRDRESOLUTION_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id: AliTRDresolution.h 27496 2008-07-22 08:35:45Z cblume $ */
7
8 ////////////////////////////////////////////////////////////////////////////
9 //                                                                        //
10 //  TRD Resolution performance                                            //
11 //                                                                        //
12 //  Authors:                                                              //
13 //    Alexandru Bercuci <A.Bercuci@gsi.de>                                //
14 //    Markus Fasel <M.Fasel@gsi.de>                                       //
15 //                                                                        //
16 ////////////////////////////////////////////////////////////////////////////
17
18 #ifndef ALITRDRECOTASK_H
19 #include "AliTRDrecoTask.h"
20 #endif
21
22 class TAxis;
23 class TH1;
24 class TH2;
25 class TH3;
26 class TF1;
27 class TGraphErrors;
28 class TObjArray;
29 class TDatabasePDG;
30 class AliTRDrecoParam;
31 class AliTRDseedV1;
32 class AliTRDtrackInfo;
33 class AliTrackPoint;
34 class AliTRDresolution : public AliTRDrecoTask
35 {
36 public:
37   enum ETRDresolutionSteer {
38      kVerbose    = BIT(18) // switch verbosity
39     ,kVisual     = BIT(19) // show partial results during processing
40     ,kTrackRefit = BIT(20) // steer track refit
41     ,kTrackSelect= BIT(21) // steer track selection
42     ,kXchange    = BIT(22) // use exchange containers
43   };
44   enum ETRDresolutionSlots {
45      kClToTrk    = 2
46     ,kClToMC
47     ,kTrkltToTrk
48     ,kTrkltToMC
49     ,kNSlots     = 4
50   };
51   enum ETRDresolutionClass {
52     kCluster=0        // cluster - track
53     ,kTracklet        // tracklet - track residuals/pulls
54     ,kTrackIn         // tracklet - track residuals/pulls at lower TRD entrance
55     ,kMCcluster       // cluster-mc resolution/pulls
56     ,kMCtracklet      // tracklet-mc resolution/pulls
57     ,kMCtrackIn       // TPC track monitor
58     ,kMCtrack         // TRD track monitor
59 /*    ,kTrackOut        // tracklet - track residuals/pulls at lower TRD entrance during refit
60     ,kMCtrackOut      // TOF/HMPID track monitor*/
61     ,kNclasses        // total number of resolution classes
62   };
63   enum ETRDresolutionClassProjs {
64     kClNproj=48       // cluster projections
65     ,kTrkltNproj=258  // tracklet projections
66     ,kTrkInNproj=42   // trackIn projections
67     ,kTrkNproj=72     // track projections
68     ,kMCTrkInNproj=62 // trackIn projections
69   };
70   enum ETRDresolutionProjs {
71     kBC    = 0 // bunch cross
72     ,kPhi
73     ,kEta
74     ,kYrez
75     ,kPrez
76     ,kZrez
77     ,kSpeciesChgRC
78     ,kPt
79     ,kNdim  // no of dimensions in the THnSparse
80   };
81   enum ETRDresolutionSize {
82      kNdimCl      = 4
83     ,kNdimTrklt   = 4
84     ,kNdimTrkIn   = 7
85     ,kNbunchCross = 3  // no of classes for bunch crossing
86     ,kNpt         = 3  // no of log bins in pt spectrum
87     ,kNcharge     = 2
88   };
89
90   AliTRDresolution();
91   AliTRDresolution(char* name, Bool_t xchange=kTRUE);
92   virtual ~AliTRDresolution();
93   
94   static Bool_t   FitTrack(const Int_t np, AliTrackPoint *points, Float_t params[10]);
95   static Bool_t   FitTracklet(const Int_t ly, const Int_t np, const AliTrackPoint *points, const Float_t trackPars[10], Float_t trackletPars[3]);
96   void            UserCreateOutputObjects();
97 //  Float_t GetCorrectionX(Int_t det, Int_t tb) const {return fXcorr[det][tb];}
98   Float_t         GetDyRange() const {return fDyRange;}
99   static Float_t  GetMeanStat(TH1 *h, Float_t cut=0., Option_t *opt="");
100   Float_t         GetPtThreshold() const {return fPtThreshold;}
101   static Int_t    GetPtBin(Float_t pt);
102   Bool_t          GetRefFigure(Int_t ifig);
103
104   virtual TObjArray*  Histos(); 
105 //  Bool_t  Load(const Char_t *file = "AnalysisResults.root", const Char_t *dir="TRD_Performance");
106 //  Bool_t  LoadCorrection(const Char_t *file=NULL);
107   void            MakeSummary();
108   static void     MakePtSegmentation(Float_t pt0=0.5, Float_t dpt=0.002);
109
110   TObjArray*      Results(ETRDresolutionClass c) const  { if(!fProj) return NULL; return (TObjArray*)fProj->At(c);}
111   void            UserExec(Option_t * opt);
112   void            InitExchangeContainers();
113   Bool_t          HasTrackRefit() const                 { return TestBit(kTrackRefit);}
114   Bool_t          HasTrackSelection() const             { return TestBit(kTrackSelect);}
115   Bool_t          IsVerbose() const                     { return TestBit(kVerbose);}
116   Bool_t          IsVisual() const                      { return TestBit(kVisual);}
117   Bool_t          UseBCselectTOF() const                { return fBCbinTOF>0;}
118   Bool_t          UseBCselectFill() const               { return fBCbinFill>0;}
119   Bool_t          UseExchangeContainers() const         { return TestBit(kXchange);}
120   Bool_t          PostProcess();
121
122   TH1*            PlotCluster(const AliTRDtrackV1 *t=NULL);
123   TH1*            PlotTracklet(const AliTRDtrackV1 *t=NULL);
124   TH1*            PlotTrackIn(const AliTRDtrackV1 *t=NULL);
125 //  TH1*            PlotTrackOut(const AliTRDtrackV1 *t=NULL);
126   TH1*            PlotMC(const AliTRDtrackV1 *t=NULL);
127
128   static Bool_t   Process(TH2* const h2, TGraphErrors **g, Int_t stat=100);
129   void            SetDyRange(Float_t dy) {fDyRange = dy;}
130 //  void    SetSegmentationLevel(Int_t l=0);
131   void            SetPtThreshold(Float_t pt)            { fPtThreshold = pt;}
132   void            SetBCselectTOF(Int_t b=0)             { fBCbinTOF = b==0?2:(b<0?1:3);}
133   void            SetBCselectFill(Int_t b=0)            { fBCbinFill = b<0||b>3499?1:b+1;}
134   void            SetVerbose(Bool_t v = kTRUE)          { SetBit(kVerbose, v);}
135   void            SetVisual(Bool_t v = kTRUE)           { SetBit(kVisual, v);}
136   void            SetTrackRefit(Bool_t v = kTRUE)       { SetBit(kTrackRefit, v);}
137   void            SetTrackSelection(Bool_t v = kTRUE)   { SetBit(kTrackSelect, v);}
138   void            SetUseExchangeContainers(Bool_t v = kTRUE) { SetBit(kXchange, v);}
139
140   void            Terminate(Option_t * opt);
141   static Bool_t   UseTrack(const Int_t np, const AliTrackPoint *points, Float_t params[10]);
142
143 private:
144   class AliTRDresolutionProjection{
145     friend class AliTRDresolution;  // Friend class
146   public:
147     AliTRDresolutionProjection();
148     virtual ~AliTRDresolutionProjection();
149     AliTRDresolutionProjection& operator+=(const AliTRDresolutionProjection& other);
150     void  Build(const Char_t *n, const Char_t *t, Int_t ix, Int_t iy, Int_t iz, TAxis *aa[]);
151     void  Increment(Int_t bin[], Double_t v);
152     TH2*  Projection2D(const Int_t nstat, const Int_t ncol, const Int_t mid=0);
153     void  SetRebinStrategy(Int_t n, Int_t rebx[], Int_t reby[]);
154     void  SetShowRange(Float_t zm, Float_t zM, Float_t em=0., Float_t eM=0.) {fRange[0] = zm; fRange[1] = zM; fRange[2] = em; fRange[3] = eM;}
155   private:
156     AliTRDresolutionProjection(const AliTRDresolutionProjection&);
157     AliTRDresolutionProjection& operator=(const AliTRDresolutionProjection&);
158   protected:
159     TH3  *fH;          // data container
160     Int_t fAx[3];      // projection axes
161     Int_t fNrebin;     // no. of rebinning steps
162     Int_t *fRebinX;    //[fNrebin] rebinning of the X axis
163     Int_t *fRebinY;    //[fNrebin] rebinning of the Y axis
164     Float_t fRange[4]; //show range of the z processed
165   ClassDef(AliTRDresolutionProjection, 1)  // wrapper for a projection container THnSparse -> TH3
166   };
167
168   AliTRDresolution(const AliTRDresolution&);
169   AliTRDresolution& operator=(const AliTRDresolution&);
170
171   void        AdjustF1(TH1 *h, TF1 *f);
172   TObjArray*  BuildMonitorContainerCluster(const char* name, Bool_t expand=kFALSE, Float_t range=-1.);
173   TObjArray*  BuildMonitorContainerTracklet(const char* name, Bool_t expand=kFALSE);
174   TObjArray*  BuildMonitorContainerTrack(const char* name);
175   void        DrawSigma(TH2 *h2, Float_t scale=1, Float_t m=0., Float_t M=-1.,  const Char_t *t=NULL);
176   void        GetLandauMpvFwhm(TF1 * const f, Float_t &mpv, Float_t &xm, Float_t &xM);
177   void        GetRange(TH2 *h2, Char_t mod, Float_t *range);
178
179 protected:
180   Bool_t      MakeProjectionCluster(Bool_t mc=kFALSE);
181   Bool_t      MakeProjectionTracklet(Bool_t mc=kFALSE);
182   Bool_t      MakeProjectionTrackIn(Bool_t mc=kFALSE);
183   Bool_t      MakeProjectionTrack();
184   Bool_t      Process(TH2* const h2, TF1 *f, Float_t k, TGraphErrors **g);
185   Bool_t      Pulls(Double_t dyz[2], Double_t cc[3], Double_t tilt) const;
186
187   UShort_t              fIdxPlot;         // plot counter (internal)
188   UShort_t              fIdxFrame;        // frame counter (internal)
189   Float_t               fPtThreshold;     // pt threshold for some performance plots
190   Float_t               fDyRange;         // min/max dy
191   Int_t                 fBCbinTOF;        // set/select by TOF BC index
192   Int_t                 fBCbinFill;       // set/select by Bunch Fill index
193   static Char_t const  *fgPerformanceName[kNclasses]; //! name of performance plot
194   static Int_t const    fgkNbins[kNdim];  //! no of bins/projection
195   static Double_t const fgkMin[kNdim];    //! low limits for projections
196   static Double_t const fgkMax[kNdim];    //! high limits for projections
197   static Char_t const  *fgkTitle[kNdim];  //! title of projection 
198   static Float_t        fgPtBin[kNpt+1];  //! pt segmentation
199   TObjArray            *fProj;            //! result holder - sigma values
200   TDatabasePDG         *fDBPDG;           //! PDG database
201
202   // calibration containers
203   TObjArray            *fCl;              //! cluster2track calib
204   TObjArray            *fMCcl;            //! cluster2mc calib
205   
206   ClassDef(AliTRDresolution, 10) // TRD tracking resolution task
207 };
208 #endif