16#include "VertexFit/Helix.h"
17#include "VertexFit/BField.h"
39 const HepSymMatrix & Ea)
50 m_alpha = 10000. / 2.99792458 / m_bField;
61 m_Ea(HepSymMatrix(5,0)),
66 m_alpha = 10000. / 2.99792458 / m_bField;
78 m_Ea(HepSymMatrix(5,0)),
83 m_alpha = 10000. / 2.99792458 / m_bField;
119 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
120 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
121 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
136 p[0] = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi));
137 p[1] = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi));
138 p[2] = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
145 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
146 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
147 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
158 if (m_matrixValid) Ex = m_Ea.similarity(
delXDelA(phi));
176 double pt = fabs(m_pt);
177 double px = - pt *
sin(m_ac[1] + phi);
178 double py = pt *
cos(m_ac[1] + phi);
179 double pz = pt * m_ac[4];
181 return Hep3Vector(px, py, pz);
196 double pt = fabs(m_pt);
197 double px = - pt *
sin(m_ac[1] + phi);
198 double py = pt *
cos(m_ac[1] + phi);
199 double pz = pt * m_ac[4];
201 if (m_matrixValid) Em = m_Ea.similarity(
delMDelA(phi));
204 return Hep3Vector(px, py, pz);
220 double pt = fabs(m_pt);
221 double px = - pt *
sin(m_ac[1] + phi);
222 double py = pt *
cos(m_ac[1] + phi);
223 double pz = pt * m_ac[4];
224 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
226 return HepLorentzVector(px, py, pz, E);
243 double pt = fabs(m_pt);
244 double px = - pt *
sin(m_ac[1] + phi);
245 double py = pt *
cos(m_ac[1] + phi);
246 double pz = pt * m_ac[4];
247 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
249 if (m_matrixValid) Em = m_Ea.similarity(
del4MDelA(phi,
mass));
252 return HepLorentzVector(px, py, pz, E);
259 HepSymMatrix & Emx)
const {
271 double pt = fabs(m_pt);
272 double px = - pt *
sin(m_ac[1] + phi);
273 double py = pt *
cos(m_ac[1] + phi);
274 double pz = pt * m_ac[4];
275 double E = sqrt(pt * pt * (1. + m_ac[4] * m_ac[4]) +
mass *
mass);
277 x.setX(m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi)));
278 x.setY(m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi)));
279 x.setZ(m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi);
284 return HepLorentzVector(px, py, pz, E);
290 const double &
dr = m_ac[0];
291 const double &
phi0 = m_ac[1];
292 const double &
kappa = m_ac[2];
293 const double &
dz = m_ac[3];
294 const double &
tanl = m_ac[4];
296 double rdr =
dr + m_r;
298 double csf0 =
cos(phi);
299 double snf0 = (1. - csf0) * (1. + csf0);
300 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
301 if(phi >
M_PI) snf0 = - snf0;
303 double xc = m_pivot.x() + rdr * csf0;
304 double yc = m_pivot.y() + rdr * snf0;
307 csf = (xc - newPivot.x()) / m_r;
308 snf = (yc - newPivot.y()) / m_r;
309 double anrm = sqrt(csf * csf + snf * snf);
313 phi = atan2(snf, csf);
326 double drp = (m_pivot.x() +
dr * csf0 + m_r * (csf0 - csf) - newPivot.x())
328 + (m_pivot.y() +
dr * snf0 + m_r * (snf0 - snf) - newPivot.y()) * snf;
329 double dzp = m_pivot.z() +
dz - m_r *
tanl * phid - newPivot.z();
339 if (m_matrixValid) m_Ea = m_Ea.similarity(
delApDelA(ap));
352 const HepSymMatrix & Ea) {
356 m_matrixValid =
true;
362 if (
this == & i)
return *
this;
364 m_bField = i.m_bField;
369 m_matrixValid = i.m_matrixValid;
371 m_center = i.m_center;
386VFHelix::updateCache(
void) {
402 if (m_ac[2] != 0.0) {
404 m_r = m_alpha / m_ac[2];
411 double x = m_pivot.x() + (m_ac[0] + m_r) * m_cp;
412 double y = m_pivot.y() + (m_ac[0] + m_r) * m_sp;
425 HepMatrix dApDA(5,5,0);
427 const double &
dr = m_ac[0];
428 const double &
phi0 = m_ac[1];
429 const double & cpa = m_ac[2];
430 const double &
dz = m_ac[3];
431 const double & tnl = m_ac[4];
434 double phi0p = ap[1];
439 double rdr = m_r +
dr;
441 if ((m_r + drp) != 0.0) {
442 rdrpr = 1. / (m_r + drp);
448 double csfd =
cos(phi0p -
phi0);
449 double snfd =
sin(phi0p -
phi0);
454 dApDA[0][1] = rdr*snfd;
456 dApDA[0][2] = (m_r/cpa)*( 1.0 - csfd );
461 dApDA[1][0] = - rdrpr*snfd;
462 dApDA[1][1] = rdr*rdrpr*csfd;
464 dApDA[1][2] = (m_r/cpa)*rdrpr*snfd;
471 dApDA[3][0] = m_r*rdrpr*tnl*snfd;
472 dApDA[3][1] = m_r*tnl*(1.0 - rdr*rdrpr*csfd);
474 dApDA[3][2] = (m_r/cpa)*tnl*(phid - m_r*rdrpr*snfd);
479 dApDA[3][4] = - m_r*phid;
494 HepMatrix dXDA(3,5,0);
496 const double &
dr = m_ac[0];
497 const double &
phi0 = m_ac[1];
498 const double & cpa = m_ac[2];
499 const double &
dz = m_ac[3];
500 const double & tnl = m_ac[4];
502 double cosf0phi =
cos(
phi0 + phi);
503 double sinf0phi =
sin(
phi0 + phi);
506 dXDA[0][1] = -
dr * m_sp + m_r * (- m_sp + sinf0phi);
508 dXDA[0][2] = - (m_r / cpa) * (m_cp - cosf0phi);
516 dXDA[1][1] =
dr * m_cp + m_r * (m_cp - cosf0phi);
518 dXDA[1][2] = - (m_r / cpa) * (m_sp - sinf0phi);
528 dXDA[2][2] = (m_r / cpa) * tnl * phi;
533 dXDA[2][4] = - m_r * phi;
548 HepMatrix dMDA(3,5,0);
550 const double &
phi0 = m_ac[1];
551 const double & cpa = m_ac[2];
552 const double & tnl = m_ac[4];
554 double cosf0phi =
cos(
phi0+phi);
555 double sinf0phi =
sin(
phi0+phi);
558 if(cpa != 0.)rho = 1./cpa;
564 dMDA[0][1] = -fabs(rho)*cosf0phi;
565 dMDA[0][2] =
charge*rho*rho*sinf0phi;
567 dMDA[1][1] = -fabs(rho)*sinf0phi;
568 dMDA[1][2] = -
charge*rho*rho*cosf0phi;
570 dMDA[2][2] = -
charge*rho*rho*tnl;
571 dMDA[2][4] = fabs(rho);
585 HepMatrix d4MDA(4,5,0);
587 double phi0 = m_ac[1];
588 double cpa = m_ac[2];
589 double tnl = m_ac[4];
591 double cosf0phi =
cos(
phi0+phi);
592 double sinf0phi =
sin(
phi0+phi);
595 if(cpa != 0.)rho = 1./cpa;
601 double E = sqrt(rho*rho*(1.+tnl*tnl)+
mass*
mass);
603 d4MDA[0][1] = -fabs(rho)*cosf0phi;
604 d4MDA[0][2] =
charge*rho*rho*sinf0phi;
606 d4MDA[1][1] = -fabs(rho)*sinf0phi;
607 d4MDA[1][2] = -
charge*rho*rho*cosf0phi;
609 d4MDA[2][2] = -
charge*rho*rho*tnl;
610 d4MDA[2][4] = fabs(rho);
612 if (cpa != 0.0 && E != 0.0) {
613 d4MDA[3][2] = (-1.-tnl*tnl)/(cpa*cpa*cpa*E);
614 d4MDA[3][4] = tnl/(cpa*cpa*E);
631 HepMatrix d4MXDA(7,5,0);
633 const double &
dr = m_ac[0];
634 const double &
phi0 = m_ac[1];
635 const double & cpa = m_ac[2];
636 const double &
dz = m_ac[3];
637 const double & tnl = m_ac[4];
639 double cosf0phi =
cos(
phi0+phi);
640 double sinf0phi =
sin(
phi0+phi);
643 if(cpa != 0.)rho = 1./cpa;
649 double E = sqrt(rho * rho * (1. + tnl * tnl) +
mass *
mass);
651 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
652 d4MXDA[0][2] =
charge * rho * rho * sinf0phi;
654 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
655 d4MXDA[1][2] = -
charge * rho * rho * cosf0phi;
657 d4MXDA[2][2] = -
charge * rho * rho * tnl;
658 d4MXDA[2][4] = fabs(rho);
660 if (cpa != 0.0 && E != 0.0) {
661 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa * E);
662 d4MXDA[3][4] = tnl / (cpa * cpa * E);
669 d4MXDA[4][1] = -
dr * m_sp + m_r * (- m_sp + sinf0phi);
671 d4MXDA[4][2] = - (m_r / cpa) * (m_cp - cosf0phi);
677 d4MXDA[5][1] =
dr * m_cp + m_r * (m_cp - cosf0phi);
679 d4MXDA[5][2] = - (m_r / cpa) * (m_sp - sinf0phi);
681 d4MXDA[6][2] = (m_r / cpa) * tnl * phi;
689 d4MXDA[6][4] = - m_r * phi;
696 m_matrixValid =
false;
**********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
double sin(const BesAngle a)
double cos(const BesAngle a)
HepGeom::Point3D< double > HepPoint3D
virtual ~VFHelix()
Destructor.
HepMatrix del4MDelA(double phi, double mass) const
const HepPoint3D & pivot(void) const
returns pivot position.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
HepMatrix delApDelA(const HepVector &ap) const
double dr(void) const
returns an element of parameters.
HepMatrix delMDelA(double phi) const
HepMatrix del4MXDelA(double phi, double mass) const
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
HepMatrix delXDelA(double phi) const
void ignoreErrorMatrix(void)
unsets error matrix. Error calculations will be ignored after this function call until an error matri...
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
VFHelix & operator=(const VFHelix &)
Copy operator.
VFHelix(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
Constructor with pivot, helix parameter a, and its error matrix.
static const double ConstantAlpha
Constant alpha for uniform field.
const HepSymMatrix & Ea(void) const
returns error matrix.
const HepVector & a(void) const
returns helix parameters.
static VertexFitBField * instance()