8#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
10#include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
12#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
13#include <tracking/trackFindingCDC/topology/CDCWireLayer.h>
14#include <tracking/trackFindingCDC/topology/WireLine.h>
15#include <tracking/trackFindingCDC/topology/ISuperLayer.h>
17#include <tracking/trackFindingCDC/geometry/UncertainPerigeeCircle.h>
18#include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
19#include <tracking/trackFindingCDC/geometry/Vector3D.h>
20#include <tracking/trackFindingCDC/geometry/Vector2D.h>
22#include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
23#include <tracking/trackFindingCDC/numerics/ESign.h>
24#include <tracking/trackFindingCDC/numerics/Quadratic.h>
26#include <framework/gearbox/Const.h>
35using namespace TrackFindingCDC;
39 , m_localPerigeeCircle()
44 : m_localOrigin(0.0, 0.0)
45 , m_localPerigeeCircle(perigeeCircle)
52 : m_localOrigin(localOrigin)
53 , m_localPerigeeCircle(localPerigeeCircle)
54 , m_flightTime(flightTime)
63 : m_localOrigin(pos2D)
64 , m_localPerigeeCircle(
CDCBFieldUtil::absMom2DToCurvature(mom2D.norm(), charge, bZ),
75 : m_localOrigin(pos2D)
76 , m_localPerigeeCircle(
CDCBFieldUtil::absMom2DToCurvature(mom2D.norm(), charge, pos2D),
110 const double distance,
111 const double z)
const
119 double fastDistance = distance != 0.0 ? localCircle.
fastDistance(distance) : 0.0;
121 double c = localCircle.
fastDistance(localPos2D) - fastDistance;
122 double b = localCircle.
gradient(localPos2D).
dot(movePerZ);
125 const std::pair<double, double> solutionsDeltaZ = solveQuadraticABC(a, b, c);
128 const std::array<double, 2> solutionsZ{solutionsDeltaZ.second + z, solutionsDeltaZ.first + z};
133 const double distance,
134 const double z)
const
136 const std::array<double, 2> solutionsZ =
reconstructBothZ(wireLine, distance, z);
138 bool firstIsInCDC = (wireLine.
backwardZ() < solutionsZ[0] and
139 solutionsZ[0] < wireLine.
forwardZ());
140 bool secondIsInCDC = (wireLine.
backwardZ() < solutionsZ[1] and
141 solutionsZ[1] < wireLine.
forwardZ());
144 assert(not(std::fabs(solutionsZ[0] - z) > std::fabs(solutionsZ[1] - z)));
145 const double recoZ = (firstIsInCDC or not secondIsInCDC) ? solutionsZ[0] : solutionsZ[1];
150 const double distance,
151 const double z)
const
153 const std::array<double, 2> solutionsZ =
reconstructBothZ(wireLine, distance, z);
157 return {{{
getClosest(firstRecoWirePos3D.
xy()), firstRecoWirePos3D.
z()},
158 {
getClosest(secondRecoWirePos3D.
xy()), secondRecoWirePos3D.
z()}
163 const double distance,
164 const double z)
const
166 const double recoZ =
reconstructZ(wireLine, distance, z);
202 if (forwardBackwardInfo == EForwardBackward::c_Backward) {
203 movingOutward = not movingOutward;
221 if (forwardBackwardInfo == EForwardBackward::c_Backward) {
222 movingOutward = not movingOutward;
231 ISuperLayer iSuperLayerStep = nextISuperLayer - startISuperLayer;
232 assert(std::abs(iSuperLayerStep) == 1);
233 bool nextMovingOutward = iSuperLayerStep > 0;
365std::ostream& TrackFindingCDC::operator<<(std::ostream& output,
const CDCTrajectory2D& trajectory2D)
367 return output <<
"Local origin : " << trajectory2D.
getLocalOrigin() <<
", "
static const double speedOfLight
[cm/ns]
Helper functions to interact with the magnetic field.
static double curvatureToAbsMom2D(double curvature, double bZ)
Conversion helper for two dimensional curvature to momenta.
static ESign ccwInfoToChargeSign(ERotation ccwInfo)
Conversion helper from clockwise or counterclockwise travel to the charge sign.
static double absMom2DToCurvature(double absMom2D, double charge, double bZ)
Conversion helper for momenta to two dimensional curvature.
Particle trajectory as it is seen in xy projection represented as a circle.
void setPosMom2D(const Vector2D &pos2D, const Vector2D &mom2D, double charge)
Setter for start point and momentum at the start point subjected to the charge sign.
double getMaximalCylindricalR() const
Getter for the maximal distance from the origin.
CDCTrajectory2D reversed() const
Returns the reverse trajectory as a copy.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
ISuperLayer getAxialISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const
Indicates which axial superlayer is traversed after the one, where the start point of the trajectory ...
Vector2D getOuterExit(double factor=1) const
Calculates the point where the trajectory meets the outer wall of the CDC.
ISuperLayer getISuperLayerAfter(ISuperLayer iSuperLayer, bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
std::array< double, 2 > reconstructBothZ(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the two z positions where the given drift circle on the wire line touches the trajectory.
void reverse()
Reverses the trajectory in place.
bool isOriginer(double factor=1) const
Checks if the trajectory intersects with the inner radius of the CDC time the given tolerance factor.
ISuperLayer getStartISuperLayer() const
Indicates the superlayer the trajectory starts in.
Vector2D m_localOrigin
Memory for local coordinate origin of the circle representing the trajectory in global coordinates.
double setLocalOrigin(const Vector2D &localOrigin)
Setter for the origin of the local coordinate system.
double calcArcLength2D(const Vector2D &point) const
Calculate the travel distance from the start position of the trajectory.
ESign getChargeSign() const
Gets the charge sign of the trajectory.
ISuperLayer getISuperLayerAfterStart(bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
ISuperLayer getPreviousISuperLayer() const
Indicates which superlayer the trajectory traverses before the one, where the start point of the traj...
bool isCurler(double factor=1) const
Checks if the trajectory leaves the outer radius of the CDC times the given tolerance factor.
ISuperLayer getMinimalISuperLayer() const
Indicates the minimal superlayer the trajectory traverses.
double reconstructZ(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one z positions within the CDC closest to the given z where the given drift circle on the w...
bool isFitted() const
Checks if the circle is already set to a valid value.
Vector2D getSupport() const
Get the support point of the trajectory in global coordinates.
double getMinimalCylindricalR() const
Getter for the minimal distance from the origin - same as absolute value of the impact parameter.
const Vector2D & getLocalOrigin() const
Getter for the origin of the local coordinate system.
ISuperLayer getPreviousAxialISuperLayer() const
Indicates which axial superlayer the trajectory traverses before the one, where the start point of th...
std::array< Vector3D, 2 > reconstructBoth3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the two three dimensional points where the drift circle touches the wire line.
ISuperLayer getMaximalISuperLayer() const
Indicates the maximal superlayer the trajectory traverses.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Vector2D getExit() const
Calculates the point where the trajectory leaves the CDC.
double getAbsMom2D() const
Get the estimation for the absolute value of the transvers momentum.
const UncertainPerigeeCircle & getLocalCircle() const
Getter for the circle in local coordinates.
UncertainPerigeeCircle m_localPerigeeCircle
Memory for the generalized circle describing the trajectory in coordinates from the local origin.
CDCTrajectory2D()
Default constructor for ROOT compatibility.
void clear()
Clears all information from this trajectory.
bool isMovingOutward() const
Indicates if the trajectory is moving outwards or inwards (to or away from the origin) from the start...
ISuperLayer getNextISuperLayer() const
Indicates which superlayer the trajectory traverses after the one, where the start point of the traje...
ISuperLayer getNextAxialISuperLayer() const
Indicates which axial superlayer the trajectory traverses after the one, where the start point of the...
Vector2D getInnerExit() const
Calculates the point where the trajectory meets the inner wall of the CDC.
Vector3D reconstruct3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional positions within the CDC closest to the given z where the given drift...
double m_flightTime
Memory for the estimation of the time at which the particle arrived at the support point.
Class representing a sense wire layer in the central drift chamber.
double getInnerCylindricalR() const
Getter for inner radius of the layer as taken from the CDCGeometryPar.
double getOuterCylindricalR() const
Getter for outer radius of the layer as taken from the CDCGeometryPar.
Class representing the sense wire arrangement in the whole of the central drift chamber.
ISuperLayer getISuperLayerAtCylindricalR(double cylindricalR)
Returns the logical superlayer number at the given radius.
double getInnerCylindricalR() const
Getter for the inner radius of the inner most wire layer.
const std::vector< Belle2::TrackFindingCDC::CDCWireLayer > & getWireLayers() const
Getter for the underlying storing layer vector.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
double getOuterCylindricalR() const
Getter for the outer radius of the outer most wire layer.
Extension of the generalized circle also caching the perigee coordinates.
double fastDistance(const Vector2D &point) const
Getter for the linearised distance measure to a point.
Vector2D perigee() const
Getter for the perigee point.
Vector2D gradient(const Vector2D &point) const
Gradient of the distance field, hence indicates the direction of increasing distance.
Vector2D atCylindricalRForwardOf(const Vector2D &startPoint, double cylindricalR) const
Approach on the circle with the given cylindrical radius that lies in the forward direction of a star...
bool isInvalid() const
Indicates if all circle parameters are zero.
Vector2D chooseNextForwardOf(const Vector2D &start, const Vector2D &end1, const Vector2D &end2) const
Returns the one of two end point which is first reached from the given start if one strictly follows ...
Vector2D apogee() const
Getter for the apogee of the circle. If it was a line both components will be infinity.
double n3() const
Getter for the generalised circle parameter n3.
Vector2D closest(const Vector2D &point) const
Calculates the point of closest approach on the circle to the given point.
Adds an uncertainty matrix to the circle in perigee parameterisation.
void reverse()
Flips the orientation of the circle in place.
void passiveMoveBy(const Vector2D &by)
Moves the coordinate system by the vector by and calculates the new perigee and its covariance matrix...
void invalidate()
Sets all circle parameters to zero including the covariance matrix.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
void set(const double first, const double second)
Setter for both coordinate.
double cylindricalR() const
Gives the cylindrical radius of the vector. Same as norm()
double normSquared() const
Calculates .
Vector2D unit() const
Returns a unit vector colaligned with this.
double norm() const
Calculates the length of the vector.
A three dimensional vector.
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
double z() const
Getter for the z coordinate.
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Vector2D sagMovePerZ(const double z) const
Gives the two dimensional position with wire sag effect of the line at the given z value.
double backwardZ() const
Gives the backward z coordinate.
double forwardZ() const
Gives the forward z coordinate.
Vector3D sagPos3DAtZ(const double z) const
Gives the three dimensional position with wire sag effect of the line at the given z value.
Vector2D sagPos2DAtZ(const double z) const
Gives the two dimensional position with wire sag effect of the line at the given z value.
ESign
Enumeration for the distinct sign values of floating point variables.
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Abstract base class for different kinds of events.
static const ISuperLayer c_Invalid
Constant making an invalid superlayer id.
static bool isAxial(ISuperLayer iSuperLayer)
Returns if the super layer with the given id is axial.
static ISuperLayer getNextInwards(ISuperLayer iSuperLayer)
Returns the super layer that is inside of the given super layer.
static bool isInvalid(ISuperLayer iSuperLayer)
Indicates if the given number corresponds to a true cdc superlayer - excludes the logic ids for inner...
static ISuperLayer getNextOutwards(ISuperLayer iSuperLayer)
Returns the super layer that is outside of the given super layer.