347{
348 const int par_cand( 5 );
349 const float Charge_Mass[par_cand] = {0.00051100, 0.10566, 0.13957, 0.4937, 0.93827 };
350 double beta_G, beta, betterm, bethe_B;
351
352 int dedxflag =
vflag[0];
353 int sigmaflag =
vflag[1];
354 bool ifMC = false;
355 if(
vflag[2] == 1) ifMC =
true;
356
357 int Nmax_prob(0);
358 float max_prob(-0.01);
359 int ndf;
360 float chi2;
361
362 for( int it = 0; it < par_cand; it++ ) {
363 beta_G = mom/Charge_Mass[it];
364
365 if(dedxflag == 1){
366 beta = beta_G/sqrt(1+(beta_G)*(beta_G));
367 betterm = par[1]-log(par[2]+pow(1/beta_G,par[4]));
368 bethe_B = par[0]/pow(beta,par[3])*betterm-par[0];
369 }
370 else if(dedxflag == 2) {
373 if(x<4.5)
375 else if(x<10)
377 else
379 double partA = par[0]*pow(sqrt(x*x+1),par[2])/pow(x,par[2])*(par[1]-par[5]*log(pow(1/x,par[3])) ) - par[4]+
exp(par[6]+par[7]*x);
380 double partB = par[8]*pow(x,3)+par[9]*pow(x,2)+par[10]*
x+par[11];
381 double partC = -par[12]*log(par[15]+pow(1/x,par[13]))+par[14];
382 bethe_B = 550*(
A*partA+
B*partB+
C*partC);
383
384 if(beta_G> 100) bethe_B=550*1.0;
385 }
386
387 if (ifMC) {
390 if(x<4.5)
392 else if(x<10)
394 else
396 double partA = par[0]*pow(sqrt(x*x+1),par[2])/pow(x,par[2])*(par[1]-par[5]*log(pow(1/x,par[3])) ) - par[4]+
exp(par[6]+par[7]*x);
397 double partB = par[8]*pow(x,3)+par[9]*pow(x,2)+par[10]*
x+par[11];
398 double partC = -par[12]*log(par[15]+pow(1/x,par[13]))+par[14];
399 bethe_B = 550*(
A*partA+
B*partB+
C*partC);
400
401 if(beta_G> 100) bethe_B=550*1.0;
402 }
403
404
405 if (Nohit > 0) {
406 dedx_exp[it] = bethe_B;
407 double sig_the = std::sin((double)theta);
408 double f_betagamma, g_sinth, h_nhit, i_t0;
409
410 if (ifMC) {
411
412 if(sigmaflag == 6) {
413
414 double nhit = (double)Nohit;
415 double sigma_bg=1.0;
416 double ndedx=bethe_B/550;
417 sigma_bg= sig_par[0]+sig_par[1]*ndedx+sig_par[2]*ndedx*ndedx;
418
419 double cor_nhit = 1.0;
420 if (nhit < 5) nhit = 5;
421 if (nhit <= 35)
422 cor_nhit = sig_par[3]*pow(nhit,4)+sig_par[4]*pow(nhit,3)+sig_par[5]*pow(nhit,2) +
423 sig_par[6]*nhit+sig_par[7];
424
425 double cor_sin= 1.0;
426 if(sig_the>0.99) sig_the=0.99;
427 cor_sin = sig_par[8]*pow(sig_the,4)+sig_par[9]*pow(sig_the,3) +
428 sig_par[10]*pow(sig_the,2)+sig_par[11]*sig_the+sig_par[12];
429
430
431 double cor_t0 = 1.0;
432
433
434 if (trkalg == 1)
435 ex_sigma[it] = 550 * sigma_bg * cor_nhit * cor_sin * cor_t0;
436 else
437 ex_sigma[it] = 550 * sigma_bg * cor_nhit * cor_sin * cor_t0 * sig_par[13];
438
439 }
440
441 else{
443 double nhit = (double)Nohit;
444 double sigma_bg=1.0;
445
446 if (x > 0.3)
447 sigma_bg = sig_par[0]*
exp(sig_par[1]*x)+sig_par[2]*
exp(sig_par[3]*pow(x,0.25))+sig_par[4];
448 else
449 sigma_bg = sig_par[5]*
exp(sig_par[6]*x)+ sig_par[7];
450
451
452 double cor_nhit = 1.0;
453 if (nhit < 5) nhit = 5;
454 if (nhit <= 35)
455 cor_nhit = sig_par[8]*pow(nhit,4)+sig_par[9]*pow(nhit,3)+sig_par[10]*pow(nhit,2) +
456 sig_par[11]*nhit+sig_par[12];
457
458 double cor_sin= 1.0;
459 if(sig_the>0.99) sig_the=0.99;
460 cor_sin = sig_par[13]*pow(sig_the,4)+sig_par[14]*pow(sig_the,3) +
461 sig_par[15]*pow(sig_the,2)+sig_par[16]*sig_the+sig_par[17];
462
463
464 double cor_t0 = 1.0;
465
466
467 if (trkalg == 1)
468 ex_sigma[it] = 550 * sigma_bg * cor_nhit * cor_sin * cor_t0;
469 else
470 ex_sigma[it] = 550 * sigma_bg * cor_nhit * cor_sin * cor_t0 * sig_par[18];
471
472 }
473 }
474 else {
475 if(sigmaflag == 1) {
476 f_betagamma=sig_par[0]*pow(beta_G,sig_par[1])+sig_par[2];
477 g_sinth=(sig_par[3]*sig_the*sig_the+sig_par[4])/(sig_par[3]*sig_par[5]*sig_par[5]+sig_par[4]);
478 h_nhit=(sig_par[6]*Nohit*Nohit+sig_par[7]*Nohit+sig_par[8]) /
479 (sig_par[6]*sig_par[9]*sig_par[9]+sig_par[7]*sig_par[9]+sig_par[8]);
480 if(sig_par[13] != 0)
481 i_t0 = (sig_par[10]*t0*t0+sig_par[11]*t0+sig_par[12]) /
482 (sig_par[10]*sig_par[13]*sig_par[13]+sig_par[11]*sig_par[13]+sig_par[12]);
483 else if(sig_par[13] == 0)
484 i_t0 =1;
485
486
487 ex_sigma[it]= f_betagamma* g_sinth * h_nhit * i_t0;
488 }
489 else if(sigmaflag == 2) {
491 double nhit = (double)Nohit;
492 double sigma_bg=1.0;
493 if (x > 0.3)
494 sigma_bg = sig_par[0]*
exp(sig_par[1]*x)+sig_par[2]*
exp(sig_par[3]*pow(x,0.25))+sig_par[4];
495 else
496 sigma_bg = sig_par[5]*
exp(sig_par[6]*x)+ sig_par[7];
497
498 double cor_nhit=1.0;
499 if(nhit<5) nhit=5;
500 if (nhit <= 35)
501 cor_nhit = sig_par[8]*pow(nhit,4)+sig_par[9]*pow(nhit,3)+sig_par[10]*pow(nhit,2) + sig_par[11]*nhit+sig_par[12];
502
503 double cor_sin= 1.0;
504 if(sig_the>0.99) sig_the = 0.99;
505 cor_sin = sig_par[13]*pow(sig_the,4)+sig_par[14]*pow(sig_the,3) +
506 sig_par[15]*pow(sig_the,2)+sig_par[16]*sig_the+sig_par[17];
507
508 double cor_t0 = 1;
509 if (t0 > 1200) t0 = 1200;
510 if (t0 > 800)
511 cor_t0 = sig_par[18]*pow(t0,2)+sig_par[19]*t0+sig_par[20];
512
513 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*cor_t0;
514 }
515 else if(sigmaflag == 3) {
517 double nhit = (double)Nohit;
518 double sigma_bg=1.0;
519 if (x > 0.3)
520 sigma_bg = sig_par[0]*
exp(sig_par[1]*x)+sig_par[2]*
exp(sig_par[3]*pow(x,0.25))+sig_par[4];
521 else
522 sigma_bg = sig_par[5]*
exp(sig_par[6]*x)+ sig_par[7];
523
524 double cor_nhit = 1.0;
525 if (nhit < 5) nhit = 5;
526 if (nhit <= 35)
527 cor_nhit = sig_par[8]*pow(nhit,4)+sig_par[9]*pow(nhit,3)+sig_par[10]*pow(nhit,2) + sig_par[11]*nhit+sig_par[12];
528
529 double cor_sin= 1.0;
530 if(sig_the>0.99) sig_the=0.99;
531 cor_sin = sig_par[13]*pow(sig_the,4)+sig_par[14]*pow(sig_the,3) +
532 sig_par[15]*pow(sig_the,2)+sig_par[16]*sig_the+sig_par[17];
533
534 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin;
535 }
536 else if(sigmaflag == 4) {
538 double nhit = (double)Nohit;
539 double sigma_bg=1.0;
540 if (x > 0.3)
541 sigma_bg = sig_par[0]*
exp(sig_par[1]*x)+sig_par[2]*
exp(sig_par[3]*pow(x,0.25))+sig_par[4];
542 else
543 sigma_bg = sig_par[5]*
exp(sig_par[6]*x)+ sig_par[7];
544
545 double cor_nhit = 1.0;
546 if (nhit < 5) nhit = 5;
547 if (nhit <= 35)
548 cor_nhit = sig_par[8]*pow(nhit,4)+sig_par[9]*pow(nhit,3)+sig_par[10]*pow(nhit,2) + sig_par[11]*nhit+sig_par[12];
549
550 double cor_sin= 1.0;
551 if(sig_the>0.99) sig_the=0.99;
552 cor_sin = sig_par[13]*pow(sig_the,4)+sig_par[14]*pow(sig_the,3) +
553 sig_par[15]*pow(sig_the,2)+sig_par[16]*sig_the+sig_par[17];
554
555 if(trkalg==1)
556 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin;
557 else
558 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*sig_par[18];
559 }
560 else if(sigmaflag == 5) {
562 double nhit = (double)Nohit;
563 double sigma_bg=1.0;
564 if (x > 0.3)
565 sigma_bg = sig_par[0]*
exp(sig_par[1]*x)+sig_par[2]*
exp(sig_par[3]*pow(x,0.25))+sig_par[4];
566 else
567 sigma_bg = sig_par[5]*
exp(sig_par[6]*x)+ sig_par[7];
568
569 double cor_nhit=1.0;
570 if(nhit<5) nhit=5;
571 if (nhit <= 35)
572 cor_nhit = sig_par[8]*pow(nhit,4)+sig_par[9]*pow(nhit,3)+sig_par[10]*pow(nhit,2) +
573 sig_par[11]*nhit+sig_par[12];
574 double cor_sin= 1.0;
575 if(sig_the>0.99) sig_the = 0.99;
576 cor_sin = sig_par[13]*pow(sig_the,4)+sig_par[14]*pow(sig_the,3) +
577 sig_par[15]*pow(sig_the,2)+sig_par[16]*sig_the+sig_par[17];
578
579 double cor_t0 = 1;
580 if (t0 > 1200) t0 = 1200;
581 if (t0 > 800)
582 cor_t0 = sig_par[18]*pow(t0,2)+sig_par[19]*t0+sig_par[20];
583
584 if(trkalg==1)
585 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*cor_t0;
586 else
587 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*cor_t0*sig_par[21];
588 }
589 else if(sigmaflag == 6) {
590 double x= bethe_B/550;
591 double nhit = (double)Nohit;
592 double sigma_bg=1.0;
593
594 sigma_bg= sig_par[0]+sig_par[1]*
x+sig_par[2]*
x*
x;
595
596 double cor_nhit = 1.0;
597 if (nhit < 5) nhit = 5;
598 if (nhit <= 35)
599 cor_nhit = sig_par[3]*pow(nhit,4)+sig_par[4]*pow(nhit,3)+sig_par[5]*pow(nhit,2) + sig_par[6]*nhit+sig_par[7];
600
601 double cor_sin= 1.0;
602 if(sig_the>0.99) sig_the=0.99;
603 cor_sin = sig_par[8]*pow(sig_the,4)+sig_par[9]*pow(sig_the,3) +
604 sig_par[10]*pow(sig_the,2)+sig_par[11]*sig_the+sig_par[12];
605
606 if(trkalg==1)
607 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin;
608 else
609 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*sig_par[13];
610 }
611 else if(sigmaflag == 7) {
612 double x= bethe_B/550;
613 double nhit = (double)Nohit;
614 double sigma_bg=1.0;
615
616 sigma_bg= sig_par[0]+sig_par[1]*
x+sig_par[2]*
x*
x;
617
618
619 double cor_nhit=1.0;
620 if(nhit<5) nhit=5;
621 if (nhit <= 35)
622 cor_nhit = sig_par[3]*pow(nhit,4)+sig_par[4]*pow(nhit,3)+sig_par[5]*pow(nhit,2) +
623 sig_par[6]*nhit+sig_par[7];
624 double cor_sin= 1.0;
625 if(sig_the>0.99) sig_the = 0.99;
626 cor_sin = sig_par[8]*pow(sig_the,4)+sig_par[9]*pow(sig_the,3) +
627 sig_par[10]*pow(sig_the,2)+sig_par[11]*sig_the+sig_par[12];
628
629 double cor_t0 = 1;
630 if (t0 > 1200) t0 = 1200;
631 if (t0 > 800)
632 cor_t0 = sig_par[13]*pow(t0,2)+sig_par[14]*t0+sig_par[15];
633
634 if(trkalg==1)
635 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*cor_t0;
636 else
637 ex_sigma[it]=550*sigma_bg*cor_nhit*cor_sin*cor_t0*sig_par[16];
638 }
639 }
640
641 double dedx_correc = dedx;
642 chi_dedx[it] = (dedx_correc - dedx_exp[it])/ex_sigma[it];
643 chi2 = chi_dedx[it]*chi_dedx[it];
644 ndf=1;
645 pid_prob[it] = 0.0;
646
647
648 if (it == -999) {
649 std::cout << " mom = " << mom <<"exp"<< dedx_exp[it]
650 << " sigma "<<ex_sigma[it] <<" prob "<<pid_prob[it]
651 << std::endl;
652 }
653 if( pid_prob[it] > max_prob ){
654 max_prob = pid_prob[it];
655 Nmax_prob = it;
656 }
657 }
658 else{
659 dedx_exp[it] = 0.0;
660 ex_sigma[it] = 1000.0;
661 pid_prob[it] = 0.0;
662 chi_dedx[it] = 999.0;
663 }
664 }
665
666}