* add tuned on data functionality for TOF (non-gaussian tails)
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliPIDResponse.h
CommitLineData
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
1d59271b 14#include "AliVParticle.h"
15#include "AliVTrack.h"
16
29bf19f2 17#include "AliITSPIDResponse.h"
18#include "AliTPCPIDResponse.h"
19#include "AliTRDPIDResponse.h"
20#include "AliTOFPIDResponse.h"
567624b5 21#include "AliHMPIDPIDResponse.h"
e96b9916 22#include "AliEMCALPIDResponse.h"
1d59271b 23#include "AliPID.h"
29bf19f2 24
25#include "TNamed.h"
26
4ec8e76d 27class TF1;
00a38d07 28class TObjArray;
f84b18dd 29class TLinearFitter;
00a38d07 30
31class AliVEvent;
32class AliTRDPIDResponseObject;
33class AliTOFPIDParams;
567624b5 34class AliHMPIDPIDParams;
1c9d11be 35class AliOADBContainer;
29bf19f2 36
37class AliPIDResponse : public TNamed {
38public:
4ec8e76d 39 AliPIDResponse(Bool_t isMC=kFALSE);
40 virtual ~AliPIDResponse();
29bf19f2 41
00a38d07 42 enum EDetector {
43 kITS=0,
44 kTPC=1,
45 kTRD=2,
46 kTOF=3,
47 kHMPID=4,
48 kEMCAL=5,
49 kPHOS=6,
50 kNdetectors=7
51 };
52
fd21ec8d 53 enum EDetCode {
54 kDetITS = 0x1,
55 kDetTPC = 0x2,
56 kDetTRD = 0x4,
57 kDetTOF = 0x8,
58 kDetHMPID = 0x10,
59 kDetEMCAL = 0x20,
60 kDetPHOS = 0x40
61 };
62
29bf19f2 63 enum EStartTimeType_t {kFILL_T0,kTOF_T0, kT0_T0, kBest_T0};
fd21ec8d 64
65 enum ITSPIDmethod { kITSTruncMean, kITSLikelihood };
66
67 enum EDetPidStatus {
68 kDetNoSignal=0,
69 kDetPidOk=1,
355b831b 70 kDetMismatch=2,
71 kDetNoParams=3
fd21ec8d 72 };
f84b18dd 73
29bf19f2 74 AliITSPIDResponse &GetITSResponse() {return fITSResponse;}
75 AliTPCPIDResponse &GetTPCResponse() {return fTPCResponse;}
76 AliTOFPIDResponse &GetTOFResponse() {return fTOFResponse;}
77 AliTRDPIDResponse &GetTRDResponse() {return fTRDResponse;}
e96b9916 78 AliEMCALPIDResponse &GetEMCALResponse() {return fEMCALResponse;}
f84b18dd 79
355b831b 80 // -----------------------------------------
81 // buffered getters
82 //
83
84 // Number of sigmas
85 EDetPidStatus NumberOfSigmas(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type, Double_t &val) const;
86
00a38d07 87 Float_t NumberOfSigmas(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type) const;
29bf19f2 88
00a38d07 89 virtual Float_t NumberOfSigmasITS (const AliVParticle *track, AliPID::EParticleType type) const;
90 virtual Float_t NumberOfSigmasTPC (const AliVParticle *track, AliPID::EParticleType type) const;
f84b18dd 91 virtual Float_t NumberOfSigmasTPC (const AliVParticle *track, AliPID::EParticleType type, AliTPCPIDResponse::ETPCdEdxSource dedxSource) const;
00a38d07 92 virtual Float_t NumberOfSigmasEMCAL(const AliVParticle *track, AliPID::EParticleType type, Double_t &eop, Double_t showershape[4]) const;
1c9d11be 93 virtual Float_t NumberOfSigmasTOF (const AliVParticle *track, AliPID::EParticleType type) const;
355b831b 94 virtual Float_t NumberOfSigmasTOF (const AliVParticle *track, AliPID::EParticleType type, const Float_t /*timeZeroTOF*/) const { return NumberOfSigmasTOF(track,type); }
567624b5 95 virtual Float_t NumberOfSigmasHMPID(const AliVParticle *track, AliPID::EParticleType type) const;
00a38d07 96 virtual Float_t NumberOfSigmasEMCAL(const AliVParticle *track, AliPID::EParticleType type) const;
97
1c9d11be 98 Bool_t IdentifiedAsElectronTRD(const AliVTrack *track, Double_t efficiencyLevel,Double_t centrality=-1,AliTRDPIDResponse::ETRDPIDMethod PIDmethod=AliTRDPIDResponse::kLQ1D) const;
29bf19f2 99
567624b5 100 // Signal delta
1d59271b 101 EDetPidStatus GetSignalDelta(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type, Double_t &val, Bool_t ratio=kFALSE) const;
102 Double_t GetSignalDelta(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type, Bool_t ratio=kFALSE) const;
567624b5 103
355b831b 104 // Probabilities
00a38d07 105 EDetPidStatus ComputePIDProbability (EDetCode detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
355b831b 106 EDetPidStatus ComputePIDProbability (EDetector detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
fd21ec8d 107
1c9d11be 108 virtual EDetPidStatus ComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
109 virtual EDetPidStatus ComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
110 virtual EDetPidStatus ComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
355b831b 111 virtual EDetPidStatus ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
1c9d11be 112 virtual EDetPidStatus ComputeEMCALProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
113 virtual EDetPidStatus ComputePHOSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
114 virtual EDetPidStatus ComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
fd21ec8d 115
355b831b 116 virtual EDetPidStatus ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[],AliTRDPIDResponse::ETRDPIDMethod PIDmethod) const;
117
118 // pid status
119 EDetPidStatus CheckPIDStatus(EDetector detCode, const AliVTrack *track) const;
120
97d17530 121 Float_t GetTOFMismatchProbability(const AliVTrack *track) const;
122
fd21ec8d 123 void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; }
ea235c90 124
4ec8e76d 125 void SetOADBPath(const char* path) {fOADBPath=path;}
80f28562 126 const char *GetOADBPath() const {return fOADBPath.Data();}
00a38d07 127
128 void SetCustomTPCpidResponse(const char* tpcpid) { fCustomTPCpidResponse = tpcpid; }
129 const char* GetCustomTPCpidResponse() const { return fCustomTPCpidResponse.Data(); }
130
131 void InitialiseEvent(AliVEvent *event, Int_t pass, Int_t run=-1);
ea235c90 132 void SetCurrentFile(const char* file) { fCurrentFile=file; }
4ec8e76d 133
00a38d07 134 // cache PID in the track
1c9d11be 135 void SetCachePID(Bool_t cache) { fCachePID=cache; }
136 Bool_t GetCachePID() const { return fCachePID; }
137 void FillTrackDetectorPID(const AliVTrack *track, EDetector detector) const;
00a38d07 138 void FillTrackDetectorPID();
139
e96b9916 140 AliVEvent * GetCurrentEvent() const {return fCurrentEvent;}
141
fd21ec8d 142 // User settings for the MC period and reco pass
143 void SetMCperiod(const char *mcPeriod) {fMCperiodUser=mcPeriod;}
144 void SetRecoPass(Int_t recoPass) {fRecoPassUser=recoPass;}
80f28562 145
146 // event info
147 Float_t GetCurrentCentrality() const {return fCurrCentrality;};
148
f84b18dd 149 // TPC setting
150 void SetUseTPCEtaCorrection(Bool_t useEtaCorrection = kTRUE) { fUseTPCEtaCorrection = useEtaCorrection; };
151 Bool_t UseTPCEtaCorrection() const { return fUseTPCEtaCorrection; };
152
0b39f221 153 // TOF setting
154 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 155 void SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option);
0b39f221 156
539a5a59 157 virtual Float_t GetTPCsignalTunedOnData(const AliVTrack *t) const {return t->GetTPCsignal();};
a2c30af1 158 virtual Float_t GetTOFsignalTunedOnData(const AliVTrack *t) const {return t->GetTOFsignal();};
539a5a59 159 Bool_t IsTunedOnData() const {return fTuneMConData;};
160 void SetTunedOnData(Bool_t flag=kTRUE,Int_t recoPass=0){fTuneMConData = flag; if(recoPass>0) fRecoPassUser = recoPass;};
a2c30af1 161 Int_t GetTunedOnDataMask() const {return fTuneMConDataMask;};
162 void SetTunedOnDataMask(Int_t detMask) {fTuneMConDataMask = detMask;}
539a5a59 163
4ec8e76d 164 AliPIDResponse(const AliPIDResponse &other);
165 AliPIDResponse& operator=(const AliPIDResponse &other);
80f28562 166
29bf19f2 167
168protected:
567624b5 169 AliITSPIDResponse fITSResponse; //PID response function of the ITS
170 AliTPCPIDResponse fTPCResponse; //PID response function of the TPC
171 AliTRDPIDResponse fTRDResponse; //PID response function of the TRD
172 AliTOFPIDResponse fTOFResponse; //PID response function of the TOF
173 AliHMPIDPIDResponse fHMPIDResponse; //PID response function of the HMPID
e96b9916 174 AliEMCALPIDResponse fEMCALResponse; //PID response function of the EMCAL
4ec8e76d 175
fd21ec8d 176 Float_t fRange; // nSigma max in likelihood
177 ITSPIDmethod fITSPIDmethod; // 0 = trunc mean; 1 = likelihood
178
1c9d11be 179 //unbuffered PID calculation
355b831b 180 virtual Float_t GetNumberOfSigmasTOFold (const AliVParticle */*track*/, AliPID::EParticleType /*type*/) const {return 0;}
1d59271b 181 virtual Float_t GetSignalDeltaTOFold(const AliVParticle */*track*/, AliPID::EParticleType /*type*/, Bool_t /*ratio*/=kFALSE) const {return -9999.;}
567624b5 182
1c9d11be 183 EDetPidStatus GetComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[],AliTRDPIDResponse::ETRDPIDMethod PIDmethod=AliTRDPIDResponse::kLQ1D) const;
355b831b 184 EDetPidStatus GetTOFPIDStatus(const AliVTrack *track) const;
355b831b 185
a2c30af1 186 Bool_t fTuneMConData; // switch to force the MC to be similar to data
187 Int_t fTuneMConDataMask; // select for which detectors enable MC tuning on data
188
189
4ec8e76d 190private:
191 Bool_t fIsMC; // If we run on MC data
1c9d11be 192 Bool_t fCachePID;
4ec8e76d 193
194 TString fOADBPath; // OADB path to use
00a38d07 195 TString fCustomTPCpidResponse; // Custom TPC Pid Response file for debugging purposes
4ec8e76d 196
197 TString fBeamType; //! beam type (PP) or (PBPB)
198 TString fLHCperiod; //! LHC period
199 TString fMCperiodTPC; //! corresponding MC period to use for the TPC splines
fd21ec8d 200 TString fMCperiodUser; // MC prodution requested by the user
ea235c90 201 TString fCurrentFile; //! name of currently processed file
4ec8e76d 202 Int_t fRecoPass; //! reconstruction pass
fd21ec8d 203 Int_t fRecoPassUser; // reconstruction pass explicitly set by the user
4ec8e76d 204 Int_t fRun; //! current run number
205 Int_t fOldRun; //! current run number
78cbd205 206 Float_t fResT0A; //! T0A resolution in current run
207 Float_t fResT0C; //! T0C resolution in current run
208 Float_t fResT0AC; //! T0A.and.T0C resolution in current run
fd21ec8d 209
4ec8e76d 210 TObjArray *fArrPidResponseMaster; //! TPC pid splines
211 TF1 *fResolutionCorrection; //! TPC resolution correction
644666df 212 AliOADBContainer* fOADBvoltageMaps; //! container with the voltage maps
f84b18dd 213 Bool_t fUseTPCEtaCorrection; // Use TPC eta correction
214
db0e2c5f 215 AliTRDPIDResponseObject *fTRDPIDResponseObject; //! TRD PID Response Object
ea235c90 216
0b39f221 217 Float_t fTOFtail; //! TOF tail effect used in TOF probability
b79db598 218 AliTOFPIDParams *fTOFPIDParams; //! TOF PID Params - period depending (OADB loaded)
567624b5 219
220 AliHMPIDPIDParams *fHMPIDPIDParams; //! HMPID PID Params (OADB loaded)
e96b9916 221
b2138b40 222 TObjArray *fEMCALPIDParams; //! EMCAL PID Params
223
e96b9916 224 AliVEvent *fCurrentEvent; //! event currently being processed
80f28562 225
226 Float_t fCurrCentrality; //! current centrality
4ec8e76d 227
355b831b 228
4ec8e76d 229 void ExecNewRun();
230
231 //
232 //setup parametrisations
233 //
234
235 //ITS
236 void SetITSParametrisation();
237
238 //TPC
f84b18dd 239 void SetTPCEtaMaps(Double_t refineFactorMapX = 6.0, Double_t refineFactorMapY = 6.0, Double_t refineFactorSigmaMapX = 6.0,
240 Double_t refineFactorSigmaMapY = 6.0);
4ec8e76d 241 void SetTPCPidResponseMaster();
242 void SetTPCParametrisation();
243 Double_t GetTPCMultiplicityBin(const AliVEvent * const event);
f84b18dd 244
245 // TPC helpers for the eta maps
246 void AddPointToHyperplane(TH2D* h, TLinearFitter* linExtrapolation, Int_t binX, Int_t binY);
247 TH2D* RefineHistoViaLinearInterpolation(TH2D* h, Double_t refineFactorX = 6.0, Double_t refineFactorY = 6.0);
4ec8e76d 248
ea235c90 249 //TRD
250 void SetTRDPidResponseMaster();
251 void InitializeTRDResponse();
bd58d4b9 252 void SetTRDSlices(UInt_t TRDslicesForPID[2],AliTRDPIDResponse::ETRDPIDMethod method) const;
ea235c90 253
4ec8e76d 254 //TOF
b79db598 255 void SetTOFPidResponseMaster();
256 void InitializeTOFResponse();
b2138b40 257
567624b5 258 //HMPID
259 void SetHMPIDPidResponseMaster();
260 void InitializeHMPIDResponse();
261
b2138b40 262 //EMCAL
263 void SetEMCALPidResponseMaster();
264 void InitializeEMCALResponse();
265
4ec8e76d 266 //
267 void SetRecoInfo();
1c9d11be 268
355b831b 269 //-------------------------------------------------
1c9d11be 270 //unbuffered PID calculation
355b831b 271 //
272
273 // Number of sigmas
1c9d11be 274 Float_t GetNumberOfSigmas(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type) const;
275 Float_t GetNumberOfSigmasITS (const AliVParticle *track, AliPID::EParticleType type) const;
276 Float_t GetNumberOfSigmasTPC (const AliVParticle *track, AliPID::EParticleType type) const;
355b831b 277 Float_t GetNumberOfSigmasTOF (const AliVParticle *track, AliPID::EParticleType type) const;
567624b5 278 Float_t GetNumberOfSigmasHMPID(const AliVParticle *track, AliPID::EParticleType type) const;
1c9d11be 279 Float_t GetNumberOfSigmasEMCAL(const AliVParticle *track, AliPID::EParticleType type, Double_t &eop, Double_t showershape[4]) const;
280 Float_t GetNumberOfSigmasEMCAL(const AliVParticle *track, AliPID::EParticleType type) const;
281
355b831b 282 Float_t GetBufferedNumberOfSigmas(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type) const;
567624b5 283
284 // Signal deltas
1d59271b 285 EDetPidStatus GetSignalDeltaITS(const AliVParticle *track, AliPID::EParticleType type, Double_t &val, Bool_t ratio=kFALSE) const;
286 EDetPidStatus GetSignalDeltaTPC(const AliVParticle *track, AliPID::EParticleType type, Double_t &val, Bool_t ratio=kFALSE) const;
287 EDetPidStatus GetSignalDeltaTOF(const AliVParticle *track, AliPID::EParticleType type, Double_t &val, Bool_t ratio=kFALSE) const;
288 EDetPidStatus GetSignalDeltaHMPID(const AliVParticle *vtrack, AliPID::EParticleType type, Double_t &val, Bool_t ratio=kFALSE) const;
355b831b 289
290 // Probabilities
1c9d11be 291 EDetPidStatus GetComputePIDProbability (EDetector detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
292 EDetPidStatus GetComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
293 EDetPidStatus GetComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
294 EDetPidStatus GetComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
295 EDetPidStatus GetComputeEMCALProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
296 EDetPidStatus GetComputePHOSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
297 EDetPidStatus GetComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
355b831b 298
299 // pid status
300 EDetPidStatus GetPIDStatus(EDetector det, const AliVTrack *track) const;
301 EDetPidStatus GetITSPIDStatus(const AliVTrack *track) const;
302 EDetPidStatus GetTPCPIDStatus(const AliVTrack *track) const;
303 EDetPidStatus GetTRDPIDStatus(const AliVTrack *track) const;
304 EDetPidStatus GetHMPIDPIDStatus(const AliVTrack *track) const;
305 EDetPidStatus GetPHOSPIDStatus(const AliVTrack *track) const;
306 EDetPidStatus GetEMCALPIDStatus(const AliVTrack *track) const;
307
f84b18dd 308 ClassDef(AliPIDResponse, 11); //PID response handling
29bf19f2 309};
310
29bf19f2 311#endif