1 //------------------------------------------------------------//
2 // Class for identification of pions,kaons and protons in ITS //
3 // Prior particles population (probabilities) are taken from //
4 // Hijing event generator. //
5 //------------------------------------------------------------//
10 #include <TClonesArray.h>
12 #include "AliKalmanTrack.h"
13 #include "AliITSIOTrack.h"
14 #include "AliITStrackV2.h"
20 AliITSPid::AliITSPid(const AliITSPid &source) : TObject(source),
21 fMxtrs(source.fMxtrs),
30 fPcode(source.fPcode),
31 fSigmin(source.fSigmin),
32 fSilent(source.fSilent),
33 fCutKa(source.fCutKa),
34 fCutPr(source.fCutPr),
38 // Copy constructor. This is a function which is not allowed to be
43 //______________________________________________________________________
44 AliITSPid& AliITSPid::operator=(const AliITSPid& source){
45 // Assignment operator. This is a function which is not allowed to be
47 new(this) AliITSPid(source);
52 Float_t AliITSPid::Qtrm(Int_t track) {
54 // This calculates truncated mean signal for given track.
56 TVector q(*( this->GetVec(track) ));
61 Int_t nl=0; for(Int_t i=0;i<ml;i++){if(q(i)>fSigmin){vf[nl]=q(i+1);nl++;}}
64 case 1:q(6)=q(1); break;
65 case 2:q(6)=(q(1)+q(2))/2.; break;
67 for(int fi=0;fi<2;fi++){
69 do{ swap=0; float qmin=vf[fi];
70 for(int j=fi+1;j<nl;j++)
71 if(qmin>vf[j]){qmin=vf[j];vf[j]=vf[fi];vf[fi]=qmin;swap=1;};
74 q(6)= (vf[0]+vf[1])/2.;
77 for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
81 Float_t AliITSPid::Qtrm(Float_t qarr[6],Int_t narr) const{
83 //This calculates truncated mean signal for given signal set.
87 if(narr>0&&narr<7){ml=narr;}else{return 0;};
88 nl=0; for(Int_t i=0;i<ml;i++){if(qarr[i]>fSigmin){q[nl]=qarr[i];nl++;}}
91 case 1:qm=q[0]; break;
92 case 2:qm=(q[0]+q[1])/2.; break;
95 for(int fi=0;fi<2;fi++){
96 do{ swap=0; qmin=q[fi];
97 for(int j=fi+1;j<nl;j++)
98 if(qmin>q[j]){qmin=q[j];q[j]=q[fi];q[fi]=qmin;swap=1;};
107 Int_t AliITSPid::Wpik(Float_t pm,Float_t q){
108 //Calcutates probabilityes of pions and kaons
109 //Returns particle code for dominant probability.
111 for(int i=0;i<6;i++){par[i]=fGGpi[i]->Eval(pm);}
112 fggpi->SetParameters(par);
114 for(int i=0;i<3;i++){par[i]=fGGka[i]->Eval(pm);}
115 fggka->SetParameters(par);
117 Float_t ppi=fggpi->Eval(q);
118 Float_t pka=fggka->Eval(q);
124 if(p>0)cout<<" ppi,pka="<<ppi/p<<" "<<pka/p<<endl;
131 fWp=0.; fWpi=ppi; fWk=pka;
132 if( pka>ppi){return fPcode=321;}else{return fPcode=211;}
135 //-----------------------------------------------------------
136 Int_t AliITSPid::Wpikp(Float_t pm,Float_t q){
138 //Calcutates probabilityes of pions,kaons and protons.
139 //Returns particle code for dominant probability.
141 for(int i=0;i<6;i++){par[i]=fGGpi[i]->Eval(pm);}
142 fggpi->SetParameters(par);
144 for(int i=0;i<3;i++){par[i]=fGGka[i]->Eval(pm);}
145 fggka->SetParameters(par);
147 for(int i=0;i<3;i++){par[i]=fGGpr[i]->Eval(pm);}
148 fggpr->SetParameters(par);
150 Float_t p,ppi,pka,ppr;
151 if( q>(fggpr->GetParameter(1)+fggpr->GetParameter(2)) )
152 { p=1.0; ppr=1.0; ppi=pka=0.0;
163 fWp=ppr; fWpi=ppi; fWk=pka;
164 //if(!fSilent)cout<<" ppi,pka,ppr="<<ppi<<" "<<pka<<" "<<ppr<<endl;
166 if( ppi>pka&&ppi>ppr )
168 else{ if(pka>ppr){return fPcode=321;}else{return fPcode=2212;}
173 //-----------------------------------------------------------
174 Int_t AliITSPid::GetPcode(TClonesArray* rps,Float_t pm)
176 //Returns particle code
177 Info("GetPcode","method not implemented - Inputs TClonesArray *%x , Float_t %f",rps,pm);
180 //-----------------------------------------------------------
181 Int_t AliITSPid::GetPcode(AliKalmanTrack *track)
183 //Returns particle code for given track.
184 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
185 Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
186 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
187 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
188 Float_t lam=TMath::ATan(par[3]);
189 Float_t pt1=TMath::Abs(par[4]);
190 Float_t mom=1./(pt1*TMath::Cos(lam));
191 Float_t dedx=track->GetPIDsignal();
192 Int_t pcode=GetPcode(dedx/40.,mom);
193 // cout<<"TPCtrack dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
194 return pcode?pcode:211;
196 //------------------------------------------------------------
197 Int_t AliITSPid::GetPcode(AliITSIOTrack *track)
199 //Returns particle code for given track(V1).
204 Float_t mom=TMath::Sqrt(px*px+py*py+pz*pz);
205 //???????????????????
207 Float_t dedx=track->GetdEdx();
208 //???????????????????
209 Int_t pcode=GetPcode(dedx,mom);
210 // cout<<"ITSV1 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
211 return pcode?pcode:211;
213 //-----------------------------------------------------------
214 Int_t AliITSPid::GetPcode(AliITStrackV2 *track)
216 //Returns particle code for given track(V2).
217 if(track==0)return 0;
218 // track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
219 track->PropagateTo(3.,0.0028,65.19);
220 //track->PropagateToVertex(); Not needed. (I.B.)
221 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
222 Float_t lam=TMath::ATan(par[3]);
223 Float_t pt1=TMath::Abs(par[4]);
225 if( (pt1*TMath::Cos(lam))!=0. ){ mom=1./(pt1*TMath::Cos(lam)); }else{mom=0.;};
226 Float_t dedx=track->GetdEdx();
227 // cout<<"lam,pt1,mom,dedx="<<lam<<","<<pt1<<","<<mom<<","<<dedx<<endl;
228 Int_t pcode=GetPcode(dedx,mom);
229 // cout<<"ITS V2 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
230 return pcode?pcode:211;
232 //-----------------------------------------------------------
233 Int_t AliITSPid::GetPcode(Float_t q,Float_t pm)
235 //Returns particle code for given signal and momentum.
236 fWpi=fWk=fWp=0.; fPcode=0;
239 { if( q<fCutKa->Eval(pm) )
241 else{ if( q<fCutPr->Eval(pm) )
243 else{return Proton();}
247 if ( q>fCutPr->Eval(pm) ){
254 if( pm<=1.10 ){ return Wpikp(pm,q); }
257 //-----------------------------------------------------------
258 void AliITSPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
259 Float_t klo,Float_t khi,Float_t plo,Float_t phi)
261 // The cut-table initializer method.
271 //------------------------------------------------------------
272 void AliITSPid::SetVec(Int_t ntrack,const TVector& info) const
274 //Store track info in tracls table
275 TClonesArray& arr=*fTrs;
276 new( arr[ntrack] ) TVector(info);
278 //-----------------------------------------------------------
279 TVector* AliITSPid::GetVec(Int_t ntrack) const
281 //Get given track from track table
282 TClonesArray& arr=*fTrs;
283 return (TVector*)arr[ntrack];
285 //-----------------------------------------------------------
286 void AliITSPid::SetEdep(Int_t track,Float_t Edep)
288 //Set dEdx for given track
290 if( ((TVector*)fTrs->At(track))->IsValid() )
291 {TVector yy( *((TVector*)fTrs->At(track)) );xx=yy; }
292 Int_t j=(Int_t)xx(0); if(j>4)return;
293 xx(++j)=Edep;xx(0)=j;
294 TClonesArray &arr=*fTrs;
295 new(arr[track])TVector(xx);
297 //-----------------------------------------------------------
298 void AliITSPid::SetPmom(Int_t track,Float_t Pmom)
300 //Set momentum for given track
302 if( ((TVector*)fTrs->At(track))->IsValid() )
303 {TVector yy( *((TVector*)fTrs->At(track)) );xx=yy; }
305 TClonesArray &arr=*fTrs;
306 new(arr[track])TVector(xx);
308 //-----------------------------------------------------------
309 void AliITSPid::SetPcod(Int_t track,Int_t partcode)
311 //Set particle code for given track
313 if( ((TVector*)fTrs->At(track))->IsValid() )
314 {TVector yy( *((TVector*)fTrs->At(track)) );xx=yy; }
316 {xx(11)=partcode; fMxtrs++;
317 TClonesArray &arr=*fTrs;
318 new(arr[track])TVector(xx);
321 //-----------------------------------------------------------
322 void AliITSPid::Print(Int_t track)
324 //Prints information for given track
325 cout<<fMxtrs<<" tracks in AliITSPid obj."<<endl;
326 if( ((TVector*)fTrs->At(track))->IsValid() )
327 {TVector xx( *((TVector*)fTrs->At(track)) );
331 {cout<<"No data for track "<<track<<endl;return;}
333 //-----------------------------------------------------------
334 void AliITSPid::Tab(void)
336 //Make PID for tracks stored in tracks table
337 if(fTrs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
338 cout<<"------------------------------------------------------------------------"<<endl;
339 cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
340 " Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
341 cout<<"------------------------------------------------------------------------"<<endl;
342 for(Int_t i=0;i<fTrs->GetEntries();i++)
344 TVector xxx( *((TVector*)fTrs->At(i)) );
345 if( xxx.IsValid() && xxx(0)>0 )
347 TVector xx( *((TVector*)fTrs->At(i)) );
351 xx(6)=(this->Qtrm(i));
356 // 2)Calculate Wpi,Wk,Wp
357 this->GetPcode(xx(6),xx(10)/1000.);
364 for(Int_t j=1;j<11;j++){
365 if(i<7){ cout.width(7);cout.precision(4);cout<<xx(j);}
366 if(i>7){ cout.width(7);cout.precision(5);cout<<xx(j);}
370 // 4)Update data in TVector
371 TClonesArray &arr=*fTrs;
372 new(arr[i])TVector(xx);
375 {/*cout<<"No data for track "<<i<<endl;*/}
376 }// End loop for tracks
378 void AliITSPid::Reset(void)
381 for(Int_t i=0;i<fTrs->GetEntries();i++){
383 TClonesArray &arr=*fTrs;
384 new(arr[i])TVector(xx);
387 //-----------------------------------------------------------
388 AliITSPid::AliITSPid(Int_t ntrack):
406 //Constructor for AliITSPid class
408 fTrs = new TClonesArray("TVector",ntrack);
409 TClonesArray &arr=*fTrs;
410 for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
412 fCutKa=new TF1("fcutka","pol4",0.05,0.4);
413 Double_t ka[5]={25.616, -161.59, 408.97, -462.17, 192.86};
414 fCutKa->SetParameters(ka);
416 fCutPr=new TF1("fcutpr","[0]/x/x+[1]",0.05,1.1);
417 Double_t pr[2]={0.70675,0.4455};
418 fCutPr->SetParameters(pr);
420 //---------- signal fit ----------
422 fGGpi[0]=new TF1("fp1pi","pol4",0.34,1.2);
423 Double_t parpi0[10]={ -1.9096471071e+03, 4.5354331545e+04, -1.1860738840e+05,
424 1.1405329025e+05, -3.8289694496e+04 };
425 fGGpi[0]->SetParameters(parpi0);
426 fGGpi[1]=new TF1("fp2pi","[0]/x/x+[1]",0.34,1.2);
427 Double_t parpi1[10]={ 1.0791668283e-02, 9.7347716496e-01 };
428 fGGpi[1]->SetParameters(parpi1);
429 fGGpi[2]=new TF1("fp3pi","[0]/x/x+[1]",0.34,1.2);
430 Double_t parpi2[10]={ 5.8191602279e-04, 9.7285601334e-02 };
431 fGGpi[2]->SetParameters(parpi2);
432 fGGpi[3]=new TF1("fp4pi","pol4",0.34,1.2);
433 Double_t parpi3[10]={ 6.6267353195e+02, 7.1595101104e+02, -5.3095111914e+03,
434 6.2900977606e+03, -2.2935862292e+03 };
435 fGGpi[3]->SetParameters(parpi3);
436 fGGpi[4]=new TF1("fp5pi","[0]/x/x+[1]",0.34,1.2);
437 Double_t parpi4[10]={ 9.0419011783e-03, 1.1628922525e+00 };
438 fGGpi[4]->SetParameters(parpi4);
439 fGGpi[5]=new TF1("fp6pi","[0]/x/x+[1]",0.34,1.2);
440 Double_t parpi5[10]={ 1.8324872519e-03, 2.1503968838e-01 };
441 fGGpi[5]->SetParameters(parpi5);
444 fGGka[0]=new TF1("fp1ka","pol4",0.24,1.2);
445 Double_t parka0[20]={
446 -1.1204243395e+02,4.6716191428e+01,2.2584059281e+03,
447 -3.7123338009e+03,1.6003647641e+03 };
448 fGGka[0]->SetParameters(parka0);
449 fGGka[1]=new TF1("fp2ka","[0]/x/x+[1]",0.24,1.2);
450 Double_t parka1[20]={
451 2.5181172905e-01,8.7566001814e-01 };
452 fGGka[1]->SetParameters(parka1);
453 fGGka[2]=new TF1("fp3ka","pol6",0.24,1.2);
454 Double_t parka2[20]={
455 8.6236021573e+00,-7.0970427531e+01,2.4846827669e+02,
456 -4.6094401290e+02,4.7546751408e+02,-2.5807112462e+02,
458 fGGka[2]->SetParameters(parka2);
461 fGGpr[0]=new TF1("fp1pr","pol4",0.4,1.2);
462 Double_t parpr0[10]={
463 6.0150106543e+01,-8.8176206410e+02,3.1222644604e+03,
464 -3.5269200901e+03,1.2859128345e+03 };
465 fGGpr[0]->SetParameters(parpr0);
466 fGGpr[1]=new TF1("fp2pr","[0]/x/x+[1]",0.4,1.2);
467 Double_t parpr1[10]={
468 9.4970837607e-01,7.3573504201e-01 };
469 fGGpr[1]->SetParameters(parpr1);
470 fGGpr[2]=new TF1("fp3pr","[0]/x/x+[1]",0.4,1.2);
471 Double_t parpr2[10]={
472 1.2498403757e-01,2.7845072306e-02 };
473 fGGpr[2]->SetParameters(parpr2);
475 //----------- end fit -----------
477 fggpr=new TF1("ggpr","gaus",0.4,1.2);
478 fggpi=new TF1("ggpi","gaus+gaus(3)",0.4,1.2);
479 fggka=new TF1("ggka","gaus",0.4,1.2);
481 //-------------------------------------------------
483 // Ncut Pmom pilo pihi klo khi plo phi
484 // cut[j] [0] [1] [2] [3] [4] [5] [6]
485 //----------------------------------------------------------------
486 SetCut( 1, 0.12 , 0. , 0. , kInf , kInf , kInf , kInf );
487 SetCut( 2, 0.20 , 0. , 6.0 , 6.0 , kInf , kInf , kInf );
488 SetCut( 3, 0.30 , 0. , 3.5 , 3.5 , 9.0 , 9.0 , kInf );
489 SetCut( 4, 0.41 , 0. , 1.9 , 1.9 , 4.0 , 4.0 , kInf );
490 //----------------------------------------------------------------
491 SetCut( 5, 0.47 , 0.935, 0.139, 1.738 , 0.498 , 3.5 , kInf ); //410-470
492 SetCut( 6, 0.53 , 0.914, 0.136, 1.493 , 0.436 , 3.0 , kInf ); //470-530
493 //----------------------------------------------------------------
494 SetCut( 7, 0.59 , 0.895, 0.131, 1.384 , 0.290 , 2.7 , kInf ); //530-590
495 SetCut( 8, 0.65 , 0.887, 0.121, 1.167 , 0.287 , 2.5 , kInf ); //590-650
496 SetCut( 9, 0.73 , 0.879, 0.120, 1.153 , 0.257 , 2.0 , kInf ); //650-730
497 //----------------------------------------------------------------
498 SetCut( 10, 0.83 , 0.880, 0.126, 1.164 , 0.204 , 2.308 , 0.297 ); //730-830
499 SetCut( 11, 0.93 , 0.918, 0.145, 1.164 , 0.204 , 2.00 , 0.168 ); //830-930
500 SetCut( 12, 1.03 , 0.899, 0.128, 1.164 , 0.204 ,1.80 , 0.168);
501 //------------------------ pi,K ---------------------
502 fAprob[0][0]=1212; fAprob[1][0]=33.; // fAprob[0][i] - const for pions,cut[i+5]
503 fAprob[0][1]=1022; fAprob[1][1]=46.2 ; // fAprob[1][i] - kaons
504 //---------------------------------------------------
505 fAprob[0][2]= 889.7; fAprob[1][2]=66.58; fAprob[2][2]=14.53;
506 fAprob[0][3]= 686.; fAprob[1][3]=88.8; fAprob[2][3]=19.27;
507 fAprob[0][4]= 697.; fAprob[1][4]=125.6; fAprob[2][4]=28.67;
508 //------------------------ pi,K,p -------------------
509 fAprob[0][5]= 633.7; fAprob[1][5]=100.1; fAprob[2][5]=37.99; // fAprob[2][i] - protons
510 fAprob[0][6]= 469.5; fAprob[1][6]=20.74; fAprob[2][6]=25.43;
511 fAprob[0][7]= 355.; fAprob[1][7]=
512 355.*(20.74/469.5); fAprob[2][7]=34.08;