Public Member Functions | Private Attributes | Static Private Attributes | List of all members
gar_content::Helix Class Reference

Helix class. More...

#include <Helix.h>

Public Member Functions

 Helix (const float phi0, const float d0, const float x0, const float omega, const float tanlambda, const float bField)
 Constructor using canonical (LEP-wise) parameterisation. More...
 
 Helix (const pandora::CartesianVector &position, const pandora::CartesianVector &momentum, const float charge, const float bField)
 Constructor. More...
 
pandora::StatusCode GetPointInZY (const float z0, const float y0, const float az, const float ay, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
 Get helix intersection point with a plane parallel to x axis. The plane is defined by two coordinates in the plane (z0,y0) and a normal vector (az,ay). More...
 
pandora::StatusCode GetPointInZY (const float z0, const float y0, const float az, const float ay, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint, float &genericTime) const
 Get helix intersection point with a plane parallel to x axis. The plane is defined by two coordinates in the plane (z0,y0) and a normal vector (az,ay). More...
 
pandora::StatusCode GetPointInX (const float xPlane, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
 Get helix intersection point with a plane perpendicular to x axis. More...
 
pandora::StatusCode GetPointInX (const float xPlane, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint, float &genericTime) const
 Get helix intersection point with a plane perpendicular to x axis. More...
 
pandora::StatusCode GetPointOnCircle (const float radius, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
 Get coordinates of helix intersection with cylinder, aligned along z-axis. More...
 
pandora::StatusCode GetPointOnCircle (const float radius, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint, float &genericTime) const
 Get coordinates of helix intersection with cylinder, aligned along z-axis. More...
 
pandora::StatusCode GetDistanceToPoint (const pandora::CartesianVector &point, pandora::CartesianVector &distance) const
 Get distance of the closest approach of helix to an arbitrary point in space. More...
 
pandora::StatusCode GetDistanceToPoint (const pandora::CartesianVector &point, pandora::CartesianVector &distance, float &genericTime) const
 Get distance of the closest approach of helix to an arbitrary point in space. More...
 
pandora::StatusCode GetDistanceToHelix (const Helix *const pHelix, pandora::CartesianVector &positionOfClosestApproach, pandora::CartesianVector &v0momentum, float &helixDistance) const
 Get distance between two helices. More...
 
pandora::CartesianVector GetExtrapolatedMomentum (const pandora::CartesianVector &position) const
 
const pandora::CartesianVector & GetMomentum () const
 Get momentum of particle at the point of closest approach to IP. More...
 
const pandora::CartesianVector & GetReferencePoint () const
 Get reference point of track. More...
 
float GetPhi0 () const
 Get phi angle of the momentum vector at the point of closest approach to IP. More...
 
float GetD0 () const
 Get x signed distance of closest approach to IP in the R-Phi plane. More...
 
float GetX0 () const
 Get x coordinate of the point of closest approach to IP in the R-Phi plane. More...
 
float GetOmega () const
 Get signed curvature of the track. More...
 
float GetTanLambda () const
 Get tangent of dip angle of the track. More...
 
float GetPzy () const
 Get transverse momentum of the track. More...
 
float GetCharge () const
 Get charge. More...
 
float GetZCentre () const
 Get z coordinate of circumference. More...
 
float GetYCentre () const
 Get y coordinate of circumference. More...
 
float GetRadius () const
 Get radius of circumference. More...
 

Private Attributes

pandora::CartesianVector m_referencePoint
 The coordinates of the reference point. More...
 
pandora::CartesianVector m_momentum
 The momentum vector at reference point. More...
 
float m_phi0
 phi0 in canonical parameterization More...
 
float m_d0
 d0 in canonical parameterisation More...
 
float m_x0
 x0 in canonical parameterisation More...
 
float m_omega
 signed curvature in canonical parameterisation More...
 
float m_tanLambda
 tanLambda More...
 
float m_pzy
 The transverse momentum. More...
 
float m_charge
 The particle charge. More...
 
float m_zCentre
 The circle centre z coordinate. More...
 
float m_yCentre
 The circle centre y coordinate. More...
 
float m_radius
 The radius of circle in ZY plane. More...
 
float m_phiRefPoint
 Phi w.r.t. (Z0, Y0) of circle at reference point. More...
 
float m_phiAtPCA
 Phi w.r.t. (Z0, Y0) of circle at point of closest approach. More...
 
float m_zAtPCA
 z coordinate at point of closest approach More...
 
float m_yAtPCA
 y coordinate at point of closest approach More...
 
float m_pzAtPCA
 Momentum z component at point of closest approach. More...
 
float m_pyAtPCA
 Momentum y component at point of closest approach. More...
 
float m_phiMomRefPoint
 Phi of Momentum vector at reference point. More...
 

Static Private Attributes

static const float FCT = 2.99792458E-4f
 
static const float TWO_PI = static_cast<float>(2. * std::acos(-1.0))
 
static const float HALF_PI = static_cast<float>(0.5 * std::acos(-1.0))
 

Detailed Description

Helix class.

Definition at line 14 of file Helix.h.

Constructor & Destructor Documentation

gar_content::Helix::Helix ( const float  phi0,
const float  d0,
const float  x0,
const float  omega,
const float  tanlambda,
const float  bField 
)

Constructor using canonical (LEP-wise) parameterisation.

Parameters
phi0phi angle of momentum vector at the point of closest approach to IP in R-Phi plane
d0signed distance of closest approach in R-Phi plane
x0x coordinate of the point of closest approach to IP in R-Phi plane
omegasigned curvature
tanLambdatangent of dip angle
bFieldmagnetic field (in Tesla)

Definition at line 16 of file Helix.cc.

17  : m_referencePoint(0.f, 0.f, 0.f),
18  m_momentum(0.f, 0.f, 0.f),
19  m_phi0(phi0),
20  m_d0(d0),
21  m_x0(x0),
22  m_omega(omega),
23  m_tanLambda(tanLambda)
24  {
25  if ((bField < std::numeric_limits<float>::epsilon()) || (std::fabs(omega) < std::numeric_limits<float>::epsilon()))
26  {
27  std::cout << "Helix, invalid parameter: bField " << bField << ", omega " << omega << std::endl;
28  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
29  }
30 
31  m_charge = omega / std::fabs(omega);
32  m_radius = 1.f / std::fabs(omega);
33  m_zAtPCA = -m_d0 * std::sin(m_phi0);
34  m_yAtPCA = m_d0 * std::cos(m_phi0);
36  m_pzy = FCT * bField * m_radius;
37  m_momentum.SetValues(m_pzy * std::cos(m_phi0), m_pzy * std::sin(m_phi0), m_tanLambda * m_pzy);
38  m_pzAtPCA = m_momentum.GetZ();
39  m_pyAtPCA = m_momentum.GetY();
40  m_phiMomRefPoint = std::atan2(m_pyAtPCA, m_pzAtPCA);
41  m_zCentre = m_referencePoint.GetZ() + m_radius * std::cos(m_phi0 - HALF_PI * m_charge);
42  m_yCentre = m_referencePoint.GetY() + m_radius * std::sin(m_phi0 - HALF_PI * m_charge);
43  m_phiAtPCA = std::atan2(-m_yCentre, -m_zCentre);
45  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_phiMomRefPoint
Phi of Momentum vector at reference point.
Definition: Helix.h:259
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_phi0
phi0 in canonical parameterization
Definition: Helix.h:243
float m_charge
The particle charge.
Definition: Helix.h:249
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
float m_pyAtPCA
Momentum y component at point of closest approach.
Definition: Helix.h:258
pandora::CartesianVector m_referencePoint
The coordinates of the reference point.
Definition: Helix.h:240
float m_x0
x0 in canonical parameterisation
Definition: Helix.h:245
float m_zAtPCA
z coordinate at point of closest approach
Definition: Helix.h:255
float m_pzy
The transverse momentum.
Definition: Helix.h:248
float m_pzAtPCA
Momentum z component at point of closest approach.
Definition: Helix.h:257
float m_omega
signed curvature in canonical parameterisation
Definition: Helix.h:246
static const float FCT
Definition: Helix.h:236
float m_tanLambda
tanLambda
Definition: Helix.h:247
float m_phiRefPoint
Phi w.r.t. (Z0, Y0) of circle at reference point.
Definition: Helix.h:253
float m_yAtPCA
y coordinate at point of closest approach
Definition: Helix.h:256
static const float HALF_PI
Definition: Helix.h:238
float m_d0
d0 in canonical parameterisation
Definition: Helix.h:244
float m_phiAtPCA
Phi w.r.t. (Z0, Y0) of circle at point of closest approach.
Definition: Helix.h:254
QTextStream & endl(QTextStream &s)
gar_content::Helix::Helix ( const pandora::CartesianVector &  position,
const pandora::CartesianVector &  momentum,
const float  charge,
const float  bField 
)

Constructor.

Parameters
positionposition of the reference point
momentummomentum vector at the reference point
chargeparticle charge
bFieldmagnetic field (in Tesla)

Definition at line 49 of file Helix.cc.

52  m_charge(charge)
53  {
54  const double pz(momentum.GetZ()), py(momentum.GetY());
55  const double pzy(std::sqrt(pz * pz + py * py));
56 
57  if ((bField < std::numeric_limits<float>::epsilon()) || (std::fabs(pzy) < std::numeric_limits<float>::epsilon()))
58  {
59  std::cout << "Helix, invalid parameter: bField " << bField << ", pzy " << pzy << std::endl;
60  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
61  }
62 
63  const double radius(pzy / (FCT * bField));
64  m_pzy = static_cast<float>(pzy);
65  m_radius = static_cast<float>(radius);
66 
67  m_omega = charge / m_radius;
68  m_tanLambda = momentum.GetX() / m_pzy;
69  m_phiMomRefPoint = static_cast<float>(std::atan2(py, pz));
70 
71  const double z(position.GetZ()), y(position.GetY());
72  const double zCentre(z + radius * static_cast<double>(std::cos(m_phiMomRefPoint - HALF_PI * charge)));
73  const double yCentre(y + radius * static_cast<double>(std::sin(m_phiMomRefPoint - HALF_PI * charge)));
74  m_zCentre = static_cast<float>(zCentre);
75  m_yCentre = static_cast<float>(yCentre);
76 
77  double d0;
78  if (charge > 0)
79  {
80  d0 = static_cast<double>(charge) * radius - static_cast<double>(std::sqrt(zCentre * zCentre + yCentre * yCentre));
81  }
82  else
83  {
84  d0 = static_cast<double>(charge) * radius + static_cast<double>(std::sqrt(zCentre * zCentre + yCentre * yCentre));
85  }
86  m_d0 = static_cast<float>(d0);
87 
88  m_phiRefPoint = static_cast<float>(std::atan2(y - yCentre, z - zCentre));
89  m_phiAtPCA = static_cast<float>(std::atan2(-yCentre, -zCentre));
90  m_phi0 = -HALF_PI * charge + m_phiAtPCA;
91 
92  while (m_phi0 < 0.)
93  m_phi0 += TWO_PI;
94 
95  while (m_phi0 >= TWO_PI)
96  m_phi0 -= TWO_PI;
97 
98  m_zAtPCA = m_zCentre + m_radius * std::cos(m_phiAtPCA);
99  m_yAtPCA = m_yCentre + m_radius * std::sin(m_phiAtPCA);
100  m_pzAtPCA = m_pzy * std::cos(m_phi0);
101  m_pyAtPCA = m_pzy * std::sin(m_phi0);
102 
103  float deltaPhi = m_phiRefPoint - m_phiAtPCA;
104  float zCircles = (-position.GetX() * charge) / (TWO_PI * ((m_radius * m_tanLambda) - deltaPhi));
105 
106  int n1, n2;
107  if (zCircles >= std::numeric_limits<float>::epsilon())
108  {
109  n1 = static_cast<int>(zCircles);
110  n2 = n1 + 1;
111  }
112  else
113  {
114  n1 = static_cast<int>(zCircles) - 1;
115  n2 = n1 + 1;
116  }
117 
118  const int nCircles((std::fabs(n1 - zCircles) < std::fabs(n2 - zCircles) ? n1 : n2));
119  m_x0 = position.GetX() + m_radius * m_tanLambda * charge * (deltaPhi + TWO_PI * nCircles);
120  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_phiMomRefPoint
Phi of Momentum vector at reference point.
Definition: Helix.h:259
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_phi0
phi0 in canonical parameterization
Definition: Helix.h:243
float m_charge
The particle charge.
Definition: Helix.h:249
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
float m_pyAtPCA
Momentum y component at point of closest approach.
Definition: Helix.h:258
static const float TWO_PI
Definition: Helix.h:237
pandora::CartesianVector m_referencePoint
The coordinates of the reference point.
Definition: Helix.h:240
float m_x0
x0 in canonical parameterisation
Definition: Helix.h:245
float m_zAtPCA
z coordinate at point of closest approach
Definition: Helix.h:255
float m_pzy
The transverse momentum.
Definition: Helix.h:248
float m_pzAtPCA
Momentum z component at point of closest approach.
Definition: Helix.h:257
float m_omega
signed curvature in canonical parameterisation
Definition: Helix.h:246
static const float FCT
Definition: Helix.h:236
float m_tanLambda
tanLambda
Definition: Helix.h:247
float m_phiRefPoint
Phi w.r.t. (Z0, Y0) of circle at reference point.
Definition: Helix.h:253
float m_yAtPCA
y coordinate at point of closest approach
Definition: Helix.h:256
def momentum(x1, x2, x3, scale=1.)
static const float HALF_PI
Definition: Helix.h:238
float m_d0
d0 in canonical parameterisation
Definition: Helix.h:244
float m_phiAtPCA
Phi w.r.t. (Z0, Y0) of circle at point of closest approach.
Definition: Helix.h:254
QTextStream & endl(QTextStream &s)

Member Function Documentation

float gar_content::Helix::GetCharge ( ) const
inline

Get charge.

Returns
the charge

Definition at line 356 of file Helix.h.

357  {
358  return m_charge;
359  }
float m_charge
The particle charge.
Definition: Helix.h:249
float gar_content::Helix::GetD0 ( ) const
inline

Get x signed distance of closest approach to IP in the R-Phi plane.

Returns
the signed distance of closest approach

Definition at line 321 of file Helix.h.

322  {
323  return m_d0;
324  }
float m_d0
d0 in canonical parameterisation
Definition: Helix.h:244
pandora::StatusCode gar_content::Helix::GetDistanceToHelix ( const Helix *const  pHelix,
pandora::CartesianVector &  positionOfClosestApproach,
pandora::CartesianVector &  v0momentum,
float &  helixDistance 
) const

Get distance between two helices.

Parameters
pHelixaddress of a second helix
positionOfClosestApproachto receive position of the point of closest approach
v0momentumto receive the v0 momentum
helixDistanceto receive the distance between the two helices

Definition at line 341 of file Helix.cc.

343  {
344  if (this == pHelix)
345  return pandora::STATUS_CODE_INVALID_PARAMETER;
346 
347  const float z01(this->GetZCentre());
348  const float y01(this->GetYCentre());
349 
350  const float z02(pHelix->GetZCentre());
351  const float y02(pHelix->GetYCentre());
352 
353  const float rad1(this->GetRadius());
354  const float rad2(pHelix->GetRadius());
355 
356  const float distance(std::sqrt((z01-z02) * (z01-z02) + (y01-y02) * (y01-y02)));
357 
358  bool singlePoint(true);
359  float phi1(0.), phi2(0.);
360 
361  if (rad1 + rad2 < distance)
362  {
363  phi1 = std::atan2(y02 - y01, z02 - z01);
364  phi2 = std::atan2(y01 - y02, z01 - z02);
365  }
366  else if (distance + rad2 < rad1)
367  {
368  phi1 = std::atan2(y02 - y01, z02 - z01);
369  phi2 = phi1;
370  }
371  else if (distance + rad1 < rad2)
372  {
373  phi1 = std::atan2(y01 - y02, z01 - z02);
374  phi2 = phi1;
375  }
376  else
377  {
378  if ((std::fabs(distance) < std::numeric_limits<float>::epsilon()) || (std::fabs(rad2) < std::numeric_limits<float>::epsilon()))
379  return pandora::STATUS_CODE_FAILURE;
380 
381  singlePoint = false;
382  float cosAlpha = 0.5f * (distance * distance + rad2 * rad2 - rad1 * rad1) / (distance * rad2);
383  float alpha = std::acos(cosAlpha);
384  float phi0 = std::atan2(y01 - y02, z01 - z02);
385  phi1 = phi0 + alpha;
386  phi2 = phi0 - alpha;
387  }
388 
389  const pandora::CartesianVector &referencePoint1(m_referencePoint);
390  const pandora::CartesianVector &referencePoint2(pHelix->GetReferencePoint());
391 
392  pandora::CartesianVector position1(0.f, 0.f, 0.f), position2(0.f, 0.f, 0.f);
393 
394  if (singlePoint)
395  {
396  const float zSect1(z01 + rad1 * std::cos(phi1));
397  const float ySect1(y01 + rad1 * std::sin(phi1));
398  const float zSect2(z02 + rad2 * std::cos(phi2));
399  const float ySect2(y02 + rad2 * std::sin(phi2));
400  const float r1(std::sqrt(zSect1 * zSect1 + ySect1 * ySect1));
401  const float r2(std::sqrt(zSect2 * zSect2 + ySect2 * ySect2));
402 
403  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, this->GetPointOnCircle(r1, referencePoint1, position1));
404  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, pHelix->GetPointOnCircle(r2, referencePoint2, position2));
405  }
406  else
407  {
408  const float zSect1(z02 + rad2*std::cos(phi1));
409  const float ySect1(y02 + rad2*std::sin(phi1));
410  const float zSect2(z02 + rad2*std::cos(phi2));
411  const float ySect2(y02 + rad2*std::sin(phi2));
412 
413  const float phiI2(std::atan2(referencePoint2.GetY() - y02, referencePoint2.GetZ() - z02));
414  const float phiF21(std::atan2(ySect1 - y02, zSect1 - z02));
415  const float phiF22(std::atan2(ySect2 - y02, zSect2 - z02));
416  const float charge2(pHelix->GetCharge());
417 
418  float deltaPhi21(phiF21 - phiI2);
419  float deltaPhi22(phiF22 - phiI2);
420 
421  if (deltaPhi21 < 0 && charge2 < 0)
422  {
423  deltaPhi21 += TWO_PI;
424  }
425  else if (deltaPhi21 > 0 && charge2 > 0)
426  {
427  deltaPhi21 -= TWO_PI;
428  }
429 
430  if (deltaPhi22 < 0 && charge2 < 0)
431  {
432  deltaPhi22 += TWO_PI;
433  }
434  else if (deltaPhi22 > 0 && charge2 > 0)
435  {
436  deltaPhi22 -= TWO_PI;
437  }
438 
439  const float pzy2(pHelix->GetPzy());
440  const float genericTime21(-charge2 * deltaPhi21 * rad2 / pzy2);
441  const float genericTime22(-charge2 * deltaPhi22 * rad2 / pzy2);
442 
443  const float px2(pHelix->GetMomentum().GetX());
444  const float X21(referencePoint2.GetX() + genericTime21 * px2);
445  const float X22(referencePoint2.GetX() + genericTime22 * px2);
446 
447  const pandora::CartesianVector temp21(X21, ySect1, zSect1);
448  const pandora::CartesianVector temp22(X22, ySect2, zSect2);
449 
450  const float phiI1(std::atan2(referencePoint1.GetY() - y01, referencePoint1.GetZ() - z01));
451  const float phiF11(std::atan2(ySect1-y01,zSect1-z01));
452  const float phiF12(std::atan2(ySect2-y01,zSect2-z01));
453  const float charge1(m_charge);
454 
455  float deltaPhi11(phiF11 - phiI1);
456  float deltaPhi12(phiF12 - phiI1);
457 
458  if (deltaPhi11 < 0 && charge1 < 0)
459  {
460  deltaPhi11 += TWO_PI;
461  }
462  else if (deltaPhi11 > 0 && charge1 > 0)
463  {
464  deltaPhi11 -= TWO_PI;
465  }
466 
467  if (deltaPhi12 < 0 && charge1 < 0)
468  {
469  deltaPhi12 += TWO_PI;
470  }
471  else if (deltaPhi12 > 0 && charge1 > 0)
472  {
473  deltaPhi12 -= TWO_PI;
474  }
475 
476  const float pzy1(m_pzy);
477  const float genericTime11(-charge1 * deltaPhi11 * rad1 / pzy1);
478  const float genericTime12(-charge1 * deltaPhi12 * rad1 / pzy1);
479 
480  const float px1(m_momentum.GetX());
481  const float X11(referencePoint1.GetX() + genericTime11 * px1);
482  const float X12(referencePoint1.GetX() + genericTime12 * px1);
483 
484  const pandora::CartesianVector temp11(X11, ySect1, zSect1);
485  const pandora::CartesianVector temp12(X12, ySect2, zSect2);
486 
487  const float dist1((temp11 - temp21).GetMagnitudeSquared());
488  const float dist2((temp12 - temp22).GetMagnitudeSquared());
489 
490  if (dist1 < dist2)
491  {
492  position1 = temp11;
493  position2 = temp21;
494  }
495  else
496  {
497  position1 = temp12;
498  position2 = temp22;
499  }
500  }
501 
502  const pandora::CartesianVector momentum1(this->GetExtrapolatedMomentum(position1));
503  const pandora::CartesianVector momentum2(pHelix->GetExtrapolatedMomentum(position2));
504 
505  helixDistance = (position1 - position2).GetMagnitude();
506  positionOfClosestApproach = (position1 + position2) * 0.5;
507  v0momentum = momentum1 + momentum2;
508 
509  return pandora::STATUS_CODE_SUCCESS;
510  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_charge
The particle charge.
Definition: Helix.h:249
pandora::StatusCode GetPointOnCircle(const float radius, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
Get coordinates of helix intersection with cylinder, aligned along z-axis.
Definition: Helix.h:281
static const float TWO_PI
Definition: Helix.h:237
pandora::CartesianVector m_referencePoint
The coordinates of the reference point.
Definition: Helix.h:240
float GetRadius() const
Get radius of circumference.
Definition: Helix.h:377
double alpha
Definition: doAna.cpp:15
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
float m_pzy
The transverse momentum.
Definition: Helix.h:248
float GetYCentre() const
Get y coordinate of circumference.
Definition: Helix.h:370
pandora::CartesianVector GetExtrapolatedMomentum(const pandora::CartesianVector &position) const
Definition: Helix.cc:514
float GetZCentre() const
Get z coordinate of circumference.
Definition: Helix.h:363
pandora::StatusCode gar_content::Helix::GetDistanceToPoint ( const pandora::CartesianVector &  point,
pandora::CartesianVector &  distance 
) const
inline

Get distance of the closest approach of helix to an arbitrary point in space.

Parameters
pointcoordinates of the specified point
distanceto receive a vector of distances from helix to point in the following projections: x component: distance in R-Phi plane y-component: distance along Z axis z-component: 3D distance magnitude

Definition at line 289 of file Helix.h.

290  {
291  float genericTime;
292  return this->GetDistanceToPoint(point, distance, genericTime);
293  }
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
pandora::StatusCode GetDistanceToPoint(const pandora::CartesianVector &point, pandora::CartesianVector &distance) const
Get distance of the closest approach of helix to an arbitrary point in space.
Definition: Helix.h:289
pandora::StatusCode gar_content::Helix::GetDistanceToPoint ( const pandora::CartesianVector &  point,
pandora::CartesianVector &  distance,
float &  genericTime 
) const

Get distance of the closest approach of helix to an arbitrary point in space.

Parameters
pointcoordinates of the specified point
distanceto receive a vector of distances from helix to point in the following projections: x component: distance in R-Phi plane y-component: distance along Z axis z-component: 3D distance magnitude
genericTimeto receive the generic time (helix length, from reference point to intersection, divided by particle momentum)

Definition at line 290 of file Helix.cc.

291  {
292  const float phi(std::atan2(point.GetY() - m_yCentre, point.GetZ() - m_zCentre));
293  const float phi0(std::atan2(m_referencePoint.GetY() - m_yCentre, m_referencePoint.GetZ() - m_zCentre));
294 
295  int nCircles = 0;
296  if (std::fabs(m_tanLambda * m_radius) > 1.e-20)
297  {
298  const float zCircles((phi0 - phi - m_charge * (point.GetX() - m_referencePoint.GetX()) / (m_tanLambda * m_radius)) / TWO_PI);
299 
300  int n1, n2;
301  if (zCircles >= std::numeric_limits<float>::epsilon())
302  {
303  n1 = static_cast<int>(zCircles);
304  n2 = n1 + 1;
305  }
306  else
307  {
308  n1 = static_cast<int>(zCircles) - 1;
309  n2 = n1 + 1;
310  }
311 
312  nCircles = ((std::fabs(n1 - zCircles) < std::fabs(n2 - zCircles) ? n1 : n2));
313  }
314 
315  const float dPhi(TWO_PI * (static_cast<float>(nCircles)) + phi - phi0);
316  const float xOnHelix(m_referencePoint.GetX() - m_charge * m_radius * m_tanLambda * dPhi);
317 
318  const float distZ(std::fabs(m_zCentre - point.GetZ()));
319  const float distY(std::fabs(m_yCentre - point.GetY()));
320  const float distX(std::fabs(xOnHelix - point.GetX()));
321 
322  float distZY(std::sqrt(distZ * distZ + distY * distY));
323  distZY = std::fabs(distZY - m_radius);
324 
325  distance.SetValues(distX, distZY, std::sqrt(distZY * distZY + distZ * distZ));
326 
327  if (std::fabs(m_momentum.GetX()) > 0)
328  {
329  genericTime = (xOnHelix - m_referencePoint.GetX()) / m_momentum.GetX();
330  }
331  else
332  {
333  genericTime = m_charge * m_radius * dPhi / m_pzy;
334  }
335 
336  return pandora::STATUS_CODE_SUCCESS;
337  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_charge
The particle charge.
Definition: Helix.h:249
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
static const float TWO_PI
Definition: Helix.h:237
pandora::CartesianVector m_referencePoint
The coordinates of the reference point.
Definition: Helix.h:240
const double e
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
float m_pzy
The transverse momentum.
Definition: Helix.h:248
float m_tanLambda
tanLambda
Definition: Helix.h:247
pandora::CartesianVector gar_content::Helix::GetExtrapolatedMomentum ( const pandora::CartesianVector &  position) const
Parameters
Getextrapolated momentum at a specified position
positionthe specified position
Returns
the extrapolated momentum

Definition at line 514 of file Helix.cc.

515  {
516  float phi = std::atan2(position.GetY() - m_yCentre, position.GetZ() - m_zCentre);
517 
518  if (phi < 0.)
519  phi += TWO_PI;
520 
521  phi = phi - m_phiAtPCA + m_phi0;
522 
523  return pandora::CartesianVector(m_momentum.GetX(), m_pzy * std::sin(phi), m_pzy * std::cos(phi));
524  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_phi0
phi0 in canonical parameterization
Definition: Helix.h:243
static const float TWO_PI
Definition: Helix.h:237
float m_pzy
The transverse momentum.
Definition: Helix.h:248
float m_phiAtPCA
Phi w.r.t. (Z0, Y0) of circle at point of closest approach.
Definition: Helix.h:254
const pandora::CartesianVector & gar_content::Helix::GetMomentum ( ) const
inline

Get momentum of particle at the point of closest approach to IP.

Returns
the momentum of particle

Definition at line 297 of file Helix.h.

298  {
299  return m_momentum;
300  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float gar_content::Helix::GetOmega ( ) const
inline

Get signed curvature of the track.

Returns
the signed curvature of the track

Definition at line 335 of file Helix.h.

336  {
337  return m_omega;
338  }
float m_omega
signed curvature in canonical parameterisation
Definition: Helix.h:246
float gar_content::Helix::GetPhi0 ( ) const
inline

Get phi angle of the momentum vector at the point of closest approach to IP.

Returns
the phi angle of the momentum vector

Definition at line 311 of file Helix.h.

312  {
313  if (m_phi0 < 0.)
314  return m_phi0 + TWO_PI;
315 
316  return m_phi0;
317  }
float m_phi0
phi0 in canonical parameterization
Definition: Helix.h:243
static const float TWO_PI
Definition: Helix.h:237
pandora::StatusCode gar_content::Helix::GetPointInX ( const float  xPlane,
const pandora::CartesianVector &  referencePoint,
pandora::CartesianVector &  intersectionPoint 
) const
inline

Get helix intersection point with a plane perpendicular to x axis.

Parameters
xPlanethe x coordinate for the specified plane
referencePointthe reference point of the helix
intersectionPointto receive the coordinates of the intersection point

Definition at line 273 of file Helix.h.

274  {
275  float genericTime;
276  return this->GetPointInX(xPlane, referencePoint, intersectionPoint, genericTime);
277  }
pandora::StatusCode GetPointInX(const float xPlane, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
Get helix intersection point with a plane perpendicular to x axis.
Definition: Helix.h:273
pandora::StatusCode gar_content::Helix::GetPointInX ( const float  xPlane,
const pandora::CartesianVector &  referencePoint,
pandora::CartesianVector &  intersectionPoint,
float &  genericTime 
) const

Get helix intersection point with a plane perpendicular to x axis.

Parameters
xPlanethe x coordinate for the specified plane
referencePointthe reference point of the helix
intersectionPointto receive the coordinates of the intersection point
genericTimeto receive the generic time (helix length, from reference point to intersection, divided by particle momentum)

Definition at line 196 of file Helix.cc.

198  {
199  if (std::fabs(m_momentum.GetX()) < std::numeric_limits<float>::epsilon())
200  return pandora::STATUS_CODE_NOT_FOUND;
201 
202  genericTime = (xPlane - referencePoint.GetX()) / m_momentum.GetX();
203 
204  const float phi0(std::atan2(referencePoint.GetY() - m_yCentre, referencePoint.GetZ() - m_zCentre));
205  const float phi(phi0 - m_charge * m_pzy * genericTime / m_radius);
206 
207  intersectionPoint.SetValues(xPlane, m_yCentre + m_radius * std::sin(phi), m_zCentre + m_radius * std::cos(phi));
208 
209  return pandora::STATUS_CODE_SUCCESS;
210  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_charge
The particle charge.
Definition: Helix.h:249
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
float m_pzy
The transverse momentum.
Definition: Helix.h:248
pandora::StatusCode gar_content::Helix::GetPointInZY ( const float  z0,
const float  y0,
const float  az,
const float  ay,
const pandora::CartesianVector &  referencePoint,
pandora::CartesianVector &  intersectionPoint 
) const
inline

Get helix intersection point with a plane parallel to x axis. The plane is defined by two coordinates in the plane (z0,y0) and a normal vector (az,ay).

Parameters
z0z coordinate in the specified plane
y0y coordinate in the specified plane
azz component of vector normal to specified plane
ayy component of vector normal to specified plane
referencePointthe reference point of the helix
intersectionPointto receive the coordinates of the intersection point

Definition at line 264 of file Helix.h.

266  {
267  float genericTime;
268  return this->GetPointInZY(z0, y0, az, ay, referencePoint, intersectionPoint, genericTime);
269  }
pandora::StatusCode GetPointInZY(const float z0, const float y0, const float az, const float ay, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
Get helix intersection point with a plane parallel to x axis. The plane is defined by two coordinates...
Definition: Helix.h:264
pandora::StatusCode gar_content::Helix::GetPointInZY ( const float  z0,
const float  y0,
const float  az,
const float  ay,
const pandora::CartesianVector &  referencePoint,
pandora::CartesianVector &  intersectionPoint,
float &  genericTime 
) const

Get helix intersection point with a plane parallel to x axis. The plane is defined by two coordinates in the plane (z0,y0) and a normal vector (az,ay).

Parameters
z0z coordinate in the specified plane
y0y coordinate in the specified plane
azz component of vector normal to specified plane
ayy component of vector normal to specified plane
referencePointthe reference point of the helix
intersectionPointto receive the coordinates of the intersection point
genericTimeto receive the generic time (helix length, from reference point to intersection, divided by particle momentum)

Definition at line 124 of file Helix.cc.

126  {
127  const float AA(std::sqrt(az * az + ay * ay));
128 
129  if (AA <= 0)
130  return pandora::STATUS_CODE_FAILURE;
131 
132  const float BB((az * (z0 - m_zCentre) + ay * (y0 - m_yCentre)) / AA);
133  const float CC(((z0 - m_zCentre) * (z0 - m_zCentre) + (y0 - m_yCentre) * (y0 - m_yCentre) - m_radius * m_radius) / AA);
134 
135  const float DET(BB * BB - CC);
136 
137  if (DET < 0)
138  return pandora::STATUS_CODE_NOT_FOUND;
139 
140  float tt1(-BB + std::sqrt(DET));
141  float tt2(-BB - std::sqrt(DET));
142 
143  const float zz1(z0 + tt1 * az);
144  const float yy1(y0 + tt1 * ay);
145  const float zz2(z0 + tt2 * az);
146  const float yy2(y0 + tt2 * ay);
147 
148  const float phi1(std::atan2(yy1 - m_yCentre, zz1 - m_zCentre));
149  const float phi2(std::atan2(yy2 - m_yCentre, zz2 - m_zCentre));
150  const float phi0(std::atan2(referencePoint.GetY() - m_yCentre, referencePoint.GetZ() - m_zCentre));
151 
152  float dphi1(phi1 - phi0);
153  float dphi2(phi2 - phi0);
154 
155  if (dphi1 < 0 && m_charge < 0)
156  {
157  dphi1 = dphi1 + TWO_PI;
158  }
159  else if (dphi1 > 0 && m_charge > 0)
160  {
161  dphi1 = dphi1 - TWO_PI;
162  }
163 
164  if (dphi2 < 0 && m_charge < 0)
165  {
166  dphi2 = dphi2 + TWO_PI;
167  }
168  else if (dphi2 > 0 && m_charge > 0)
169  {
170  dphi2 = dphi2 - TWO_PI;
171  }
172 
173  // Calculate generic time
174  tt1 = -m_charge * dphi1 * m_radius / m_pzy;
175  tt2 = -m_charge * dphi2 * m_radius / m_pzy;
176 
177  if ((tt1 < 0.) || (tt2 < 0.))
178  std::cout << "Helix:: GetPointInXY, warning - negative generic time, tt1 " << tt1 << ", tt2 " << tt2 << std::endl;
179 
180  if (tt1 < tt2)
181  {
182  genericTime = tt1;
183  intersectionPoint.SetValues(referencePoint.GetX() + genericTime * m_momentum.GetX(), yy1, zz1);
184  }
185  else
186  {
187  genericTime = tt2;
188  intersectionPoint.SetValues(referencePoint.GetX() + genericTime * m_momentum.GetX(), yy2, zz2);
189  }
190 
191  return pandora::STATUS_CODE_SUCCESS;
192  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_charge
The particle charge.
Definition: Helix.h:249
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
static const float TWO_PI
Definition: Helix.h:237
float m_pzy
The transverse momentum.
Definition: Helix.h:248
QTextStream & endl(QTextStream &s)
pandora::StatusCode gar_content::Helix::GetPointOnCircle ( const float  radius,
const pandora::CartesianVector &  referencePoint,
pandora::CartesianVector &  intersectionPoint 
) const
inline

Get coordinates of helix intersection with cylinder, aligned along z-axis.

Parameters
radiusthe radius of the cylinder
referencePointthe reference point of the helix
intersectionPointto receive the coordinates of the intersection point

Definition at line 281 of file Helix.h.

282  {
283  float genericTime;
284  return this->GetPointOnCircle(radius, referencePoint, intersectionPoint, genericTime);
285  }
pandora::StatusCode GetPointOnCircle(const float radius, const pandora::CartesianVector &referencePoint, pandora::CartesianVector &intersectionPoint) const
Get coordinates of helix intersection with cylinder, aligned along z-axis.
Definition: Helix.h:281
pandora::StatusCode gar_content::Helix::GetPointOnCircle ( const float  radius,
const pandora::CartesianVector &  referencePoint,
pandora::CartesianVector &  intersectionPoint,
float &  genericTime 
) const

Get coordinates of helix intersection with cylinder, aligned along z-axis.

Parameters
radiusthe radius of the cylinder
referencePointthe reference point of the helix
intersectionPointto receive the coordinates of the intersection point
genericTimeto receive the generic time (helix length, from reference point to intersection, divided by particle momentum)

Definition at line 214 of file Helix.cc.

216  {
217  const float distCenterToIP(std::sqrt(m_zCentre * m_zCentre + m_yCentre * m_yCentre));
218 
219  if ( ((distCenterToIP + m_radius) < radius) || ((m_radius + radius) < distCenterToIP) )
220  return pandora::STATUS_CODE_NOT_FOUND;
221 
222  const float phiCentre(std::atan2(m_yCentre, m_zCentre));
223 
224  float phiStar(radius * radius + distCenterToIP * distCenterToIP - m_radius * m_radius);
225  phiStar = 0.5f * phiStar / std::max(1.e-20f, radius * distCenterToIP);
226 
227  if (phiStar > 1.f)
228  phiStar = 0.9999999f;
229 
230  if (phiStar < -1.f)
231  phiStar = -0.9999999f;
232 
233  phiStar = std::acos(phiStar);
234 
235  const float zz1(radius * std::cos(phiCentre + phiStar));
236  const float yy1(radius * std::sin(phiCentre + phiStar));
237 
238  const float zz2(radius * std::cos(phiCentre-phiStar));
239  const float yy2(radius * std::sin(phiCentre-phiStar));
240 
241  const float phi1(std::atan2(yy1 - m_yCentre, zz1 - m_zCentre));
242  const float phi2(std::atan2(yy2 - m_yCentre, zz2 - m_zCentre));
243  const float phi0(std::atan2(referencePoint.GetY() - m_yCentre, referencePoint.GetZ() - m_zCentre));
244 
245  float dphi1(phi1 - phi0);
246  float dphi2(phi2 - phi0);
247 
248  if (dphi1 < 0 && m_charge < 0)
249  {
250  dphi1 = dphi1 + TWO_PI;
251  }
252  else if (dphi1 > 0 && m_charge > 0)
253  {
254  dphi1 = dphi1 - TWO_PI;
255  }
256 
257  if (dphi2 < 0 && m_charge < 0)
258  {
259  dphi2 = dphi2 + TWO_PI;
260  }
261  else if (dphi2 > 0 && m_charge > 0)
262  {
263  dphi2 = dphi2 - TWO_PI;
264  }
265 
266  // Calculate generic time
267  const float tt1(-m_charge * dphi1 * m_radius / m_pzy);
268  const float tt2(-m_charge * dphi2 * m_radius / m_pzy);
269 
270  if ((tt1 < 0.) || (tt2 < 0.))
271  std::cout << "Helix:: GetPointOnCircle, warning - negative generic time, tt1 " << tt1 << ", tt2 " << tt2 << std::endl;
272 
273  // Previously returned both xx1, xx2, etc.
274  if (tt1 < tt2)
275  {
276  genericTime = tt1;
277  intersectionPoint.SetValues(referencePoint.GetX() + genericTime * m_momentum.GetX(), yy1, zz1);
278  }
279  else
280  {
281  genericTime = tt2;
282  intersectionPoint.SetValues(referencePoint.GetX() + genericTime * m_momentum.GetX(), yy2, zz2);
283  }
284 
285  return pandora::STATUS_CODE_SUCCESS;
286  }
pandora::CartesianVector m_momentum
The momentum vector at reference point.
Definition: Helix.h:241
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float m_charge
The particle charge.
Definition: Helix.h:249
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
static const float TWO_PI
Definition: Helix.h:237
const double e
float m_pzy
The transverse momentum.
Definition: Helix.h:248
static int max(int a, int b)
QTextStream & endl(QTextStream &s)
float gar_content::Helix::GetPzy ( ) const
inline

Get transverse momentum of the track.

Returns
the transverse momentum of the track

Definition at line 349 of file Helix.h.

350  {
351  return m_pzy;
352  }
float m_pzy
The transverse momentum.
Definition: Helix.h:248
float gar_content::Helix::GetRadius ( ) const
inline

Get radius of circumference.

Returns
the radius of circumference

Definition at line 377 of file Helix.h.

378  {
379  return m_radius;
380  }
float m_radius
The radius of circle in ZY plane.
Definition: Helix.h:252
const pandora::CartesianVector & gar_content::Helix::GetReferencePoint ( ) const
inline

Get reference point of track.

Returns
the reference point of track

Definition at line 304 of file Helix.h.

305  {
306  return m_referencePoint;
307  }
pandora::CartesianVector m_referencePoint
The coordinates of the reference point.
Definition: Helix.h:240
float gar_content::Helix::GetTanLambda ( ) const
inline

Get tangent of dip angle of the track.

Returns
the tangent of dip angle of the track

Definition at line 342 of file Helix.h.

343  {
344  return m_tanLambda;
345  }
float m_tanLambda
tanLambda
Definition: Helix.h:247
float gar_content::Helix::GetX0 ( ) const
inline

Get x coordinate of the point of closest approach to IP in the R-Phi plane.

Returns
the x coordinate of the point of closest approach

Definition at line 328 of file Helix.h.

329  {
330  return m_x0;
331  }
float m_x0
x0 in canonical parameterisation
Definition: Helix.h:245
float gar_content::Helix::GetYCentre ( ) const
inline

Get y coordinate of circumference.

Returns
the y coordinate of circumference

Definition at line 370 of file Helix.h.

371  {
372  return m_yCentre;
373  }
float m_yCentre
The circle centre y coordinate.
Definition: Helix.h:251
float gar_content::Helix::GetZCentre ( ) const
inline

Get z coordinate of circumference.

Returns
the z coordinate of circumference

Definition at line 363 of file Helix.h.

364  {
365  return m_zCentre;
366  }
float m_zCentre
The circle centre z coordinate.
Definition: Helix.h:250

Member Data Documentation

const float gar_content::Helix::FCT = 2.99792458E-4f
staticprivate

Definition at line 236 of file Helix.h.

const float gar_content::Helix::HALF_PI = static_cast<float>(0.5 * std::acos(-1.0))
staticprivate

Definition at line 238 of file Helix.h.

float gar_content::Helix::m_charge
private

The particle charge.

Definition at line 249 of file Helix.h.

float gar_content::Helix::m_d0
private

d0 in canonical parameterisation

Definition at line 244 of file Helix.h.

pandora::CartesianVector gar_content::Helix::m_momentum
private

The momentum vector at reference point.

Definition at line 241 of file Helix.h.

float gar_content::Helix::m_omega
private

signed curvature in canonical parameterisation

Definition at line 246 of file Helix.h.

float gar_content::Helix::m_phi0
private

phi0 in canonical parameterization

Definition at line 243 of file Helix.h.

float gar_content::Helix::m_phiAtPCA
private

Phi w.r.t. (Z0, Y0) of circle at point of closest approach.

Definition at line 254 of file Helix.h.

float gar_content::Helix::m_phiMomRefPoint
private

Phi of Momentum vector at reference point.

Definition at line 259 of file Helix.h.

float gar_content::Helix::m_phiRefPoint
private

Phi w.r.t. (Z0, Y0) of circle at reference point.

Definition at line 253 of file Helix.h.

float gar_content::Helix::m_pyAtPCA
private

Momentum y component at point of closest approach.

Definition at line 258 of file Helix.h.

float gar_content::Helix::m_pzAtPCA
private

Momentum z component at point of closest approach.

Definition at line 257 of file Helix.h.

float gar_content::Helix::m_pzy
private

The transverse momentum.

Definition at line 248 of file Helix.h.

float gar_content::Helix::m_radius
private

The radius of circle in ZY plane.

Definition at line 252 of file Helix.h.

pandora::CartesianVector gar_content::Helix::m_referencePoint
private

The coordinates of the reference point.

Definition at line 240 of file Helix.h.

float gar_content::Helix::m_tanLambda
private

tanLambda

Definition at line 247 of file Helix.h.

float gar_content::Helix::m_x0
private

x0 in canonical parameterisation

Definition at line 245 of file Helix.h.

float gar_content::Helix::m_yAtPCA
private

y coordinate at point of closest approach

Definition at line 256 of file Helix.h.

float gar_content::Helix::m_yCentre
private

The circle centre y coordinate.

Definition at line 251 of file Helix.h.

float gar_content::Helix::m_zAtPCA
private

z coordinate at point of closest approach

Definition at line 255 of file Helix.h.

float gar_content::Helix::m_zCentre
private

The circle centre z coordinate.

Definition at line 250 of file Helix.h.

const float gar_content::Helix::TWO_PI = static_cast<float>(2. * std::acos(-1.0))
staticprivate

Definition at line 237 of file Helix.h.


The documentation for this class was generated from the following files: