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>
17using namespace ROOT::Math;
26 void HelixSwimmer::set(
const XYZPoint& position,
const XYZVector& momentum,
double charge,
double Bz)
28 double p = momentum.R();
29 double pT = momentum.Rho();
31 if (std::abs(b /
Unit::T) > pT) {
32 m_R = pT / std::abs(b);
34 m_kz = momentum.Z() / p;
45 kx = momentum.X() / p;
46 ky = momentum.Y() / p;
47 kz = momentum.Z() / p;
70 XYZPoint vec(
x0 +
kx * length,
y0 +
ky * length,
z0 +
kz * length);
80 XYZVector vec(-k_T * sin(phi), k_T * cos(phi),
m_kz);
92 double phi = normal.Phi();
93 double s = r.Dot(normal);
94 if (std::abs(s) >
m_R)
return std::numeric_limits<double>::quiet_NaN();
97 double v =
m_kz * normal.Z();
102 for (
int i = 0; i < 100; i++) {
103 double cosAlpha = (s - v * t) /
m_R;
104 if (std::abs(cosAlpha) > 1) {
105 return std::numeric_limits<double>::quiet_NaN();
108 double dt = t - t_prev;
109 if (dt == 0 or (dt + dt_prev) == 0)
return t;
113 if (std::abs(dt_prev) < 1e-6) {
114 B2DEBUG(20,
"TOP::HelixSwimmer::getDistanceToPlane: not converged"
118 B2DEBUG(20,
"TOP::HelixSwimmer::getDistanceToPlane: not converged"
120 return std::numeric_limits<double>::quiet_NaN();
123 auto r = point - XYZPoint(
x0,
y0,
z0);
124 auto v = XYZVector(
kx,
ky,
kz);
125 return r.Dot(normal) / v.Dot(normal);
static const double speedOfLight
[cm/ns]
double m_phi0
phi of reference position
void moveReferencePosition(double length)
Moves reference position along helix by length.
double & kx
direction in x for zero magnetic field
ROOT::Math::XYZPoint getPosition(double length) const
Returns particle position at given length.
ROOT::Math::Transform3D m_transformInv
transformation from nominal to local frame
double getDistanceToPlane(const ROOT::Math::XYZPoint &point, const ROOT::Math::XYZVector &normal) const
Returns the distance along helix to the nearest intersection with the plane nearly parallel to z axis...
double & ky
direction in y for zero magnetic field
double & z0
z of reference position for zero magnetic field
double & kz
direction in z for zero magnetic field
double & y0
y of reference position for zero magnetic field
double shortestDistance(double cosAlpha, double phi) const
Returns shortest distance.
ROOT::Math::XYZVector getDirection(double length) const
Returns particle direction at given length.
double m_yc
helix axis position in y
double m_omega
angular speed [1/cm]
double m_T0
helix length of single turn
double m_z0
z of reference position
double m_xc
helix axis position in x
void set(const ROOT::Math::XYZPoint &position, const ROOT::Math::XYZVector &momentum, double charge, double Bz)
Sets the helix.
double & x0
x of reference position for zero magnetic field
static const double T
[tesla]
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.