]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/AliHFEtrdPIDqa.h
76257597e3b81a242859d809272d6b3e5acdefc3
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEtrdPIDqa.h
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15 //
16 // QA class for TRD PID
17 // Evaluate TRD PID using well identified reference tracks
18 // For more information see implementation file
19 //
20 #ifndef ALIHFETRDPIDQA_H
21 #define ALIHFETRDPIDQA_H
22
23 #ifndef ROOT_TNamed
24 #include <TNamed.h>
25 #endif
26
27 #ifndef ROOT_THnSparse
28 #include <THnSparse.h>
29 #endif
30
31 #ifndef ROOT_TH2
32 #include <TH2.h>
33 #endif
34
35 #ifndef ALIHFECOLLECTION_H
36 #include "AliHFEcollection.h"
37 #endif
38
39 class TArrayD;
40 class TBrowser;
41 class TCollection;
42 class TF1;
43 class TGraph;
44 class TGraphErrors;
45 class TH1;
46 //class TH2;
47 class TList;
48 class TObjArray;
49
50 class AliAODTrack;
51 class AliESDtrack;
52 class AliVTrack;
53 class AliHFEpidTRD;
54
55 class AliHFEtrdPIDqa : public TNamed{
56   public:
57     AliHFEtrdPIDqa();
58     AliHFEtrdPIDqa(const Char_t *name);
59     AliHFEtrdPIDqa(const AliHFEtrdPIDqa &ref);
60     AliHFEtrdPIDqa &operator=(const AliHFEtrdPIDqa &ref);
61     virtual void Copy(TObject &o) const;
62     virtual Long64_t Merge(TCollection *coll);
63     virtual ~AliHFEtrdPIDqa();
64    
65     virtual void Browse(TBrowser *b);
66     virtual Bool_t IsFolder() const { return kTRUE; }
67
68     void ProcessTracks(const TObjArray * const  l, Int_t species);
69     void ProcessTrack(const AliVTrack *const track, Int_t species);
70
71     void Init();
72     void FinishAnalysis();
73     void ShowMessages() { fShowMessage = kTRUE; }
74     void SetTotalChargeInSlice0() { fTotalChargeInSlice0 = kTRUE; }
75     void StoreResults(const Char_t *filename = "HFEtrdPIDqa.root");
76     void SaveThresholdParameters(const Char_t * filename = "TRD.Thresholds.root", Double_t lowerLimit = 0.5, Double_t upperLimit = 3.5);
77
78     TGraphErrors *GetPionEfficiency(Int_t ntracklets, Int_t eleffpercent);
79     TGraphErrors *GetProtonEfficiency(Int_t ntracklets, Int_t eleffpercent);
80     TGraph *GetThreshold(Int_t ntracklets, Int_t eleffpercent);
81
82     void DrawTracklet(Int_t tracklet, Double_t pmin = -1., Double_t pmax = -1., Bool_t doFit = kFALSE);
83     void ClearLists();
84
85     Double_t EvalPionEfficiency(Int_t ntls, Int_t eEff, Double_t p);
86     Double_t EvalProtonEfficiency(Int_t ntls, Int_t eEff, Double_t p);
87     Double_t EvalThreshold(Int_t ntls, Int_t eEff, Double_t p);
88
89     Double_t CalculateIntegratedPionEfficiency(UInt_t nTracklets, Double_t electronEff, Double_t pmin, Double_t pmax, Double_t *error = NULL);
90
91     //---------------------------------------------------
92     // Getters for Histograms
93     THnSparseF *GetLikelihoodHistogram() const { return fHistos ? dynamic_cast<THnSparseF *>(fHistos->Get("fLikeTRD")) : NULL; }
94     THnSparseF *GetQAHistogram() const { return fHistos ? dynamic_cast<THnSparseF *>(fHistos->Get("fQAtrack")) : NULL; }
95     THnSparseF *GetdEdxHistogram() const { return fHistos ? dynamic_cast<THnSparseF *>(fHistos->Get("fQAdEdx")) : NULL; }
96     THnSparseF *GetHistoTruncMean() const { return fHistos ? dynamic_cast<THnSparseF *>(fHistos->Get("fTRDtruncMean")) : NULL; }
97     TH2 *GetSliceChargePions(Bool_t pions = kTRUE) const { 
98       const Char_t * species = pions ? "Pions" : "Electrons";
99       return fHistos ? dynamic_cast<TH2 *>(fHistos->Get(Form("fTRDslices%s", species))) : NULL; 
100     }
101     AliHFEcollection *GetHistos() const { return fHistos; }
102     //---------------------------------------------------
103   protected:
104     // Description of the containers we use to store basic information
105     // we access in the Post Processing. For all containers we have a 
106     // common part containing species, momentum and number of tracklets,
107     // and a specific part. For both containers we define the number of 
108     // variables too
109     enum QuantitiesCommon_t{
110       kSpecies = 0,
111       kP = 1,
112       kNTracklets = 2,
113       kQuantitiesCommon = 3
114     };
115     enum QuantitiesLike_t{
116       kElectronLike = 3,
117       kNClustersLike = 4,
118       kQuantitiesLike = 5
119     };
120     enum QuantitiesQAtrack_t{
121       kNonZeroTrackletCharge = 3,
122       kNClusters = 4,
123       kQuantitiesQA = 5
124     };
125     enum QuantitiesdEdx_t{
126       kNclusters = 3,
127       kNonZeroSlices = 4,
128       kdEdx = 5,
129       kQuantitiesdEdx = 6
130     };
131     enum QuantitiesTruncMean_t{
132       kTPCdEdx = 3,
133       kTRDdEdxMethod1 = 4,
134       kTRDdEdxMethod2 = 5,
135       kQuantitiesTruncMean = 6
136     };
137
138     void ProcessTrackESD(const AliESDtrack * const track, Int_t species);
139     void ProcessTrackAOD(const AliAODTrack * const track, Int_t species);
140
141     void FillTRDLikelihoods(const AliESDtrack * const track, Int_t species);
142     void FillTRDQAplots(const AliESDtrack *const track, Int_t species);
143
144     void AnalyseNTracklets(Int_t nTracklets);
145     Double_t CalculateHadronEfficiency(const TH1 * const hadron, const TH1 *const electron, Double_t eff, Int_t &threshbin, Double_t &error);
146     TF1 *MakeThresholds(TGraph *input, Double_t lowerLimit, Double_t upperLimit);
147
148     void CreateLikelihoodHistogram();
149     void CreateQAHistogram();
150     void CreatedEdxHistogram();
151     void CreateHistoTruncatedMean();
152
153   private:
154     enum{
155       kNElectronEffs = 6
156     };
157     static const Double_t fgkElectronEff[kNElectronEffs];       // Electron efficiency bins
158     static const Int_t    fgkNBinsCommon[kQuantitiesCommon];    // Number of bins for common quantities
159     static const Double_t fgkMinBinCommon[kQuantitiesCommon];   // Bin Limits for common quantities (lower limit)
160     static const Double_t fgkMaxBinCommon[kQuantitiesCommon];   // Bin Limits for common quantities (upper limit)
161     AliHFEpidTRD *fTRDpid;        // HFE PID for TRD
162     AliHFEcollection *fHistos;    // Histogram collection
163
164     // List for Histograms:
165     TList *fPionEfficiencies;     //! List for Pion efficiencies
166     TList *fProtonEfficiencies;   //! List for Proton efficiencies
167     TList *fKaonEfficiencies;     //! List for Kaon efficiencies
168
169     TList *fThresholds;           //! List for Threshold Graphs
170
171     Bool_t fShowMessage;         // Display debug messages
172     Bool_t fTotalChargeInSlice0;  // Flag for Foreward/Backward compatibility in TRD total charge calculation
173   
174   ClassDef(AliHFEtrdPIDqa, 3)     // QA class for TRD PID 
175 };
176 #endif
177