9#include <tracking/modules/flipAndRefit/FlippedRecoTracksMergerModule.h>
10#include <mdst/dataobjects/Track.h>
11#include <mdst/dataobjects/TrackFitResult.h>
12#include <tracking/dataobjects/RecoTrack.h>
13#include <tracking/dbobjects/TrackFlippingCuts.h>
22 setDescription(
"This module will check the 2 flipping QIs of one RecoTrack and update the original RecoTrack, Track and TrackFitResults if the flipped one should be taken (according to the 2 flipping QIs)");
26 "Name of the input StoreArray");
28 "Name of the input StoreArray for flipped tracks");
41 B2FATAL(
"TRKTrackFlipAndRefit_MVA_cuts payload is not available");
47 if (!(*m_flipCutsFromDB).getOnOffInfo())
return;
54 if (not recoTrack.wasFitSuccessful()) {
64 auto trackFitResult = track->getTrackFitResultWithClosestMass(
Const::pion);
65 if (trackFitResult->getTransverseMomentum() > (*m_flipCutsFromDB).getPtCut())
continue;
67 double mvaFlipCut = (*m_flipCutsFromDB).getSecondCut();
70 if (std::isnan(recoTrack.get2ndFlipQualityIndicator()) or (recoTrack.get2ndFlipQualityIndicator() < mvaFlipCut))
continue;
74 if (!flippedRecoTrack)
continue;
81 B2WARNING(
"Consistency check of genfit track failed. Will skip this track candidate.");
87 if (!trackFlipped)
continue;
88 std::vector<Track::ChargedStableTrackFitResultPair> fitResultsAfter =
90 std::vector<Track::ChargedStableTrackFitResultPair> fitResultsBefore = track->getTrackFitResults();
93 track->setFlippedAndRefitted();
96 for (
auto fitResult : fitResultsBefore) {
97 auto iterFitResult = std::find_if(fitResultsAfter.begin(),
100 if (iterFitResult == fitResultsAfter.end()) {
101 track->setTrackFitResultIndex(fitResult.first, -1);
102 fitResult.second->mask();
108 for (
auto fitResult : fitResultsAfter) {
110 auto oldFitResultPairIter = std::find_if(fitResultsBefore.begin(),
114 if (oldFitResultPairIter != fitResultsBefore.end()) {
115 oldFitResultPairIter->second->updateTrackFitResult(*fitResult.second);
119 const int newTrackFitResultArrayIndex = newFitResult->
getArrayIndex();
120 track->setTrackFitResultIndex(fitResult.first, newTrackFitResultArrayIndex);
124 recoTrack.flipTrackDirectionAndCharge();
static const ChargedStable pion
charged pion particle
StoreArray< RecoTrack > m_inputRecoTracks
store array for the input RecoTracks
std::string m_inputStoreArrayNameFlipped
Name of the input StoreArray for flipped tracks.
void initialize() override
Declare required StoreArray.
void event() override
Event processing.
StoreArray< TrackFitResult > m_trackFitResults
StoreArray of TrackFitResult, only default name should be considered here.
DBObjPtr< TrackFlippingCuts > m_flipCutsFromDB
flipping cuts could be read from the DB
void beginRun() override
Begin run.
std::string m_inputStoreArrayName
Name of the input StoreArray.
FlippedRecoTracksMergerModule()
Constructor of the module. Setting up parameters and description.
StoreArray< RecoTrack > m_inputRecoTracksFlipped
store array for the input flipped RecoTracks
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...
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
static void swapGenfitTrack(RecoTrack &recoTrack, const genfit::Track *track)
Set the genfit track of a Recotrack copying the information from another genfit track.
This is the Reconstruction Event-Data Model Track.
const genfit::Track & getGenfitTrack() const
Returns genfit track.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
void updateTrackFitResult(const TrackFitResult &input)
update the TrackFitResults
Class that bundles various TrackFitResults.
std::vector< ChargedStableTrackFitResultPair > getTrackFitResultsByName(const std::string trackFitResultsName) const
Access to all track fit results at the same time (from TrackFitResult with specified name)
std::pair< Const::ChargedStable, TrackFitResult * > ChargedStableTrackFitResultPair
Pair to hold the particle hypothesis used for the fit as first entry and the result of the track fit ...
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.