Belle II Software  release-05-01-25
TrackQualityEstimatorMVAModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Sebastian Racs, Michael Eliachevitch *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/modules/trackQualityEstimator/TrackQualityEstimatorMVAModule.h>
12 
13 using namespace Belle2;
14 
15 
16 REG_MODULE(TrackQualityEstimatorMVA);
17 
19 {
20  //Set module properties
21  setDescription("The quality estimator module for a fully reconstructed track");
23 
24  addParam("recoTracksStoreArrayName",
26  "Name of the recoTrack StoreArray.",
28 
29  addParam("SVDCDCRecoTracksStoreArrayName",
31  "Name of the SVD-CDC StoreArray.",
33 
34  addParam("CDCRecoTracksStoreArrayName",
36  "Name of the CDC StoreArray.",
38 
39  addParam("SVDRecoTracksStoreArrayName",
41  "Name of the SVD StoreArray.",
43 
44  addParam("PXDRecoTracksStoreArrayName",
46  "Name of the PXD StoreArray.",
48 
49  addParam("TracksStoreArrayName",
51  "Name of the fitted mdst Tracks StoreArray.",
53 
54  addParam("WeightFileIdentifier",
56  "Identifier of weightfile in Database or local root/xml file.",
58 
59  addParam("collectEventFeatures",
61  "Whether to use eventwise features.",
63 }
64 
66 {
68 
70  m_eventInfoExtractor = std::make_unique<EventInfoExtractor>(m_variableSet);
71  }
72  m_recoTrackExtractor = std::make_unique<RecoTrackExtractor>(m_variableSet);
73  m_subRecoTrackExtractor = std::make_unique<SubRecoTrackExtractor>(m_variableSet);
74  m_hitInfoExtractor = std::make_unique<HitInfoExtractor>(m_variableSet);
75 
76  m_mvaExpert = std::make_unique<MVAExpert>(m_weightFileIdentifier, m_variableSet);
77  m_mvaExpert->initialize();
78 }
79 
81 {
82  m_mvaExpert->beginRun();
83 }
84 
86 {
87  for (RecoTrack& recoTrack : m_recoTracks) {
88  const RecoTrack* pxdRecoTrack = recoTrack.getRelatedTo<RecoTrack>(m_pxdRecoTracksStoreArrayName);
89  const RecoTrack* svdcdcRecoTrack =
91  RecoTrack* cdcRecoTrack{nullptr};
92  RecoTrack* svdRecoTrack{nullptr};
93  if (svdcdcRecoTrack) {
94  cdcRecoTrack = svdcdcRecoTrack->getRelatedTo<RecoTrack>(m_cdcRecoTracksStoreArrayName);
95  svdRecoTrack = svdcdcRecoTrack->getRelatedTo<RecoTrack>(m_svdRecoTracksStoreArrayName);
96  }
97 
99  m_eventInfoExtractor->extractVariables(m_recoTracks, recoTrack);
100  }
101  m_recoTrackExtractor->extractVariables(recoTrack);
102  m_subRecoTrackExtractor->extractVariables(cdcRecoTrack, svdRecoTrack, pxdRecoTrack);
103  m_hitInfoExtractor->extractVariables(recoTrack);
104  // get quality indicator from classifier
105  const float qualityIndicator = m_mvaExpert->predict();
106  // set quality indicator property in RecoTracks and mdst Tracks from track fit
107  recoTrack.setQualityIndicator(qualityIndicator);
108  }
109 }
Belle2::TrackQualityEstimatorMVAModule::initialize
void initialize() override
Initializes the Module.
Definition: TrackQualityEstimatorMVAModule.cc:65
Belle2::TrackQualityEstimatorMVAModule::m_recoTrackExtractor
std::unique_ptr< RecoTrackExtractor > m_recoTrackExtractor
pointer to object that extracts info from the root RecoTrack
Definition: TrackQualityEstimatorMVAModule.h:91
Belle2::TrackQualityEstimatorMVAModule::m_eventInfoExtractor
std::unique_ptr< EventInfoExtractor > m_eventInfoExtractor
pointer to object that extracts info from the whole event
Definition: TrackQualityEstimatorMVAModule.h:89
Belle2::TrackQualityEstimatorMVAModule::beginRun
void beginRun() override
Launches mvaExpert and sets the magnetic field strength.
Definition: TrackQualityEstimatorMVAModule.cc:80
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::TrackQualityEstimatorMVAModule::m_hitInfoExtractor
std::unique_ptr< HitInfoExtractor > m_hitInfoExtractor
pointer to object that extracts info from the hits within the RecoTrack
Definition: TrackQualityEstimatorMVAModule.h:95
Belle2::TrackQualityEstimatorMVAModule::m_weightFileIdentifier
std::string m_weightFileIdentifier
identifier of weightfile in Database or local root/xml file
Definition: TrackQualityEstimatorMVAModule.h:77
Belle2::TrackQualityEstimatorMVAModule::m_tracksStoreArrayName
std::string m_tracksStoreArrayName
Name of the StoreArray with mdst Tracks from track fit.
Definition: TrackQualityEstimatorMVAModule.h:74
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ 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:82
Belle2::RelationsInterface::getRelatedTo
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
Definition: RelationsObject.h:250
Belle2::TrackQualityEstimatorMVAModule::m_variableSet
std::vector< Named< float * > > m_variableSet
set of named variables to be used in MVA
Definition: TrackQualityEstimatorMVAModule.h:98
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::TrackQualityEstimatorMVAModule::m_svdRecoTracksStoreArrayName
std::string m_svdRecoTracksStoreArrayName
Name of the SVD StoreArray.
Definition: TrackQualityEstimatorMVAModule.h:70
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackQualityEstimatorMVAModule::m_collectEventFeatures
bool m_collectEventFeatures
Parameter to enable event-wise features.
Definition: TrackQualityEstimatorMVAModule.h:80
Belle2::TrackQualityEstimatorMVAModule::m_cdcRecoTracksStoreArrayName
std::string m_cdcRecoTracksStoreArrayName
Name of the CDC StoreArray.
Definition: TrackQualityEstimatorMVAModule.h:68
Belle2::TrackQualityEstimatorMVAModule::m_subRecoTrackExtractor
std::unique_ptr< SubRecoTrackExtractor > m_subRecoTrackExtractor
pointer to object that extracts info from the related sub RecoTracks
Definition: TrackQualityEstimatorMVAModule.h:93
Belle2::Module::addParam
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:562
Belle2::TrackQualityEstimatorMVAModule::m_svdcdcRecoTracksStoreArrayName
std::string m_svdcdcRecoTracksStoreArrayName
Name of the SVD-CDC StoreArray.
Definition: TrackQualityEstimatorMVAModule.h:66
Belle2::TrackQualityEstimatorMVAModule::m_recoTracks
StoreArray< RecoTrack > m_recoTracks
Store Array of the recoTracks.
Definition: TrackQualityEstimatorMVAModule.h:83
Belle2::TrackQualityEstimatorMVAModule::m_pxdRecoTracksStoreArrayName
std::string m_pxdRecoTracksStoreArrayName
Name of the PXD StoreArray.
Definition: TrackQualityEstimatorMVAModule.h:72
Belle2::TrackQualityEstimatorMVAModule::m_recoTracksStoreArrayName
std::string m_recoTracksStoreArrayName
Name of the recoTrack StoreArray.
Definition: TrackQualityEstimatorMVAModule.h:64
Belle2::TrackQualityEstimatorMVAModule::event
void event() override
Applies the selected quality estimation method for a given set of TCs.
Definition: TrackQualityEstimatorMVAModule.cc:85
Belle2::TrackQualityEstimatorMVAModule::TrackQualityEstimatorMVAModule
TrackQualityEstimatorMVAModule()
Constructor of the module.
Definition: TrackQualityEstimatorMVAModule.cc:18
Belle2::TrackQualityEstimatorMVAModule::m_mvaExpert
std::unique_ptr< MVAExpert > m_mvaExpert
pointer to the object to interact with the MVA package
Definition: TrackQualityEstimatorMVAModule.h:86