9 #include <top/reconstruction_cpp/HelixSwimmer.h>
10 #include <framework/gearbox/Const.h>
11 #include <framework/gearbox/Unit.h>
12 #include <framework/logging/Logger.h>
24 void HelixSwimmer::set(
const TVector3& position,
const TVector3& momentum,
double charge,
double Bz)
26 double p = momentum.Mag();
27 double pT = momentum.Perp();
28 double b = -Bz * charge * Const::speedOfLight;
29 if (abs(b / Unit::T) > pT) {
32 m_kz = momentum.Z() / p;
33 m_phi0 = momentum.Phi() - copysign(M_PI / 2, m_omega);
34 m_xc = position.X() - m_R * cos(m_phi0);
35 m_yc = position.Y() - m_R * sin(m_phi0);
37 m_T0 = 2 * M_PI / abs(m_omega);
43 kx = momentum.X() / p;
44 ky = momentum.Y() / p;
45 kz = momentum.Z() / p;
49 void HelixSwimmer::setTransformation(
const TRotation& rotation,
const TVector3& translation)
51 m_rotationInv = rotation.Inverse();
52 m_translation = translation;
55 void HelixSwimmer::moveReferencePosition(
double length)
58 m_phi0 += m_omega * length;
59 m_z0 += m_kz * length;
70 double phi = m_phi0 + m_omega * length;
71 TVector3 vec(m_xc + m_R * cos(phi), m_yc + m_R * sin(phi), m_z0 + m_kz * length);
72 return m_rotationInv * (vec - m_translation);
74 TVector3 vec(x0 + kx * length, y0 + ky * length, z0 + kz * length);
75 return m_rotationInv * (vec - m_translation);
79 TVector3 HelixSwimmer::getDirection(
double length)
const
82 double phi = m_phi0 + m_omega * length;
83 double k_T = m_omega * m_R;
84 TVector3 vec(-k_T * sin(phi), k_T * cos(phi), m_kz);
85 return m_rotationInv * vec;
87 TVector3 vec(kx, ky, kz);
88 return m_rotationInv * vec;
92 double HelixSwimmer::getDistanceToPlane(
const TVector3& point,
const TVector3& normal)
const
95 auto r = point - TVector3(m_xc, m_yc, m_z0);
96 double phi = normal.Phi();
97 double s = r * normal;
98 if (abs(s) > m_R)
return std::numeric_limits<double>::quiet_NaN();
100 double t = shortestDistance(s / m_R, phi);
101 double v = m_kz * normal.Z();
102 if (v == 0)
return t;
106 for (
int i = 0; i < 100; i++) {
107 double cosAlpha = (s - v * t) / m_R;
108 if (abs(cosAlpha) > 1) {
109 return std::numeric_limits<double>::quiet_NaN();
111 t = shortestDistance(cosAlpha, phi);
112 double dt = t - t_prev;
113 if (dt == 0 or (dt + dt_prev) == 0)
return t;
117 if (abs(dt_prev) < 1e-6) {
118 B2DEBUG(20,
"TOP::HelixSwimmer::getDistanceToPlane: not converged"
122 B2DEBUG(20,
"TOP::HelixSwimmer::getDistanceToPlane: not converged"
124 return std::numeric_limits<double>::quiet_NaN();
127 auto r = point - TVector3(x0, y0, z0);
128 auto v = TVector3(kx, ky, kz);
129 return (r * normal) / (v * normal);
Class to store variables with their name which were sent to the logging service.
ExpRunEvt getPosition(const std::vector< Evt > &events, double tEdge)
Get the exp-run-evt number from the event time [hours].
Abstract base class for different kinds of events.