Belle II Software development
KinkFitter.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#pragma once
9
10#include <framework/datastore/StoreArray.h>
11#include <framework/gearbox/Const.h>
12#include <mdst/dataobjects/TrackFitResult.h>
13#include <mdst/dataobjects/Kink.h>
14#include <tracking/dataobjects/RecoTrack.h>
15#include <tracking/trackFitting/fitter/base/TrackFitter.h>
16
17#include <utility>
18
19namespace Belle2 {
32 class KinkFitter {
33
34 public:
42 KinkFitter(const std::string& trackFitResultsName = "", const std::string& kinksName = "",
43 const std::string& recoTracksName = "",
44 const std::string& copiedRecoTracksName = "RecoTracksKinkTmp");
45
52 void initializeCuts(const double vertexDistanceCut, const double vertexChi2Cut, const double precutDistance);
53
62 void setFitterMode(const unsigned char fitterMode);
63
90 bool fitAndStore(const Track* trackMother, const Track* trackDaughter, short filterFlag);
91
92 private:
93
101 RecoTrack* copyRecoTrackAndSplit(const RecoTrack* splitRecoTrack, const bool motherFlag, const unsigned int delta);
102
110 bool splitRecoTrack(const RecoTrack* recoTrackSplit, short& recoTrackIndexMother, short& recoTrackIndexDaughter);
111
125 unsigned int combineTracksAndFit(const Track* trackMother, const Track* trackDaughter);
126
135 int findHitPositionForReassignment(const RecoTrack* recoTrack,
136 ROOT::Math::XYZVector& vertexPos,
137 int direction);
138
148 RecoTrack* copyRecoTrackAndReassignCDCHits(RecoTrack* motherRecoTrack, RecoTrack* daughterRecoTrack,
149 const bool motherFlag, const int delta);
150
159 bool refitRecoTrackAfterReassign(RecoTrack* recoTrackMotherRefit, RecoTrack* recoTrackDaughterRefit,
160 const RecoTrack* recoTrackMother, const RecoTrack* recoTrackDaughter);
161
171 const ROOT::Math::XYZVector& momentumSeed,
172 const ROOT::Math::XYZVector& positionSeed,
173 const double& timeSeed);
174
185 RecoTrack* copyRecoTrackForRefit(const RecoTrack* recoTrack,
186 const ROOT::Math::XYZVector& momentumSeed,
187 const ROOT::Math::XYZVector& positionSeed,
188 const double& timeSeed,
189 const bool blockInnerStereoHits = false, const bool useAnotherFitter = false);
190
198 bool isRefitImproveFilter6(const RecoTrack* recoTrackDaughterRefit, const ROOT::Math::XYZVector& motherPosLast);
199
215 bool vertexFitWithRecoTracks(RecoTrack* recoTrackMother, RecoTrack* recoTrackDaughter,
216 unsigned int& reassignHitStatus,
217 ROOT::Math::XYZVector& vertexPos, double& distance,
218 ROOT::Math::XYZVector vertexPosSeed = ROOT::Math::XYZVector(0, 0, 0));
219
230 bool extrapolateToVertex(genfit::MeasuredStateOnPlane& stMother, genfit::MeasuredStateOnPlane& stDaughter,
231 const ROOT::Math::XYZVector& vertexPosition, unsigned int& reassignHitStatus);
232
241 TrackFitResult* buildTrackFitResult(RecoTrack* recoTrack, const genfit::MeasuredStateOnPlane& msop,
242 const double Bz, const Const::ParticleType trackHypothesis);
243
250 void errMatrixForKFit(ROOT::Math::PxPyPzEVector& fourMomentum, TMatrixDSym& covMatrix6,
251 TMatrixDSym& errMatrix7);
252
253
254 private:
255
256 // variables used for input
257 std::string m_recoTracksName;
258 StoreArray <RecoTrack> m_recoTracks;
259
260 // variables used for output
261 StoreArray <TrackFitResult> m_trackFitResults;
262 StoreArray <Kink> m_kinks;
263
264 // cut variables
269
270 // fitter working mode variables
271 unsigned char m_kinkFitterMode;
280
281 // helper variables
282 StoreArray <RecoTrack> m_copiedRecoTracks;
283 genfit::MeasuredStateOnPlane m_stMotherBuffer;
284 genfit::MeasuredStateOnPlane m_stDaughterBuffer;
287 };
288
290}
The ParticleType class for identifying different particle types.
Definition: Const.h:408
KinkFitter class to create Kink mdst's objects from reconstructed tracks.
Definition: KinkFitter.h:32
bool splitRecoTrack(const RecoTrack *recoTrackSplit, short &recoTrackIndexMother, short &recoTrackIndexDaughter)
Split track into two based on |chi2/ndf - 1|.
Definition: KinkFitter.cc:612
bool refitRecoTrackAfterReassign(RecoTrack *recoTrackMotherRefit, RecoTrack *recoTrackDaughterRefit, const RecoTrack *recoTrackMother, const RecoTrack *recoTrackDaughter)
Try to fit new RecoTracks after hit reassignment.
Definition: KinkFitter.cc:311
StoreArray< RecoTrack > m_copiedRecoTracks
RecoTrack used to refit tracks.
Definition: KinkFitter.h:282
genfit::MeasuredStateOnPlane m_stMotherBuffer
buffer for the MeasuredStateOnPlane of mother obtained in the vertex fit
Definition: KinkFitter.h:283
bool vertexFitWithRecoTracks(RecoTrack *recoTrackMother, RecoTrack *recoTrackDaughter, unsigned int &reassignHitStatus, ROOT::Math::XYZVector &vertexPos, double &distance, ROOT::Math::XYZVector vertexPosSeed=ROOT::Math::XYZVector(0, 0, 0))
Fit kink vertex using RecoTrack's as inputs.
Definition: KinkFitter.cc:1280
StoreArray< Kink > m_kinks
Kink (output).
Definition: KinkFitter.h:262
bool m_kinkFitterModeCombineAndFit
fitter mode 3rd bit
Definition: KinkFitter.h:278
RecoTrack * m_motherKinkRecoTrackCache
cache for the RecoTrack of mother used to find the best vertex
Definition: KinkFitter.h:285
double m_vertexDistanceCut
cut on the distance at the found vertex.
Definition: KinkFitter.h:265
RecoTrack * copyRecoTrackForRefit(const RecoTrack *recoTrack, const ROOT::Math::XYZVector &momentumSeed, const ROOT::Math::XYZVector &positionSeed, const double &timeSeed, const bool blockInnerStereoHits=false, const bool useAnotherFitter=false)
Refit the daughter track blocking hits if required.
Definition: KinkFitter.cc:391
double m_vertexChi2Cut
Chi2 cut.
Definition: KinkFitter.h:266
bool fitAndStore(const Track *trackMother, const Track *trackDaughter, short filterFlag)
Fit kink with cardinal hypothesis and store it if the fit was successful.
Definition: KinkFitter.cc:828
StoreArray< TrackFitResult > m_trackFitResults
TrackFitResult (output).
Definition: KinkFitter.h:261
int findHitPositionForReassignment(const RecoTrack *recoTrack, ROOT::Math::XYZVector &vertexPos, int direction)
Find hit position closest to the vertex.
Definition: KinkFitter.cc:135
RecoTrack * m_daughterKinkRecoTrackCache
cache for the RecoTrack of daughter used to find the best vertex
Definition: KinkFitter.h:286
bool extrapolateToVertex(genfit::MeasuredStateOnPlane &stMother, genfit::MeasuredStateOnPlane &stDaughter, const ROOT::Math::XYZVector &vertexPosition, unsigned int &reassignHitStatus)
Extrapolate the fit results to the perigee to the kink vertex.
Definition: KinkFitter.cc:92
double m_precutDistance
Preselection cut on distance between ending points of two tracks used in prefilter.
Definition: KinkFitter.h:267
std::string m_recoTracksName
RecoTrackColName (input).
Definition: KinkFitter.h:257
TrackFitResult * buildTrackFitResult(RecoTrack *recoTrack, const genfit::MeasuredStateOnPlane &msop, const double Bz, const Const::ParticleType trackHypothesis)
Build TrackFitResult of the Kink Track.
Definition: KinkFitter.cc:115
bool m_kinkFitterModeSplitTrack
fitter mode 4th bit
Definition: KinkFitter.h:279
bool m_kinkFitterModeHitsReassignment
fitter mode 1st bit
Definition: KinkFitter.h:276
RecoTrack * copyRecoTrackAndSplit(const RecoTrack *splitRecoTrack, const bool motherFlag, const unsigned int delta)
Create a RecoTrack in a separate StoreArray based on one to be split.
Definition: KinkFitter.cc:515
StoreArray< RecoTrack > m_recoTracks
RecoTrack (input)
Definition: KinkFitter.h:258
bool isRefitImproveFilter6(const RecoTrack *recoTrackDaughterRefit, const ROOT::Math::XYZVector &motherPosLast)
check if the refit of filter 6 daughter tracks improves the distance between mother and daughter
Definition: KinkFitter.cc:447
RecoTrack * copyRecoTrackForFlipAndRefit(const RecoTrack *recoTrack, const ROOT::Math::XYZVector &momentumSeed, const ROOT::Math::XYZVector &positionSeed, const double &timeSeed)
Flip and refit the daughter track.
Definition: KinkFitter.cc:358
RecoTrack * copyRecoTrackAndReassignCDCHits(RecoTrack *motherRecoTrack, RecoTrack *daughterRecoTrack, const bool motherFlag, const int delta)
Copy RecoTrack to a separate StoreArray and reassign CDC hits according to delta.
Definition: KinkFitter.cc:193
bool m_kinkFitterModeFlipAndRefit
fitter mode 2nd bit
Definition: KinkFitter.h:277
unsigned char m_kinkFitterMode
fitter mode from 0 to 15 written in bits:
Definition: KinkFitter.h:271
void initializeCuts(const double vertexDistanceCut, const double vertexChi2Cut, const double precutDistance)
Initialize the cuts which will be applied during the fit and store process.
Definition: KinkFitter.cc:82
void errMatrixForKFit(ROOT::Math::PxPyPzEVector &fourMomentum, TMatrixDSym &covMatrix6, TMatrixDSym &errMatrix7)
Prepare the error matrix for the kFit.
Definition: KinkFitter.cc:1412
genfit::MeasuredStateOnPlane m_stDaughterBuffer
buffer for the MeasuredStateOnPlane of daughter obtained in the vertex fit
Definition: KinkFitter.h:284
void setFitterMode(const unsigned char fitterMode)
set kink fitter mode.
Definition: KinkFitter.cc:68
unsigned int combineTracksAndFit(const Track *trackMother, const Track *trackDaughter)
Combine daughter and mother tracks in one and fit.
Definition: KinkFitter.cc:469
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
Definition: Track.h:25
Abstract base class for different kinds of events.