16#include "TrackUtil/Helix.h"
17#include "CLHEP/Matrix/Matrix.h"
18#include "GaudiKernel/StatusCode.h"
19#include "GaudiKernel/IInterface.h"
20#include "GaudiKernel/Kernel.h"
21#include "GaudiKernel/Service.h"
22#include "GaudiKernel/ISvcLocator.h"
23#include "GaudiKernel/SvcFactory.h"
24#include "GaudiKernel/IDataProviderSvc.h"
25#include "GaudiKernel/Bootstrap.h"
26#include "GaudiKernel/MsgStream.h"
27#include "GaudiKernel/SmartDataPtr.h"
28#include "GaudiKernel/IMessageSvc.h"
49 const HepSymMatrix & Ea)
56 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",
m_pmgnIMF);
57 if(scmgn!=StatusCode::SUCCESS) {
58 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
75 m_Ea(HepSymMatrix(5,0)) {
76 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",
m_pmgnIMF);
77 if(scmgn!=StatusCode::SUCCESS) {
79 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
97 m_Ea(HepSymMatrix(5,0)) {
98 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",
m_pmgnIMF);
99 if(scmgn!=StatusCode::SUCCESS) {
101 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
113 m_a[2] = charge / perp;
141 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
142 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
143 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
158 p[0] = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi));
159 p[1] = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi));
160 p[2] = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
167 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
168 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
169 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
180 if (m_matrixValid) Ex = m_Ea.similarity(
delXDelA(phi));
199 double px = - pt *
sin(m_ac[1] + phi);
200 double py = pt *
cos(m_ac[1] + phi);
201 double pz = pt * m_ac[4];
203 return Hep3Vector(px, py, pz);
219 double px = - pt *
sin(m_ac[1] + phi);
220 double py = pt *
cos(m_ac[1] + phi);
221 double pz = pt * m_ac[4];
223 if (m_matrixValid) Em = m_Ea.similarity(
delMDelA(phi));
226 return Hep3Vector(px, py, pz);
243 double px = - pt *
sin(m_ac[1] + phi);
244 double py = pt *
cos(m_ac[1] + phi);
245 double pz = pt * m_ac[4];
246 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
248 return HepLorentzVector(px, py, pz, E);
266 double px = - pt *
sin(m_ac[1] + phi);
267 double py = pt *
cos(m_ac[1] + phi);
268 double pz = pt * m_ac[4];
269 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
271 if (m_matrixValid) Em = m_Ea.similarity(
del4MDelA(phi,
mass));
274 return HepLorentzVector(px, py, pz, E);
281 HepSymMatrix & Emx)
const {
294 double px = - pt *
sin(m_ac[1] + phi);
295 double py = pt *
cos(m_ac[1] + phi);
296 double pz = pt * m_ac[4];
297 double E = sqrt(pt * pt * (1. + m_ac[4] * m_ac[4]) +
mass *
mass);
299 x.setX(m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi)));
300 x.setY(m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi)));
301 x.setZ(m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi);
306 return HepLorentzVector(px, py, pz, E);
312 const double &
dr = m_ac[0];
313 const double &
phi0 = m_ac[1];
314 const double &
kappa = m_ac[2];
315 const double &
dz = m_ac[3];
316 const double &
tanl = m_ac[4];
318 double rdr = dr + m_r;
320 double csf0 =
cos(phi);
321 double snf0 = (1. - csf0) * (1. + csf0);
322 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
323 if(phi >
M_PI) snf0 = - snf0;
325 double xc = m_pivot.x() + rdr * csf0;
326 double yc = m_pivot.y() + rdr * snf0;
329 csf = (xc - newPivot.x()) / m_r;
330 snf = (yc - newPivot.y()) / m_r;
331 double anrm = sqrt(csf * csf + snf * snf);
335 phi = atan2(snf, csf);
346 double phid = fmod(phi - phi0 +
M_PI8,
M_PI2);
348 double drp = (m_pivot.x() + dr * csf0 + m_r * (csf0 - csf) - newPivot.x())
350 + (m_pivot.y() + dr * snf0 + m_r * (snf0 - snf) - newPivot.y()) * snf;
351 double dzp = m_pivot.z() + dz - m_r * tanl * phid - newPivot.z();
361 if (m_matrixValid) m_Ea = m_Ea.similarity(
delApDelA(ap));
374 const HepSymMatrix & Ea) {
378 m_matrixValid =
true;
384 if (
this == & i)
return *
this;
391 m_matrixValid = i.m_matrixValid;
393 m_center = i.m_center;
408Helix::updateCache(
void) {
424 if (m_ac[2] != 0.0) {
426 m_r = m_alpha / m_ac[2];
433 double x = m_pivot.x() + (m_ac[0] + m_r) * m_cp;
434 double y = m_pivot.y() + (m_ac[0] + m_r) * m_sp;
447 HepMatrix dApDA(5,5,0);
449 const double &
dr = m_ac[0];
450 const double &
phi0 = m_ac[1];
451 const double & cpa = m_ac[2];
452 const double &
dz = m_ac[3];
453 const double & tnl = m_ac[4];
456 double phi0p = ap[1];
461 double rdr = m_r + dr;
463 if ((m_r + drp) != 0.0) {
464 rdrpr = 1. / (m_r + drp);
470 double csfd =
cos(phi0p - phi0);
471 double snfd =
sin(phi0p - phi0);
472 double phid = fmod(phi0p - phi0 +
M_PI8,
M_PI2);
476 dApDA[0][1] = rdr*snfd;
478 dApDA[0][2] = (m_r/cpa)*( 1.0 - csfd );
483 dApDA[1][0] = - rdrpr*snfd;
484 dApDA[1][1] = rdr*rdrpr*csfd;
486 dApDA[1][2] = (m_r/cpa)*rdrpr*snfd;
493 dApDA[3][0] = m_r*rdrpr*tnl*snfd;
494 dApDA[3][1] = m_r*tnl*(1.0 - rdr*rdrpr*csfd);
496 dApDA[3][2] = (m_r/cpa)*tnl*(phid - m_r*rdrpr*snfd);
501 dApDA[3][4] = - m_r*phid;
516 HepMatrix dXDA(3,5,0);
518 const double &
dr = m_ac[0];
519 const double &
phi0 = m_ac[1];
520 const double & cpa = m_ac[2];
521 const double &
dz = m_ac[3];
522 const double & tnl = m_ac[4];
524 double cosf0phi =
cos(phi0 + phi);
525 double sinf0phi =
sin(phi0 + phi);
528 dXDA[0][1] = - dr * m_sp + m_r * (- m_sp + sinf0phi);
530 dXDA[0][2] = - (m_r / cpa) * (m_cp - cosf0phi);
538 dXDA[1][1] = dr * m_cp + m_r * (m_cp - cosf0phi);
540 dXDA[1][2] = - (m_r / cpa) * (m_sp - sinf0phi);
550 dXDA[2][2] = (m_r / cpa) * tnl * phi;
555 dXDA[2][4] = - m_r * phi;
570 HepMatrix dMDA(3,5,0);
572 const double &
phi0 = m_ac[1];
573 const double & cpa = m_ac[2];
574 const double & tnl = m_ac[4];
576 double cosf0phi =
cos(phi0+phi);
577 double sinf0phi =
sin(phi0+phi);
580 if(cpa != 0.)rho = 1./cpa;
584 if(cpa < 0.)charge = -1.;
586 dMDA[0][1] = -fabs(rho)*cosf0phi;
587 dMDA[0][2] = charge*rho*rho*sinf0phi;
589 dMDA[1][1] = -fabs(rho)*sinf0phi;
590 dMDA[1][2] = -charge*rho*rho*cosf0phi;
592 dMDA[2][2] = -charge*rho*rho*tnl;
593 dMDA[2][4] = fabs(rho);
607 HepMatrix d4MDA(4,5,0);
609 double phi0 = m_ac[1];
610 double cpa = m_ac[2];
611 double tnl = m_ac[4];
613 double cosf0phi =
cos(phi0+phi);
614 double sinf0phi =
sin(phi0+phi);
617 if(cpa != 0.)rho = 1./cpa;
621 if(cpa < 0.)charge = -1.;
623 double E = sqrt(rho*rho*(1.+tnl*tnl)+
mass*
mass);
625 d4MDA[0][1] = -fabs(rho)*cosf0phi;
626 d4MDA[0][2] = charge*rho*rho*sinf0phi;
628 d4MDA[1][1] = -fabs(rho)*sinf0phi;
629 d4MDA[1][2] = -charge*rho*rho*cosf0phi;
631 d4MDA[2][2] = -charge*rho*rho*tnl;
632 d4MDA[2][4] = fabs(rho);
634 if (cpa != 0.0 && E != 0.0) {
635 d4MDA[3][2] = (-1.-tnl*tnl)/(cpa*cpa*cpa*E);
636 d4MDA[3][4] = tnl/(cpa*cpa*E);
653 HepMatrix d4MXDA(7,5,0);
655 const double &
dr = m_ac[0];
656 const double &
phi0 = m_ac[1];
657 const double & cpa = m_ac[2];
658 const double &
dz = m_ac[3];
659 const double & tnl = m_ac[4];
661 double cosf0phi =
cos(phi0+phi);
662 double sinf0phi =
sin(phi0+phi);
665 if(cpa != 0.)rho = 1./cpa;
669 if(cpa < 0.)charge = -1.;
671 double E = sqrt(rho * rho * (1. + tnl * tnl) +
mass *
mass);
673 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
674 d4MXDA[0][2] = charge * rho * rho * sinf0phi;
676 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
677 d4MXDA[1][2] = - charge * rho * rho * cosf0phi;
679 d4MXDA[2][2] = - charge * rho * rho * tnl;
680 d4MXDA[2][4] = fabs(rho);
682 if (cpa != 0.0 && E != 0.0) {
683 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa * E);
684 d4MXDA[3][4] = tnl / (cpa * cpa * E);
691 d4MXDA[4][1] = - dr * m_sp + m_r * (- m_sp + sinf0phi);
693 d4MXDA[4][2] = - (m_r / cpa) * (m_cp - cosf0phi);
699 d4MXDA[5][1] = dr * m_cp + m_r * (m_cp - cosf0phi);
701 d4MXDA[5][2] = - (m_r / cpa) * (m_sp - sinf0phi);
703 d4MXDA[6][2] = (m_r / cpa) * tnl * phi;
711 d4MXDA[6][4] = - m_r * phi;
718 m_matrixValid =
false;
725 double l =
center().perp();
727 double cosPhi = (m_rad * m_rad + l * l - r * r) / (2 * m_rad * l);
729 if(cosPhi < -1 || cosPhi > 1)
return 0;
**********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 sin(const BesAngle a)
double cos(const BesAngle a)
NTuple::Item< double > m_pt
HepMatrix delApDelA(const HepVector &ap) const
static const double ConstantAlpha
Constant alpha for uniform field.
HepMatrix delMDelA(double phi) const
double dPhi(HepPoint3D &hit) const
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
void ignoreErrorMatrix(void)
unsets error matrix. Error calculations will be ignored after this function call until an error matri...
Helix & operator=(const Helix &)
Copy operator.
IMagneticFieldSvc * m_pmgnIMF
HepMatrix del4MXDelA(double phi, double mass) const
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
double IntersectCylinder(double r) const
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
HepMatrix del4MDelA(double phi, double mass) const
HepMatrix delXDelA(double phi) const
double radius(void) const
returns radious of helix.
double dr(void) const
returns an element of parameters.
virtual ~Helix()
Destructor.
const HepPoint3D & pivot(void) const
returns pivot position.
virtual double getReferField()=0