83 const std::shared_ptr<genfit::AbsFitter>& genfitFitter =
createFitter();
85 fitter.resetFitter(genfitFitter);
88 B2DEBUG(29,
"Number of reco track candidates to process: " <<
m_recoTracks.getEntries());
89 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(29,
"Fitting reco track candidate number " << recoTrackCounter);
100 B2DEBUG(29,
"Reco track candidate has start values: ");
101 B2DEBUG(29,
"Momentum: " << recoTrack.getMomentumSeed().X() <<
" " << recoTrack.getMomentumSeed().Y() <<
" " <<
102 recoTrack.getMomentumSeed().Z());
103 B2DEBUG(29,
"Position: " << recoTrack.getPositionSeed().X() <<
" " << recoTrack.getPositionSeed().Y() <<
" " <<
104 recoTrack.getPositionSeed().Z());
105 B2DEBUG(29,
"Charge: " << recoTrack.getChargeSeed());
106 B2DEBUG(29,
"Total number of hits assigned to the track: " << recoTrack.getNumberOfTotalHits());
110 bool flippedCharge =
false;
112 bool wasFitSuccessful;
114 if (pdgCodeToUseForFitting != Monopoles::c_monopolePDGCode) {
116 B2DEBUG(29,
"PDG: " << pdgCodeToUseForFitting);
123 && recoTrack.getCardinalRepresentation() == recoTrack.getTrackRepresentationForPDG(pdgCodeToUseForFitting)) {
126 flippedCharge |= recoTrack.getChargeSeed() != recoTrack.getMeasuredStateOnPlaneFromFirstHit().getCharge();
130 B2DEBUG(29,
"Refitting with opposite charge PDG: " << pdgCodeToUseForFitting);
138 const genfit::AbsTrackRep* trackRep = recoTrack.getTrackRepresentationForPDG(pdgCodeToUseForFitting);
141 B2FATAL(
"TrackRepresentation for PDG id " << pdgCodeToUseForFitting <<
" not present in RecoTrack although it " <<
142 "should have been created.");
145 B2DEBUG(28,
"-----> Fit results:");
146 if (wasFitSuccessful) {
147 const genfit::FitStatus* fs = recoTrack.getTrackFitStatus(trackRep);
148 const genfit::KalmanFitStatus* kfs =
dynamic_cast<const genfit::KalmanFitStatus*
>(fs);
149 B2DEBUG(28,
" Chi2 of the fit: " << kfs->getChi2());
150 B2DEBUG(28,
" NDF of the fit: " << kfs->getBackwardNdf());
152 double pValue = recoTrack.getTrackFitStatus(trackRep)->getPVal();
153 B2DEBUG(28,
" pValue of the fit: " << pValue);
154 const genfit::MeasuredStateOnPlane& mSoP = recoTrack.getMeasuredStateOnPlaneFromFirstHit(trackRep);
155 B2DEBUG(28,
"Charge after fit " << mSoP.getCharge());
156 B2DEBUG(28,
"Position after fit " << mSoP.getPos().X() <<
" " << mSoP.getPos().Y() <<
" " << mSoP.getPos().Z());
157 B2DEBUG(28,
"Momentum after fit " << mSoP.getMom().X() <<
" " << mSoP.getMom().Y() <<
" " << mSoP.getMom().Z());
159 B2DEBUG(28,
" fit failed!");
165 recoTrack.setChargeSeed(-recoTrack.getChargeSeed());
167 for (
const auto trackRep : recoTrack.getRepresentations()) {
169 fitter.fit(recoTrack, particleUsedForFitting);
172 recoTrackCounter += 1;
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.