Belle II Software development
Composite.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * External Contributor: Wouter Hulsbergen *
5 * *
6 * See git log for contributors and copyright holders. *
7 * This file is licensed under LGPL-3.0, see LICENSE.md. *
8 **************************************************************************/
9
10
11#include <analysis/VertexFitting/TreeFitter/Composite.h>
12#include <analysis/VertexFitting/TreeFitter/FitParams.h>
13
14#include <TMatrixFSym.h>
15#include <Math/Vector3D.h>
16
17namespace TreeFitter {
18
20 bool massConstraint)
21 : ParticleBase(particle, mother, &config), m_params(), m_hasEnergy(true), m_massconstraint(massConstraint)
22 {
24 }
25
27 {
28 return initTau(fitparams);
29 }
30
32 {
33 const int posindex = posIndex();
34 const int momindex = momIndex();
35
36 fitparams.getStateVector().segment(posindex, 3) = m_params.segment(0, 3);
37
38 fitparams.getStateVector().segment(momindex, 4) = m_params.segment(3, 4);
39
40 return ErrCode(ErrCode::Status::success) ;
41 }
42
44 {
45 const ROOT::Math::XYZVector pos = particle()->getVertex();
46 const ROOT::Math::XYZVector mom = particle()->getMomentum();
47 const double energy = particle()->getEnergy();
48
49 m_params = Eigen::Matrix<double, 7, 1>::Zero(7, 1);
50 m_params(0) = pos.X();
51 m_params(1) = pos.Y();
52 m_params(2) = pos.Z();
53 m_params(3) = mom.X();
54 m_params(4) = mom.Y();
55 m_params(5) = mom.Z();
56
57 m_params(6) = energy;
58
59 m_covariance = Eigen::Matrix < double, -1, -1, 0, 7, 7 >::Zero(7, 7);
60 const TMatrixFSym cov7in = particle()->getMomentumVertexErrorMatrix(); //this is (p,E,x)
61
62 for (int row = 0; row < 4; ++row) { //first the p,E block
63 for (int col = 0; col <= row; ++col) {
64 m_covariance(3 + row, 3 + col) = cov7in[row][col];
65 }
66 }
67
68 for (int row = 0; row < 3; ++row) { //then the x block
69 for (int col = 0; col <= row; ++col) {
70 m_covariance(row, col) = cov7in[4 + row][4 + col];
71 }
72 }
73 }
74
76 {
77 const int posindex = posIndex() ;
78 const int momindex = momIndex() ;
79
80 p.getResiduals().segment(0, 3) = m_params.segment(0, 3) - fitparams.getStateVector().segment(posindex, 3);
81
82 p.getResiduals().segment(3, 4) = m_params.segment(3, 4) - fitparams.getStateVector().segment(momindex, 4);
83
84 for (int row = 0; row < 3; ++row) {
85 p.getH()(row, posindex + row) = -1;
86 }
87
88 for (int row = 0; row < 4; ++row) {
89 p.getH()(3 + row, momindex + row) = -1;
90 }
91
92 p.getV().triangularView<Eigen::Lower>() = m_covariance.triangularView<Eigen::Lower>();
93
94 return ErrCode(ErrCode::Status::success) ;
95 }
96
98 {
99 ErrCode status;
100 switch (type) {
101 case Constraint::mass:
102 status |= projectMassConstraint(fitparams, p);
103 break;
104 case Constraint::composite:
105 status |= projectComposite(fitparams, p);
106 break ;
107 case Constraint::geometric:
108 status |= projectGeoConstraint(fitparams, p);
109 break ;
110 default:
111 status |= ParticleBase::projectConstraint(type, fitparams, p);
112 }
113 return status ;
114 }
115
116}
Class to store reconstructed particles.
Definition: Particle.h:75
double getEnergy() const
Returns total energy.
Definition: Particle.h:535
ROOT::Math::XYZVector getVertex() const
Returns vertex position (POCA for charged, IP for neutral FS particles)
Definition: Particle.h:631
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
Definition: Particle.h:560
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:420
Composite(Belle2::Particle *bc, const ParticleBase *mother, const ConstraintConfiguration &config, bool massconstraint=false)
constructor
Definition: Composite.cc:19
void updateParams()
update changed params
Definition: Composite.cc:43
virtual ErrCode projectConstraint(Constraint::Type, const FitParams &, Projection &) const override
project this constraint
Definition: Composite.cc:97
Eigen::Matrix< double, 7, 1 > m_params
column vector to store the measurement
Definition: Composite.h:82
virtual int momIndex() const override
get momentum index in statevector
Definition: Composite.h:61
Eigen::Matrix< double, -1, -1, 0, 7, 7 > m_covariance
only lower triangle filled!
Definition: Composite.h:85
virtual int type() const override
get ype
Definition: Composite.h:52
virtual ErrCode initParticleWithMother(FitParams &fitparams) override
init particle in case it has a mother
Definition: Composite.cc:26
virtual ErrCode initMotherlessParticle(FitParams &fitparams) override
init particle in case it has no mother
Definition: Composite.cc:31
ErrCode projectComposite(const FitParams &fitparams, Projection &p) const
project this particle constraint
Definition: Composite.cc:75
virtual int posIndex() const override
get position index in statevectof x,y,z,tau,px,py,pz
Definition: Composite.h:55
constraint configuration class
Type
type of constraints the order of these constraints is important: it is the order in which they are ap...
Definition: Constraint.h:27
abstract errorocode be aware that the default is success
Definition: ErrCode.h:14
Class to store and manage fitparams (statevector)
Definition: FitParams.h:20
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector()
getter for the fit parameters/statevector
Definition: FitParams.h:65
base class for all particles
Definition: ParticleBase.h:25
Belle2::Particle * particle() const
get basf2 particle
Definition: ParticleBase.h:92
ErrCode initTau(FitParams &par) const
initialises tau as a length
virtual ErrCode projectMassConstraint(const FitParams &, Projection &) const
project mass constraint abstract
virtual ErrCode projectConstraint(Constraint::Type, const FitParams &, Projection &) const
project constraint.
virtual ErrCode projectGeoConstraint(const FitParams &, Projection &) const
project geometrical constraint
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
Definition: Projection.h:18