]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/dielectron/AliDielectronPID.h
07601202e7abad419cc1f927b4ad20412487f9a7
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronPID.h
1 #ifndef ALIDIELECTRONPID_H
2 #define ALIDIELECTRONPID_H
3
4 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 //#############################################################
8 //#                                                           # 
9 //#         Class AliDielectronPID                     #
10 //#                                                           #
11 //#  Authors:                                                 #
12 //#   Anton     Andronic, GSI / A.Andronic@gsi.de             #
13 //#   Ionut C.  Arsene,   GSI / I.C.Arsene@gsi.de             #
14 //#   Julian    Book,     Uni Ffm / Julian.Book@cern.ch       #
15 //#   Frederick Kramer,   Uni Ffm, / Frederick.Kramer@cern.ch #
16 //#   Magnus    Mager,    CERN / Magnus.Mager@cern.ch         #
17 //#   WooJin J. Park,     GSI / W.J.Park@gsi.de               #
18 //#   Jens      Wiechula, Uni HD / Jens.Wiechula@cern.ch      #
19 //#                                                           #
20 //#############################################################
21
22 #include <AliPID.h>
23 #include <AliESDpid.h>
24 #include <AliAODTrack.h>
25 #include <AliAODPid.h>
26
27 #include <AliAnalysisCuts.h>
28
29 class TF1;
30 class TList;
31 class AliVTrack;
32 class TGraph;
33
34 class AliDielectronPID : public AliAnalysisCuts {
35 public:
36   enum DetType {kITS, kTPC, kTRD, kTOF};
37   enum PIDbitTupe {kIgnore=0, kRequire, kIfAvailable};
38   
39   AliDielectronPID();
40   AliDielectronPID(const char*name, const char* title);
41
42   virtual ~AliDielectronPID();
43
44   void AddCut(DetType det, AliPID::EParticleType type, Double_t nSigmaLow, Double_t nSigmaUp=-99999.,
45               Double_t pMin=0, Double_t pMax=0, Bool_t exclude=kFALSE, UInt_t pidBitType=AliDielectronPID::kRequire);
46
47   void AddCut(DetType det, AliPID::EParticleType type, Double_t nSigmaLow, TF1 * const funUp,
48               Double_t pMin=0, Double_t pMax=0, Bool_t exclude=kFALSE, UInt_t pidBitType=AliDielectronPID::kRequire);
49
50   void AddCut(DetType det, AliPID::EParticleType type, TF1 * const funLow, Double_t nSigmaUp,
51               Double_t pMin=0, Double_t pMax=0, Bool_t exclude=kFALSE, UInt_t pidBitType=AliDielectronPID::kRequire);
52
53   void AddCut(DetType det, AliPID::EParticleType type, TF1 * const funLow, TF1 * const funUp,
54               Double_t pMin=0, Double_t pMax=0, Bool_t exclude=kFALSE, UInt_t pidBitType=AliDielectronPID::kRequire);
55   
56   void SetDefaults(Int_t def);
57
58   //
59   //Analysis cuts interface
60   //const
61   virtual Bool_t IsSelected(TObject* track);
62   virtual Bool_t IsSelected(TList*   /* list */ ) {return kFALSE;}
63
64   static void SetCorrGraph(TGraph * const gr) { fgFitCorr=gr; }
65   static void SetCorrVal(Double_t run);
66   static Double_t GetCorrVal()   { return fgCorr; }
67   static TGraph *GetCorrGraph()  { return fgFitCorr; }
68   
69 private:
70   enum {kNmaxPID=10};
71   
72   DetType  fDetType[kNmaxPID];    //detector type of nsigma cut
73   AliPID::EParticleType fPartType[kNmaxPID]; //particle type
74   Float_t  fNsigmaLow[kNmaxPID];  //lower nsigma bound
75   Float_t  fNsigmaUp[kNmaxPID];   //upper nsigma bound
76   Double_t fPmin[kNmaxPID];       //lower momentum
77   Double_t fPmax[kNmaxPID];       //upper momentum
78   Bool_t   fExclude[kNmaxPID];    //use as exclusion band
79   TF1     *fFunUpperCut[kNmaxPID];//use function as upper cut
80   TF1     *fFunLowerCut[kNmaxPID];//use function as lower cut
81   UChar_t  fNcuts;                //number of cuts
82   UChar_t  fRequirePIDbit[kNmaxPID]; //How to make use of the pid bit (see)
83
84   AliESDpid *fESDpid;             //! esd pid object
85
86                                   
87   static TGraph *fgFitCorr;       //spline fit object to correct the nsigma deviation in the TPC electron band
88   static Double_t fgCorr;         //!correction value for current run. Set if fgFitCorr is set and SetCorrVal(run)
89                                   // was called
90   
91   Bool_t IsSelectedITS(AliVTrack * const part, Int_t icut) const;
92   Bool_t IsSelectedTPC(AliVTrack * const part, Int_t icut) const;
93   Bool_t IsSelectedTRD(AliVTrack * const part, Int_t icut) const;
94   Bool_t IsSelectedTOF(AliVTrack * const part, Int_t icut) const;
95
96   Float_t NumberOfSigmasITS(const AliAODTrack *track, AliPID::EParticleType type) const;
97   Float_t NumberOfSigmasTPC(const AliAODTrack *track, AliPID::EParticleType type) const;
98   Float_t NumberOfSigmasTOF(const AliAODTrack *track, AliPID::EParticleType type) const;
99   
100   AliDielectronPID(const AliDielectronPID &c);
101   AliDielectronPID &operator=(const AliDielectronPID &c);
102
103   ClassDef(AliDielectronPID,3)         // Dielectron PID
104 };
105
106
107 //
108 // Inline functions for AOD as long as ther is no AOD pid object we have to fake it
109 //
110
111 inline Float_t AliDielectronPID::NumberOfSigmasITS(const AliAODTrack *track, AliPID::EParticleType type) const {
112   AliAODPid *pid=track->GetDetPid();
113   if (!pid) return -1000.;
114   
115   return fESDpid->GetITSResponse().GetNumberOfSigmas(track->P(),pid->GetITSsignal(),type);
116 }
117
118 inline Float_t AliDielectronPID::NumberOfSigmasTPC(const AliAODTrack *track, AliPID::EParticleType type) const {
119   AliAODPid *pid=track->GetDetPid();
120   if (!pid) return -1000.;
121     
122   Double_t mom = pid->GetTPCmomentum();
123   if (mom<0) mom=track->P();
124
125   //FIXME: rough estimate of the number of clusters used for PID. Needs to be fixed!!!
126   Int_t ncl=(Int_t)track->GetTPCClusterMap().CountBits();
127   return fESDpid->GetTPCResponse().GetNumberOfSigmas(mom,pid->GetTPCsignal(),ncl,type);
128 }
129
130 inline Float_t AliDielectronPID::NumberOfSigmasTOF(const AliAODTrack *track, AliPID::EParticleType type) const {
131   AliAODPid *pid=track->GetDetPid();
132   if (!pid) return -1000.;
133   
134   Double_t times[AliPID::kSPECIES];
135   pid->GetIntegratedTimes(times);
136   Double_t tofRes = fESDpid->GetTOFResponse().GetExpectedSigma(track->P(),times[type],AliPID::ParticleMass(type));
137   return (pid->GetTOFsignal() - times[type])/ tofRes;
138 }
139
140
141
142 #endif