10#include <framework/logging/Logger.h>
11#include <framework/geometry/B2Vector3.h>
13#include <analysis/dataobjects/Particle.h>
14#include <mdst/dataobjects/KLMCluster.h>
16#include <analysis/VertexFitting/TreeFitter/RecoKlong.h>
17#include <analysis/VertexFitting/TreeFitter/FitParams.h>
18#include <analysis/VertexFitting/TreeFitter/ErrCode.h>
37 Eigen::Matrix<double, 1, 3> vertexToCluster = Eigen::Matrix<double, 1, 3>::Zero(1, 3);
38 for (
unsigned int i = 0; i < 3; ++i) {
42 const double distanceToMother = vertexToCluster.norm();
45 const double absMom = std::sqrt(energy * energy - pdgMass * pdgMass);
49 for (
unsigned int i = 0; i < 3; ++i) {
51 fitparams.
getStateVector()(momindex + i) = absMom * vertexToCluster(i) / distanceToMother;
54 return ErrCode(ErrCode::Status::success);
59 return ErrCode(ErrCode::Status::success);
68 const double factorX = 1000;
71 Eigen::Matrix<double, 4, 4>::Identity(4, 4) * factorE;
74 Eigen::Matrix<double, 3, 3>::Identity(3, 3) * factorX;
76 return ErrCode(ErrCode::Status::success);
88 TMatrixDSym cov7 = cluster->getError7x7();
90 for (
int row = 0; row < 3; ++row) {
91 for (
int col = 0; col < 3; ++col) {
105 cluster->getMomentumMag() * cluster->getMomentumMag());
109 if ((std::abs(p_vec.X()) >= std::abs(p_vec.Y())) && (std::abs(p_vec.X()) >= std::abs(p_vec.Z()))) {
111 }
else if ((std::abs(p_vec.Y()) >= std::abs(p_vec.X())) && (std::abs(p_vec.Y()) >= std::abs(p_vec.Z()))) {
113 }
else if ((std::abs(p_vec.Z()) >= std::abs(p_vec.Y())) && (std::abs(p_vec.Z()) >= std::abs(p_vec.X()))) {
116 B2ERROR(
"Could not estimate highest momentum for Klong constraint. Aborting this fit.\n px: "
117 << p_vec.X() <<
" py: " << p_vec.Y() <<
" pz: " << p_vec.Z() <<
" calculated from Ec: " <<
m_clusterPars(3));
118 return ErrCode(ErrCode::Status::photondimerror);
121 return ErrCode(ErrCode::Status::success);
129 const Eigen::Matrix<double, 1, 3> x_vertex = fitparams.
getStateVector().segment(posindex, 3);
130 const Eigen::Matrix<double, 1, 3> p_vec = fitparams.
getStateVector().segment(momindex, 3);
132 if (0 == p_vec[
m_i1]) {
return ErrCode(ErrCode::Status::klongdimerror); }
136 const double mom = p_vec.norm();
138 const double energy = std::sqrt(mom * mom + pdgMass * pdgMass);
141 Eigen::Matrix<double, 3, 1> residual3 = Eigen::Matrix<double, 3, 1>::Zero(3, 1);
146 Eigen::Matrix<double, 3, 4> P = Eigen::Matrix<double, 3, 4>::Zero(3, 4);
156 p.getResiduals().segment(0, 3) = residual3;
158 p.getV() = P *
m_covariance.selfadjointView<Eigen::Lower>() * P.transpose();
162 p.getH()(0, posindex +
m_i1) = p_vec[
m_i2] / p_vec[
m_i1];
163 p.getH()(0, posindex +
m_i2) = -1.0;
164 p.getH()(0, posindex +
m_i3) = 0;
166 p.getH()(1, posindex +
m_i1) = p_vec[
m_i3] / p_vec[
m_i1];
167 p.getH()(1, posindex +
m_i2) = 0;
168 p.getH()(1, posindex +
m_i3) = -1.0;
170 p.getH()(0, momindex +
m_i1) = p_vec[
m_i2] * elim / p_vec[
m_i1];
171 p.getH()(0, momindex +
m_i2) = -1. * elim;
172 p.getH()(0, momindex +
m_i3) = 0;
174 p.getH()(1, momindex +
m_i1) = p_vec[
m_i3] * elim / p_vec[
m_i1];;
175 p.getH()(1, momindex +
m_i2) = 0;
176 p.getH()(1, momindex +
m_i3) = -1. * elim;
178 p.getH()(2, momindex +
m_i1) = -1. * p_vec[
m_i1] / mom;
179 p.getH()(2, momindex +
m_i2) = -1. * p_vec[
m_i2] / mom;
180 p.getH()(2, momindex +
m_i3) = -1. * p_vec[
m_i3] / mom;
182 return ErrCode(ErrCode::Status::success);
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType X() const
access variable X (= .at(0) without boundary check)
DataType Y() const
access variable Y (= .at(1) without boundary check)
Class to store reconstructed particles.
const KLMCluster * getKLMCluster() const
Returns the pointer to the KLMCluster object that was used to create this Particle (ParticleType == c...
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
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
base class for all particles
Belle2::Particle * particle() const
get basf2 particle
virtual int posIndex() const
get vertex index (in statevector!)
const ParticleBase * mother() const
getMother() / hasMother()
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
Eigen::Matrix< double, 4, 4 > m_covariance
covariance (x_c,y_c,z_c,E_c) of measured pars
ErrCode initCovariance(FitParams &fitparams) const override
init covariance
ErrCode initParams()
update or init params
int m_i3
another random index
int m_i1
index with the highest momentum.
virtual ErrCode initParticleWithMother(FitParams &fitparams) override
init particle with mother
RecoKlong(Belle2::Particle *bc, const ParticleBase *mother)
constructor
virtual ErrCode initMotherlessParticle(FitParams &fitparams) override
init particle without mother
bool m_init
was initialized*
ErrCode projectRecoConstraint(const FitParams &fitparams, Projection &p) const override
project klong constraint
Eigen::Matrix< double, 1, 4 > m_clusterPars
constrains measured params (x_c, y_c, z_c, E_c)
base for RecoPhoton RecoTrack
virtual int momIndex() const override
get momentum index