cluster -> TrackPoint
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliTPCPIDResponse.h
CommitLineData
10d100d4 1#ifndef ALITPCPIDRESPONSE_H
2#define ALITPCPIDRESPONSE_H
8c6a71ab 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6//-------------------------------------------------------
7// TPC PID class
8// A very naive design... Should be made better by the detector experts...
9// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
aea7a46d 10// With many additions and modifications suggested by
11// Alexander Kalweit, GSI, alexander.philipp.kalweit@cern.ch
12// Dariusz Miskowiec, GSI, D.Miskowiec@gsi.de
f84b18dd 13// ...and some modifications by
14// Mikolaj Krzewicki, GSI, mikolaj.krzewicki@cern.ch
15// ...and some modifications plus eta correction functions by
16// Benjamin Hess, University of Tuebingen, bhess@cern.ch
8c6a71ab 17//-------------------------------------------------------
18#include <Rtypes.h>
644666df 19
20#include <TNamed.h>
21#include <TVectorF.h>
d2aa6df0 22#include <TObjArray.h>
87da0205 23#include <TF1.h>
8c6a71ab 24
aea7a46d 25#include "AliPID.h"
f84b18dd 26#include "AliVTrack.h"
aea7a46d 27
f84b18dd 28class TH2D;
644666df 29class TSpline3;
30
31class AliTPCPIDResponse: public TNamed {
8c6a71ab 32public:
10d100d4 33 AliTPCPIDResponse();
1b45e564 34 //TODO Remove? AliTPCPIDResponse(const Double_t *param);
644666df 35 AliTPCPIDResponse(const AliTPCPIDResponse&);
36 AliTPCPIDResponse& operator=(const AliTPCPIDResponse&);
f84b18dd 37 virtual ~AliTPCPIDResponse();
644666df 38
39 enum EChamberStatus {
40 kChamberOff=0,
41 kChamberHighGain=1,
42 kChamberLowGain=2,
43 kChamberInvalid=3
44 };
45
46 enum ETPCgainScenario {
47 kDefault= 0,
48 kALLhigh = 1,
49 kOROChigh = 2,
50 kGainScenarioInvalid = 3
51 };
52
53 static const Int_t fgkNumberOfParticleSpecies=AliPID::kSPECIESC;
54 static const Int_t fgkNumberOfGainScenarios=3;
55 static const Int_t fgkNumberOfdEdxSourceScenarios=3;
56
57 enum ETPCdEdxSource {
58 kdEdxDefault=0, // use combined dEdx from IROC+OROC (assumes ideal detector)
59 kdEdxOROC=1, // use only OROC
60 kdEdxHybrid=2, // Use IROC+OROC dEdx only where IROCS are good (high gain), otherwise fall back to OROC only
61 kdEdxInvalid=3 //invalid
62 };
63
10d100d4 64 void SetSigma(Float_t res0, Float_t resN2);
aea7a46d 65 void SetBetheBlochParameters(Double_t kp1,
66 Double_t kp2,
67 Double_t kp3,
68 Double_t kp4,
69 Double_t kp5
70 );
1b45e564 71 //Better prevent user from setting fMIP != 50. because fMIP set fix to 50 for much other code:
10d100d4 72 void SetMip(Float_t mip) { fMIP = mip; } // Set overall normalisation; mean dE/dx for MIP
aea7a46d 73 Double_t Bethe(Double_t bg) const;
d2aa6df0 74 void SetUseDatabase(Bool_t useDatabase) { fUseDatabase = useDatabase;}
644666df 75 Bool_t GetUseDatabase() const { return fUseDatabase;}
d2aa6df0 76
77 void SetResponseFunction(AliPID::EParticleType type, TObject * const o) { fResponseFunctions.AddAt(o,(Int_t)type); }
deae51a8 78 const TObject * GetResponseFunction(AliPID::EParticleType type) { return fResponseFunctions.At((Int_t)type); }
644666df 79 void SetVoltage(Int_t n, Float_t v) {fVoltageMap[n]=v;}
80 void SetVoltageMap(const TVectorF& a) {fVoltageMap=a;} //resets ownership, ~ will not delete contents
81 Float_t GetVoltage(Int_t n) const {return fVoltageMap[n];}
82 void SetLowGainIROCthreshold(Float_t v) {fLowGainIROCthreshold=v;}
83 void SetBadIROCthreshold(Float_t v) {fBadIROCthreshhold=v;}
84 void SetLowGainOROCthreshold(Float_t v) {fLowGainOROCthreshold=v;}
85 void SetBadOROCthreshold(Float_t v) {fBadOROCthreshhold=v;}
86 void SetMaxBadLengthFraction(Float_t f) {fMaxBadLengthFraction=f;}
87
88 void SetMagField(Double_t mf) { fMagField=mf; }
d2aa6df0 89
f84b18dd 90 const TH2D* GetEtaCorrMap() const { return fhEtaCorr; };
91 Bool_t SetEtaCorrMap(TH2D* hMap);
92
87da0205 93 Double_t GetTrackTanTheta(const AliVTrack *track) const;
f84b18dd 94
87da0205 95 Double_t GetEtaCorrection(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource = kdEdxDefault) const;
96
f84b18dd 97 Double_t GetEtaCorrectedTrackdEdx(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource = kdEdxDefault) const;
98
99 const TH2D* GetSigmaPar1Map() const { return fhEtaSigmaPar1; };
100 Double_t GetSigmaPar0() const { return fSigmaPar0; };
101 Bool_t SetSigmaParams(TH2D* hSigmaPar1Map, Double_t sigmaPar0);
102
103 Double_t GetSigmaPar1(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource = kdEdxDefault) const;
104
87da0205 105
106 const TF1* GetMultiplicityCorrectionFunction() const { return fCorrFuncMultiplicity; };
107 void SetParameterMultiplicityCorrection(Int_t parIndex, Double_t parValue)
108 { if (fCorrFuncMultiplicity) fCorrFuncMultiplicity->SetParameter(parIndex, parValue); };
109
110 const TF1* GetMultiplicityCorrectionFunctionTanTheta() const { return fCorrFuncMultiplicityTanTheta; };
111 void SetParameterMultiplicityCorrectionTanTheta(Int_t parIndex, Double_t parValue)
112 { if (fCorrFuncMultiplicityTanTheta) fCorrFuncMultiplicityTanTheta->SetParameter(parIndex, parValue); };
113
114 const TF1* GetMultiplicitySigmaCorrectionFunction() const { return fCorrFuncSigmaMultiplicity; };
115 void SetParameterMultiplicitySigmaCorrection(Int_t parIndex, Double_t parValue)
116 { if (fCorrFuncSigmaMultiplicity) fCorrFuncSigmaMultiplicity->SetParameter(parIndex, parValue); };
117
118 void ResetMultiplicityCorrectionFunctions();
119
120 void SetCurrentEventMultiplicity(Int_t value) { fCurrentEventMultiplicity = value; };
121 Int_t GetCurrentEventMultiplicity() const { return fCurrentEventMultiplicity; };
122
123 Double_t GetMultiplicityCorrection(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource) const;
124
125 Double_t GetMultiplicitySigmaCorrection(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource) const;
126
127 Double_t GetMultiplicityCorrectedTrackdEdx(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource = kdEdxDefault) const;
128
129 Double_t GetEtaAndMultiplicityCorrectedTrackdEdx(const AliVTrack *track, AliPID::EParticleType species,
130 ETPCdEdxSource dedxSource = kdEdxDefault) const;
644666df 131 //NEW
132 void SetSigma(Float_t res0, Float_t resN2, ETPCgainScenario gainScenario );
644666df 133 Double_t GetExpectedSignal( const AliVTrack* track,
134 AliPID::EParticleType species,
f84b18dd 135 ETPCdEdxSource dedxSource = kdEdxDefault,
87da0205 136 Bool_t correctEta = kFALSE,
137 Bool_t correctMultiplicity = kFALSE) const;
644666df 138 Double_t GetExpectedSigma( const AliVTrack* track,
139 AliPID::EParticleType species,
f84b18dd 140 ETPCdEdxSource dedxSource = kdEdxDefault,
87da0205 141 Bool_t correctEta = kFALSE,
142 Bool_t correctMultiplicity = kFALSE) const;
644666df 143 Float_t GetNumberOfSigmas( const AliVTrack* track,
144 AliPID::EParticleType species,
f84b18dd 145 ETPCdEdxSource dedxSource = kdEdxDefault,
87da0205 146 Bool_t correctEta = kFALSE,
147 Bool_t correctMultiplicity = kFALSE) const;
567624b5 148
149 Float_t GetSignalDelta( const AliVTrack* track,
150 AliPID::EParticleType species,
151 ETPCdEdxSource dedxSource = kdEdxDefault,
87da0205 152 Bool_t correctEta = kFALSE,
153 Bool_t correctMultiplicity = kFALSE,
154 Bool_t ratio = kFALSE) const;
567624b5 155
644666df 156 void SetResponseFunction(TObject* o,
157 AliPID::EParticleType type,
158 ETPCgainScenario gainScenario);
159 void Print(Option_t* option="") const;
160 TSpline3* GetResponseFunction( AliPID::EParticleType species,
161 ETPCgainScenario gainScenario ) const;
162 TSpline3* GetResponseFunction( const AliVTrack* track,
163 AliPID::EParticleType species,
f84b18dd 164 ETPCdEdxSource dedxSource = kdEdxDefault) const;
644666df 165 Bool_t ResponseFunctiondEdxN(const AliVTrack* track,
166 AliPID::EParticleType species,
f84b18dd 167 ETPCdEdxSource dedxSource,
168 Double_t& dEdx, Int_t& nPoints, ETPCgainScenario& gainScenario, TSpline3** responseFunction) const;
f85a3764 169 Bool_t sectorNumbersInOut(Double_t* trackPositionInner,
170 Double_t* trackPositionOuter,
644666df 171 Float_t& phiIn, Float_t& phiOut,
172 Int_t& in, Int_t& out ) const;
173 AliTPCPIDResponse::EChamberStatus TrackStatus(const AliVTrack* track, Int_t layer) const;
174 Float_t MaxClusterRadius(const AliVTrack* track) const;
175 Bool_t TrackApex(const AliVTrack* track, Float_t magField, Double_t position[3]) const;
176 static const char* GainScenarioName(Int_t n) {return fgkGainScenarioName[(n>fgkNumberOfdEdxSourceScenarios)?fgkNumberOfdEdxSourceScenarios+1:n];}
177 Int_t ResponseFunctionIndex( AliPID::EParticleType species,
178 ETPCgainScenario gainScenario ) const;
179 void ResetSplines();
180
644666df 181 //OLD
10d100d4 182 Double_t GetExpectedSignal(const Float_t mom,
aea7a46d 183 AliPID::EParticleType n=AliPID::kKaon) const;
10d100d4 184 Double_t GetExpectedSigma(const Float_t mom, const Int_t nPoints,
644666df 185 AliPID::EParticleType n=AliPID::kKaon) const;
186 Float_t GetNumberOfSigmas(const Float_t mom,
187 const Float_t dEdx,
188 const Int_t nPoints,
189 AliPID::EParticleType n=AliPID::kKaon) const {
f84b18dd 190 //
191 // Deprecated function (for backward compatibility). Please use
87da0205 192 // GetNumberOfSigmas(const AliVTrack *track, AliPID::EParticleType species, ETPCdEdxSource dedxSource,
193 // Bool_t correctEta, Bool_t correctMultiplicity)
f84b18dd 194 // instead!TODO
195 //
196
10d100d4 197 Double_t bethe=GetExpectedSignal(mom,n);
198 Double_t sigma=GetExpectedSigma(mom,nPoints,n);
199 return (dEdx-bethe)/sigma;
200 }
aea7a46d 201
10d100d4 202 Double_t GetMIP() const { return fMIP;}
644666df 203 Float_t GetRes0() const { return fRes0[0]; }
204 Float_t GetResN2() const { return fResN2[0]; }
205 Float_t GetRes0(ETPCgainScenario s) const { return fRes0[s]; }
206 Float_t GetResN2(ETPCgainScenario s) const { return fResN2[s]; }
b981edcd 207
f84b18dd 208protected:
209 Double_t GetExpectedSignal(const AliVTrack* track,
210 AliPID::EParticleType species,
211 Double_t dEdx,
212 const TSpline3* responseFunction,
87da0205 213 Bool_t correctEta,
214 Bool_t correctMultiplicity) const;
f84b18dd 215
216 Double_t GetExpectedSigma(const AliVTrack* track,
217 AliPID::EParticleType species,
218 ETPCgainScenario gainScenario,
219 Double_t dEdx,
220 Int_t nPoints,
221 const TSpline3* responseFunction,
87da0205 222 Bool_t correctEta,
223 Bool_t correctMultiplicity) const;
f84b18dd 224
225 Double_t GetEtaCorrection(const AliVTrack *track, Double_t dEdxSplines) const;
226
87da0205 227 Double_t GetMultiplicityCorrection(const AliVTrack *track, const Double_t dEdxExpected, const Int_t multiplicity) const;
228
229 Double_t GetMultiplicitySigmaCorrection(const Double_t dEdxExpected, const Int_t multiplicity) const;
230
f84b18dd 231 Double_t GetSigmaPar1(const AliVTrack *track, AliPID::EParticleType species,
232 Double_t dEdx, const TSpline3* responseFunction) const;
233
8c6a71ab 234private:
10d100d4 235 Float_t fMIP; // dEdx for MIP
644666df 236 Float_t fRes0[fgkNumberOfGainScenarios]; // relative dEdx resolution rel sigma = fRes0*sqrt(1+fResN2/npoint)
237 Float_t fResN2[fgkNumberOfGainScenarios]; // relative Npoint dependence rel sigma = fRes0*sqrt(1+fResN2/npoint)
aea7a46d 238
239 Double_t fKp1; // Parameters
240 Double_t fKp2; // of
241 Double_t fKp3; // the ALEPH
242 Double_t fKp4; // Bethe-Bloch
243 Double_t fKp5; // formula
244
d2aa6df0 245 Bool_t fUseDatabase; // flag if fine-tuned database-response or simple ALEPH BB should be used
644666df 246
d2aa6df0 247 TObjArray fResponseFunctions; //! ObjArray of response functions individually for each particle
644666df 248 TVectorF fVoltageMap; //!stores a map of voltages wrt nominal for all chambers
249 Float_t fLowGainIROCthreshold; //voltage threshold below which the IROC is considered low gain
250 Float_t fBadIROCthreshhold; //voltage threshold for bad IROCS
251 Float_t fLowGainOROCthreshold; //voltage threshold below which the OROC is considered low gain
252 Float_t fBadOROCthreshhold; //voltage threshold for bad OROCS
253 Float_t fMaxBadLengthFraction; //the maximum allowed fraction of track length in a bad sector.
254
644666df 255 Int_t sectorNumber(Double_t phi) const;
256
257 Double_t fMagField; //! Magnetic field
258
259 static const char* fgkGainScenarioName[fgkNumberOfGainScenarios+1];
d2aa6df0 260
f84b18dd 261 TH2D* fhEtaCorr; //! Map for TPC eta correction
262 TH2D* fhEtaSigmaPar1; //! Map for parameter 1 of the dEdx sigma parametrisation
263
264 Double_t fSigmaPar0; // Parameter 0 of the dEdx sigma parametrisation
87da0205 265
266 Int_t fCurrentEventMultiplicity; // Multiplicity of the current event
267 TF1* fCorrFuncMultiplicity; //! Function to correct for the multiplicity dependence of the TPC dEdx
268 TF1* fCorrFuncMultiplicityTanTheta; //! Function to correct the additional tanTheta dependence of the multiplicity dependence of the TPC dEdx
269 TF1* fCorrFuncSigmaMultiplicity; //! Function to correct for the multiplicity dependence of the TPC dEdx resolution
f84b18dd 270
87da0205 271 ClassDef(AliTPCPIDResponse,6) // TPC PID class
8c6a71ab 272};
273
274#endif
275
276