10 #include <framework/logging/Logger.h>
12 #include <analysis/dataobjects/Particle.h>
13 #include <mdst/dataobjects/KLMCluster.h>
15 #include <analysis/VertexFitting/TreeFitter/RecoKlong.h>
16 #include <analysis/VertexFitting/TreeFitter/FitParams.h>
17 #include <analysis/VertexFitting/TreeFitter/ErrCode.h>
19 namespace TreeFitter {
36 Eigen::Matrix<double, 1, 3> vertexToCluster = Eigen::Matrix<double, 1, 3>::Zero(1, 3);
37 for (
unsigned int i = 0; i < 3; ++i) {
41 const double distanceToMother = vertexToCluster.norm();
43 const double energy2 = energy * energy;
45 const double absMom = -1 * std::sqrt(energy2 - pdgMass2);
49 for (
unsigned int i = 0; i < 3; ++i) {
51 fitparams.
getStateVector()(momindex + i) = absMom * vertexToCluster(i) / distanceToMother;
56 return ErrCode(ErrCode::Status::success);
61 return ErrCode(ErrCode::Status::success);
70 const double factorX = 1000;
73 Eigen::Matrix<double, 4, 4>::Identity(4, 4) * factorE;
76 Eigen::Matrix<double, 3, 3>::Identity(3, 3) * factorX;
78 return ErrCode(ErrCode::Status::success);
85 const TVector3 cluster_pos = cluster->getClusterPosition();
90 TMatrixDSym cov7 = cluster->getError7x7();
92 for (
int row = 0; row < 3; ++row) {
93 for (
int col = 0; col < 3; ++col) {
107 cluster->getMomentumMag());
111 if ((std::abs(p_vec(0)) >= std::abs(p_vec(1))) && (std::abs(p_vec(0)) >= std::abs(p_vec(2)))) {
113 }
else if ((std::abs(p_vec(1)) >= std::abs(p_vec(0))) && (std::abs(p_vec(1)) >= std::abs(p_vec(2)))) {
115 }
else if ((std::abs(p_vec(2)) >= std::abs(p_vec(1))) && (std::abs(p_vec(2)) >= std::abs(p_vec(0)))) {
118 B2ERROR(
"Could not estimate highest momentum for Klong constraint. Aborting this fit.\n px: "
119 << p_vec(0) <<
" py: " << p_vec(1) <<
" pz: " << p_vec(2) <<
" calculated from Ec: " <<
m_clusterPars(3));
120 return ErrCode(ErrCode::Status::photondimerror);
123 return ErrCode(ErrCode::Status::success);
131 const Eigen::Matrix<double, 1, 3> x_vertex = fitparams.
getStateVector().segment(posindex, 3);
132 const Eigen::Matrix<double, 1, 3> p_vec = fitparams.
getStateVector().segment(momindex, 3);
134 if (0 == p_vec[
m_i1]) {
return ErrCode(ErrCode::Status::klongdimerror); }
138 const double mom = p_vec.norm();
142 Eigen::Matrix<double, 3, 1> residual3 = Eigen::Matrix<double, 3, 1>::Zero(3, 1);
147 Eigen::Matrix<double, 3, 4> P = Eigen::Matrix<double, 3, 4>::Zero(3, 4);
157 p.getResiduals().segment(0, 3) = residual3;
159 p.getV() = P *
m_covariance.selfadjointView<Eigen::Lower>() * P.transpose();
163 p.getH()(0, posindex +
m_i1) = p_vec[
m_i2] / p_vec[
m_i1];
164 p.getH()(0, posindex +
m_i2) = -1.0;
165 p.getH()(0, posindex +
m_i3) = 0;
167 p.getH()(1, posindex +
m_i1) = p_vec[
m_i3] / p_vec[
m_i1];
168 p.getH()(1, posindex +
m_i2) = 0;
169 p.getH()(1, posindex +
m_i3) = -1.0;
171 p.getH()(0, momindex +
m_i1) = p_vec[
m_i2] * elim / p_vec[
m_i1];
172 p.getH()(0, momindex +
m_i2) = -1. * elim;
173 p.getH()(0, momindex +
m_i3) = 0;
175 p.getH()(1, momindex +
m_i1) = p_vec[
m_i3] * elim / p_vec[
m_i1];;
176 p.getH()(1, momindex +
m_i2) = 0;
177 p.getH()(1, momindex +
m_i3) = -1. * elim;
179 p.getH()(2, momindex +
m_i1) = -1. * p_vec[
m_i1] / mom;
180 p.getH()(2, momindex +
m_i2) = -1. * p_vec[
m_i2] / mom;
181 p.getH()(2, momindex +
m_i3) = -1. * p_vec[
m_i3] / mom;
182 p.getH()(2, momindex + 3) = -1;
184 return ErrCode(ErrCode::Status::success);
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...
TVector3 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