Belle II Software  release-06-02-00
HelixSwimmer.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <TVector3.h>
12 #include <TRotation.h>
13 #include <cmath>
14 #include <algorithm>
15 
16 namespace Belle2 {
21  namespace TOP {
22 
29  class HelixSwimmer {
30 
31  public:
32 
37  {}
38 
46  void set(const TVector3& position, const TVector3& momentum, double charge, double Bz);
47 
54  void setTransformation(const TRotation& rotation, const TVector3& translation);
55 
60  void moveReferencePosition(double length);
61 
67  TVector3 getPosition(double length) const;
68 
74  TVector3 getDirection(double length) const;
75 
82  double getDistanceToPlane(const TVector3& point, const TVector3& normal) const;
83 
84  private:
85 
92  double shortestDistance(double cosAlpha, double phi) const;
93 
99  double withinSingleTurn(double t) const;
100 
101  double m_R = 0;
102  double m_xc = 0;
103  double m_yc = 0;
104  double m_omega = 0;
105  double m_kz = 0;
106  double m_phi0 = 0;
107  double m_z0 = 0;
108  double m_T0 = 0;
110  double& x0 = m_xc;
111  double& y0 = m_yc;
112  double& z0 = m_z0;
113  double& kx = m_R;
114  double& ky = m_phi0;
115  double& kz = m_kz;
117  TRotation m_rotationInv;
118  TVector3 m_translation;
120  };
121 
122 
123  inline double HelixSwimmer::shortestDistance(double cosAlpha, double phi) const
124  {
125  double alpha = acos(cosAlpha);
126  double t1 = withinSingleTurn((phi - m_phi0 - alpha) / m_omega);
127  double t2 = withinSingleTurn((phi - m_phi0 + alpha) / m_omega);
128  double ta = std::min(t1, t2);
129  double tb = std::max(t1 - m_T0, t2 - m_T0);
130  double t = (abs(ta) < abs(tb)) ? ta : tb;
131  return t;
132  }
133 
134  inline double HelixSwimmer::withinSingleTurn(double t) const
135  {
136  t = fmod(t, m_T0);
137  if (t < 0) t += m_T0;
138  return t;
139  }
140 
141  } // namespace TOP
143 } // namespace Belle2
144 
Utility for propagation of a particle along helix.
Definition: HelixSwimmer.h:29
TVector3 getDirection(double length) const
Returns particle direction at given length.
Definition: HelixSwimmer.cc:79
TVector3 getPosition(double length) const
Returns particle position at given length.
Definition: HelixSwimmer.cc:67
double m_phi0
phi of reference position
Definition: HelixSwimmer.h:106
void set(const TVector3 &position, const TVector3 &momentum, double charge, double Bz)
Sets the helix.
Definition: HelixSwimmer.cc:24
void moveReferencePosition(double length)
Moves reference position along helix by length.
Definition: HelixSwimmer.cc:55
double withinSingleTurn(double t) const
Returns helix length within a single turn.
Definition: HelixSwimmer.h:134
double & kx
direction in x for zero magnetic field
Definition: HelixSwimmer.h:113
double getDistanceToPlane(const TVector3 &point, const TVector3 &normal) const
Returns the distance along helix to the nearest intersection with a plane nearly parallel to z axis.
Definition: HelixSwimmer.cc:92
double & ky
direction in y for zero magnetic field
Definition: HelixSwimmer.h:114
double & z0
z of reference position for zero magnetic field
Definition: HelixSwimmer.h:112
double & kz
direction in z for zero magnetic field
Definition: HelixSwimmer.h:115
HelixSwimmer()
default constructor
Definition: HelixSwimmer.h:36
double & y0
y of reference position for zero magnetic field
Definition: HelixSwimmer.h:111
double shortestDistance(double cosAlpha, double phi) const
Returns shortest distance.
Definition: HelixSwimmer.h:123
double m_R
helix radius
Definition: HelixSwimmer.h:101
double m_yc
helix axis position in y
Definition: HelixSwimmer.h:103
TVector3 m_translation
translation vector
Definition: HelixSwimmer.h:118
double m_omega
angular speed [1/cm]
Definition: HelixSwimmer.h:104
double m_T0
helix length of single turn
Definition: HelixSwimmer.h:108
double m_z0
z of reference position
Definition: HelixSwimmer.h:107
void setTransformation(const TRotation &rotation, const TVector3 &translation)
Sets transformation from the frame in which helix is constructed to module local frame.
Definition: HelixSwimmer.cc:49
double m_xc
helix axis position in x
Definition: HelixSwimmer.h:102
TRotation m_rotationInv
inverse of rotation matrix
Definition: HelixSwimmer.h:117
double & x0
x of reference position for zero magnetic field
Definition: HelixSwimmer.h:110
double m_kz
slope in z
Definition: HelixSwimmer.h:105
Abstract base class for different kinds of events.