11#include <analysis/VertexFitting/KFit/MassFourCFitKFit.h>
12#include <analysis/VertexFitting/KFit/MakeMotherKFit.h>
13#include <analysis/utility/CLHEPToROOT.h>
14#include <framework/gearbox/Const.h>
17#include <TMatrixFSym.h>
21using namespace Belle2::analysis;
23using namespace ROOT::Math;
26 m_FourMomentum(PxPyPzEVector())
44 if ((childTrackId.back() - childTrackId.front()) != childTrackId.size() - 1)
184 return HepSymMatrix(3, 0);
430 sprintf(buf,
"%s:%s(): internal error; this function should never be called", __FILE__, __func__);
447 int row = 0, col = 0;
520 pdata.setError(this->
makeError3(pdata.getMomentum(),
540 for (
int i = 0; i < 3; i++)
for (
int j = i; j < 3; j++) {
569 HepMatrix al_1_prime(
m_al_1);
570 HepMatrix Sum_al_1(4, 1, 0);
585 Sum_al_1[3][0] += energy[i];
597 Sum_child_al_1[i * 4 + 3][0] += energy[k];
600 for (
int j = 0; j < 3; j++) Sum_child_al_1[i * 4 + j][0] += al_1_prime[k *
KFitConst::kNumber7 + j][0];
611 + Sum_child_al_1[i * 4 + 3][0] * Sum_child_al_1[i * 4 + 3][0] - Sum_child_al_1[i * 4 + 0][0] * Sum_child_al_1[i * 4 + 0][0]
612 - Sum_child_al_1[i * 4 + 1][0] * Sum_child_al_1[i * 4 + 1][0] - Sum_child_al_1[i * 4 + 2][0] * Sum_child_al_1[i * 4 + 2][0]
617 if (energy[i] == 0) {
627 for (
int l = 0; l < 4; l++) {
628 for (
int n = 0; n < 6; n++) {
633 double invE = 1. / energy[i];
654 double invE = 1. / energy[i];
656 Sum_child_al_1[l * 4 + 0][0]);
658 Sum_child_al_1[l * 4 + 1][0]);
660 Sum_child_al_1[l * 4 + 2][0]);
663 Sum_child_al_1[l * 4 + 1][0]) * a;
665 Sum_child_al_1[l * 4 + 0][0]) * a;
668 for (
int n = 0; n < 6; n++) {
681 HepMatrix al_1_prime(
m_al_1);
682 HepMatrix Sum_al_1(7, 1, 0);
695 Sum_al_1[6][0] = + a;
699 if (energy[i] == 0) {
706 double invE = 1. / energy[i];
707 Sum_al_1[3][0] += energy[i];
723 if (energy[i] == 0) {
729 for (
int l = 0; l < 4; l++) {
730 for (
int n = 0; n < 6; n++) {
758 for (
unsigned i = 0; i < n; ++i) {
763 for (
unsigned j = i + 1; j < n; ++j) {
775 double prob = TMath::Prob(chi2, ndf);
static const double speedOfLight
[cm/ns]
Class to store reconstructed particles.
void setExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
void updateMomentum(const ROOT::Math::PxPyPzEVector &p4, const ROOT::Math::XYZVector &vertex, const TMatrixFSym &errMatrix, double pValue)
Sets Lorentz vector, position, 7x7 error matrix and p-value.
int m_NecessaryTrackCount
Number needed tracks to perform fit.
double m_MagneticField
Magnetic field.
CLHEP::HepMatrix m_al_1
See J.Tanaka Ph.D (2001) p136 for definition.
virtual enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &c)
Set a correlation matrix.
const CLHEP::HepSymMatrix makeError3(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e, const bool is_fix_mass) const
Rebuild an error matrix from a Lorentz vector and an error matrix.
const CLHEP::HepSymMatrix getTrackError(const int id) const
Get an error matrix of the track.
const CLHEP::HepLorentzVector getTrackMomentum(const int id) const
Get a Lorentz vector of the track.
CLHEP::HepMatrix m_lam
See J.Tanaka Ph.D (2001) p137 for definition.
const HepPoint3D getTrackPosition(const int id) const
Get a position of the track.
CLHEP::HepMatrix m_property
Container of charges and masses.
enum KFitError::ECode m_ErrorCode
Error code.
virtual enum KFitError::ECode setZeroCorrelation(void)
Indicate no correlation between tracks.
CLHEP::HepMatrix m_V_al_1
See J.Tanaka Ph.D (2001) p138 for definition.
virtual int getNDF(void) const
Get an NDF of the fit.
CLHEP::HepMatrix m_d
See J.Tanaka Ph.D (2001) p137 for definition.
bool isFitted(void) const
Return false if fit is not performed yet or performed fit is failed; otherwise true.
CLHEP::HepMatrix m_D
See J.Tanaka Ph.D (2001) p137 for definition.
CLHEP::HepMatrix m_V_D
See J.Tanaka Ph.D (2001) p138 for definition.
bool isTrackIDInRange(const int id) const
Check if the id is in the range.
virtual const CLHEP::HepMatrix getCorrelation(const int id1, const int id2, const int flag=KFitConst::kAfterFit) const
Get a correlation matrix between two tracks.
bool m_FlagCorrelation
Flag whether a correlation among tracks exists.
CLHEP::HepSymMatrix m_V_al_0
See J.Tanaka Ph.D (2001) p137 for definition.
const KFitTrack getTrack(const int id) const
Get a specified track object.
std::vector< CLHEP::HepMatrix > m_BeforeCorrelation
Container of input correlation matrices.
bool m_FlagFitted
Flag to indicate if the fit is performed and succeeded.
double m_CHIsq
chi-square of the fit.
int getTrackCount(void) const
Get the number of added tracks.
std::vector< KFitTrack > m_Tracks
Container of input tracks.
const CLHEP::HepMatrix makeError4(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e) const
Rebuild an error matrix from a Lorentz vector and an error matrix.
int m_TrackCount
Number of tracks.
CLHEP::HepMatrix m_al_0
See J.Tanaka Ph.D (2001) p136 for definition.
enum KFitError::ECode doFit1(void)
Perform a fit (used in MassFitKFit::doFit()).
static void displayError(const char *file, const int line, const char *func, const enum ECode code)
Display a description of error and its location.
ECode
ECode is a error code enumerate.
@ kUnimplemented
Unprepared.
@ kCannotGetMatrixInverse
Cannot calculate matrix inverse (bad track property or internal error)
@ kOutOfRange
Specified track-id out of range.
@ kDivisionByZero
Division by zero (bad track property or internal error)
@ kBadTrackSize
Track count too small to perform fit.
@ kBadMatrixSize
Wrong correlation matrix size.
@ kBadCorrelationSize
Wrong correlation matrix size (internal error)
MakeMotherKFit is a class to build mother particle from kinematically fitted daughters.
enum KFitError::ECode setVertex(const HepPoint3D &v)
Set a vertex position of the mother particle.
enum KFitError::ECode addTrack(const KFitTrack &kp)
Add a track to the make-mother object.
enum KFitError::ECode doMake(void)
Perform a reconstruction of mother particle.
const CLHEP::HepSymMatrix getMotherError(void) const
Get an error matrix of the mother particle.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &e)
Set a correlation matrix.
const HepPoint3D getMotherPosition(void) const
Get a position of the mother particle.
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set a vertex error matrix of the mother particle.
enum KFitError::ECode setTrackVertexError(const CLHEP::HepMatrix &e)
Set a vertex error matrix of the child particle in the addTrack'ed order.
const CLHEP::HepLorentzVector getMotherMomentum(void) const
Get a Lorentz vector of the mother particle.
enum KFitError::ECode setMagneticField(const double mf)
Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
enum KFitError::ECode setZeroCorrelation(void) override
Indicate no correlation between tracks.
enum KFitError::ECode setVertex(const HepPoint3D &v)
Set an initial vertex position for the mass-four-momentum-constraint fit.
bool m_FlagTrackVertexError
Flag to indicate if the vertex error matrix of the child particle is preset.
enum KFitError::ECode setFourMomentum(const ROOT::Math::PxPyPzEVector &m)
Set an 4 Momentum for the mass-four-constraint fit.
bool m_FlagAtDecayPoint
Flag controlled by setFlagAtDecayPoint().
bool getFlagAtDecayPoint(void) const
Get a flag if to constraint at the decay point in the mass-four-momentum-constraint fit.
enum KFitError::ECode addMassConstraint(const double m, std::vector< unsigned > &childTrackId)
Set an invariant mass of daughter particle for the mass-four-momentum-constraint fit.
enum KFitError::ECode prepareInputMatrix(void) override
Build grand matrices for minimum search from input-track properties.
bool getFlagFitWithVertex(void) const
Get a flag if the fit is allowed with moving the vertex position.
enum KFitError::ECode calculateNDF(void) override
Calculate an NDF of the fit.
double getCHIsq(void) const override
Get a chi-square of the fit.
enum KFitError::ECode setFlagAtDecayPoint(const bool flag)
Set a flag if to constraint at the decay point in the mass-four-momentum-constraint fit.
enum KFitError::ECode setTrackZeroVertexError(void)
Indicate no vertex uncertainty in the child particle in the addTrack'ed order.
std::vector< int > m_IsFixMass
Array of flags whether the track property is fixed at the mass.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode unfixMass(void)
Tell the object to unfix the last added track property at the invariant mass.
enum KFitError::ECode prepareInputSubMatrix(void) override
Build sub-matrices for minimum search from input-track properties.
bool m_FlagFitIncludingVertex
Flag to indicate if the fit is allowed with moving the vertex position.
~MassFourCFitKFit(void)
Destruct the object.
enum KFitError::ECode doFit(void)
Perform a mass-four-momentum-constraint fit.
double m_InvariantMass
Invariant mass.
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-four-momentum-constraint fit.
std::vector< CLHEP::HepMatrix > m_BeforeTrackVertexError
array of vertex error matrices before the fit.
enum KFitError::ECode makeCoreMatrix(void) override
Build matrices using the kinematical constraint.
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set an initial vertex error matrix for the mass-four-momentum-constraint fit.
enum KFitError::ECode setTrackVertexError(const CLHEP::HepMatrix &e)
Set a vertex error matrix of the child particle in the addTrack'ed order.
enum KFitError::ECode prepareCorrelation(void) override
Build a grand correlation matrix from input-track properties.
HepPoint3D m_AfterVertex
Vertex position after the fit.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &m) override
Set a correlation matrix.
std::vector< std::pair< int, int > > m_ConstraintMassChildLists
Daughter track id of constrained particle.
std::vector< CLHEP::HepMatrix > m_AfterTrackVertexError
array of vertex error matrices after the fit.
const CLHEP::HepMatrix getCorrelation(const int id1, const int id2, const int flag=KFitConst::kAfterFit) const override
Get a correlation matrix between two tracks.
double getTrackCHIsq(const int id) const override
Get a chi-square of the track.
const CLHEP::HepSymMatrix getVertexError(const int flag=KFitConst::kAfterFit) const
Get a vertex error matrix.
MassFourCFitKFit()
Construct an object with no argument.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
std::vector< double > m_ConstraintMassList
constrained mass
const CLHEP::HepMatrix getTrackVertexError(const int id, const int flag=KFitConst::kAfterFit) const
Get a vertex error matrix of the track.
int m_ConstraintMassCount
CLHEP::HepSymMatrix m_AfterVertexError
Vertex error matrix after the fit.
enum KFitError::ECode prepareOutputMatrix(void) override
Build an output error matrix.
CLHEP::HepSymMatrix m_BeforeVertexError
Vertex error matrix before the fit.
HepPoint3D m_BeforeVertex
Vertex position before the fit.
enum KFitError::ECode fixMass(void)
Tell the object to fix the last added track property at the invariant mass.
ROOT::Math::PxPyPzEVector m_FourMomentum
Four Momentum.
double getInvariantMass(void) const
Get an invariant mass.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.
static const int kMaxTrackCount
Maximum track size.
static const int kMaxTrackCount2
Maximum track size (internal use)
static const int kAfterFit
Input parameter to specify after-fit when setting/getting a track attribute.
static const int kBeforeFit
Input parameter to specify before-fit when setting/getting a track attribute.
static const int kNumber7
Constant 7 to check matrix size (internal use)