Belle II Software development
RecoTracksReverterModule.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/flipAndRefit/RecoTracksReverterModule.h>
10#include <tracking/dataobjects/RecoTrack.h>
11#include <mdst/dataobjects/Track.h>
12#include <tracking/dbobjects/TrackFlippingCuts.h>
13
14using namespace Belle2;
15
16REG_MODULE(RecoTracksReverter);
17
19 Module()
20{
21 setDescription("Revert the RecoTracks, including changing of the seed position, reverting the momentum and revising the hits Order");
23
24 addParam("inputStoreArrayName", m_inputStoreArrayName,
25 "Name of the input StoreArray");
26 addParam("outputStoreArrayName", m_outputStoreArrayName,
27 "Name of the output StoreArray");
28}
29
40
42{
43 if (!m_flipCutsFromDB.isValid())
44 B2FATAL("TRKTrackFlipAndRefit_MVA_cuts payload is not available");
45}
46
48{
49 // check if the flip&refit is switched on (or off)
50 if (!(*m_flipCutsFromDB).getOnOffInfo()) return;
51
52 for (const RecoTrack& recoTrack : m_inputRecoTracks) {
53
54 if (not recoTrack.wasFitSuccessful()) {
55 continue;
56 }
57
58 double mvaFlipCut = (*m_flipCutsFromDB).getFirstCut();
59
60 if (recoTrack.getFlipQualityIndicator() < mvaFlipCut) continue;
61 Track* track = recoTrack.getRelatedFrom<Belle2::Track>();
62 if (!track) continue;
63
64 const auto& measuredStateOnPlane = recoTrack.getMeasuredStateOnPlaneFromLastHit();
65 const ROOT::Math::XYZVector& currentPosition = ROOT::Math::XYZVector(measuredStateOnPlane.getPos());
66 const ROOT::Math::XYZVector& currentMomentum = ROOT::Math::XYZVector(measuredStateOnPlane.getMom());
67 const double& currentCharge = measuredStateOnPlane.getCharge();
68
69 RecoTrack* newRecoTrack = m_outputRecoTracks.appendNew(currentPosition, -currentMomentum, -currentCharge,
70 recoTrack.getStoreArrayNameOfPXDHits(), recoTrack.getStoreArrayNameOfSVDHits(), recoTrack.getStoreArrayNameOfCDCHits(),
71 recoTrack.getStoreArrayNameOfBKLMHits(), recoTrack.getStoreArrayNameOfEKLMHits(),
72 recoTrack.getStoreArrayNameOfRecoHitInformation());
73 newRecoTrack->addHitsFromRecoTrack(&recoTrack, newRecoTrack->getNumberOfTotalHits(), true);
74 newRecoTrack->addRelationTo(&recoTrack);
75 }
76}
77
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition DataStore.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
size_t addHitsFromRecoTrack(const RecoTrack *recoTrack, unsigned int sortingParameterOffset=0, bool reversed=false, std::optional< double > optionalMinimalWeight=std::nullopt)
Add all hits from another RecoTrack to this RecoTrack.
Definition RecoTrack.cc:240
static void registerRequiredRelations(StoreArray< RecoTrack > &recoTracks, std::string const &pxdHitsStoreArrayName="", std::string const &svdHitsStoreArrayName="", std::string const &cdcHitsStoreArrayName="", std::string const &bklmHitsStoreArrayName="", std::string const &eklmHitsStoreArrayName="", std::string const &recoHitInformationStoreArrayName="")
Convenience method which registers all relations required to fully use a RecoTrack.
Definition RecoTrack.cc:53
unsigned int getNumberOfTotalHits() const
Return the number of cdc + svd + pxd + bklm + eklm hits.
Definition RecoTrack.h:436
StoreArray< RecoTrack > m_inputRecoTracks
Store Array of the input tracks.
StoreArray< RecoTrack > m_outputRecoTracks
Store Array of the output tracks.
void initialize() override
Declare required StoreArray.
void event() override
Event processing.
RecoTracksReverterModule()
Constructor of the module. Setting up parameters and description.
DBObjPtr< TrackFlippingCuts > m_flipCutsFromDB
the flipping cuts can be read from the DB
std::string m_inputStoreArrayName
Name of the input StoreArray.
std::string m_outputStoreArrayName
Name of the output StoreArray.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Class that bundles various TrackFitResults.
Definition Track.h:25
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.