ATLAS Offline Software
Loading...
Searching...
No Matches
CP::MVATrackVertexAssociationTool Class Reference

#include <MVATrackVertexAssociationTool.h>

Inheritance diagram for CP::MVATrackVertexAssociationTool:
Collaboration diagram for CP::MVATrackVertexAssociationTool:

Public Member Functions

 MVATrackVertexAssociationTool (const std::string &name)
virtual StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual bool isCompatible (const xAOD::TrackParticle &trk, const xAOD::Vertex &vx) const override
 This function just return the decision of whether the track is matched to the Vertex Not sure whether the track is matched to best choice.
virtual bool isCompatible (const xAOD::TrackParticle &trk) const override
virtual xAOD::TrackVertexAssociationMap getMatchMap (std::vector< const xAOD::TrackParticle * > &trk_list, std::vector< const xAOD::Vertex * > &vx_list) const override
virtual xAOD::TrackVertexAssociationMap getMatchMap (const xAOD::TrackParticleContainer &trk_cont, const xAOD::VertexContainer &vx_cont) const override
virtual ElementLink< xAOD::VertexContainergetUniqueMatchVertexLink (const xAOD::TrackParticle &trk, const xAOD::VertexContainer &vx_cont) const override
 This functions will return the best matched vertex.
virtual const xAOD::VertexgetUniqueMatchVertex (const xAOD::TrackParticle &trk, std::vector< const xAOD::Vertex * > &vx_list) const override
virtual xAOD::TrackVertexAssociationMap getUniqueMatchMap (std::vector< const xAOD::TrackParticle * > &trk_list, std::vector< const xAOD::Vertex * > &vx_list) const override
 This functions related to the previous functions, will return a 2D vector to store the best matched tracks for each vertex.
virtual xAOD::TrackVertexAssociationMap getUniqueMatchMap (const xAOD::TrackParticleContainer &trk_cont, const xAOD::VertexContainer &vx_cont) const override
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

bool isMatch (const xAOD::TrackParticle &trk, const xAOD::Vertex &vx, float &mvaOutput, const xAOD::EventInfo *evtInfo=nullptr) const
template<typename T, typename V>
xAOD::TrackVertexAssociationMap getMatchMapInternal (const T &trk_list, const V &vx_list) const
template<typename T, typename V>
xAOD::TrackVertexAssociationMap getUniqueMatchMapInternal (const T &trk_list, const V &vx_list) const
template<typename T>
const xAOD::VertexgetUniqueMatchVertexInternal (const xAOD::TrackParticle &trk, const T &vx_list) const
StatusCode initializeNetwork ()
float evaluateNetwork (const xAOD::TrackParticle &trk, const xAOD::Vertex &vx, const xAOD::EventInfo &evt) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared
The properties that can be defined via the python job options
Gaudi::Property< std::string > m_fileName {this, "NetworkFileName", "" }
 Input lwtnn network file.
Gaudi::Property< std::vector< std::string > > m_inputNames
 Vector of input variable names.
Gaudi::Property< std::vector< int > > m_inputTypes
 Vector of input variable types.
Gaudi::Property< std::string > m_outputName
 Name of the output node to cut on.
Gaudi::Property< boolm_isSequential
 Is the network sequential or functional.
Gaudi::Property< std::string > m_wp {this, "WorkingPoint", "Tight", "TVA working point to apply."}
 TVA working point.
Gaudi::Property< floatm_cut
 TVA cut value on the output discriminant.
Gaudi::Property< boolm_usePathResolver
 Use the PathResolver to find our input file.
Gaudi::Property< std::string > m_hardScatterDeco
 The decoration name of the ElementLink to the hardscatter vertex (found on xAOD::EventInfo)
Truly private internal data members
MVAInputEvaluator::InputSelectionMap m_inputMap
 Input variable name/type map.
MVAInputEvaluator m_inputEval
 Input variable evaluator.
