EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
Helix.h
Go to the documentation of this file.
1// FIXME SPDX-License-Identifier: TBD
2// Copyright (C) 1997 - 2025 The STAR Collaboration, Xin Dong, Rongrong Ma
3
4#pragma once
5
6#include <edm4eic/ReconstructedParticleCollection.h>
7#include <edm4eic/TrackParametersCollection.h>
8#include <edm4eic/unit_system.h>
9#include <edm4hep/Vector3f.h>
10#include <stdlib.h>
11#include <cmath>
12#include <iterator>
13#include <utility>
14
15namespace eicrecon {
16
17class Helix {
18 bool mSingularity; // true for straight line case (B=0)
19 edm4hep::Vector3f mOrigin;
20 double mDipAngle;
21 double mCurvature;
22 double mPhase;
23 int mH; // -sign(q*B);
24
25 double mCosDipAngle;
26 double mSinDipAngle;
27 double mCosPhase;
28 double mSinPhase;
29
30public:
32 Helix(const double c, const double dip, const double phase, const edm4hep::Vector3f& o,
33 const int h = -1);
34
36 Helix(const edm4hep::Vector3f& p, const edm4hep::Vector3f& o, const double B, const int q);
37
39 Helix(const edm4eic::ReconstructedParticle& p, const double b_field);
40
41 ~Helix() = default;
42
43 double dipAngle() const;
44 double curvature() const;
45 double phase() const;
46 double xcenter() const;
47 double ycenter() const;
48 int h() const;
49
50 const edm4hep::Vector3f& origin() const;
51
52 void setParameters(double c, double dip, double phase, const edm4hep::Vector3f& o, int h);
53
54 void setParameters(const edm4hep::Vector3f& p, const edm4hep::Vector3f& o, const double B,
55 const int q);
56
58 void setParameters(const edm4eic::TrackParameters& trk, const double b_field);
59
61 double x(double s) const;
62 double y(double s) const;
63 double z(double s) const;
64
65 edm4hep::Vector3f at(double s) const;
66
68 double cx(double s) const;
69 double cy(double s) const;
70 double cz(double s = 0) const;
71
72 edm4hep::Vector3f cat(double s) const;
73
75 double period() const;
76
78 std::pair<double, double> pathLength(double r) const;
79
81 std::pair<double, double> pathLength(double r, double x, double y);
82
84 double pathLength(const edm4hep::Vector3f& p, bool scanPeriods = true) const;
85
87 double pathLength(const edm4hep::Vector3f& r, const edm4hep::Vector3f& n) const;
88
90 double pathLength(double x, double y) const;
91
93 std::pair<double, double> pathLengths(const Helix&, double minStepSize = 10 * edm4eic::unit::um,
94 double minRange = 10 * edm4eic::unit::cm) const;
95
97 double distance(const edm4hep::Vector3f& p, bool scanPeriods = true) const;
98
100 bool valid(double world = 1.e+5) const { return !bad(world); }
101 int bad(double world = 1.e+5) const;
102
104 void moveOrigin(double s);
105
106 static const double NoSolution;
107
108 void setCurvature(double);
109 void setPhase(double);
110 void setDipAngle(double);
111
113 double fudgePathLength(const edm4hep::Vector3f&) const;
114
115 // Requires: signed Magnetic Field
116 edm4hep::Vector3f momentum(double) const; // returns the momentum at origin
117 edm4hep::Vector3f momentumAt(double, double) const; // returns momentum at S
118 int charge(double) const; // returns charge of particle
119 // 2d DCA to x,y point signed relative to curvature
120 double curvatureSignedDistance(double x, double y);
121 // 2d DCA to x,y point signed relative to rotation
122 double geometricSignedDistance(double x, double y);
123 // 3d DCA to 3d point signed relative to curvature
124 double curvatureSignedDistance(const edm4hep::Vector3f&);
125 // 3d DCA to 3d point signed relative to rotation
126 double geometricSignedDistance(const edm4hep::Vector3f&);
127
128 //
129 void Print() const;
130
131}; // end class Helix
132
133//
134// Inline functions
135//
136inline int Helix::h() const { return mH; }
137
138inline double Helix::dipAngle() const { return mDipAngle; }
139
140inline double Helix::curvature() const { return mCurvature; }
141
142inline double Helix::phase() const { return mPhase; }
143
144inline double Helix::x(double s) const {
145 if (mSingularity)
146 return mOrigin.x - s * mCosDipAngle * mSinPhase;
147 else
148 return mOrigin.x + (cos(mPhase + s * mH * mCurvature * mCosDipAngle) - mCosPhase) / mCurvature;
149}
150
151inline double Helix::y(double s) const {
152 if (mSingularity)
153 return mOrigin.y + s * mCosDipAngle * mCosPhase;
154 else
155 return mOrigin.y + (sin(mPhase + s * mH * mCurvature * mCosDipAngle) - mSinPhase) / mCurvature;
156}
157
158inline double Helix::z(double s) const { return mOrigin.z + s * mSinDipAngle; }
159
160inline double Helix::cx(double s) const {
161 if (mSingularity)
162 return -mCosDipAngle * mSinPhase;
163 else
164 return -sin(mPhase + s * mH * mCurvature * mCosDipAngle) * mH * mCosDipAngle;
165}
166
167inline double Helix::cy(double s) const {
168 if (mSingularity)
169 return mCosDipAngle * mCosPhase;
170 else
171 return cos(mPhase + s * mH * mCurvature * mCosDipAngle) * mH * mCosDipAngle;
172}
173
174inline double Helix::cz(double /* s */) const { return mSinDipAngle; }
175
176inline const edm4hep::Vector3f& Helix::origin() const { return mOrigin; }
177
178inline edm4hep::Vector3f Helix::at(double s) const { return edm4hep::Vector3f(x(s), y(s), z(s)); }
179
180inline edm4hep::Vector3f Helix::cat(double s) const {
181 return edm4hep::Vector3f(cx(s), cy(s), cz(s));
182}
183
184inline double Helix::pathLength(double X, double Y) const {
185 return fudgePathLength(edm4hep::Vector3f(X, Y, 0));
186}
187inline int Helix::bad(double WorldSize) const {
188
189 // int ierr;
190 if (!std::isfinite(mDipAngle))
191 return 11;
192 if (!std::isfinite(mCurvature))
193 return 12;
194
195 // ierr = mOrigin.bad(WorldSize);
196 // if (ierr) return 3+ierr*100;
197
198 if (std::abs(mDipAngle) > 1.58)
199 return 21;
200 double qwe = std::abs(std::abs(mDipAngle) - M_PI / 2);
201 if (qwe < 1. / WorldSize)
202 return 31;
203
204 if (std::abs(mCurvature) > WorldSize)
205 return 22;
206 if (mCurvature < 0)
207 return 32;
208
209 if (std::abs(mH) != 1)
210 return 24;
211
212 return 0;
213}
214
215} // namespace eicrecon
Definition Helix.h:17
double cx(double s) const
pointing vector of helix at point s
Definition Helix.h:160
double cy(double s) const
Definition Helix.h:167
void setDipAngle(double)
Definition Helix.cc:128
double distance(const edm4hep::Vector3f &p, bool scanPeriods=true) const
minimal distance between point and helix
Definition Helix.cc:162
void setPhase(double)
performs also various checks
Definition Helix.cc:120
double dipAngle() const
Definition Helix.h:138
void Print() const
Definition Helix.cc:525
edm4hep::Vector3f cat(double s) const
Definition Helix.h:180
~Helix()=default
void setParameters(double c, double dip, double phase, const edm4hep::Vector3f &o, int h)
starting point
Definition Helix.cc:76
std::pair< double, double > pathLengths(const Helix &, double minStepSize=10 *edm4eic::unit::um, double minRange=10 *edm4eic::unit::cm) const
path lengths at dca between two helices
Definition Helix.cc:412
static const double NoSolution
Definition Helix.h:106
int charge(double) const
Definition Helix.cc:554
bool valid(double world=1.e+5) const
checks for valid parametrization
Definition Helix.h:100
edm4hep::Vector3f momentum(double) const
Definition Helix.cc:534
edm4hep::Vector3f momentumAt(double, double) const
Definition Helix.cc:547
double curvature() const
Definition Helix.h:140
edm4hep::Vector3f at(double s) const
Definition Helix.h:178
double period() const
returns period length of helix
Definition Helix.cc:249
double x(double s) const
coordinates of helix at point s
Definition Helix.h:144
double xcenter() const
aziumth in xy-plane measured from ring center
Definition Helix.cc:134
const edm4hep::Vector3f & origin() const
-sign(q*B);
Definition Helix.h:176
int bad(double world=1.e+5) const
Definition Helix.h:187
double fudgePathLength(const edm4hep::Vector3f &) const
value of S where distance in x-y plane is minimal
Definition Helix.cc:148
double y(double s) const
Definition Helix.h:151
std::pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Definition Helix.cc:256
double ycenter() const
x-center of circle in xy-plane
Definition Helix.cc:141
double phase() const
1/R in xy-plane
Definition Helix.h:142
void moveOrigin(double s)
move the origin along the helix to s which becomes then s=0
Definition Helix.cc:515
void setCurvature(double)
Definition Helix.cc:106
double z(double s) const
Definition Helix.h:158
int h() const
y-center of circle in xy-plane
Definition Helix.h:136
double cz(double s=0) const
Definition Helix.h:174
double curvatureSignedDistance(double x, double y)
Definition Helix.cc:579
double geometricSignedDistance(double x, double y)
Definition Helix.cc:556
-client
Definition CalorimeterClusterRecoCoG.cc:37