24 #ifndef genfit_RKTrackRep_h
25 #define genfit_RKTrackRep_h
27 #include "AbsTrackRep.h"
28 #include "StateOnPlane.h"
30 #include "StepLimits.h"
46 std::fill(state7_.begin(), state7_.end(), 0);
59 std::fill(jac7_.begin(), jac7_.end(), 0);
60 std::fill(noise7_.begin(), noise7_.end(), 0);
73 friend class RKTrackRepTests_momMag_Test;
74 friend class RKTrackRepTests_calcForwardJacobianAndNoise_Test;
75 friend class RKTrackRepTests_getState7_Test;
76 friend class RKTrackRepTests_getState5_Test;
89 bool stopAtBoundary =
false,
90 bool calcJacobianNoise =
false)
const override;
95 const TVector3& linePoint,
96 const TVector3& lineDirection,
97 bool stopAtBoundary =
false,
98 bool calcJacobianNoise =
false)
const override;
101 const TVector3& point,
102 bool stopAtBoundary =
false,
103 bool calcJacobianNoise =
false)
const override {
104 return extrapToPoint(state, point,
nullptr, stopAtBoundary, calcJacobianNoise);
108 const TVector3& point,
109 const TMatrixDSym& G,
110 bool stopAtBoundary =
false,
111 bool calcJacobianNoise =
false)
const override {
112 return extrapToPoint(state, point, &G, stopAtBoundary, calcJacobianNoise);
117 const TVector3& linePoint = TVector3(0.,0.,0.),
118 const TVector3& lineDirection = TVector3(0.,0.,1.),
119 bool stopAtBoundary =
false,
120 bool calcJacobianNoise =
false)
const override;
125 const TVector3& linePoint = TVector3(0.,0.,0.),
126 const TVector3& lineDirection = TVector3(0.,0.,1.),
127 bool stopAtBoundary =
false,
128 bool calcJacobianNoise =
false)
const override ;
132 const TVector3& point = TVector3(0.,0.,0.),
133 bool stopAtBoundary =
false,
134 bool calcJacobianNoise =
false)
const override;
138 bool stopAtBoundary =
false,
139 bool calcJacobianNoise =
false)
const override;
142 unsigned int getDim()
const override {
return 5;}
163 std::vector<genfit::MatStep>
getSteps()
const override;
167 virtual void setPosMom(
StateOnPlane& state,
const TVector3& pos,
const TVector3& mom)
const override;
169 virtual void setPosMomErr(
MeasuredStateOnPlane& state,
const TVector3& pos,
const TVector3& mom,
const TVector3& posErr,
const TVector3& momErr)
const override;
192 bool varField =
true,
193 bool calcOnlyLastRowOfJ =
false)
const;
200 void initArrays()
const;
203 const TVector3& point,
204 const TMatrixDSym* G =
nullptr,
205 bool stopAtBoundary =
false,
206 bool calcJacobianNoise =
false)
const;
211 void calcJ_pM_5x7(
M5x7& J_pM,
const TVector3& U,
const TVector3& V,
const M1x3& pTilde,
double spu)
const;
216 void calcJ_Mp_7x5(
M7x5& J_Mp,
const TVector3& U,
const TVector3& V,
const TVector3& W,
const M1x3& A)
const;
218 void calcForwardJacobianAndNoise(
const M1x7& startState7,
const DetPlane& startPlane,
219 const M1x7& destState7,
const DetPlane& destPlane)
const;
221 void transformM6P(
const M6x6& in6x6,
241 M1x7* J_MMT_unprojected_lastRow,
242 double& coveredDistance,
245 M7x7& noiseProjection,
247 bool onlyOneStep =
false,
248 bool calcOnlyLastRowOfJ =
false)
const;
250 double estimateStep(
const M1x7& state7,
253 const double& charge,
257 TVector3 pocaOnLine(
const TVector3& linePoint,
258 const TVector3& lineDirection,
259 const TVector3& point)
const;
277 bool fillExtrapSteps,
278 TMatrixDSym* cov =
nullptr,
279 bool onlyOneStep =
false,
280 bool stopAtBoundary =
false,
281 double maxStep = 1.E99)
const;
285 double momMag(
const M1x7& state7)
const;
296 mutable int RKStepsFXStop_;
297 mutable std::vector<ExtrapStep> ExtrapSteps_;
300 mutable TMatrixDSym fNoise_;
302 mutable bool useCache_;
308 mutable M7x7 noiseArray_;
Abstract base class for a track representation.
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and,...
#StateOnPlane with additional covariance matrix.
AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v)
unsigned int getDim() const override
Get the dimension of the state vector used by the track representation.
M7x7 noiseProjection_
noise matrix of the last extrapolation
std::vector< genfit::MatStep > getSteps() const override
Get stepsizes and material properties of crossed materials of the last extrapolation.
virtual void setPosMomErr(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TVector3 &posErr, const TVector3 &momErr) const override
Set position and momentum and error of state.
virtual bool isSame(const AbsTrackRep *other) override
check if other is of same type (e.g. RKTrackRep) and has same pdg code.
std::vector< RKStep > RKSteps_
state where the last extrapolation has ended
int RKStepsFXStart_
RungeKutta steps made in the last extrapolation.
virtual TVector3 getMom(const StateOnPlane &state) const override
Get the cartesian momentum vector of a state.
virtual AbsTrackRep * clone() const override
Clone the trackRep.
virtual double getMomMag(const StateOnPlane &state) const override
get the magnitude of the momentum in GeV.
bool RKutta(const M1x4 &SU, const DetPlane &plane, double charge, double mass, M1x7 &state7, M7x7 *jacobianT, M1x7 *J_MMT_unprojected_lastRow, double &coveredDistance, double &flightTime, bool &checkJacProj, M7x7 &noiseProjection, StepLimits &limits, bool onlyOneStep=false, bool calcOnlyLastRowOfJ=false) const
Propagates the particle through the magnetic field.
virtual double extrapolateToCone(StateOnPlane &state, double radius, const TVector3 &linePoint=TVector3(0., 0., 0.), const TVector3 &lineDirection=TVector3(0., 0., 1.), bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state to the cone surface, and returns the extrapolation length and,...
virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane &state) const override
Get the 6D covariance.
virtual double extrapolateToPlane(StateOnPlane &state, const SharedPlanePtr &plane, bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state to plane, and returns the extrapolation length and, via reference,...
double getTime(const StateOnPlane &state) const override
Get the time corresponding to the StateOnPlane. Extrapolation.
virtual double getMomVar(const MeasuredStateOnPlane &state) const override
get the variance of the absolute value of the momentum .
TMatrixD fJacobian_
steps made in Extrap during last extrapolation
virtual double getRadiationLenght() const override
Get the accumulated X/X0 (path / radiation length) of the material crossed in the last extrapolation.
void setTime(StateOnPlane &state, double time) const override
Set time at which the state was defined.
virtual double extrapolateToCylinder(StateOnPlane &state, double radius, const TVector3 &linePoint=TVector3(0., 0., 0.), const TVector3 &lineDirection=TVector3(0., 0., 1.), bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state to the cylinder surface, and returns the extrapolation length and,...
virtual void setChargeSign(StateOnPlane &state, double charge) const override
Set the sign of the charge according to charge.
StateOnPlane lastEndState_
state where the last extrapolation has started
virtual void getBackwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const override
Get the jacobian and noise matrix of the last extrapolation if it would have been done in opposite di...
virtual double extrapolateToSphere(StateOnPlane &state, double radius, const TVector3 &point=TVector3(0., 0., 0.), bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state to the sphere surface, and returns the extrapolation length and,...
double Extrap(const DetPlane &startPlane, const DetPlane &destPlane, double charge, double mass, bool &isAtBoundary, M1x7 &state7, double &flightTime, bool fillExtrapSteps, TMatrixDSym *cov=nullptr, bool onlyOneStep=false, bool stopAtBoundary=false, double maxStep=1.E99) const
Handles propagation and material effects.
virtual void getPosMom(const StateOnPlane &state, TVector3 &pos, TVector3 &mom) const override
Get cartesian position and momentum vector of a state.
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const=0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and,...
virtual double getCharge(const StateOnPlane &state) const override
Get the (fitted) charge of a state.
virtual bool isSameType(const AbsTrackRep *other) override
check if other is of same type (e.g. RKTrackRep).
virtual void setPosMomCov(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) const override
Set position, momentum and covariance of state.
unsigned int cachePos_
use cached RKSteps_ for extrapolation
virtual double getQop(const StateOnPlane &state) const override
Get charge over momentum.
virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state to the POCA to a point, and returns the extrapolation length and,...
virtual TVector3 getPos(const StateOnPlane &state) const override
Get the cartesian position of a state.
virtual double RKPropagate(M1x7 &state7, M7x7 *jacobian, M1x3 &SA, double S, bool varField=true, bool calcOnlyLastRowOfJ=false) const
The actual Runge Kutta propagation.
virtual void getPosMomCov(const MeasuredStateOnPlane &state, TVector3 &pos, TVector3 &mom, TMatrixDSym &cov) const override
Translates MeasuredStateOnPlane into 3D position, momentum and 6x6 covariance.
virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point, const TMatrixDSym &G, bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state to the POCA to a point in the metric of G, and returns the extrapolation lengt...
virtual void getForwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const override
Get the jacobian and noise matrix of the last extrapolation.
virtual double extrapolateBy(StateOnPlane &state, double step, bool stopAtBoundary=false, bool calcJacobianNoise=false) const override
Extrapolates the state by step (cm) and returns the extrapolation length and, via reference,...
virtual void setPosMom(StateOnPlane &state, const TVector3 &pos, const TVector3 &mom) const override
Set position and momentum of state.
virtual void setQop(StateOnPlane &state, double qop) const override
Set charge/momentum.
A state with arbitrary dimension defined in a DetPlane.
Helper to store different limits on the stepsize for the RKTRackRep.
Defines for I/O streams used for error and debug printing.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Simple struct containing MaterialProperties and stepsize in the material.