SG::ReadHandleKey< xAOD::EventInfom_eventInfo {this, "EventInfo", "EventInfo", "EventInfo key"}
 EventInfo key.
SG::ReadDecorHandleKey< xAOD::EventInfom_hardScatterDecoKey
 Hardscatter vertex link key.
std::string m_inputNodeName = ""
 Name of the input node (for functional modes)
std::unique_ptr< lwt::LightweightNeuralNetwork > m_network
 Network as implemented using lwtnn.
std::unique_ptr< lwt::LightweightGraph > m_graph

Detailed Description

Definition at line 36 of file MVATrackVertexAssociationTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MVATrackVertexAssociationTool()

CP::MVATrackVertexAssociationTool::MVATrackVertexAssociationTool ( const std::string & name)

Definition at line 36 of file MVATrackVertexAssociationTool.cxx.

36 :
37 AsgTool(name) {}
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evaluateNetwork()

float CP::MVATrackVertexAssociationTool::evaluateNetwork ( const xAOD::TrackParticle & trk,
const xAOD::Vertex & vx,
const xAOD::EventInfo & evt ) const
private

Definition at line 276 of file MVATrackVertexAssociationTool.cxx.

276 {
277
278 // Evaluate our inputs
279 std::map<std::string, double> input;
280 m_inputEval.eval(trk, vx, evt, input);
281
282 // Evaluate our network
283 std::map<std::string, double> output;
284 // For sequential:
285 if (m_isSequential) {
286 output = m_network->compute(input);
287 }
288 // For functional:
289 else {
290 std::map<std::string, std::map<std::string, double>> wrappedInput;
291 wrappedInput[m_inputNodeName] = input;
292 output = m_graph->compute(wrappedInput);
293 }
294
295 return output[m_outputName];
296}
std::unique_ptr< lwt::LightweightGraph > m_graph
Gaudi::Property< std::string > m_outputName
Name of the output node to cut on.
std::string m_inputNodeName
Name of the input node (for functional modes)
Gaudi::Property< bool > m_isSequential
Is the network sequential or functional.
MVAInputEvaluator m_inputEval
Input variable evaluator.
std::unique_ptr< lwt::LightweightNeuralNetwork > m_network
Network as implemented using lwtnn.
output
Definition merge.py:16

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::TEvent, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getMatchMap() [1/2]

xAOD::TrackVertexAssociationMap CP::MVATrackVertexAssociationTool::getMatchMap ( const xAOD::TrackParticleContainer & trk_cont,
const xAOD::VertexContainer & vx_cont ) const
overridevirtual

Implements CP::ITrackVertexAssociationTool.

Definition at line 101 of file MVATrackVertexAssociationTool.cxx.

101 {
102 return getMatchMapInternal(trkCont, vxCont);
103}
xAOD::TrackVertexAssociationMap getMatchMapInternal(const T &trk_list, const V &vx_list) const

◆ getMatchMap() [2/2]

xAOD::TrackVertexAssociationMap CP::MVATrackVertexAssociationTool::getMatchMap ( std::vector< const xAOD::TrackParticle * > & trk_list,
std::vector< const xAOD::Vertex * > & vx_list ) const
overridevirtual

Implements CP::ITrackVertexAssociationTool.

Definition at line 97 of file MVATrackVertexAssociationTool.cxx.

97 {
98 return getMatchMapInternal(trk_list, vx_list);
99}

◆ getMatchMapInternal()

template<typename T, typename V>
xAOD::TrackVertexAssociationMap CP::MVATrackVertexAssociationTool::getMatchMapInternal ( const T & trk_list,
const V & vx_list ) const
private

Definition at line 158 of file MVATrackVertexAssociationTool.cxx.

