Inline declaration eliminiated to avoid problems with GCC on RH7.1+
[u/mrichter/AliRoot.git] / ITS / AliITSPid.cxx
CommitLineData
23efe5f1 1#include "AliITSPid.h"
2#include "TMath.h"
3#include <iostream.h>
4ClassImp(AliITSPid)
5
6//-----------------------------------------------------------
7Float_t AliITSPid::qcorr(Float_t xc)
8{
9 assert(0);
10 Float_t fcorr;
11 fcorr=( 0.766 +0.9692*xc -1.267*xc*xc )*( 1.-TMath::Exp(-xc*64.75) );
12 if(fcorr<=0.1)fcorr=0.1;
13return qtot/fcorr;
14}
15
16//-----------------------------------------------------------
17#include "vector.h"
18#include <algorithm>
19Float_t AliITSPid::qtrm(Int_t track)
20{
21 TVector q(*( this->GetVec(track) ));
22 Int_t nl=(Int_t)q(0);
23 if(nl<1)return 0.;
24 vector<float> vf(nl);
25 switch(nl){
26 case 1:q(6)=q(1); break;
27 case 2:q(6)=(q(1)+q(2))/2.; break;
28 default:
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.;
32 break;
33 }
34 for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
35 return (q(6));
36}
37//-----------------------------------------------------------
23efe5f1 38Int_t AliITSPid::wpik(Int_t nc,Float_t q)
39{
40 return pion();
41
42 Float_t qmpi,qmk,sigpi,sigk,dpi,dk,ppi,pk;
43 qmpi =cut[nc][1];
44 sigpi=cut[nc][2];
45 qmk =cut[nc][3];
46 sigk =cut[nc][4];
47 Float_t dqpi=(q-qmpi)/sigpi;
48 Float_t dqk =(q-qmk )/sigk;
49 if( dqk<-1. )return pion();
50 dpi =fabs(dqpi);
51 dk =fabs(dqk);
52 ppi =1.- TMath::Erf(dpi); // +0.5;
53 pk =1.- TMath::Erf(dk); // +0.5;
54 Float_t rpik=ppi/(pk+0.0000001);
55 cout<<"q,dqpi,dqk, wpik: ppi,pk,rpik="
56 <<q<<" "<<dqpi<<" "<<dqk<<" "<<ppi<<" "<<pk<<" "<<rpik<<endl;
57 if( rpik>=1000. ){return pion();}
58 if( rpik>0.001 ){fWk=1./(rpik+1.); fWpi=1.-fWk;return 0;}
59 return pion();
60}
61//-----------------------------------------------------------
23efe5f1 62Int_t AliITSPid::wpikp(Int_t nc,Float_t q)
63{
64 return pion();
65
66 Float_t qmpi,qmk,qmp,sigpi,sigk,sigp,ppi,pka,ppr,rppi,rpka;
67
68 qmpi =cut[nc][1];
69 sigpi=cut[nc][2];
70 qmk =cut[nc][3];
71 sigk =cut[nc][4];
72 qmp =cut[nc][5];
73 sigp =cut[nc][6];
74
75 ppi =TMath::Erf( TMath::Abs((q-qmpi)/sigpi) )+0.5;
76 pka =TMath::Erf( TMath::Abs((q-qmk )/sigk) )+0.5;
77 ppr =TMath::Erf( TMath::Abs((q-qmp )/sigp) )+0.5;
78
79 rppi=ppr/ppi;
80 rpka=ppr/pka;
81 Float_t rp;
82 if( rppi>rpka ) { rp=rpka; }
83 else{ rp=rppi; }
84 if( rp>=1000. ){ return proton(); }
85 if( rp>0.001 ){ fWp=rp/(rp+1.);return proton(); }
86
87 return 0;
88}
89//-----------------------------------------------------------
90Int_t AliITSPid::GetPcode(TClonesArray* rps,Float_t pm)
91{
92 return 0;
93}
94//-----------------------------------------------------------
95Int_t AliITSPid::GetPcode(Float_t q,Float_t pm)
96{
97 fWpi=fWk=fWp=-1.; fPcode=0;
98//1)
99 if ( pm<=cut[1][0] )
100 { return pion(); }
101//2)
102 if ( pm<=cut[2][0] )
103 { if( q<cut[2][2] ){ return pion(); } else { return kaon();} }
104//3)
105 if ( pm<=cut[3][0] )
106 if( q<cut[3][2])
107 { return pion(); }
108 else
109 { if ( q<=cut[3][5] ) {return kaon();} else {return proton();}}
110//4)
111 if ( pm<=cut[4][0] )
112 if( q<cut[4][2] )
113 { return pion(); }
114 else
115 { if( q<=cut[4][4] ) {return kaon();} else {return proton(); }}
116//5)
117 if ( pm<=cut[5][0] )
118 if ( q>cut[5][5] ) {return proton();} else {return wpik(5,q);};
119//6)
120 if ( pm<=cut[6][0] )
121 if ( q>cut[6][5] ) {return proton();} else {return wpik(6,q);};
122//7)
123 if ( pm<=cut[7][0] )
124 if ( q<=cut[7][5] ) {return fPcode;} else {return proton();};
125//8)
126 if ( pm<=cut[8][0] )
127 if ( q<=cut[8][5] ) {return fPcode;} else {return proton();};
128//9)
129 if ( pm<=cut[9][0] )
130 if ( q<=cut[9][5] ) {return fPcode;} else {return proton();};
131//10)
132 if( pm<=cut[10][0] ){ return wpikp(10,q); }
133//11)
134 if( pm<=cut[11][0] ){ return wpikp(11,q); }
135//12)
136 if( pm<=cut[12][0] ){ return wpikp(12,q); }
137
138 return fPcode;
139}
140//-----------------------------------------------------------
141void AliITSPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
142 Float_t klo,Float_t khi,Float_t plo,Float_t phi)
143{
144 cut[n][0]=pm;
145 cut[n][1]=pilo;
146 cut[n][2]=pihi;
147 cut[n][3]=klo;
148 cut[n][4]=khi;
149 cut[n][5]=plo;
150 cut[n][6]=phi;
151 return ;
152}
153//-----------------------------------------------------------
154void AliITSPid::SetVec(Int_t ntrack,TVector info)
155{
156TClonesArray& arr=*trs;
157 new( arr[ntrack] ) TVector(info);
158}
159//-----------------------------------------------------------
160TVector* AliITSPid::GetVec(Int_t ntrack)
161{
162TClonesArray& arr=*trs;
163 return (TVector*)arr[ntrack];
164}
165//-----------------------------------------------------------
166void AliITSPid::SetEdep(Int_t track,Float_t Edep)
167{
168 TVector xx(0,11);
169 if( ((TVector*)trs->At(track))->IsValid() )
170 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
171 Int_t j=(Int_t)xx(0); if(j>4)return;
172 xx(++j)=Edep;xx(0)=j;
173 TClonesArray &arr=*trs;
174 new(arr[track])TVector(xx);
175}
176//-----------------------------------------------------------
177void AliITSPid::SetPmom(Int_t track,Float_t Pmom)
178{
179 TVector xx(0,11);
180 if( ((TVector*)trs->At(track))->IsValid() )
181 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
182 xx(10)=Pmom;
183 TClonesArray &arr=*trs;
184 new(arr[track])TVector(xx);
185}
186//-----------------------------------------------------------
187void AliITSPid::SetPcod(Int_t track,Int_t partcode)
188{
189 TVector xx(0,11);
190 if( ((TVector*)trs->At(track))->IsValid() )
191 {TVector yy( *((TVector*)trs->At(track)) );xx=yy; }
192 if(xx(11)==0)
193 {xx(11)=partcode; mxtrs++;
194 TClonesArray &arr=*trs;
195 new(arr[track])TVector(xx);
196 }
197}
198//-----------------------------------------------------------
199void AliITSPid::Print(Int_t track)
200{cout<<mxtrs<<" tracks in AliITSPid obj."<<endl;
201 if( ((TVector*)trs->At(track))->IsValid() )
202 {TVector xx( *((TVector*)trs->At(track)) );
203 xx.Print();
204 }
205 else
206 {cout<<"No data for track "<<track<<endl;return;}
207}
208//-----------------------------------------------------------
209void AliITSPid::Tab(void)
210{
211if(trs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
212cout<<"------------------------------------------------------------------------"<<endl;
213cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
214 " Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
215cout<<"------------------------------------------------------------------------"<<endl;
216for(Int_t i=0;i<trs->GetEntries();i++)
217{
218 TVector xx( *((TVector*)trs->At(i)) );
219 if( xx.IsValid() && xx(0)>0 )
220 {
221 TVector xx( *((TVector*)trs->At(i)) );
222 if(xx(0)>=2)
223 {
224// 1)Calculate Qtrm
225 xx(6)=(this->qtrm(i));
226
227 }else{
228 xx(6)=xx(1);
229 }
230// 2)Calculate Wpi,Wk,Wp
231 this->GetPcode(xx(6),xx(10)/1000.);
232 xx(7)=GetWpi();
233 xx(8)=GetWk();
234 xx(9)=GetWp();
235// 3)Print table
236 if(xx(0)>0){
237 cout<<xx(0)<<" ";
238 for(Int_t j=1;j<11;j++){
239 cout.width(7);cout.precision(5);cout<<xx(j);
240 }
241 cout<<endl;
242 }
243// 4)Update data in TVector
244 TClonesArray &arr=*trs;
245 new(arr[i])TVector(xx);
246 }
247 else
248 {/*cout<<"No data for track "<<i<<endl;*/}
249}// End loop for tracks
250}
251void AliITSPid::Reset(void)
252{
253 for(Int_t i=0;i<trs->GetEntries();i++){
254 TVector xx(0,11);
255 TClonesArray &arr=*trs;
256 new(arr[i])TVector(xx);
257 }
258}
259//-----------------------------------------------------------
260AliITSPid::AliITSPid(Int_t ntrack)
261{
262 trs = new TClonesArray("TVector",ntrack);
263 TClonesArray &arr=*trs;
264 for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
265 mxtrs=0;
266const int inf=10;
267// Ncut Pmom pilo pihi klo khi plo phi
268// cut[j] [0] [1] [2] [3] [4] [5] [6]
269//----------------------------------------------------------------
270 SetCut( 1, 0.12 , 0. , 0. , inf , inf , inf , inf );
271 SetCut( 2, 0.20 , 0. , 6.0 , 6.0 , inf , inf , inf );
272 SetCut( 3, 0.30 , 0. , 3.5 , 3.5 , 9.0 , 9.0 , inf );
273 SetCut( 4, 0.41 , 0. , 1.9 , 1.9 , 4.0 , 4.0 , inf );
274//----------------------------------------------------------------
275 SetCut( 5, 0.47 , 1. , 0.12, 1.98 , 0.17 , 3.5 , inf );
276 SetCut( 6, 0.53 , 1. , 0.12, 1.75 , 0.16 , 3.0 , inf );
277//----------------------------------------------------------------
278 SetCut( 7, 0.59 , 0. , 0. , 1.18 , 0.125 , 2.7 , inf );
279 SetCut( 8, 0.65 , 0. , 0. , 1.18 , 0.125 , 2.5 , inf );
280 SetCut( 9, 0.73 , 0. , 0. , 0. , 0.125 , 2.0 , inf );
281//----------------------------------------------------------------
282 SetCut( 10, 0.83 , 0. , 0. , 1.25 , 0.13 , 2.14 , 0.20 );
283 SetCut( 11, 0.93 , 0. , 0. , 1.18 , 0.125 , 1.88 , 0.18 );
284 SetCut( 12, 1.03 , 0. , 0. , 1.13 , 0.12 , 1.68 , 0.155);
285}
286//-----------------------------------------------------------
287