1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //-----------------------------------------------------------------//
18 // Implementation of the TOF PID class //
19 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch //
21 //-----------------------------------------------------------------//
31 #include "AliTOFPIDResponse.h"
33 ClassImp(AliTOFPIDResponse)
35 TF1 *AliTOFPIDResponse::fTOFtailResponse = NULL; // function to generate a TOF tail
36 TH1F *AliTOFPIDResponse::fHmismTOF = NULL; // TOF mismatch distribution
37 TH1D *AliTOFPIDResponse::fHchannelTOFdistr=NULL; // TOF channel distance distribution
39 //_________________________________________________________________________
40 AliTOFPIDResponse::AliTOFPIDResponse():
42 fPmax(0), // zero at 0.5 GeV/c for pp
50 if(!fTOFtailResponse){
51 fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000);
52 fTOFtailResponse->SetParameter(0,1);
53 fTOFtailResponse->SetParameter(1,-26);
54 fTOFtailResponse->SetParameter(2,1);
55 fTOFtailResponse->SetParameter(3,0.89);
56 fTOFtailResponse->SetNpx(10000);
64 //_________________________________________________________________________
65 AliTOFPIDResponse::AliTOFPIDResponse(Double_t *param):
67 fPmax(0), // zero at 0.5 GeV/c for pp
71 // The main constructor
75 //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb
82 if(!fTOFtailResponse){
83 fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000);
84 fTOFtailResponse->SetParameter(0,1);
85 fTOFtailResponse->SetParameter(1,-26);
86 fTOFtailResponse->SetParameter(2,1);
87 fTOFtailResponse->SetParameter(3,0.89);
88 fTOFtailResponse->SetNpx(10000);
95 //_________________________________________________________________________
96 void AliTOFPIDResponse::SetTOFtail(Float_t tail){
97 if(!fTOFtailResponse){
98 fTOFtailResponse = new TF1("fTOFtail","[0]*TMath::Exp(-(x-[1])*(x-[1])/2/[2]/[2])* (x < [1]+[3]*[2]) + (x > [1]+[3]*[2])*[0]*TMath::Exp(-(x-[1]-[3]*[2]*0.5)*[3]/[2] * 0.0111)*0.018",-1000,1000);
99 fTOFtailResponse->SetParameter(0,1);
100 fTOFtailResponse->SetParameter(1,-26);
101 fTOFtailResponse->SetParameter(2,1);
102 fTOFtailResponse->SetParameter(3,tail);
103 fTOFtailResponse->SetNpx(10000);
106 fTOFtailResponse->SetParameter(3,tail);
109 //_________________________________________________________________________
111 AliTOFPIDResponse::GetMismatchProbability(Double_t time,Double_t eta) const {
113 TFile *fmism = new TFile("$ALICE_ROOT/TOF/data/TOFmismatchDistr.root");
114 if(fmism) fHmismTOF = (TH1F *) fmism->Get("TOFmismDistr");
116 printf("I cannot retrive TOF mismatch histos... skipped!");
119 fHmismTOF->Scale(TMath::Sqrt(2*TMath::Pi())/(fHmismTOF->Integral(1,fHmismTOF->GetNbinsX()) * fHmismTOF->GetBinWidth(1)));
121 TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root");
122 if(fchDist) fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist");
123 if(!fHchannelTOFdistr){
124 printf("I cannot retrive TOF channel distance distribution... skipped!");
129 Float_t etaAbs = TMath::Abs(eta);
130 Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
131 if(channel < 1 || etaAbs > 1) channel = 1;
132 Float_t distIP = fHchannelTOFdistr->GetBinContent(channel);
134 Double_t mismWeight = fHmismTOF->Interpolate(time - distIP*3.35655419905265973e+01);
138 //_________________________________________________________________________
139 Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, Float_t mass) const {
141 // Return the expected sigma of the PID signal for the specified
143 // If the operation is not possible, return a negative value.
146 Double_t dpp=fPar[0] + fPar[1]*mom + fPar[2]*mass/mom; //mean relative pt resolution;
149 Double_t sigma = dpp*time/(1.+ mom*mom/(mass*mass));
151 Int_t index = GetMomBin(mom);
153 Double_t t0res = fT0resolution[index];
155 return TMath::Sqrt(sigma*sigma + fPar[3]*fPar[3]/mom/mom + fSigma*fSigma + t0res*t0res);
158 //_________________________________________________________________________
159 Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, AliPID::EParticleType type) const {
161 // Return the expected sigma of the PID signal for the specified
163 // If the operation is not possible, return a negative value.
166 Double_t mass = AliPID::ParticleMassZ(type);
167 Double_t dpp=fPar[0] + fPar[1]*mom + fPar[2]*mass/mom; //mean relative pt resolution;
170 Double_t sigma = dpp*time/(1.+ mom*mom/(mass*mass));
172 Int_t index = GetMomBin(mom);
174 Double_t t0res = fT0resolution[index];
176 return TMath::Sqrt(sigma*sigma + fPar[3]*fPar[3]/mom/mom + fSigma*fSigma + t0res*t0res);
179 //_________________________________________________________________________
180 Double_t AliTOFPIDResponse::GetExpectedSignal(const AliVTrack* track,AliPID::EParticleType type) const {
182 // Return the expected signal of the PID signal for the particle type
183 // If the operation is not possible, return a negative value.
186 track->GetIntegratedTimes(expt);
187 if (type<=AliPID::kProton) return expt[type];
189 Double_t p = track->P();
190 Double_t massZ = AliPID::ParticleMassZ(type);
191 return expt[0]/p*massZ*TMath::Sqrt(1.+p*p/massZ/massZ);
194 //_________________________________________________________________________
195 Int_t AliTOFPIDResponse::GetMomBin(Float_t p) const{
197 // Returns the momentum bin index
201 while(p > fPCutMin[i] && i < fNmomBins) i++;
206 //_________________________________________________________________________
207 void AliTOFPIDResponse::SetMomBoundary(){
209 // Set boundaries for momentum bins
224 //_________________________________________________________________________
225 Float_t AliTOFPIDResponse::GetStartTime(Float_t mom) const {
227 // Returns event_time value as estimated by TOF combinatorial algorithm
230 Int_t ibin = GetMomBin(mom);
231 return GetT0bin(ibin);
234 //_________________________________________________________________________
235 Float_t AliTOFPIDResponse::GetStartTimeRes(Float_t mom) const {
237 // Returns event_time resolution as estimated by TOF combinatorial algorithm
240 Int_t ibin = GetMomBin(mom);
241 return GetT0binRes(ibin);
244 //_________________________________________________________________________
245 Int_t AliTOFPIDResponse::GetStartTimeMask(Float_t mom) const {
247 // Returns event_time mask
250 Int_t ibin = GetMomBin(mom);
251 return GetT0binMask(ibin);
254 //_________________________________________________________________________
255 Double_t AliTOFPIDResponse::GetTailRandomValue(Float_t pt,Float_t eta,Float_t time,Float_t addmism) // generate a random value to add a tail to TOF time (for MC analyses)
259 Float_t mismAdd = addmism*0.01;
260 if(pt>1.0) mismAdd /= pt;
262 if(mismAdd > 0.01){ // apply additional mismatch
263 if(gRandom->Rndm() < mismAdd){
264 return GetMismatchRandomValue(eta)-time;
269 return fTOFtailResponse->GetRandom();
273 //_________________________________________________________________________
274 Double_t AliTOFPIDResponse::GetMismatchRandomValue(Float_t eta) // generate a random value for mismatched tracks (for MC analyses)
277 TFile *fmism = new TFile("$ALICE_ROOT/TOF/data/TOFmismatchDistr.root");
278 if(fmism) fHmismTOF = (TH1F *) fmism->Get("TOFmismDistr");
280 printf("I cannot retrive TOF mismatch histos... skipped!");
283 fHmismTOF->Scale(TMath::Sqrt(2*TMath::Pi())/(fHmismTOF->Integral(1,fHmismTOF->GetNbinsX()) * fHmismTOF->GetBinWidth(1)));
285 TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root");
286 if(fchDist) fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist");
287 if(!fHchannelTOFdistr){
288 printf("I cannot retrive TOF channel distance distribution... skipped!");
293 Float_t etaAbs = TMath::Abs(eta);
294 Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
295 if(channel < 1 || etaAbs > 1) channel = 1;
296 Float_t distIP = fHchannelTOFdistr->GetBinContent(channel);
298 return fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01;
300 //_________________________________________________________________________
301 Int_t AliTOFPIDResponse::GetTOFchannel(AliVParticle *trk) const{
302 Float_t etaAbs = TMath::Abs(trk->Eta());
303 Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
304 if(channel < 1 || etaAbs > 1) channel = 1;