Belle II Software development
ParticleKinematicFitterModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12#include <string>
13#include <analysis/DecayDescriptor/DecayDescriptor.h>
14
15// OrcaKinFit
16#include <analysis/OrcaKinFit/BaseFitter.h>
17#include <analysis/OrcaKinFit/TextTracer.h>
18
19// Constraints
20#include <analysis/OrcaKinFit/MomentumConstraint.h>
21#include <analysis/OrcaKinFit/RecoilMassConstraint.h>
22#include <analysis/OrcaKinFit/MassConstraint.h>
23
24// Fitobjects
25#include <analysis/OrcaKinFit/ParticleFitObject.h>
26
27// analysis dataobjects
28#include <framework/dataobjects/EventExtraInfo.h>
29#include <analysis/dataobjects/ParticleList.h>
30
31// framework datastore
32#include <framework/datastore/StoreObjPtr.h>
33
34// ROOT
35#include <Math/Vector4D.h>
36#include <TMatrixFSym.h>
37
38// CLHEOP
39#include <CLHEP/Matrix/SymMatrix.h>
40#include <CLHEP/Vector/LorentzVector.h>
41
42namespace Belle2 {
47 class Particle;
48 namespace OrcaKinFit {
49
54
55 public:
56
61
66 virtual void initialize() override;
67
71 virtual void terminate() override;
72
76 virtual void event() override;
77
78 private:
79
80 // module parameters
81 std::string m_listName;
82 std::string m_kinematicFitter;
83 std::string m_orcaFitterEngine;
84 std::string m_orcaTracer;
85 std::string m_orcaConstraint;
95 double m_recoilMass;
96 double m_invMass;
98 // internal variables
101 std::vector <double> m_unmeasuredLeptonFitObject;
102 std::vector <double> m_unmeasuredGammaFitObject;
105 // hard constraints
115 // UNUSED YET
116 std::string m_decayString;
124 bool doKinematicFit(Particle* p);
125
131 bool doOrcaKinFitFit(Particle* p);
132
136 bool fillFitParticles(Particle* mother, std::vector<Particle*>& particleChildren);
137
142 bool AddFour(Particle* mother);
143
150 void addParticleToOrcaKinFit(BaseFitter& fitter, Particle* particle, const int index);
151
157
163
168 void addTracerToFitter(BaseFitter& fitter);
169
173 void setConstraints();
174
178 ROOT::Math::PxPyPzEVector getLorentzVectorConstraints();
179
180
185 void resetFitter(BaseFitter& fitter);
186
193
200 void updateOrcaKinFitMother(BaseFitter& fitter, std::vector<Particle*>& particleChildren, Particle* mother);
201
202
208 bool updateOrcaKinFitDaughters(BaseFitter& fitter, Particle* mother);
209
218 void updateMapOfTrackAndDaughter(unsigned& l, std::vector<std::vector<unsigned>>& pars, std::vector<unsigned>& pard,
219 std::vector<Particle*>& allparticles, const Particle* daughter);
220
228 bool storeOrcaKinFitParticles(const std::string& prefix, BaseFitter& fitter, std::vector<Particle*>& particleChildren,
229 Particle* mother);
230
231
236 CLHEP::HepSymMatrix getCLHEPMomentumErrorMatrix(Particle* particle);
237
242 CLHEP::HepSymMatrix getCLHEPMomentumVertexErrorMatrix(Particle* particle);
243
248 CLHEP::HepLorentzVector getCLHEPLorentzVector(Particle* particle);
249
254 ROOT::Math::PxPyPzEVector getLorentzVector(ParticleFitObject* fitobject);
255
261 float getFitObjectError(ParticleFitObject* fitobject, int ilocal);
262
267 TMatrixFSym getFitObjectCovMat(ParticleFitObject* fitobject);
268
273 TMatrixFSym getCovMat7(ParticleFitObject* fitobject);
274
279
284
285 };
286
287 }// end OrcaKinFit namespace
289} // Belle2 namespace
290
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Base class for Modules.
Definition: Module.h:72
Abstract base class for fitting engines of kinematic fits.
Definition: BaseFitter.h:47
Implements constraint 0 = mass1 - mass2 - m.
Implements a constraint of the form efact*sum(E)+pxfact*sum(px)+pyfact*sum(py)+pzfact*sum(pz)=value.
bool fillFitParticles(Particle *mother, std::vector< Particle * > &particleChildren)
Fills valid particle's children (with valid error matrix) in the vector of Particles that will enter ...
void addFitObjectToConstraints(ParticleFitObject &fitobject)
Adds Orca fit object to the constraints.
void updateMapOfTrackAndDaughter(unsigned &l, std::vector< std::vector< unsigned > > &pars, std::vector< unsigned > &pard, std::vector< Particle * > &allparticles, const Particle *daughter)
update the map of daughter and tracks, find out which tracks belong to each daughter.
bool m_liftPhotonTheta
lift theta constraint of the 3CPhoton.
std::vector< double > m_unmeasuredLeptonFitObject
unmeasured fit object
bool AddFour(Particle *mother)
Added four vectors and calculated a covariance matrix for a combined particles.
std::string m_orcaConstraint
Constraint (softBeam, hardBeam (default))
int m_debugFitterLevel
internal debugging level (for New and Newton fitter only)
virtual void initialize() override
Initialize the Module.
CLHEP::HepSymMatrix getCLHEPMomentumVertexErrorMatrix(Particle *particle)
Returns particle's 7x7 momentum-vertex-error matrix as a HepSymMatrix.
MomentumConstraint m_hardConstraintE
hard beam constraint E
bool m_debugFitter
activate internal debugging (for New and Newton fitter only)
void addUnmeasuredGammaToOrcaKinFit(BaseFitter &fitter)
Adds an unmeasured gamma (E, phi, theta) to the fit (-3C) stored as EventExtraInfo TODO.
MomentumConstraint m_hardConstraintPz
hard beam constraint pz
float getFitObjectError(ParticleFitObject *fitobject, int ilocal)
Returns fit object error on the parameter ilocal.
ROOT::Math::PxPyPzEVector getLorentzVectorConstraints()
Get constraints (at whatever stage before/after fitting)
bool doOrcaKinFitFit(Particle *p)
Kinematic fit using OrcaKinFit.
bool m_add3CPhoton
add one photon with unmeasured energy to the fit (costs 1 constraints)
TMatrixFSym getTMatrixFSymMomentumErrorMatrix()
Returns particle's 7x7 momentum-error matrix as a TMatrixFSym.
std::vector< double > m_unmeasuredGammaFitObject
unmeasured fit object
void addConstraintsToFitter(BaseFitter &fitter)
Adds Orca fit object to the constraints.
void addTracerToFitter(BaseFitter &fitter)
Adds tracer to the fitter.
RecoilMassConstraint m_hardConstraintRecoilMass
hard recoil mass constraint
TMatrixFSym getTMatrixFSymMomentumVertexErrorMatrix()
Returns particle's 7x7 momentum-vertex-error matrix as a TMatrixFSym.
StoreObjPtr< EventExtraInfo > m_eventextrainfo
StoreObjPtr for the EventExtraInfo in this mode.
MomentumConstraint m_hardConstraintPy
hard beam constraint py
double m_recoilMass
Recoil mass for RecoilMass constraint.
CLHEP::HepLorentzVector getCLHEPLorentzVector(Particle *particle)
Returns particle's 4-momentum as a HepLorentzVector.
TextTracer * m_textTracer
internal text output variable
DecayDescriptor m_decaydescriptor
Decay descriptor of decays to look for.
TMatrixFSym getCovMat7(ParticleFitObject *fitobject)
Returns covariance matrix.
ROOT::Math::PxPyPzEVector getLorentzVector(ParticleFitObject *fitobject)
bool updateOrcaKinFitDaughters(BaseFitter &fitter, Particle *mother)
Update the daughters: momentum is sum of daughters TODO update covariance matrix.
void setConstraints()
Sets constraints, this is not connect to particles or a fitter at this stage.
bool m_addUnmeasuredPhoton
add one unmeasured photon to the fit (costs 3 constraints)
TMatrixFSym getFitObjectCovMat(ParticleFitObject *fitobject)
Returns covariance matrix.
CLHEP::HepSymMatrix getCLHEPMomentumErrorMatrix(Particle *particle)
Returns particle's 4x4 momentum-error matrix as a HepSymMatrix.
double m_invMass
Invariant mass for Mass constraint.
bool m_fixUnmeasuredPhotonToHER
fix the momentum of the unmeasured photon to HER
StoreObjPtr< ParticleList > m_plist
StoreObjPtr for the particle list.
void addParticleToOrcaKinFit(BaseFitter &fitter, Particle *particle, const int index)
Adds given particle to the OrcaKinFit.
void updateOrcaKinFitMother(BaseFitter &fitter, std::vector< Particle * > &particleChildren, Particle *mother)
Update the mother: momentum is sum of daughters TODO update covariance matrix.
void resetFitter(BaseFitter &fitter)
Resets all objects associated with the OrcaKinFit fitter.
bool m_fixUnmeasuredPhotonToLER
fix the momentum of the unmeasured photon to LER
bool storeOrcaKinFitParticles(const std::string &prefix, BaseFitter &fitter, std::vector< Particle * > &particleChildren, Particle *mother)
store fit object information as ExtraInfo
bool doKinematicFit(Particle *p)
Main steering routine for any kinematic fitter.
MomentumConstraint m_hardConstraintPx
hard beam constraint px
Class to store reconstructed particles.
Definition: Particle.h:75
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.