Belle II Software development
RecoTrackCreatorModule.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/RecoTrackCreatorModule.h>
9#include <tracking/dataobjects/RecoTrack.h>
10#include <tracking/dataobjects/RecoHitInformation.h>
11
12using namespace Belle2;
13
14REG_MODULE(RecoTrackCreator);
15
17 Module()
18{
19 setDescription("Converts the given genfit::TrackCands in the StoreArray to RecoTracks for further use in the fitter.");
21
22 addParam("trackCandidatesStoreArrayName", m_param_trackCandidatesStoreArrayName, "StoreArray name of the input track candidates.",
24 addParam("recoTracksStoreArrayName", m_param_recoTracksStoreArrayName, "StoreArray name of the output reco tracks.",
26 addParam("recoHitInformationStoreArrayName", m_param_recoHitInformationStoreArrayName,
27 "StoreArray name of the output reco hit information.", m_param_recoHitInformationStoreArrayName);
28
29 addParam("recreateSortingParameters", m_param_recreateSortingParameters,
30 "Flag to recreate the sorting parameters of the hit out of the stored order.", m_param_recreateSortingParameters);
31
32 addParam("pxdHitsStoreArrayName", m_param_pxdHitsStoreArrayName, "StoreArray name of the input PXD hits.",
34 addParam("svdHitsStoreArrayName", m_param_svdHitsStoreArrayName, "StoreArray name of the input SVD hits.",
36 addParam("cdcHitsStoreArrayName", m_param_cdcHitsStoreArrayName, "StoreArray name of the input CDC hits.",
38 addParam("bklmHitsStoreArrayName", m_param_bklmHitsStoreArrayName, "StoreArray name of the input BKLM hits.",
40 addParam("eklmHitsStoreArrayName", m_param_eklmHitsStoreArrayName, "StoreArray name of the input EKLM hits.",
42}
43
45{
46 // Read in genfit::TrackCands
47 // Write our RecoTracks
49
53
56 }
57
65}
66
68{
69// StoreArray<RecoHitInformation> recoHitInformations(m_param_recoHitInformationStoreArrayName);
70
71 // ugly..
72
73 for (const genfit::TrackCand& trackCandidate : m_TrackCandidates) {
74
75 if (trackCandidate.getNHits() < 3) {
76 B2WARNING("Number of hits of track candidate is smaller than 3. Not creating track out of it.");
77 continue;
78 }
79
84
85
86 newRecoTrack->addRelationTo(&trackCandidate);
87
88 // Add also the MC information
89 const int mcParticleID = trackCandidate.getMcTrackId();
90 if (mcParticleID >= 0 and m_MCParticles.isOptional() and m_MCParticles.getEntries() > 0) {
91 MCParticle* relatedMCParticle = m_MCParticles[mcParticleID];
92 if (relatedMCParticle) {
93 newRecoTrack->addRelationTo(relatedMCParticle);
94 } else {
95 B2WARNING("Related MCParticle is invalid. Can not make a relation.");
96 }
97 }
98 }
99}
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
std::string m_param_bklmHitsStoreArrayName
StoreArray name of the BKLM hits.
std::string m_param_pxdHitsStoreArrayName
StoreArray name of the PXD hits.
void initialize() override
Initialize the needed StoreArrays and ensure they are created properly.
void event() override
Loop over all track candidates and create a recotrack.
std::string m_param_eklmHitsStoreArrayName
StoreArray name of the EKLM hits.
std::string m_param_recoTracksStoreArrayName
StoreArray name of the input and output reco tracks.
std::string m_param_svdHitsStoreArrayName
StoreArray name of the SVD hits.
std::string m_param_cdcHitsStoreArrayName
StoreArray name of the CDC hits.
RecoTrackCreatorModule()
Initilialize the module parameters.
std::string m_param_recoHitInformationStoreArrayName
StoreArray name of the output reco hit information.
StoreArray< RecoTrack > m_RecoTracks
RecoTracks StoreArray.
std::string m_param_trackCandidatesStoreArrayName
StoreArray name of the input track candidates.
StoreArray< MCParticle > m_MCParticles
MCParticles StoreArray.
StoreArray< genfit::TrackCand > m_TrackCandidates
genfit::TrackCand StoreArray
bool m_param_recreateSortingParameters
Flag to recreate the sorting parameters of the hit out of the stored order.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
static RecoTrack * createFromTrackCand(const genfit::TrackCand &trackCand, const std::string &storeArrayNameOfRecoTracks="", const std::string &storeArrayNameOfPXDHits="", const std::string &storeArrayNameOfSVDHits="", const std::string &storeArrayNameOfCDCHits="", const std::string &storeArrayNameOfBKLMHits="", const std::string &storeArrayNameOfEKLMHits="", const std::string &storeArrayNameOfRecoHitInformation="", const bool recreateSortingParameters=false)
Create a reco track from a genfit::TrackCand and save it to the given store array.
Definition: RecoTrack.cc:97
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.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
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
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.