Belle II Software development
CDCTrajectory3D.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#pragma once
9
10#include <tracking/trackingUtilities/geometry/UncertainHelix.h>
11#include <tracking/trackingUtilities/geometry/Helix.h>
12#include <tracking/trackingUtilities/geometry/HelixParameters.h>
13
14#include <tracking/trackingUtilities/numerics/ESign.h>
15
16#include <Math/Vector3D.h>
17#include <Math/Vector2D.h>
18
19#include <TMath.h>
20#include <cmath>
21#include <cstddef>
22#include <iosfwd>
23
24namespace genfit {
25 class TrackCand;
26}
27
28namespace Belle2 {
33 class MCParticle;
34 namespace CDC {
35 class WireLine;
36 }
37
38 namespace TrackingUtilities {
39 class CDCTrajectory2D;
40 class CDCTrajectorySZ;
41
43 class UncertainSZLine;
44
47
48 public:
52 , m_localHelix()
53 {
54 }
55
57 explicit CDCTrajectory3D(const UncertainHelix& helix)
58 : m_localOrigin(0.0, 0.0, 0.0)
59 , m_localHelix(helix)
60 , m_flightTime(0.0)
61 {
62 }
63
65 explicit CDCTrajectory3D(const Helix& helix) : CDCTrajectory3D(UncertainHelix(helix))
66 {
67 }
68
70 CDCTrajectory3D(const ROOT::Math::XYZVector& localOrigin,
71 const UncertainHelix& localHelix,
72 double flightTime = NAN)
73 : m_localOrigin(localOrigin)
74 , m_localHelix(localHelix)
75 , m_flightTime(flightTime)
76 {
77 }
78
81 CDCTrajectory3D(const CDCTrajectory2D& trajectory2D, const CDCTrajectorySZ& trajectorySZ);
82
87 explicit CDCTrajectory3D(const CDCTrajectory2D& trajectory2D);
88
95 CDCTrajectory3D(const ROOT::Math::XYZVector& pos3D,
96 double time,
97 const ROOT::Math::XYZVector& mom3D,
98 double charge,
99 double bZ);
100
103 CDCTrajectory3D(const ROOT::Math::XYZVector& pos3D, double time, const ROOT::Math::XYZVector& mom3D, double charge);
104
106 CDCTrajectory3D(const MCParticle& mcParticle, double bZ);
107
109 explicit CDCTrajectory3D(const MCParticle& mcParticle);
110
112 CDCTrajectory3D(const genfit::TrackCand& gfTrackCand, double bZ);
113
115 explicit CDCTrajectory3D(const genfit::TrackCand& gfTrackCand);
116
117 public:
119 bool isInvalid() const
120 {
121 return m_localHelix->isInvalid();
122 }
123
125 bool isFitted() const
126 {
127 return not isInvalid();
128 }
129
131 void clear()
132 {
133 m_localOrigin.SetXYZ(0.0, 0.0, 0.0);
134 m_localHelix.invalidate();
135 m_flightTime = NAN;
136 }
137
138 public:
140 bool fillInto(genfit::TrackCand& trackCand) const;
141
143 bool fillInto(genfit::TrackCand& gfTrackCand, double bZ) const;
144
146 CovarianceMatrix<6> getCartesianCovariance(double bZ) const;
147
148 public:
150 void reverse()
151 {
152 m_localHelix.reverse();
154 }
155
161
169 ROOT::Math::XYZVector reconstruct3D(const CDC::WireLine& wireLine, double distance = 0.0) const;
170
179 double calcArcLength2D(const ROOT::Math::XYZVector& point) const
180 {
181 return getLocalHelix()->circleXY().arcLengthTo(VectorUtil::getXYVector(point - getLocalOrigin()));
182 }
183
185 double getArcLength2DPeriod() const
186 {
188 }
189
190 public:
196 double shiftPeriod(int nPeriods);
197
198 public:
200 ESign getChargeSign() const;
201
203 double getAbsMom3D(double bZ) const;
204
206 double getAbsMom3D() const;
207
209 ROOT::Math::XYZVector getMom3DAtSupport(const double bZ) const
210 {
212 }
213
215 ROOT::Math::XYZVector getMom3DAtSupport() const
216 {
218 }
219
221 ROOT::Math::XYZVector getFlightDirection3DAtSupport() const
222 {
223 return getLocalHelix()->tangential();
224 }
225
228 ROOT::Math::XYZVector getSupport() const
229 {
230 return getLocalHelix()->perigee() + getLocalOrigin();
231 }
232
234 ROOT::Math::XYZVector getGlobalPerigee() const
235 {
236 return getLocalHelix()->closestXY(-VectorUtil::getXYVector(m_localOrigin)) + m_localOrigin;
237 }
238
240 ROOT::Math::XYVector getGlobalCenter() const
241 {
242 return getLocalHelix()->centerXY() + VectorUtil::getXYVector(m_localOrigin);
243 }
244
245 public:
248 bool isCurler(double factor = 1) const;
249
252 {
253 return std::fabs(getGlobalImpact() + 2 * getLocalHelix()->radiusXY());
254 }
255
258 {
259 return std::fabs(getGlobalImpact());
260 }
261
263 double getGlobalImpact() const
264 {
265 return getLocalHelix()->distanceXY(-VectorUtil::getXYVector(m_localOrigin));
266 }
267
268 public:
271
274
277
280
283
285 double getLocalCovariance(EHelixParameter iRow, EHelixParameter iCol) const
286 {
287 return getLocalHelix().covariance(iRow, iCol);
288 }
289
292 double getLocalVariance(EHelixParameter i) const
293 {
294 return getLocalHelix().variance(i);
295 }
296
298 double getTanLambda() const
299 {
300 return getLocalHelix()->tanLambda();
301 }
302
304 double getCurvatureXY() const
305 {
306 return getLocalHelix()->curvatureXY();
307 }
308
310 double getPValue() const
311 {
312 return TMath::Prob(getChi2(), getNDF());
313 }
314
316 double getChi2() const
317 {
318 return getLocalHelix().chi2();
319 }
320
322 void setChi2(const double chi2)
323 {
324 return m_localHelix.setChi2(chi2);
325 }
326
328 size_t getNDF() const
329 {
330 return getLocalHelix().ndf();
331 }
332
334 void setNDF(std::size_t ndf)
335 {
336 return m_localHelix.setNDF(ndf);
337 }
338
341 {
342 return m_localHelix;
343 }
344
346 void setLocalHelix(const UncertainHelix& localHelix)
347 {
348 m_localHelix = localHelix;
349 }
350
352 const ROOT::Math::XYZVector& getLocalOrigin() const
353 {
354 return m_localOrigin;
355 }
356
362 double setLocalOrigin(const ROOT::Math::XYZVector& localOrigin);
363
365 double getFlightTime() const
366 {
367 return m_flightTime;
368 }
369
371 void setFlightTime(double flightTime)
372 {
373 m_flightTime = flightTime;
374 }
375 private:
378 ROOT::Math::XYZVector m_localOrigin;
379
383
385 double m_flightTime = NAN;
386 };
387
389 std::ostream& operator<<(std::ostream& output, const CDCTrajectory3D& trajectory3D);
390 }
392}
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
Particle trajectory as it is seen in xy projection represented as a circle.
Particle full three dimensional trajectory.
UncertainPerigeeCircle getLocalCircle() const
Getter for the circle in local coordinates.
double setLocalOrigin(const ROOT::Math::XYZVector &localOrigin)
Setter for the origin of the local coordinate system.
double getMaximalCylindricalR() const
Getter for the maximal distance from the origin.
double getLocalCovariance(EHelixParameter iRow, EHelixParameter iCol) const
Getter for an individual element of the covariance matrix of the local helix parameters.
bool fillInto(genfit::TrackCand &trackCand) const
Copies the trajectory information to the Genfit track candidate.
double getAbsMom3D() const
Get the estimation for the absolute value of the transvers momentum.
CovarianceMatrix< 6 > getCartesianCovariance(double bZ) const
Convert the helix parameters to the cartesian coordinates x,y,z,px,py,pz.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
bool isInvalid() const
Checks if the trajectory is already set to a valid value.
CDCTrajectory3D reversed() const
Returns the reverse trajectory as a copy.
double getGlobalImpact() const
Getter for the signed impact parameter of the trajectory.
void reverse()
Reverses the trajectory in place.
ROOT::Math::XYZVector getMom3DAtSupport() const
Get the momentum at the start point of the trajectory.
double getFlightTime() const
Getter for the time when the particle reached the support point position.
ROOT::Math::XYVector getGlobalCenter() const
Getter for the center of the helix in global coordinates.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectory3D(const ROOT::Math::XYZVector &localOrigin, const UncertainHelix &localHelix, double flightTime=NAN)
Constructs a trajectory from a local helix taken as relative to the given origin.
ESign getChargeSign() const
Gets the charge sign of the trajectory.
CDCTrajectory3D(const Helix &helix)
conversion constructor to make that one stupid test work
double getChi2() const
Getter for the chi2 value of the fit.
double getPValue() const
Getter for p-value.
ROOT::Math::XYZVector reconstruct3D(const CDC::WireLine &wireLine, double distance=0.0) const
Gives the three dimensional point which is on the dirft circle away from the wire line.
double shiftPeriod(int nPeriods)
Adjusts the z0 to the one that lies n periods forward.
bool isCurler(double factor=1) const
Checks if the trajectory leaves the outer radius of the CDC times the given tolerance factor.
double getLocalVariance(EHelixParameter i) const
Getter for an individual diagonal element of the covariance matrix of the local helix parameters.
bool isFitted() const
Checks if the trajectory has already been set to a valid value.
ROOT::Math::XYZVector getMom3DAtSupport(const double bZ) const
Get the momentum at the start point of the trajectory.
double getMinimalCylindricalR() const
Getter for the minimal distance from the origin.
UncertainSZLine getLocalSZLine() const
Getter for the sz line starting from the local origin.
double getCurvatureXY() const
Getter for the curvature as seen from the xy projection.
CDCTrajectory3D()
Default constructor for ROOT compatibility.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
const UncertainHelix & getLocalHelix() const
Getter for the helix in local coordinates.
double getTanLambda() const
Getter for the slope of z over the transverse travel distance s.
double getArcLength2DPeriod() const
Getter for the arc length for one round trip around the trajectory.
ROOT::Math::XYZVector m_localOrigin
Memory for local coordinate origin of the circle representing the trajectory in global coordinates.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freedom of the helix fit.
UncertainHelix m_localHelix
Memory for the generalized circle describing the trajectory in coordinates from the local origin.
const ROOT::Math::XYZVector & getLocalOrigin() const
Getter for the origin of the local coordinate system.
double calcArcLength2D(const ROOT::Math::XYZVector &point) const
Calculate the travel distance from the start position of the trajectory.
void clear()
Clears all information from this trajectoy.
void setFlightTime(double flightTime)
Setter for the time when the particle reached the support point position.
void setChi2(const double chi2)
Setter for the chi square value of the helix fit.
CDCTrajectory3D(const UncertainHelix &helix)
Constructs a trajectory from a helix with reference point equivalent to the origin.
ROOT::Math::XYZVector getGlobalPerigee() const
Getter for the closest approach on the trajectory to the global origin.
size_t getNDF() const
Getter for the number of degrees of freedom of the helix fit.
ROOT::Math::XYZVector getFlightDirection3DAtSupport() const
Get the unit momentum at the start point of the trajectory.
ROOT::Math::XYZVector getSupport() const
Getter for the support point of the trajectory in global coordinates, where arcLength2D = 0.
void setLocalHelix(const UncertainHelix &localHelix)
Setter for the helix that describes the trajectory in local coordinates.
double m_flightTime
Memory for the estimation of the time at which the particle arrived at the support point.
Extension of the generalized circle also caching the perigee coordinates.
Definition Helix.h:30
ROOT::Math::XYZVector perigee() const
Getter for the perigee point of the helix.
Definition Helix.h:238
ROOT::Math::XYZVector closestXY(const ROOT::Math::XYVector &pointXY) const
Calculates the point on the helix with the smallest perpendicular (xy) distance.
Definition Helix.h:127
ROOT::Math::XYZVector tangential() const
Getter for the unit three dimensional tangential vector at the perigee point of the helix.
Definition Helix.h:294
double tanLambda() const
Getter for the proportinality factor from arc length in xy space to z.
Definition Helix.h:245
double curvatureXY() const
Getter for the signed curvature in the xy projection.
Definition Helix.h:208
double arcLength2DPeriod() const
Getter for the arc length of one trip around the helix.
Definition Helix.h:270
ROOT::Math::XYVector centerXY() const
Getter for the central point of the helix.
Definition Helix.h:288
const PerigeeCircle & circleXY() const
Getter for the projection into xy space.
Definition Helix.h:326
double distanceXY(const ROOT::Math::XYVector &point) const
Calculates the distance of the line parallel to the z axes through the given point.
Definition Helix.h:140
Extension of the generalized circle also caching the perigee coordinates.
double arcLengthTo(const ROOT::Math::XYVector &point) const
Calculates the arc length between the perigee and the given point.
A general helix class including a covariance matrix.
double variance(const EHelixParameter &i) const
Getter for individual diagonal elements of the covariance matrix.
double covariance(const EHelixParameter &iRow, const EHelixParameter &iCol) const
Getter for individual elements of the covariance matrix.
double chi2() const
Getter for the chi square value of the helix fit.
std::size_t ndf() const
Getter for the number of degrees of freediom used in the helix fit.
Adds an uncertainty matrix to the circle in perigee parameterisation.
A line in sz where s is the transverse travel distance as seen in the xy projection with uncertaintie...
Abstract base class for different kinds of events.