158 {
159
161
162 for (const auto *vertex : vx_list) {
164 trktovxlist.clear();
165 trktovxlist.reserve(trk_list.size());
166 for (const auto *track : trk_list) {
167 if (isCompatible(*track, *vertex)) {
168 trktovxlist.push_back(track);
169 }
170 }
171 trktovxmap[vertex] = trktovxlist;
172 }
173
174 return trktovxmap;
175}
virtual bool isCompatible(const xAOD::TrackParticle &trk, const xAOD::Vertex &vx) const override
This function just return the decision of whether the track is matched to the Vertex Not sure whether...
std::vector< const xAOD::TrackParticle * > TrackVertexAssociationList
std::map< const xAOD::Vertex *, xAOD::TrackVertexAssociationList > TrackVertexAssociationMap

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::TEvent, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getUniqueMatchMap() [1/2]

xAOD::TrackVertexAssociationMap CP::MVATrackVertexAssociationTool::getUniqueMatchMap ( const xAOD::TrackParticleContainer & trk_cont,
const xAOD::VertexContainer & vx_cont ) const
overridevirtual

Implements CP::ITrackVertexAssociationTool.

Definition at line 122 of file MVATrackVertexAssociationTool.cxx.

122 {
123 return getUniqueMatchMapInternal(trkCont, vxCont);
124}
xAOD::TrackVertexAssociationMap getUniqueMatchMapInternal(const T &trk_list, const V &vx_list) const

◆ getUniqueMatchMap() [2/2]

xAOD::TrackVertexAssociationMap CP::MVATrackVertexAssociationTool::getUniqueMatchMap ( std::vector< const xAOD::TrackParticle * > & trk_list,
std::vector< const xAOD::Vertex * > & vx_list ) const
overridevirtual

This functions related to the previous functions, will return a 2D vector to store the best matched tracks for each vertex.

Implements CP::ITrackVertexAssociationTool.

Definition at line 118 of file MVATrackVertexAssociationTool.cxx.

118 {
119 return getUniqueMatchMapInternal(trk_list, vx_list);
120}

◆ getUniqueMatchMapInternal()

template<typename T, typename V>
xAOD::TrackVertexAssociationMap CP::MVATrackVertexAssociationTool::getUniqueMatchMapInternal ( const T & trk_list,
const V & vx_list ) const
private

Definition at line 202 of file MVATrackVertexAssociationTool.cxx.

202 {
203
205
206 // Initialize map
207 for (const auto *vertex : vx_list) {
209 trktovxlist.clear();
210 trktovxlist.reserve(trk_list.size());
211 trktovxmap[vertex] = trktovxlist;
212 }
213
214 // Perform matching
215 for (const auto *track : trk_list) {
216 const xAOD::Vertex* vx_match = getUniqueMatchVertexInternal(*track, vx_list);
217 if (vx_match) {
218 // Found matched vertex
219 trktovxmap[vx_match].push_back(track);
220 }
221 }
222
223 return trktovxmap;
224}
const xAOD::Vertex * getUniqueMatchVertexInternal(const xAOD::TrackParticle &trk, const T &vx_list) const
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ getUniqueMatchVertex()

const xAOD::Vertex * CP::MVATrackVertexAssociationTool::getUniqueMatchVertex ( const xAOD::TrackParticle & trk,
std::vector< const xAOD::Vertex * > & vx_list ) const
overridevirtual

Implements CP::ITrackVertexAssociationTool.

Definition at line 105 of file MVATrackVertexAssociationTool.cxx.

105 {
106 return getUniqueMatchVertexInternal(trk, vx_list);
107}

◆ getUniqueMatchVertexInternal()

template<typename T>
const xAOD::Vertex * CP::MVATrackVertexAssociationTool::getUniqueMatchVertexInternal ( const xAOD::TrackParticle & trk,
const T & vx_list ) const
private

Definition at line 178 of file MVATrackVertexAssociationTool.cxx.

