10 #include <framework/logging/Logger.h>
12 #include <analysis/dataobjects/Particle.h>
13 #include <mdst/dataobjects/ECLCluster.h>
15 #include <analysis/ClusterUtility/ClusterUtils.h>
17 #include <analysis/VertexFitting/TreeFitter/RecoPhoton.h>
18 #include <analysis/VertexFitting/TreeFitter/FitParams.h>
19 #include <analysis/VertexFitting/TreeFitter/ErrCode.h>
21 #include <framework/gearbox/Const.h>
23 namespace TreeFitter {
29 m_useEnergy(useEnergy(*particle)),
32 m_momentumScalingFactor(particle->getMomentumScalingFactor())
41 Eigen::Matrix<double, 1, 3> vertexToCluster = Eigen::Matrix<double, 1, 3>::Zero(1, 3);
42 for (
unsigned int i = 0; i < 3; ++i) {
46 const double distanceToMother = vertexToCluster.norm();
50 for (
unsigned int i = 0; i < 3; ++i) {
52 fitparams.
getStateVector()(momindex + i) = energy * vertexToCluster(i) / distanceToMother;
55 return ErrCode(ErrCode::Status::success);
60 return ErrCode(ErrCode::Status::success);
81 const double factorX = 1000;
84 Eigen::Matrix<double, 4, 4>::Identity(4, 4) * factorE;
87 Eigen::Matrix<double, 3, 3>::Identity(3, 3) * factorX;
89 return ErrCode(ErrCode::Status::success);
96 const TVector3 centroid = cluster->getClusterPosition();
97 const double energy = cluster->getEnergy(clusterhypo);
103 TMatrixDSym cov_EPhiTheta = cluster->getCovarianceMatrix3x3();
105 Eigen::Matrix<double, 2, 2> covPhiTheta = Eigen::Matrix<double, 2, 2>::Zero(2, 2);
107 for (
int row = 0; row < 2; ++row) {
108 for (
int col = 0; col < 2; ++col) {
109 covPhiTheta(row, col) = cov_EPhiTheta[row + 1][col + 1];
114 const double R = cluster->getR();
115 const double theta = cluster->getPhi();
116 const double phi = cluster->getTheta();
118 const double st = std::sin(theta);
119 const double ct = std::cos(theta);
120 const double sp = std::sin(phi);
121 const double cp = std::cos(phi);
123 Eigen::Matrix<double, 2, 3> polarToCartesian = Eigen::Matrix<double, 2, 3>::Zero(2, 3);
126 polarToCartesian(0, 0) = -1. * R * st * sp;
127 polarToCartesian(0, 1) = R * st * cp;
128 polarToCartesian(0, 2) = 0 ;
130 polarToCartesian(1, 0) = R * ct * cp;
131 polarToCartesian(1, 1) = R * ct * sp;
132 polarToCartesian(1, 2) = -1. * R * st ;
134 m_covariance.block<3, 3>(0, 0) = polarToCartesian.transpose() * covPhiTheta * polarToCartesian;
145 if ((std::abs(p_vec(0)) >= std::abs(p_vec(1))) && (std::abs(p_vec(0)) >= std::abs(p_vec(2)))) {
147 }
else if ((std::abs(p_vec(1)) >= std::abs(p_vec(0))) && (std::abs(p_vec(1)) >= std::abs(p_vec(2)))) {
149 }
else if ((std::abs(p_vec(2)) >= std::abs(p_vec(1))) && (std::abs(p_vec(2)) >= std::abs(p_vec(0)))) {
152 B2ERROR(
"Could not estimate highest momentum for photon constraint. Aborting this fit.\n px: "
153 << p_vec(0) <<
" py: " << p_vec(1) <<
" pz: " << p_vec(2) <<
" calculated from Ec: " <<
m_clusterPars(3));
154 return ErrCode(ErrCode::Status::photondimerror);
158 return ErrCode(ErrCode::Status::success);
181 const Eigen::Matrix<double, 1, 3> x_vertex = fitparams.
getStateVector().segment(posindex, 3);
182 const Eigen::Matrix<double, 1, 3> p_vec = fitparams.
getStateVector().segment(momindex, 3);
184 if (0 == p_vec[
m_i1]) {
return ErrCode(ErrCode::photondimerror); }
188 const double mom = p_vec.norm();
191 Eigen::Matrix<double, 3, 1> residual3 = Eigen::Matrix<double, 3, 1>::Zero(3, 1);
197 Eigen::Matrix<double, 3, 4> P = Eigen::Matrix<double, 3, 4>::Zero(3, 4);
206 p.getResiduals().segment(0, 3) = residual3;
208 p.getV() = P *
m_covariance.selfadjointView<Eigen::Lower>() * P.transpose();
212 p.getH()(0, posindex +
m_i1) = p_vec[
m_i2] / p_vec[
m_i1];
213 p.getH()(0, posindex +
m_i2) = -1.0;
214 p.getH()(0, posindex +
m_i3) = 0;
216 p.getH()(1, posindex +
m_i1) = p_vec[
m_i3] / p_vec[
m_i1];
217 p.getH()(1, posindex +
m_i2) = 0;
218 p.getH()(1, posindex +
m_i3) = -1.0;
221 p.getH()(0, momindex +
m_i1) = p_vec[
m_i2] * elim / p_vec[
m_i1];
222 p.getH()(0, momindex +
m_i2) = -1. * elim;
223 p.getH()(0, momindex +
m_i3) = 0;
225 p.getH()(1, momindex +
m_i1) = p_vec[
m_i3] * elim / p_vec[
m_i1];
226 p.getH()(1, momindex +
m_i2) = 0;
227 p.getH()(1, momindex +
m_i3) = -1. * elim;
229 p.getH()(2, momindex +
m_i1) = -1. * p_vec[
m_i1] / mom;
230 p.getH()(2, momindex +
m_i2) = -1. * p_vec[
m_i2] / mom;
231 p.getH()(2, momindex +
m_i3) = -1. * p_vec[
m_i3] / mom;
235 return ErrCode(ErrCode::Status::success);
Class to provide momentum-related information from ECLClusters.
The ParticleType class for identifying different particle types.
static const ParticleType pi0
neutral pion particle
static const ParticleType photon
photon particle
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
Class to store reconstructed particles.
const ECLCluster * getECLCluster() const
Returns the pointer to the ECLCluster object that was used to create this Particle (if ParticleType =...
TVector3 getMomentum() const
Returns momentum vector.
int getPDGCode(void) const
Returns PDG code.
ECLCluster::EHypothesisBit getECLClusterEHypothesisBit() const
Returns the ECLCluster EHypothesisBit for this Particle.
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()
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
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
RecoPhoton(Belle2::Particle *bc, const ParticleBase *mother)
constructor
ErrCode initParams()
update or init params
const float m_momentumScalingFactor
scale the momentum / energy by this correction factor
int m_i3
another random index
int m_i1
index with the highest momentum.
virtual ErrCode initParticleWithMother(FitParams &fitparams) override
init particle with mother
static bool useEnergy(const Belle2::Particle &cand)
has energy in fit params?
int m_i2
random other index
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 photon constraint
Eigen::Matrix< double, 1, 4 > m_clusterPars
constrains measured params (x_c, y_c, z_c, E_c)