8#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
10#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
11#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
13#include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
15#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
17#include <tracking/trackFindingCDC/geometry/UncertainHelix.h>
18#include <tracking/trackFindingCDC/geometry/Helix.h>
19#include <tracking/trackFindingCDC/geometry/HelixParameters.h>
20#include <tracking/trackFindingCDC/geometry/UncertainPerigeeCircle.h>
21#include <tracking/trackFindingCDC/geometry/UncertainSZLine.h>
22#include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
24#include <tracking/trackFindingCDC/geometry/Vector3D.h>
25#include <tracking/trackFindingCDC/geometry/Vector2D.h>
27#include <tracking/trackFindingCDC/numerics/ESign.h>
28#include <tracking/trackFindingCDC/numerics/Quadratic.h>
30#include <tracking/trackFindingCDC/numerics/CovarianceMatrixUtil.h>
31#include <tracking/trackFindingCDC/numerics/JacobianMatrixUtil.h>
32#include <tracking/trackFindingCDC/numerics/TMatrixConversion.h>
34#include <genfit/TrackCand.h>
36#include <mdst/dataobjects/MCParticle.h>
38#include <framework/gearbox/Const.h>
40#include <TMatrixDSym.h>
45using namespace TrackFindingCDC;
49 : m_localOrigin(trajectory2D.getLocalOrigin())
50 , m_localHelix(trajectory2D.getLocalCircle(), trajectorySZ.getSZLine())
51 , m_flightTime(trajectory2D.getFlightTime())
65 : m_localOrigin(pos3D)
66 , m_localHelix(
CDCBFieldUtil::absMom2DToCurvature(mom3D.xy().norm(), charge, bZ),
85 mcParticle.getProductionTime(),
87 mcParticle.getCharge(),
94 mcParticle.getProductionTime(),
96 mcParticle.getCharge())
102 gfTrackCand.getTimeSeed(),
104 gfTrackCand.getChargeSeed(),
116 const TMatrixDSym& seedCov = gfTrackCand.getCovSeed();
122 const double px = gfTrackCand.getStateSeed()[iPx];
123 const double py = gfTrackCand.getStateSeed()[iPy];
124 const double pt = hypot2(px, py);
126 const double cosPhi0 = px / pt;
127 const double sinPhi0 = py / pt;
130 jacobianRot(iX, iX) = cosPhi0;
131 jacobianRot(iX, iY) = sinPhi0;
132 jacobianRot(iY, iX) = -sinPhi0;
133 jacobianRot(iY, iY) = cosPhi0;
134 jacobianRot(iZ, iZ) = 1.0;
136 jacobianRot(iPx, iPx) = cosPhi0;
137 jacobianRot(iPx, iPy) = sinPhi0;
138 jacobianRot(iPy, iPx) = -sinPhi0;
139 jacobianRot(iPy, iPy) = cosPhi0;
140 jacobianRot(iPz, iPz) = 1.0;
148 const double invPt = 1 / pt;
149 const double invPtSquared = invPt * invPt;
150 const double pz = gfTrackCand.getStateSeed()[iPz];
152 const double charge = gfTrackCand.getChargeSeed();
154 using namespace NHelixParameterIndices;
155 jacobianReduce(c_Curv, iPx) = charge * invPtSquared / alpha ;
156 jacobianReduce(c_Phi0, iPy) = invPt;
157 jacobianReduce(c_I, iY) = 1;
158 jacobianReduce(c_TanL, iPx) = - pz * invPtSquared;
159 jacobianReduce(c_TanL, iPz) = invPt;
160 jacobianReduce(c_Z0, iZ) = 1;
181 const double impactXY = localHelix->
impactXY();
184 const double cosPhi0 = phi0Vec.
x();
185 const double sinPhi0 = phi0Vec.
y();
187 const double curvatureXY = localHelix->
curvatureXY();
188 const double tanLambda = localHelix->
tanLambda();
207 const double chargeAlphaCurv =
static_cast<double>(charge) * alpha * curvatureXY;
208 const double chargeAlphaCurv2 =
static_cast<double>(charge) * alpha * std::pow(curvatureXY, 2);
210 const double invChargeAlphaCurv = 1.0 / chargeAlphaCurv;
211 const double invChargeAlphaCurv2 = 1.0 / chargeAlphaCurv2;
213 using namespace NHelixParameterIndices;
215 jacobianInflate(iX, c_Phi0) = -impactXY;
216 jacobianInflate(iY, c_I) = 1.0;
217 jacobianInflate(iZ, c_Z0) = 1.0;
221 jacobianInflate(iPx, c_Curv) = 0;
222 jacobianInflate(iPy, c_Phi0) = momentum.cylindricalR();
223 jacobianInflate(iPz, c_Curv) = 0;
224 jacobianInflate(iPz, c_TanL) = momentum.cylindricalR();
226 jacobianInflate(iPx, c_Curv) = invChargeAlphaCurv2;
227 jacobianInflate(iPy, c_Phi0) = - invChargeAlphaCurv;
228 jacobianInflate(iPz, c_Curv) = tanLambda * invChargeAlphaCurv2;
229 jacobianInflate(iPz, c_TanL) = - invChargeAlphaCurv;
239 jacobianRot(iX, iX) = cosPhi0;
240 jacobianRot(iX, iY) = -sinPhi0;
241 jacobianRot(iY, iX) = sinPhi0;
242 jacobianRot(iY, iY) = cosPhi0;
243 jacobianRot(iZ, iZ) = 1.0;
245 jacobianRot(iPx, iPx) = cosPhi0;
246 jacobianRot(iPx, iPy) = -sinPhi0;
247 jacobianRot(iPy, iPx) = sinPhi0;
248 jacobianRot(iPy, iPy) = cosPhi0;
249 jacobianRot(iPz, iPz) = 1.0;
278 gfTrackCand.setPosMomSeed(position, momentum, charge);
283 gfTrackCand.setCovSeed(covSeed);
293 return calculateCovarianceMatrix(
getLocalHelix(), momentum, charge, bZ);
310 double factor2DTo3D = hypot2(1, tanLambda);
313 return factor2DTo3D * absMom2D;
320 double factor2DTo3D = hypot2(1, tanLambda);
323 return factor2DTo3D * absMom2D;
370 double arcLength3D = arcLength2D * factor2DTo3D;
377std::ostream& TrackFindingCDC::operator<<(std::ostream& output,
const CDCTrajectory3D& trajectory3D)
379 return output <<
"Local origin : " << trajectory3D.
getLocalOrigin() <<
", "
static const double speedOfLight
[cm/ns]
A Class to store the Monte Carlo particle information.
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 getBFieldZ()
Getter for the signed magnetic field strength in z direction at the origin ( in Tesla )
static double getAlphaFromBField(double bField)
Translator from magnetic field strength in Tesla to the alpha value.
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 calcArcLength2D(const Vector3D &point) const
Calculate the travel distance from the start position of the trajectory.
Vector3D m_localOrigin
Memory for local coordinate origin of the circle representing the trajectory in global coordinates.
double getMaximalCylindricalR() const
Getter for the maximal distance from the origin.
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.
double getFlightTime() const
Getter for the time when the particle reached the support point position.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
ESign getChargeSign() const
Gets the charge sign of the trajectory.
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.
UncertainSZLine getLocalSZLine() const
Getter for the sz line starting from the local origin.
CDCTrajectory3D()
Default constructor for ROOT compatibility.
Vector3D getFlightDirection3DAtSupport() const
Get the unit momentum at the start point of the trajectory.
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.
Vector3D getMom3DAtSupport() const
Get the momentum at the start point of the trajectory.
UncertainHelix m_localHelix
Memory for the generalized circle describing the trajectory in coordinates from the local origin.
double setLocalOrigin(const Vector3D &localOrigin)
Setter for the origin of the local coordinate system.
const Vector3D & getLocalOrigin() const
Getter for the origin of the local coordinate system.
double m_flightTime
Memory for the estimation of the time at which the particle arrived at the support point.
Vector3D getSupport() const
Getter for the support point of the trajectory in global coordinates, where arcLength2D = 0.
Linear trajectory in sz space.
Class representing the sense wire arrangement in the whole of the central drift chamber.
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.
double impactXY() const
Getter for the signed distance to the z axes at the perigee point.
double tanLambda() const
Getter for the proportinality factor from arc length in xy space to z.
double curvatureXY() const
Getter for the signed curvature in the xy projection.
const Vector2D & phi0Vec() const
Getter for the direction vector in the xy projection at the perigee of the helix.
Extension of the generalized circle also caching the perigee coordinates.
A matrix implementation to be used as an interface typ through out the track finder.
A general helix class including a covariance matrix.
const HelixCovariance & helixCovariance() const
Getter for the whole covariance matrix of the perigee parameters.
UncertainSZLine uncertainSZLine() const
Reduces the helix to an sz line carrying over the relevant parts of the convariance matrix.
void setHelixCovariance(const HelixCovariance &helixCovariance)
Setter for the whole covariance matrix of the perigee parameters.
double shiftPeriod(int nPeriods)
Adjust the arclength measure to start n periods later.
void passiveMoveBy(const Vector3D &by)
Moves the coordinate system by the vector by and calculates the new perigee and its covariance matrix...
UncertainPerigeeCircle uncertainCircleXY() const
Projects the helix into the xy plain carrying over the relevant parts of the convariance matrix.
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...
void passiveMoveBy(const Vector2D &bySZ)
Moves the coordinate system by the vector by and calculates the new sz line and its covariance matrix...
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
double x() const
Getter for the x coordinate.
double y() const
Getter for the y coordinate.
A three dimensional vector.
bool hasNAN() const
Checks if one of the coordinates is NAN.
ESign
Enumeration for the distinct sign values of floating point variables.
bool isValid(ESign s)
Returns true if sign is ESign::c_Plus, ESign::c_Minus or ESign::c_Zero.
Abstract base class for different kinds of events.
static CovarianceMatrix< M > transported(const JacobianMatrix< M, N > &jacobian, const CovarianceMatrix< N > &cov)
Return a copy of the covariance matrix transported with the given jacobian matrix.
static void transport(const JacobianMatrix< N, N > &jacobian, CovarianceMatrix< N > &cov)
Transport the covariance matrix inplace with the given jacobian matrix.
static TMatrixDSym toTMatrix(const CovarianceMatrix< N > &cov)
Translate the covariance matrix to the TMatrix representation.