178 {
179
180 bool match;
181 float mvaOutput;
182 float maxValue = -1.0; // MVA output ranges between 0 and 1
183 const xAOD::Vertex* bestMatchVertex = nullptr;
184
185 for (const auto *vertex : vx_list) {
186 match = isMatch(trk, *vertex, mvaOutput);
187 if (match && (maxValue < mvaOutput)) {
188 maxValue = mvaOutput;
189 bestMatchVertex = vertex;
190 }
191 }
192
193 // check if get the matched Vertex, for the tracks not used in vertex fit
194 if (!bestMatchVertex) {
195 ATH_MSG_DEBUG("Could not find any matched vertex for this track.");
196 }
197
198 return bestMatchVertex;
199}
#define ATH_MSG_DEBUG(x)
#define maxValue(current, test)
bool isMatch(const xAOD::TrackParticle &trk, const xAOD::Vertex &vx, float &mvaOutput, const xAOD::EventInfo *evtInfo=nullptr) const
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357

◆ getUniqueMatchVertexLink()

ElementLink< xAOD::VertexContainer > CP::MVATrackVertexAssociationTool::getUniqueMatchVertexLink ( const xAOD::TrackParticle & trk,
const xAOD::VertexContainer & vxCont ) const
overridevirtual

This functions will return the best matched vertex.

Implements CP::ITrackVertexAssociationTool.

Definition at line 109 of file MVATrackVertexAssociationTool.cxx.

109 {
110 ElementLink<xAOD::VertexContainer> vx_link_tmp;
111 const xAOD::Vertex* vx_tmp = getUniqueMatchVertexInternal(trk, vxCont);
112 if (vx_tmp) {
113 vx_link_tmp.toContainedElement(vxCont, vx_tmp);
114 }
115 return vx_link_tmp;
116}

◆ initialize()

StatusCode CP::MVATrackVertexAssociationTool::initialize ( void )
overridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 39 of file MVATrackVertexAssociationTool.cxx.

39 {
40
41 // Init EventInfo and hardscatter vertex link deco
42 ATH_CHECK(m_eventInfo.initialize());
44 ATH_CHECK(m_hardScatterDecoKey.initialize());
45
46 // Init network
47 StatusCode initNetworkStatus = initializeNetwork();
48 if (initNetworkStatus != StatusCode::SUCCESS) {
49 return initNetworkStatus;
50 }
51
52 // Map our working point to a cut on the MVA output discriminant
53 if (m_wp == "Tight") {
54 m_cut = 0.85;
55 }
56 else if (m_wp == "Custom") {
57 // Nothing to do here
58 }
59 else {
60 ATH_MSG_ERROR("Invalid TVA working point \"" << m_wp << "\" - for a custom configuration, please provide \"Custom\" for the \"WorkingPoint\" property.");
61 return StatusCode::FAILURE;
62 }
63
64 // Some extra printout for Custom
65 if (m_wp == "Custom") {
66 ATH_MSG_INFO("TVA working point \"Custom\" provided - tool properties are initialized to default values unless explicitly set by the user.");
67 }
68 else {
69 ATH_MSG_INFO("TVA working point \"" << m_wp << "\" provided - tool properties have been configured accordingly.");
70 }
71
72 ATH_MSG_DEBUG("Cut on MVA output discriminant: " << m_cut);
73
74 return StatusCode::SUCCESS;
75}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Gaudi::Property< std::string > m_wp
TVA working point.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
EventInfo key.
Gaudi::Property< std::string > m_hardScatterDeco
The decoration name of the ElementLink to the hardscatter vertex (found on xAOD::EventInfo)
Gaudi::Property< float > m_cut
TVA cut value on the output discriminant.
SG::ReadDecorHandleKey< xAOD::EventInfo > m_hardScatterDecoKey
Hardscatter vertex link key.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ initializeNetwork()

StatusCode CP::MVATrackVertexAssociationTool::initializeNetwork ( )
private

Definition at line 226 of file MVATrackVertexAssociationTool.cxx.

