 |
Belle II Software
release-05-02-19
|
10 #include <tracking/trackFitting/fitter/base/TrackFitter.h>
12 #include <tracking/dataobjects/RecoTrack.h>
14 #include <genfit/AbsTrackRep.h>
15 #include <genfit/FitStatus.h>
16 #include <genfit/AbsFitter.h>
17 #include <genfit/DAF.h>
18 #include <genfit/KalmanFitterInfo.h>
28 int currentPdgCode = particleType.
getPDGCode();
30 const auto& pdgParticleCharge = particleType.
getParticlePDG()->Charge();
34 B2ASSERT(
"Charge of candidate and PDG particle don't match. (Code assumes |q| = 1).",
35 fabs(pdgParticleCharge) == fabs(recoTrackCharge * 3.0));
41 if (std::signbit(pdgParticleCharge) != std::signbit(recoTrackCharge))
44 return currentPdgCode;
62 return fit(recoTrack, trackRepresentation);
70 return fit(recoTrack, trackRepresentation);
81 B2WARNING(e.getExcString());
93 if (not kalmanFitterInfo) {
94 recoHitInformation->setFlag(RecoHitInformation::RecoHitFlag::c_dismissedByFit);
96 std::vector<double> weights = kalmanFitterInfo->getWeights();
97 for (
const double weight : weights) {
99 recoHitInformation->setFlag(RecoHitInformation::RecoHitFlag::c_dismissedByFit);
111 B2ASSERT(
"No fitter was loaded! Have you reset the fitter to an invalid one?",
m_fitter);
116 B2WARNING(
"No track points (measurements) were added to this reco track. Have you used an invalid measurement adder?");
120 const std::vector<genfit::AbsTrackRep*>& trackRepresentations = recoTrack.
getRepresentations();
121 if (std::find(trackRepresentations.begin(), trackRepresentations.end(), trackRepresentation) == trackRepresentations.end()) {
122 B2FATAL(
"The TrackRepresentation provided is not part of the Reco Track.");
127 B2DEBUG(100,
"Hit content did not change, track representation is already present and you used only default parameters." <<
128 "I will not fit the track again. If you still want to do so, set the dirty flag of the track.");
132 const auto previousSetting = gErrorIgnoreLevel;
134 auto fitWithoutCheckResult =
fitWithoutCheck(recoTrack, *trackRepresentation);
135 gErrorIgnoreLevel = previousSetting;
136 return fitWithoutCheckResult;
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Determinstic Annealing Filter (DAF) implementation.
Object containing AbsMeasurement and AbsFitterInfo objects.
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
std::shared_ptr< genfit::AbsFitter > m_fitter
The internal storage of the used fitting algorithms.
void resetFitterToDefaultSettings()
Use the default settings of the fitter to fit the reco tracks.
bool wasFitSuccessful(const genfit::AbsTrackRep *representation=nullptr) const
Returns true if the last fit with the given representation was successful.
bool addMeasurements(RecoTrack &recoTrack) const
After you have filled the internal storage with measurement creators (either by providing your own or...
genfit::AbsTrackRep * getCardinalRepresentation() const
Get a pointer to the cardinal track representation. You are not allowed to modify or delete it!
bool hasTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Check, if there is a fit status for the given representation or for the cardinal one.
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
MeasurementAdder m_measurementAdder
The measurement adder algorithm class.
void setDirtyFlag(const bool &dirtyFlag=true)
Set to true, if you want to rebuild the measurements and do the fit independent on changes of the hit...
KalmanFitterInfo * getKalmanFitterInfo(const AbsTrackRep *rep=nullptr) const
Helper to avoid casting.
int getPDGCode() const
PDG code.
Abstract base class for a track representation.
static int createCorrectPDGCodeForChargedStable(const Const::ChargedStable &particleType, const RecoTrack &recoTrack)
Helper function to multiply the PDG code of a charged stable with the charge of the reco track (if ne...
const std::vector< genfit::AbsTrackRep * > & getRepresentations() const
Return a list of track representations. You are not allowed to modify or delete them!
static constexpr unsigned int s_defaultMaxFailedHits
Default maxFailedHits for the default DAF fitter.
const genfit::TrackPoint * getCreatedTrackPoint(const RecoHitInformation *recoHitInformation) const
Get a pointer to the TrackPoint that was created from this hit.
void setProbCut(const double prob_cut)
Set the probability cut for the weight calculation for the hits.
This is the Reconstruction Event-Data Model Track.
static const ChargedStable pion
charged pion particle
bool fitWithoutCheck(RecoTrack &recoTrack, const genfit::AbsTrackRep &trackRepresentation) const
Helper function to do the fit.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
Abstract base class for different kinds of events.
static constexpr double s_defaultProbCut
Default probCut for the default DAF fitter.
static genfit::AbsTrackRep * createOrReturnRKTrackRep(RecoTrack &recoTrack, int PDGcode)
Checks if a TrackRap for the PDG id of the RecoTrack (and its charge conjugate) does already exit and...
bool m_skipDirtyCheck
Flag to skip the dirty flag check which is needed when using non-default fitters.
std::vector< RecoHitInformation * > getRecoHitInformations(bool getSorted=false) const
Return a list of all RecoHitInformations associated with the RecoTrack.
Provides a type-safe way to pass members of the chargedStableSet set.
bool getDirtyFlag() const
This returns true, if a hit was added after the last fit and measurement creation and a refit should ...
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
void deleteFittedInformationForRepresentation(const genfit::AbsTrackRep *rep)
Delete all fitted information for the given representations.
bool isFitted() const
Has the track been fitted?
void resetFitter(const std::shared_ptr< genfit::AbsFitter > &fitter)
Set the internal storage of the fitter to a provided one, if you want to use non-default settings.
Int_t m_gErrorIgnoreLevel
Control the output level of the ROOT functions used by the GenFit fitter. Default is increased from k...
const TParticlePDG * getParticlePDG() const
Accessor for ROOT TParticlePDG object.
static constexpr double s_defaultDeltaPValue
Default deltaPValue for the default DAF fitter.