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>
20 namespace TreeFitter {
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();
44 const double energy2 = energy * energy;
46 const double absMom = -1 * std::sqrt(energy2 - pdgMass2);
50 for (
unsigned int i = 0; i < 3; ++i) {
52 fitparams.
getStateVector()(momindex + i) = absMom * vertexToCluster(i) / distanceToMother;
57 return ErrCode(ErrCode::Status::success);
62 return ErrCode(ErrCode::Status::success);
71 const double factorX = 1000;
74 Eigen::Matrix<double, 4, 4>::Identity(4, 4) * factorE;
77 Eigen::Matrix<double, 3, 3>::Identity(3, 3) * factorX;
79 return ErrCode(ErrCode::Status::success);
91 TMatrixDSym cov7 = cluster->getError7x7();
93 for (
int row = 0; row < 3; ++row) {
94 for (
int col = 0; col < 3; ++col) {
108 cluster->getMomentumMag());
112 if ((std::abs(p_vec.x()) >= std::abs(p_vec.y())) && (std::abs(p_vec.x()) >= std::abs(p_vec.z()))) {
114 }
else if ((std::abs(p_vec.y()) >= std::abs(p_vec.x())) && (std::abs(p_vec.y()) >= std::abs(p_vec.z()))) {
116 }
else if ((std::abs(p_vec.z()) >= std::abs(p_vec.y())) && (std::abs(p_vec.z()) >= std::abs(p_vec.x()))) {
119 B2ERROR(
"Could not estimate highest momentum for Klong constraint. Aborting this fit.\n px: "
120 << p_vec.x() <<
" py: " << p_vec.y() <<
" pz: " << p_vec.z() <<
" calculated from Ec: " <<
m_clusterPars(3));
121 return ErrCode(ErrCode::Status::photondimerror);
124 return ErrCode(ErrCode::Status::success);
132 const Eigen::Matrix<double, 1, 3> x_vertex = fitparams.
getStateVector().segment(posindex, 3);
133 const Eigen::Matrix<double, 1, 3> p_vec = fitparams.
getStateVector().segment(momindex, 3);
135 if (0 == p_vec[
m_i1]) {
return ErrCode(ErrCode::Status::klongdimerror); }
139 const double mom = p_vec.norm();
143 Eigen::Matrix<double, 3, 1> residual3 = Eigen::Matrix<double, 3, 1>::Zero(3, 1);
148 Eigen::Matrix<double, 3, 4> P = Eigen::Matrix<double, 3, 4>::Zero(3, 4);
158 p.getResiduals().segment(0, 3) = residual3;
160 p.getV() = P *
m_covariance.selfadjointView<Eigen::Lower>() * P.transpose();
164 p.getH()(0, posindex +
m_i1) = p_vec[
m_i2] / p_vec[
m_i1];
165 p.getH()(0, posindex +
m_i2) = -1.0;
166 p.getH()(0, posindex +
m_i3) = 0;
168 p.getH()(1, posindex +
m_i1) = p_vec[
m_i3] / p_vec[
m_i1];
169 p.getH()(1, posindex +
m_i2) = 0;
170 p.getH()(1, posindex +
m_i3) = -1.0;
172 p.getH()(0, momindex +
m_i1) = p_vec[
m_i2] * elim / p_vec[
m_i1];
173 p.getH()(0, momindex +
m_i2) = -1. * elim;
174 p.getH()(0, momindex +
m_i3) = 0;
176 p.getH()(1, momindex +
m_i1) = p_vec[
m_i3] * elim / p_vec[
m_i1];;
177 p.getH()(1, momindex +
m_i2) = 0;
178 p.getH()(1, momindex +
m_i3) = -1. * elim;
180 p.getH()(2, momindex +
m_i1) = -1. * p_vec[
m_i1] / mom;
181 p.getH()(2, momindex +
m_i2) = -1. * p_vec[
m_i2] / mom;
182 p.getH()(2, momindex +
m_i3) = -1. * p_vec[
m_i3] / mom;
183 p.getH()(2, momindex + 3) = -1;
185 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...
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, MAX_MATRIX_SIZE > & getCovariance()
getter for the states covariance
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector()
getter for the fit parameters/statevector
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()
double pdgMass() const
get pdg mass
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