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; |
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;} |
83 | void InitialiseEvent(AliVEvent *event, Int_t pass); |
ea235c90 |
84 | void SetCurrentFile(const char* file) { fCurrentFile=file; } |
4ec8e76d |
85 | |
e96b9916 |
86 | AliVEvent * GetCurrentEvent() const {return fCurrentEvent;} |
87 | |
fd21ec8d |
88 | // User settings for the MC period and reco pass |
89 | void SetMCperiod(const char *mcPeriod) {fMCperiodUser=mcPeriod;} |
90 | void SetRecoPass(Int_t recoPass) {fRecoPassUser=recoPass;} |
91 | |
4ec8e76d |
92 | AliPIDResponse(const AliPIDResponse &other); |
93 | AliPIDResponse& operator=(const AliPIDResponse &other); |
29bf19f2 |
94 | |
95 | protected: |
96 | AliITSPIDResponse fITSResponse; //PID response function of the ITS |
97 | AliTPCPIDResponse fTPCResponse; //PID response function of the TPC |
98 | AliTRDPIDResponse fTRDResponse; //PID response function of the TRD |
99 | AliTOFPIDResponse fTOFResponse; //PID response function of the TOF |
e96b9916 |
100 | AliEMCALPIDResponse fEMCALResponse; //PID response function of the EMCAL |
4ec8e76d |
101 | |
fd21ec8d |
102 | Float_t fRange; // nSigma max in likelihood |
103 | ITSPIDmethod fITSPIDmethod; // 0 = trunc mean; 1 = likelihood |
104 | |
4ec8e76d |
105 | private: |
106 | Bool_t fIsMC; // If we run on MC data |
107 | |
108 | TString fOADBPath; // OADB path to use |
109 | |
110 | TString fBeamType; //! beam type (PP) or (PBPB) |
111 | TString fLHCperiod; //! LHC period |
112 | TString fMCperiodTPC; //! corresponding MC period to use for the TPC splines |
fd21ec8d |
113 | TString fMCperiodUser; // MC prodution requested by the user |
ea235c90 |
114 | TString fCurrentFile; //! name of currently processed file |
4ec8e76d |
115 | Int_t fRecoPass; //! reconstruction pass |
fd21ec8d |
116 | Int_t fRecoPassUser; // reconstruction pass explicitly set by the user |
4ec8e76d |
117 | Int_t fRun; //! current run number |
118 | Int_t fOldRun; //! current run number |
fd21ec8d |
119 | |
4ec8e76d |
120 | TObjArray *fArrPidResponseMaster; //! TPC pid splines |
121 | TF1 *fResolutionCorrection; //! TPC resolution correction |
122 | |
ce487a7f |
123 | AliTRDPIDParams *fTRDPIDParams; //! TRD PID Params |
ea235c90 |
124 | AliTRDPIDReference *fTRDPIDReference; //! TRD PID References |
125 | UInt_t fTRDslicesForPID[2]; //! TRD PID slices |
126 | |
4ec8e76d |
127 | Int_t fTOFTimeZeroType; //! default start time type for tof (ESD) |
128 | Float_t fTOFres; //! TOF resolution |
e96b9916 |
129 | |
b2138b40 |
130 | TObjArray *fEMCALPIDParams; //! EMCAL PID Params |
131 | |
e96b9916 |
132 | AliVEvent *fCurrentEvent; //! event currently being processed |
4ec8e76d |
133 | |
134 | void ExecNewRun(); |
135 | |
136 | // |
137 | //setup parametrisations |
138 | // |
139 | |
140 | //ITS |
141 | void SetITSParametrisation(); |
142 | |
143 | //TPC |
144 | void SetTPCPidResponseMaster(); |
145 | void SetTPCParametrisation(); |
146 | Double_t GetTPCMultiplicityBin(const AliVEvent * const event); |
147 | |
ea235c90 |
148 | //TRD |
149 | void SetTRDPidResponseMaster(); |
150 | void InitializeTRDResponse(); |
151 | |
4ec8e76d |
152 | //TOF |
b2138b40 |
153 | |
154 | //EMCAL |
155 | void SetEMCALPidResponseMaster(); |
156 | void InitializeEMCALResponse(); |
157 | |
4ec8e76d |
158 | // |
159 | void SetRecoInfo(); |
29bf19f2 |
160 | |
9731418d |
161 | ClassDef(AliPIDResponse,3); //PID response handling |
29bf19f2 |
162 | }; |
163 | |
164 | inline Float_t AliPIDResponse::NumberOfSigmasTPC(const AliVParticle *vtrack, AliPID::EParticleType type) const { |
165 | AliVTrack *track=(AliVTrack*)vtrack; |
166 | Double_t mom = track->GetTPCmomentum(); |
167 | Double_t sig = track->GetTPCsignal(); |
168 | UInt_t sigN = track->GetTPCsignalN(); |
169 | |
170 | Double_t nSigma = -999.; |
171 | if (sigN>0) nSigma=fTPCResponse.GetNumberOfSigmas(mom,sig,sigN,type); |
172 | |
173 | return nSigma; |
174 | } |
175 | |
176 | inline Float_t AliPIDResponse::NumberOfSigmasITS(const AliVParticle *vtrack, AliPID::EParticleType type) const { |
177 | AliVTrack *track=(AliVTrack*)vtrack; |
178 | Float_t dEdx=track->GetITSsignal(); |
179 | if (dEdx<=0) return -999.; |
180 | |
181 | UChar_t clumap=track->GetITSClusterMap(); |
182 | Int_t nPointsForPid=0; |
183 | for(Int_t i=2; i<6; i++){ |
184 | if(clumap&(1<<i)) ++nPointsForPid; |
185 | } |
186 | Float_t mom=track->P(); |
187 | Bool_t isSA=kTRUE; |
188 | if(track->GetTPCNcls()>0) isSA=kFALSE; |
189 | return fITSResponse.GetNumberOfSigmas(mom,dEdx,type,nPointsForPid,isSA); |
190 | } |
191 | |
192 | #endif |