17TofCPID * TofCPID::m_pointer = 0;
20 if(!m_pointer) m_pointer =
new TofCPID();
27 m_pars[2]= -0.0733139;
29 m_pars[4]= 0.00145052;
30 m_pars[5]= -1.72471e-06;
31 m_pars[6]= 5.92726e-10;
32 m_pars[7]= -0.0645428;
33 m_pars[8]= -0.00143637;
35 m_pars[10]= 0.0101188;
38 m_pars[13]= -0.443142;
44 for(
int i = 0; i < 5; i++) {
58 std::cout<<
"read tofC"<<std::endl;
59 std::string tofdata_mom_file =
path +
"/share/pidparatof/tofpdata.txt";
60 ifstream inputmomdata(tofdata_mom_file.c_str(),std::ios_base::in);
61 if ( !inputmomdata ) {
62 cout <<
" can not open: " << tofdata_mom_file << endl;
66 std::string tofdata_theta_file =
path +
"/share/pidparatof/tofthetadata.txt";
67 ifstream inputthetadata(tofdata_theta_file.c_str(),std::ios_base::in);
68 if ( !inputthetadata ) {
69 cout <<
" can not open: " << tofdata_theta_file << endl;
73 std::string tofdata_endcap_file =
path +
"/share/pidparatof/tofendcapdata.txt";
74 ifstream inputendcapdata(tofdata_endcap_file.c_str(),std::ios_base::in);
75 if ( !inputendcapdata ) {
76 cout <<
" can not open: " << tofdata_endcap_file << endl;
81 std::string tofmc_mom_file =
path +
"/share/pidparatof/tofpmc.txt";
82 ifstream inputmommc(tofmc_mom_file.c_str(),std::ios_base::in);
84 cout <<
" can not open: " << tofmc_mom_file << endl;
88 std::string tofmc_theta_file =
path +
"/share/pidparatof/tofthetamc.txt";
89 ifstream inputthetamc(tofmc_theta_file.c_str(),std::ios_base::in);
90 if ( !inputthetamc ) {
91 cout <<
" can not open: " << tofmc_theta_file << endl;
95 std::string tofmc_endcap_file =
path +
"/share/pidparatof/tofendcapmc.txt";
96 ifstream inputendcapmc(tofmc_endcap_file.c_str(),std::ios_base::in);
97 if ( !inputendcapmc ) {
98 cout <<
" can not open: " << tofmc_endcap_file << endl;
105 for(
int i=0; i<5; i++)
107 for(
int j=0; j<8; j++)
109 inputthetadata>>m_thetapara[i][j];
113 for(
int i=0; i<5; i++)
115 for(
int j=0; j<12; j++)
117 inputmomdata>>m_momentpara[i][j];
121 for(
int i=0; i<5; i++)
123 for(
int j=0; j<4; j++)
125 inputendcapdata>>m_endcappara[i][j];
131 for(
int i=0; i<5; i++)
133 for(
int j=0; j<8; j++)
135 inputthetamc>>m_thetapara[i][j];
139 for(
int i=0; i<5; i++)
141 for(
int j=0; j<12; j++)
143 inputmommc>>m_momentpara[i][j];
147 for(
int i=0; i<5; i++)
149 for(
int j=0; j<4; j++)
151 inputendcapmc>>m_endcappara[i][j];
181 double ptrk = mdcTrk->
p();
187 SmartRefVector<RecTofTrack> tofTrk = recTrk->
tofTrack();
188 SmartRefVector<RecTofTrack>::iterator it;
190 const std::vector<TTofTrack* >& tofTrk = recTrk->
tofTrack();
191 std::vector<TTofTrack* >::const_iterator it;
195 std::vector<int> tofccount;
197 for(it = tofTrk.begin(); it!=tofTrk.end(); it++,goodtofctrk++) {
198 unsigned int st = (*it)->status();
203 if(hitst->
is_cluster()) tofccount.push_back(goodtofctrk);
206 if(tofccount.size()!=1)
return irc;
207 it = tofTrk.begin()+tofccount[0];
208 double tof = (*it)->tof();
212 double path = ((*it)->path())*10.0;
215 m_zhitc = ((*it)->zrhit())*10;
217 m_mass2 =
ptrk *
ptrk * (1/beta2 -1);
218 if ((m_mass2>20)||(m_mass2<-1))
return irc;
219 if(tof <=0 )
return irc;
220 double chitemp = 99.;
225 for(
int i = 0; i < 5; i++) {
233 double sep = tof - (*it)->texp(i)-(*it)->toffset(i);
238 if(fabs(m_chi[i]) < chitemp) chitemp = fabs(m_chi[i]);
241 if(fabs(ppp) > pdftemp) pdftemp = fabs(ppp);
246 if(fabs(m_chimin) >
chiMinCut())
return irc;
247 for(
int i = 0; i < 5; i++) {
265 double offsetp = 0.0;
266 double offsetc = 0.0;
277 {
if(
ptrk < 0.3) ptemp = 0.3;
278 if(
ptrk > 1.3) ptemp = 1.3;
281 {
if(
ptrk < 0.3) ptemp = 0.3;
282 if(
ptrk > 1.3) ptemp = 1.3;
285 double plog = log(ptemp);
286 double costcos =
cos(costm);
287 offsetp=
mypol5(plog,m_momentpara[0][0],m_momentpara[0][1],m_momentpara[0][2],m_momentpara[0][3],m_momentpara[0][4],m_momentpara[0][5]);
288 sigp=
mypol5(plog,m_momentpara[0][6],m_momentpara[0][7],m_momentpara[0][8],m_momentpara[0][9],m_momentpara[0][10],m_momentpara[0][11]);
291 offsetc=m_endcappara[0][0];
292 sigcos=m_endcappara[0][2];
295 offsetc=m_endcappara[0][1];
296 sigcos=m_endcappara[0][3];
298 if(fabs(costm)<=0.83)
300 offsetc=
mypol3(costcos,m_thetapara[0][0],m_thetapara[0][1],m_thetapara[0][2],m_thetapara[0][3]);
301 sigcos=
mypol3(costcos,m_thetapara[0][4],m_thetapara[0][5],m_thetapara[0][6],m_thetapara[0][7]);
305 offset=offsetc+sigcos*offsetp;
307 offset=offsetp+sigp*offsetc;
315 {
if(
ptrk < 0.3) ptemp = 0.3;
316 if(
ptrk > 1.3) ptemp = 1.3;
319 {
if(
ptrk < 0.3) ptemp = 0.3;
320 if(
ptrk > 1.3) ptemp = 1.3;
323 double plog = log(ptemp);
324 double costcos =
cos(costm);
325 offsetp=
mypol5(plog,m_momentpara[1][0],m_momentpara[1][1],m_momentpara[1][2],m_momentpara[1][3],m_momentpara[1][4],m_momentpara[1][5]);
326 sigp=
mypol5(plog,m_momentpara[1][6],m_momentpara[1][7],m_momentpara[1][8],m_momentpara[1][9],m_momentpara[1][10],m_momentpara[1][11]);
329 offsetc=m_endcappara[1][0];
330 sigcos=m_endcappara[1][2];
333 offsetc=m_endcappara[1][1];
334 sigcos=m_endcappara[1][3];
336 if(fabs(costm)<=0.83)
338 offsetc=
mypol3(costcos,m_thetapara[1][0],m_thetapara[1][1],m_thetapara[1][2],m_thetapara[1][3]);
339 sigcos=
mypol3(costcos,m_thetapara[1][4],m_thetapara[1][5],m_thetapara[1][6],m_thetapara[1][7]);
343 offset=offsetc+sigcos*offsetp;
345 offset=offsetp+sigp*offsetc;
353 {
if(
ptrk < 0.3) ptemp = 0.3;
354 if(
ptrk > 1.6) ptemp = 1.6;
357 {
if(
ptrk < 0.3) ptemp = 0.3;
358 if(
ptrk > 1.6) ptemp = 1.6;
361 double plog = log(ptemp);
362 double costcos =
cos(costm);
363 offsetp=
mypol5(plog,m_momentpara[2][0],m_momentpara[2][1],m_momentpara[2][2],m_momentpara[2][3],m_momentpara[2][4],m_momentpara[2][5]);
364 sigp=
mypol5(plog,m_momentpara[2][6],m_momentpara[2][7],m_momentpara[2][8],m_momentpara[2][9],m_momentpara[2][10],m_momentpara[2][11]);
367 offsetc=m_endcappara[2][0];
368 sigcos=m_endcappara[2][2];
371 offsetc=m_endcappara[2][1];
372 sigcos=m_endcappara[2][3];
374 if(fabs(costm)<=0.83)
376 offsetc=
mypol3(costcos,m_thetapara[2][0],m_thetapara[2][1],m_thetapara[2][2],m_thetapara[2][3]);
377 sigcos=
mypol3(costcos,m_thetapara[2][4],m_thetapara[2][5],m_thetapara[2][6],m_thetapara[2][7]);
381 offset=offsetc+sigcos*offsetp;
383 offset=offsetp+sigp*offsetc;
391 {
if(
ptrk < 0.4) ptemp = 0.4;
392 if(
ptrk > 1.3) ptemp = 1.3;
395 {
if(
ptrk < 0.4) ptemp = 0.4;
396 if(
ptrk > 1.3) ptemp = 1.3;
398 double plog = log(ptemp);
399 double costcos =
cos(costm);
400 offsetp=
mypol5(plog,m_momentpara[3][0],m_momentpara[3][1],m_momentpara[3][2],m_momentpara[3][3],m_momentpara[3][4],m_momentpara[3][5]);
401 sigp=
mypol5(plog,m_momentpara[3][6],m_momentpara[3][7],m_momentpara[3][8],m_momentpara[3][9],m_momentpara[3][10],m_momentpara[3][11]);
404 offsetc=m_endcappara[3][0];
405 sigcos=m_endcappara[3][2];
408 offsetc=m_endcappara[3][1];
409 sigcos=m_endcappara[3][3];
411 if(fabs(costm)<=0.83)
413 offsetc=
mypol3(costcos,m_thetapara[3][0],m_thetapara[3][1],m_thetapara[3][2],m_thetapara[3][3]);
414 sigcos=
mypol3(costcos,m_thetapara[3][4],m_thetapara[3][5],m_thetapara[3][6],m_thetapara[3][7]);
418 offset=offsetc+sigcos*offsetp;
420 offset=offsetp+sigp*offsetc;
428 {
if(
ptrk < 0.5) ptemp = 0.5;
429 if(
ptrk > 1.3) ptemp = 1.3;
432 {
if(
ptrk < 0.5) ptemp = 0.5;
433 if(
ptrk > 1.3) ptemp = 1.3;
435 double plog = log(ptemp);
436 double costcos =
cos(costm);
437 offsetp=
mypol5(plog,m_momentpara[4][0],m_momentpara[4][1],m_momentpara[4][2],m_momentpara[4][3],m_momentpara[4][4],m_momentpara[4][5]);
438 sigp=
mypol5(plog,m_momentpara[4][6],m_momentpara[4][7],m_momentpara[4][8],m_momentpara[4][9],m_momentpara[4][10],m_momentpara[4][11]);
441 offsetc=m_endcappara[4][0];
442 sigcos=m_endcappara[4][2];
445 offsetc=m_endcappara[4][1];
446 sigcos=m_endcappara[4][3];
448 if(fabs(costm)<=0.83)
450 offsetc=
mypol3(costcos,m_thetapara[4][0],m_thetapara[4][1],m_thetapara[4][2],m_thetapara[4][3]);
451 sigcos=
mypol3(costcos,m_thetapara[4][4],m_thetapara[4][5],m_thetapara[4][6],m_thetapara[4][7]);
454 offset=offsetc+sigcos*offsetp;
456 offset=offsetp+sigp*offsetc;
482 {
if(
ptrk < 0.3) ptemp = 0.3;
483 if(
ptrk > 1.3) ptemp = 1.3;
486 {
if(
ptrk < 0.3) ptemp = 0.3;
487 if(
ptrk > 1.3) ptemp = 1.3;
490 double plog = log(ptemp);
491 double costcos =
cos(costm);
493 sigmap=
mypol5(plog,m_momentpara[0][6],m_momentpara[0][7],m_momentpara[0][8],m_momentpara[0][9],m_momentpara[0][10],m_momentpara[0][11]);
496 sigmac=m_endcappara[0][2];
499 sigmac=m_endcappara[0][3];
503 sigmac=
mypol3(costcos,m_thetapara[0][4],m_thetapara[0][5],m_thetapara[0][6],m_thetapara[0][7]);
515 {
if(
ptrk < 0.3) ptemp = 0.3;
516 if(
ptrk > 1.3) ptemp = 1.3;
519 {
if(
ptrk < 0.3) ptemp = 0.3;
520 if(
ptrk > 1.3) ptemp = 1.3;
523 double plog = log(ptemp);
524 double costcos =
cos(costm);
526 sigmap=
mypol5(plog,m_momentpara[1][6],m_momentpara[1][7],m_momentpara[1][8],m_momentpara[1][9],m_momentpara[1][10],m_momentpara[1][11]);
529 sigmac=m_endcappara[1][2];
532 sigmac=m_endcappara[1][3];
536 sigmac=
mypol3(costcos,m_thetapara[1][4],m_thetapara[1][5],m_thetapara[1][6],m_thetapara[1][7]);
549 {
if(
ptrk < 0.3) ptemp = 0.3;
550 if(
ptrk > 1.6) ptemp = 1.6;
553 {
if(
ptrk < 0.3) ptemp = 0.3;
554 if(
ptrk > 1.6) ptemp = 1.6;
557 double plog = log(ptemp);
558 double costcos =
cos(costm);
559 sigmap=
mypol5(plog,m_momentpara[2][6],m_momentpara[2][7],m_momentpara[2][8],m_momentpara[2][9],m_momentpara[2][10],m_momentpara[2][11]);
562 sigmac=m_endcappara[2][2];
565 sigmac=m_endcappara[2][3];
569 sigmac=
mypol3(costcos,m_thetapara[2][4],m_thetapara[2][5],m_thetapara[2][6],m_thetapara[2][7]);
583 {
if(
ptrk < 0.4) ptemp = 0.4;
584 if(
ptrk > 1.3) ptemp = 1.3;
587 {
if(
ptrk < 0.4) ptemp = 0.4;
588 if(
ptrk > 1.3) ptemp = 1.3;
590 double plog = log(ptemp);
591 double costcos =
cos(costm);
592 sigmap=
mypol5(plog,m_momentpara[3][6],m_momentpara[3][7],m_momentpara[3][8],m_momentpara[3][9],m_momentpara[3][10],m_momentpara[3][11]);
595 sigmac=m_endcappara[3][2];
598 sigmac=m_endcappara[3][3];
602 sigmac=
mypol3(costcos,m_thetapara[3][4],m_thetapara[3][5],m_thetapara[3][6],m_thetapara[3][7]);
615 {
if(
ptrk < 0.5) ptemp = 0.5;
616 if(
ptrk > 1.3) ptemp = 1.3;
619 {
if(
ptrk < 0.5) ptemp = 0.5;
620 if(
ptrk > 1.3) ptemp = 1.3;
622 double plog = log(ptemp);
623 double costcos =
cos(costm);
624 sigmap=
mypol5(plog,m_momentpara[4][6],m_momentpara[4][7],m_momentpara[4][8],m_momentpara[4][9],m_momentpara[4][10],m_momentpara[4][11]);
627 sigmac=m_endcappara[4][2];
630 sigmac=m_endcappara[4][3];
634 sigmac=
mypol3(costcos,m_thetapara[4][4],m_thetapara[4][5],m_thetapara[4][6],m_thetapara[4][7]);
654 return par0 + (par1 *
y) +(par2 *
y *
y) + (par3 *
y *
y *
y);
658double TofCPID::mypol5(
double x,
double par0,
double par1,
double par2,
double par3,
double par4,
double par5)
661 return par0 + (par1 *
y) +(par2 *
y *
y) + (par3 *
y *
y *
y) + (par4 *
y *
y *
y *
y)+ (par5 *
y *
y *
y *
y *
y);
double cos(const BesAngle a)
const double theta() const
SmartRefVector< RecTofTrack > tofTrack()
EvtRecTrack * PidTrk() const
double probCalculate(double chi2, int n)
double pdfCalculate(double offset, double sigma)
double pdfMinSigmaCut() const
int particleIDCalculation()
double mypol3(double x, double par0, double par1, double par2, double par3)
double mypol5(double x, double par0, double par1, double par2, double par3, double par4, double par5)
static TofCPID * instance()
double offsetTofC(int n, double ptrk, double cost)
double offset(int n) const
double sigmaTofC(int n, double ptrk, double cost)
void setStatus(unsigned int status)