86#include <cdc/simulation/Helix.h>
87#include <CLHEP/Matrix/Matrix.h>
129 if (a_min.num_row() != 5 || a_max.num_row() != 5)
return;
138 const HepSymMatrix&
Ea)
149 if (
m_a.num_row() == 5 &&
m_Ea.num_row() == 5) {
162 m_Ea(HepSymMatrix(5, 0))
165 if (
m_a.num_row() == 5) {
178 m_a(HepVector(5, 0)),
179 m_Ea(HepSymMatrix(5, 0))
187 m_a[2] = charge / perp;
190 m_a[2] = charge * (DBL_MAX);
216 return HepPoint3D(
x, y, z);
259 return HepPoint3D(
x, y, z);
276 double pt = fabs(
m_pt);
277 double px = - pt * sin(
m_ac[1] + phi);
278 double py = pt * cos(
m_ac[1] + phi);
279 double pz = pt *
m_ac[4];
281 return Hep3Vector(px, py, pz);
298 double pt = fabs(
m_pt);
299 double px = - pt * sin(
m_ac[1] + phi);
300 double py = pt * cos(
m_ac[1] + phi);
301 double pz = pt *
m_ac[4];
306 return Hep3Vector(px, py, pz);
324 double pt = fabs(
m_pt);
325 double px = - pt * sin(
m_ac[1] + phi);
326 double py = pt * cos(
m_ac[1] + phi);
327 double pz = pt *
m_ac[4];
328 double E =
sqrt(pt * pt * (1. +
m_ac[4] *
m_ac[4]) + mass * mass);
330 return HepLorentzVector(px, py, pz,
E);
349 double pt = fabs(
m_pt);
350 double px = - pt * sin(
m_ac[1] + phi);
351 double py = pt * cos(
m_ac[1] + phi);
352 double pz = pt *
m_ac[4];
353 double E =
sqrt(pt * pt * (1. +
m_ac[4] *
m_ac[4]) + mass * mass);
358 return HepLorentzVector(px, py, pz,
E);
365 HepSymMatrix& Emx)
const
379 double pt = fabs(
m_pt);
380 double px = - pt * sin(
m_ac[1] + phi);
381 double py = pt * cos(
m_ac[1] + phi);
382 double pz = pt *
m_ac[4];
383 double E =
sqrt(pt * pt * (1. +
m_ac[4] *
m_ac[4]) + mass * mass);
392 return HepLorentzVector(px, py, pz,
E);
400#if defined(BELLE_DEBUG)
403 const double&
dr =
m_ac[0];
406 const double&
dz =
m_ac[3];
409 double rdr =
dr +
m_r;
411 double csf0 = cos(phi);
412 double snf0 = (1. - csf0) * (1. + csf0);
413 snf0 =
sqrt((snf0 > 0.) ? snf0 : 0.);
414 if (phi > M_PI) snf0 = - snf0;
416 double xc =
m_pivot.x() + rdr * csf0;
417 double yc =
m_pivot.y() + rdr * snf0;
420 csf = (xc - newPivot.x()) /
m_r;
421 snf = (yc - newPivot.y()) /
m_r;
422 double anrm =
sqrt(csf * csf + snf * snf);
426 phi = atan2(snf, csf);
438 if (phid > M_PI) phid = phid -
M_PI2;
439 double drp = (
m_pivot.x() +
dr * csf0 +
m_r * (csf0 - csf) - newPivot.x())
441 + (
m_pivot.y() +
dr * snf0 +
m_r * (snf0 - snf) - newPivot.y()) * snf;
460#if defined(BELLE_DEBUG)
473 const HepSymMatrix&
Ea)
488 if (
this == & i)
return *
this;
516#if defined(BELLE_DEBUG)
536 if (
m_ac[2] != 0.0) {
537 if (
m_ac[2] == DBL_MAX ||
m_ac[2] == (-DBL_MAX)) {
555#if defined(BELLE_DEBUG)
565 if (
m_ac[2] != 0.0) {
566 if (
m_ac[2] == DBL_MAX ||
m_ac[2] == (-DBL_MAX)) {
597 HepMatrix dApDA(5, 5, 0);
599 const double&
dr =
m_ac[0];
601 const double& cpa =
m_ac[2];
603 const double& tnl =
m_ac[4];
606 double phi0p = ap[1];
611 double rdr =
m_r +
dr;
613 if ((
m_r + drp) != 0.0) {
614 rdrpr = 1. / (
m_r + drp);
620 double csfd = cos(phi0p -
phi0);
621 double snfd = sin(phi0p -
phi0);
623 if (phid > M_PI) phid = phid -
M_PI2;
626 dApDA[0][1] = rdr * snfd;
628 dApDA[0][2] = (
m_r / cpa) * (1.0 - csfd);
630 dApDA[0][2] = (DBL_MAX);
633 dApDA[1][0] = - rdrpr * snfd;
634 dApDA[1][1] = rdr * rdrpr * csfd;
636 dApDA[1][2] = (
m_r / cpa) * rdrpr * snfd;
638 dApDA[1][2] = (DBL_MAX);
643 dApDA[3][0] =
m_r * rdrpr * tnl * snfd;
644 dApDA[3][1] =
m_r * tnl * (1.0 - rdr * rdrpr * csfd);
646 dApDA[3][2] = (
m_r / cpa) * tnl * (phid -
m_r * rdrpr * snfd);
648 dApDA[3][2] = (DBL_MAX);
651 dApDA[3][4] = -
m_r * phid;
668 HepMatrix dXDA(3, 5, 0);
670 const double&
dr =
m_ac[0];
672 const double& cpa =
m_ac[2];
674 const double& tnl =
m_ac[4];
676 double cosf0phi = cos(
phi0 + phi);
677 double sinf0phi = sin(
phi0 + phi);
682 dXDA[0][2] = - (
m_r / cpa) * (
m_cp - cosf0phi);
684 dXDA[0][2] = (DBL_MAX);
692 dXDA[1][2] = - (
m_r / cpa) * (
m_sp - sinf0phi);
694 dXDA[1][2] = (DBL_MAX);
702 dXDA[2][2] = (
m_r / cpa) * tnl * phi;
704 dXDA[2][2] = (DBL_MAX);
707 dXDA[2][4] = -
m_r * phi;
724 HepMatrix dMDA(3, 5, 0);
727 const double& cpa =
m_ac[2];
728 const double& tnl =
m_ac[4];
730 double cosf0phi = cos(
phi0 + phi);
731 double sinf0phi = sin(
phi0 + phi);
734 if (cpa != 0.)rho = 1. / cpa;
735 else rho = (DBL_MAX);
738 if (cpa < 0.)charge = -1.;
740 dMDA[0][1] = -fabs(rho) * cosf0phi;
741 dMDA[0][2] = charge * rho * rho * sinf0phi;
743 dMDA[1][1] = -fabs(rho) * sinf0phi;
744 dMDA[1][2] = -charge * rho * rho * cosf0phi;
746 dMDA[2][2] = -charge * rho * rho * tnl;
747 dMDA[2][4] = fabs(rho);
764 HepMatrix d4MDA(4, 5, 0);
767 double cpa =
m_ac[2];
768 double tnl =
m_ac[4];
770 double cosf0phi = cos(
phi0 + phi);
771 double sinf0phi = sin(
phi0 + phi);
774 if (cpa != 0.)rho = 1. / cpa;
775 else rho = (DBL_MAX);
778 if (cpa < 0.)charge = -1.;
780 double E =
sqrt(rho * rho * (1. + tnl * tnl) + mass * mass);
782 d4MDA[0][1] = -fabs(rho) * cosf0phi;
783 d4MDA[0][2] = charge * rho * rho * sinf0phi;
785 d4MDA[1][1] = -fabs(rho) * sinf0phi;
786 d4MDA[1][2] = -charge * rho * rho * cosf0phi;
788 d4MDA[2][2] = -charge * rho * rho * tnl;
789 d4MDA[2][4] = fabs(rho);
791 if (cpa != 0.0 &&
E != 0.0) {
792 d4MDA[3][2] = (-1. - tnl * tnl) / (cpa * cpa * cpa *
E);
793 d4MDA[3][4] = tnl / (cpa * cpa *
E);
795 d4MDA[3][2] = (DBL_MAX);
796 d4MDA[3][4] = (DBL_MAX);
813 HepMatrix d4MXDA(7, 5, 0);
815 const double&
dr =
m_ac[0];
817 const double& cpa =
m_ac[2];
819 const double& tnl =
m_ac[4];
821 double cosf0phi = cos(
phi0 + phi);
822 double sinf0phi = sin(
phi0 + phi);
825 if (cpa != 0.)rho = 1. / cpa;
826 else rho = (DBL_MAX);
829 if (cpa < 0.)charge = -1.;
831 double E =
sqrt(rho * rho * (1. + tnl * tnl) + mass * mass);
833 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
834 d4MXDA[0][2] = charge * rho * rho * sinf0phi;
836 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
837 d4MXDA[1][2] = - charge * rho * rho * cosf0phi;
839 d4MXDA[2][2] = - charge * rho * rho * tnl;
840 d4MXDA[2][4] = fabs(rho);
842 if (cpa != 0.0 &&
E != 0.0) {
843 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa *
E);
844 d4MXDA[3][4] = tnl / (cpa * cpa *
E);
846 d4MXDA[3][2] = (DBL_MAX);
847 d4MXDA[3][4] = (DBL_MAX);
853 d4MXDA[4][2] = - (
m_r / cpa) * (
m_cp - cosf0phi);
855 d4MXDA[4][2] = (DBL_MAX);
861 d4MXDA[5][2] = - (
m_r / cpa) * (
m_sp - sinf0phi);
863 d4MXDA[6][2] = (
m_r / cpa) * tnl * phi;
865 d4MXDA[5][2] = (DBL_MAX);
867 d4MXDA[6][2] = (DBL_MAX);
871 d4MXDA[6][4] = -
m_r * phi;
888 const double dr =
m_a[0];
890 const double cpa =
m_a[2];
891 const double dz =
m_a[3];
892 const double tnl =
m_a[4];
894 std::cout <<
"Helix::dr = " <<
dr <<
" phi0 = " <<
phi0 <<
" cpa = " << cpa
895 <<
" dz = " <<
dz <<
" tnl = " << tnl << std::endl;
896 std::cout <<
" pivot = " <<
m_pivot << std::endl;
906 const double adr = fabs(
m_a[0]);
907 const double acpa = fabs(
m_a[2]);
916 if (
m_a[0] != 0.0 ||
m_a[1] != 0.0 ||
m_a[2] != 0.0 ||
917 m_a[3] != 0.0 ||
m_a[4] != 0.0) {
static bool ms_print_debug
Debug option flag.
void checkValid(void)
Check whether helix parameters is valid or not.
HepMatrix delMDelA(double phi) const
DM/DA.
HepMatrix del4MDelA(double phi, double mass) const
DM4/DA.
Helix(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
Constructor with pivot, helix parameter a, and its error matrix.
void ignoreErrorMatrix(void)
Unsets error matrix.
const HepPoint3D & pivot(void) const
returns pivot position.
HepMatrix delXDelA(double phi) const
DX/DA.
HepPoint3D m_center
Cache of the center position of Helix.
const HepSymMatrix & Ea(void) const
Returns error matrix.
virtual ~Helix()
Destructor.
static bool set_exception(bool)
set exception
HepMatrix del4MXDelA(double phi, double mass) const
DMX4/DA.
void updateCache(void)
updateCache
bool m_matrixValid
True: matrix valid, False: matrix not valid.
double m_ac[5]
Cache of the helix parameter.
double tanl(void) const
Return helix parameter tangent lambda.
bool m_helixValid
True: helix valid, False: helix not valid.
double phi0(void) const
Return helix parameter phi0.
static bool ms_throw_exception
Throw exception flag.
static bool ms_check_range
Check the helix parameter's range.
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
Sets helix pivot position, parameters, and error matrix.
const HepVector & a(void) const
Returns helix parameters.
double dr(void) const
Return helix parameter dr.
void debugHelix(void) const
Debug Helix.
void debugPrint(void) const
Print the helix parameters to stdout.
static HepVector ms_amin
minimum limit of Helix parameter a
HepMatrix delApDelA(const HepVector &ap) const
DAp/DA.
HepVector m_a
Helix parameter.
double dz(void) const
Return helix parameter dz.
static const double ConstantAlpha
Constant alpha for uniform field.
static HepVector ms_amax
maxiimum limit of Helix parameter a
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
static const std::string invalidhelix
String "Invalid Helix".
Helix & operator=(const Helix &)
Copy operator.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double m_cp
Cache of the cos phi0.
double m_alpha
10000.0/(speed of light)/B.
HepSymMatrix m_Ea
Error of the helix parameter.
double m_sp
Cache of the sin phi0.
double m_bField
Magnetic field, assuming uniform Bz in the unit of kG.
double m_r
Cache of the r.
double kappa(void) const
Return helix parameter kappa.
double m_pt
Cache of the pt.
static void set_limits(const HepVector &a_min, const HepVector &a_max)
set limit for parameter "a"
static bool set_print(bool)
Set print option for debugging.
Helix()
Constructor initializing all perigee parameters to zero.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.