]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliTOFPIDResponse.cxx
Corrected recommit of rev. 63120
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliTOFPIDResponse.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 //-----------------------------------------------------------------//
17 //                                                                 //
18 //           Implementation of the TOF PID class                   //
19 //      Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch         //
20 //                                                                 //
21 //-----------------------------------------------------------------//
22
23 #include "TMath.h"
24 #include "AliLog.h"
25 #include "TF1.h"
26
27 #include "AliTOFPIDResponse.h"
28
29 ClassImp(AliTOFPIDResponse)
30
31 TF1 *AliTOFPIDResponse::fTOFtailResponse = NULL; // function to generate a TOF tail
32
33 //_________________________________________________________________________
34 AliTOFPIDResponse::AliTOFPIDResponse(): 
35   fSigma(0),
36   fPmax(0),         // zero at 0.5 GeV/c for pp
37   fTime0(0)
38 {
39   fPar[0] = 0.008;
40   fPar[1] = 0.008;
41   fPar[2] = 0.002;
42   fPar[3] = 40.0;
43
44   if(!fTOFtailResponse){
45     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);
46     fTOFtailResponse->SetParameter(0,1);
47     fTOFtailResponse->SetParameter(1,-26);
48     fTOFtailResponse->SetParameter(2,1);
49     fTOFtailResponse->SetParameter(3,0.89);
50     fTOFtailResponse->SetNpx(10000);
51   }
52     
53
54   // Reset T0 info
55   ResetT0info();
56   SetMomBoundary();
57 }
58 //_________________________________________________________________________
59 AliTOFPIDResponse::AliTOFPIDResponse(Double_t *param):
60   fSigma(param[0]),
61   fPmax(0),          // zero at 0.5 GeV/c for pp
62   fTime0(0)
63 {
64   //
65   //  The main constructor
66   //
67   //
68
69   //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb 
70
71   fPar[0] = 0.008;
72   fPar[1] = 0.008;
73   fPar[2] = 0.002;
74   fPar[3] = 40.0;
75
76   if(!fTOFtailResponse){
77     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);
78     fTOFtailResponse->SetParameter(0,1);
79     fTOFtailResponse->SetParameter(1,-26);
80     fTOFtailResponse->SetParameter(2,1);
81     fTOFtailResponse->SetParameter(3,0.89);
82     fTOFtailResponse->SetNpx(10000);
83   }
84
85   // Reset T0 info
86   ResetT0info();
87   SetMomBoundary();
88 }
89 //_________________________________________________________________________
90 Double_t 
91 AliTOFPIDResponse::GetMismatchProbability(Double_t p, Double_t mass) const {
92   //
93   // Returns the probability of mismatching 
94   // assuming 1/(p*beta)^2 scaling
95   //
96   const Double_t km=0.5;                   // "reference" momentum (GeV/c)
97
98   Double_t ref2=km*km*km*km/(km*km + mass*mass);// "reference" (p*beta)^2
99   Double_t p2beta2=p*p*p*p/(p*p + mass*mass);
100
101   return fPmax*ref2/p2beta2;
102 }
103 //_________________________________________________________________________
104 Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, Float_t mass) const {
105   //
106   // Return the expected sigma of the PID signal for the specified
107   // particle mass/Z.
108   // If the operation is not possible, return a negative value.
109   //
110
111   Double_t dpp=fPar[0] + fPar[1]*mom + fPar[2]*mass/mom;      //mean relative pt resolution;
112
113  
114   Double_t sigma = dpp*time/(1.+ mom*mom/(mass*mass));
115   
116   Int_t index = GetMomBin(mom);
117
118   Double_t t0res = fT0resolution[index];
119
120   return TMath::Sqrt(sigma*sigma + fPar[3]*fPar[3]/mom/mom + fSigma*fSigma + t0res*t0res);
121
122 }
123 //_________________________________________________________________________
124 Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, AliPID::EParticleType  type) const {
125   //
126   // Return the expected sigma of the PID signal for the specified
127   // particle type.
128   // If the operation is not possible, return a negative value.
129   //
130   
131   Double_t mass = AliPID::ParticleMassZ(type);
132   Double_t dpp=fPar[0] + fPar[1]*mom + fPar[2]*mass/mom;      //mean relative pt resolution;
133
134  
135   Double_t sigma = dpp*time/(1.+ mom*mom/(mass*mass));
136   
137   Int_t index = GetMomBin(mom);
138
139   Double_t t0res = fT0resolution[index];
140
141   return TMath::Sqrt(sigma*sigma + fPar[3]*fPar[3]/mom/mom + fSigma*fSigma + t0res*t0res);
142
143 }
144 //_________________________________________________________________________
145 Double_t AliTOFPIDResponse::GetExpectedSignal(const AliVTrack* track,AliPID::EParticleType type) const {
146   //
147   // Return the expected signal of the PID signal for the particle type
148   // If the operation is not possible, return a negative value.
149   //
150   Double_t expt[5];
151   track->GetIntegratedTimes(expt);
152   if (type<=AliPID::kProton) return expt[type];
153   else {
154     Double_t p = track->P();
155     Double_t massZ = AliPID::ParticleMassZ(type);
156     return expt[0]/p*massZ*TMath::Sqrt(1.+p*p/massZ/massZ);
157   }
158 }
159 //_________________________________________________________________________
160 Int_t AliTOFPIDResponse::GetMomBin(Float_t p) const{
161   //
162   // Returns the momentum bin index
163   //
164
165   Int_t i=0;
166   while(p > fPCutMin[i] && i < fNmomBins) i++;
167   if(i > 0) i--;
168
169   return i;
170 }
171 //_________________________________________________________________________
172 void AliTOFPIDResponse::SetMomBoundary(){
173   //
174   // Set boundaries for momentum bins
175   //
176
177   fPCutMin[0] = 0.3;
178   fPCutMin[1] = 0.5;
179   fPCutMin[2] = 0.6;
180   fPCutMin[3] = 0.7;
181   fPCutMin[4] = 0.8;
182   fPCutMin[5] = 0.9;
183   fPCutMin[6] = 1;
184   fPCutMin[7] = 1.2;
185   fPCutMin[8] = 1.5;
186   fPCutMin[9] = 2;
187   fPCutMin[10] = 3;  
188 }
189 //_________________________________________________________________________
190 Float_t AliTOFPIDResponse::GetStartTime(Float_t mom) const {
191   //
192   // Returns event_time value as estimated by TOF combinatorial algorithm
193   //
194
195   Int_t ibin = GetMomBin(mom);
196   return GetT0bin(ibin);
197
198 }
199 //_________________________________________________________________________
200 Float_t AliTOFPIDResponse::GetStartTimeRes(Float_t mom) const {
201   //
202   // Returns event_time resolution as estimated by TOF combinatorial algorithm
203   //
204
205   Int_t ibin = GetMomBin(mom);
206   return GetT0binRes(ibin);
207
208 }
209 //_________________________________________________________________________
210 Int_t AliTOFPIDResponse::GetStartTimeMask(Float_t mom) const {
211   //
212   // Returns event_time mask
213   //
214
215   Int_t ibin = GetMomBin(mom);
216   return GetT0binMask(ibin);
217
218 }
219 //_________________________________________________________________________
220 Double_t AliTOFPIDResponse::GetTailRandomValue() const // generate a random value to add a tail to TOF time (for MC analyses)
221 {
222   if(fTOFtailResponse)
223     return fTOFtailResponse->GetRandom();
224   else
225     return 0.0;
226 }