7 #include "UtilBeamLine3D.h"
8 const float detEpsilon=1e-4;
11 int twoLineDca3D(
double& lambda,
double& kappa,TVector3& V, TVector3& U, TVector3& R,TVector3& P){
17 util.hA[20]->Fill(det);
19 if(det<detEpsilon)
return -1;
26 if(util.fcnMon1&0x2) {
27 printf(
"\nbm V=%.1f %.1f %.1f, U=%.3f %.3f %.3f\n",V.x(),V.y(),V.z(),U.x(),U.y(),U.z());
29 printf(
" tr R=%.1f %.1f %.1f, P=%.3f %.3f %.3f\n",R.x(),R.y(),R.z(),P.x(),P.y(),P.z());
30 printf(
" lam=%f kap=%f det=%f a=%f b=%f c=%f\n",lambda,kappa, det,a,b,c);
38 void beamLineLike3D(
int &npar,
double *grad,
double &fcnval,
double *inpPar,
int iflag){
39 double dmax2=util.cut_Dmax*util.cut_Dmax;
44 assert (util.track.size()>10);
45 TVector3 V;TVector3 U;
46 V.SetXYZ(inpPar[0],inpPar[1],0.);
47 U.SetXYZ(inpPar[2],inpPar[3],1.);
50 assert(fabs(1.-U.Mag2())<1.e-6);
53 sprintf(txt,
"FCN: 3D dca, beamLine X=%.2f Y=%.2f",V.x(),V.y());
54 printf(
"monitor %s\n",txt);
55 util.hA[21]->SetTitle(txt);
61 vector<TrackStump>::iterator it;
62 for (it=util.track.begin() ; it < util.track.end(); it++) {
65 double lambda=0, kappa=0;
66 TVector3 r(t->r),p(t->p);
67 if( twoLineDca3D(lambda,kappa,V,U,r,p)) {
70 if(util.fcnMon1&0x2) {
71 TVector3 r1=r+lambda*p;
72 TVector3 r2=V+kappa*U;
74 printf(
" dca T=%.1f %.1f %.1f B=%.1f %.1f %.1f dca=%.1f\n",r1.x(),r1.y(),r1.z(),r2.x(),r2.y(),r2.z(),D.Mag());
77 TVector3 D=((r-V)+(lambda*p-kappa*U));
79 util.hA[21]->Fill(D.Mag());
80 TVector3 r1=r+lambda*p;
81 util.hA[22]->Fill(r1.z(),D.Mag());
83 util.hA[23]->Fill(r.z());
88 double dZ2=D.z()*D.z();
90 if (dT2<dmax2) chi2+=dT2/t->ery2;
91 else chi2+=dmax2/t->ery2;
92 if (dZ2<dmax2) chi2+=dZ2/t->erz2;
93 else chi2+=dmax2/t->erz2;
98 if(util.fcnCount<0)
return;
99 if(util.fcnCount%10==0)printf(
"nCall=%d fcn=%.1f position:V=%.2f,%.2f tilt(Z=100cm):U=%.2f,%.2f\n",util.fcnCount,chi2,V.x(),V.y(),U.x()*100.,U.y()*100.);