226 {
227
228 // Load our input evaluator
229 if (m_inputNames.size() != m_inputTypes.size()) {
230 ATH_MSG_ERROR("Size of input variable names (" + std::to_string(m_inputNames.size()) + ") does not equal size of input variable types (" + std::to_string(m_inputTypes.size()) + ").");
231 return StatusCode::FAILURE;
232 }
233 m_inputMap.clear();
234 for (std::size_t i = 0; i < m_inputNames.size(); i++) {
236 }
238
239 // Load our input file
240 std::string fileName;
241 if (m_usePathResolver) {
243 if (fileName.empty()) {
244 ATH_MSG_ERROR("Could not find input network file: " + m_fileName);
245 return StatusCode::FAILURE;
246 }
247 }
248 else {
250 }
251 std::ifstream netFile(fileName);
252 if (!netFile) {
253 ATH_MSG_ERROR("Could not properly open input network file: " + fileName);
254 return StatusCode::FAILURE;
255 }
256
257 // For sequential:
258 if (m_isSequential) {
259 lwt::JSONConfig netDef = lwt::parse_json(netFile);
260 m_network = std::make_unique<lwt::LightweightNeuralNetwork>(netDef.inputs, netDef.layers, netDef.outputs);
261 }
262 // For functional:
263 else {
264 lwt::GraphConfig netDef = lwt::parse_json_graph(netFile);
265 if (netDef.inputs.size() != 1) {
266 ATH_MSG_ERROR("Network in file \"" + fileName + "\" has more than 1 input node: # of input nodes = " + std::to_string(netDef.inputs.size()));
267 return StatusCode::FAILURE;
268 }
269 m_inputNodeName = netDef.inputs[0].name;
270 m_graph = std::make_unique<lwt::LightweightGraph>(netDef);
271 }
272
273 return StatusCode::SUCCESS;
274}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Property< std::vector< int > > m_inputTypes
Vector of input variable types.
Gaudi::Property< bool > m_usePathResolver
Use the PathResolver to find our input file.
Gaudi::Property< std::vector< std::string > > m_inputNames
Vector of input variable names.
Gaudi::Property< std::string > m_fileName
Input lwtnn network file.
MVAInputEvaluator::InputSelectionMap m_inputMap
Input variable name/type map.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isCompatible() [1/2]

bool CP::MVATrackVertexAssociationTool::isCompatible ( const xAOD::TrackParticle & trk) const
overridevirtual

Implements CP::ITrackVertexAssociationTool.

Definition at line 82 of file MVATrackVertexAssociationTool.cxx.

82 {
83 const EventContext& ctx = Gaudi::Hive::currentContext();
84 SG::ReadHandle<xAOD::EventInfo> evt(m_eventInfo, ctx);
85 if (!evt.isValid()) {
86 throw std::runtime_error("ERROR in CP::MVATrackVertexAssociationTool::isCompatible : could not retrieve xAOD::EventInfo!");
87 }
88 SG::ReadDecorHandle<xAOD::EventInfo, ElementLink<xAOD::VertexContainer>> hardScatterDeco(m_hardScatterDecoKey, ctx);
89 const ElementLink<xAOD::VertexContainer>& vtxLink = hardScatterDeco(*evt);
90 if (!vtxLink.isValid()) {
91 throw std::runtime_error("ERROR in CP::MVATrackVertexAssociationTool::isCompatible : hardscatter vertex link is not valid!");
92 }
93 float mvaOutput = -1.;
94 return isMatch(trk, **vtxLink, mvaOutput, evt.get());
95}

◆ isCompatible() [2/2]

bool CP::MVATrackVertexAssociationTool::isCompatible ( const xAOD::TrackParticle & trk,
const xAOD::Vertex & vx ) const
overridevirtual

This function just return the decision of whether the track is matched to the Vertex Not sure whether the track is matched to best choice.

Implements CP::ITrackVertexAssociationTool.

Definition at line 77 of file MVATrackVertexAssociationTool.cxx.

