15#include "trg/cdc/Helix.h"
16#include "CLHEP/Matrix/Matrix.h"
63 if (a_min.num_row() != 5 || a_max.num_row() != 5)
return;
71 const CLHEP::HepVector& a,
72 const CLHEP::HepSymMatrix& Ea)
73 : m_matrixValid(true),
83 if (
m_a.num_row() == 5 &&
m_Ea.num_row() == 5) {
89 const CLHEP::HepVector& a)
90 : m_matrixValid(false),
96 m_Ea(CLHEP::HepSymMatrix(5, 0))
99 if (
m_a.num_row() == 5) {
105 const CLHEP::Hep3Vector& momentum,
107 : m_matrixValid(false),
112 m_a(CLHEP::HepVector(5, 0)),
113 m_Ea(CLHEP::HepSymMatrix(5, 0))
121 m_a[2] = charge / perp;
124 m_a[2] = charge * (DBL_MAX);
206 double pt = fabs(
m_pt);
207 double px = - pt * sin(
m_ac[1] + phi);
208 double py = pt * cos(
m_ac[1] + phi);
209 double pz = pt *
m_ac[4];
211 return CLHEP::Hep3Vector(px, py, pz);
227 double pt = fabs(
m_pt);
228 double px = - pt * sin(
m_ac[1] + phi);
229 double py = pt * cos(
m_ac[1] + phi);
230 double pz = pt *
m_ac[4];
235 return CLHEP::Hep3Vector(px, py, pz);
238 CLHEP::HepLorentzVector
252 double pt = fabs(
m_pt);
253 double px = - pt * sin(
m_ac[1] + phi);
254 double py = pt * cos(
m_ac[1] + phi);
255 double pz = pt *
m_ac[4];
256 double E =
sqrt(pt * pt * (1. +
m_ac[4] *
m_ac[4]) + mass * mass);
258 return CLHEP::HepLorentzVector(px, py, pz,
E);
262 CLHEP::HepLorentzVector
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];
280 double E =
sqrt(pt * pt * (1. +
m_ac[4] *
m_ac[4]) + mass * mass);
285 return CLHEP::HepLorentzVector(px, py, pz,
E);
288 CLHEP::HepLorentzVector
292 CLHEP::HepSymMatrix& Emx)
const
306 double pt = fabs(
m_pt);
307 double px = - pt * sin(
m_ac[1] + phi);
308 double py = pt * cos(
m_ac[1] + phi);
309 double pz = pt *
m_ac[4];
310 double E =
sqrt(pt * pt * (1. +
m_ac[4] *
m_ac[4]) + mass * mass);
319 return CLHEP::HepLorentzVector(px, py, pz,
E);
326#if defined(BELLE_DEBUG)
329 const double&
dr =
m_ac[0];
332 const double&
dz =
m_ac[3];
335 double rdr =
dr +
m_r;
337 double csf0 = cos(phi);
338 double snf0 = (1. - csf0) * (1. + csf0);
339 snf0 =
sqrt((snf0 > 0.) ? snf0 : 0.);
340 if (phi > M_PI) snf0 = - snf0;
342 double xc =
m_pivot.x() + rdr * csf0;
343 double yc =
m_pivot.y() + rdr * snf0;
346 csf = (xc - newPivot.x()) /
m_r;
347 snf = (yc - newPivot.y()) /
m_r;
348 double anrm =
sqrt(csf * csf + snf * snf);
352 phi = atan2(snf, csf);
364 if (phid > M_PI) phid = phid -
M_PI2;
365 double drp = (
m_pivot.x() +
dr * csf0 +
m_r * (csf0 - csf) - newPivot.x())
367 + (
m_pivot.y() +
dr * snf0 +
m_r * (snf0 - snf) - newPivot.y()) * snf;
370 CLHEP::HepVector ap(5);
386#if defined(BELLE_DEBUG)
397 const CLHEP::HepVector& a,
398 const CLHEP::HepSymMatrix& Ea)
411 if (
this == & i)
return *
this;
438#if defined(BELLE_DEBUG)
456 if (
m_ac[2] != 0.0) {
457 if (
m_ac[2] == DBL_MAX ||
m_ac[2] == (-DBL_MAX)) {
475#if defined(BELLE_DEBUG)
485 if (
m_ac[2] != 0.0) {
486 if (
m_ac[2] == DBL_MAX ||
m_ac[2] == (-DBL_MAX)) {
516 CLHEP::HepMatrix dApDA(5, 5, 0);
518 const double&
dr =
m_ac[0];
520 const double& cpa =
m_ac[2];
522 const double& tnl =
m_ac[4];
525 double phi0p = ap[1];
530 double rdr =
m_r +
dr;
532 if ((
m_r + drp) != 0.0) {
533 rdrpr = 1. / (
m_r + drp);
539 double csfd = cos(phi0p -
phi0);
540 double snfd = sin(phi0p -
phi0);
542 if (phid > M_PI) phid = phid -
M_PI2;
545 dApDA[0][1] = rdr * snfd;
547 dApDA[0][2] = (
m_r / cpa) * (1.0 - csfd);
549 dApDA[0][2] = (DBL_MAX);
552 dApDA[1][0] = - rdrpr * snfd;
553 dApDA[1][1] = rdr * rdrpr * csfd;
555 dApDA[1][2] = (
m_r / cpa) * rdrpr * snfd;
557 dApDA[1][2] = (DBL_MAX);
562 dApDA[3][0] =
m_r * rdrpr * tnl * snfd;
563 dApDA[3][1] =
m_r * tnl * (1.0 - rdr * rdrpr * csfd);
565 dApDA[3][2] = (
m_r / cpa) * tnl * (phid -
m_r * rdrpr * snfd);
567 dApDA[3][2] = (DBL_MAX);
570 dApDA[3][4] = -
m_r * phid;
586 CLHEP::HepMatrix dXDA(3, 5, 0);
588 const double&
dr =
m_ac[0];
590 const double& cpa =
m_ac[2];
592 const double& tnl =
m_ac[4];
594 double cosf0phi = cos(
phi0 + phi);
595 double sinf0phi = sin(
phi0 + phi);
600 dXDA[0][2] = - (
m_r / cpa) * (
m_cp - cosf0phi);
602 dXDA[0][2] = (DBL_MAX);
610 dXDA[1][2] = - (
m_r / cpa) * (
m_sp - sinf0phi);
612 dXDA[1][2] = (DBL_MAX);
620 dXDA[2][2] = (
m_r / cpa) * tnl * phi;
622 dXDA[2][2] = (DBL_MAX);
625 dXDA[2][4] = -
m_r * phi;
641 CLHEP::HepMatrix dMDA(3, 5, 0);
644 const double& cpa =
m_ac[2];
645 const double& tnl =
m_ac[4];
647 double cosf0phi = cos(
phi0 + phi);
648 double sinf0phi = sin(
phi0 + phi);
651 if (cpa != 0.)rho = 1. / cpa;
652 else rho = (DBL_MAX);
655 if (cpa < 0.)charge = -1.;
657 dMDA[0][1] = -fabs(rho) * cosf0phi;
658 dMDA[0][2] = charge * rho * rho * sinf0phi;
660 dMDA[1][1] = -fabs(rho) * sinf0phi;
661 dMDA[1][2] = -charge * rho * rho * cosf0phi;
663 dMDA[2][2] = -charge * rho * rho * tnl;
664 dMDA[2][4] = fabs(rho);
680 CLHEP::HepMatrix d4MDA(4, 5, 0);
683 double cpa =
m_ac[2];
684 double tnl =
m_ac[4];
686 double cosf0phi = cos(
phi0 + phi);
687 double sinf0phi = sin(
phi0 + phi);
690 if (cpa != 0.)rho = 1. / cpa;
691 else rho = (DBL_MAX);
694 if (cpa < 0.)charge = -1.;
696 double E =
sqrt(rho * rho * (1. + tnl * tnl) + mass * mass);
698 d4MDA[0][1] = -fabs(rho) * cosf0phi;
699 d4MDA[0][2] = charge * rho * rho * sinf0phi;
701 d4MDA[1][1] = -fabs(rho) * sinf0phi;
702 d4MDA[1][2] = -charge * rho * rho * cosf0phi;
704 d4MDA[2][2] = -charge * rho * rho * tnl;
705 d4MDA[2][4] = fabs(rho);
707 if (cpa != 0.0 &&
E != 0.0) {
708 d4MDA[3][2] = (-1. - tnl * tnl) / (cpa * cpa * cpa *
E);
709 d4MDA[3][4] = tnl / (cpa * cpa *
E);
711 d4MDA[3][2] = (DBL_MAX);
712 d4MDA[3][4] = (DBL_MAX);
728 CLHEP::HepMatrix d4MXDA(7, 5, 0);
730 const double&
dr =
m_ac[0];
732 const double& cpa =
m_ac[2];
734 const double& tnl =
m_ac[4];
736 double cosf0phi = cos(
phi0 + phi);
737 double sinf0phi = sin(
phi0 + phi);
740 if (cpa != 0.)rho = 1. / cpa;
741 else rho = (DBL_MAX);
744 if (cpa < 0.)charge = -1.;
746 double E =
sqrt(rho * rho * (1. + tnl * tnl) + mass * mass);
748 d4MXDA[0][1] = - fabs(rho) * cosf0phi;
749 d4MXDA[0][2] = charge * rho * rho * sinf0phi;
751 d4MXDA[1][1] = - fabs(rho) * sinf0phi;
752 d4MXDA[1][2] = - charge * rho * rho * cosf0phi;
754 d4MXDA[2][2] = - charge * rho * rho * tnl;
755 d4MXDA[2][4] = fabs(rho);
757 if (cpa != 0.0 &&
E != 0.0) {
758 d4MXDA[3][2] = (- 1. - tnl * tnl) / (cpa * cpa * cpa *
E);
759 d4MXDA[3][4] = tnl / (cpa * cpa *
E);
761 d4MXDA[3][2] = (DBL_MAX);
762 d4MXDA[3][4] = (DBL_MAX);
768 d4MXDA[4][2] = - (
m_r / cpa) * (
m_cp - cosf0phi);
770 d4MXDA[4][2] = (DBL_MAX);
776 d4MXDA[5][2] = - (
m_r / cpa) * (
m_sp - sinf0phi);
778 d4MXDA[6][2] = (
m_r / cpa) * tnl * phi;
780 d4MXDA[5][2] = (DBL_MAX);
782 d4MXDA[6][2] = (DBL_MAX);
786 d4MXDA[6][4] = -
m_r * phi;
802 const double dr =
m_a[0];
804 const double cpa =
m_a[2];
805 const double dz =
m_a[3];
806 const double tnl =
m_a[4];
808 std::cout <<
"TRGCDCHelix::dr = " <<
dr <<
" phi0 = " <<
phi0 <<
" cpa = " << cpa
809 <<
" dz = " <<
dz <<
" tnl = " << tnl << std::endl;
810 std::cout <<
" pivot = " <<
m_pivot << std::endl;
819 const double adr = fabs(
m_a[0]);
821 const double acpa = fabs(
m_a[2]);
830 if (
m_a[0] != 0.0 ||
m_a[1] != 0.0 ||
m_a[2] != 0.0 ||
831 m_a[3] != 0.0 ||
m_a[4] != 0.0)
832 std::cout <<
"something wrong" << std::endl;
TRGCDCHelix parameter class.
HepGeom::Point3D< double > m_center
caches
CLHEP::HepVector m_a
a HepVector parameter
CLHEP::HepSymMatrix m_Ea
Ea HepSymMatrix parameter.
HepGeom::Point3D< double > m_pivot
pivot
bool m_matrixValid
matrix validity
bool m_helixValid
helix validity
double m_alpha
alpha parameter
double m_bField
magnetic field
double sqrt(double a)
sqrt for double
void set(const HepGeom::Point3D< double > &pivot, const CLHEP::HepVector &a, const CLHEP::HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
static CLHEP::HepVector ms_amax
limits for helix parameters
static bool ms_print_debug
print debug info or not
TRGCDCHelix & operator=(const TRGCDCHelix &)
Copy operator.
void checkValid(void)
check validity
HepGeom::Point3D< double > x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
static void set_limits(const CLHEP::HepVector &a_min, const CLHEP::HepVector &a_max)
set limits for helix parameters
void ignoreErrorMatrix(void)
unsets error matrix. Error calculations will be ignored after this function call until an error matri...
const CLHEP::HepSymMatrix & Ea(void) const
returns error matrix.
static bool set_exception(bool)
set to throw exception or not
void updateCache(void)
update Caches
double tanl(void) const
returns tanl.
double phi0(void) const
returns phi0.
static bool ms_throw_exception
throw exception or not
const CLHEP::HepVector & a(void) const
returns helix parameters.
static bool ms_check_range
range in checked or not
CLHEP::HepMatrix del4MXDelA(double phi, double mass) const
Mathmatical functions.
double dr(void) const
returns dr.
void debugPrint(void) const
print debug info
CLHEP::HepMatrix delApDelA(const CLHEP::HepVector &ap) const
Mathmatical functions.
double dz(void) const
returns dz.
static const double ConstantAlpha
Constant alpha for uniform field.
static const std::string invalidhelix
string of invalid helix
virtual ~TRGCDCHelix()
Destructor.
static CLHEP::HepVector ms_amin
limits for helix parameters
CLHEP::HepMatrix delXDelA(double phi) const
Mathmatical functions.
CLHEP::HepMatrix del4MDelA(double phi, double mass) const
Mathmatical functions.
CLHEP::HepMatrix delMDelA(double phi) const
Mathmatical functions.
double kappa(void) const
returns kappa.
static bool set_print(bool)
set to print debug info or not
CLHEP::Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
const HepGeom::Point3D< double > & pivot(void) const
returns pivot position.
TRGCDCHelix(const HepGeom::Point3D< double > &pivot, const CLHEP::HepVector &a, const CLHEP::HepSymMatrix &Ea)
Constructor with pivot, helix parameter a, and its error matrix.
Abstract base class for different kinds of events.