#90105
[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
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
25class AliVEvent;
4ec8e76d 26class TF1;
29bf19f2 27
28class AliPIDResponse : public TNamed {
29public:
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;
29bf19f2 64 virtual Float_t NumberOfSigmasTOF(const AliVParticle *track, AliPID::EParticleType type) const = 0;
ea235c90 65 virtual Bool_t IdentifiedAsElectronTRD(const AliVTrack *track, Double_t efficiencyLevel) const;
29bf19f2 66
fd21ec8d 67 EDetPidStatus ComputePIDProbability (EDetCode detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
68
69 EDetPidStatus ComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
70 EDetPidStatus ComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
71 EDetPidStatus ComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
72 EDetPidStatus ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
73 EDetPidStatus ComputeEMCALProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
74 EDetPidStatus ComputePHOSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
75 EDetPidStatus ComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
76
77
78 void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; }
4ec8e76d 79 virtual void SetTOFResponse(AliVEvent */*event*/,EStartTimeType_t /*option*/) {;}
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");};
98
4ec8e76d 99 AliPIDResponse(const AliPIDResponse &other);
100 AliPIDResponse& operator=(const AliPIDResponse &other);
80f28562 101
29bf19f2 102
103protected:
104 AliITSPIDResponse fITSResponse; //PID response function of the ITS
105 AliTPCPIDResponse fTPCResponse; //PID response function of the TPC
106 AliTRDPIDResponse fTRDResponse; //PID response function of the TRD
107 AliTOFPIDResponse fTOFResponse; //PID response function of the TOF
e96b9916 108 AliEMCALPIDResponse fEMCALResponse; //PID response function of the EMCAL
4ec8e76d 109
fd21ec8d 110 Float_t fRange; // nSigma max in likelihood
111 ITSPIDmethod fITSPIDmethod; // 0 = trunc mean; 1 = likelihood
112
4ec8e76d 113private:
114 Bool_t fIsMC; // If we run on MC data
115
116 TString fOADBPath; // OADB path to use
117
118 TString fBeamType; //! beam type (PP) or (PBPB)
119 TString fLHCperiod; //! LHC period
120 TString fMCperiodTPC; //! corresponding MC period to use for the TPC splines
fd21ec8d 121 TString fMCperiodUser; // MC prodution requested by the user
ea235c90 122 TString fCurrentFile; //! name of currently processed file
4ec8e76d 123 Int_t fRecoPass; //! reconstruction pass
fd21ec8d 124 Int_t fRecoPassUser; // reconstruction pass explicitly set by the user
4ec8e76d 125 Int_t fRun; //! current run number
126 Int_t fOldRun; //! current run number
fd21ec8d 127
4ec8e76d 128 TObjArray *fArrPidResponseMaster; //! TPC pid splines
129 TF1 *fResolutionCorrection; //! TPC resolution correction
130
ce487a7f 131 AliTRDPIDParams *fTRDPIDParams; //! TRD PID Params
ea235c90 132 AliTRDPIDReference *fTRDPIDReference; //! TRD PID References
133 UInt_t fTRDslicesForPID[2]; //! TRD PID slices
134
4ec8e76d 135 Int_t fTOFTimeZeroType; //! default start time type for tof (ESD)
136 Float_t fTOFres; //! TOF resolution
0b39f221 137 Float_t fTOFtail; //! TOF tail effect used in TOF probability
e96b9916 138
b2138b40 139 TObjArray *fEMCALPIDParams; //! EMCAL PID Params
140
e96b9916 141 AliVEvent *fCurrentEvent; //! event currently being processed
80f28562 142
143 Float_t fCurrCentrality; //! current centrality
4ec8e76d 144
145 void ExecNewRun();
146
147 //
148 //setup parametrisations
149 //
150
151 //ITS
152 void SetITSParametrisation();
153
154 //TPC
155 void SetTPCPidResponseMaster();
156 void SetTPCParametrisation();
157 Double_t GetTPCMultiplicityBin(const AliVEvent * const event);
158
ea235c90 159 //TRD
160 void SetTRDPidResponseMaster();
161 void InitializeTRDResponse();
162
4ec8e76d 163 //TOF
b2138b40 164
165 //EMCAL
166 void SetEMCALPidResponseMaster();
167 void InitializeEMCALResponse();
168
4ec8e76d 169 //
170 void SetRecoInfo();
29bf19f2 171
0b39f221 172 ClassDef(AliPIDResponse,5); //PID response handling
29bf19f2 173};
174
175inline Float_t AliPIDResponse::NumberOfSigmasTPC(const AliVParticle *vtrack, AliPID::EParticleType type) const {
176 AliVTrack *track=(AliVTrack*)vtrack;
177 Double_t mom = track->GetTPCmomentum();
178 Double_t sig = track->GetTPCsignal();
179 UInt_t sigN = track->GetTPCsignalN();
180
181 Double_t nSigma = -999.;
182 if (sigN>0) nSigma=fTPCResponse.GetNumberOfSigmas(mom,sig,sigN,type);
183
184 return nSigma;
185}
186
187inline Float_t AliPIDResponse::NumberOfSigmasITS(const AliVParticle *vtrack, AliPID::EParticleType type) const {
188 AliVTrack *track=(AliVTrack*)vtrack;
189 Float_t dEdx=track->GetITSsignal();
190 if (dEdx<=0) return -999.;
191
192 UChar_t clumap=track->GetITSClusterMap();
193 Int_t nPointsForPid=0;
194 for(Int_t i=2; i<6; i++){
195 if(clumap&(1<<i)) ++nPointsForPid;
196 }
197 Float_t mom=track->P();
198 Bool_t isSA=kTRUE;
199 if(track->GetTPCNcls()>0) isSA=kFALSE;
200 return fITSResponse.GetNumberOfSigmas(mom,dEdx,type,nPointsForPid,isSA);
201}
202
203#endif