 |
Belle II Software
release-05-02-19
|
10 #include <tracking/modules/fitter/BaseRecoFitterModule.h>
11 #include <tracking/dataobjects/RecoTrack.h>
13 #include <genfit/KalmanFitStatus.h>
14 #include <genfit/FitStatus.h>
15 #include <genfit/MaterialEffects.h>
16 #include <genfit/FieldManager.h>
18 #include <framework/datastore/StoreArray.h>
19 #include <tracking/trackFitting/fitter/base/TrackFitter.h>
21 #include <simulation/monopoles/MonopoleConstants.h>
26 BaseRecoFitterModule::BaseRecoFitterModule() :
29 setDescription(
"Fit the given reco tracks with the given fitter parameters.");
47 "Use these particle hypotheses for fitting. Please use positive pdg codes only.",
54 "Configures whether the CDC Translators should be initialized by the FitterModule",
56 addParam(
"monopoleMagCharge", Monopoles::monopoleMagCharge,
57 "Sets monopole magnetic charge hypothesis if it is in the pdgCodesToUseForFitting",
58 Monopoles::monopoleMagCharge);
64 recoTracks.isRequired();
66 if (!genfit::MaterialEffects::getInstance()->isInitialized()) {
67 B2FATAL(
"Material effects not set up. Please use SetupGenfitExtrapolationModule.");
71 B2FATAL(
"Magnetic field not set up. Please use SetupGenfitExtrapolationModule.");
74 genfit::MaterialEffects::getInstance()->setMagCharge(Monopoles::monopoleMagCharge);
86 const std::shared_ptr<genfit::AbsFitter>& genfitFitter =
createFitter();
88 fitter.resetFitter(genfitFitter);
91 B2DEBUG(100,
"Number of reco track candidates to process: " << recoTracks.
getEntries());
92 unsigned int recoTrackCounter = 0;
95 if (recoTrack.getNumberOfTotalHits() < 3) {
96 B2WARNING(
"Genfit2Module: only " << recoTrack.getNumberOfTotalHits() <<
" were assigned to the Track! " <<
97 "This Track will not be fitted!");
101 B2DEBUG(100,
"Fitting reco track candidate number " << recoTrackCounter);
102 B2DEBUG(100,
"Reco track candidate has start values: ");
103 B2DEBUG(100,
"Momentum: " << recoTrack.getMomentumSeed().X() <<
" " << recoTrack.getMomentumSeed().Y() <<
" " <<
104 recoTrack.getMomentumSeed().Z());
105 B2DEBUG(100,
"Position: " << recoTrack.getPositionSeed().X() <<
" " << recoTrack.getPositionSeed().Y() <<
" " <<
106 recoTrack.getPositionSeed().Z());
107 B2DEBUG(100,
"Charge: " << recoTrack.getChargeSeed());
108 B2DEBUG(100,
"Total number of hits assigned to the track: " << recoTrack.getNumberOfTotalHits());
111 bool wasFitSuccessful;
112 if (pdgCodeToUseForFitting != Monopoles::c_monopolePDGCode) {
114 B2DEBUG(100,
"PDG: " << pdgCodeToUseForFitting);
115 wasFitSuccessful = fitter.fit(recoTrack, particleUsedForFitting);
118 wasFitSuccessful = fitter.fit(recoTrack, pdgCodeToUseForFitting);
120 const genfit::AbsTrackRep* trackRep = recoTrack.getTrackRepresentationForPDG(pdgCodeToUseForFitting);
123 B2FATAL(
"TrackRepresentation for PDG id " << pdgCodeToUseForFitting <<
" not present in RecoTrack although it " <<
124 "should have been created.");
127 B2DEBUG(99,
"-----> Fit results:");
128 if (wasFitSuccessful) {
131 B2DEBUG(99,
" Chi2 of the fit: " << kfs->
getChi2());
132 B2DEBUG(99,
" NDF of the fit: " << kfs->getBackwardNdf());
134 double pValue = recoTrack.getTrackFitStatus(trackRep)->getPVal();
135 B2DEBUG(99,
" pValue of the fit: " << pValue);
137 B2DEBUG(99,
"Charge after fit " << mSoP.getCharge());
138 B2DEBUG(99,
"Position after fit " << mSoP.getPos().X() <<
" " << mSoP.getPos().Y() <<
" " << mSoP.getPos().Z());
139 B2DEBUG(99,
"Momentum after fit " << mSoP.getMom().X() <<
" " << mSoP.getMom().Y() <<
" " << mSoP.getMom().Z());
141 B2DEBUG(99,
" fit failed!");
144 recoTrackCounter += 1;
double getChi2() const
Get chi^2 of the fit.
std::string m_param_eklmHitsStoreArrayName
StoreArray name of the EKLM hits.
void setDescription(const std::string &description)
Sets the description of the module.
#StateOnPlane with additional covariance matrix.
FitStatus for use with AbsKalmanFitter implementations.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
bool m_param_resortHits
Resort the hits while fitting.
void initialize() override
Initialize the store ararys and check for the material effects.
Abstract base class for a track representation.
virtual std::shared_ptr< genfit::AbsFitter > createFitter() const =0
Method to create the used filter.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Algorithm class to handle the fitting of RecoTrack objects.
This is the Reconstruction Event-Data Model Track.
std::string m_param_pxdHitsStoreArrayName
StoreArray name of the PXD hits.
void event() override
Do the fitting using the created fitter.
std::string m_param_recoTracksStoreArrayName
StoreArray name of the input and output reco tracks.
Abstract base class for different kinds of events.
std::vector< unsigned int > m_param_pdgCodesToUseForFitting
Use these particle hypotheses for fitting.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Provides a type-safe way to pass members of the chargedStableSet set.
std::string m_param_cdcHitsStoreArrayName
StoreArray name of the CDC hits.
Accessor to arrays stored in the data store.
std::string m_param_svdHitsStoreArrayName
StoreArray name of the SVD hits.
static FieldManager * getInstance()
Get singleton instance.
Class where important numbers and properties of a fit can be stored.
int getEntries() const
Get the number of objects in the array.
std::string m_param_bklmHitsStoreArrayName
StoreArray name of the BKLM hits.
bool m_param_initializeCDCTranslators
Configures whether the CDC Translators should be initialized by the FitterModule especially useful fo...