10#include <analysis/VertexFitting/TreeFitter/RecoTrack.h>
11#include <analysis/VertexFitting/TreeFitter/FitParams.h>
12#include <analysis/VertexFitting/TreeFitter/HelixUtils.h>
14#include <framework/gearbox/Const.h>
15#include <mdst/dataobjects/Track.h>
20 constexpr double pi = TMath::Pi();
21 constexpr double twoPi = TMath::TwoPi();
26 m_trackfit(particle->getTrackFitResult()),
31 m_momentumScalingFactor(particle->getEffectiveMomentumScale())
48 return ErrCode(ErrCode::Status::success);
53 return ErrCode(ErrCode::Status::success);
62 for (
int row = 0; row < 3; ++row) {
63 fitparams.
getCovariance()(momindex + row, momindex + row) = 1000 * p4Err[row][row];
66 return ErrCode(ErrCode::Status::success);
76 return ErrCode(ErrCode::Status::success);
83 for (
unsigned int i = 0; i < trackParameter.size(); ++i) {
88 for (
int row = 0; row < 5; ++row) {
89 for (
int col = 0; col <= row; ++col) {
95 return ErrCode(ErrCode::Status::success);
104 Eigen::Matrix<double, 1, 6> positionAndMom = Eigen::Matrix<double, 1, 6>::Zero(1, 6);
105 positionAndMom.segment(0, 3) = fitparams.
getStateVector().segment(posindexmother, 3);
106 positionAndMom.segment(3, 3) = fitparams.
getStateVector().segment(momindex, 3);
107 Eigen::Matrix<double, 5, 6> jacobian = Eigen::Matrix<double, 5, 6>::Zero(5, 6);
110 ROOT::Math::XYZVector(positionAndMom(3), positionAndMom(4), positionAndMom(5)),
124 auto* nonconst =
const_cast<RecoTrack*
>(
this);
126 nonconst->updateParams(
m_flt);
129 Eigen::Matrix<double, 1, 5> helixpars(5);
130 helixpars(0) = helix.getD0();
131 helixpars(1) = helix.getPhi0();
132 helixpars(2) = helix.getOmega();
133 helixpars(3) = helix.getZ0();
134 helixpars(4) = helix.getTanLambda();
136 p.getResiduals().segment(0, 5) =
m_params - helixpars;
139 double phiResidual = p.getResiduals().segment(0, 5)(1);
140 phiResidual = std::fmod(phiResidual + pi, twoPi);
141 if (phiResidual < 0) phiResidual += twoPi;
143 p.getResiduals().segment(0, 5)(1) = phiResidual;
145 p.getV().triangularView<Eigen::Lower>() =
m_covariance.triangularView<Eigen::Lower>();
147 p.getH().block<5, 3>(0, posindexmother) = -1.0 * jacobian.block<5, 3>(0, 0);
148 p.getH().block<5, 3>(0, momindex) = -1.0 * jacobian.block<5, 3>(0, 3);
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
Class to store reconstructed particles.
TMatrixFSym getMomentumErrorMatrix() const
Returns the 4x4 momentum error matrix.
Helix getHelix() const
Conversion to framework Helix (without covariance).
TMatrixDSym getCovariance5() const
Getter for covariance matrix of perigee parameters in matrix form.
std::vector< float > getTau() const
Getter for all perigee parameters.
abstract errorocode be aware that the default is success
Class to store and manage fitparams (statevector)
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector()
getter for the fit parameters/statevector
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance()
getter for the states covariance
static void getJacobianToCartesianFrameworkHelix(Eigen::Matrix< double, 5, 6 > &jacobian, const double x, const double y, const double z, const double px, const double py, const double pz, const double bfield, const double charge)
get the jacobian dh={helix pars}/dx={x,y,z,px,py,pz} for the implementation of the framework helix.
base class for all particles
Belle2::Particle * particle() const
get basf2 particle
virtual int posIndex() const
get vertex index (in statevector!)
int charge() const
get charge
const ParticleBase * mother() const
getMother() / hasMother()
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
base for RecoPhoton RecoTrack
virtual int momIndex() const override
get momentum index
representation of all charged final states FIXME rename since this name is taken in tracking
ErrCode initCovariance(FitParams &fitparams) const override
init covariance matrix of this particle constraint
const Belle2::TrackFitResult * m_trackfit
trackfit result from reconstruction
Eigen::Matrix< double, 1, 5 > m_params
column vector to store the measurement
const float m_momentumScalingFactor
scale the momenta by this correction factor
virtual ErrCode projectRecoConstraint(const FitParams &, Projection &) const override
project the constraint (calculate residuals)
ErrCode updateParams(double flt)
updated the cached parameters
virtual ErrCode initParticleWithMother(FitParams &fitparams) override
init with mother particle (replacing initPar2)
double m_bfield
B field along z
virtual ErrCode initMotherlessParticle(FitParams &fitparams) override
init without mother particle
ErrCode updFltToMother(const FitParams &fitparams)
update flight length to mother
double m_flt
helix arc length at vertex
Eigen::Matrix< double, 5, 5 > m_covariance
only lower triangle filled!
bool m_cached
flag to mark the particle as initialised
RecoTrack(Belle2::Particle *bc, const ParticleBase *mother)
constructor