ATLAS Offline Software
MultifoldGNNTool.cxx
Go to the documentation of this file.
1 /*
2 + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 namespace FlavorTagInference {
10 
11  MultifoldGNNTool::MultifoldGNNTool(const std::string& name):
12  asg::AsgTool(name),
13  m_props()
14  {
15  declareProperty("nnFiles", m_nn_files,
16  "the path to the netowrk file used to run inference");
17  declareProperty("foldHashName", m_fold_hash_name,
18  "the path to the netowrk file used to run inference");
19  propify(*this, &m_props);
20  }
21 
22  MultifoldGNNTool::~MultifoldGNNTool() {}
23 
25 
27  if (!m_nnsvc.empty()) {
28  ATH_CHECK(m_nnsvc.retrieve());
29  std::vector<std::shared_ptr<const FlavorTagInference::GNN>> gnns;
30  for (const auto& file: m_nn_files) {
31  auto newopts = opts;
32  if (auto def_handle = m_defaults.value().extract(file)) {
33  newopts.default_output_values = def_handle.mapped();
34  }
35  gnns.emplace_back(m_nnsvc->get(file, newopts));
36  }
37  if (!m_defaults.empty()) {
38  ATH_MSG_ERROR("unused per-fold defaults!");
39  return StatusCode::FAILURE;
40  }
41  m_gnn.reset(new MultifoldGNN(gnns, m_fold_hash_name));
42  } else {
43  ATH_MSG_INFO("Initialize multi-fold GNN");
45  }
46 
47  return StatusCode::SUCCESS;
48  }
49 
50  void MultifoldGNNTool::decorate(const xAOD::IParticle& i_jet) const {
51  m_gnn->decorate(i_jet);
52  }
54  m_gnn->decorateWithDefaults(i_jet);
55  }
56 
57  // Dependencies
58  std::set<std::string> MultifoldGNNTool::getDecoratorKeys() const {
59  return m_gnn->getDecoratorKeys();
60  }
61  std::set<std::string> MultifoldGNNTool::getAuxInputKeys() const {
62  return m_gnn->getAuxInputKeys();
63  }
64  std::set<std::string> MultifoldGNNTool::getConstituentAuxInputKeys() const {
65  return m_gnn->getConstituentAuxInputKeys();
66  }
67 
68 }
FlavorTagInference::MultifoldGNNTool::getDecoratorKeys
virtual std::set< std::string > getDecoratorKeys() const override
Definition: MultifoldGNNTool.cxx:58
FlavorTagInference::MultifoldGNN
Definition: MultifoldGNN.h:25
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FlavorTagInference::MultifoldGNNTool::m_props
FlavorTagInference::GNNToolProperties m_props
Definition: MultifoldGNNTool.h:63
FlavorTagInference::MultifoldGNNTool::decorate
virtual void decorate(const xAOD::IParticle &i_jet) const override
Method to decorate a jet.
Definition: MultifoldGNNTool.cxx:50
asg
Definition: DataHandleTestTool.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
FlavorTagInference::MultifoldGNNTool::getConstituentAuxInputKeys
virtual std::set< std::string > getConstituentAuxInputKeys() const override
Definition: MultifoldGNNTool.cxx:64
GNNOptions.h
FlavorTagInference::propify
void propify(asg::AsgTool &tool, GNNToolProperties *props)
Definition: GNNToolifiers.cxx:12
FlavorTagInference::MultifoldGNNTool::m_fold_hash_name
std::string m_fold_hash_name
Definition: MultifoldGNNTool.h:62
FlavorTagInference::MultifoldGNNTool::m_nnsvc
ServiceHandle< FlavorTagInference::INNSharingSvc > m_nnsvc
Definition: MultifoldGNNTool.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
file
TFile * file
Definition: tile_monitor.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MultifoldGNNTool.h
FlavorTagInference::getOptions
GNNOptions getOptions(const GNNToolProperties &)
Definition: GNNToolifiers.cxx:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MultifoldGNN.h
FlavorTagInference::MultifoldGNNTool::getAuxInputKeys
virtual std::set< std::string > getAuxInputKeys() const override
Definition: MultifoldGNNTool.cxx:61
FlavorTagInference::MultifoldGNNTool::m_nn_files
std::vector< std::string > m_nn_files
Definition: MultifoldGNNTool.h:61
FlavorTagInference::MultifoldGNNTool::m_defaults
Gaudi::Property< MMD > m_defaults
Definition: MultifoldGNNTool.h:65
FlavorTagInference::MultifoldGNNTool::m_gnn
std::shared_ptr< const MultifoldGNN > m_gnn
Definition: MultifoldGNNTool.h:64
FlavorTagInference::MultifoldGNNTool::decorateWithDefaults
virtual void decorateWithDefaults(const xAOD::IParticle &i_jet) const override
Method to decorate a jet with defaults.
Definition: MultifoldGNNTool.cxx:53
athena.opts
opts
Definition: athena.py:88
FlavorTagInference::MultifoldGNNTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: MultifoldGNNTool.cxx:24