]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSdEdxAnalyzer.h
Macro to test the CA tracker
[u/mrichter/AliRoot.git] / ITS / AliITSdEdxAnalyzer.h
1 #ifndef ALIITSDEDXANALYZER_H
2 #define ALIITSDEDXANALYZER_H
3 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////
9 //                                                               //
10 // Class for:                                                    //
11 // - building histograms of dE/dx in bins of pt/layer/particle   //
12 // - comparing dEdx signal with Bethe-Bloch expected value       //
13 // Origin: F.Prino, Torino, prino@to.infn.it                     //
14 //                                                               //
15 ///////////////////////////////////////////////////////////////////
16
17 #include <TObject.h>
18 #include <TParticle.h>
19 #include <TH1F.h>
20 #include <TH2F.h>
21 #include <TGraph.h>
22
23 class AliESDEvent;
24 class AliStack;
25 class AliLog;
26
27 class AliITSdEdxAnalyzer : public TObject {
28
29  public:
30   AliITSdEdxAnalyzer();
31   AliITSdEdxAnalyzer(const Int_t npbins, const Float_t pmin, const Float_t pmax);
32   virtual ~AliITSdEdxAnalyzer();
33
34   void SetMaterial(Float_t dens, Float_t thick){
35     fDensity=dens;
36     fThickness=thick;
37   }
38   void SetMomentumBins(const Int_t npbins, const Float_t pmin, const Float_t pmax);
39   void SetUseBBFromAliExternalTrackParam() {fBBmodel=0;}
40   void SetUseBBFromAliITSpidESD() {fBBmodel=1;}
41   void SetMIPdEdx(Float_t val){fMIP=val;}
42   void SetTPCMinimumPIDProb(Float_t min){fTPCpidCut=min;}
43
44   void ReadEvent(const AliESDEvent* ev, AliStack* stack=0);
45
46
47   Double_t BetheBloch(TParticle* part) const{
48     return BetheBloch(part->P(),part->GetMass());
49   }
50   Double_t BetheBloch(const Float_t p, const Float_t m) const;
51
52
53   TH1F* GetSingleLayerdEdxHisto(const Int_t lay, const Int_t pdgcode, const Int_t pbin) const {
54     if(lay<3 || lay>6) AliFatal("Wrong LayerNumber");
55     return fHistodEdx[GetIndex(GetSpecieBin(pdgcode),pbin,lay-3)];
56   }
57   TH1F* GetTruncatedMeandEdxHisto(const Int_t pdgcode, const Int_t pbin) const {
58     return fHistodEdx[GetIndex(GetSpecieBin(pdgcode),pbin,4)];
59   }
60
61   TH1F* GetSingleLayerDeltadEdxHisto(const Int_t lay, const Int_t pdgcode, const Int_t pbin) const {
62     if(lay<3 || lay>6) AliFatal("Wrong LayerNumber");
63     return fHistoDeltadEdx[GetIndex(GetSpecieBin(pdgcode),pbin,lay-3)];
64   }
65   TH1F* GetTruncatedMeanDeltadEdxHisto(const Int_t pdgcode, const Int_t pbin) const {
66     return fHistoDeltadEdx[GetIndex(GetSpecieBin(pdgcode),pbin,4)];
67   }
68
69   TH2F* GetSingleLayerdEdxVsPHisto(const Int_t lay, const Int_t pdgcode) const {
70     if(lay<3 || lay>6) AliFatal("Wrong LayerNumber");
71     return fHistodEdxVsP[GetIndex2(GetSpecieBin(pdgcode),lay-3)];
72   }
73   TH2F* GetTruncatedMeandEdxVsPHisto(const Int_t pdgcode) const {
74     return fHistodEdxVsP[GetIndex2(GetSpecieBin(pdgcode),4)];
75   }
76
77   TGraph* GetBetheBlochGraph(const Int_t pdgcode) const;
78
79   void WriteHistos(TString filename="ITS.dEdx.root") const;
80
81  protected:
82
83   Int_t GetNHistos() const {return kNParticles*kNValuesdEdx*fNPBins;}
84   Int_t GetNHistos2() const {return kNParticles*kNValuesdEdx;}
85   Int_t GetIndex(const Int_t iSp, const Int_t iP, const Int_t iVal) const {
86     return iVal+kNValuesdEdx*iP+fNPBins*kNValuesdEdx*iSp;
87   }
88   Int_t GetIndex2(const Int_t iSp, const Int_t iVal) const {
89     return iVal+kNValuesdEdx*iSp;
90   }
91   Int_t GetMomentumBin(Float_t p) const{
92     Int_t iBin=(Int_t)((p-fPMin)/(fPMax-fPMin)*fNPBins);
93     if(iBin>=0 && iBin<fNPBins)return iBin; 
94     return -1;
95   }
96   Int_t GetSpecieBin(Int_t absPdgCode) const {
97     for(Int_t iS=0; iS<kNParticles; iS++) if(absPdgCode==fgkPdgCode[iS]) return iS;
98     return -1;
99   }
100
101   Int_t GetPaticleIdFromTPC(const AliESDtrack* track) const;
102   void BookHistos();
103   void DeleteHistos();
104   
105  private:
106
107   AliITSdEdxAnalyzer(const AliITSdEdxAnalyzer& dum);
108   AliITSdEdxAnalyzer& operator=(const AliITSdEdxAnalyzer& dum);
109
110   enum {kNParticles=3};  
111   enum {kNValuesdEdx=5};
112
113   static const Int_t fgkPdgCode[kNParticles]; // initialized in the cxx
114   static const Int_t fgkLayerCode[kNValuesdEdx]; // initialized in the cxx
115   
116
117   Int_t   fNPBins;         // Number of Momentum bins
118   Float_t fPMin;           // Minimum P
119   Float_t fPMax;           // Maximum P
120   TH1F**  fHistodEdx;      // Array of histograms of dEdx_meas in bins of pt
121   TH1F**  fHistoDeltadEdx; // Array of histograms of dEdx_meas-dEdx_expected in bins of pt
122   TH2F**  fHistodEdxVsP;   // Array of histograms of dEdx_meas vs. pt
123   Float_t fThickness;      // detector thickness (cm)
124   Float_t fDensity;        // detector density (g/cm3)
125   Int_t   fBBmodel;        // is there MC truth info?
126   Float_t fMIP;            // normalization for MIP
127   Float_t fTPCpidCut;      // minimum probability for PID in TPC   
128
129   ClassDef(AliITSdEdxAnalyzer,0);
130 };
131 #endif