Belle II Software development
TrackQualityEstimatorMVAModule.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/trackQualityEstimator/TrackQualityEstimatorMVAModule.h>
10
11using namespace Belle2;
12
13
14REG_MODULE(TrackQualityEstimatorMVA);
15
17{
18 //Set module properties
19 setDescription("The quality estimator module for a fully reconstructed track");
21
22 addParam("recoTracksStoreArrayName",
24 "Name of the recoTrack StoreArray.",
26
27 addParam("SVDCDCRecoTracksStoreArrayName",
29 "Name of the SVD-CDC StoreArray.",
31
32 addParam("CDCRecoTracksStoreArrayName",
34 "Name of the CDC StoreArray.",
36
37 addParam("SVDRecoTracksStoreArrayName",
39 "Name of the SVD StoreArray.",
41
42 addParam("PXDRecoTracksStoreArrayName",
44 "Name of the PXD StoreArray.",
46
47 addParam("TracksStoreArrayName",
49 "Name of the fitted mdst Tracks StoreArray.",
51
52 addParam("WeightFileIdentifier",
54 "Identifier of weightfile in Database or local root/xml file.",
56
57 addParam("collectEventFeatures",
59 "Whether to use eventwise features.",
61}
62
64{
66
68 m_eventInfoExtractor = std::make_unique<EventInfoExtractor>(m_variableSet);
69 }
70 m_recoTrackExtractor = std::make_unique<RecoTrackExtractor>(m_variableSet);
71 m_subRecoTrackExtractor = std::make_unique<SubRecoTrackExtractor>(m_variableSet);
72 m_hitInfoExtractor = std::make_unique<HitInfoExtractor>(m_variableSet);
73
74 m_mvaExpert = std::make_unique<MVAExpert>(m_weightFileIdentifier, m_variableSet);
75 m_mvaExpert->initialize();
76}
77
79{
80 m_mvaExpert->beginRun();
81}
82
84{
85 for (RecoTrack& recoTrack : m_recoTracks) {
86 const RecoTrack* pxdRecoTrack = recoTrack.getRelatedTo<RecoTrack>(m_pxdRecoTracksStoreArrayName);
87 const RecoTrack* svdcdcRecoTrack =
89 RecoTrack* cdcRecoTrack{nullptr};
90 RecoTrack* svdRecoTrack{nullptr};
91 if (svdcdcRecoTrack) {
92 cdcRecoTrack = svdcdcRecoTrack->getRelatedTo<RecoTrack>(m_cdcRecoTracksStoreArrayName);
93 svdRecoTrack = svdcdcRecoTrack->getRelatedTo<RecoTrack>(m_svdRecoTracksStoreArrayName);
94 }
95
97 m_eventInfoExtractor->extractVariables(m_recoTracks, recoTrack);
98 }
99 m_recoTrackExtractor->extractVariables(recoTrack);
100 m_subRecoTrackExtractor->extractVariables(cdcRecoTrack, svdRecoTrack, pxdRecoTrack);
101 m_hitInfoExtractor->extractVariables(recoTrack);
102 // get quality indicator from classifier
103 const float qualityIndicator = m_mvaExpert->predict();
104 // set quality indicator property in RecoTracks and mdst Tracks from track fit
105 recoTrack.setQualityIndicator(qualityIndicator);
106 }
107}
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
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
std::unique_ptr< HitInfoExtractor > m_hitInfoExtractor
pointer to object that extracts info from the hits within the RecoTrack
std::unique_ptr< EventInfoExtractor > m_eventInfoExtractor
pointer to object that extracts info from the whole event
void initialize() override
Initializes the Module.
void event() override
Applies the selected quality estimation method for a given set of TCs.
std::string m_svdRecoTracksStoreArrayName
Name of the SVD StoreArray.
std::string m_tracksStoreArrayName
Name of the StoreArray with mdst Tracks from track fit.
std::string m_svdcdcRecoTracksStoreArrayName
Name of the SVD-CDC StoreArray.
bool m_collectEventFeatures
Parameter to enable event-wise features.
std::string m_pxdRecoTracksStoreArrayName
Name of the PXD StoreArray.
std::unique_ptr< MVAExpert > m_mvaExpert
pointer to the object to interact with the MVA package
std::string m_weightFileIdentifier
identifier of weightfile in Database or local root/xml file
void beginRun() override
Launches mvaExpert and sets the magnetic field strength.
std::vector< Named< float * > > m_variableSet
set of named variables to be used in MVA
std::string m_cdcRecoTracksStoreArrayName
Name of the CDC StoreArray.
StoreArray< RecoTrack > m_recoTracks
Store Array of the recoTracks.
std::unique_ptr< RecoTrackExtractor > m_recoTrackExtractor
pointer to object that extracts info from the root RecoTrack
std::string m_recoTracksStoreArrayName
Name of the recoTrack StoreArray.
std::unique_ptr< SubRecoTrackExtractor > m_subRecoTrackExtractor
pointer to object that extracts info from the related sub RecoTracks
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.