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 //-----------------------------------------------------------
17 //PH #include "vector.h"
20 Float_t AliITSPid::qtrm(Int_t track)
22 TVector q(*( this->GetVec(track) ));
27 case 1:q(6)=q(1); break;
28 case 2:q(6)=(q(1)+q(2))/2.; break;
30 for(Int_t i=0;i<nl;i++){vf[i]=q(i+1);}
31 sort(vf.begin(),vf.end());
32 q(6)= (vf[0]+vf[1])/2.;
35 for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
38 //........................................................
39 Float_t AliITSPid::qtrm(Float_t qarr[6],Int_t narr)
44 nl=0; for(Int_t i=0;i<ml;i++){if(qarr[i]>0.){q[i]=qarr[i];nl++;}}
48 case 1:qm=q[0]; break;
49 case 2:qm=(q[0]+q[1])/2.; break;
51 for(Int_t i=0;i<nl;i++){vf[i]=q[i];}
52 sort(vf.begin(),vf.end());
58 //-----------------------------------------------------------
60 Int_t AliITSPid::wpik(Int_t nc,Float_t q)
64 Float_t qmpi,qmk,sigpi,sigk,dpi,dk,ppi,pk;
69 Float_t dqpi=(q-qmpi)/sigpi;
70 Float_t dqk =(q-qmk )/sigk;
71 if( dqk<-1. )return pion();
72 dpi =TMath::Abs(dqpi);
74 ppi =1.- TMath::Erf(dpi); // +0.5;
75 pk =1.- TMath::Erf(dk); // +0.5;
76 Float_t rpik=ppi/(pk+0.0000001);
77 cout<<"q,dqpi,dqk, wpik: ppi,pk,rpik="
78 <<q<<" "<<dqpi<<" "<<dqk<<" "<<ppi<<" "<<pk<<" "<<rpik<<endl;
79 if( rpik>=1000. ){return pion();}
80 if( rpik>0.001 ){fWk=1./(rpik+1.); fWpi=1.-fWk;return 0;}
83 //-----------------------------------------------------------
85 Int_t AliITSPid::wpikp(Int_t nc,Float_t q)
89 Float_t qmpi,qmk,qmp,sigpi,sigk,sigp,ppi,pka,ppr,rppi,rpka;
98 ppi =TMath::Erf( TMath::Abs((q-qmpi)/sigpi) )+0.5;
99 pka =TMath::Erf( TMath::Abs((q-qmk )/sigk) )+0.5;
100 ppr =TMath::Erf( TMath::Abs((q-qmp )/sigp) )+0.5;
105 if( rppi>rpka ) { rp=rpka; }
107 if( rp>=1000. ){ return proton(); }
108 if( rp>0.001 ){ fWp=rp/(rp+1.);return proton(); }
112 //-----------------------------------------------------------
113 Int_t AliITSPid::GetPcode(TClonesArray* rps,Float_t pm)
117 //-----------------------------------------------------------
118 Int_t AliITSPid::GetPcode(AliTPCtrack *track)
120 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
121 Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
122 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
123 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
124 Float_t lam=TMath::ATan(par[3]);
125 Float_t pt_1=TMath::Abs(par[4]);
126 Float_t mom=1./(pt_1*TMath::Cos(lam));
127 Float_t dedx=track->GetdEdx();
128 Int_t pcode=GetPcode(dedx/40.,mom);
129 cout<<"TPCtrack dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
130 return pcode?pcode:211;
132 //------------------------------------------------------------
134 Int_t AliITSPid::GetPcode(AliITSIOTrack *track)
140 Float_t mom=TMath::Sqrt(px*px+py*py+pz*pz);
141 //???????????????????
143 Float_t dedx=track->GetdEdx();
144 //???????????????????
145 Int_t pcode=GetPcode(dedx,mom);
146 cout<<"ITSV1 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
147 return pcode?pcode:211;
150 //-----------------------------------------------------------
151 Int_t AliITSPid::GetPcode(AliITStrackV2 *track)
153 if(track==0)return 0;
154 //track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
155 track->PropagateTo(3.,0.0028,65.19);
157 track->PropagateToVertex();
158 Double_t xk,par[5]; track->GetExternalParameters(xk,par);
159 Float_t lam=TMath::ATan(par[3]);
160 Float_t pt_1=TMath::Abs(par[4]);
162 if( (pt_1*TMath::Cos(lam))!=0. ){ mom=1./(pt_1*TMath::Cos(lam)); }else{mom=0.;};
163 Float_t dedx=track->GetdEdx();
164 //cout<<"lam,pt_1,mom,dedx="<<lam<<","<<pt_1<<","<<mom<<","<<dedx<<endl;
165 Int_t pcode=GetPcode(dedx,mom);
166 //cout<<"ITS V2 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
167 return pcode?pcode:211;
169 //-----------------------------------------------------------
170 Int_t AliITSPid::GetPcode(Float_t q,Float_t pm)
172 fWpi=fWk=fWp=-1.; fPcode=0;
178 { if( q<cut[2][2] ){ return pion(); } else { return kaon();} }
184 { if ( q<=cut[3][5] ) {return kaon();} else {return proton();}}
190 { if( q<=cut[4][4] ) {return kaon();} else {return proton(); }}
193 if ( q>cut[5][5] ) {return proton();} else {return wpik(5,q);};
196 if ( q>cut[6][5] ) {return proton();} else {return wpik(6,q);};
199 if ( q<=cut[7][5] ) {return fPcode;} else {return proton();};
202 if ( q<=cut[8][5] ) {return fPcode;} else {return proton();};
205 if ( q<=cut[9][5] ) {return fPcode;} else {return proton();};
207 if( pm<=cut[10][0] ){ return wpikp(10,q); }
209 if( pm<=cut[11][0] ){ return wpikp(11,q); }
211 if( pm<=cut[12][0] ){ return wpikp(12,q); }
215 //-----------------------------------------------------------
216 void AliITSPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
217 Float_t klo,Float_t khi,Float_t plo,Float_t phi)
228 //-----------------------------------------------------------
229 void AliITSPid::SetVec(Int_t ntrack,TVector info)
231 TClonesArray& arr=*trs;
232 new( arr[ntrack] ) TVector(info);
234 //-----------------------------------------------------------
235 TVector* AliITSPid::GetVec(Int_t ntrack)
237 TClonesArray& arr=*trs;
238 return (TVector*)arr[ntrack];
240 //-----------------------------------------------------------
241 void AliITSPid::SetEdep(Int_t track,Float_t Edep)
244 if( ((TVector*)trs->At(track))->IsValid() )
245 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
246 Int_t j=(Int_t)xx(0); if(j>4)return;
247 xx(++j)=Edep;xx(0)=j;
248 TClonesArray &arr=*trs;
249 new(arr[track])TVector(xx);
251 //-----------------------------------------------------------
252 void AliITSPid::SetPmom(Int_t track,Float_t Pmom)
255 if( ((TVector*)trs->At(track))->IsValid() )
256 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
258 TClonesArray &arr=*trs;
259 new(arr[track])TVector(xx);
261 //-----------------------------------------------------------
262 void AliITSPid::SetPcod(Int_t track,Int_t partcode)
265 if( ((TVector*)trs->At(track))->IsValid() )
266 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
268 {xx(11)=partcode; mxtrs++;
269 TClonesArray &arr=*trs;
270 new(arr[track])TVector(xx);
273 //-----------------------------------------------------------
274 void AliITSPid::Print(Int_t track)
275 {cout<<mxtrs<<" tracks in AliITSPid obj."<<endl;
276 if( ((TVector*)trs->At(track))->IsValid() )
277 {TVector xx( *((TVector*)trs->At(track)) );
281 {cout<<"No data for track "<<track<<endl;return;}
283 //-----------------------------------------------------------
284 void AliITSPid::Tab(void)
286 if(trs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
287 cout<<"------------------------------------------------------------------------"<<endl;
288 cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
289 " Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
290 cout<<"------------------------------------------------------------------------"<<endl;
291 for(Int_t i=0;i<trs->GetEntries();i++)
293 TVector xx( *((TVector*)trs->At(i)) );
294 if( xx.IsValid() && xx(0)>0 )
296 TVector xx( *((TVector*)trs->At(i)) );
300 xx(6)=(this->qtrm(i));
305 // 2)Calculate Wpi,Wk,Wp
306 this->GetPcode(xx(6),xx(10)/1000.);
313 for(Int_t j=1;j<11;j++){
314 cout.width(7);cout.precision(5);cout<<xx(j);
318 // 4)Update data in TVector
319 TClonesArray &arr=*trs;
320 new(arr[i])TVector(xx);
323 {/*cout<<"No data for track "<<i<<endl;*/}
324 }// End loop for tracks
326 void AliITSPid::Reset(void)
328 for(Int_t i=0;i<trs->GetEntries();i++){
330 TClonesArray &arr=*trs;
331 new(arr[i])TVector(xx);
334 //-----------------------------------------------------------
335 AliITSPid::AliITSPid(Int_t ntrack)
337 trs = new TClonesArray("TVector",ntrack);
338 TClonesArray &arr=*trs;
339 for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
342 // Ncut Pmom pilo pihi klo khi plo phi
343 // cut[j] [0] [1] [2] [3] [4] [5] [6]
344 //----------------------------------------------------------------
345 SetCut( 1, 0.12 , 0. , 0. , inf , inf , inf , inf );
346 SetCut( 2, 0.20 , 0. , 6.0 , 6.0 , inf , inf , inf );
347 SetCut( 3, 0.30 , 0. , 3.5 , 3.5 , 9.0 , 9.0 , inf );
348 SetCut( 4, 0.41 , 0. , 1.9 , 1.9 , 4.0 , 4.0 , inf );
349 //----------------------------------------------------------------
350 SetCut( 5, 0.47 , 1. , 0.12, 1.98 , 0.17 , 3.5 , inf );
351 SetCut( 6, 0.53 , 1. , 0.12, 1.75 , 0.16 , 3.0 , inf );
352 //----------------------------------------------------------------
353 SetCut( 7, 0.59 , 0. , 0. , 1.18 , 0.125 , 2.7 , inf );
354 SetCut( 8, 0.65 , 0. , 0. , 1.18 , 0.125 , 2.5 , inf );
355 SetCut( 9, 0.73 , 0. , 0. , 0. , 0.125 , 2.0 , inf );
356 //----------------------------------------------------------------
357 SetCut( 10, 0.83 , 0. , 0. , 1.25 , 0.13 , 2.14 , 0.20 );
358 SetCut( 11, 0.93 , 0. , 0. , 1.18 , 0.125 , 1.88 , 0.18 );
359 SetCut( 12, 1.03 , 0. , 0. , 1.13 , 0.12 , 1.68 , 0.155);
361 //-----------------------------------------------------------