3 #include "AliITSIOTrack.h"
7 //-----------------------------------------------------------
8 Float_t AliITSPid::qcorr(Float_t xc)
12 fcorr=( 0.766 +0.9692*xc -1.267*xc*xc )*( 1.-TMath::Exp(-xc*64.75) );
13 if(fcorr<=0.1)fcorr=0.1;
16 //-----------------------------------------------------------
19 Float_t AliITSPid::qtrm(Int_t track)
21 TVector q(*( this->GetVec(track) ));
26 case 1:q(6)=q(1); break;
27 case 2:q(6)=(q(1)+q(2))/2.; break;
29 for(Int_t i=0;i<nl;i++){vf[i]=q(i+1);}
30 sort(vf.begin(),vf.end());
31 q(6)= (vf[0]+vf[1])/2.;
34 for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
37 //........................................................
38 Float_t AliITSPid::qtrm(Float_t qarr[6],Int_t narr)
43 nl=0; for(Int_t i=0;i<ml;i++){if(qarr[i]>0.){q[i]=qarr[i];nl++;}}
47 case 1:qm=q[0]; break;
48 case 2:qm=(q[0]+q[1])/2.; break;
50 for(Int_t i=0;i<nl;i++){vf[i]=q[i];}
51 sort(vf.begin(),vf.end());
57 //-----------------------------------------------------------
59 Int_t AliITSPid::wpik(Int_t nc,Float_t q)
63 Float_t qmpi,qmk,sigpi,sigk,dpi,dk,ppi,pk;
68 Float_t dqpi=(q-qmpi)/sigpi;
69 Float_t dqk =(q-qmk )/sigk;
70 if( dqk<-1. )return pion();
73 ppi =1.- TMath::Erf(dpi); // +0.5;
74 pk =1.- TMath::Erf(dk); // +0.5;
75 Float_t rpik=ppi/(pk+0.0000001);
76 cout<<"q,dqpi,dqk, wpik: ppi,pk,rpik="
77 <<q<<" "<<dqpi<<" "<<dqk<<" "<<ppi<<" "<<pk<<" "<<rpik<<endl;
78 if( rpik>=1000. ){return pion();}
79 if( rpik>0.001 ){fWk=1./(rpik+1.); fWpi=1.-fWk;return 0;}
82 //-----------------------------------------------------------
84 Int_t AliITSPid::wpikp(Int_t nc,Float_t q)
88 Float_t qmpi,qmk,qmp,sigpi,sigk,sigp,ppi,pka,ppr,rppi,rpka;
97 ppi =TMath::Erf( TMath::Abs((q-qmpi)/sigpi) )+0.5;
98 pka =TMath::Erf( TMath::Abs((q-qmk )/sigk) )+0.5;
99 ppr =TMath::Erf( TMath::Abs((q-qmp )/sigp) )+0.5;
104 if( rppi>rpka ) { rp=rpka; }
106 if( rp>=1000. ){ return proton(); }
107 if( rp>0.001 ){ fWp=rp/(rp+1.);return proton(); }
111 //-----------------------------------------------------------
112 Int_t AliITSPid::GetPcode(TClonesArray* rps,Float_t pm)
116 //-----------------------------------------------------------
117 Int_t AliITSPid::GetPcode(AliTPCtrack *track)
119 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
120 Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
121 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
122 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
123 Float_t lam=TMath::ATan(par[3]);
124 Float_t pt_1=TMath::Abs(par[4]);
125 Float_t mom=1./(pt_1*TMath::Cos(lam));
126 Float_t dedx=track->GetdEdx();
127 Int_t pcode=GetPcode(dedx/40.,mom);
128 cout<<"TPCtrack dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
129 return pcode?pcode:211;
131 //------------------------------------------------------------
133 Int_t AliITSPid::GetPcode(AliITSIOTrack *track)
139 Float_t mom=TMath::Sqrt(px*px+py*py+pz*pz);
140 //???????????????????
142 Float_t dedx=track->GetdEdx();
143 //???????????????????
144 Int_t pcode=GetPcode(dedx,mom);
145 cout<<"ITSV1 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
146 return pcode?pcode:211;
149 //-----------------------------------------------------------
150 Int_t AliITSPid::GetPcode(AliITStrackV2 *track)
152 if(track==0)return 0;
153 //track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
154 track->PropagateTo(3.,0.0028,65.19);
156 track->PropagateToVertex();
157 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
158 Float_t lam=TMath::ATan(par[3]);
159 Float_t pt_1=TMath::Abs(par[4]);
161 if( (pt_1*TMath::Cos(lam))!=0. ){ mom=1./(pt_1*TMath::Cos(lam)); }else{mom=0.;};
162 Float_t dedx=track->GetdEdx();
163 //cout<<"lam,pt_1,mom,dedx="<<lam<<","<<pt_1<<","<<mom<<","<<dedx<<endl;
164 Int_t pcode=GetPcode(dedx,mom);
165 //cout<<"ITS V2 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
166 return pcode?pcode:211;
168 //-----------------------------------------------------------
169 Int_t AliITSPid::GetPcode(Float_t q,Float_t pm)
171 fWpi=fWk=fWp=-1.; fPcode=0;
177 { if( q<cut[2][2] ){ return pion(); } else { return kaon();} }
183 { if ( q<=cut[3][5] ) {return kaon();} else {return proton();}}
189 { if( q<=cut[4][4] ) {return kaon();} else {return proton(); }}
192 if ( q>cut[5][5] ) {return proton();} else {return wpik(5,q);};
195 if ( q>cut[6][5] ) {return proton();} else {return wpik(6,q);};
198 if ( q<=cut[7][5] ) {return fPcode;} else {return proton();};
201 if ( q<=cut[8][5] ) {return fPcode;} else {return proton();};
204 if ( q<=cut[9][5] ) {return fPcode;} else {return proton();};
206 if( pm<=cut[10][0] ){ return wpikp(10,q); }
208 if( pm<=cut[11][0] ){ return wpikp(11,q); }
210 if( pm<=cut[12][0] ){ return wpikp(12,q); }
214 //-----------------------------------------------------------
215 void AliITSPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
216 Float_t klo,Float_t khi,Float_t plo,Float_t phi)
227 //-----------------------------------------------------------
228 void AliITSPid::SetVec(Int_t ntrack,TVector info)
230 TClonesArray& arr=*trs;
231 new( arr[ntrack] ) TVector(info);
233 //-----------------------------------------------------------
234 TVector* AliITSPid::GetVec(Int_t ntrack)
236 TClonesArray& arr=*trs;
237 return (TVector*)arr[ntrack];
239 //-----------------------------------------------------------
240 void AliITSPid::SetEdep(Int_t track,Float_t Edep)
243 if( ((TVector*)trs->At(track))->IsValid() )
244 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
245 Int_t j=(Int_t)xx(0); if(j>4)return;
246 xx(++j)=Edep;xx(0)=j;
247 TClonesArray &arr=*trs;
248 new(arr[track])TVector(xx);
250 //-----------------------------------------------------------
251 void AliITSPid::SetPmom(Int_t track,Float_t Pmom)
254 if( ((TVector*)trs->At(track))->IsValid() )
255 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
257 TClonesArray &arr=*trs;
258 new(arr[track])TVector(xx);
260 //-----------------------------------------------------------
261 void AliITSPid::SetPcod(Int_t track,Int_t partcode)
264 if( ((TVector*)trs->At(track))->IsValid() )
265 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
267 {xx(11)=partcode; mxtrs++;
268 TClonesArray &arr=*trs;
269 new(arr[track])TVector(xx);
272 //-----------------------------------------------------------
273 void AliITSPid::Print(Int_t track)
274 {cout<<mxtrs<<" tracks in AliITSPid obj."<<endl;
275 if( ((TVector*)trs->At(track))->IsValid() )
276 {TVector xx( *((TVector*)trs->At(track)) );
280 {cout<<"No data for track "<<track<<endl;return;}
282 //-----------------------------------------------------------
283 void AliITSPid::Tab(void)
285 if(trs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
286 cout<<"------------------------------------------------------------------------"<<endl;
287 cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
288 " Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
289 cout<<"------------------------------------------------------------------------"<<endl;
290 for(Int_t i=0;i<trs->GetEntries();i++)
292 TVector xx( *((TVector*)trs->At(i)) );
293 if( xx.IsValid() && xx(0)>0 )
295 TVector xx( *((TVector*)trs->At(i)) );
299 xx(6)=(this->qtrm(i));
304 // 2)Calculate Wpi,Wk,Wp
305 this->GetPcode(xx(6),xx(10)/1000.);
312 for(Int_t j=1;j<11;j++){
313 cout.width(7);cout.precision(5);cout<<xx(j);
317 // 4)Update data in TVector
318 TClonesArray &arr=*trs;
319 new(arr[i])TVector(xx);
322 {/*cout<<"No data for track "<<i<<endl;*/}
323 }// End loop for tracks
325 void AliITSPid::Reset(void)
327 for(Int_t i=0;i<trs->GetEntries();i++){
329 TClonesArray &arr=*trs;
330 new(arr[i])TVector(xx);
333 //-----------------------------------------------------------
334 AliITSPid::AliITSPid(Int_t ntrack)
336 trs = new TClonesArray("TVector",ntrack);
337 TClonesArray &arr=*trs;
338 for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
341 // Ncut Pmom pilo pihi klo khi plo phi
342 // cut[j] [0] [1] [2] [3] [4] [5] [6]
343 //----------------------------------------------------------------
344 SetCut( 1, 0.12 , 0. , 0. , inf , inf , inf , inf );
345 SetCut( 2, 0.20 , 0. , 6.0 , 6.0 , inf , inf , inf );
346 SetCut( 3, 0.30 , 0. , 3.5 , 3.5 , 9.0 , 9.0 , inf );
347 SetCut( 4, 0.41 , 0. , 1.9 , 1.9 , 4.0 , 4.0 , inf );
348 //----------------------------------------------------------------
349 SetCut( 5, 0.47 , 1. , 0.12, 1.98 , 0.17 , 3.5 , inf );
350 SetCut( 6, 0.53 , 1. , 0.12, 1.75 , 0.16 , 3.0 , inf );
351 //----------------------------------------------------------------
352 SetCut( 7, 0.59 , 0. , 0. , 1.18 , 0.125 , 2.7 , inf );
353 SetCut( 8, 0.65 , 0. , 0. , 1.18 , 0.125 , 2.5 , inf );
354 SetCut( 9, 0.73 , 0. , 0. , 0. , 0.125 , 2.0 , inf );
355 //----------------------------------------------------------------
356 SetCut( 10, 0.83 , 0. , 0. , 1.25 , 0.13 , 2.14 , 0.20 );
357 SetCut( 11, 0.93 , 0. , 0. , 1.18 , 0.125 , 1.88 , 0.18 );
358 SetCut( 12, 1.03 , 0. , 0. , 1.13 , 0.12 , 1.68 , 0.155);
360 //-----------------------------------------------------------