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;
74 m_Ea(HepSymMatrix(5,0)) {
75 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",
m_pmgnIMF);
76 if(scmgn!=StatusCode::SUCCESS) {
78 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
95 m_Ea(HepSymMatrix(5,0)) {
96 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",
m_pmgnIMF);
97 if(scmgn!=StatusCode::SUCCESS) {
99 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
110 m_a[2] = charge / perp;
138 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
139 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
140 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
155 p[0] = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi));
156 p[1] = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi));
157 p[2] = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
164 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
165 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
166 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
177 if (m_matrixValid) Ex = m_Ea.similarity(
delXDelA(phi));
196 double px = - pt *
sin(m_ac[1] + phi);
197 double py = pt *
cos(m_ac[1] + phi);
198 double pz = pt * m_ac[4];
200 return Hep3Vector(px, py, pz);
216 double px = - pt *
sin(m_ac[1] + phi);
217 double py = pt *
cos(m_ac[1] + phi);
218 double pz = pt * m_ac[4];
220 if (m_matrixValid) Em = m_Ea.similarity(
delMDelA(phi));
223 return Hep3Vector(px, py, pz);
240 double px = - pt *
sin(m_ac[1] + phi);
241 double py = pt *
cos(m_ac[1] + phi);
242 double pz = pt * m_ac[4];
243 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
245 return HepLorentzVector(px, py, pz, E);
263 double px = - pt *
sin(m_ac[1] + phi);
264 double py = pt *
cos(m_ac[1] + phi);
265 double pz = pt * m_ac[4];
266 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
268 if (m_matrixValid) Em = m_Ea.similarity(
del4MDelA(phi,
mass));
271 return HepLorentzVector(px, py, pz, E);
278 HepSymMatrix & Emx)
const {
291 double px = - pt *
sin(m_ac[1] + phi);
292 double py = pt *
cos(m_ac[1] + phi);
293 double pz = pt * m_ac[4];
294 double E = sqrt(pt * pt * (1. + m_ac[4] * m_ac[4]) +
mass *
mass);
296 x.setX(m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi)));
297 x.setY(m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi)));
298 x.setZ(m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi);
303 return HepLorentzVector(px, py, pz, E);
309 const double &
dr = m_ac[0];
310 const double &
phi0 = m_ac[1];
311 const double &
kappa = m_ac[2];
312 const double &
dz = m_ac[3];
313 const double &
tanl = m_ac[4];
315 double rdr = dr + m_r;
317 double csf0 =
cos(phi);
318 double snf0 = (1. - csf0) * (1. + csf0);
319 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
320 if(phi >
M_PI) snf0 = - snf0;
322 double xc = m_pivot.x() + rdr * csf0;
323 double yc = m_pivot.y() + rdr * snf0;
326 csf = (xc - newPivot.x()) / m_r;
327 snf = (yc - newPivot.y()) / m_r;
328 double anrm = sqrt(csf * csf + snf * snf);
332 phi = atan2(snf, csf);
343 double phid = fmod(phi - phi0 +
M_PI8,
M_PI2);
345 double drp = (m_pivot.x() + dr * csf0 + m_r * (csf0 - csf) - newPivot.x())
347 + (m_pivot.y() + dr * snf0 + m_r * (snf0 - snf) - newPivot.y()) * snf;
348 double dzp = m_pivot.z() + dz - m_r * tanl * phid - newPivot.z();
358 if (m_matrixValid) m_Ea = m_Ea.similarity(
delApDelA(ap));
371 const HepSymMatrix & Ea) {
375 m_matrixValid =
true;
381 if (
this == & i)
return *
this;
388 m_matrixValid = i.m_matrixValid;
390 m_center = i.m_center;
405Helix::updateCache(
void) {
421 if (m_ac[2] != 0.0) {
423 m_r = m_alpha / m_ac[2];
430 double x = m_pivot.x() + (m_ac[0] + m_r) * m_cp;
431 double y = m_pivot.y() + (m_ac[0] + m_r) * m_sp;
444 HepMatrix dApDA(5,5,0);
446 const double &
dr = m_ac[0];
447 const double &
phi0 = m_ac[1];
448 const double & cpa = m_ac[2];
449 const double &
dz = m_ac[3];
450 const double & tnl = m_ac[4];
453 double phi0p = ap[1];
458 double rdr = m_r + dr;
460 if ((m_r + drp) != 0.0) {
461 rdrpr = 1. / (m_r + drp);
467 double csfd =
cos(phi0p - phi0);
468 double snfd =
sin(phi0p - phi0);
469 double phid = fmod(phi0p - phi0 +
M_PI8,
M_PI2);
473 dApDA[0][1] = rdr*snfd;
475 dApDA[0][2] = (m_r/cpa)*( 1.0 - csfd );
480 dApDA[1][0] = - rdrpr*snfd;
481 dApDA[1][1] = rdr*rdrpr*csfd;
483 dApDA[1][2] = (m_r/cpa)*rdrpr*snfd;
490 dApDA[3][0] = m_r*rdrpr*tnl*snfd;
491 dApDA[3][1] = m_r*tnl*(1.0 - rdr*rdrpr*csfd);
493 dApDA[3][2] = (m_r/cpa)*tnl*(phid - m_r*rdrpr*snfd);
498 dApDA[3][4] = - m_r*phid;
513 HepMatrix dXDA(3,5,0);
515 const double &
dr = m_ac[0];
516 const double &
phi0 = m_ac[1];
517 const double & cpa = m_ac[2];
518 const double &
dz = m_ac[3];
519 const double & tnl = m_ac[4];
521 double cosf0phi =
cos(phi0 + phi);
522 double sinf0phi =
sin(phi0 + phi);
525 dXDA[0][1] = - dr * m_sp + m_r * (- m_sp + sinf0phi);
527 dXDA[0][2] = - (m_r / cpa) * (m_cp - cosf0phi);
535 dXDA[1][1] = dr * m_cp + m_r * (m_cp - cosf0phi);
537 dXDA[1][2] = - (m_r / cpa) * (m_sp - sinf0phi);
547 dXDA[2][2] = (m_r / cpa) * tnl * phi;
552 dXDA[2][4] = - m_r * phi;
567 HepMatrix dMDA(3,5,0);
569 const double &
phi0 = m_ac[1];
570 const double & cpa = m_ac[2];
571 const double & tnl = m_ac[4];
573 double cosf0phi =
cos(phi0+phi);
574 double sinf0phi =
sin(phi0+phi);
577 if(cpa != 0.)rho = 1./cpa;
581 if(cpa < 0.)charge = -1.;
583 dMDA[0][1] = -fabs(rho)*cosf0phi;
584 dMDA[0][2] = charge*rho*rho*sinf0phi;
586 dMDA[1][1] = -fabs(rho)*sinf0phi;
587 dMDA[1][2] = -charge*rho*rho*cosf0phi;
589 dMDA[2][2] = -charge*rho*rho*tnl;
590 dMDA[2][4] = fabs(rho);
604 HepMatrix d4MDA(4,5,0);
606 double phi0 = m_ac[1];
607 double cpa = m_ac[2];
608 double tnl = m_ac[4];
610 double cosf0phi =
cos(phi0+phi);
611 double sinf0phi =
sin(phi0+phi);
614 if(cpa != 0.)rho = 1./cpa;
618 if(cpa < 0.)charge = -1.;
620 double E = sqrt(rho*rho*(1.+tnl*tnl)+
mass*
mass);
622 d4MDA[0][1] = -fabs(rho)*cosf0phi;
623 d4MDA[0][2] = charge*rho*rho*sinf0phi;
625 d4MDA[1][1] = -fabs(rho)*sinf0phi;
626 d4MDA[1][2] = -charge*rho*rho*cosf0phi;
628 d4MDA[2][2] = -charge*rho*rho*tnl;
629 d4MDA[2][4] = fabs(rho);
631 if (cpa != 0.0 && E != 0.0) {
632 d4MDA[3][2] = (-1.-tnl*tnl)/(cpa*cpa*cpa*E);
633 d4MDA[3][4] = tnl/(cpa*cpa*E);
650 HepMatrix d4MXDA(7,5,0);
652 const double &
dr = m_ac[0];
653 const double &
phi0 = m_ac[1];
654 const double & cpa = m_ac[2];
655 const double &
dz = m_ac[3];
656 const double & tnl = m_ac[4];
658 double cosf0phi =
cos(phi0+phi);
659 double sinf0phi =
sin(phi0+phi);
662 if(cpa != 0.)rho = 1./cpa;
666 if(cpa < 0.)charge = -1.;
668 double E = sqrt(rho * rho * (1. + tnl * tnl) +
mass *
mass);
670 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
671 d4MXDA[0][2] = charge * rho * rho * sinf0phi;
673 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
674 d4MXDA[1][2] = - charge * rho * rho * cosf0phi;
676 d4MXDA[2][2] = - charge * rho * rho * tnl;
677 d4MXDA[2][4] = fabs(rho);
679 if (cpa != 0.0 && E != 0.0) {
680 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa * E);
681 d4MXDA[3][4] = tnl / (cpa * cpa * E);
688 d4MXDA[4][1] = - dr * m_sp + m_r * (- m_sp + sinf0phi);
690 d4MXDA[4][2] = - (m_r / cpa) * (m_cp - cosf0phi);
696 d4MXDA[5][1] = dr * m_cp + m_r * (m_cp - cosf0phi);
698 d4MXDA[5][2] = - (m_r / cpa) * (m_sp - sinf0phi);
700 d4MXDA[6][2] = (m_r / cpa) * tnl * phi;
708 d4MXDA[6][4] = - m_r * phi;
715 m_matrixValid =
false;
double sin(const BesAngle a)
double cos(const BesAngle a)
**********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
NTuple::Item< double > m_pt
HepMatrix delApDelA(const HepVector &ap) const
HepMatrix delMDelA(double phi) const
IMagneticFieldSvc * m_pmgnIMF
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.
HepMatrix del4MXDelA(double phi, double mass) const
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
static const double ConstantAlpha
Constant alpha for uniform field.
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 dr(void) const
returns an element of parameters.
virtual ~Helix()
Destructor.
Helix(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
Constructor with pivot, helix parameter a, and its error matrix.
const HepPoint3D & pivot(void) const
returns pivot position.
virtual double getReferField()=0