71 double kap = 0.5 *
par.omega();
75 double radius = slayer->
rEnd();
79 std::cout <<
"delPhi "<<slayer->
delPhi()
82 <<
" zEnd() "<<slayer->
zEnd()
83 <<
" phiAx "<<segStuff.
phiAx
85 <<
" phiDiff "<<phiSeg - segStuff.
phiAx<< std::endl;
87 bool lStraight =
false;
88 if (fabs(kap)<1.e-9) lStraight =
true;
91 double zApprox = phiDiff.
rad() * -dPhiZ;
93 std::cout<<
"zApp "<<zApprox<<std::endl;
95 double delRad = slayer->
stDip() *
96 (1. - zApprox * zApprox * segStuff.
wirLen2inv);
100 delPhiArg = delRad * d0 / (radius*radius);
102 delPhiArg = -delRad * kap;
109 bool szFaild =
false;
112 for (
int ihit = 0; ihit < parentSeg->
nHit(); ihit++){
120 span.
sigma[hitFit] = 1;
121 arcTemp += span.
x[hitFit];
127 std::cout<<
"MdcSegInfoSterO hit "<<ihit<<
" z calc faild"<<std::endl;
131 if (hitFit >0) span.
fit(hitFit);
135 segStuff.
phiAx += delPhiArg +
137 phiDiff = phiSeg - segStuff.
phiAx;
138 double z = phiDiff.
rad() * -dPhiZ;
140 std::cout<<
"z "<<z<<std::endl;
145 double arg = radius*radius - d0*d0;
146 if (
arg <= 0.0)
return 1;
147 double rD0Root = sqrt(
arg);
148 double rD0Rinv = 1. / rD0Root;
149 double rinv = 1./radius;
151 double slope = parentSeg->
slope();
152 ct = dPhiZ * (rD0Root * slope + d0 * rinv) * rinv;
155 if (
arc == 0.0)
return 1;
159 std::cout <<
"in MdcSegInfoSterO : z0 "<<
z0 <<
" "<<
_errmat[0]
165 double dctdm = dPhiZ * rD0Root * rinv;
166 double dctdD = -dPhiZ * rinv * (slope * d0 * rD0Rinv - rinv);
167 double dzdm = -
arc * dPhiZ * rD0Root * rinv;
168 double dzdphi = dPhiZ;
169 double dzdphi0 = -dPhiZ;
170 double dzdD = -dPhiZ +
ct * d0 * rD0Rinv -
arc * dctdD;
172 const double *inErr = parentSeg->
errmat();
174 const HepMatrix trackErr =
par.covariance();
175 _errmat[0] = dzdm * dzdm * inErr[2] +
176 2 * dzdm * dzdphi * inErr[1] +
177 dzdphi * dzdphi * inErr[0] +
178 dzdD * dzdD * trackErr(1,1) +
179 dzdphi0 * dzdphi0 * trackErr(2,2) +
180 2 * dzdD * dzdphi0 * trackErr(1,2);
184 _errmat[2] = dctdm * dctdm * inErr[2] +
185 dctdD * dctdD * trackErr(1,1);
189 _errmat[1] = dzdm * dctdm * inErr[2] +
190 dzdphi * dctdm * inErr[1] +
191 dzdD * dctdD * trackErr(1,1) +
192 dzdphi0 * dctdD * trackErr(1,2);
197 double arg = 1. - kap*kap * radius*radius;
198 if (
arg < 0.0)
return 1;
199 double rKapRoot = sqrt(
arg);
200 double rKapRinv = 1. / rKapRoot;
201 double ctFactor = -rKapRoot * -dPhiZ;
202 double slopeAx = kap * rKapRinv;
203 double slope = parentSeg->
slope();
213 ct = (slopeAx - slope) * ctFactor;
215 if (
arc == 0.0)
return 1;
220 arc = arcTemp/hitFit;
230 std::cout<<
"--slayer NO. "<<slayer->
index()<<std::endl;
231 std::cout<<
"ori ct "<<(slopeAx - slope) * ctFactor
235 <<
" arc "<<arcTemp/hitFit<<std::endl;
236 std::cout<<
"-------- "<<std::endl;
239 double dctdm = dPhiZ * rKapRoot;
240 double dctdkap = -dPhiZ * ( 1 + radius * radius * kap * rKapRinv * slope);
241 double dzdm =
arc * -dPhiZ * rKapRoot;
242 double dzdphi = dPhiZ;
243 double dzdkap = dPhiZ * radius * rKapRinv -
arc * dctdkap -
244 ct * ( radius * rKapRinv / kap -
arc / kap);
245 double dzdphi0 = -dPhiZ ;
247 const double *inErr = parentSeg->
errmat();
249 const HepMatrix trackErr =
par.covariance();
250 _errmat[0] = dzdm * dzdm * inErr[2] +
251 2 * dzdm * dzdphi * inErr[1] +
252 dzdphi * dzdphi * inErr[0] +
253 dzdkap * dzdkap * trackErr(3,3) +
254 dzdphi0 * dzdphi0 * trackErr(2,2) +
255 2 * dzdkap * dzdphi0 * trackErr(2,3);
272 _errmat[2] = dctdm * dctdm * inErr[2] +
273 dctdkap * dctdkap * trackErr(3,3);
277 _errmat[1] = dzdm * dctdm * inErr[2] +
278 dzdphi * dctdm * inErr[1] +
279 dzdkap * dctdkap * trackErr(3,3) +
280 dzdphi0 * dctdkap * trackErr(2,3);
292 std::cout <<
" ErrMsg(warning)" <<
"Failed to invert matrix -- MdcSegInfo::calcStereo" <<
312 std::cout<<
"---------- "<<std::endl;
315 std::cout<<
"fp rp "<<fp<<
" "<<rp<<std::endl;
316 std::cout<<
"Xmid "<<X<<std::endl;
322 double d0 = -
par.d0();
323 double phi0 = (
par.phi0()-
pi/2);
325 if((-1)*
par.omega()/Bz > 0) _charge = 1;
329 else r = 1/
par.omega();
331 double xc =
sin(
par.phi0()) *(-d0+r) * -1.;
332 double yc = -1.*
cos(
par.phi0()) *(-d0+r) * -1;
337 double wwmag2 = ww.mag2();
338 double wwmag = sqrt(wwmag2);
339 int ambig = hitUse.
ambig();
341 double driftdist = fabs( h.
driftDist(t0,ambig) );
343 driftdist/wwmag * ww.y(), 0.);
345 std::cout<<
"xc "<<xc <<
" yc "<<yc<<
" drfitdist "<<driftdist<<std::endl;
346 std::cout<<
"r1 "<<r <<
" d0 "<<d0 <<
" phi0 "<<phi0<<std::endl;
347 std::cout<<
"lr "<<lr<<
" hit ambig "<<hitUse.
ambig()<<
" ambig "<<ambig
349 <<
" right "<<h.
driftDist(0,-1)<<std::endl;
357 if (ambig == 0) lr =
ORIGIN;
377 double vmag2 =
v.mag2();
381 double wv = w.dot(
v);
383 double d2 = wv * wv - vmag2 * (w.mag2() - r * r);
385 std::cout<<
"X_fix "<<X<<
" center "<<center<<std::endl;
386 std::cout<<
"V "<<V<<std::endl;
387 std::cout<<
"w "<<w<<
" v "<<
v<<std::endl;
394 std::cout <<
"in MdcSegInfoSterO !!! stereo: 0. > d2 = " << d2 <<
" "
395 << hitUse.
ambig() << std::endl;
404 std::cout<<
"wv "<<wv<<
" d "<<d<<
" vmag2 "<<vmag2<<std::endl;
406 l[0] = (- wv + d) / vmag2;
407 l[1] = (- wv - d) / vmag2;
414 z[0] = X.z() + l[0] * V.z();
415 z[1] = X.z() + l[1] * V.z();
417 std::cout <<
"X.z "<<X.z()<<
" V.z "<<V.z()<<std::endl;
418 std::cout <<
"l0, l1 = " << l[0] <<
", " << l[1] << std::endl;
419 std::cout <<
"rpz " << rp.z() <<
" fpz " << fp.z() << std::endl;
420 std::cout <<
"z0 " << z[0] <<
" z1 " << z[1] << std::endl;
423 if (hitUse.
ambig() == 0) {
424 if(debug>0)std::cout<<
" ambig = 0 " <<std::endl;
425 if (z[0] > rp.z()+20. || z[0] < fp.z()-20.) {
428 if (z[1] > rp.z()+20. || z[1] < fp.z()-20.) {
432 if(debug>0)std::cout<<
" ambig != 0 " <<std::endl;
434 if (fabs(z[0]/rp.z())>1.05 ) { ok[0] =
false; }
436 if (fabs(z[1]/rp.z())>1.05 ) { ok[1] =
false; }
438 if ((! ok[0]) && (! ok[1])) {
439 if(debug>0&&(hitUse.
ambig()!=0)&&fabs(z[1]/rp.z())>1.05)std::cout<<
" z[1] bad " << std::endl;
440 if(debug>0&&(hitUse.
ambig()!=0)&&fabs(z[0]/rp.z())>1.05)std::cout<<
" z[0] bad " << std::endl;
443 std::cout<<
" z[1] bad " <<
"rpz " << rp.z() <<
" fpz " << fp.z()
444 <<
"z0 " << z[0] <<
" z1 " << z[1] << std::endl;
445 std::cout<<
" !ok[0] && !ok[1] return -2" <<std::endl;
456 std::cout<<__FILE__<<
" "<<__LINE__<<
" p0 "<<p[0].x()<<
" "<<p[0].y()<< std::endl;
457 std::cout<<__FILE__<<
" "<<__LINE__<<
" p1 "<<p[1].x()<<
" "<<p[1].y()<< std::endl;
458 std::cout<<__FILE__<<
" "<<__LINE__<<
" c "<<center.x()<<
" "<<center.y()<<
" "<<_charge<< std::endl;
459 std::cout<<__FILE__<<
" "<<__LINE__<<
" p0 centerx*y "<<center.x() * p[0].y()<<
" centery*x"<<center.y() * p[0].x()<< std::endl;
460 std::cout<<__FILE__<<
" "<<__LINE__<<
" p1 centerx*y "<<center.x() * p[1].y()<<
" centery*x"<<center.y() * p[1].x()<< std::endl;
481 double cosdPhi = - center.dot((p[best] - center).
unit()) / center.mag();
483 if(fabs(cosdPhi)<=1.0) {
484 dPhi = acos(cosdPhi);
485 }
else if (cosdPhi>1.0) {
492 tmp.setX(
abs(r * dPhi));
497 span->
y[hitFit] = z[best];
501 span->
x[hitFit] =
abs(r * dPhi);
502 if (hitUse.
ambig()<0) driftdist *= -1.;
506 std::cout<<
"("<<h.
layernumber()<<
","<<h.
wirenumber()<<
") s "<<span->
x[hitFit]<<
" z "<<span->
y[hitFit]<<std::endl;