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 **************************************************************************/
20 #include "AliTPCPid.h"
22 //#include "AliITSIOTrack.h"
23 #include "Riostream.h"
25 // Correction 13.01.2003 Z.S.,Dubna
27 //------------------------------------------------------------
28 Float_t AliTPCPid::qcorr(Float_t xc)
32 fcorr=( 0.766 +0.9692*xc -1.267*xc*xc )*( 1.-TMath::Exp(-xc*64.75) );
33 if(fcorr<=0.1)fcorr=0.1;
36 //-----------------------------------------------------------
37 Float_t AliTPCPid::qtrm(Int_t track)
39 TVector q(*( this->GetVec(track) ));
44 Int_t nl=0; for(Int_t i=0;i<ml;i++){if(q(i)>fSigmin){vf[nl]=q(i+1);nl++;}}
47 case 1:q(6)=q(1); break;
48 case 2:q(6)=(q(1)+q(2))/2.; break;
50 for(int fi=0;fi<2;fi++){
52 do{ swap=0; float qmin=vf[fi];
53 for(int j=fi+1;j<nl;j++)
54 if(qmin>vf[j]){qmin=vf[j];vf[j]=vf[fi];vf[fi]=qmin;swap=1;};
57 q(6)= (vf[0]+vf[1])/2.;
60 for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
62 }// --- End AliTPCPid::qtrm ---
64 Float_t AliTPCPid::qtrm(Float_t qarr[6],Int_t narr)
69 if(narr>0&&narr<7){ml=narr;}else{return 0;};
70 nl=0; for(Int_t i=0;i<ml;i++){if(qarr[i]>fSigmin){q[nl]=qarr[i];nl++;}}
73 case 1:qm=q[0]; break;
74 case 2:qm=(q[0]+q[1])/2.; break;
77 for(int fi=0;fi<2;fi++){
78 do{ swap=0; qmin=q[fi];
79 for(int j=fi+1;j<nl;j++)
80 if(qmin>q[j]){qmin=q[j];q[j]=q[fi];q[fi]=qmin;swap=1;};
87 }// --- End AliTPCPid::qtrm ---
89 Int_t AliTPCPid::wpik(Int_t nc,Float_t q)
91 Float_t qmpi,qmk,sigpi,sigk,dpi,dk,ppi,pk;
97 appi = aprob[0][nc-5];
100 cout<<"qmpi,sigpi,qmk,sigk="<<qmpi<<" "<<sigpi<<" "<<qmk<<" "<<sigk<<endl;
101 cout<<"appi,apk="<<appi<<","<<apk<<endl;
103 Float_t dqpi=(q-qmpi)/sigpi;
104 Float_t dqk =(q-qmk )/sigk;
107 Double_t dn=appi*TMath::Gaus(q,qmpi,sigpi)+apk*TMath::Gaus(q,qmk,sigk);
109 ppi=appi*TMath::Gaus(q,qmpi,sigpi)/dn;
110 pk = apk*TMath::Gaus(q,qmk, sigk )/dn;
111 }else{fWpi=1;return pion();}
112 Float_t rpik=ppi/(pk+0.0000001);
114 cout<<"q,dqpi,dqk, wpik: ppi,pk,rpik="
115 <<q<<" "<<dqpi<<" "<<dqk<<" "<<ppi<<" "<<pk<<" "<<rpik<<endl;
117 fWp=0.; fWpi=ppi; fWk=pk;
118 if( pk>ppi){return kaon();}else{return pion();}
120 //-----------------------------------------------------------
122 Int_t AliTPCPid::wpikp(Int_t nc,Float_t q)
124 Float_t qmpi,qmk,qmp,sigpi,sigk,sigp,ppi,pk,pp;
125 Float_t appi,apk,app;
134 //appi = apk = app = 1.;
135 appi = aprob[0][nc-5];
136 apk = aprob[1][nc-5];
137 app = aprob[2][nc-5];
139 Double_t dn= appi*TMath::Gaus(q,qmpi,sigpi)
140 +apk*TMath::Gaus(q,qmk,sigk)+app*TMath::Gaus(q,qmp,sigp);
142 ppi=appi*TMath::Gaus(q,qmpi,sigpi)/dn;
143 pk = apk*TMath::Gaus(q,qmk, sigk )/dn;
144 pp = app*TMath::Gaus(q,qmp, sigp )/dn;
146 else{fWpi=1;return pion();}
147 fWp=pp; fWpi=ppi; fWk=pk;
149 cout<<" wpikp: mid,sig pi,k,p="<<qmpi<<" "<<sigpi<<"; "<<qmk<<" "<<sigk<<"; "
150 <<qmp<<" "<<sigp<<"; "<<endl;
151 cout<<" aprob: "<<appi<<" "<<apk<<" "<<app<<endl;
152 cout<<" ppi,pk,pp="<<ppi<<" "<<pk<<" "<<pp<<endl;
154 if( ppi>pk&&ppi>pp ) { return pion(); }
155 if(pk>pp){return kaon();}else{return proton();}
157 //-----------------------------------------------------------
158 Int_t AliTPCPid::GetPcode(TClonesArray* rps,Float_t pm)
162 //-----------------------------------------------------------
163 Int_t AliTPCPid::GetPcode(AliTPCtrack *track)
165 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
166 Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
167 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
168 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
169 Float_t lam=TMath::ATan(par[3]);
170 Float_t pt_1=TMath::Abs(par[4]);
171 Float_t mom=1./(pt_1*TMath::Cos(lam));
172 Float_t dedx=track->GetdEdx();
173 Int_t pcode=GetPcode(dedx/40.,mom);
174 cout<<"TPCtrack dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
175 return pcode?pcode:211;
177 //-----------------------------------------------------------
178 Int_t AliTPCPid::GetPcode(AliITStrackV2 *track)
180 if(track==0)return 0;
181 // track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
182 track->PropagateTo(3.,0.0028,65.19);
183 track->PropagateToVertex();
184 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
185 Float_t lam=TMath::ATan(par[3]);
186 Float_t pt_1=TMath::Abs(par[4]);
188 if( (pt_1*TMath::Cos(lam))!=0. ){ mom=1./(pt_1*TMath::Cos(lam)); }else{mom=0.;};
189 Float_t dedx=track->GetdEdx();
190 cout<<"lam,pt_1,mom,dedx="<<lam<<","<<pt_1<<","<<mom<<","<<dedx<<endl;
191 Int_t pcode=GetPcode(dedx,mom);
192 cout<<"ITS V2 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
193 return pcode?pcode:211;
195 //-----------------------------------------------------------
196 Int_t AliTPCPid::GetPcode(Float_t q,Float_t pm)
198 fWpi=fWk=fWp=0.; fPcode=0;
199 //1)---------------------- 0-120 MeV/c --------------
201 { fWpi=1.; return pion(); }
202 //2)----------------------120-200 Mev/c ( 29.7.2002 ) -------------
204 { if( q<fCutKa->Eval(pm) ){fWpi=1.; return pion(); }
205 else {fWk =1.; return kaon();} }
206 //3)----------------------200-400 Mev/c -------------
208 if( q<fCutKa->Eval(pm) )
209 { fWpi=1.;return pion(); }
211 { if ( q<=fCutPr->Eval(pm) )
212 {fWk=1.;return kaon();}
213 else {fWp=1.;return proton();}
215 //4)----------------------400-450 Mev/c -------------
217 if( q<fCutKaTune*fCutKa->Eval(pm) )
218 { fWpi=1.;return pion(); }
220 { if( q<fCutPr->Eval(pm) )
221 {fWk=1.;return kaon();} else {fWp=1.;return proton(); }
223 //5)----------------------450-500 Mev/c -------------
225 if ( q>fCutPr->Eval(pm) )
226 {fWp=1.;return proton();} else {return wpik(5,q);};
227 //6)----------------------500-550 Mev/c -------------
229 if ( q>fCutPr->Eval(pm) )
230 {fWp=1.;return proton();} else {return wpik(6,q);};
231 //7)----------------------550-600 Mev/c -------------
233 if ( q>fCutPr->Eval(pm) )
234 {fWp=1.;return proton();} else {return wpik(7,q);};
235 //8)----------------------600-650 Mev/c -------------
237 if ( q>fCutPrTune*fCutPr->Eval(pm) ){fWp=1.;return proton();}
238 else {return wpik(8,q);};
239 //9)----------------------650-730 Mev/c -------------
241 if ( q>fCutPrTune*fCutPr->Eval(pm) ){fWp=1.;return proton();}
242 else {return wpik(9,q);};
243 //10)----------------------730-830 Mev/c -------------
245 if ( q>fCutPrTune*fCutPr->Eval(pm) ){fWp=1.;return proton();}
246 else {return wpik(10,q);};
247 //11)----------------------830-930 Mev/c -------------
248 if( pm<=cut[11][0] ){ return wpikp(11,q); }
249 //12)----------------------930-1030 Mev/c -------------
251 { return wpikp(12,q); };
255 //-----------------------------------------------------------
256 void AliTPCPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
257 Float_t klo,Float_t khi,Float_t plo,Float_t phi)
268 //------------------------------------------------------------
269 void AliTPCPid::SetVec(Int_t ntrack,TVector info)
271 TClonesArray& arr=*trs;
272 new( arr[ntrack] ) TVector(info);
274 //-----------------------------------------------------------
275 TVector* AliTPCPid::GetVec(Int_t ntrack)
277 TClonesArray& arr=*trs;
278 return (TVector*)arr[ntrack];
280 //-----------------------------------------------------------
281 void AliTPCPid::SetEdep(Int_t track,Float_t Edep)
284 if( ((TVector*)trs->At(track))->IsValid() )
285 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
286 Int_t j=(Int_t)xx(0); if(j>4)return;
287 xx(++j)=Edep;xx(0)=j;
288 TClonesArray &arr=*trs;
289 new(arr[track])TVector(xx);
291 //-----------------------------------------------------------
292 void AliTPCPid::SetPmom(Int_t track,Float_t Pmom)
295 if( ((TVector*)trs->At(track))->IsValid() )
296 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
298 TClonesArray &arr=*trs;
299 new(arr[track])TVector(xx);
301 //-----------------------------------------------------------
302 void AliTPCPid::SetPcod(Int_t track,Int_t partcode)
305 if( ((TVector*)trs->At(track))->IsValid() )
306 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
308 {xx(11)=partcode; mxtrs++;
309 TClonesArray &arr=*trs;
310 new(arr[track])TVector(xx);
313 //-----------------------------------------------------------
314 void AliTPCPid::Print(Int_t track)
315 {cout<<mxtrs<<" tracks in AliITSPid obj."<<endl;
316 if( ((TVector*)trs->At(track))->IsValid() )
317 {TVector xx( *((TVector*)trs->At(track)) );
321 {cout<<"No data for track "<<track<<endl;return;}
323 //-----------------------------------------------------------
324 void AliTPCPid::Tab(void)
326 if(trs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
327 cout<<"------------------------------------------------------------------------"<<endl;
328 cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
329 " Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
330 cout<<"------------------------------------------------------------------------"<<endl;
331 for(Int_t i=0;i<trs->GetEntries();i++)
333 TVector xx( *((TVector*)trs->At(i)) );
334 if( xx.IsValid() && xx(0)>0 )
336 TVector xx( *((TVector*)trs->At(i)) );
340 xx(6)=(this->qtrm(i));
345 // 2)Calculate Wpi,Wk,Wp
346 this->GetPcode(xx(6),xx(10)/1000.);
353 for(Int_t j=1;j<11;j++){
354 cout.width(7);cout.precision(5);cout<<xx(j);
358 // 4)Update data in TVector
359 TClonesArray &arr=*trs;
360 new(arr[i])TVector(xx);
363 {/*cout<<"No data for track "<<i<<endl;*/}
364 }// End loop for tracks
366 void AliTPCPid::Reset(void)
368 for(Int_t i=0;i<trs->GetEntries();i++){
370 TClonesArray &arr=*trs;
371 new(arr[i])TVector(xx);
374 //-----------------------------------------------------------
375 AliTPCPid::AliTPCPid(Int_t ntrack)
377 trs = new TClonesArray("TVector",ntrack);
378 TClonesArray &arr=*trs;
379 for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
382 //fCutKa = new TF1("fkaons","[0]/x/x+[1]",0.1,1.2);
383 //fCutPr = new TF1("fprotons","[0]/x/x +[1]",0.2,1.2);
384 TF1 *f_rmska = new TF1("x_frmska","1.46-7.82*x+16.78*x^2-15.53*x^3+5.24*x^4 ",
386 fCutKa = new TF1("fkaons",
387 "1.25+0.044/x/x+1.25+0.044*x-13.87*x^2+22.37*x^3-10.05*x^4-2.5*x_frmska",
389 fCutPr = new TF1("fprotons",
390 "0.83*(15.32-56.094*x+89.962*x^2-66.1856*x^3+18.4052*x^4)",
392 fCutKaTune=1.1; // 0.92;
393 fCutPrTune=1.0; //0.80;
396 // Ncut Pmom pilo pihi klo khi plo phi
397 // cut[j] [0] [1] [2] [3] [4] [5] [6]
398 //----------------------------------------------------------------
399 SetCut( 1, 0.120, 0. , 0. , inf , inf , inf , inf );
400 SetCut( 2, 0.200, 0. , 6.0 , 6.0 , inf , inf , inf ); //120-200
401 SetCut( 3, 0.400, 0. , 3.5 , 3.5 , 9.0 , 9.0 , inf ); //200-400
402 SetCut( 4, 0.450, 0. , 1.9 , 1.9 , 4.0 , 4.0 , inf ); //400-450
403 //----------------------------------------------------------------
404 SetCut( 5, 0.500, 0.976, 0.108, 1.484 , 0.159 , 3.5 , inf ); //450-500
405 SetCut( 6, 0.550, 0.979, 0.108, 1.376 , 0.145 , 3.0 , inf ); //500-550
406 //----------------------------------------------------------------
407 SetCut( 7, 0.600, 0.984, 0.111, 1.295 , 0.146 , 2.7 , inf ); //550-600
408 SetCut( 8, 0.650, 0.989, 0.113, 1.239 , 0.141 , 2.5 , inf ); //600-650
409 SetCut( 9, 0.730, 0.995, 0.109, 1.172 , 0.132 , 2.0 , inf ); //650-730
410 //----------------------------------------------------------------
411 SetCut( 10, 0.830, 1.008, 0.116, 1.117 , 0.134 , 1.703, 0.209 ); //730-830
412 SetCut( 11, 0.930, 1.019, 0.115, 1.072 , 0.121 , 1.535, 0.215 ); //830-930
413 SetCut( 12, 1.230, 1.035, 0.117, 1.053 , 0.140 ,1.426, 0.270); //930-1030
414 //------------------------ pi,K ---------------------
415 aprob[0][0]=33219.; aprob[1][0]=1971.; // aprob[0][i] - pions
416 aprob[0][1]=28828.; aprob[1][1]=1973.; // aprob[1][i] - kaons
417 //---------------------------------------------------
418 aprob[0][2]=24532.; aprob[1][2]=1932.; aprob[2][2]=1948.;
419 aprob[0][3]=20797.; aprob[1][3]=1823.; aprob[2][3]=1970.;
420 aprob[0][4]=27017.; aprob[1][4]=2681.; aprob[2][4]=2905.;
421 //------------------------ pi,K,p -------------------
422 aprob[0][5]= 24563.; aprob[1][5]=2816.; aprob[2][5]=3219.;
423 aprob[0][6]= 16877.; aprob[1][6]=2231.; aprob[2][6]=2746.;
424 aprob[0][7]= 11557.; aprob[1][7]=1681; aprob[2][7]=2190.;
428 //-----------------------------------------------------------