Belle II Software development
FittedTracksStorerModule.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#include <tracking/modules/fitter/FittedTracksStorerModule.h>
9#include <tracking/dataobjects/RecoTrack.h>
10#include <mdst/dataobjects/MCParticle.h>
11#include <mdst/dataobjects/Track.h>
12
13using namespace Belle2;
14
15REG_MODULE(FittedTracksStorer);
16
18 Module()
19{
21 setDescription("A module to copy only the fitted reco tracks to the output store array.");
22
23 addParam("inputRecoTracksStoreArrayName", m_param_inputRecoTracksStoreArrayName, "StoreArray name of the input reco tracks.",
25 addParam("outputRecoTracksStoreArrayName", m_param_outputRecoTracksStoreArrayName, "StoreArray name of the output reco tracks.",
27 addParam("minimalWeight", m_param_minimalWeight, "Minimal weight for copying the hits.", m_param_minimalWeight);
28}
29
31{
34
37
40 }
41
42 if (m_Tracks.isOptional()) {
43 m_Tracks.registerRelationTo(m_outputRecoTracks);
44 }
45}
46
47
49{
50 for (RecoTrack& recoTrack : m_inputRecoTracks) {
51 if (recoTrack.wasFitSuccessful()) {
52 auto newRecoTrack = recoTrack.copyToStoreArray(m_outputRecoTracks);
53 newRecoTrack->addHitsFromRecoTrack(&recoTrack, 0, false, m_param_minimalWeight);
54
55 // Add also relations
56 auto relatedTrack = recoTrack.getRelated<Track>();
57 if (relatedTrack) {
58 relatedTrack->addRelationTo(newRecoTrack);
59 }
60
61 auto relatedParticle = recoTrack.getRelated<MCParticle>();
62 if (relatedParticle) {
63 newRecoTrack->addRelationTo(relatedParticle);
64 }
65
66 recoTrack.addRelationTo(newRecoTrack);
67 }
68 }
69}
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
StoreArray< RecoTrack > m_inputRecoTracks
Input RecoTracks StoreArray.
StoreArray< RecoTrack > m_outputRecoTracks
Output RecoTracks StoreArray.
std::string m_param_outputRecoTracksStoreArrayName
StoreArray name of the output reco tracks.
void initialize() override
Initialize the store arrays.
void event() override
Do the copying.
std::optional< double > m_param_minimalWeight
Minimal weight for copying the hits.
std::string m_param_inputRecoTracksStoreArrayName
StoreArray name of the input reco tracks.
StoreArray< Track > m_Tracks
Tracks StoreArray.
StoreArray< MCParticle > m_MCParticles
MCParticles StoreArray.
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.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
@ 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
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
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).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.