4#include "CLHEP/Units/PhysicalConstants.h"
6const double alpha = -0.00299792458;
12 m_hel = HepVector(5, 0);
13 m_eHel = HepSymMatrix(5, 0);
17 m_trackID = htrk.m_trackID;
18 m_partID = htrk.m_partID;
24 m_trackID = htrk.m_trackID;
25 m_partID = htrk.m_partID;
37 const int trackid,
const int partid) {
39 m_hel = HepVector(5, 0);
40 m_eHel = HepSymMatrix(5, 0);
55 const int trackid,
const int partid) {
57 m_hel = HepVector(5, 0);
58 m_eHel = HepSymMatrix(5, 0);
64 for(
int i = 0; i < 5; i++){
65 for(
int j = 0; j < 5; j++) {
81 for(
int i = 0; i < 3; i++) {
93 for(
int i = 0; i < 5; i++) {
94 for(
int j = 0; j < 3; j++){
100 HepSymMatrix eH(5, 0);
101 eH = (wtrk.
Ew()).similarity(T);
103 double mass = (wtrk.
p()).m();
105 for(
int i = 0; i < 5; i++) {
115 m_eHel = htrk.
eHel();
124 int charge = m_hel[2] > 0 ? +1: -1;
132 int charge = m_hel[2] > 0 ? +1: -1;
136 double x = (m_hel[0] +
rad) *
cos(m_hel[1]);
137 double y = (m_hel[0] +
rad) *
sin(m_hel[1]);
149 m_hel = HepVector(5, 0);
150 m_eHel = HepSymMatrix(5, 0);
165 double pxy = sqrt(px*px+py*py);
166 double T = sqrt((px+a*y)*(px+a*y)+(py-a*
x)*(py-a*
x));
167 double J= (
x*px+y*py)/T*a/
pxy;
170 double phi0 = fmod((4*CLHEP::pi)+atan2(0-px-a*y, py-a*
x), (2*CLHEP::pi));
172 double dz = z - (pz/a) *asin(J);
198 double T = sqrt((px+a*y)*(px+a*y)+(py-a*
x)*(py-a*
x));
201 HepMatrix m_A(5, 3, 0);
203 m_A[0][0] = (py-a*
x)/T;
204 m_A[0][1] = 0 -(px + a*y)/T;
205 m_A[1][0] = 0- a*(px + a*y)/T/T;
206 m_A[1][1] = 0 - a * (py - a*
x)/T/T;
207 m_A[3][0] = 0 - (pz/T)*(px + a*y)/T;
208 m_A[3][1] = 0 - (pz/T)*(py - a*
x)/T;
231 double pxy = sqrt(px*px+py*py);
232 double T = sqrt((px+a*y)*(px+a*y)+(py-a*
x)*(py-a*
x));
233 double J= (
x*px+y*py)/T*a/
pxy;
235 HepMatrix m_B(5, 3, 0);
237 m_B[0][0] = (px/
pxy - (px+a*y)/T)/a;
238 m_B[0][1] = (py/
pxy - (py-a*
x)/T)/a;
239 m_B[1][0] = 0 -(py-a*
x)/T/T;
240 m_B[1][1] = (px + a*y)/T/T;
243 m_B[3][0] = (pz/a)*(py/
pxy/
pxy-(py-a*
x)/T/T);
244 m_B[3][1] = 0-(pz/a)*(px/
pxy/
pxy-(px+a*y)/T/T);
245 m_B[3][2] = 0 - asin(J)/a;
262 HepMatrix dWdh(7, 5, 0);
264 double ptrk =
p3().rho();
double E = sqrt(ptrk*ptrk +
mass *
mass);
265 double px =
p3().x();
266 double py =
p3().y();
267 double pz =
p3().z();
268 double x0 =
x3().x();
269 double y0 =
x3().y();
270 double z0 =
x3().z();
271 w[0] = px; w[1] = py; w[2] = pz; w[3] = E;
272 w[4] = x0; w[5] = y0; w[6] = z0;
274 dWdh[0][1] = -py; dWdh[0][2] = 0 - px/
kappa();
275 dWdh[1][1] = px; dWdh[1][2] = 0 - py/
kappa();
279 dWdh[4][0] =
cos(
phi0()); dWdh[4][1] = 0 - y0;
280 dWdh[5][0] =
sin(
phi0()); dWdh[5][1] = x0;
282 HepSymMatrix Ew(7, 0);
283 Ew = m_eHel.similarity(dWdh);
290 if(m_partID > -1 && m_partID < 5) {
302 double mass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
318 double rad2 = htrk.
radius();
335 double xt = xc2.x() - xc1.x();
336 double yt = xc2.y() - xc1.y();
337 if(xt == 0 && yt == 0)
return HepPoint3D(999,999,999);
338 double rt = rad1*rad1-rad2*rad2-xc1.perp2()+xc2.perp2();
339 double x1, y1, x2, y2;
341 double a = 1 + yt*yt/(xt*xt);
343 double b = 2*xc1.x()*yt/xt-yt*rt/(xt*xt)-2*xc1.y();
344 double c = rt*rt/(4*xt*xt)-xc1.x()*rt/xt-rad1*rad1+xc1.perp2();
345 double d = b*b - 4 * a * c;
351 x1 = (rt - 2 * yt * y1)/(2*xt);
354 x2 = (rt - 2 * yt * y2)/(2*xt);
356 double a = 1 + xt*xt/(yt*yt);
358 double b = 2*xc1.y()*xt/yt-xt*rt/(yt*yt)-2*xc1.x();
359 double c = rt*rt/(4*yt*yt)-xc1.y()*rt/yt-rad1*rad1+xc1.perp2();
360 double d = b*b - 4 * a * c;
366 y1 = (rt - 2 * xt * x1)/(2*yt);
369 y2 = (rt - 2 * xt * x2)/(2*yt);
372 double z1[2], z2[2], J1[2], J2[2];
378 J1[0] = a1*((x1-
x3().x())*
p3().x()+(y1-
x3().y())*
p3().y())/
p3().perp2();
379 J1[1] = a2*((x1-htrk.
x3().
x())*htrk.
p3().x()+(y1-htrk.
x3().y())*htrk.
p3().y())/htrk.
p3().perp2();
380 z1[0] =
x3().z()+
p3().z()/a1*asin(J1[0]);
381 z1[1] = htrk.
x3().z()+htrk.
p3().z()/a2*asin(J1[1]);
383 J2[0] = a1*((x2-
x3().x())*
p3().x()+(y2-
x3().y())*
p3().y())/
p3().perp2();
384 J2[1] = a2*((x2-htrk.
x3().
x())*htrk.
p3().x()+(y2-htrk.
x3().y())*htrk.
p3().y())/htrk.
p3().perp2();
385 z2[0] =
x3().z()+
p3().z()/a2*asin(J2[0]);
386 z2[1] = htrk.
x3().z()+htrk.
p3().z()/a2*asin(J2[1]);
390 if(fabs(z1[0]-z1[1]) < fabs(z2[0]-z2[1])) {
431 double phiH0 = fmod((4*CLHEP::pi)+atan2(
p3().y(),
p3().
x()), (2*CLHEP::pi));
432 double phiG0 = fmod((4*CLHEP::pi)+atan2(G.
p3().y(), G.
p3().x()), (2*CLHEP::pi));
435 double a =
x3().x() - G.
x3().x() + g*
sin(phiG0) - h*
sin(phiH0);
436 double b =
x3().y() - G.
x3().y() - g*
cos(phiG0) + h*
cos(phiH0);
437 double c1 = h*lamH*lamH;
438 double c2 = 0 - g*lamG*lamG;
439 double d1 = 0 - g*lamG*lamH;
440 double d2 = h*lamG*lamH;
441 double e1 = lamH*(
x3().z() - G.
x3().z() - h*phiH0*lamH + g*phiG0*lamG);
442 double e2 = lamG*(
x3().z() - G.
x3().z() - h*phiH0*lamH + g*phiG0*lamG);
444 HepVector phiE(2, 0);
449 HepSymMatrix Omega(2, 0);
450 double phiH = phiE[0];
451 double phiG = phiE[1];
452 z[0] =
cos(phiH)*(a-g*
sin(phiG))+
sin(phiH)*(b+g*
cos(phiG))+
c1*phiH+d1*phiG+
e1;
453 z[1] =
cos(phiG)*(a+h*
sin(phiH))+
sin(phiG)*(b-h*
cos(phiH))+c2*phiG+d2*phiH+
e2;
454 Omega[0][0] = 0-
sin(phiH)*(a-g*
sin(phiG))+
cos(phiH)*(b+g*
cos(phiG))+
c1;
455 Omega[0][1] = -g*
cos(phiH)*
cos(phiG)-g*
sin(phiH)*
sin(phiG)+d1;
456 Omega[1][0] =h*
cos(phiH)*
cos(phiG)+h*
sin(phiG)*
sin(phiH)+d2;
457 Omega[1][1] = -
sin(phiG)*(a+h*
sin(phiH))+
cos(phiG)*(b-h*
cos(phiH))+c2;
459 phi = phiE - Omega.inverse(ifail) * z;
460 if((fabs(phi[0]-phiE[0])<1E-3) && (fabs(phi[1]-phiE[1])<1E-3)) {
468 double phiH = phiE[0];
469 double phiG = phiE[1];
472 double dis = (posH-posG).rho();
473 mpos = 0.5*(posH+posG);
double sin(const BesAngle a)
double cos(const BesAngle a)
HepGeom::Point3D< double > HepPoint3D
HepPoint3D positionCylinder(const double) const
HepPoint3D positionTwoHelix(const HTrackParameter) const
HepMatrix dHdp(const HepVector p, const HepVector x)
double minDistanceTwoHelix(const HTrackParameter G, HepPoint3D &pos)
HepMatrix dHdx(const HepVector p, const HepVector x)
double xmass(const int i) const
WTrackParameter wTrack() const
HepPoint3D positionPlane(const double) const
HepPoint3D center() const
HepSymMatrix eHel() const
void setEHel(const HepSymMatrix eH)
HepPoint3D positionCone() const
static VertexFitBField * instance()
double getBFieldZ(const HepPoint3D &vtx)
void setEw(const HepSymMatrix &Ew)
HepLorentzVector p() const
void setCharge(const int charge)
void setW(const HepVector &w)