9#include "AthLinks/ElementLink.h"
24#include "lwtnn/NNLayerConfig.hh"
25#include "lwtnn/parse_json.hh"
48 if (initNetworkStatus != StatusCode::SUCCESS) {
49 return initNetworkStatus;
53 if (
m_wp ==
"Tight") {
56 else if (
m_wp ==
"Custom") {
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;
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.");
69 ATH_MSG_INFO(
"TVA working point \"" <<
m_wp <<
"\" provided - tool properties have been configured accordingly.");
74 return StatusCode::SUCCESS;
78 float mvaOutput = -1.;
79 return isMatch(trk, vx, mvaOutput);
83 const EventContext& ctx = Gaudi::Hive::currentContext();
86 throw std::runtime_error(
"ERROR in CP::MVATrackVertexAssociationTool::isCompatible : could not retrieve xAOD::EventInfo!");
91 throw std::runtime_error(
"ERROR in CP::MVATrackVertexAssociationTool::isCompatible : hardscatter vertex link is not valid!");
93 float mvaOutput = -1.;
94 return isMatch(trk, **vtxLink, mvaOutput, evt.get());
132 const EventContext& ctx = Gaudi::Hive::currentContext();
144 throw std::runtime_error(
"ERROR in CP::MVATrackVertexAssociationTool::isMatch : could not retrieve xAOD::EventInfo!");
154 return (mvaOutput >=
m_cut);
157template <
typename T,
typename V>
162 for (
const auto *vertex : vx_list) {
165 trktovxlist.reserve(trk_list.size());
166 for (
const auto *
track : trk_list) {
168 trktovxlist.push_back(
track);
171 trktovxmap[vertex] = trktovxlist;
185 for (
const auto *vertex : vx_list) {
189 bestMatchVertex = vertex;
194 if (!bestMatchVertex) {
195 ATH_MSG_DEBUG(
"Could not find any matched vertex for this track.");
198 return bestMatchVertex;
201template <
typename T,
typename V>
207 for (
const auto *vertex : vx_list) {
210 trktovxlist.reserve(trk_list.size());
211 trktovxmap[vertex] = trktovxlist;
215 for (
const auto *
track : trk_list) {
219 trktovxmap[vx_match].push_back(
track);
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;
240 std::string fileName;
243 if (fileName.empty()) {
245 return StatusCode::FAILURE;
251 std::ifstream netFile(fileName);
253 ATH_MSG_ERROR(
"Could not properly open input network file: " + fileName);
254 return StatusCode::FAILURE;
259 lwt::JSONConfig netDef = lwt::parse_json(netFile);
260 m_network = std::make_unique<lwt::LightweightNeuralNetwork>(netDef.inputs, netDef.layers, netDef.outputs);
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;
270 m_graph = std::make_unique<lwt::LightweightGraph>(netDef);
273 return StatusCode::SUCCESS;
279 std::map<std::string, double> input;
283 std::map<std::string, double> output;
290 std::map<std::string, std::map<std::string, double>> wrappedInput;
292 output =
m_graph->compute(wrappedInput);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define maxValue(current, test)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
ElementLink implementation for ROOT usage.
bool isValid() const
Test to see if the link can be dereferenced.
bool toContainedElement(BaseConstReference data, ElementType element, IProxyDict *sg=0)
Set from element pointer and a reference to the container (storable)
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
VxType::VertexType vertexType() const
The type of the vertex.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Select isolated Photons, Electrons and Muons.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
std::vector< const xAOD::TrackParticle * > TrackVertexAssociationList
EventInfo_v1 EventInfo
Definition of the latest event info version.
std::map< const xAOD::Vertex *, xAOD::TrackVertexAssociationList > TrackVertexAssociationMap
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".