29bf19f2 |
1 | #ifndef ALIPIDRESPONSE_H |
2 | #define ALIPIDRESPONSE_H |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ |
5 | |
6 | //---------------------------------------------------------------// |
7 | // Base class for handling the pid response // |
8 | // functions of all detectors // |
9 | // and give access to the nsigmas // |
10 | // // |
11 | // Origin: Jens Wiechula, Uni Tuebingen, jens.wiechula@cern.ch // |
12 | //---------------------------------------------------------------// |
13 | |
14 | #include "AliITSPIDResponse.h" |
15 | #include "AliTPCPIDResponse.h" |
16 | #include "AliTRDPIDResponse.h" |
17 | #include "AliTOFPIDResponse.h" |
e96b9916 |
18 | #include "AliEMCALPIDResponse.h" |
29bf19f2 |
19 | |
20 | #include "AliVParticle.h" |
21 | #include "AliVTrack.h" |
22 | |
23 | #include "TNamed.h" |
24 | |
25 | class AliVEvent; |
4ec8e76d |
26 | class TF1; |
29bf19f2 |
27 | |
28 | class AliPIDResponse : public TNamed { |
29 | public: |
4ec8e76d |
30 | AliPIDResponse(Bool_t isMC=kFALSE); |
31 | virtual ~AliPIDResponse(); |
29bf19f2 |
32 | |
fd21ec8d |
33 | enum EDetCode { |
34 | kDetITS = 0x1, |
35 | kDetTPC = 0x2, |
36 | kDetTRD = 0x4, |
37 | kDetTOF = 0x8, |
38 | kDetHMPID = 0x10, |
39 | kDetEMCAL = 0x20, |
40 | kDetPHOS = 0x40 |
41 | }; |
42 | |
29bf19f2 |
43 | enum EStartTimeType_t {kFILL_T0,kTOF_T0, kT0_T0, kBest_T0}; |
fd21ec8d |
44 | |
45 | enum ITSPIDmethod { kITSTruncMean, kITSLikelihood }; |
46 | |
47 | enum EDetPidStatus { |
48 | kDetNoSignal=0, |
49 | kDetPidOk=1, |
50 | kDetMismatch=2 |
51 | }; |
29bf19f2 |
52 | |
53 | AliITSPIDResponse &GetITSResponse() {return fITSResponse;} |
54 | AliTPCPIDResponse &GetTPCResponse() {return fTPCResponse;} |
55 | AliTOFPIDResponse &GetTOFResponse() {return fTOFResponse;} |
56 | AliTRDPIDResponse &GetTRDResponse() {return fTRDResponse;} |
e96b9916 |
57 | AliEMCALPIDResponse &GetEMCALResponse() {return fEMCALResponse;} |
fd21ec8d |
58 | |
59 | Float_t NumberOfSigmas(EDetCode detCode, const AliVParticle *track, AliPID::EParticleType type) const; |
29bf19f2 |
60 | |
61 | virtual Float_t NumberOfSigmasITS(const AliVParticle *track, AliPID::EParticleType type) const; |
62 | virtual Float_t NumberOfSigmasTPC(const AliVParticle *track, AliPID::EParticleType type) const; |
e96b9916 |
63 | virtual Float_t NumberOfSigmasEMCAL(const AliVTrack *track, AliPID::EParticleType type) const; |
6d0064aa |
64 | virtual Float_t NumberOfSigmasEMCAL(const AliVTrack *track, AliPID::EParticleType type, Double_t &eop, Double_t showershape[4]) const; |
29bf19f2 |
65 | virtual Float_t NumberOfSigmasTOF(const AliVParticle *track, AliPID::EParticleType type) const = 0; |
ea235c90 |
66 | virtual Bool_t IdentifiedAsElectronTRD(const AliVTrack *track, Double_t efficiencyLevel) const; |
29bf19f2 |
67 | |
fd21ec8d |
68 | EDetPidStatus ComputePIDProbability (EDetCode detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
69 | |
70 | EDetPidStatus ComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
71 | EDetPidStatus ComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
72 | EDetPidStatus ComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
73 | EDetPidStatus ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
74 | EDetPidStatus ComputeEMCALProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
75 | EDetPidStatus ComputePHOSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
76 | EDetPidStatus ComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const; |
77 | |
78 | |
79 | void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; } |
ea235c90 |
80 | void SetTRDslicesForPID(UInt_t slice1, UInt_t slice2) {fTRDslicesForPID[0]=slice1;fTRDslicesForPID[1]=slice2;} |
81 | |
4ec8e76d |
82 | void SetOADBPath(const char* path) {fOADBPath=path;} |
80f28562 |
83 | const char *GetOADBPath() const {return fOADBPath.Data();} |
4ec8e76d |
84 | void InitialiseEvent(AliVEvent *event, Int_t pass); |
ea235c90 |
85 | void SetCurrentFile(const char* file) { fCurrentFile=file; } |
4ec8e76d |
86 | |
e96b9916 |
87 | AliVEvent * GetCurrentEvent() const {return fCurrentEvent;} |
88 | |
fd21ec8d |
89 | // User settings for the MC period and reco pass |
90 | void SetMCperiod(const char *mcPeriod) {fMCperiodUser=mcPeriod;} |
91 | void SetRecoPass(Int_t recoPass) {fRecoPassUser=recoPass;} |
80f28562 |
92 | |
93 | // event info |
94 | Float_t GetCurrentCentrality() const {return fCurrCentrality;}; |
95 | |
0b39f221 |
96 | // TOF setting |
97 | void SetTOFtail(Float_t tail=1.1){if(tail > 0) fTOFtail=tail; else printf("TOF tail should be greater than 0 (nothing done)\n");}; |
5f8db5fe |
98 | void SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option); |
0b39f221 |
99 | |
4ec8e76d |
100 | AliPIDResponse(const AliPIDResponse &other); |
101 | AliPIDResponse& operator=(const AliPIDResponse &other); |
80f28562 |
102 | |
29bf19f2 |
103 | |
104 | protected: |
105 | AliITSPIDResponse fITSResponse; //PID response function of the ITS |
106 | AliTPCPIDResponse fTPCResponse; //PID response function of the TPC |
107 | AliTRDPIDResponse fTRDResponse; //PID response function of the TRD |
108 | AliTOFPIDResponse fTOFResponse; //PID response function of the TOF |
e96b9916 |
109 | AliEMCALPIDResponse fEMCALResponse; //PID response function of the EMCAL |
4ec8e76d |
110 | |
fd21ec8d |
111 | Float_t fRange; // nSigma max in likelihood |
112 | ITSPIDmethod fITSPIDmethod; // 0 = trunc mean; 1 = likelihood |
113 | |
4ec8e76d |
114 | private: |
115 | Bool_t fIsMC; // If we run on MC data |
116 | |
117 | TString fOADBPath; // OADB path to use |
118 | |
119 | TString fBeamType; //! beam type (PP) or (PBPB) |
120 | TString fLHCperiod; //! LHC period |
121 | TString fMCperiodTPC; //! corresponding MC period to use for the TPC splines |
fd21ec8d |
122 | TString fMCperiodUser; // MC prodution requested by the user |
ea235c90 |
123 | TString fCurrentFile; //! name of currently processed file |
4ec8e76d |
124 | Int_t fRecoPass; //! reconstruction pass |
fd21ec8d |
125 | Int_t fRecoPassUser; // reconstruction pass explicitly set by the user |
4ec8e76d |
126 | Int_t fRun; //! current run number |
127 | Int_t fOldRun; //! current run number |
fd21ec8d |
128 | |
4ec8e76d |
129 | TObjArray *fArrPidResponseMaster; //! TPC pid splines |
130 | TF1 *fResolutionCorrection; //! TPC resolution correction |
131 | |
ce487a7f |
132 | AliTRDPIDParams *fTRDPIDParams; //! TRD PID Params |
ea235c90 |
133 | AliTRDPIDReference *fTRDPIDReference; //! TRD PID References |
134 | UInt_t fTRDslicesForPID[2]; //! TRD PID slices |
135 | |
4ec8e76d |
136 | Int_t fTOFTimeZeroType; //! default start time type for tof (ESD) |
137 | Float_t fTOFres; //! TOF resolution |
0b39f221 |
138 | Float_t fTOFtail; //! TOF tail effect used in TOF probability |
e96b9916 |
139 | |
b2138b40 |
140 | TObjArray *fEMCALPIDParams; //! EMCAL PID Params |
141 | |
e96b9916 |
142 | AliVEvent *fCurrentEvent; //! event currently being processed |
80f28562 |
143 | |
144 | Float_t fCurrCentrality; //! current centrality |
4ec8e76d |
145 | |
146 | void ExecNewRun(); |
147 | |
148 | // |
149 | //setup parametrisations |
150 | // |
151 | |
152 | //ITS |
153 | void SetITSParametrisation(); |
154 | |
155 | //TPC |
156 | void SetTPCPidResponseMaster(); |
157 | void SetTPCParametrisation(); |
158 | Double_t GetTPCMultiplicityBin(const AliVEvent * const event); |
159 | |
ea235c90 |
160 | //TRD |
161 | void SetTRDPidResponseMaster(); |
162 | void InitializeTRDResponse(); |
163 | |
4ec8e76d |
164 | //TOF |
b2138b40 |
165 | |
166 | //EMCAL |
167 | void SetEMCALPidResponseMaster(); |
168 | void InitializeEMCALResponse(); |
169 | |
4ec8e76d |
170 | // |
171 | void SetRecoInfo(); |
29bf19f2 |
172 | |
0b39f221 |
173 | ClassDef(AliPIDResponse,5); //PID response handling |
29bf19f2 |
174 | }; |
175 | |
176 | inline Float_t AliPIDResponse::NumberOfSigmasTPC(const AliVParticle *vtrack, AliPID::EParticleType type) const { |
177 | AliVTrack *track=(AliVTrack*)vtrack; |
178 | Double_t mom = track->GetTPCmomentum(); |
179 | Double_t sig = track->GetTPCsignal(); |
180 | UInt_t sigN = track->GetTPCsignalN(); |
181 | |
182 | Double_t nSigma = -999.; |
183 | if (sigN>0) nSigma=fTPCResponse.GetNumberOfSigmas(mom,sig,sigN,type); |
184 | |
185 | return nSigma; |
186 | } |
187 | |
188 | inline Float_t AliPIDResponse::NumberOfSigmasITS(const AliVParticle *vtrack, AliPID::EParticleType type) const { |
189 | AliVTrack *track=(AliVTrack*)vtrack; |
190 | Float_t dEdx=track->GetITSsignal(); |
191 | if (dEdx<=0) return -999.; |
192 | |
193 | UChar_t clumap=track->GetITSClusterMap(); |
194 | Int_t nPointsForPid=0; |
195 | for(Int_t i=2; i<6; i++){ |
196 | if(clumap&(1<<i)) ++nPointsForPid; |
197 | } |
198 | Float_t mom=track->P(); |
199 | Bool_t isSA=kTRUE; |
200 | if(track->GetTPCNcls()>0) isSA=kFALSE; |
201 | return fITSResponse.GetNumberOfSigmas(mom,dEdx,type,nPointsForPid,isSA); |
202 | } |
203 | |
204 | #endif |