Belle II Software development
DAFRecoFitterModule.cc
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
9#include <tracking/modules/fitter/DAFRecoFitterModule.h>
10#include <tracking/trackFitting/fitter/base/TrackFitter.h>
11#include <tracking/dbobjects/DAFParameters.h>
12
13using namespace Belle2;
14
15REG_MODULE(DAFRecoFitter);
16
18{
19 setDescription("DAF Fitter using Genfit. If you have TrackCands, you have to convert them to RecoTracks"
20 "using the RecoTrackCreatorModule first. After that, you probably want to add the measurements from the"
21 "hits using the MeasurementCreatorModule. Default parameters are read from the database.");
22
24 "Probability cut for the DAF. Any value between 0 and 1 is possible. Common values are between 0.01 and 0.001",
26
27 addParam("trackFitType", m_trackFitType,
28 "Type of track fit algorithm to use the corresponding DAFParameter, the list is defined in DAFConfiguration class.",
30}
31
33std::shared_ptr<genfit::AbsFitter> DAFRecoFitterModule::createFitter() const
34{
35 if (!m_DAFConfiguration.isValid())
36 B2FATAL("DAF Configuration is not available.");
37
39 if (!DAFParams)
40 B2FATAL("DAF parameters for " << (short)m_trackFitType << " is not available.");
41
42 if (static_cast<float>(m_param_probabilityCut) != DAFParams->getProbabilityCut()) {
44 // Only show this warning the first time a DAF instance is created to avoid spamming logs. Otherwise this warning is shown each event at least once in case of non-default DAF settings / DAF setting not from DB
45 B2WARNING("DAF was called with a different probability cut than the database one (new: " << m_param_probabilityCut << " ; DB: " <<
46 DAFParams->getProbabilityCut() << " ). This new value will be used, the other parameters are read from the database");
48 }
49 std::shared_ptr<genfit::DAF> fitter = std::make_shared<genfit::DAF>(DAFParams->getAnnealingScheme(),
50 DAFParams->getMinimumIterations(),
51 DAFParams->getMaximumIterations(),
52 DAFParams->getMinimumIterationsForPVal(),
53 true,
54 DAFParams->getDeltaPValue(),
55 DAFParams->getDeltaWeight(),
57 DAFParams->getMinimumPValue());
58 fitter->setMaxFailedHits(DAFParams->getMaximumFailedHits());
59
60 return fitter;
61 } else {
62 // The user has not changed any parameters, so this is basically the default fitter. We return nullptr,
63 // to not reset the fitter and make refitting unnecessary.
64 return std::shared_ptr<genfit::DAF>(nullptr);
65 }
66}
ETrackFitType
Enum for identifying the type of track fit algorythm ( or cosmic)
The payload containing the DAF parameters.
int getMaximumIterations() const
Get the maximum number of iterations of annealing scheme.
std::tuple< float, float, int > getAnnealingScheme() const
Get the start and end temperatures and number of iterations for the annealing scheme returns a tuple ...
int getMaximumFailedHits() const
Get the maximum number of failed hits after which the fit should be cancelled.
int getMinimumIterationsForPVal() const
Get the minimum number of iterations for pValue check.
float getDeltaPValue() const
Get the DeltaPValue for p-value convergence criterion.
int getMinimumIterations() const
Get the minimum number of iterations of annealing scheme.
float getMinimumPValue() const
Get the minimum PValue used for the convergence criterion.
float getProbabilityCut() const
Get the probability cut for the weight calculation for the hits.
float getDeltaWeight() const
Get the DeltaWeight for weight convergence criterion.
DBObjPtr< DAFConfiguration > m_DAFConfiguration
DAF Configuration Database OjbPtr.
DAFRecoFitterModule()
Module for the DAF fitter.
bool m_changedParametersMessageWasShown
Boolean to only show the warning about changed DAF parameters on first occurrence but not each time a...
double m_param_probabilityCut
Probability cut for the DAF.
std::shared_ptr< genfit::AbsFitter > createFitter() const override
Create a DAF fitter.
short m_trackFitType
Track Fit type to select the proper DAFParameter from DAFConfiguration; by default c_Default.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
static constexpr double s_defaultProbCut
Default probCut for the default DAF fitter.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.