77 {
78 float mvaOutput = -1.;
79 return isMatch(trk, vx, mvaOutput);
80}

◆ isMatch()

bool CP::MVATrackVertexAssociationTool::isMatch ( const xAOD::TrackParticle & trk,
const xAOD::Vertex & vx,
float & mvaOutput,
const xAOD::EventInfo * evtInfo = nullptr ) const
private

Definition at line 130 of file MVATrackVertexAssociationTool.cxx.

130 {
131
132 const EventContext& ctx = Gaudi::Hive::currentContext();
133
134 // Fake vertex, return false
135 if (vx.vertexType() == xAOD::VxType::NoVtx) {
136 return false;
137 }
138
139 // Retrieve our EventInfo
140 const xAOD::EventInfo* evt = nullptr;
141 if (!evtInfo) {
142 SG::ReadHandle<xAOD::EventInfo> evttmp(m_eventInfo, ctx);
143 if (!evttmp.isValid()) {
144 throw std::runtime_error("ERROR in CP::MVATrackVertexAssociationTool::isMatch : could not retrieve xAOD::EventInfo!");
145 }
146 evt = evttmp.get();
147 }
148 else {
149 evt = evtInfo;
150 }
151
152 // Evaluate our network and compare against our TVA cut (">= cut" := associated)
153 mvaOutput = this->evaluateNetwork(trk, vx, *evt);
154 return (mvaOutput >= m_cut);
155}
float evaluateNetwork(const xAOD::TrackParticle &trk, const xAOD::Vertex &vx, const xAOD::EventInfo &evt) const
VxType::VertexType vertexType() const
The type of the vertex.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_cut

Gaudi::Property<float> CP::MVATrackVertexAssociationTool::m_cut
private
Initial value:
{this, "OutputCut" , -1.0,
"TVA cut value on the output value (set manually with \"Custom\" WP)."}

TVA cut value on the output discriminant.

Definition at line 111 of file MVATrackVertexAssociationTool.h.

111 {this, "OutputCut" , -1.0,
112 "TVA cut value on the output value (set manually with \"Custom\" WP)."};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_eventInfo

SG::ReadHandleKey<xAOD::EventInfo> CP::MVATrackVertexAssociationTool::m_eventInfo {this, "EventInfo", "EventInfo", "EventInfo key"}
private

EventInfo key.

Definition at line 136 of file MVATrackVertexAssociationTool.h.

