96#include "CLHEP/Matrix/Matrix.h"
97#include "GaudiKernel/StatusCode.h"
98#include "GaudiKernel/IInterface.h"
99#include "GaudiKernel/Kernel.h"
100#include "GaudiKernel/Service.h"
101#include "GaudiKernel/Kernel.h"
102#include "GaudiKernel/ISvcLocator.h"
103#include "GaudiKernel/SvcFactory.h"
104#include "GaudiKernel/IDataProviderSvc.h"
105#include "GaudiKernel/Bootstrap.h"
106#include "GaudiKernel/MsgStream.h"
107#include "GaudiKernel/SmartDataPtr.h"
108#include "GaudiKernel/IMessageSvc.h"
109#include "GaudiKernel/IPartPropSvc.h"
111#include "GaudiKernel/SmartDataPtr.h"
128 const HepSymMatrix & Ea)
136 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc",m_pmgnIMF);
137 if(scmgn!=StatusCode::SUCCESS) {
139 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
142 m_alpha = 10000. / 2.99792458 / m_bField;
153 m_matrixValid(
false),
154 m_Ea(HepSymMatrix(5,0)) {
155 StatusCode scmgn = Gaudi::svcLocator()->service (
"MagneticFieldSvc",m_pmgnIMF);
156 if(scmgn!=StatusCode::SUCCESS) {
158 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
161 m_alpha = 10000. / 2.99792458 / m_bField;
174 m_matrixValid(
false),
175 m_Ea(HepSymMatrix(5,0)) {
176 StatusCode scmgn = Gaudi::svcLocator()->service (
"MagneticFieldSvc",m_pmgnIMF);
177 if(scmgn!=StatusCode::SUCCESS) {
179 std::cout<<
"Unable to open Magnetic field service"<<std::endl;
182 m_alpha = 10000. / 2.99792458 / m_bField;
190 m_a[2] = charge / perp;
222 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
223 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
224 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
239 p[0] = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi));
240 p[1] = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi));
241 p[2] = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
248 double x = m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] +phi));
249 double y = m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] +phi));
250 double z = m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi;
261 if (m_matrixValid) Ex = m_Ea.similarity(
delXDelA(phi));
279 double pt = fabs(m_pt);
280 double px = - pt *
sin(m_ac[1] + phi);
281 double py = pt *
cos(m_ac[1] + phi);
282 double pz = pt * m_ac[4];
284 return Hep3Vector(px, py, pz);
299 double pt = fabs(m_pt);
300 double px = - pt *
sin(m_ac[1] + phi);
301 double py = pt *
cos(m_ac[1] + phi);
302 double pz = pt * m_ac[4];
304 if (m_matrixValid) Em = m_Ea.similarity(
delMDelA(phi));
307 return Hep3Vector(px, py, pz);
323 double pt = fabs(m_pt);
324 double px = - pt *
sin(m_ac[1] + phi);
325 double py = pt *
cos(m_ac[1] + phi);
326 double pz = pt * m_ac[4];
327 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
329 return HepLorentzVector(px, py, pz, E);
346 double pt = fabs(m_pt);
347 double px = - pt *
sin(m_ac[1] + phi);
348 double py = pt *
cos(m_ac[1] + phi);
349 double pz = pt * m_ac[4];
350 double E = sqrt(pt*pt*(1.+m_ac[4]*m_ac[4])+
mass*
mass);
352 if (m_matrixValid) Em = m_Ea.similarity(
del4MDelA(phi,
mass));
355 return HepLorentzVector(px, py, pz, E);
362 HepSymMatrix & Emx)
const {
374 double pt = fabs(m_pt);
375 double px = - pt *
sin(m_ac[1] + phi);
376 double py = pt *
cos(m_ac[1] + phi);
377 double pz = pt * m_ac[4];
378 double E = sqrt(pt * pt * (1. + m_ac[4] * m_ac[4]) +
mass *
mass);
380 x.setX(m_pivot.x() + m_ac[0] * m_cp + m_r * (m_cp -
cos(m_ac[1] + phi)));
381 x.setY(m_pivot.y() + m_ac[0] * m_sp + m_r * (m_sp -
sin(m_ac[1] + phi)));
382 x.setZ(m_pivot.z() + m_ac[3] - m_r * m_ac[4] * phi);
387 return HepLorentzVector(px, py, pz, E);
393 const double &
dr = m_ac[0];
394 const double &
phi0 = m_ac[1];
395 const double &
kappa = m_ac[2];
396 const double &
dz = m_ac[3];
397 const double &
tanl = m_ac[4];
399 double rdr =
dr + m_r;
401 double csf0 =
cos(phi);
402 double snf0 = (1. - csf0) * (1. + csf0);
403 snf0 = sqrt((snf0 > 0.) ? snf0 : 0.);
404 if(phi >
M_PI) snf0 = - snf0;
406 double xc = m_pivot.x() + rdr * csf0;
407 double yc = m_pivot.y() + rdr * snf0;
410 csf = (xc - newPivot.x()) / m_r;
411 snf = (yc - newPivot.y()) / m_r;
412 double anrm = sqrt(csf * csf + snf * snf);
416 phi = atan2(snf, csf);
429 double drp = (m_pivot.x() +
dr * csf0 + m_r * (csf0 - csf) - newPivot.x())
431 + (m_pivot.y() +
dr * snf0 + m_r * (snf0 - snf) - newPivot.y()) * snf;
432 double dzp = m_pivot.z() +
dz - m_r *
tanl * phid - newPivot.z();
442 if (m_matrixValid) m_Ea = m_Ea.similarity(
delApDelA(ap));
455 const HepSymMatrix & Ea) {
459 m_matrixValid =
true;
465 if (
this == & i)
return *
this;
467 m_bField = i.m_bField;
472 m_matrixValid = i.m_matrixValid;
474 m_center = i.m_center;
489Dedx_Helix::updateCache(
void) {
505 if (m_ac[2] != 0.0) {
507 m_r = m_alpha / m_ac[2];
514 double x = m_pivot.x() + (m_ac[0] + m_r) * m_cp;
515 double y = m_pivot.y() + (m_ac[0] + m_r) * m_sp;
528 HepMatrix dApDA(5,5,0);
530 const double &
dr = m_ac[0];
531 const double &
phi0 = m_ac[1];
532 const double & cpa = m_ac[2];
533 const double &
dz = m_ac[3];
534 const double & tnl = m_ac[4];
537 double phi0p = ap[1];
542 double rdr = m_r +
dr;
544 if ((m_r + drp) != 0.0) {
545 rdrpr = 1. / (m_r + drp);
551 double csfd =
cos(phi0p -
phi0);
552 double snfd =
sin(phi0p -
phi0);
557 dApDA[0][1] = rdr*snfd;
559 dApDA[0][2] = (m_r/cpa)*( 1.0 - csfd );
564 dApDA[1][0] = - rdrpr*snfd;
565 dApDA[1][1] = rdr*rdrpr*csfd;
567 dApDA[1][2] = (m_r/cpa)*rdrpr*snfd;
574 dApDA[3][0] = m_r*rdrpr*tnl*snfd;
575 dApDA[3][1] = m_r*tnl*(1.0 - rdr*rdrpr*csfd);
577 dApDA[3][2] = (m_r/cpa)*tnl*(phid - m_r*rdrpr*snfd);
582 dApDA[3][4] = - m_r*phid;
597 HepMatrix dXDA(3,5,0);
599 const double &
dr = m_ac[0];
600 const double &
phi0 = m_ac[1];
601 const double & cpa = m_ac[2];
602 const double &
dz = m_ac[3];
603 const double & tnl = m_ac[4];
605 double cosf0phi =
cos(
phi0 + phi);
606 double sinf0phi =
sin(
phi0 + phi);
609 dXDA[0][1] = -
dr * m_sp + m_r * (- m_sp + sinf0phi);
611 dXDA[0][2] = - (m_r / cpa) * (m_cp - cosf0phi);
619 dXDA[1][1] =
dr * m_cp + m_r * (m_cp - cosf0phi);
621 dXDA[1][2] = - (m_r / cpa) * (m_sp - sinf0phi);
631 dXDA[2][2] = (m_r / cpa) * tnl * phi;
636 dXDA[2][4] = - m_r * phi;
651 HepMatrix dMDA(3,5,0);
653 const double &
phi0 = m_ac[1];
654 const double & cpa = m_ac[2];
655 const double & tnl = m_ac[4];
657 double cosf0phi =
cos(
phi0+phi);
658 double sinf0phi =
sin(
phi0+phi);
661 if(cpa != 0.)rho = 1./cpa;
665 if(cpa < 0.)charge = -1.;
667 dMDA[0][1] = -fabs(rho)*cosf0phi;
668 dMDA[0][2] = charge*rho*rho*sinf0phi;
670 dMDA[1][1] = -fabs(rho)*sinf0phi;
671 dMDA[1][2] = -charge*rho*rho*cosf0phi;
673 dMDA[2][2] = -charge*rho*rho*tnl;
674 dMDA[2][4] = fabs(rho);
688 HepMatrix d4MDA(4,5,0);
690 double phi0 = m_ac[1];
691 double cpa = m_ac[2];
692 double tnl = m_ac[4];
694 double cosf0phi =
cos(
phi0+phi);
695 double sinf0phi =
sin(
phi0+phi);
698 if(cpa != 0.)rho = 1./cpa;
702 if(cpa < 0.)charge = -1.;
704 double E = sqrt(rho*rho*(1.+tnl*tnl)+
mass*
mass);
706 d4MDA[0][1] = -fabs(rho)*cosf0phi;
707 d4MDA[0][2] = charge*rho*rho*sinf0phi;
709 d4MDA[1][1] = -fabs(rho)*sinf0phi;
710 d4MDA[1][2] = -charge*rho*rho*cosf0phi;
712 d4MDA[2][2] = -charge*rho*rho*tnl;
713 d4MDA[2][4] = fabs(rho);
715 if (cpa != 0.0 && E != 0.0) {
716 d4MDA[3][2] = (-1.-tnl*tnl)/(cpa*cpa*cpa*E);
717 d4MDA[3][4] = tnl/(cpa*cpa*E);
734 HepMatrix d4MXDA(7,5,0);
736 const double &
dr = m_ac[0];
737 const double &
phi0 = m_ac[1];
738 const double & cpa = m_ac[2];
739 const double &
dz = m_ac[3];
740 const double & tnl = m_ac[4];
742 double cosf0phi =
cos(
phi0+phi);
743 double sinf0phi =
sin(
phi0+phi);
746 if(cpa != 0.)rho = 1./cpa;
750 if(cpa < 0.)charge = -1.;
752 double E = sqrt(rho * rho * (1. + tnl * tnl) +
mass *
mass);
754 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
755 d4MXDA[0][2] = charge * rho * rho * sinf0phi;
757 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
758 d4MXDA[1][2] = - charge * rho * rho * cosf0phi;
760 d4MXDA[2][2] = - charge * rho * rho * tnl;
761 d4MXDA[2][4] = fabs(rho);
763 if (cpa != 0.0 && E != 0.0) {
764 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa * E);
765 d4MXDA[3][4] = tnl / (cpa * cpa * E);
772 d4MXDA[4][1] = -
dr * m_sp + m_r * (- m_sp + sinf0phi);
774 d4MXDA[4][2] = - (m_r / cpa) * (m_cp - cosf0phi);
780 d4MXDA[5][1] =
dr * m_cp + m_r * (m_cp - cosf0phi);
782 d4MXDA[5][2] = - (m_r / cpa) * (m_sp - sinf0phi);
784 d4MXDA[6][2] = (m_r / cpa) * tnl * phi;
792 d4MXDA[6][4] = - m_r * phi;
799 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
HepMatrix del4MDelA(double phi, double mass) const
const HepVector & a(void) const
returns helix parameters.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
static const double ConstantAlpha
Constant alpha for uniform field.
Dedx_Helix & operator=(const Dedx_Helix &)
Copy operator.
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
virtual ~Dedx_Helix()
Destructor.
HepMatrix delMDelA(double phi) const
const HepSymMatrix & Ea(void) const
returns error matrix.
Dedx_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.
double dr(void) const
returns an element of parameters.
void ignoreErrorMatrix(void)
unsets error matrix. Error calculations will be ignored after this function call until an error matri...
HepMatrix delXDelA(double phi) const
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
HepMatrix delApDelA(const HepVector &ap) const
virtual double getReferField()=0