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 **************************************************************************/
18 Revision 1.3 2003/03/04 07:36:15 kowal2
23 #include "AliTPCPid.h"
25 //#include "AliITSIOTrack.h"
26 #include "Riostream.h"
28 // Correction 13.01.2003 Z.S.,Dubna
30 //------------------------------------------------------------
31 Float_t AliTPCPid::qcorr(Float_t xc)
35 fcorr=( 0.766 +0.9692*xc -1.267*xc*xc )*( 1.-TMath::Exp(-xc*64.75) );
36 if(fcorr<=0.1)fcorr=0.1;
39 //-----------------------------------------------------------
40 Float_t AliTPCPid::qtrm(Int_t track)
42 TVector q(*( this->GetVec(track) ));
47 Int_t nl=0; for(Int_t i=0;i<ml;i++){if(q(i)>fSigmin){vf[nl]=q(i+1);nl++;}}
50 case 1:q(6)=q(1); break;
51 case 2:q(6)=(q(1)+q(2))/2.; break;
53 for(int fi=0;fi<2;fi++){
55 do{ swap=0; float qmin=vf[fi];
56 for(int j=fi+1;j<nl;j++)
57 if(qmin>vf[j]){qmin=vf[j];vf[j]=vf[fi];vf[fi]=qmin;swap=1;};
60 q(6)= (vf[0]+vf[1])/2.;
63 for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
65 }// --- End AliTPCPid::qtrm ---
67 Float_t AliTPCPid::qtrm(Float_t qarr[6],Int_t narr)
72 if(narr>0&&narr<7){ml=narr;}else{return 0;};
73 nl=0; for(Int_t i=0;i<ml;i++){if(qarr[i]>fSigmin){q[nl]=qarr[i];nl++;}}
76 case 1:qm=q[0]; break;
77 case 2:qm=(q[0]+q[1])/2.; break;
80 for(int fi=0;fi<2;fi++){
81 do{ swap=0; qmin=q[fi];
82 for(int j=fi+1;j<nl;j++)
83 if(qmin>q[j]){qmin=q[j];q[j]=q[fi];q[fi]=qmin;swap=1;};
90 }// --- End AliTPCPid::qtrm ---
92 Int_t AliTPCPid::wpik(Int_t nc,Float_t q)
94 Float_t qmpi,qmk,sigpi,sigk,dpi,dk,ppi,pk;
100 appi = aprob[0][nc-5];
101 apk = aprob[1][nc-5];
103 cout<<"qmpi,sigpi,qmk,sigk="<<qmpi<<" "<<sigpi<<" "<<qmk<<" "<<sigk<<endl;
104 cout<<"appi,apk="<<appi<<","<<apk<<endl;
106 Float_t dqpi=(q-qmpi)/sigpi;
107 Float_t dqk =(q-qmk )/sigk;
108 dpi =TMath::Abs(dqpi);
110 Double_t dn=appi*TMath::Gaus(q,qmpi,sigpi)+apk*TMath::Gaus(q,qmk,sigk);
112 ppi=appi*TMath::Gaus(q,qmpi,sigpi)/dn;
113 pk = apk*TMath::Gaus(q,qmk, sigk )/dn;
114 }else{fWpi=1;return pion();}
115 Float_t rpik=ppi/(pk+0.0000001);
117 cout<<"q,dqpi,dqk, wpik: ppi,pk,rpik="
118 <<q<<" "<<dqpi<<" "<<dqk<<" "<<ppi<<" "<<pk<<" "<<rpik<<endl;
120 fWp=0.; fWpi=ppi; fWk=pk;
121 if( pk>ppi){return kaon();}else{return pion();}
123 //-----------------------------------------------------------
125 Int_t AliTPCPid::wpikp(Int_t nc,Float_t q)
127 Float_t qmpi,qmk,qmp,sigpi,sigk,sigp,ppi,pk,pp;
128 Float_t appi,apk,app;
137 //appi = apk = app = 1.;
138 appi = aprob[0][nc-5];
139 apk = aprob[1][nc-5];
140 app = aprob[2][nc-5];
142 Double_t dn= appi*TMath::Gaus(q,qmpi,sigpi)
143 +apk*TMath::Gaus(q,qmk,sigk)+app*TMath::Gaus(q,qmp,sigp);
145 ppi=appi*TMath::Gaus(q,qmpi,sigpi)/dn;
146 pk = apk*TMath::Gaus(q,qmk, sigk )/dn;
147 pp = app*TMath::Gaus(q,qmp, sigp )/dn;
149 else{fWpi=1;return pion();}
150 fWp=pp; fWpi=ppi; fWk=pk;
152 cout<<" wpikp: mid,sig pi,k,p="<<qmpi<<" "<<sigpi<<"; "<<qmk<<" "<<sigk<<"; "
153 <<qmp<<" "<<sigp<<"; "<<endl;
154 cout<<" aprob: "<<appi<<" "<<apk<<" "<<app<<endl;
155 cout<<" ppi,pk,pp="<<ppi<<" "<<pk<<" "<<pp<<endl;
157 if( ppi>pk&&ppi>pp ) { return pion(); }
158 if(pk>pp){return kaon();}else{return proton();}
160 //-----------------------------------------------------------
161 Int_t AliTPCPid::GetPcode(TClonesArray* rps,Float_t pm)
165 //-----------------------------------------------------------
166 Int_t AliTPCPid::GetPcode(AliTPCtrack *track)
168 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
169 Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
170 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
171 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
172 Float_t lam=TMath::ATan(par[3]);
173 Float_t pt_1=TMath::Abs(par[4]);
174 Float_t mom=1./(pt_1*TMath::Cos(lam));
175 Float_t dedx=track->GetdEdx();
176 Int_t pcode=GetPcode(dedx/40.,mom);
177 cout<<"TPCtrack dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
178 return pcode?pcode:211;
180 //-----------------------------------------------------------
181 Int_t AliTPCPid::GetPcode(AliITStrackV2 *track)
183 if(track==0)return 0;
184 // track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
185 track->PropagateTo(3.,0.0028,65.19);
186 track->PropagateToVertex();
187 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
188 Float_t lam=TMath::ATan(par[3]);
189 Float_t pt_1=TMath::Abs(par[4]);
191 if( (pt_1*TMath::Cos(lam))!=0. ){ mom=1./(pt_1*TMath::Cos(lam)); }else{mom=0.;};
192 Float_t dedx=track->GetdEdx();
193 cout<<"lam,pt_1,mom,dedx="<<lam<<","<<pt_1<<","<<mom<<","<<dedx<<endl;
194 Int_t pcode=GetPcode(dedx,mom);
195 cout<<"ITS V2 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
196 return pcode?pcode:211;
198 //-----------------------------------------------------------
199 Int_t AliTPCPid::GetPcode(Float_t q,Float_t pm)
201 fWpi=fWk=fWp=0.; fPcode=0;
202 //1)---------------------- 0-120 MeV/c --------------
204 { fWpi=1.; return pion(); }
205 //2)----------------------120-200 Mev/c ( 29.7.2002 ) -------------
207 { if( q<fCutKa->Eval(pm) ){fWpi=1.; return pion(); }
208 else {fWk =1.; return kaon();} }
209 //3)----------------------200-400 Mev/c -------------
211 if( q<fCutKa->Eval(pm) )
212 { fWpi=1.;return pion(); }
214 { if ( q<=fCutPr->Eval(pm) )
215 {fWk=1.;return kaon();}
216 else {fWp=1.;return proton();}
218 //4)----------------------400-450 Mev/c -------------
220 if( q<fCutKaTune*fCutKa->Eval(pm) )
221 { fWpi=1.;return pion(); }
223 { if( q<fCutPr->Eval(pm) )
224 {fWk=1.;return kaon();} else {fWp=1.;return proton(); }
226 //5)----------------------450-500 Mev/c -------------
228 if ( q>fCutPr->Eval(pm) )
229 {fWp=1.;return proton();} else {return wpik(5,q);};
230 //6)----------------------500-550 Mev/c -------------
232 if ( q>fCutPr->Eval(pm) )
233 {fWp=1.;return proton();} else {return wpik(6,q);};
234 //7)----------------------550-600 Mev/c -------------
236 if ( q>fCutPr->Eval(pm) )
237 {fWp=1.;return proton();} else {return wpik(7,q);};
238 //8)----------------------600-650 Mev/c -------------
240 if ( q>fCutPrTune*fCutPr->Eval(pm) ){fWp=1.;return proton();}
241 else {return wpik(8,q);};
242 //9)----------------------650-730 Mev/c -------------
244 if ( q>fCutPrTune*fCutPr->Eval(pm) ){fWp=1.;return proton();}
245 else {return wpik(9,q);};
246 //10)----------------------730-830 Mev/c -------------
248 if ( q>fCutPrTune*fCutPr->Eval(pm) ){fWp=1.;return proton();}
249 else {return wpik(10,q);};
250 //11)----------------------830-930 Mev/c -------------
251 if( pm<=cut[11][0] ){ return wpikp(11,q); }
252 //12)----------------------930-1030 Mev/c -------------
254 { return wpikp(12,q); };
258 //-----------------------------------------------------------
259 void AliTPCPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
260 Float_t klo,Float_t khi,Float_t plo,Float_t phi)
271 //------------------------------------------------------------
272 void AliTPCPid::SetVec(Int_t ntrack,TVector info)
274 TClonesArray& arr=*trs;
275 new( arr[ntrack] ) TVector(info);
277 //-----------------------------------------------------------
278 TVector* AliTPCPid::GetVec(Int_t ntrack)
280 TClonesArray& arr=*trs;
281 return (TVector*)arr[ntrack];
283 //-----------------------------------------------------------
284 void AliTPCPid::SetEdep(Int_t track,Float_t Edep)
287 if( ((TVector*)trs->At(track))->IsValid() )
288 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
289 Int_t j=(Int_t)xx(0); if(j>4)return;
290 xx(++j)=Edep;xx(0)=j;
291 TClonesArray &arr=*trs;
292 new(arr[track])TVector(xx);
294 //-----------------------------------------------------------
295 void AliTPCPid::SetPmom(Int_t track,Float_t Pmom)
298 if( ((TVector*)trs->At(track))->IsValid() )
299 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
301 TClonesArray &arr=*trs;
302 new(arr[track])TVector(xx);
304 //-----------------------------------------------------------
305 void AliTPCPid::SetPcod(Int_t track,Int_t partcode)
308 if( ((TVector*)trs->At(track))->IsValid() )
309 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
311 {xx(11)=partcode; mxtrs++;
312 TClonesArray &arr=*trs;
313 new(arr[track])TVector(xx);
316 //-----------------------------------------------------------
317 void AliTPCPid::Print(Int_t track)
318 {cout<<mxtrs<<" tracks in AliITSPid obj."<<endl;
319 if( ((TVector*)trs->At(track))->IsValid() )
320 {TVector xx( *((TVector*)trs->At(track)) );
324 {cout<<"No data for track "<<track<<endl;return;}
326 //-----------------------------------------------------------
327 void AliTPCPid::Tab(void)
329 if(trs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
330 cout<<"------------------------------------------------------------------------"<<endl;
331 cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
332 " Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
333 cout<<"------------------------------------------------------------------------"<<endl;
334 for(Int_t i=0;i<trs->GetEntries();i++)
336 TVector xx( *((TVector*)trs->At(i)) );
337 if( xx.IsValid() && xx(0)>0 )
339 TVector xx( *((TVector*)trs->At(i)) );
343 xx(6)=(this->qtrm(i));
348 // 2)Calculate Wpi,Wk,Wp
349 this->GetPcode(xx(6),xx(10)/1000.);
356 for(Int_t j=1;j<11;j++){
357 cout.width(7);cout.precision(5);cout<<xx(j);
361 // 4)Update data in TVector
362 TClonesArray &arr=*trs;
363 new(arr[i])TVector(xx);
366 {/*cout<<"No data for track "<<i<<endl;*/}
367 }// End loop for tracks
369 void AliTPCPid::Reset(void)
371 for(Int_t i=0;i<trs->GetEntries();i++){
373 TClonesArray &arr=*trs;
374 new(arr[i])TVector(xx);
377 //-----------------------------------------------------------
378 AliTPCPid::AliTPCPid(Int_t ntrack)
380 trs = new TClonesArray("TVector",ntrack);
381 TClonesArray &arr=*trs;
382 for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
385 //fCutKa = new TF1("fkaons","[0]/x/x+[1]",0.1,1.2);
386 //fCutPr = new TF1("fprotons","[0]/x/x +[1]",0.2,1.2);
387 TF1 *f_rmska = new TF1("x_frmska","1.46-7.82*x+16.78*x^2-15.53*x^3+5.24*x^4 ",
389 fCutKa = new TF1("fkaons",
390 "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",
392 fCutPr = new TF1("fprotons",
393 "0.83*(15.32-56.094*x+89.962*x^2-66.1856*x^3+18.4052*x^4)",
395 fCutKaTune=1.1; // 0.92;
396 fCutPrTune=1.0; //0.80;
399 // Ncut Pmom pilo pihi klo khi plo phi
400 // cut[j] [0] [1] [2] [3] [4] [5] [6]
401 //----------------------------------------------------------------
402 SetCut( 1, 0.120, 0. , 0. , inf , inf , inf , inf );
403 SetCut( 2, 0.200, 0. , 6.0 , 6.0 , inf , inf , inf ); //120-200
404 SetCut( 3, 0.400, 0. , 3.5 , 3.5 , 9.0 , 9.0 , inf ); //200-400
405 SetCut( 4, 0.450, 0. , 1.9 , 1.9 , 4.0 , 4.0 , inf ); //400-450
406 //----------------------------------------------------------------
407 SetCut( 5, 0.500, 0.976, 0.108, 1.484 , 0.159 , 3.5 , inf ); //450-500
408 SetCut( 6, 0.550, 0.979, 0.108, 1.376 , 0.145 , 3.0 , inf ); //500-550
409 //----------------------------------------------------------------
410 SetCut( 7, 0.600, 0.984, 0.111, 1.295 , 0.146 , 2.7 , inf ); //550-600
411 SetCut( 8, 0.650, 0.989, 0.113, 1.239 , 0.141 , 2.5 , inf ); //600-650
412 SetCut( 9, 0.730, 0.995, 0.109, 1.172 , 0.132 , 2.0 , inf ); //650-730
413 //----------------------------------------------------------------
414 SetCut( 10, 0.830, 1.008, 0.116, 1.117 , 0.134 , 1.703, 0.209 ); //730-830
415 SetCut( 11, 0.930, 1.019, 0.115, 1.072 , 0.121 , 1.535, 0.215 ); //830-930
416 SetCut( 12, 1.230, 1.035, 0.117, 1.053 , 0.140 ,1.426, 0.270); //930-1030
417 //------------------------ pi,K ---------------------
418 aprob[0][0]=33219.; aprob[1][0]=1971.; // aprob[0][i] - pions
419 aprob[0][1]=28828.; aprob[1][1]=1973.; // aprob[1][i] - kaons
420 //---------------------------------------------------
421 aprob[0][2]=24532.; aprob[1][2]=1932.; aprob[2][2]=1948.;
422 aprob[0][3]=20797.; aprob[1][3]=1823.; aprob[2][3]=1970.;
423 aprob[0][4]=27017.; aprob[1][4]=2681.; aprob[2][4]=2905.;
424 //------------------------ pi,K,p -------------------
425 aprob[0][5]= 24563.; aprob[1][5]=2816.; aprob[2][5]=3219.;
426 aprob[0][6]= 16877.; aprob[1][6]=2231.; aprob[2][6]=2746.;
427 aprob[0][7]= 11557.; aprob[1][7]=1681; aprob[2][7]=2190.;
431 //-----------------------------------------------------------