136{this, "EventInfo", "EventInfo", "EventInfo key"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_fileName

Gaudi::Property<std::string> CP::MVATrackVertexAssociationTool::m_fileName {this, "NetworkFileName", "" }
private

Input lwtnn network file.

Definition at line 89 of file MVATrackVertexAssociationTool.h.

89{this, "NetworkFileName", "" };

◆ m_graph

std::unique_ptr<lwt::LightweightGraph> CP::MVATrackVertexAssociationTool::m_graph
private

Definition at line 147 of file MVATrackVertexAssociationTool.h.

◆ m_hardScatterDeco

Gaudi::Property<std::string> CP::MVATrackVertexAssociationTool::m_hardScatterDeco
private
Initial value:
{this, "HardScatterLinkDeco", "hardScatterVertexLink",
"The decoration name of the ElementLink to the hardscatter vertex (found on xAOD::EventInfo)"}

The decoration name of the ElementLink to the hardscatter vertex (found on xAOD::EventInfo)

Definition at line 119 of file MVATrackVertexAssociationTool.h.

119 {this, "HardScatterLinkDeco", "hardScatterVertexLink",
120 "The decoration name of the ElementLink to the hardscatter vertex (found on xAOD::EventInfo)"};

◆ m_hardScatterDecoKey

SG::ReadDecorHandleKey<xAOD::EventInfo> CP::MVATrackVertexAssociationTool::m_hardScatterDecoKey
private
Initial value:
{this, "VertexScatterKey", "" ,
"Overwrriten in the configuration step by the <HardScatterLinkDeco> property"}

Hardscatter vertex link key.

Definition at line 139 of file MVATrackVertexAssociationTool.h.

139 {this, "VertexScatterKey", "" ,
140 "Overwrriten in the configuration step by the <HardScatterLinkDeco> property"};

◆ m_inputEval

MVAInputEvaluator CP::MVATrackVertexAssociationTool::m_inputEval
private

Input variable evaluator.

Definition at line 133 of file MVATrackVertexAssociationTool.h.

◆ m_inputMap

MVAInputEvaluator::InputSelectionMap CP::MVATrackVertexAssociationTool::m_inputMap
private

Input variable name/type map.

Definition at line 130 of file MVATrackVertexAssociationTool.h.

◆ m_inputNames

Gaudi::Property<std::vector<std::string> > CP::MVATrackVertexAssociationTool::m_inputNames
private
Initial value:
{this, "InputNames", {},
"Vector of the network's input variable names (std::vector<std::string>)." }

Vector of input variable names.

Definition at line 92 of file MVATrackVertexAssociationTool.h.

92 {this, "InputNames", {},
93 "Vector of the network's input variable names (std::vector<std::string>)." };

◆ m_inputNodeName

std::string CP::MVATrackVertexAssociationTool::m_inputNodeName = ""
private

Name of the input node (for functional modes)

Definition at line 143 of file MVATrackVertexAssociationTool.h.

◆ m_inputTypes

Gaudi::Property<std::vector<int> > CP::MVATrackVertexAssociationTool::m_inputTypes
private
Initial value:
{this,"InputTypes", {},
"Vector of the network's input variable evaluator types (std::vector<CP::MVAEvaluatorInput::Input>)."}

Vector of input variable types.

Definition at line 96 of file MVATrackVertexAssociationTool.h.

96 {this,"InputTypes", {},
97 "Vector of the network's input variable evaluator types (std::vector<CP::MVAEvaluatorInput::Input>)."};

◆ m_isSequential

Gaudi::Property<bool> CP::MVATrackVertexAssociationTool::m_isSequential
private
Initial value:
{this, "IsSequential", true,
"Is the network sequential (true) or functional (false)."}

Is the network sequential or functional.

Definition at line 104 of file MVATrackVertexAssociationTool.h.

104 {this, "IsSequential", true,
105 "Is the network sequential (true) or functional (false)."};

◆ m_network

std::unique_ptr<lwt::LightweightNeuralNetwork> CP::MVATrackVertexAssociationTool::m_network
private

Network as implemented using lwtnn.

Definition at line 146 of file MVATrackVertexAssociationTool.h.

◆ m_outputName

Gaudi::Property<std::string> CP::MVATrackVertexAssociationTool::m_outputName
private
Initial value:
{this, "OutputNodeName", "",
"Name of the output node to cut on for TVA."}

Name of the output node to cut on.

Definition at line 100 of file MVATrackVertexAssociationTool.h.

100 {this, "OutputNodeName", "",
101 "Name of the output node to cut on for TVA."} ;

◆ m_usePathResolver

Gaudi::Property<bool> CP::MVATrackVertexAssociationTool::m_usePathResolver
private
Initial value:
{this, "UsePathResolver", true,
"Use the PathResolver for finding the input lwtnn network file."}

Use the PathResolver to find our input file.

Definition at line 115 of file MVATrackVertexAssociationTool.h.

115 {this, "UsePathResolver", true,
116 "Use the PathResolver for finding the input lwtnn network file."};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_wp

Gaudi::Property<std::string> CP::MVATrackVertexAssociationTool::m_wp {this, "WorkingPoint", "Tight", "TVA working point to apply."}
private

TVA working point.

Definition at line 108 of file MVATrackVertexAssociationTool.h.

108{this, "WorkingPoint", "Tight", "TVA working point to apply."};

The documentation for this class was generated from the following files: