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