 |
Belle II Software
release-05-01-25
|
9 #include <analysis/VertexFitting/KFit/MakeMotherKFit.h>
10 #include <analysis/VertexFitting/KFit/MassPointingVertexFitKFit.h>
11 #include <analysis/utility/CLHEPToROOT.h>
15 using namespace Belle2::analysis;
16 using namespace CLHEP;
18 MassPointingVertexFitKFit::MassPointingVertexFitKFit():
20 m_AfterVertexError(HepSymMatrix(3, 0)),
25 m_V_E = HepMatrix(3, 3, 0);
26 m_v = HepMatrix(3, 1, 0);
27 m_v_a = HepMatrix(3, 1, 0);
288 for (
int i = 0; i < 3; i++)
m_v[i][0] =
m_v_a[i][0];
303 int row = 0, col = 0;
341 pdata.setMomentum(HepLorentzVector(h3v, sqrt(h3v.mag2() + pdata.getMass()*pdata.getMass())),
KFitConst::kAfterFit);
350 pdata.setError(this->
makeError3(pdata.getMomentum(),
366 for (
int i = 0; i < 3; i++)
for (
int j = i; j < 3; j++)
390 HepMatrix al_1_prime(
m_al_1);
391 HepMatrix Sum_al_1(4, 1, 0);
409 Sum_al_1[3][0] += energy[i];
420 double mom = sqrt(Sum_al_1[0][0] * Sum_al_1[0][0] + Sum_al_1[1][0] * Sum_al_1[1][0] + Sum_al_1[2][0] * Sum_al_1[2][0]);
421 double Pt2 = Sum_al_1[0][0] * Sum_al_1[0][0] + Sum_al_1[1][0] * Sum_al_1[1][0];
424 + Sum_al_1[3][0] * Sum_al_1[3][0] - Sum_al_1[0][0] * Sum_al_1[0][0]
425 - Sum_al_1[1][0] * Sum_al_1[1][0] - Sum_al_1[2][0] * Sum_al_1[2][0]
429 phiPointingConstraint = std::fmod(phiPointingConstraint + TMath::Pi(), TMath::TwoPi());
430 if (phiPointingConstraint < 0) phiPointingConstraint += TMath::TwoPi();
431 phiPointingConstraint -= TMath::Pi();
436 double Sum_a = 0., Sum_tmpx = 0., Sum_tmpy = 0.;
439 if (energy[i] == 0) {
448 double invE = 1. / energy[i];
490 m_E[2 *
m_TrackCount][0] = -2.*Sum_al_1[1][0] * Sum_a + 2.*Sum_al_1[3][0] * Sum_tmpy;
491 m_E[2 *
m_TrackCount][1] = 2.*Sum_al_1[0][0] * Sum_a - 2.*Sum_al_1[3][0] * Sum_tmpx;
503 double sininv, sqrtag;
513 double pt = sqrt(px * px + py * py);
521 double invPt = 1. / pt;
522 double invPt2 = invPt * invPt;
523 double dlx =
m_v_a[0][0] - x;
524 double dly =
m_v_a[1][0] - y;
525 double dlz =
m_v_a[2][0] - z;
526 double a1 = -dlx * py + dly * px;
527 double a2 = dlx * px + dly * py;
528 double r2d2 = dlx * dlx + dly * dly;
529 double Rx = dlx - 2.*px * a2 * invPt2;
530 double Ry = dly - 2.*py * a2 * invPt2;
542 double tmp0 = 1.0 - B * B;
549 sqrtag = 1.0 / sqrt(tmp0);
551 U = dlz - pz * sininv / a;
559 U = dlz - pz * a2 * invPt2;
564 m_d[i * 2 + 0][0] = a1 - 0.5 * a * r2d2;
565 m_d[i * 2 + 1][0] = U * pt;
585 m_E[i * 2 + 0][0] = -py - a * dlx;
586 m_E[i * 2 + 0][1] = px - a * dly;
587 m_E[i * 2 + 0][2] = 0.0;
588 m_E[i * 2 + 1][0] = -px * pz * pt * S;
589 m_E[i * 2 + 1][1] = -py * pz * pt * S;
590 m_E[i * 2 + 1][2] = pt;
609 for (
unsigned i = 0; i < n; ++i) {
613 for (
unsigned j = i + 1; j < n; ++j) {
621 B2DEBUG(2,
"Error in doMake");
626 double prob = TMath::Prob(chi2, ndf);
627 mother->addExtraInfo(
"ndf", ndf);
628 mother->addExtraInfo(
"chiSquared", chi2);
629 mother->updateMomentum(
double m_MagneticField
Magnetic field.
HepPoint3D m_BeforeVertex
Vertex position before the fit.
CLHEP::HepMatrix m_v
See J.Tanaka Ph.D (2001) p137 for definition.
enum KFitError::ECode setProductionVertex(const HepPoint3D &v)
Set the production vertex of the particle.
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.
double m_CHIsq
chi-square of the fit.
std::vector< CLHEP::HepMatrix > m_AfterTrackVertexError
array of vertex error matrices after the fit.
enum KFitError::ECode m_ErrorCode
Error code.
~MassPointingVertexFitKFit(void)
Destruct the object.
bool m_FlagCorrelation
Flag whether a correlation among tracks exists.
CLHEP::HepMatrix m_D
See J.Tanaka Ph.D (2001) p137 for definition.
const CLHEP::HepMatrix getCorrelation(const int id1, const int id2, const int flag=KFitConst::kAfterFit) const override
Get a correlation matrix between two tracks.
static const int kBeforeFit
Input parameter to specify before-fit when setting/getting a track attribute.
enum KFitError::ECode setTrackVertexError(const CLHEP::HepMatrix &e)
Set a vertex error matrix of the child particle in the addTrack'ed order.
virtual const CLHEP::HepMatrix getCorrelation(const int id1, const int id2, const int flag=KFitConst::kAfterFit) const
Get a correlation matrix between two tracks.
enum KFitError::ECode setVertex(const HepPoint3D &v)
Set a vertex position of the mother particle.
bool isFitted(void) const
Return false if fit is not performed yet or performed fit is failed; otherwise true.
enum KFitError::ECode doFit2(void)
Perform a fit (used in VertexFitKFit::doFit() and MassVertexFitKFit::doFit()).
int m_NecessaryTrackCount
Number needed tracks to perform fit.
enum KFitError::ECode prepareCorrelation(void) override
Build a grand correlation matrix from input-track properties.
const CLHEP::HepSymMatrix getTrackError(const int id) const
Get an error matrix of the track.
CLHEP::HepMatrix m_lam0
See J.Tanaka Ph.D (2001) p138 for definition.
CLHEP::HepMatrix m_Cov_v_al_1
See J.Tanaka Ph.D (2001) p137 for definition.
std::vector< KFitTrack > m_Tracks
Container of input tracks.
CLHEP::HepMatrix m_property
Container of charges and masses.
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-vertex-pointing constraint fit.
CLHEP::HepMatrix m_lam
See J.Tanaka Ph.D (2001) p137 for definition.
CLHEP::HepMatrix m_V_D
See J.Tanaka Ph.D (2001) p138 for definition.
CLHEP::HepMatrix m_al_1
See J.Tanaka Ph.D (2001) p136 for definition.
enum KFitError::ECode prepareInputSubMatrix(void) override
Build sub-matrices for minimum search from input-track properties.
static void displayError(const char *file, const int line, const char *func, const enum ECode code)
Display a description of error and its location.
@ kBadCorrelationSize
Wrong correlation matrix size (internal error)
CLHEP::HepMatrix m_E
See J.Tanaka Ph.D (2001) p137 for definition.
const CLHEP::HepSymMatrix getMotherError(void) const
Get an error matrix of the mother particle.
virtual enum KFitError::ECode setZeroCorrelation(void)
Indicate no correlation between tracks.
enum KFitError::ECode calculateNDF(void) override
Calculate an NDF of the fit.
bool m_FlagFitted
Flag to indicate if the fit is performed and succeeded.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
MakeMotherKFit is a class to build mother particle from kinematically fitted daughters.
const CLHEP::HepLorentzVector getMotherMomentum(void) const
Get a Lorentz vector of the mother particle.
HepPoint3D m_AfterVertex
Vertex position after the fit.
int getTrackCount(void) const
Get the number of added tracks.
static const int kAfterFit
Input parameter to specify after-fit when setting/getting a track attribute.
CLHEP::HepMatrix m_v_a
See J.Tanaka Ph.D (2001) p137 for definition.
static const int kMaxTrackCount
Maximum track size.
static const int kMaxTrackCount2
Maximum track size (internal use)
enum KFitError::ECode setZeroCorrelation(void) override
Indicate no correlation between tracks.
CLHEP::HepMatrix m_V_al_1
See J.Tanaka Ph.D (2001) p138 for definition.
const CLHEP::HepMatrix getTrackVertexError(const int id) const
Get a vertex error matrix of the track.
Abstract base class for different kinds of events.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &m) override
Set a correlation matrix.
virtual int getNDF(void) const
Get an NDF of the fit.
@ kDivisionByZero
Division by zero (bad track property or internal error)
virtual enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &c)
Set a correlation matrix.
enum KFitError::ECode setMagneticField(const double mf)
Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
int m_TrackCount
Number of tracks.
enum KFitError::ECode prepareOutputMatrix(void) override
Build an output error matrix.
@ kCannotGetMatrixInverse
Cannot calculate matrix inverse (bad track property or internal error)
HepPoint3D m_ProductionVertex
Production vertex position.
CLHEP::HepMatrix m_al_0
See J.Tanaka Ph.D (2001) p136 for definition.
static constexpr double kLightSpeed
Speed of light.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &e)
Set a correlation matrix.
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set a vertex error matrix of the mother particle.
enum KFitError::ECode doFit(void)
Perform a mass-vertex-pointing constraint fit.
const KFitTrack getTrack(const int id) const
Get a specified track object.
CLHEP::HepMatrix m_d
See J.Tanaka Ph.D (2001) p137 for definition.
const HepPoint3D getMotherPosition(void) const
Get a position of the mother particle.
Class to store reconstructed particles.
std::vector< int > m_IsFixMass
Array of flags whether the track property is fixed at the mass.
CLHEP::HepMatrix m_V_Dt
See J.Tanaka Ph.D (2001) p138 for definition.
enum KFitError::ECode addTrack(const KFitTrack &kp)
Add a track to the make-mother object.
bool isTrackIDInRange(const int id) const
Check if the id is in the range.
enum KFitError::ECode unfixMass(void)
Tell the object to unfix the last added track property at the invariant mass.
const HepPoint3D getTrackPosition(const int id) const
Get a position of the track.
ECode
ECode is a error code enumerate.
CLHEP::HepSymMatrix m_AfterVertexError
Vertex error matrix after the fit.
enum KFitError::ECode doMake(void)
Perform a reconstruction of mother particle.
@ kOutOfRange
Specified track-id out of range.
double getInvariantMass(void) const
Get an invariant mass.
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.
const CLHEP::HepSymMatrix getVertexError(void) const
Get a fitted vertex error matrix.
enum KFitError::ECode prepareInputMatrix(void) override
Build grand matrices for minimum search from input-track properties.
enum KFitError::ECode fixMass(void)
Tell the object to fix the last added track property at the invariant mass.
static const int kNumber7
Constant 7 to check matrix size (internal use)
double getTrackCHIsq(const int id) const override
Get a chi-square of the track.
CLHEP::HepMatrix m_V_E
See J.Tanaka Ph.D (2001) p138 for definition.
@ kBadTrackSize
Track count too small to perform fit.
CLHEP::HepSymMatrix m_V_al_0
See J.Tanaka Ph.D (2001) p137 for definition.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
double getCHIsq(void) const override
Get a chi-square of the fit.
std::vector< CLHEP::HepMatrix > m_BeforeCorrelation
Container of input correlation matrices.
double m_InvariantMass
Invariant mass.
enum KFitError::ECode setInitialVertex(const HepPoint3D &v)
Set an initial vertex point for the mass-vertex-pointing constraint fit.
const CLHEP::HepLorentzVector getTrackMomentum(const int id) const
Get a Lorentz vector of the track.
enum KFitError::ECode makeCoreMatrix(void) override
Build matrices using the kinematical constraint.