3#include "KalFitAlg/helix/Helix.h"
4#include "KalFitAlg/KalFitWire.h"
5#include "KalFitAlg/KalFitTrack.h"
6#include "KalFitAlg/KalFitMaterial.h"
7#include "KalFitAlg/KalFitElement.h"
8#include "KalFitAlg/KalFitCylinder.h"
9#include "MdcGeomSvc/MdcGeomSvc.h"
10#include "GaudiKernel/Bootstrap.h"
11#include "CLHEP/Matrix/Vector.h"
12#include "CLHEP/Matrix/Matrix.h"
13#include "CLHEP/Matrix/SymMatrix.h"
14#include "CLHEP/Vector/ThreeVector.h"
15#include "CLHEP/Units/PhysicalConstants.h"
16#include "Math/Point3Dfwd.h"
17#include "Math/Point3D.h"
18#include "Math/Vector3D.h"
20using namespace ROOT::Math;
43int KalFitTrack::lead_ = 2;
44int KalFitTrack::back_ = 1;
64const double KalFitTrack::MASS[NMASS] = { 0.000510999,
83 const HepSymMatrix& Ea,
84 unsigned int m,
double chisq,
unsigned int nhits)
85:
Helix(pivot, a, Ea), type_(0), insist_(0), chiSq_(0),
86 nchits_(0), nster_(0), ncath_(0),
87 ndf_back_(0), chiSq_back_(0), pathip_(0),
88 path_rd_(0), path_ab_(0), tof_(0), dchi2_max_(0), r_max_(0),
89 tof_kaon_(0), tof_proton_(0), pat1_(0), pat2_(0), layer_prec_(0),
90 trasan_id_(0), nhit_r_(0), nhit_z_(0),pathSM_(0),tof2_(0)
92 memset(PathL_, 0,
sizeof(PathL_));
94 if (m < NMASS) mass_ = MASS[m];
96 r0_ = fabs(center().perp() - fabs(radius()));
111 pivot_last_ =
pivot();
118 pivot_forMdc_ =
pivot();
126 double l =
center().perp();
128 double cosPhi = (m_rad * m_rad + l * l - r * r) / (2 * m_rad * l);
130 if(cosPhi < -1 || cosPhi > 1)
return 0;
132 double dPhi =
center().phi() - acos(cosPhi) -
phi0();
144 double d = r * r - (y - xc.y()) * (y - xc.y());
148 if(xx > 0) xx -= sqrt(d);
151 double l = (plane.inverse() *
162 double d = r * r - (
x - xc.x()) * (
x - xc.x());
166 if(yy > 0) yy -= sqrt(d);
169 double l = (plane.inverse() *
185 HepSymMatrix ea =
Ea();
194 double pmag = 1 / fabs(k) * sqrt(pt2);
195 double dth = material.
mcs_angle(mass_, path, pmag);
196 double dth2 = dth * dth;
197 double pt2dth2 = pt2 * dth2;
200 ea[2][2] += k2 * t2 * dth2;
201 ea[2][4] += k *
t * pt2dth2;
202 ea[4][4] += pt2 * pt2dth2;
204 ea[3][3] += dth2 * path * path /3 / (1 + t2);
205 ea[3][4] += dth2 * path/2 * sqrt(1 + t2);
206 ea[3][2] += dth2 *
t / sqrt(1 + t2) * k * path/2;
207 ea[0][0] += dth2 * path * path/3;
208 ea[0][1] += dth2 * sqrt(1 + t2) * path/2;
214 double x0 = material.
X0();
215 if (x0) path_rd_ += path/x0;
226 double pmag = ( 1 / fabs(k) ) * sqrt(1 + t2);
227 double psq = pmag*pmag;
237 double dth = 0.0136* sqrt(pathx * (mass_*mass_ + psq))/psq
238 *(1 + 0.038 * log(pathx));;
239 HepSymMatrix ea =
Ea();
241 cout<<
"msgasmdc():path "<<path<<
" pathx "<<pathx<<endl;
242 cout<<
"msgasmdc():dth "<<dth<<endl;
243 cout<<
"msgasmdc():ea before: "<<ea<<endl;
245 double dth2 = dth * dth;
247 ea[1][1] += (1 + t2) * dth2;
248 ea[2][2] += k2 * t2 * dth2;
249 ea[2][4] += k *
t * (1 + t2) * dth2;
250 ea[4][4] += (1 + t2) * (1 + t2) * dth2;
254 ea[3][3] += dth2 * path * path /3 / (1 + t2);
255 ea[3][4] += dth2 * path/2 * sqrt(1 + t2);
256 ea[3][2] += dth2 *
t / sqrt(1 + t2) * k * path/2;
257 ea[0][0] += dth2 * path * path/3;
258 ea[0][1] += dth2 * sqrt(1 + t2) * path/2;
262 cout<<
"msgasmdc():ea after: "<<
Ea()<<endl;
271 cout<<
"ms...pathip..."<<pathip_<<endl;
280 cout<<
"eloss():ea before: "<<
Ea()<<endl;
283 double v_a_2_2 = v_a[2] * v_a[2];
284 double v_a_4_2 = v_a[4] * v_a[4];
285 double pmag = 1 / fabs(v_a[2]) * sqrt(1 + v_a_4_2);
286 double psq = pmag * pmag;
287 double E = sqrt(mass_ * mass_ + psq);
288 double dE = material.
dE(mass_, path, pmag);
292 psq += dE * (dE + 2 * sqrt(mass_ * mass_ + psq));
294 double dE_max = E - mass_;
295 if( dE<dE_max ) psq += dE * (dE - 2 * sqrt(mass_ * mass_ + psq));
302 double psq_kaon = p_kaon_ * p_kaon_;
303 double dE_kaon = material.
dE(MASS[3], path, p_kaon_);
304 psq_kaon += dE_kaon * (dE_kaon -
305 2 * sqrt(MASS[3] * MASS[3] + psq_kaon));
306 if (psq_kaon < 0) psq_kaon = 0;
307 p_kaon_ = sqrt(psq_kaon);
311 double psq_proton = p_proton_ * p_proton_;
312 double dE_proton = material.
dE(MASS[4], path, p_proton_);
313 psq_proton += dE_proton * (dE_proton -
314 2 * sqrt(MASS[4] * MASS[4] + psq_proton));
315 if (psq_proton < 0) psq_proton = 0;
316 p_proton_ = sqrt(psq_proton);
322 if(psq < 0) dpt = 9999;
323 else dpt = v_a[2] * pmag / sqrt(psq);
326 cout<<
"eloss():k: "<<v_a[2]<<
" k' "<<dpt<<endl;
330 HepSymMatrix ea =
Ea();
331 double r_E_prim = (E + dE)/E;
339 del_E = material.
del_E(mass_, path, pmag);
342 ea[2][2] += (v_a[2] * v_a[2]) * E * E * del_E * del_E / (psq*psq);
346 double dpt2 = dpt*dpt;
347 double A = dpt*dpt2/(v_a_2_2*v_a[2])*r_E_prim;
348 double B = v_a[4]/(1+v_a_4_2)*
349 dpt*(1-dpt2/v_a_2_2*r_E_prim);
351 double ea_2_0 = A*ea[2][0] + B*ea[4][0];
352 double ea_2_1 = A*ea[2][1] + B*ea[4][1];
353 double ea_2_2 = A*A*ea[2][2] + 2*A*B*ea[2][4] + B*B*ea[4][4];
354 double ea_2_3 = A*ea[2][3] + B*ea[4][3];
355 double ea_2_4 = A*ea[2][4] + B*ea[4][4];
377 unsigned int nhit = HitsMdc_.size();
380 double* Rad =
new double[nhit];
381 double* Ypos =
new double[nhit];
382 for(
unsigned i=0 ; i < nhit; i++ ){
386 Hep3Vector wire = (CLHEP::Hep3Vector)fwd -(CLHEP::Hep3Vector)bck;
389 Helix work = tracktest;
391 work.
pivot((fwd + bck) * .5);
393 / wire.z() * wire + bck;
396 Rad[ind] = tracktest.
x(0).perp();
404 for(
int j, k = nhit - 1; k >= 0; k = j){
406 for(
int i = 1; i <= k; i++)
407 if(Rad[i - 1] > Rad[i]){
409 std::swap(Rad[i], Rad[j]);
410 std::swap(HitsMdc_[i], HitsMdc_[j]);
414 for(
int j, k = nhit - 1; k >= 0; k = j){
416 for(
int i = 1; i <= k; i++)
417 if(Rad[i - 1] < Rad[i]){
419 std::swap(Rad[i], Rad[j]);
420 std::swap(HitsMdc_[i], HitsMdc_[j]);
424 for(
int j, k = nhit - 1; k >= 0; k = j){
426 for(
int i = 1; i <= k; i++)
427 if(Ypos[i - 1] > Ypos[i]){
429 std::swap(Ypos[i], Ypos[j]);
430 std::swap(HitsMdc_[i], HitsMdc_[j]);
438 for(
int it=0; it<
HitsMdc().size()-1; it++){
439 if(HitsMdc_[it].wire().layer().layerId() == HitsMdc_[it+1].wire().layer().layerId())
441 if((
kappa()<0)&&(HitsMdc_[it].wire().localId() > HitsMdc_[it+1].wire().localId())){
442 std::swap(HitsMdc_[it], HitsMdc_[it+1]);
444 if((
kappa()>0)&&(HitsMdc_[it].wire().localId() < HitsMdc_[it+1].wire().localId())){
445 std::swap(HitsMdc_[it], HitsMdc_[it+1]);
454 unsigned int nhit = HitsMdc_.size();
456 for(
unsigned i=0 ; i < nhit; i++ )
457 Num[HitsMdc_[i].wire().layer().layerId()]++;
458 for(
unsigned i=0 ; i < nhit; i++ )
459 if (Num[HitsMdc_[i].wire().layer().layerId()]>2)
460 HitsMdc_[i].chi2(-2);
472 if (wire_ID<0 || wire_ID>6796){
473 std::cout <<
"KalFitTrack : wire_ID problem : " << wire_ID << std::endl;
483 double csf0 =
cos(phi);
484 double snf0 = (1. - csf0) * (1. + csf0);
485 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
486 if(phi >
M_PI) snf0 = - snf0;
489 Hep3Vector ip(0, 0, 0);
493 double phi_ip = work.
phi0();
494 if (fabs(phi - phi_ip) >
M_PI) {
495 if (phi > phi_ip) phi -= 2 *
M_PI;
496 else phi_ip -= 2 *
M_PI;
499 double l = fabs(
radius() * (phi - phi_ip) * sqrt(1 +
t *
t));
500 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
501 double mass_over_p( mass_ / pmag );
502 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
503 tofest = l / ( 29.9792458 * beta );
504 if(csmflag==1 &&
HitMdc.
wire().
y()>0.) tofest= -1. * tofest;
507 const HepSymMatrix& ea =
Ea();
508 const HepVector& v_a =
a();
512 double dchi2R(99999999), dchi2L(99999999);
515 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
517 HepMatrix v_HT = v_H.T();
519 double estim = (v_HT * v_a)[0];
520 HepVector ea_v_H = ea * v_H;
521 HepMatrix ea_v_HT = (ea_v_H).T();
522 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
524 HepSymMatrix eaNew(5);
546 double dmeas2[2] = { 0.1*ddl, 0.1*ddr };
547 double er_dmeas2[2] = {0. , 0.};
549 er_dmeas2[0] = 0.1*erddl;
550 er_dmeas2[1] = 0.1*erddr;
560 double er_dmeasL, dmeasL;
562 dmeasL = (-1.0)*dmeas2[0];
563 er_dmeasL = er_dmeas2[0];
569 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
570 eaNew.assign(ea - ea_v_H * AL * ea_v_HT);
571 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
572 if(0. == RkL) RkL = 1.e-4;
574 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
576 double sigL = (dmeasL - (v_HT * aNew)[0]);
577 dchi2L = (sigL*sigL) / (RkL * er_dmeasL*er_dmeasL);
578 }
else if (lr == 1) {
581 double er_dmeasR, dmeasR;
584 er_dmeasR = er_dmeas2[1];
591 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
592 eaNew.assign(ea - ea_v_H * AR * ea_v_HT);
593 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
594 if(0. == RkR) RkR = 1.e-4;
596 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
598 double sigR = (dmeasR- (v_HT * aNew)[0]);
599 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
604 cout<<
"in smoother_Mdc: lr= "<<lr<<
" a: "<<v_a<<
" a_NEW: "<<aNew<<endl;
611 if ( !( aNew[2] && fabs(aNew[2]-
a()[2]) < 1.0 ) ) chge=0;
613 chiSq_back_ += dchi2R;
616 }
else if (lr == -1) {
617 chiSq_back_ += dchi2L;
631 Hep3Vector ip(0, 0, 0);
634 HepVector a_temp1 = helixNew1.a();
635 HepSymMatrix ea_temp1 = helixNew1.Ea();
641 KalFitTrack helixNew2(pivot_work, v_a, ea, 0, 0, 0);
643 HepVector a_temp2 = helixNew2.a();
644 HepSymMatrix ea_temp2 = helixNew2.Ea();
668 int layerid = (*HitMdc).wire().layer().layerId();
672 if (wire_ID<0 || wire_ID>6796){
673 std::cout <<
"KalFitTrack : wire_ID problem : " << wire_ID << std::endl;
682 double csf0 =
cos(phi);
683 double snf0 = (1. - csf0) * (1. + csf0);
684 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
685 if(phi >
M_PI) snf0 = - snf0;
688 Hep3Vector ip(0, 0, 0);
692 double phi_ip = work.
phi0();
693 if (fabs(phi - phi_ip) >
M_PI) {
694 if (phi > phi_ip) phi -= 2 *
M_PI;
695 else phi_ip -= 2 *
M_PI;
698 double l = fabs(
radius() * (phi - phi_ip) * sqrt(1 +
t *
t));
699 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
700 double mass_over_p( mass_ / pmag );
701 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
702 tofest = l / ( 29.9792458 * beta );
703 if(csmflag==1 && (*HitMdc).wire().y()>0.) tofest= -1. * tofest;
706 const HepSymMatrix& ea =
Ea();
707 const HepVector& v_a =
a();
730 double dchi2R(99999999), dchi2L(99999999);
732 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
734 HepMatrix v_HT = v_H.T();
736 double estim = (v_HT * v_a)[0];
737 HepVector ea_v_H = ea * v_H;
738 HepMatrix ea_v_HT = (ea_v_H).T();
739 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
740 HepSymMatrix eaNew(5);
742 double time = (*HitMdc).tdc();
760 double dmeas2[2] = { 0.1*ddl, 0.1*ddr };
761 double er_dmeas2[2] = {0., 0.};
763 er_dmeas2[0] = 0.1*erddl;
764 er_dmeas2[1] = 0.1*erddr;
771 double er_dmeasL, dmeasL;
773 dmeasL = (-1.0)*dmeas2[0];
774 er_dmeasL = er_dmeas2[0];
776 dmeasL = (-1.0)*fabs((*HitMdc).dist()[0]);
777 er_dmeasL = (*HitMdc).erdist()[0];
783 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
784 eaNew.assign(ea - ea_v_H * AL * ea_v_HT);
785 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
786 if(0. == RkL) RkL = 1.e-4;
788 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
790 double sigL = (dmeasL - (v_HT * aNew)[0]);
791 dchi2L = (sigL*sigL) / (RkL * er_dmeasL*er_dmeasL);
792 }
else if (lr == 1) {
795 double er_dmeasR, dmeasR;
798 er_dmeasR = er_dmeas2[1];
800 dmeasR = fabs((*HitMdc).dist()[1]);
801 er_dmeasR = (*HitMdc).erdist()[1];
808 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
809 eaNew.assign(ea - ea_v_H * AR * ea_v_HT);
810 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
811 if(0. == RkR) RkR = 1.e-4;
813 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
815 double sigR = (dmeasR- (v_HT * aNew)[0]);
816 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
821 cout<<
"in smoother_Mdc: lr= "<<lr<<
" a: "<<v_a<<
" a_NEW: "<<aNew<<endl;
830 if (!(aNew[2] && fabs(aNew[2]-
a()[2]) < 1.0)) chge = 0;
832 chiSq_back_ += dchi2R;
837 }
else if (lr == -1) {
838 chiSq_back_ += dchi2L;
851 HepVector a_pre_fwd_temp=seg.
a_pre_fwd();
852 if( (a_pre_fwd_temp[1]-seg.
a_pre_bwd()[1]) > 3. *
M_PI /2.) a_pre_fwd_temp[1]-=
M_PI2;
853 if( (a_pre_fwd_temp[1]-seg.
a_pre_bwd()[1]) < -3. *
M_PI /2. ) a_pre_fwd_temp[1]+=
M_PI2;
858 if( (a_pre_filt_temp[1]-seg.
a_pre_bwd()[1]) > 3. *
M_PI /2. ) a_pre_filt_temp[1] -=
M_PI2;
859 if( (a_pre_filt_temp[1]-seg.
a_pre_bwd()[1]) < -3. *
M_PI /2.) a_pre_filt_temp[1] +=
M_PI2;
874 std::cout<<
"seg.Ea_pre_bwd().inverse(inv) ..."<<seg.
Ea_pre_bwd().inverse(inv)<<std::endl;
875 std::cout<<
"seg.Ea_pre_fwd().inverse(inv) ..."<<seg.
Ea_pre_fwd().inverse(inv)<<std::endl;
878 HepSymMatrix Ea_pre_comb = (seg.
Ea_pre_bwd().inverse(inv)+seg.
Ea_pre_fwd().inverse(inv)).inverse(inv);
883 std::cout<<
"Ea_pre_comb_ ... "<<Ea_pre_comb<<std::endl;
884 std::cout<<
"seg.a_pre_bwd()..."<<seg.
a_pre_bwd()<<std::endl;
885 std::cout<<
"seg.a_pre_fwd()..."<<seg.
a_pre_fwd()<<std::endl;
891 std::cout<<
"seg.Ea_filt_fwd()..."<<seg.
Ea_filt_fwd()<<std::endl;
892 std::cout<<
"seg.Ea_filt_fwd().inverse(inv)..."<<seg.
Ea_filt_fwd().inverse(inv)<<std::endl;
898 std::cout<<
"seg.Ea() is ..."<<seg.
Ea()<<std::endl;
899 std::cout<<
"seg.Ea_filt_fwd().inverse(inv)*seg.a_filt_fwd() ..."<<seg.
Ea_filt_fwd().inverse(inv)*seg.
a_filt_fwd()<<std::endl;
900 std::cout<<
"seg.Ea_pre_bwd().inverse(inv)*seg.a_pre_bwd() ... "<<seg.
Ea_pre_bwd().inverse(inv)*seg.
a_pre_bwd()<<std::endl;
916 std::cout<<
"the dd in smoother_Mdc is "<<dd
917 <<
" the (v_HT*a_pre_comb)[0] is "<<(v_HT*a_pre_comb)[0]<<std::endl;
922 std::cout<<
"method 1 ..."<<sqrt(seg.
a()[0]*seg.
a()[0]+seg.
a()[3]*seg.
a()[3])<<std::endl;
923 std::cout<<
"method 2 ..."<<fabs((v_HT*seg.
a())[0])<<std::endl;
930 HepVector a_temp1 = helixNew1.a();
931 HepSymMatrix ea_temp1 = helixNew1.Ea();
939 HepVector a_temp2 = helixNew2.a();
940 HepSymMatrix ea_temp2 = helixNew2.Ea();
965 int layerid = (*HitMdc).wire().layer().layerId();
969 if (wire_ID<0 || wire_ID>6796){
970 std::cout <<
"KalFitTrack : wire_ID problem : " << wire_ID << std::endl;
979 double csf0 =
cos(phi);
980 double snf0 = (1. - csf0) * (1. + csf0);
981 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
982 if(phi >
M_PI) snf0 = - snf0;
985 Hep3Vector ip(0, 0, 0);
989 double phi_ip = work.
phi0();
990 if (fabs(phi - phi_ip) >
M_PI) {
991 if (phi > phi_ip) phi -= 2 *
M_PI;
992 else phi_ip -= 2 *
M_PI;
995 double l = fabs(
radius() * (phi - phi_ip) * sqrt(1 +
t *
t));
996 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
997 double mass_over_p( mass_ / pmag );
998 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
999 tofest = l / ( 29.9792458 * beta );
1000 if(csmflag==1 && (*HitMdc).wire().y()>0.) tofest= -1. * tofest;
1003 const HepSymMatrix& ea =
Ea();
1004 const HepVector& v_a =
a();
1028 double dchi2R(99999999), dchi2L(99999999);
1029 HepVector v_H(5, 0);
1030 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
1032 HepMatrix v_HT = v_H.T();
1034 double estim = (v_HT * v_a)[0];
1035 HepVector ea_v_H = ea * v_H;
1036 HepMatrix ea_v_HT = (ea_v_H).T();
1037 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
1038 HepSymMatrix eaNew(5);
1040 double time = (*HitMdc).tdc();
1058 double dmeas2[2] = { 0.1*ddl, 0.1*ddr };
1059 double er_dmeas2[2] = {0., 0.};
1061 er_dmeas2[0] = 0.1*erddl;
1062 er_dmeas2[1] = 0.1*erddr;
1069 double er_dmeasL, dmeasL;
1071 dmeasL = (-1.0)*dmeas2[0];
1072 er_dmeasL = er_dmeas2[0];
1074 dmeasL = (-1.0)*fabs((*HitMdc).dist()[0]);
1075 er_dmeasL = (*HitMdc).erdist()[0];
1081 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
1082 eaNew.assign(ea - ea_v_H * AL * ea_v_HT);
1083 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
1084 if(0. == RkL) RkL = 1.e-4;
1086 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
1088 double sigL = (dmeasL - (v_HT * aNew)[0]);
1089 dchi2L = (sigL*sigL) / (RkL * er_dmeasL*er_dmeasL);
1090 }
else if (lr == 1) {
1093 double er_dmeasR, dmeasR;
1096 er_dmeasR = er_dmeas2[1];
1098 dmeasR = fabs((*HitMdc).dist()[1]);
1099 er_dmeasR = (*HitMdc).erdist()[1];
1106 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
1107 eaNew.assign(ea - ea_v_H * AR * ea_v_HT);
1108 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
1109 if(0. == RkR) RkR = 1.e-4;
1111 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
1113 double sigR = (dmeasR- (v_HT * aNew)[0]);
1114 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
1119 cout<<
"in smoother_Mdc: lr= "<<lr<<
" a: "<<v_a<<
" a_NEW: "<<aNew<<endl;
1121 double dchi2_loc(0);
1128 if (!(aNew[2] && fabs(aNew[2]-
a()[2]) < 1.0)) chge = 0;
1130 chiSq_back_ += dchi2R;
1135 }
else if (lr == -1) {
1136 chiSq_back_ += dchi2L;
1149 HepVector a_pre_fwd_temp=seg.
a_pre_fwd();
1150 if( (a_pre_fwd_temp[1]-seg.
a_pre_bwd()[1]) > 3. *
M_PI /2.) a_pre_fwd_temp[1]-=
M_PI2;
1151 if( (a_pre_fwd_temp[1]-seg.
a_pre_bwd()[1]) < -3. *
M_PI /2. ) a_pre_fwd_temp[1]+=
M_PI2;
1156 if( (a_pre_filt_temp[1]-seg.
a_pre_bwd()[1]) > 3. *
M_PI /2. ) a_pre_filt_temp[1] -=
M_PI2;
1157 if( (a_pre_filt_temp[1]-seg.
a_pre_bwd()[1]) < -3. *
M_PI /2.) a_pre_filt_temp[1] +=
M_PI2;
1172 std::cout<<
"seg.Ea_pre_bwd().inverse(inv) ..."<<seg.
Ea_pre_bwd().inverse(inv)<<std::endl;
1173 std::cout<<
"seg.Ea_pre_fwd().inverse(inv) ..."<<seg.
Ea_pre_fwd().inverse(inv)<<std::endl;
1176 HepSymMatrix Ea_pre_comb = (seg.
Ea_pre_bwd().inverse(inv)+seg.
Ea_pre_fwd().inverse(inv)).inverse(inv);
1181 std::cout<<
"Ea_pre_comb_ ... "<<Ea_pre_comb<<std::endl;
1182 std::cout<<
"seg.a_pre_bwd()..."<<seg.
a_pre_bwd()<<std::endl;
1183 std::cout<<
"seg.a_pre_fwd()..."<<seg.
a_pre_fwd()<<std::endl;
1190 std::cout<<
"seg.Ea_filt_fwd()..."<<seg.
Ea_filt_fwd()<<std::endl;
1191 std::cout<<
"seg.Ea_filt_fwd().inverse(inv)..."<<seg.
Ea_filt_fwd().inverse(inv)<<std::endl;
1197 std::cout<<
"seg.Ea() is ..."<<seg.
Ea()<<std::endl;
1198 std::cout<<
"seg.Ea_filt_fwd().inverse(inv)*seg.a_filt_fwd() ..."<<seg.
Ea_filt_fwd().inverse(inv)*seg.
a_filt_fwd()<<std::endl;
1199 std::cout<<
"seg.Ea_pre_bwd().inverse(inv)*seg.a_pre_bwd() ... "<<seg.
Ea_pre_bwd().inverse(inv)*seg.
a_pre_bwd()<<std::endl;
1215 std::cout<<
"the dd in smoother_Mdc is "<<dd
1216 <<
" the (v_HT*a_pre_comb)[0] is "<<(v_HT*a_pre_comb)[0]<<std::endl;
1221 std::cout<<
"method 1 ..."<<sqrt(seg.
a()[0]*seg.
a()[0]+seg.
a()[3]*seg.
a()[3])<<std::endl;
1222 std::cout<<
"method 2 ..."<<fabs((v_HT*seg.
a())[0])<<std::endl;
1228 helixNew1.pivot(ip);
1229 HepVector a_temp1 = helixNew1.a();
1230 HepSymMatrix ea_temp1 = helixNew1.Ea();
1237 helixNew2.pivot(ip);
1238 HepVector a_temp2 = helixNew2.a();
1239 HepSymMatrix ea_temp2 = helixNew2.Ea();
1255 double v_d,
double m_V)
1257 HepMatrix m_HT = m_H.T();
1264 HepMatrix m_XT = m_X.T();
1265 HepMatrix
m_C = m_X *
Ea() * m_XT;
1267 HepVector m_K = 1 / (m_V + (m_HT *
m_C * m_H)[0]) * m_H;
1268 HepVector v_a =
a();
1269 HepSymMatrix ea =
Ea();
1270 HepMatrix mXTmK = m_XT * m_K;
1271 double v_r = v_m - v_d - (m_HT * v_x)[0];
1272 v_a += ea * mXTmK * v_r;
1274 ea.assign(ea - ea * mXTmK * m_HT * m_X * ea);
1278 HepMatrix mCmK =
m_C * m_K;
1280 m_C -= mCmK * m_HT *
m_C;
1281 v_r = v_m - v_d - (m_HT * v_x)[0];
1282 double m_R = m_V - (m_HT *
m_C * m_H)[0];
1283 double chiSq = v_r * v_r / m_R;
1313 double light_speed( 29.9792458 );
1315 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
1317 double mass_over_p( mass_ / pmag );
1318 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
1319 tof_ += path / ( light_speed * beta );
1324 double massk_over_p( MASS[3] / p_kaon_ );
1325 double beta_kaon( 1.0 / sqrt( 1.0 + massk_over_p * massk_over_p ) );
1326 tof_kaon_ += path / (light_speed * beta_kaon);
1329 double massp_over_p( MASS[4] / p_proton_ );
1330 double beta_proton( 1.0 / sqrt( 1.0 + massp_over_p * massp_over_p ) );
1331 tof_proton_ += path / (light_speed * beta_proton);
1342 double phi0 =
a()[1];
1345 double csf0 =
cos(phi);
1346 double snf0 = (1. - csf0) * (1. + csf0);
1347 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
1348 if(phi >
M_PI) snf0 = - snf0;
1369 double ALPHA_loc = 10000./2.99792458/Bz;
1370 return ALPHA_loc /
a()[2];
1384 double xnp(nextPivot.x()), ynp(nextPivot.y()), znp(nextPivot.z());
1385 HepSymMatrix Ea_now =
Ea();
1387 double xp(piv.x()), yp(piv.y()), zp(piv.z());
1389 double phi0 =
a()[1];
1392 double tanl =
a()[4];
1398 double rdr =
dr + m_rad;
1400 double csf0 =
cos(phi);
1401 double snf0 = (1. - csf0) * (1. + csf0);
1402 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
1403 if(phi >
M_PI) snf0 = - snf0;
1405 double xc = xp + rdr * csf0;
1406 double yc = yp + rdr * snf0;
1407 double csf = (xc - xnp) / m_rad;
1408 double snf = (yc - ynp) / m_rad;
1409 double anrm = sqrt(csf * csf + snf * snf);
1412 phi = atan2(snf, csf);
1415 double drp = (xp +
dr * csf0 + m_rad * (csf0 - csf) - xnp)
1417 + (yp +
dr * snf0 + m_rad * (snf0 - snf) - ynp) * snf;
1418 double dzp = zp +
dz - m_rad *
tanl * phid - znp;
1430 Hep3Vector x1(xp +
dr*csf0, yp +
dr*snf0, zp +
dz);
1431 double csf0p =
cos(ap[1]);
1432 double snf0p = (1. - csf0p) * (1. + csf0p);
1433 snf0p = sqrt((snf0p > 0.) ? snf0p : 0.);
1434 if(ap[1] >
M_PI) snf0p = - snf0p;
1436 Hep3Vector x2(xnp + drp*csf0p,
1439 Hep3Vector dist((x1 - x2).
x()/100.0,
1440 (x1 - x2).y()/100.0,
1441 (x1 - x2).z()/100.0);
1443 (x1.y() + x2.y())/2,
1444 (x1.z() + x2.z())/2);
1447 field = 1000.*field;
1448 Hep3Vector dB(field.x(),
1452 double akappa(fabs(
kappa));
1453 double sign =
kappa/akappa;
1455 dp = 0.299792458 * sign * dB.cross(dist);
1457 dhp[0] = -akappa*(dp[0]*csf0p+dp[1]*snf0p);
1458 dhp[1] =
kappa*akappa*(dp[0]*snf0p-dp[1]*csf0p);
1459 dhp[2] = dp[2]*akappa+dhp[1]*
tanl/
kappa;
1468 Ea_now.assign(m_del * Ea_now * m_del.T());
1483 double th = 90.0 - 180.0*M_1_PI*atan( tl );
1501 double xnp(nextPivot.x()), ynp(nextPivot.y()), znp(nextPivot.z());
1503 HepSymMatrix Ea_now =
Ea();
1505 double xp(piv.x()), yp(piv.y()), zp(piv.z());
1508 double phi0 =
a()[1];
1511 double tanl =
a()[4];
1516 double rdr =
dr + m_rad;
1518 double csf0 =
cos(phi);
1519 double snf0 = (1. - csf0) * (1. + csf0);
1520 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
1521 if(phi >
M_PI) snf0 = - snf0;
1523 double xc = xp + rdr * csf0;
1524 double yc = yp + rdr * snf0;
1525 double csf = (xc - xnp) / m_rad;
1526 double snf = (yc - ynp) / m_rad;
1527 double anrm = sqrt(csf * csf + snf * snf);
1530 phi = atan2(snf, csf);
1533 double drp = (xp +
dr * csf0 + m_rad * (csf0 - csf) - xnp)
1535 + (yp +
dr * snf0 + m_rad * (snf0 - snf) - ynp) * snf;
1536 double dzp = zp +
dz - m_rad *
tanl * phid - znp;
1550 Hep3Vector x1(xp +
dr*csf0, yp +
dr*snf0, zp +
dz);
1552 double csf0p =
cos(ap[1]);
1553 double snf0p = (1. - csf0p) * (1. + csf0p);
1554 snf0p = sqrt((snf0p > 0.) ? snf0p : 0.);
1555 if(ap[1] >
M_PI) snf0p = - snf0p;
1557 Hep3Vector x2(xnp + drp*csf0p,
1561 Hep3Vector dist((x1 - x2).
x()/100.0,
1562 (x1 - x2).y()/100.0,
1563 (x1 - x2).z()/100.0);
1566 (x1.y() + x2.y())/2,
1567 (x1.z() + x2.z())/2);
1571 field = 1000.*field;
1574 Hep3Vector dB(field.x(),
1583 double akappa(fabs(
kappa));
1584 double sign =
kappa/akappa;
1586 dp = 0.299792458 * sign * dB.cross(dist);
1591 dhp[0] = -akappa*(dp[0]*csf0p+dp[1]*snf0p);
1592 dhp[1] =
kappa*akappa*(dp[0]*snf0p-dp[1]*csf0p);
1593 dhp[2] = dp[2]*akappa+dhp[1]*
tanl/
kappa;
1605 Ea_now.assign(m_del * Ea_now * m_del.T());
1615 double tanl_0(tracktest.
a()[4]);
1616 double phi0_0(tracktest.
a()[1]);
1617 double radius_0(tracktest.
radius());
1618 tracktest.
pivot(newPivot);
1620 double phi0_1 = tracktest.
a()[1];
1621 if (fabs(phi0_1 - phi0_0) >
M_PI) {
1622 if (phi0_1 > phi0_0) phi0_1 -= 2 *
M_PI;
1623 else phi0_0 -= 2 *
M_PI;
1625 if(phi0_1 == phi0_0) phi0_1 = phi0_0 + 1.e-10;
1626 pathl = fabs(radius_0 * (phi0_1 - phi0_0)
1627 * sqrt(1 + tanl_0 * tanl_0));
1737 Hep3Vector zvector( 0., 0., z_c-rho*dphi*tanl);
1739 double xcio, ycio, phip;
1741 double delrin = 2.0;
1742 if( m_zf-delrin > zvector.z() ){
1743 phip = z_c - m_zb + delrin;
1744 phip = phip/( rho*tanl );
1746 xcio = x_c - rho*cos( phip );
1747 ycio = y_c - rho*sin( phip );
1748 cell_IO[i].setX( xcio );
1749 cell_IO[i].setY( ycio );
1750 cell_IO[i].setZ( m_zb+delrin );
1753 else if( m_zb+delrin < zvector.z() ){
1754 phip = z_c - m_zf-delrin;
1755 phip = phip/( rho*tanl );
1757 xcio = x_c - rho*cos( phip );
1758 ycio = y_c - rho*sin( phip );
1759 cell_IO[i].setX( xcio );
1760 cell_IO[i].setY( ycio );
1761 cell_IO[i].setZ( m_zf-delrin );
1765 cell_IO[i] = iocand;
1766 cell_IO[i] += zvector;
1769 if( i == 0 ) phi_in = dphi;
1771// path length estimation
1773Hep3Vector cl = cell_IO[1] - cell_IO[0];
1775cout<<"cell_IO[0] "<<cell_IO[0]<<" cell_IO[1] "<<cell_IO[1]<<" cl "<<cl<<endl;
1781double ch_ltrk_rp = 0;
1782ch_dphi = cl.perp()*0.5/(ALPHA_loc*pt);
1783ch_dphi = 2.0 * asin( ch_dphi );
1784ch_ltrk_rp = ch_dphi*ALPHA_loc*pt;
1786cout<<"ch_dphi "<<ch_dphi<<" ch_ltrk_rp "<<ch_ltrk_rp<<" cl.z "<<cl.z()<<endl;
1788ch_ltrk = sqrt( ch_ltrk_rp*ch_ltrk_rp + cl.z()*cl.z() );
1789ch_theta = cl.theta();
1791if( ch_theta < theta*0.85 || 1.15*theta < ch_theta)
1792 ch_ltrk *= -1; /// miss calculation
1794if( epflag[0] == 1 || epflag [1] == 1 )
1795 ch_ltrk *= -1; /// invalid resion for dE/dx or outside of Mdc
1797 mom_[layer] = momentum( phi_in );
1798 PathL_[layer] = ch_ltrk;
1800 cout<<"ch_ltrk "<<ch_ltrk<<endl;
1810 j = (int) pow(2.,i);
1813 }
else if (i < 50) {
1814 j = (int) pow(2.,(i-31));
1852 int wire_ID = Wire.
geoID();
1857 if (wire_ID<0 || wire_ID>6796){
1858 std::cout <<
" KalFitTrack: wire_ID problem : " << wire_ID
1862 int flag_ster = Wire.
stereo();
1867 double csf0 =
cos(phi);
1868 double snf0 = (1. - csf0) * (1. + csf0);
1869 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
1870 if(phi >
M_PI) snf0 = - snf0;
1878 Hep3Vector ip(0, 0, 0);
1880 phi_ip = work.
phi0();
1881 if (fabs(phi - phi_ip) >
M_PI) {
1882 if (phi > phi_ip) phi -= 2 *
M_PI;
1883 else phi_ip -= 2 *
M_PI;
1885 dphi = phi - phi_ip;
1886 double l = fabs(
radius() * dphi * sqrt(1 +
t *
t));
1887 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
1888 double mass_over_p( mass_ / pmag );
1889 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
1890 tofest = l / ( 29.9792458 * beta );
1891 if(csmflag==1 &&
HitMdc.
wire().
y()>0.) tofest= -1. * tofest;
1894 const HepSymMatrix& ea =
Ea();
1895 const HepVector& v_a =
a();
1896 double dchi2R(99999999), dchi2L(99999999);
1898 HepVector v_H(5, 0);
1899 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
1901 HepMatrix v_HT = v_H.T();
1903 double estim = (v_HT * v_a)[0];
1906 HepVector ea_v_H = ea * v_H;
1907 HepMatrix ea_v_HT = (ea_v_H).T();
1908 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
1910 HepSymMatrix eaNewL(5), eaNewR(5);
1911 HepVector aNewL(5), aNewR(5);
1920 std::cout<<
"drifttime in update_hits() for ananlysis is "<<drifttime<<std::endl;
1921 std::cout<<
"ddl in update_hits() for ananlysis is "<<ddl<<std::endl;
1922 std::cout<<
"ddr in update_hits() for ananlysis is "<<ddr<<std::endl;
1923 std::cout<<
"erddl in update_hits() for ananlysis is "<<erddl<<std::endl;
1924 std::cout<<
"erddr in update_hits() for ananlysis is "<<erddr<<std::endl;
1928 double dmeas2[2] = { 0.1*ddl, 0.1*ddr };
1929 double er_dmeas2[2] = {0.,0.};
1931 er_dmeas2[0] = 0.1*erddl;
1932 er_dmeas2[1] = 0.1*erddr;
1941 if ((
LR_==0 && lr != 1.0) ||
1942 (
LR_==1 && lr == -1.0)) {
1943 double er_dmeasL, dmeasL;
1945 dmeasL = (-1.0)*fabs(dmeas2[0]);
1946 er_dmeasL = er_dmeas2[0];
1952 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
1953 eaNewL.assign(ea - ea_v_H * AL * ea_v_HT);
1954 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
1956 std::cout<<
" ea_v_H * AL * ea_v_HT is: "<<ea_v_H * AL * ea_v_HT<<std::endl;
1957 std::cout<<
" v_H is: "<<v_H<<
" Ea is: "<<ea<<
" v_H_T_ea_v_H is: "<<v_H_T_ea_v_H<<std::endl;
1958 std::cout<<
" AL is: "<<AL<<
" (v_H_T_ea_v_H)[0] * AL is: "<<(v_H_T_ea_v_H)[0]*AL<<std::endl;
1961 if(0. == RkL) RkL = 1.e-4;
1963 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
1964 aNewL = v_a + diffL;
1965 double sigL = dmeasL -(v_HT * aNewL)[0];
1966 dtracknew = (v_HT * aNewL)[0];
1967 dchi2L = (sigL * sigL)/(RkL * er_dmeasL*er_dmeasL);
1970 std::cout<<
" fwd_filter : in left hypothesis dchi2L is "<<dchi2L<<std::endl;
1974 if ((
LR_==0 && lr != -1.0) ||
1975 (
LR_==1 && lr == 1.0)) {
1976 double er_dmeasR, dmeasR;
1979 er_dmeasR = er_dmeas2[1];
1985 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
1986 eaNewR.assign(ea - ea_v_H * AR * ea_v_HT);
1987 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
1990 std::cout<<
" ea_v_H * AR * ea_v_HT is: "<<ea_v_H * AR * ea_v_HT<<std::endl;
1991 std::cout<<
" v_H is: "<<v_H<<
" Ea is: "<<ea<<
" v_H_T_ea_v_H is: "<<v_H_T_ea_v_H<<std::endl;
1992 std::cout<<
" AR is: "<<AR<<
" (v_H_T_ea_v_H)[0] * AR is: "<<(v_H_T_ea_v_H)[0]*AR<<std::endl;
1995 if(0. == RkR) RkR = 1.e-4;
1996 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
1997 aNewR = v_a + diffR;
1998 double sigR = dmeasR -(v_HT * aNewR)[0];
1999 dtracknew = (v_HT * aNewR)[0];
2000 dchi2R = (sigR*sigR)/(RkR * er_dmeasR*er_dmeasR);
2002 std::cout<<
" fwd_filter : in right hypothesis dchi2R is "<<dchi2R<<std::endl;
2006 double dchi2_loc(0);
2007 if (fabs(dchi2R-dchi2L)<10. && inext>0) {
2010 double chi2_fromR(
chi2_next(H_fromR, HitMdc_next, csmflag));
2012 double chi2_fromL(
chi2_next(H_fromL, HitMdc_next, csmflag));
2014 std::cout <<
" chi2_fromL = " << chi2_fromL
2015 <<
", chi2_fromR = " << chi2_fromR << std::endl;
2017 if (fabs(chi2_fromR-chi2_fromL)<10.){
2019 if (inext+1<HitsMdc_.size())
2020 for(
int k=inext+1 ; k < HitsMdc_.size(); k++ )
2021 if (!(HitsMdc_[k].chi2()<0)) {
2028 double chi2_fromR2(
chi2_next(H_fromR, HitMdc_next2, csmflag));
2029 double chi2_fromL2(
chi2_next(H_fromL, HitMdc_next2, csmflag));
2031 std::cout <<
" chi2_fromL2 = " << chi2_fromL2
2032 <<
", chi2_fromR2 = " << chi2_fromR2 << std::endl;
2034 if (fabs(dchi2R+chi2_fromR+chi2_fromR2-(dchi2L+chi2_fromL+chi2_fromL2))<2) {
2035 if (chi2_fromR2<chi2_fromL2)
2044 if (dchi2R+chi2_fromR < dchi2L+chi2_fromL){
2047 std::cout <<
" choose right..." << std::endl;
2052 std::cout <<
" choose left..." << std::endl;
2060 if (((
LR_==0 && dchi2R < dchi2L && lr != -1) ||
2061 (
LR_==1 && lr == 1)) &&
2062 fabs(aNewR[2]-
a()[2]) < 1000. && aNewR[2]) {
2065 if (flag_ster) nster_++;
2070 if (l_mass_ == lead_){
2075 }
else if (((
LR_==0 && dchi2L <= dchi2R && lr != 1) ||
2076 (
LR_==1 && lr == -1)) &&
2077 fabs(aNewL[2]-
a()[2]) < 1000. && aNewL[2]){
2080 if (flag_ster) nster_++;
2085 if (l_mass_ == lead_){
2092 if (dchi2_loc > dchi2_max_) {
2093 dchi2_max_ = dchi2_loc ;
2094 r_max_ =
pivot().perp();
2096 dchi2out = dchi2_loc;
2111 int layerid = (*HitMdc).wire().layer().layerId();
2116 std::cout<<
"in update_hits(kalFitHelixSeg,...) : the layerid ="<<layerid<<std::endl;
2117 std::cout<<
" update_hits: lr= " << lr <<std::endl;
2121 int wire_ID = Wire.
geoID();
2123 if (wire_ID<0 || wire_ID>6796){
2124 std::cout <<
" KalFitTrack: wire_ID problem : " << wire_ID
2128 int flag_ster = Wire.
stereo();
2133 double csf0 =
cos(phi);
2134 double snf0 = (1. - csf0) * (1. + csf0);
2135 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
2136 if(phi >
M_PI) snf0 = - snf0;
2144 Hep3Vector ip(0, 0, 0);
2146 phi_ip = work.
phi0();
2147 if (fabs(phi - phi_ip) >
M_PI) {
2148 if (phi > phi_ip) phi -= 2 *
M_PI;
2149 else phi_ip -= 2 *
M_PI;
2151 dphi = phi - phi_ip;
2153 double l = fabs(
radius() * dphi * sqrt(1 +
t *
t));
2154 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
2155 double mass_over_p( mass_ / pmag );
2156 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2157 tofest = l / ( 29.9792458 * beta );
2158 if(csmflag==1 && (*HitMdc).wire().y()>0.) tofest= -1. * tofest;
2161 const HepSymMatrix& ea =
Ea();
2166 const HepVector& v_a =
a();
2190 double dchi2R(99999999), dchi2L(99999999);
2192 HepVector v_H(5, 0);
2193 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
2195 HepMatrix v_HT = v_H.T();
2197 double estim = (v_HT * v_a)[0];
2198 HepVector ea_v_H = ea * v_H;
2199 HepMatrix ea_v_HT = (ea_v_H).T();
2200 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
2202 HepSymMatrix eaNewL(5), eaNewR(5);
2203 HepVector aNewL(5), aNewR(5);
2205 cout<<
"phi "<<phi<<
" snf0 "<<snf0<<
" csf0 "<<csf0<<endl
2206 <<
" meas: "<<meas <<endl;
2207 cout<<
"the related matrix:"<<endl;
2208 cout<<
"v_H "<<v_H<<endl;
2209 cout<<
"v_a "<<v_a<<endl;
2210 cout<<
"ea "<<ea<<endl;
2211 cout<<
"v_H_T_ea_v_H "<<v_H_T_ea_v_H<<endl;
2212 cout<<
"LR_= "<<
LR_ <<
"lr= " << lr <<endl;
2215 double time = (*HitMdc).tdc();
2229 std::cout<<
"the pure drift time is "<<drifttime<<std::endl;
2230 std::cout<<
"the drift dist left hypothesis is "<<ddl<<std::endl;
2231 std::cout<<
"the drift dist right hypothesis is "<<ddr<<std::endl;
2232 std::cout<<
"the error sigma left hypothesis is "<<erddl<<std::endl;
2233 std::cout<<
"the error sigma right hypothesis is "<<erddr<<std::endl;
2235 double dmeas2[2] = { 0.1*ddl , 0.1*ddr };
2236 double er_dmeas2[2] = {0. , 0.} ;
2239 er_dmeas2[0] = 0.1*erddl;
2240 er_dmeas2[1] = 0.1*erddr;
2249 if ((
LR_==0 && lr != 1.0) ||
2250 (
LR_==1 && lr == -1.0)) {
2252 double er_dmeasL, dmeasL;
2254 dmeasL = (-1.0)*fabs(dmeas2[0]);
2255 er_dmeasL = er_dmeas2[0];
2257 dmeasL = (-1.0)*fabs((*HitMdc).dist()[0]);
2258 er_dmeasL = (*HitMdc).erdist()[0];
2261 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
2262 eaNewL.assign(ea - ea_v_H * AL * ea_v_HT);
2263 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
2264 if(0. == RkL) RkL = 1.e-4;
2266 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
2268 aNewL = v_a + diffL;
2269 double sigL = dmeasL -(v_HT * aNewL)[0];
2270 dchi2L = (sigL * sigL) / (RkL * er_dmeasL*er_dmeasL);
2273 if ((
LR_==0 && lr != -1.0) ||
2274 (
LR_==1 && lr == 1.0)) {
2276 double er_dmeasR, dmeasR;
2279 er_dmeasR = er_dmeas2[1];
2281 dmeasR = fabs((*HitMdc).dist()[1]);
2282 er_dmeasR = (*HitMdc).erdist()[1];
2285 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
2286 eaNewR.assign(ea - ea_v_H * AR * ea_v_HT);
2287 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
2288 if(0. == RkR) RkR = 1.e-4;
2290 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
2292 aNewR = v_a + diffR;
2293 double sigR = dmeasR -(v_HT * aNewR)[0];
2294 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
2298 double dchi2_loc(0);
2301 cout<<
" track::update_hits......"<<endl;
2302 std::cout <<
" dchi2R = " << dchi2R <<
", dchi2L = " << dchi2L
2303 <<
" estimate = "<<estim<< std::endl;
2304 std::cout <<
" dmeasR = " << dmeas2[1]
2305 <<
", dmeasL = " << (-1.0)*fabs(dmeas2[0]) <<
", check HitMdc.ddl = "
2306 << (*HitMdc).dist()[0] << std::endl;
2307 std::cout<<
"dchi2L : "<<dchi2L<<
" ,dchi2R: "<<dchi2R<<std::endl;
2311 if (fabs(dchi2R-dchi2L)<10. && inext>0) {
2316 double chi2_fromR(
chi2_next(H_fromR, HitMdc_next,csmflag));
2320 double chi2_fromL(
chi2_next(H_fromL, HitMdc_next,csmflag));
2323 std::cout <<
" chi2_fromL = " << chi2_fromL
2324 <<
", chi2_fromR = " << chi2_fromR << std::endl;
2326 if (fabs(chi2_fromR-chi2_fromL)<10.){
2328 if (inext+1<HitsMdc_.size())
2329 for(
int k=inext+1 ; k < HitsMdc_.size(); k++ )
2330 if (!(HitsMdc_[k].chi2()<0)) {
2339 double chi2_fromR2(
chi2_next(H_fromR, HitMdc_next2, csmflag));
2340 double chi2_fromL2(
chi2_next(H_fromL, HitMdc_next2, csmflag));
2342 std::cout <<
" chi2_fromL2 = " << chi2_fromL2
2343 <<
", chi2_fromR2 = " << chi2_fromR2 << std::endl;
2345 if (fabs(dchi2R+chi2_fromR+chi2_fromR2-(dchi2L+chi2_fromL+chi2_fromL2))<2) {
2346 if (chi2_fromR2<chi2_fromL2)
2355 if (dchi2R+chi2_fromR < dchi2L+chi2_fromL){
2358 std::cout <<
" choose right..." << std::endl;
2363 std::cout <<
" choose left..." << std::endl;
2372 if (((
LR_==0 && dchi2R < dchi2L && lr != -1) ||
2373 (
LR_==1 && lr == 1)) &&
2374 fabs(aNewR[2]-
a()[2]) < 1000. && aNewR[2]) {
2377 if (flag_ster) nster_++;
2402 if (l_mass_ == lead_){
2406 update_bit((*HitMdc).wire().layer().layerId());
2408 }
else if (((
LR_==0 && dchi2L <= dchi2R && lr != 1) ||
2409 (
LR_==1 && lr == -1)) &&
2410 fabs(aNewL[2]-
a()[2]) < 1000. && aNewL[2]){
2413 if (flag_ster) nster_++;
2437 if (l_mass_ == lead_){
2441 update_bit((*HitMdc).wire().layer().layerId());
2446 if (dchi2_loc > dchi2_max_) {
2447 dchi2_max_ = dchi2_loc ;
2448 r_max_ =
pivot().perp();
2450 dchi2out = dchi2_loc;
2465 int layerid = (*HitMdc).wire().layer().layerId();
2469 std::cout<<
"in update_hits(kalFitHelixSeg,...) : the layerid ="<<layerid<<std::endl;
2470 std::cout<<
" update_hits: lr= " << lr <<std::endl;
2474 int wire_ID = Wire.
geoID();
2476 if (wire_ID<0 || wire_ID>6796){
2477 std::cout <<
" KalFitTrack: wire_ID problem : " << wire_ID
2481 int flag_ster = Wire.
stereo();
2486 double csf0 =
cos(phi);
2487 double snf0 = (1. - csf0) * (1. + csf0);
2488 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
2489 if(phi >
M_PI) snf0 = - snf0;
2497 Hep3Vector ip(0, 0, 0);
2499 phi_ip = work.
phi0();
2500 if (fabs(phi - phi_ip) >
M_PI) {
2501 if (phi > phi_ip) phi -= 2 *
M_PI;
2502 else phi_ip -= 2 *
M_PI;
2504 dphi = phi - phi_ip;
2506 double l = fabs(
radius() * dphi * sqrt(1 +
t *
t));
2507 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
2508 double mass_over_p( mass_ / pmag );
2509 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2510 tofest = l / ( 29.9792458 * beta );
2511 if(csmflag==1 && (*HitMdc).wire().y()>0.) tofest= -1. * tofest;
2514 const HepSymMatrix& ea =
Ea();
2519 const HepVector& v_a =
a();
2544 double dchi2R(99999999), dchi2L(99999999);
2546 HepVector v_H(5, 0);
2547 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
2549 HepMatrix v_HT = v_H.T();
2551 double estim = (v_HT * v_a)[0];
2552 HepVector ea_v_H = ea * v_H;
2553 HepMatrix ea_v_HT = (ea_v_H).T();
2554 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
2556 HepSymMatrix eaNewL(5), eaNewR(5);
2557 HepVector aNewL(5), aNewR(5);
2559 cout<<
"phi "<<phi<<
" snf0 "<<snf0<<
" csf0 "<<csf0<<endl
2560 <<
" meas: "<<meas <<endl;
2561 cout<<
"the related matrix:"<<endl;
2562 cout<<
"v_H "<<v_H<<endl;
2563 cout<<
"v_a "<<v_a<<endl;
2564 cout<<
"ea "<<ea<<endl;
2565 cout<<
"v_H_T_ea_v_H "<<v_H_T_ea_v_H<<endl;
2566 cout<<
"LR_= "<<
LR_ <<
"lr= " << lr <<endl;
2569 double time = (*HitMdc).tdc();
2583 std::cout<<
"the pure drift time is "<<drifttime<<std::endl;
2584 std::cout<<
"the drift dist left hypothesis is "<<ddl<<std::endl;
2585 std::cout<<
"the drift dist right hypothesis is "<<ddr<<std::endl;
2586 std::cout<<
"the error sigma left hypothesis is "<<erddl<<std::endl;
2587 std::cout<<
"the error sigma right hypothesis is "<<erddr<<std::endl;
2589 double dmeas2[2] = { 0.1*ddl , 0.1*ddr };
2590 double er_dmeas2[2] = {0. , 0.} ;
2593 er_dmeas2[0] = 0.1*erddl;
2594 er_dmeas2[1] = 0.1*erddr;
2603 if ((
LR_==0 && lr != 1.0) ||
2604 (
LR_==1 && lr == -1.0)) {
2606 double er_dmeasL, dmeasL;
2608 dmeasL = (-1.0)*fabs(dmeas2[0]);
2609 er_dmeasL = er_dmeas2[0];
2611 dmeasL = (-1.0)*fabs((*HitMdc).dist()[0]);
2612 er_dmeasL = (*HitMdc).erdist()[0];
2615 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
2616 eaNewL.assign(ea - ea_v_H * AL * ea_v_HT);
2617 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
2618 if(0. == RkL) RkL = 1.e-4;
2620 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
2622 aNewL = v_a + diffL;
2623 double sigL = dmeasL -(v_HT * aNewL)[0];
2624 dchi2L = (sigL * sigL) / (RkL * er_dmeasL*er_dmeasL);
2627 if ((
LR_==0 && lr != -1.0) ||
2628 (
LR_==1 && lr == 1.0)) {
2630 double er_dmeasR, dmeasR;
2633 er_dmeasR = er_dmeas2[1];
2635 dmeasR = fabs((*HitMdc).dist()[1]);
2636 er_dmeasR = (*HitMdc).erdist()[1];
2639 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
2640 eaNewR.assign(ea - ea_v_H * AR * ea_v_HT);
2641 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
2642 if(0. == RkR) RkR = 1.e-4;
2644 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
2646 aNewR = v_a + diffR;
2647 double sigR = dmeasR -(v_HT * aNewR)[0];
2648 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
2652 double dchi2_loc(0);
2655 cout<<
" track::update_hits......"<<endl;
2656 std::cout <<
" dchi2R = " << dchi2R <<
", dchi2L = " << dchi2L
2657 <<
" estimate = "<<estim<< std::endl;
2658 std::cout <<
" dmeasR = " << dmeas2[1]
2659 <<
", dmeasL = " << (-1.0)*fabs(dmeas2[0]) <<
", check HitMdc.ddl = "
2660 << (*HitMdc).dist()[0] << std::endl;
2663 if (fabs(dchi2R-dchi2L)<10. && inext>0) {
2668 double chi2_fromR(
chi2_next(H_fromR, HitMdc_next,csmflag));
2671 double chi2_fromL(
chi2_next(H_fromL, HitMdc_next,csmflag));
2673 std::cout <<
" chi2_fromL = " << chi2_fromL
2674 <<
", chi2_fromR = " << chi2_fromR << std::endl;
2676 if (fabs(chi2_fromR-chi2_fromL)<10.){
2678 if (inext+1<HitsMdc_.size())
2679 for(
int k=inext+1 ; k < HitsMdc_.size(); k++ )
2680 if (!(HitsMdc_[k].chi2()<0)) {
2687 double chi2_fromR2(
chi2_next(H_fromR, HitMdc_next2, csmflag));
2688 double chi2_fromL2(
chi2_next(H_fromL, HitMdc_next2, csmflag));
2690 std::cout <<
" chi2_fromL2 = " << chi2_fromL2
2691 <<
", chi2_fromR2 = " << chi2_fromR2 << std::endl;
2693 if (fabs(dchi2R+chi2_fromR+chi2_fromR2-(dchi2L+chi2_fromL+chi2_fromL2))<2) {
2694 if (chi2_fromR2<chi2_fromL2)
2703 if (dchi2R+chi2_fromR < dchi2L+chi2_fromL){
2706 std::cout <<
" choose right..." << std::endl;
2711 std::cout <<
" choose left..." << std::endl;
2720 if (((
LR_==0 && dchi2R < dchi2L && lr != -1) ||
2721 (
LR_==1 && lr == 1)) &&
2722 fabs(aNewR[2]-
a()[2]) < 1000. && aNewR[2]) {
2725 if (flag_ster) nster_++;
2750 if (l_mass_ == lead_){
2754 update_bit((*HitMdc).wire().layer().layerId());
2756 }
else if (((
LR_==0 && dchi2L <= dchi2R && lr != 1) ||
2757 (
LR_==1 && lr == -1)) &&
2758 fabs(aNewL[2]-
a()[2]) < 1000. && aNewL[2]){
2761 if (flag_ster) nster_++;
2784 if (l_mass_ == lead_){
2788 update_bit((*HitMdc).wire().layer().layerId());
2793 if (dchi2_loc > dchi2_max_) {
2794 dchi2_max_ = dchi2_loc ;
2795 r_max_ =
pivot().perp();
2797 dchi2out = dchi2_loc;
2809 int wire_ID = Wire.
geoID();
2815 Hep3Vector wire = (Hep3Vector)fwd -(Hep3Vector)bck;
2818 work.
pivot((fwd + bck) * .5);
2819 HepPoint3D x0kal = (work.
x(0).z() - bck.z())/ wire.z() * wire + bck;
2822 Hep3Vector meas =
H.momentum(0).cross(wire).unit();
2824 if (wire_ID<0 || wire_ID>6796){
2825 std::cout <<
"KalFitTrack : wire_ID problem : " << wire_ID
2834 double csf0 =
cos(phi);
2835 double snf0 = (1. - csf0) * (1. + csf0);
2836 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
2837 if(phi >
M_PI) snf0 = - snf0;
2840 Hep3Vector ip(0, 0, 0);
2844 double phi_ip = work.
phi0();
2845 if (fabs(phi - phi_ip) >
M_PI) {
2846 if (phi > phi_ip) phi -= 2 *
M_PI;
2847 else phi_ip -= 2 *
M_PI;
2850 double l = fabs(
radius() * (phi - phi_ip) * sqrt(1 +
t *
t));
2851 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
2852 double mass_over_p( mass_ / pmag );
2853 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2854 tofest = l / ( 29.9792458 * beta );
2858 const HepSymMatrix& ea =
H.Ea();
2859 const HepVector& v_a =
H.a();
2862 HepVector v_H(5, 0);
2863 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
2865 HepMatrix v_HT = v_H.T();
2867 double estim = (v_HT * v_a)[0];
2868 HepVector ea_v_H = ea * v_H;
2869 HepMatrix ea_v_HT = (ea_v_H).T();
2870 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
2872 HepSymMatrix eaNewL(5), eaNewR(5);
2873 HepVector aNewL(5), aNewR(5);
2884 double dmeas2[2] = { 0.1*ddl, 0.1*ddr };
2885 double er_dmeas2[2] = {0. , 0.};
2887 er_dmeas2[0] = 0.1*erddl;
2888 er_dmeas2[1] = 0.1*erddr;
2896 if ((
LR_==0 && lr != 1.0) ||
2897 (
LR_==1 && lr == -1.0)) {
2899 double er_dmeasL, dmeasL;
2901 dmeasL = (-1.0)*fabs(dmeas2[0]);
2902 er_dmeasL = er_dmeas2[0];
2908 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
2909 eaNewL.assign(ea - ea_v_H * AL * ea_v_HT);
2910 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
2911 if(0. == RkL) RkL = 1.e-4;
2913 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
2914 aNewL = v_a + diffL;
2915 double sigL = dmeasL -(v_HT * aNewL)[0];
2916 dchi2L = (sigL * sigL) / (RkL * er_dmeasL*er_dmeasL);
2919 if ((
LR_==0 && lr != -1.0) ||
2920 (
LR_==1 && lr == 1.0)) {
2922 double er_dmeasR, dmeasR;
2925 er_dmeasR = er_dmeas2[1];
2931 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
2932 eaNewR.assign(ea - ea_v_H * AR * ea_v_HT);
2933 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
2934 if(0. == RkR) RkR = 1.e-4;
2936 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
2937 aNewR = v_a + diffR;
2938 double sigR = dmeasR -(v_HT * aNewR)[0];
2939 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
2942 if (dchi2R < dchi2L){
2943 H.a(aNewR);
H.Ea(eaNewR);
2945 H.a(aNewL);
H.Ea(eaNewL);
2947 return ((dchi2R < dchi2L) ? dchi2R : dchi2L);
2954 int wire_ID = Wire.
geoID();
2960 Hep3Vector wire = (Hep3Vector)fwd -(Hep3Vector)bck;
2963 work.
pivot((fwd + bck) * .5);
2964 HepPoint3D x0kal = (work.
x(0).z() - bck.z())/ wire.z() * wire + bck;
2967 Hep3Vector meas =
H.momentum(0).cross(wire).unit();
2969 if (wire_ID<0 || wire_ID>6796){
2970 std::cout <<
"KalFitTrack : wire_ID problem : " << wire_ID
2979 double csf0 =
cos(phi);
2980 double snf0 = (1. - csf0) * (1. + csf0);
2981 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
2982 if(phi >
M_PI) snf0 = - snf0;
2985 Hep3Vector ip(0, 0, 0);
2989 double phi_ip = work.
phi0();
2990 if (fabs(phi - phi_ip) >
M_PI) {
2991 if (phi > phi_ip) phi -= 2 *
M_PI;
2992 else phi_ip -= 2 *
M_PI;
2995 double l = fabs(
radius() * (phi - phi_ip) * sqrt(1 +
t *
t));
2996 double pmag( sqrt( 1.0 +
t*
t ) /
kappa());
2997 double mass_over_p( mass_ / pmag );
2998 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2999 tofest = l / ( 29.9792458 * beta );
3000 if(csmflag==1 &&
HitMdc.
wire().
y()>0.) tofest= -1. * tofest;
3003 const HepSymMatrix& ea =
H.Ea();
3004 const HepVector& v_a =
H.a();
3007 HepVector v_H(5, 0);
3008 v_H[0] = -csf0 * meas.x() - snf0 * meas.y();
3010 HepMatrix v_HT = v_H.T();
3012 double estim = (v_HT * v_a)[0];
3013 HepVector ea_v_H = ea * v_H;
3014 HepMatrix ea_v_HT = (ea_v_H).T();
3015 HepVector v_H_T_ea_v_H = v_HT * ea_v_H;
3017 HepSymMatrix eaNewL(5), eaNewR(5);
3018 HepVector aNewL(5), aNewR(5);
3029 double dmeas2[2] = { 0.1*ddl, 0.1*ddr };
3030 double er_dmeas2[2] = {0. , 0.};
3032 er_dmeas2[0] = 0.1*erddl;
3033 er_dmeas2[1] = 0.1*erddr;
3041 if ((
LR_==0 && lr != 1.0) ||
3042 (
LR_==1 && lr == -1.0)) {
3044 double er_dmeasL, dmeasL;
3046 dmeasL = (-1.0)*fabs(dmeas2[0]);
3047 er_dmeasL = er_dmeas2[0];
3053 double AL = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasL*er_dmeasL);
3054 eaNewL.assign(ea - ea_v_H * AL * ea_v_HT);
3055 double RkL = 1 - (v_H_T_ea_v_H)[0] * AL;
3056 if(0. == RkL) RkL = 1.e-4;
3058 HepVector diffL = ea_v_H * AL * (dmeasL - estim);
3059 aNewL = v_a + diffL;
3060 double sigL = dmeasL -(v_HT * aNewL)[0];
3061 dchi2L = (sigL * sigL) / (RkL * er_dmeasL*er_dmeasL);
3064 if ((
LR_==0 && lr != -1.0) ||
3065 (
LR_==1 && lr == 1.0)) {
3067 double er_dmeasR, dmeasR;
3070 er_dmeasR = er_dmeas2[1];
3076 double AR = 1 / ((v_H_T_ea_v_H)[0] + er_dmeasR*er_dmeasR);
3077 eaNewR.assign(ea - ea_v_H * AR * ea_v_HT);
3078 double RkR = 1 - (v_H_T_ea_v_H)[0] * AR;
3079 if(0. == RkR) RkR = 1.e-4;
3081 HepVector diffR = ea_v_H * AR * (dmeasR - estim);
3082 aNewR = v_a + diffR;
3083 double sigR = dmeasR -(v_HT * aNewR)[0];
3084 dchi2R = (sigR*sigR) / (RkR * er_dmeasR*er_dmeasR);
3087 if (dchi2R < dchi2L){
3088 H.a(aNewR);
H.Ea(eaNewR);
3090 H.a(aNewL);
H.Ea(eaNewL);
3092 return ((dchi2R < dchi2L) ? dchi2R : dchi2L);
3097 double sigma1,sigma2,
f;
3101 sigma1=0.112784; sigma2=0.229274;
f=0.666;
3102 }
else if(driftDist<1.){
3103 sigma1=0.103123; sigma2=0.269797;
f=0.934;
3104 }
else if(driftDist<1.5){
3105 sigma1=0.08276; sigma2=0.17493;
f=0.89;
3106 }
else if(driftDist<2.){
3107 sigma1=0.070109; sigma2=0.149859;
f=0.89;
3108 }
else if(driftDist<2.5){
3109 sigma1=0.064453; sigma2=0.130149;
f=0.886;
3110 }
else if(driftDist<3.){
3111 sigma1=0.062383; sigma2=0.138806;
f=0.942;
3112 }
else if(driftDist<3.5){
3113 sigma1=0.061873; sigma2=0.145696;
f=0.946;
3114 }
else if(driftDist<4.){
3115 sigma1=0.061236; sigma2=0.119584;
f=0.891;
3116 }
else if(driftDist<4.5){
3117 sigma1=0.066292; sigma2=0.148426;
f=0.917;
3118 }
else if(driftDist<5.){
3119 sigma1=0.078074; sigma2=0.188148;
f=0.911;
3120 }
else if(driftDist<5.5){
3121 sigma1=0.088657; sigma2=0.27548;
f=0.838;
3123 sigma1=0.093089; sigma2=0.115556;
f=0.367;
3127 sigma1=0.112433; sigma2=0.327548;
f=0.645;
3128 }
else if(driftDist<1.){
3129 sigma1=0.096703; sigma2=0.305206;
f=0.897;
3130 }
else if(driftDist<1.5){
3131 sigma1=0.082518; sigma2=0.248913;
f= 0.934;
3132 }
else if(driftDist<2.){
3133 sigma1=0.072501; sigma2=0.153868;
f= 0.899;
3134 }
else if(driftDist<2.5){
3135 sigma1= 0.065535; sigma2=0.14246;
f=0.914;
3136 }
else if(driftDist<3.){
3137 sigma1=0.060497; sigma2=0.126489;
f=0.918;
3138 }
else if(driftDist<3.5){
3139 sigma1=0.057643; sigma2= 0.112927;
f=0.892;
3140 }
else if(driftDist<4.){
3141 sigma1=0.055266; sigma2=0.094833;
f=0.887;
3142 }
else if(driftDist<4.5){
3143 sigma1=0.056263; sigma2=0.124419;
f= 0.932;
3144 }
else if(driftDist<5.){
3145 sigma1=0.056599; sigma2=0.124248;
f=0.923;
3146 }
else if(driftDist<5.5){
3147 sigma1= 0.061377; sigma2=0.146147;
f=0.964;
3148 }
else if(driftDist<6.){
3149 sigma1=0.063978; sigma2=0.150591;
f=0.942;
3150 }
else if(driftDist<6.5){
3151 sigma1=0.072951; sigma2=0.15685;
f=0.913;
3152 }
else if(driftDist<7.){
3153 sigma1=0.085438; sigma2=0.255109;
f=0.931;
3154 }
else if(driftDist<7.5){
3155 sigma1=0.101635; sigma2=0.315529;
f=0.878;
3157 sigma1=0.149529; sigma2=0.374697;
f=0.89;
3160 double sigmax = sqrt(
f*sigma1*sigma1+(1 -
f)*sigma2*sigma2)*0.1;
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
HepGeom::Point3D< double > HepPoint3D
double cos(const BesAngle a)
********INTEGER modcns REAL m_C
HepGeom::Transform3D HepTransform3D
virtual StatusCode fieldVector(const HepGeom::Point3D< double > &xyz, HepGeom::Vector3D< double > &fvec) const =0
CLHEP::HepVector a_pre_fwd(void)
CLHEP::HepSymMatrix Ea_filt_fwd(void)
CLHEP::HepVector a_filt_bwd(void)
CLHEP::HepVector a_include(void)
CLHEP::HepSymMatrix Ea_pre_bwd(void)
double doca_include(void)
CLHEP::HepVector a_filt_fwd(void)
double doca_exclude(void)
CLHEP::HepVector a_pre_bwd(void)
CLHEP::HepSymMatrix & Ea_pre_fwd(void)
CLHEP::HepVector a_exclude(void)
CLHEP::HepSymMatrix Ea_filt_bwd(void)
double residual_exclude(void)
CLHEP::HepSymMatrix Ea_include(void)
CLHEP::HepSymMatrix Ea_exclude(void)
KalFitHitMdc * HitMdc(void)
double residual_include(void)
Description of a Hit in Mdc.
RecMdcHit * rechitptr(void)
const double * erdist(void) const
const double * dist(void) const
const KalFitWire & wire(void) const
const int layerId(void) const
returns layer ID
double X0(void) const
Extractor.
double del_E(double mass, double path, double p) const
Calculate the straggling of energy loss.
double mcs_angle(double mass, double path, double p) const
Calculate Multiple Scattering angle.
double dE(double mass, double path, double p) const
Calculate energy loss.
Description of a track class (<- Helix.cc)
~KalFitTrack(void)
destructor
double chi2_next(Helix &H, KalFitHitMdc &HitMdc, int csmflag)
static int lead(void)
Magnetic field map.
double getDriftTime(KalFitHitMdc &hitmdc, double toftime) const
static double chi2_hitf_
Cut chi2 for each hit.
KalFitTrack(const HepPoint3D &pivot, const CLHEP::HepVector &a, const CLHEP::HepSymMatrix &Ea, unsigned int m, double chiSq, unsigned int nhits)
constructor
static double dchi2cuts_anal[43]
static double dchi2cuts_calib[43]
static int debug_
for debug
double filter(double v_m, const CLHEP::HepVector &m_H, double v_d, double m_V)
void order_wirhit(int index)
static int nmdc_hit2_
Cut chi2 for each hit.
double getSigma(int layerId, double driftDist) const
KalFitHelixSeg & HelixSeg(int i)
void addTofSM(double time)
static int resolflag_
wire resoltion flag
static double factor_strag_
factor of energy loss straggling for electron
const HepPoint3D & pivot_numf(const HepPoint3D &newPivot)
Sets pivot position in a given mag field.
void ms(double path, const KalFitMaterial &m, int index)
static int Tof_correc_
Flag for TOF correction.
double intersect_cylinder(double r) const
Intersection with different geometry.
vector< KalFitHitMdc > & HitsMdc(void)
static int numf_
Flag for treatment of non-uniform mag field.
void path_add(double path)
Update the path length estimation.
double update_hits_csmalign(KalFitHelixSeg &HelixSeg, int inext, CLHEP::Hep3Vector &meas, int way, double &dchi2, int csmflag)
static int drifttime_choice_
the drifttime choice
double smoother_Mdc(KalFitHelixSeg &seg, CLHEP::Hep3Vector &meas, int &flg, int csmflag)
Kalman smoother for Mdc.
void msgasmdc(double path, int index)
Calculate multiple scattering angle.
void appendHitsMdc(KalFitHitMdc h)
Functions for Mdc hits list.
void addPathSM(double path)
static double mdcGasRadlen_
static double dchi2cutf_calib[43]
void eloss(double path, const KalFitMaterial &m, int index)
Calculate total energy lost in material.
void update_last(void)
Record the current parameters as ..._last information :
double getDriftDist(KalFitHitMdc &hitmdc, double drifttime, int lr) const
double intersect_yz_plane(const HepTransform3D &plane, double x) const
double intersect_zx_plane(const HepTransform3D &plane, double y) const
static int numfcor_
NUMF treatment improved.
double intersect_xy_plane(double z) const
double radius_numf(void) const
Estimation of the radius in a given mag field.
double smoother_Mdc_csmalign(KalFitHelixSeg &seg, CLHEP::Hep3Vector &meas, int &flg, int csmflag)
double update_hits(KalFitHitMdc &HitMdc, int inext, CLHEP::Hep3Vector &meas, int way, double &dchi2, double &dtrack, double &dtracknew, double &dtdc, int csmflag)
Include the Mdc wire hits.
static double dchi2cutf_anal[43]
static int LR_
Use L/R decision from MdcRecHit information :
KalFitHitMdc & HitMdc(int i)
static int strag_
Flag to take account of energy loss straggling :
Description of a Wire class.
unsigned int geoID(void) const
HepPoint3D bck(void) const
HepPoint3D fwd(void) const
Geometry :
const KalFitLayer_Mdc & layer(void) const
unsigned int stereo(void) const
HepMatrix delApDelA(const HepVector &ap) const
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
void ignoreErrorMatrix(void)
unsets error matrix. Error calculations will be ignored after this function call until an error matri...
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
HepMatrix delXDelA(double phi) const
double radius(void) const
returns radious of helix.
double dr(void) const
returns an element of parameters.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
const double getEntra(void) const
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")