Belle II Software development
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 <Math/Vector3D.h>
12#include <Math/Point3D.h>
13#include <Math/Transform3D.h>
14#include <cmath>
15#include <algorithm>
16
17namespace Belle2 {
22 namespace TOP {
23
31
32 public:
33
38 {}
39
47 void set(const ROOT::Math::XYZPoint& position, const ROOT::Math::XYZVector& momentum, double charge, double Bz);
48
53 void setTransformation(const ROOT::Math::Transform3D& transform) {m_transformInv = transform.Inverse();}
54
59 void moveReferencePosition(double length);
60
66 ROOT::Math::XYZPoint getPosition(double length) const;
67
73 ROOT::Math::XYZVector getDirection(double length) const;
74
81 double getDistanceToPlane(const ROOT::Math::XYZPoint& point, const ROOT::Math::XYZVector& normal) const;
82
83 private:
84
91 double shortestDistance(double cosAlpha, double phi) const;
92
98 double withinSingleTurn(double t) const;
99
100 double m_R = 0;
101 double m_xc = 0;
102 double m_yc = 0;
103 double m_omega = 0;
104 double m_kz = 0;
105 double m_phi0 = 0;
106 double m_z0 = 0;
107 double m_T0 = 0;
109 double& x0 = m_xc;
110 double& y0 = m_yc;
111 double& z0 = m_z0;
112 double& kx = m_R;
113 double& ky = m_phi0;
114 double& kz = m_kz;
116 ROOT::Math::Transform3D m_transformInv;
118 };
119
120
121 inline double HelixSwimmer::shortestDistance(double cosAlpha, double phi) const
122 {
123 double alpha = acos(cosAlpha);
124 double t1 = withinSingleTurn((phi - m_phi0 - alpha) / m_omega);
125 double t2 = withinSingleTurn((phi - m_phi0 + alpha) / m_omega);
126 double ta = std::min(t1, t2);
127 double tb = std::max(t1 - m_T0, t2 - m_T0);
128 double t = (std::abs(ta) < std::abs(tb)) ? ta : tb;
129 return t;
130 }
131
132 inline double HelixSwimmer::withinSingleTurn(double t) const
133 {
134 t = fmod(t, m_T0);
135 if (t < 0) t += m_T0;
136 return t;
137 }
138
139 } // namespace TOP
141} // namespace Belle2
142
Utility for propagation of a particle along helix.
Definition: HelixSwimmer.h:30
double m_phi0
phi of reference position
Definition: HelixSwimmer.h:105
void moveReferencePosition(double length)
Moves reference position along helix by length.
Definition: HelixSwimmer.cc:51
double withinSingleTurn(double t) const
Returns helix length within a single turn.
Definition: HelixSwimmer.h:132
double & kx
direction in x for zero magnetic field
Definition: HelixSwimmer.h:112
ROOT::Math::XYZPoint getPosition(double length) const
Returns particle position at given length.
Definition: HelixSwimmer.cc:63
ROOT::Math::Transform3D m_transformInv
transformation from nominal to local frame
Definition: HelixSwimmer.h:116
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...
Definition: HelixSwimmer.cc:88
double & ky
direction in y for zero magnetic field
Definition: HelixSwimmer.h:113
double & z0
z of reference position for zero magnetic field
Definition: HelixSwimmer.h:111
double & kz
direction in z for zero magnetic field
Definition: HelixSwimmer.h:114
void setTransformation(const ROOT::Math::Transform3D &transform)
Sets transformation from the frame in which helix is constructed (nominal frame) to module local fram...
Definition: HelixSwimmer.h:53
HelixSwimmer()
default constructor
Definition: HelixSwimmer.h:37
double & y0
y of reference position for zero magnetic field
Definition: HelixSwimmer.h:110
double shortestDistance(double cosAlpha, double phi) const
Returns shortest distance.
Definition: HelixSwimmer.h:121
double m_R
helix radius
Definition: HelixSwimmer.h:100
ROOT::Math::XYZVector getDirection(double length) const
Returns particle direction at given length.
Definition: HelixSwimmer.cc:75
double m_yc
helix axis position in y
Definition: HelixSwimmer.h:102
double m_omega
angular speed [1/cm]
Definition: HelixSwimmer.h:103
double m_T0
helix length of single turn
Definition: HelixSwimmer.h:107
double m_z0
z of reference position
Definition: HelixSwimmer.h:106
double m_xc
helix axis position in x
Definition: HelixSwimmer.h:101
void set(const ROOT::Math::XYZPoint &position, const ROOT::Math::XYZVector &momentum, double charge, double Bz)
Sets the helix.
Definition: HelixSwimmer.cc:26
double & x0
x of reference position for zero magnetic field
Definition: HelixSwimmer.h:109
double m_kz
slope in z
Definition: HelixSwimmer.h:104
Abstract base class for different kinds of events.