1 //////////////////////////////////////////////////////////////////////////
2 // USER Class for PID in the ITS //
3 //The PID is based on the likelihood of all the four ITS' layers, //
4 //without using the truncated mean for the dE/dx. The response //
5 //functions for each layer are convoluted Landau-Gaussian functions. //
6 // Origin: Elena Bruna bruna@to.infn.it,, Massimo Masera masera@to.infn.it//
7 //////////////////////////////////////////////////////////////////////////
8 #include "AliESDtrack.h"
9 #include "AliITSPident.h"
10 #include "AliITSSteerPid.h"
11 #include <Riostream.h>
13 ClassImp(AliITSPident)
14 //_______________________________________________________________________
15 AliITSPident::AliITSPident():
25 // default constructor
26 for (Int_t i=0;i<8;i++){
31 for (Int_t i=0;i<4;i++)fNcls[i]=0;
33 //_______________________________________________________________________
34 AliITSPident::~AliITSPident(){
37 //______________________________________________________________________
38 AliITSPident::AliITSPident(const AliITSPident &ob) :TObject(ob),
40 fPBayesp(ob.fPBayesp),
41 fPBayesk(ob.fPBayesk),
42 fPBayespi(ob.fPBayespi),
43 fPPriorip(ob.fPPriorip),
44 fPPriorik(ob.fPPriorik),
45 fPPrioripi(ob.fPPrioripi),
46 fPPriorie(ob.fPPriorie)
51 //______________________________________________________________________
52 AliITSPident& AliITSPident::operator=(const AliITSPident& ob){
53 // Assignment operator
54 this->~AliITSPident();
55 new(this) AliITSPident(ob);
60 //_______________________________________________________________________
61 AliITSPident::AliITSPident(Double_t mom,AliITSSteerPid *sp,Float_t *Qlay,Float_t *nlay,Float_t priorip,Float_t priorik,Float_t prioripi,Float_t priorie):
72 for (Int_t i=0;i<8;i++){
77 for(Int_t la=0;la<4;la++){//loop on layers
78 Double_t parp[3];Double_t park[3];Double_t parpi[3];
87 range[4]=0.3*parpi[1];
90 for(Int_t ii=0;ii<8;ii++){
94 sp->GetParFitLayer(la,fMom,parp,park,parpi);
95 CookFunItsLay(ii,0,parp,Qlay[ii],fMom,range[0],range[1],"fPro");
96 CookFunItsLay(ii,1,park,Qlay[ii],fMom,range[2],range[3],"fKao");
97 CookFunItsLay(ii,2,parpi,Qlay[ii],fMom,range[4],range[5],"fPi");
104 Float_t prior[4];Double_t condFun[8][3];
110 for(Int_t la=0;la<8;la++){
111 condFun[la][0]= fCondFunProLay[la];
112 condFun[la][1]= fCondFunKLay[la];
113 condFun[la][2]= fCondFunPiLay[la];
117 fPBayesp=CookCombinedBayes(condFun,prior,0);
118 fPBayesk=CookCombinedBayes(condFun,prior,1);
119 fPBayespi=CookCombinedBayes(condFun,prior,2);
122 //__________________________________________________________________________________________
123 AliITSPident::AliITSPident(AliESDtrack *track,AliITSSteerPid *sp,Float_t *Qlay,Float_t *nlay,Float_t priorip,Float_t priorik,Float_t prioripi,Float_t priorie):
130 fPPrioripi(prioripi),
134 for (Int_t i=0;i<8;i++){
135 fCondFunProLay[i]=-1;
141 track->GetExternalParameters(xr,par);
143 Float_t lamb=TMath::ATan(par[3]);
144 fMom=1/(TMath::Abs(par[4])*TMath::Cos(lamb));
148 for(Int_t la=0;la<4;la++){//loop on layers
149 Double_t parp[3];Double_t park[3];Double_t parpi[3];
152 range[0]=0.3*parp[1];
155 range[2]=0.3*park[1];
158 range[4]=0.3*parpi[1];
159 range[5]=2.*parpi[1];
162 for(Int_t ii=0;ii<8;ii++){
166 sp->GetParFitLayer(la,fMom,parp,park,parpi);
167 CookFunItsLay(ii,0,parp,Qlay[ii],fMom,range[0],range[1],"fPro");
168 CookFunItsLay(ii,1,park,Qlay[ii],fMom,range[2],range[3],"fKao");
169 CookFunItsLay(ii,2,parpi,Qlay[ii],fMom,range[4],range[5],"fPi");
176 Float_t prior[4];Double_t condFun[8][3];
182 for(Int_t la=0;la<8;la++){
183 condFun[la][0]= fCondFunProLay[la];
184 condFun[la][1]= fCondFunKLay[la];
185 condFun[la][2]= fCondFunPiLay[la];
189 fPBayesp=CookCombinedBayes(condFun,prior,0);
190 fPBayesk=CookCombinedBayes(condFun,prior,1);
191 fPBayespi=CookCombinedBayes(condFun,prior,2);
194 //_______________________________________________________________________
195 void AliITSPident::GetNclsPerLayer(Int_t *ncls) const{
196 //number of clusters for each layer (sdd1,sdd2,ssd1,ssd2)
197 for(Int_t la=0;la<4;la++){
201 }//_______________________________________________________________________
202 Double_t AliITSPident::GetProdCondFunPro() const {
203 //Product of conditional probability functions for protons
205 for(Int_t i=0;i<8;i++){
206 Double_t fun=GetCondFunPro(i);
210 }//_______________________________________________________________________
211 Double_t AliITSPident::GetProdCondFunK() const {
212 //Product of conditional probability functions for kaons
214 for(Int_t i=0;i<8;i++){
215 Double_t fun=GetCondFunK(i);
220 //_______________________________________________________________________
221 Double_t AliITSPident::GetProdCondFunPi() const {
222 //Product of conditional probability functions for pions
224 for(Int_t i=0;i<8;i++){
225 Double_t fun=GetCondFunPi(i);
230 //_______________________________________________________________________
231 void AliITSPident::PrintParameters() const{
233 cout<<"___________________________\n";
234 cout<<"Track Local Momentum = "<<" "<<fMom<<endl;
237 //_______________________________________________________________________
238 Double_t AliITSPident::Langaufun(Double_t *x, Double_t *par) {
241 //par[0]=Width (scale) parameter of Landau density
242 //par[1]=Most Probable (MP, location) parameter of Landau density
243 //par[2]=Total area (integral -inf to inf, normalization constant)
244 //par[3]=Width (sigma) of convoluted Gaussian function
246 //In the Landau distribution (represented by the CERNLIB approximation),
247 //the maximum is located at x=-0.22278298 with the location parameter=0.
248 //This shift is corrected within this function, so that the actual
249 //maximum is identical to the MP parameter.
252 Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
253 Double_t mpshift = -0.22278298; // Landau maximum location
256 Double_t np = 100.0; // number of convolution steps
257 Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
269 // MP shift correction
270 mpc = par[1] - mpshift * par[0];
272 // Range of convolution integral
273 xlow = x[0] - sc * par[3];
274 xupp = x[0] + sc * par[3];
276 step = (xupp-xlow) / np;
278 // Convolution integral of Landau and Gaussian by sum
279 for(i=1.0; i<=np/2; i++) {
280 xx = xlow + (i-.5) * step;
281 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
282 sum += fland * TMath::Gaus(x[0],xx,par[3]);
284 xx = xupp - (i-.5) * step;
285 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
286 sum += fland * TMath::Gaus(x[0],xx,par[3]);
289 return (par[2] * step * sum * invsq2pi / par[3]);
292 //_______________________________________________________________________
293 Double_t AliITSPident::Langaufun2(Double_t *x, Double_t *par){
294 //normalized langaufun
295 return 1/par[4]*Langaufun(x,par);
297 //_______________________________________________________________________
298 Double_t AliITSPident::Langaufunnorm(Double_t *x, Double_t *par){
300 //par[0]=Width (scale) parameter of Landau density
301 //par[1]=Most Probable (MP, location) parameter of Landau density
303 //par[2]=Width (sigma) of convoluted Gaussian function
305 //In the Landau distribution (represented by the CERNLIB approximation),
306 //the maximum is located at x=-0.22278298 with the location parameter=0.
307 //This shift is corrected within this function, so that the actual
308 //maximum is identical to the MP parameter.
311 Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
312 Double_t mpshift = -0.22278298; // Landau maximum location
315 Double_t np = 100.0; // number of convolution steps
316 Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
328 // MP shift correction
329 mpc = par[1] - mpshift * par[0];
331 // Range of convolution integral
332 xlow = x[0] - sc * par[2];
333 xupp = x[0] + sc * par[2];
335 step = (xupp-xlow) / np;
337 // Convolution integral of Landau and Gaussian by sum
338 for(i=1.0; i<=np/2; i++) {
339 xx = xlow + (i-.5) * step;
340 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
341 sum += fland * TMath::Gaus(x[0],xx,par[2]);
343 xx = xupp - (i-.5) * step;
344 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
345 sum += fland * TMath::Gaus(x[0],xx,par[2]);
348 return (step * sum * invsq2pi / par[2]);
350 //_______________________________________________________________________
351 Double_t AliITSPident::Gaus2(Double_t *x, Double_t *par){
352 //normalized gaussian function
353 return 1/(sqrt(2*TMath::Pi())*par[1])*TMath::Gaus(x[0],par[0],par[1]);
355 //_______________________________________________________________________
356 void AliITSPident::CookFunItsLay(Int_t lay,Int_t opt,Double_t *par,Double_t dedx,Double_t mom,Double_t rangei,Double_t rangef,TString comment){
357 //it gives the response functions
358 TF1 funLay(comment,Langaufunnorm,rangei,rangef,3);
359 funLay.SetParameters(par);
360 Double_t condFun=funLay.Eval(dedx);
362 fCondFunProLay[lay]=condFun;
363 if(mom<0.4 && dedx<100)fCondFunProLay[lay]=0.00001;
364 if(mom<0.4 &&dedx<50)fCondFunProLay[lay]=0.0000001;
367 fCondFunKLay[lay]=condFun;
368 if(mom<0.25 && dedx<100)fCondFunKLay[lay]=0.00001;
369 if(mom<0.4 &&dedx<30)fCondFunKLay[lay]=0.0000001;
372 fCondFunPiLay[lay]=condFun;
373 if(mom<0.6 &&dedx<20)fCondFunPiLay[lay]=0.001;
377 //_______________________________________________________________________
378 Float_t AliITSPident::CookCombinedBayes(Double_t condfun[][3],Float_t *prior,Int_t part)const {
379 //Bayesian combined PID in the ITS
382 Float_t pprior[4]={0,0,0,0};
383 for(Int_t j=0;j<4;j++)pprior[j]=prior[j];
384 pprior[2]+=pprior[3];//prior for electrons summed to priors for pions
385 for(Int_t i=0;i<8;i++){//layer
386 if (condfun[i][0]>0 || condfun[i][1]>0 ||condfun[i][2]>0) test++;
389 if ((pprior[0]!=0 || pprior[1]!=0 ||pprior[2]!=0)&&CookSum(condfun,pprior)!=0){
391 bayes=pprior[part]*CookProd(condfun,part)*1/CookSum(condfun,pprior);
399 //_______________________________________________________________________
400 Float_t AliITSPident::CookProd(Double_t condfun[][3],Int_t part)const{
403 for(Int_t lay=0;lay<8;lay++){
404 if(condfun[lay][part]>=0)p=p*condfun[lay][part];
409 //_______________________________________________________________________
410 Float_t AliITSPident::CookSum(Double_t condfun[][3],Float_t *prior)const{
413 Float_t pprior[4]={0,0,0,0};
414 for(Int_t j=0;j<4;j++)pprior[j]=prior[j];
415 pprior[2]+=pprior[3];//prior for electrons summed to priors for pions
416 for(Int_t i=0;i<3;i++){//sum over the particles--electrons excluded
417 sum+=pprior[i]*CookProd(condfun,i);