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 "AliITStrackV2.h"
9 #include "AliITSPident.h"
10 #include "AliITSSteerPid.h"
11 #include <Riostream.h>
13 ClassImp(AliITSPident)
14 //_______________________________________________________________________
15 AliITSPident::AliITSPident():
26 // default constructor
27 for (Int_t i=0;i<8;i++){
32 for (Int_t i=0;i<4;i++)fNcls[i]=0;
34 //_______________________________________________________________________
35 AliITSPident::~AliITSPident(){
38 //______________________________________________________________________
39 AliITSPident::AliITSPident(const AliITSPident &ob) :TObject(ob),
42 fPBayesp(ob.fPBayesp),
43 fPBayesk(ob.fPBayesk),
44 fPBayespi(ob.fPBayespi),
45 fPPriorip(ob.fPPriorip),
46 fPPriorik(ob.fPPriorik),
47 fPPrioripi(ob.fPPrioripi),
48 fPPriorie(ob.fPPriorie)
53 //______________________________________________________________________
54 AliITSPident& AliITSPident::operator=(const AliITSPident& ob){
55 // Assignment operator
56 this->~AliITSPident();
57 new(this) AliITSPident(ob);
62 //_______________________________________________________________________
63 AliITSPident::AliITSPident(Double_t mom,Double_t dEdx,AliITSSteerPid *sp,Float_t *Qlay,Float_t *nlay,Float_t priorip,Float_t priorik,Float_t prioripi,Float_t priorie):
75 for (Int_t i=0;i<8;i++){
80 for(Int_t la=0;la<4;la++){//loop on layers
81 Double_t parp[3];Double_t park[3];Double_t parpi[3];
90 range[4]=0.3*parpi[1];
93 for(Int_t ii=0;ii<8;ii++){
97 sp->GetParFitLayer(la,fMom,parp,park,parpi);
98 CookFunItsLay(ii,0,parp,Qlay[ii],fMom,range[0],range[1],"fPro");
99 CookFunItsLay(ii,1,park,Qlay[ii],fMom,range[2],range[3],"fKao");
100 CookFunItsLay(ii,2,parpi,Qlay[ii],fMom,range[4],range[5],"fPi");
107 Float_t prior[4];Double_t condFun[8][3];
113 for(Int_t la=0;la<8;la++){
114 condFun[la][0]= fCondFunProLay[la];
115 condFun[la][1]= fCondFunKLay[la];
116 condFun[la][2]= fCondFunPiLay[la];
120 fPBayesp=CookCombinedBayes(condFun,prior,0);
121 fPBayesk=CookCombinedBayes(condFun,prior,1);
122 fPBayespi=CookCombinedBayes(condFun,prior,2);
125 //__________________________________________________________________________________________
126 AliITSPident::AliITSPident(AliITStrackV2 *trackITS,AliITSSteerPid *sp,Float_t *Qlay,Float_t *nlay,Float_t priorip,Float_t priorik,Float_t prioripi,Float_t priorie):
134 fPPrioripi(prioripi),
138 for (Int_t i=0;i<8;i++){
139 fCondFunProLay[i]=-1;
145 trackITS->GetExternalParameters(xr,par);
147 Float_t lamb=TMath::ATan(par[3]);
148 fMom=1/(TMath::Abs(par[4])*TMath::Cos(lamb));
152 for(Int_t la=0;la<4;la++){//loop on layers
153 Double_t parp[3];Double_t park[3];Double_t parpi[3];
156 range[0]=0.3*parp[1];
159 range[2]=0.3*park[1];
162 range[4]=0.3*parpi[1];
163 range[5]=2.*parpi[1];
166 for(Int_t ii=0;ii<8;ii++){
170 sp->GetParFitLayer(la,fMom,parp,park,parpi);
171 CookFunItsLay(ii,0,parp,Qlay[ii],fMom,range[0],range[1],"fPro");
172 CookFunItsLay(ii,1,park,Qlay[ii],fMom,range[2],range[3],"fKao");
173 CookFunItsLay(ii,2,parpi,Qlay[ii],fMom,range[4],range[5],"fPi");
180 Float_t prior[4];Double_t condFun[8][3];
186 for(Int_t la=0;la<8;la++){
187 condFun[la][0]= fCondFunProLay[la];
188 condFun[la][1]= fCondFunKLay[la];
189 condFun[la][2]= fCondFunPiLay[la];
193 fPBayesp=CookCombinedBayes(condFun,prior,0);
194 fPBayesk=CookCombinedBayes(condFun,prior,1);
195 fPBayespi=CookCombinedBayes(condFun,prior,2);
196 fdEdx=trackITS->GetdEdx();
199 //_______________________________________________________________________
200 void AliITSPident::GetNclsPerLayer(Int_t *ncls) const{
201 //number of clusters for each layer (sdd1,sdd2,ssd1,ssd2)
202 for(Int_t la=0;la<4;la++){
206 }//_______________________________________________________________________
207 Double_t AliITSPident::GetProdCondFunPro() const {
208 //Product of conditional probability functions for protons
210 for(Int_t i=0;i<8;i++){
211 Double_t fun=GetCondFunPro(i);
215 }//_______________________________________________________________________
216 Double_t AliITSPident::GetProdCondFunK() const {
217 //Product of conditional probability functions for kaons
219 for(Int_t i=0;i<8;i++){
220 Double_t fun=GetCondFunK(i);
225 //_______________________________________________________________________
226 Double_t AliITSPident::GetProdCondFunPi() const {
227 //Product of conditional probability functions for pions
229 for(Int_t i=0;i<8;i++){
230 Double_t fun=GetCondFunPi(i);
235 //_______________________________________________________________________
236 void AliITSPident::PrintParameters() const{
238 cout<<"___________________________\n";
239 cout<<"Track Local Momentum = "<<" "<<fMom<<endl;
240 cout<<"Track dEdx = "<<" "<<fdEdx<<endl;
243 //_______________________________________________________________________
244 Double_t AliITSPident::Langaufun(Double_t *x, Double_t *par) {
247 //par[0]=Width (scale) parameter of Landau density
248 //par[1]=Most Probable (MP, location) parameter of Landau density
249 //par[2]=Total area (integral -inf to inf, normalization constant)
250 //par[3]=Width (sigma) of convoluted Gaussian function
252 //In the Landau distribution (represented by the CERNLIB approximation),
253 //the maximum is located at x=-0.22278298 with the location parameter=0.
254 //This shift is corrected within this function, so that the actual
255 //maximum is identical to the MP parameter.
258 Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
259 Double_t mpshift = -0.22278298; // Landau maximum location
262 Double_t np = 100.0; // number of convolution steps
263 Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
275 // MP shift correction
276 mpc = par[1] - mpshift * par[0];
278 // Range of convolution integral
279 xlow = x[0] - sc * par[3];
280 xupp = x[0] + sc * par[3];
282 step = (xupp-xlow) / np;
284 // Convolution integral of Landau and Gaussian by sum
285 for(i=1.0; i<=np/2; i++) {
286 xx = xlow + (i-.5) * step;
287 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
288 sum += fland * TMath::Gaus(x[0],xx,par[3]);
290 xx = xupp - (i-.5) * step;
291 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
292 sum += fland * TMath::Gaus(x[0],xx,par[3]);
295 return (par[2] * step * sum * invsq2pi / par[3]);
298 //_______________________________________________________________________
299 Double_t AliITSPident::Langaufun2(Double_t *x, Double_t *par){
300 //normalized langaufun
301 return 1/par[4]*Langaufun(x,par);
303 //_______________________________________________________________________
304 Double_t AliITSPident::Langaufunnorm(Double_t *x, Double_t *par){
306 //par[0]=Width (scale) parameter of Landau density
307 //par[1]=Most Probable (MP, location) parameter of Landau density
309 //par[2]=Width (sigma) of convoluted Gaussian function
311 //In the Landau distribution (represented by the CERNLIB approximation),
312 //the maximum is located at x=-0.22278298 with the location parameter=0.
313 //This shift is corrected within this function, so that the actual
314 //maximum is identical to the MP parameter.
317 Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
318 Double_t mpshift = -0.22278298; // Landau maximum location
321 Double_t np = 100.0; // number of convolution steps
322 Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
334 // MP shift correction
335 mpc = par[1] - mpshift * par[0];
337 // Range of convolution integral
338 xlow = x[0] - sc * par[2];
339 xupp = x[0] + sc * par[2];
341 step = (xupp-xlow) / np;
343 // Convolution integral of Landau and Gaussian by sum
344 for(i=1.0; i<=np/2; i++) {
345 xx = xlow + (i-.5) * step;
346 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
347 sum += fland * TMath::Gaus(x[0],xx,par[2]);
349 xx = xupp - (i-.5) * step;
350 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
351 sum += fland * TMath::Gaus(x[0],xx,par[2]);
354 return (step * sum * invsq2pi / par[2]);
356 //_______________________________________________________________________
357 Double_t AliITSPident::Gaus2(Double_t *x, Double_t *par){
358 //normalized gaussian function
359 return 1/(sqrt(2*TMath::Pi())*par[1])*TMath::Gaus(x[0],par[0],par[1]);
361 //_______________________________________________________________________
362 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){
363 //it gives the response functions
364 TF1 funLay(comment,Langaufunnorm,rangei,rangef,3);
365 funLay.SetParameters(par);
366 Double_t condFun=funLay.Eval(dedx);
368 fCondFunProLay[lay]=condFun;
369 if(mom<0.4 && dedx<100)fCondFunProLay[lay]=0.00001;
370 if(mom<0.4 &&dedx<50)fCondFunProLay[lay]=0.0000001;
373 fCondFunKLay[lay]=condFun;
374 if(mom<0.25 && dedx<100)fCondFunKLay[lay]=0.00001;
375 if(mom<0.4 &&dedx<30)fCondFunKLay[lay]=0.0000001;
378 fCondFunPiLay[lay]=condFun;
379 if(mom<0.6 &&dedx<20)fCondFunPiLay[lay]=0.001;
383 //_______________________________________________________________________
384 Float_t AliITSPident::CookCombinedBayes(Double_t condfun[][3],Float_t *prior,Int_t part)const {
385 //Bayesian combined PID in the ITS
388 Float_t pprior[4]={0,0,0,0};
389 for(Int_t j=0;j<4;j++)pprior[j]=prior[j];
390 pprior[2]+=pprior[3];//prior for electrons summed to priors for pions
391 for(Int_t i=0;i<8;i++){//layer
392 if (condfun[i][0]>0 || condfun[i][1]>0 ||condfun[i][2]>0) test++;
395 if ((pprior[0]!=0 || pprior[1]!=0 ||pprior[2]!=0)&&CookSum(condfun,pprior)!=0){
397 bayes=pprior[part]*CookProd(condfun,part)*1/CookSum(condfun,pprior);
405 //_______________________________________________________________________
406 Float_t AliITSPident::CookProd(Double_t condfun[][3],Int_t part)const{
409 for(Int_t lay=0;lay<8;lay++){
410 if(condfun[lay][part]>=0)p=p*condfun[lay][part];
415 //_______________________________________________________________________
416 Float_t AliITSPident::CookSum(Double_t condfun[][3],Float_t *prior)const{
419 Float_t pprior[4]={0,0,0,0};
420 for(Int_t j=0;j<4;j++)pprior[j]=prior[j];
421 pprior[2]+=pprior[3];//prior for electrons summed to priors for pions
422 for(Int_t i=0;i<3;i++){//sum over the particles--electrons excluded
423 sum+=pprior[i]*CookProd(condfun,i);