 |
Belle II Software
release-05-01-25
|
15 #include <TMatrixFSym.h>
17 #include <analysis/VertexFitting/KFit/MakeMotherKFit.h>
18 #include <analysis/VertexFitting/KFit/VertexFitKFit.h>
19 #include <analysis/utility/CLHEPToROOT.h>
24 using namespace Belle2::analysis;
25 using namespace CLHEP;
27 VertexFitKFit::VertexFitKFit():
29 m_AfterVertexError(HepSymMatrix(3, 0)),
30 m_BeamError(HepSymMatrix(3, 0))
40 m_V_E = HepMatrix(3, 3, 0);
41 m_v = HepMatrix(3, 1, 0);
42 m_v_a = HepMatrix(3, 1, 0);
69 sprintf(buf,
"%s:%s(): already constrained to IPtube", __FILE__, __func__);
86 sprintf(buf,
"%s:%s(): already constrained to IP", __FILE__, __func__);
256 HepMatrix tmp_al_a(
m_al_a);
258 HepMatrix tmp_D(
m_D), tmp_E(
m_E);
262 HepMatrix tmp2_D(
m_D), tmp2_E(
m_E);
279 HepMatrix tV_Ein(3, 3, 0);
293 m_V_D.sub(2 * k + 1, 2 * k + 1, tV_D);
294 HepMatrix tE =
m_E.sub(2 * k + 1, 2 * (k + 1), 1, 3);
295 tV_Ein += (tE.T()) * tV_D * tE;
297 HepMatrix td =
m_d.sub(2 * k + 1, 2 * (k + 1), 1, 1);
298 HepMatrix tlam0 = tV_D * (tD * tDeltaAl + td);
299 m_lam0.sub(2 * k + 1, 1, tlam0);
304 m_V_E = tV_Ein.inverse(err_inverse);
313 if (tmp_chisq <= chisq) {
360 if (tmp2_chisq <= chisq) {
423 HepMatrix tmp_al_a(
m_al_a);
425 HepMatrix tmp_D(
m_D), tmp_E(
m_E);
426 HepMatrix tmp_lam(
m_lam);
434 double tmp_vertex_chisq = 1.e+30;
437 bool it_flag =
false;
447 HepMatrix tV_Dt = tV_Dtin.inverse(err_inverse);
457 HepMatrix td =
m_d.sub(2 * k + 1, 2 * (k + 1), 1, 1);
458 HepMatrix tE =
m_E.sub(2 * k + 1, 2 * (k + 1), 1, 3);
459 chisq += ((
m_lam.sub(2 * k + 1, 2 * (k + 1), 1, 1).T()) * (tD * tDeltaAl + tE * (
m_v -
m_v_a) + td))(1,
470 if (tmp_chisq <= chisq && it_flag) {
484 if (tmp_chisq <= chisq) it_flag =
true;
504 m_V_Dt = tV_Dtin.inverse(err_inverse);
547 HepMatrix tmp_al_a(
m_al_a);
549 HepMatrix tmp_al_0(
m_al_1);
570 m_V_D.sub(2 * k + 1, 2 * k + 1, tV_D);
573 HepMatrix td =
m_d.sub(2 * k + 1, 2 * (k + 1), 1, 1);
574 HepMatrix tlam = tV_D * (tD * tDeltaAl + td);
575 m_lam.sub(2 * k + 1, 1, tlam);
576 m_EachCHIsq[k] = ((tlam.T()) * (tD * tDeltaAl + td))(1, 1);
584 if (tmp_chisq <= chisq) {
651 tmp_property[index][0] = track.getCharge();
652 tmp_property[index][1] = track.getMass();
700 for (
int i = 0; i < 3; i++)
720 pdata.setMomentum(HepLorentzVector(h3v, sqrt(h3v.mag2() + pdata.getMass()*pdata.getMass())),
KFitConst::kAfterFit);
727 pdata.setError(
makeError1(pdata.getMomentum(),
744 for (
int i = 0; i < 3; i++)
for (
int j = i; j < 3; j++)
769 double sininv, sqrtag;
779 double pt = sqrt(px * px + py * py);
786 double invPt = 1. / pt;
787 double invPt2 = invPt * invPt;
788 double dlx =
m_v_a[0][0] - x;
789 double dly =
m_v_a[1][0] - y;
790 double dlz =
m_v_a[2][0] - z;
791 double a1 = -dlx * py + dly * px;
792 double a2 = dlx * px + dly * py;
793 double r2d2 = dlx * dlx + dly * dly;
794 double Rx = dlx - 2.*px * a2 * invPt2;
795 double Ry = dly - 2.*py * a2 * invPt2;
802 B2DEBUG(10,
"KFitError: Cannot calculate arcsin");
808 double tmp0 = 1.0 - B * B;
815 sqrtag = 1.0 / sqrt(tmp0);
817 U = dlz - pz * sininv / a;
824 U = dlz - pz * a2 * invPt2;
828 m_d[i * 2 + 0][0] = a1 - 0.5 * a * r2d2;
829 m_d[i * 2 + 1][0] = U * pt;
846 m_E[i * 2 + 0][0] = -py - a * dlx;
847 m_E[i * 2 + 0][1] = px - a * dly;
848 m_E[i * 2 + 0][2] = 0.0;
849 m_E[i * 2 + 1][0] = -px * pz * pt * S;
850 m_E[i * 2 + 1][1] = -py * pz * pt * S;
851 m_E[i * 2 + 1][2] = pt;
876 sprintf(buf,
"%s:%s(): internal error; duplicated appendTube() call?", __FILE__, __func__);
895 sprintf(buf,
"%s:%s(): internal error; duplicated deleteTube() call?", __FILE__, __func__);
911 for (
unsigned i = 0; i < n; ++i) {
915 for (
unsigned j = i + 1; j < n; ++j) {
926 double prob = TMath::Prob(chi2, ndf);
928 bool haschi2 = mother->hasExtraInfo(
"chiSquared");
930 mother->setExtraInfo(
"chiSquared", chi2);
931 mother->setExtraInfo(
"ndf", ndf);
933 mother->addExtraInfo(
"chiSquared", chi2);
934 mother->addExtraInfo(
"ndf", ndf);
937 mother->updateMomentum(
double m_MagneticField
Magnetic field.
CLHEP::HepMatrix m_v
See J.Tanaka Ph.D (2001) p137 for definition.
@ kCannotGetARCSIN
Cannot get arcsin (bad track property or internal error)
const CLHEP::HepSymMatrix getVertexError(void) const
Get a fitted vertex error matrix.
static const int kMaxIterationCount
Maximum iteration step (internal use)
enum KFitError::ECode setIpTubeProfile(const CLHEP::HepLorentzVector &p, const HepPoint3D &x, const CLHEP::HepSymMatrix &e, const double q)
Set a virtual IP-tube track for the vertex constraint fit.
double m_CHIsq
chi-square of the fit.
~VertexFitKFit(void)
Destruct the object.
CLHEP::HepSymMatrix m_AfterVertexError
Vertex error matrix after the fit.
double getCHIsq(void) const override
Get a chi-square of the fit.
double m_EachCHIsq[KFitConst::kMaxTrackCount2]
Container of chi-square's of the input tracks.
enum KFitError::ECode m_ErrorCode
Error code.
bool m_FlagCorrelation
Flag whether a correlation among tracks exists.
@ kBadInitialCHIsq
Bad initial chi-square (internal error)
CLHEP::HepMatrix m_D
See J.Tanaka Ph.D (2001) p137 for definition.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
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 doFit3(void)
Perform a standard vertex-constraint fit including IP-tube constraint.
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.
KFitTrack m_TubeTrack
Entity of the virtual IP-tube track.
enum KFitError::ECode doFit2(void)
Perform a fit (used in VertexFitKFit::doFit() and MassVertexFitKFit::doFit()).
enum KFitError::ECode setKnownVertex(const bool flag=true)
Tell the object to perform a fit with vertex position fixed.
int m_NecessaryTrackCount
Number needed tracks to perform fit.
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.
virtual enum KFitError::ECode prepareCorrelation(void)
Build a grand correlation matrix from input-track properties.
const CLHEP::HepSymMatrix makeError1(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e) const
Rebuild an error matrix from a Lorentz vector and an error matrix.
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 deleteTube(void)
Delete the virtual tube track to m_Tracks just after the internal minimization call.
enum KFitError::ECode doFit5(void)
Perform a fixed-vertex-position fit mainly for slow pion.
static void displayError(const char *file, const int line, const char *func, const enum ECode code)
Display a description of error and its location.
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.
bool m_FlagFitted
Flag to indicate if the fit is performed and succeeded.
enum KFitError::ECode setIpProfile(const HepPoint3D &ip, const CLHEP::HepSymMatrix &ipe)
Set an IP-ellipsoid shape for the vertex constraint fit.
MakeMotherKFit is a class to build mother particle from kinematically fitted daughters.
HepPoint3D m_BeforeVertex
Vertex position before the fit.
static constexpr double kInitialCHIsq
Initial chi-square value (internal use)
const CLHEP::HepLorentzVector getMotherMomentum(void) const
Get a Lorentz vector of the mother particle.
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)
int m_iTrackTube
ID of the virtual tube track in the m_Tracks.
enum KFitError::ECode doFit4(void)
Perform a IP-ellipsoid and vertex-constraint fit.
CLHEP::HepMatrix m_V_al_1
See J.Tanaka Ph.D (2001) p138 for definition.
Abstract base class for different kinds of events.
enum KFitError::ECode setCorrelationMode(const bool m)
Tell the object to perform a fit with track correlations.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
virtual int getNDF(void) const
Get an NDF of the fit.
@ kDivisionByZero
Division by zero (bad track property or internal error)
HepPoint3D m_AfterVertex
Vertex position after the fit.
std::vector< CLHEP::HepMatrix > m_AfterTrackVertexError
Array of vertex error matrices after the fit.
double getCHIsqVertex(void) const
Get a chi-square of the fit excluding IP-constraint part.
double getTrackCHIsq(const int id) const override
Get a chi-square of the track.
enum KFitError::ECode setMagneticField(const double mf)
Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
bool m_CorrelationMode
Flag controlled by setCorrelationMode().
int getTrackPartNDF(void) const
Get an NDF relevant to the getTrackPartCHIsq().
KFitTrack is a container of the track information (Lorentz vector, position, and error matrix),...
int m_TrackCount
Number of tracks.
@ kCannotGetMatrixInverse
Cannot calculate matrix inverse (bad track property or internal error)
CLHEP::HepMatrix m_al_0
See J.Tanaka Ph.D (2001) p136 for definition.
bool m_FlagBeam
Flag if to perform IP-ellipsoid constraint fit.
static const int kNumber6
Constant 6 to check matrix size (internal use)
enum KFitError::ECode prepareInputSubMatrix(void) override
Build sub-matrices for minimum search from input-track properties.
static constexpr double kLightSpeed
Speed of light.
const CLHEP::HepMatrix getTrackVertexError(const int id) const
Get a vertex error matrix of the track.
enum KFitError::ECode doFit(void)
Perform a vertex-constraint fit.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &e)
Set a correlation matrix.
enum KFitError::ECode prepareInputMatrix(void) override
Build grand matrices for minimum search from input-track properties.
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set a vertex error matrix of the mother particle.
const KFitTrack getTrack(const int id) const
Get a specified track object.
double getTrackPartCHIsq(void) const
Get a sum of the chi-square associated to the input tracks.
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.
virtual double getCHIsq(void) const
Get a chi-square of the fit.
Class to store reconstructed particles.
CLHEP::HepMatrix m_V_Dt
See J.Tanaka Ph.D (2001) p138 for definition.
enum KFitError::ECode appendTube(void)
Add the virtual tube track to m_Tracks just before the internal minimization call.
const CLHEP::HepMatrix makeError2(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e) const
Rebuild an error matrix from a Lorentz vector and an error matrix.
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.
const HepPoint3D getTrackPosition(const int id) const
Get a position of the track.
double m_CHIsqVertex
chi-square of the fit excluding IP-constraint part.
enum KFitError::ECode prepareOutputMatrix(void) override
Build an output error matrix.
ECode
ECode is a error code enumerate.
enum KFitError::ECode doMake(void)
Perform a reconstruction of mother particle.
enum KFitError::ECode calculateNDF(void) override
Calculate an NDF of the fit.
@ kOutOfRange
Specified track-id out of range.
static const int kNumber7
Constant 7 to check matrix size (internal use)
bool m_FlagTube
Flag if to perform IP-tube constraint fit.
CLHEP::HepMatrix m_V_E
See J.Tanaka Ph.D (2001) p138 for definition.
CLHEP::HepSymMatrix m_BeamError
Error matrix modeling the IP ellipsoid.
@ kBadTrackSize
Track count too small to perform fit.
CLHEP::HepSymMatrix m_V_al_0
See J.Tanaka Ph.D (2001) p137 for definition.
bool m_FlagOverIteration
Flag whether the iteration count exceeds the limit.
enum KFitError::ECode setInitialVertex(const HepPoint3D &v)
Set an initial vertex point for the vertex-vertex constraint fit.
CLHEP::HepMatrix m_al_a
See J.Tanaka Ph.D (2001) p137 for definition.
enum KFitError::ECode makeCoreMatrix(void) override
Build matrices using the kinematical constraint.
virtual double getTrackCHIsq(const int id) const
Get a chi-square of the track.
bool m_FlagKnownVertex
Flag controlled by setKnownVertex().
const CLHEP::HepLorentzVector getTrackMomentum(const int id) const
Get a Lorentz vector of the track.