Updates in order to enable the '2D' PID for the TRD developed by Daniel Lohner.
[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
b79db598 20
29bf19f2 21#include "AliVParticle.h"
22#include "AliVTrack.h"
23
24#include "TNamed.h"
25
26class AliVEvent;
4ec8e76d 27class TF1;
db0e2c5f 28class AliTRDPIDResponseObject;
29bf19f2 29
30class AliPIDResponse : public TNamed {
31public:
4ec8e76d 32 AliPIDResponse(Bool_t isMC=kFALSE);
33 virtual ~AliPIDResponse();
29bf19f2 34
fd21ec8d 35 enum EDetCode {
36 kDetITS = 0x1,
37 kDetTPC = 0x2,
38 kDetTRD = 0x4,
39 kDetTOF = 0x8,
40 kDetHMPID = 0x10,
41 kDetEMCAL = 0x20,
42 kDetPHOS = 0x40
43 };
44
29bf19f2 45 enum EStartTimeType_t {kFILL_T0,kTOF_T0, kT0_T0, kBest_T0};
fd21ec8d 46
47 enum ITSPIDmethod { kITSTruncMean, kITSLikelihood };
48
49 enum EDetPidStatus {
50 kDetNoSignal=0,
51 kDetPidOk=1,
52 kDetMismatch=2
53 };
29bf19f2 54
55 AliITSPIDResponse &GetITSResponse() {return fITSResponse;}
56 AliTPCPIDResponse &GetTPCResponse() {return fTPCResponse;}
57 AliTOFPIDResponse &GetTOFResponse() {return fTOFResponse;}
58 AliTRDPIDResponse &GetTRDResponse() {return fTRDResponse;}
e96b9916 59 AliEMCALPIDResponse &GetEMCALResponse() {return fEMCALResponse;}
fd21ec8d 60
61 Float_t NumberOfSigmas(EDetCode detCode, const AliVParticle *track, AliPID::EParticleType type) const;
29bf19f2 62
63 virtual Float_t NumberOfSigmasITS(const AliVParticle *track, AliPID::EParticleType type) const;
64 virtual Float_t NumberOfSigmasTPC(const AliVParticle *track, AliPID::EParticleType type) const;
e96b9916 65 virtual Float_t NumberOfSigmasEMCAL(const AliVTrack *track, AliPID::EParticleType type) const;
6d0064aa 66 virtual Float_t NumberOfSigmasEMCAL(const AliVTrack *track, AliPID::EParticleType type, Double_t &eop, Double_t showershape[4]) const;
29bf19f2 67 virtual Float_t NumberOfSigmasTOF(const AliVParticle *track, AliPID::EParticleType type) const = 0;
ea235c90 68 virtual Bool_t IdentifiedAsElectronTRD(const AliVTrack *track, Double_t efficiencyLevel) const;
29bf19f2 69
fd21ec8d 70 EDetPidStatus ComputePIDProbability (EDetCode detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
71
72 EDetPidStatus ComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
73 EDetPidStatus ComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
74 EDetPidStatus ComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
75 EDetPidStatus ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
76 EDetPidStatus ComputeEMCALProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
77 EDetPidStatus ComputePHOSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
78 EDetPidStatus ComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const;
79
80
81 void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; }
ea235c90 82 void SetTRDslicesForPID(UInt_t slice1, UInt_t slice2) {fTRDslicesForPID[0]=slice1;fTRDslicesForPID[1]=slice2;}
83
4ec8e76d 84 void SetOADBPath(const char* path) {fOADBPath=path;}
80f28562 85 const char *GetOADBPath() const {return fOADBPath.Data();}
4ec8e76d 86 void InitialiseEvent(AliVEvent *event, Int_t pass);
ea235c90 87 void SetCurrentFile(const char* file) { fCurrentFile=file; }
4ec8e76d 88
e96b9916 89 AliVEvent * GetCurrentEvent() const {return fCurrentEvent;}
90
fd21ec8d 91 // User settings for the MC period and reco pass
92 void SetMCperiod(const char *mcPeriod) {fMCperiodUser=mcPeriod;}
93 void SetRecoPass(Int_t recoPass) {fRecoPassUser=recoPass;}
80f28562 94
95 // event info
96 Float_t GetCurrentCentrality() const {return fCurrCentrality;};
97
0b39f221 98 // TOF setting
99 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 100 void SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option);
0b39f221 101
4ec8e76d 102 AliPIDResponse(const AliPIDResponse &other);
103 AliPIDResponse& operator=(const AliPIDResponse &other);
80f28562 104
29bf19f2 105
106protected:
107 AliITSPIDResponse fITSResponse; //PID response function of the ITS
108 AliTPCPIDResponse fTPCResponse; //PID response function of the TPC
109 AliTRDPIDResponse fTRDResponse; //PID response function of the TRD
110 AliTOFPIDResponse fTOFResponse; //PID response function of the TOF
e96b9916 111 AliEMCALPIDResponse fEMCALResponse; //PID response function of the EMCAL
4ec8e76d 112
fd21ec8d 113 Float_t fRange; // nSigma max in likelihood
114 ITSPIDmethod fITSPIDmethod; // 0 = trunc mean; 1 = likelihood
115
4ec8e76d 116private:
117 Bool_t fIsMC; // If we run on MC data
118
119 TString fOADBPath; // OADB path to use
120
121 TString fBeamType; //! beam type (PP) or (PBPB)
122 TString fLHCperiod; //! LHC period
123 TString fMCperiodTPC; //! corresponding MC period to use for the TPC splines
fd21ec8d 124 TString fMCperiodUser; // MC prodution requested by the user
ea235c90 125 TString fCurrentFile; //! name of currently processed file
4ec8e76d 126 Int_t fRecoPass; //! reconstruction pass
fd21ec8d 127 Int_t fRecoPassUser; // reconstruction pass explicitly set by the user
4ec8e76d 128 Int_t fRun; //! current run number
129 Int_t fOldRun; //! current run number
fd21ec8d 130
4ec8e76d 131 TObjArray *fArrPidResponseMaster; //! TPC pid splines
132 TF1 *fResolutionCorrection; //! TPC resolution correction
133
db0e2c5f 134 AliTRDPIDResponseObject *fTRDPIDResponseObject; //! TRD PID Response Object
ea235c90 135 UInt_t fTRDslicesForPID[2]; //! TRD PID slices
136
0b39f221 137 Float_t fTOFtail; //! TOF tail effect used in TOF probability
b79db598 138 AliTOFPIDParams *fTOFPIDParams; //! TOF PID Params - period depending (OADB loaded)
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
b79db598 165 void SetTOFPidResponseMaster();
166 void InitializeTOFResponse();
b2138b40 167
168 //EMCAL
169 void SetEMCALPidResponseMaster();
170 void InitializeEMCALResponse();
171
4ec8e76d 172 //
173 void SetRecoInfo();
29bf19f2 174
b79db598 175 ClassDef(AliPIDResponse,6); //PID response handling
29bf19f2 176};
177
178inline Float_t AliPIDResponse::NumberOfSigmasTPC(const AliVParticle *vtrack, AliPID::EParticleType type) const {
179 AliVTrack *track=(AliVTrack*)vtrack;
180 Double_t mom = track->GetTPCmomentum();
181 Double_t sig = track->GetTPCsignal();
182 UInt_t sigN = track->GetTPCsignalN();
183
184 Double_t nSigma = -999.;
185 if (sigN>0) nSigma=fTPCResponse.GetNumberOfSigmas(mom,sig,sigN,type);
186
187 return nSigma;
188}
189
190inline Float_t AliPIDResponse::NumberOfSigmasITS(const AliVParticle *vtrack, AliPID::EParticleType type) const {
191 AliVTrack *track=(AliVTrack*)vtrack;
192 Float_t dEdx=track->GetITSsignal();
193 if (dEdx<=0) return -999.;
194
195 UChar_t clumap=track->GetITSClusterMap();
196 Int_t nPointsForPid=0;
197 for(Int_t i=2; i<6; i++){
198 if(clumap&(1<<i)) ++nPointsForPid;
199 }
200 Float_t mom=track->P();
201 Bool_t isSA=kTRUE;
202 if(track->GetTPCNcls()>0) isSA=kFALSE;
203 return fITSResponse.GetNumberOfSigmas(mom,dEdx,type,nPointsForPid,isSA);
204}
205
206#endif