Belle II Software development
RecoTracksCopierModule.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/recoTracksCopier/RecoTracksCopierModule.h>
10
11using namespace Belle2;
12
13REG_MODULE(RecoTracksCopier);
14
16 Module()
17{
18 setDescription("Copies RecoTracks without their fit information.");
20
21 addParam("inputStoreArrayName", m_inputStoreArrayName,
22 "Name of the input StoreArray");
23 addParam("outputStoreArrayName", m_outputStoreArrayName,
24 "Name of the output StoreArray");
25 addParam("onlyFittedTracks", m_param_onlyFittedTracks, "Only copy fitted tracks", m_param_onlyFittedTracks);
26
27}
28
30{
32
35
37
38 if (m_tracks.optionalRelationTo(m_inputRecoTracks)) {
39 m_tracks.registerRelationTo(m_outputRecoTracks);
40 }
41}
42
44{
45 for (const RecoTrack& recoTrack : m_inputRecoTracks) {
46 if (m_param_onlyFittedTracks and not recoTrack.wasFitSuccessful()) {
47 continue;
48 }
49 RecoTrack* newRecoTrack = recoTrack.copyToStoreArray(m_outputRecoTracks);
50 newRecoTrack->addHitsFromRecoTrack(&recoTrack);
51 newRecoTrack->addRelationTo(&recoTrack);
52
53 for (Track& track : recoTrack.getRelationsWith<Track>()) {
54 track.addRelationTo(newRecoTrack);
55 }
56 }
57}
58
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
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
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
RecoTrack * copyToStoreArray(StoreArray< RecoTrack > &storeArray) const
Append a new RecoTrack to the given store array and copy its general properties, but not the hits the...
Definition: RecoTrack.cc:529
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
StoreArray< RecoTrack > m_inputRecoTracks
Store Array of the input tracks.
bool m_param_onlyFittedTracks
Parameter: Copy only fitted tracks.
StoreArray< RecoTrack > m_outputRecoTracks
Store Array of the output tracks.
void initialize() override
Declare required StoreArray.
void event() override
Event processing, copies store array.
StoreArray< Track > m_tracks
Store Array of the input tracks (for relations)
std::string m_inputStoreArrayName
Name of the input StoreArray.
RecoTracksCopierModule()
Constructor of the module. Setting up parameters and description.
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).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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.