13#define Helix Ext_Helix
21#include "CLHEP/Matrix/Matrix.h"
22#include "GaudiKernel/StatusCode.h"
23#include "GaudiKernel/IInterface.h"
24#include "GaudiKernel/Kernel.h"
25#include "GaudiKernel/Service.h"
26#include "GaudiKernel/ISvcLocator.h"
27#include "GaudiKernel/SvcFactory.h"
28#include "GaudiKernel/IDataProviderSvc.h"
29#include "GaudiKernel/Bootstrap.h"
30#include "GaudiKernel/MsgStream.h"
31#include "GaudiKernel/SmartDataPtr.h"
32#include "GaudiKernel/IMessageSvc.h"
54 const HepSymMatrix & Ea)
61 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",m_pmgnIMF);
62 if(scmgn!=StatusCode::SUCCESS) {
63 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
66 m_alpha = 10000. / 2.99792458 / m_bField;
79 m_Ea(HepSymMatrix(5,0)) {
80 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",m_pmgnIMF);
81 if(scmgn!=StatusCode::SUCCESS) {
83 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
86 m_alpha = 10000. / 2.99792458 / m_bField;
100 m_Ea(HepSymMatrix(5,0)) {
101 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",m_pmgnIMF);
102 if(scmgn!=StatusCode::SUCCESS) {
104 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
107 m_alpha = 10000. / 2.99792458 / m_bField;
115 m_a[2] = charge / perp;
143 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
144 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
145 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
160 p[0] = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi));
161 p[1] = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi));
162 p[2] = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
169 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
170 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
171 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
182 if (m_matrixValid) Ex = m_Ea.similarity(
delXDelA(phi));
200 double pt = fabs(m_pt);
201 double px = - pt *
sin(m_ac[1] + phi);
202 double py = pt *
cos(m_ac[1] + phi);
203 double pz = pt * m_ac[4];
205 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];
225 if (m_matrixValid) Em = m_Ea.similarity(
delMDelA(phi));
228 return Hep3Vector(px, py, pz);
244 double pt = fabs(m_pt);
245 double px = - pt *
sin(m_ac[1] + phi);
246 double py = pt *
cos(m_ac[1] + phi);
247 double pz = pt * m_ac[4];
248 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
250 return HepLorentzVector(px, py, pz, E);
267 double pt = fabs(m_pt);
268 double px = - pt *
sin(m_ac[1] + phi);
269 double py = pt *
cos(m_ac[1] + phi);
270 double pz = pt * m_ac[4];
271 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
273 if (m_matrixValid) Em = m_Ea.similarity(
del4MDelA(phi,
mass));
276 return HepLorentzVector(px, py, pz, E);
283 HepSymMatrix & Emx)
const {
295 double pt = fabs(m_pt);
296 double px = - pt *
sin(m_ac[1] + phi);
297 double py = pt *
cos(m_ac[1] + phi);
298 double pz = pt * m_ac[4];
299 double E = sqrt(pt * pt * (1. + m_ac[4] * m_ac[4]) +
mass *
mass);
301 x.setX(m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi)));
302 x.setY(m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi)));
303 x.setZ(m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi);
308 return HepLorentzVector(px, py, pz, E);
314 const double &
dr = m_ac[0];
315 const double &
phi0 = m_ac[1];
316 const double &
kappa = m_ac[2];
317 const double &
dz = m_ac[3];
318 const double &
tanl = m_ac[4];
320 double rdr =
dr + m_r;
322 double csf0 =
cos(phi);
323 double snf0 = (1. - csf0) * (1. + csf0);
324 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
325 if(phi >
M_PI) snf0 = - snf0;
327 double xc = m_pivot.x() + rdr * csf0;
328 double yc = m_pivot.y() + rdr * snf0;
331 csf = (xc - newPivot.x()) / m_r;
332 snf = (yc - newPivot.y()) / m_r;
333 double anrm = sqrt(csf * csf + snf * snf);
337 phi = atan2(snf, csf);
350 double drp = (m_pivot.x() +
dr * csf0 + m_r * (csf0 - csf) - newPivot.x())
352 + (m_pivot.y() +
dr * snf0 + m_r * (snf0 - snf) - newPivot.y()) * snf;
353 double dzp = m_pivot.z() +
dz - m_r *
tanl * phid - newPivot.z();
363 if (m_matrixValid) m_Ea = m_Ea.similarity(
delApDelA(ap));
376 const HepSymMatrix & Ea) {
380 m_matrixValid =
true;
386 if (
this == & i)
return *
this;
388 m_bField = i.m_bField;
393 m_matrixValid = i.m_matrixValid;
395 m_center = i.m_center;
410Ext_Helix::updateCache(
void) {
426 if (m_ac[2] != 0.0) {
428 m_r = m_alpha / m_ac[2];
435 double x = m_pivot.x() + (m_ac[0] + m_r) * m_cp;
436 double y = m_pivot.y() + (m_ac[0] + m_r) * m_sp;
449 HepMatrix dApDA(5,5,0);
451 const double &
dr = m_ac[0];
452 const double &
phi0 = m_ac[1];
453 const double & cpa = m_ac[2];
454 const double &
dz = m_ac[3];
455 const double & tnl = m_ac[4];
458 double phi0p = ap[1];
463 double rdr = m_r +
dr;
465 if ((m_r + drp) != 0.0) {
466 rdrpr = 1. / (m_r + drp);
472 double csfd =
cos(phi0p -
phi0);
473 double snfd =
sin(phi0p -
phi0);
478 dApDA[0][1] = rdr*snfd;
480 dApDA[0][2] = (m_r/cpa)*( 1.0 - csfd );
485 dApDA[1][0] = - rdrpr*snfd;
486 dApDA[1][1] = rdr*rdrpr*csfd;
488 dApDA[1][2] = (m_r/cpa)*rdrpr*snfd;
495 dApDA[3][0] = m_r*rdrpr*tnl*snfd;
496 dApDA[3][1] = m_r*tnl*(1.0 - rdr*rdrpr*csfd);
498 dApDA[3][2] = (m_r/cpa)*tnl*(phid - m_r*rdrpr*snfd);
503 dApDA[3][4] = - m_r*phid;
518 HepMatrix dXDA(3,5,0);
520 const double &
dr = m_ac[0];
521 const double &
phi0 = m_ac[1];
522 const double & cpa = m_ac[2];
523 const double &
dz = m_ac[3];
524 const double & tnl = m_ac[4];
526 double cosf0phi =
cos(
phi0 + phi);
527 double sinf0phi =
sin(
phi0 + phi);
530 dXDA[0][1] = -
dr * m_sp + m_r * (- m_sp + sinf0phi);
532 dXDA[0][2] = - (m_r / cpa) * (m_cp - cosf0phi);
540 dXDA[1][1] =
dr * m_cp + m_r * (m_cp - cosf0phi);
542 dXDA[1][2] = - (m_r / cpa) * (m_sp - sinf0phi);
552 dXDA[2][2] = (m_r / cpa) * tnl * phi;
557 dXDA[2][4] = - m_r * phi;
572 HepMatrix dMDA(3,5,0);
574 const double &
phi0 = m_ac[1];
575 const double & cpa = m_ac[2];
576 const double & tnl = m_ac[4];
578 double cosf0phi =
cos(
phi0+phi);
579 double sinf0phi =
sin(
phi0+phi);
582 if(cpa != 0.)rho = 1./cpa;
586 if(cpa < 0.)charge = -1.;
588 dMDA[0][1] = -fabs(rho)*cosf0phi;
589 dMDA[0][2] = charge*rho*rho*sinf0phi;
591 dMDA[1][1] = -fabs(rho)*sinf0phi;
592 dMDA[1][2] = -charge*rho*rho*cosf0phi;
594 dMDA[2][2] = -charge*rho*rho*tnl;
595 dMDA[2][4] = fabs(rho);
609 HepMatrix d4MDA(4,5,0);
611 double phi0 = m_ac[1];
612 double cpa = m_ac[2];
613 double tnl = m_ac[4];
615 double cosf0phi =
cos(
phi0+phi);
616 double sinf0phi =
sin(
phi0+phi);
619 if(cpa != 0.)rho = 1./cpa;
623 if(cpa < 0.)charge = -1.;
625 double E = sqrt(rho*rho*(1.+tnl*tnl)+
mass*
mass);
627 d4MDA[0][1] = -fabs(rho)*cosf0phi;
628 d4MDA[0][2] = charge*rho*rho*sinf0phi;
630 d4MDA[1][1] = -fabs(rho)*sinf0phi;
631 d4MDA[1][2] = -charge*rho*rho*cosf0phi;
633 d4MDA[2][2] = -charge*rho*rho*tnl;
634 d4MDA[2][4] = fabs(rho);
636 if (cpa != 0.0 && E != 0.0) {
637 d4MDA[3][2] = (-1.-tnl*tnl)/(cpa*cpa*cpa*E);
638 d4MDA[3][4] = tnl/(cpa*cpa*E);
655 HepMatrix d4MXDA(7,5,0);
657 const double &
dr = m_ac[0];
658 const double &
phi0 = m_ac[1];
659 const double & cpa = m_ac[2];
660 const double &
dz = m_ac[3];
661 const double & tnl = m_ac[4];
663 double cosf0phi =
cos(
phi0+phi);
664 double sinf0phi =
sin(
phi0+phi);
667 if(cpa != 0.)rho = 1./cpa;
671 if(cpa < 0.)charge = -1.;
673 double E = sqrt(rho * rho * (1. + tnl * tnl) +
mass *
mass);
675 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
676 d4MXDA[0][2] = charge * rho * rho * sinf0phi;
678 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
679 d4MXDA[1][2] = - charge * rho * rho * cosf0phi;
681 d4MXDA[2][2] = - charge * rho * rho * tnl;
682 d4MXDA[2][4] = fabs(rho);
684 if (cpa != 0.0 && E != 0.0) {
685 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa * E);
686 d4MXDA[3][4] = tnl / (cpa * cpa * E);
693 d4MXDA[4][1] = -
dr * m_sp + m_r * (- m_sp + sinf0phi);
695 d4MXDA[4][2] = - (m_r / cpa) * (m_cp - cosf0phi);
701 d4MXDA[5][1] =
dr * m_cp + m_r * (m_cp - cosf0phi);
703 d4MXDA[5][2] = - (m_r / cpa) * (m_sp - sinf0phi);
705 d4MXDA[6][2] = (m_r / cpa) * tnl * phi;
713 d4MXDA[6][4] = - m_r * phi;
720 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
void ignoreErrorMatrix(void)
unsets error matrix. Error calculations will be ignored after this function call until an error matri...
HepMatrix del4MDelA(double phi, double mass) const
HepMatrix delMDelA(double phi) const
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
HepMatrix del4MXDelA(double phi, double mass) const
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
virtual ~Ext_Helix()
Destructor.
double dr(void) const
returns an element of parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
HepMatrix delXDelA(double phi) const
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
Ext_Helix & operator=(const Ext_Helix &)
Copy operator.
const HepVector & a(void) const
returns helix parameters.
HepMatrix delApDelA(const HepVector &ap) const
Ext_Helix(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
Constructor with pivot, helix parameter a, and its error matrix.
virtual double getReferField()=0