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 FlavorTagDiscriminants {
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 
26  const auto opts = getOptions(m_props);
27  if (!m_nnsvc.empty()) {
28  ATH_CHECK(m_nnsvc.retrieve());
29  std::vector<std::shared_ptr<const 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::BTagging& btag) const {
51  m_gnn->decorate(btag);
52  }
54  m_gnn->decorate(jet);
55  }
57  m_gnn->decorateWithDefaults(jet);
58  }
60  m_gnn->decorateWithDefaults(btag);
61  }
62 
63  // Dependencies
64  std::set<std::string> MultifoldGNNTool::getDecoratorKeys() const {
65  return m_gnn->getDecoratorKeys();
66  }
67  std::set<std::string> MultifoldGNNTool::getAuxInputKeys() const {
68  return m_gnn->getAuxInputKeys();
69  }
70  std::set<std::string> MultifoldGNNTool::getConstituentAuxInputKeys() const {
71  return m_gnn->getConstituentAuxInputKeys();
72  }
73 
74 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:472
FlavorTagDiscriminants::MultifoldGNNTool::m_gnn
std::shared_ptr< const MultifoldGNN > m_gnn
Definition: MultifoldGNNTool.h:69
FlavorTagDiscriminants::MultifoldGNNTool::getConstituentAuxInputKeys
virtual std::set< std::string > getConstituentAuxInputKeys() const override
Definition: MultifoldGNNTool.cxx:70
asg
Definition: DataHandleTestTool.h:28
FlavorTagDiscriminants::MultifoldGNNTool::decorate
virtual void decorate(const xAOD::BTagging &btag) const override
Method to decorate a jet.
Definition: MultifoldGNNTool.cxx:50
GNNOptions.h
FlavorTagDiscriminants::MultifoldGNNTool::m_nn_files
std::vector< std::string > m_nn_files
Definition: MultifoldGNNTool.h:66
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
FlavorTagDiscriminants::MultifoldGNNTool::getDecoratorKeys
virtual std::set< std::string > getDecoratorKeys() const override
Definition: MultifoldGNNTool.cxx:64
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FlavorTagDiscriminants::MultifoldGNNTool::m_fold_hash_name
std::string m_fold_hash_name
Definition: MultifoldGNNTool.h:67
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
FlavorTagDiscriminants::MultifoldGNNTool::m_nnsvc
ServiceHandle< INNSharingSvc > m_nnsvc
Definition: MultifoldGNNTool.h:64
FlavorTagDiscriminants::MultifoldGNNTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: MultifoldGNNTool.cxx:24
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MultifoldGNNTool.h
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MultifoldGNN.h
FlavorTagDiscriminants::MultifoldGNNTool::m_defaults
Gaudi::Property< MMD > m_defaults
Definition: MultifoldGNNTool.h:70
FlavorTagDiscriminants::MultifoldGNNTool::decorateWithDefaults
virtual void decorateWithDefaults(const SG::AuxElement &jet) const override
Method to decorate a jet with defaults.
Definition: MultifoldGNNTool.cxx:56
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
FlavorTagDiscriminants::MultifoldGNNTool::getAuxInputKeys
virtual std::set< std::string > getAuxInputKeys() const override
Definition: MultifoldGNNTool.cxx:67
FlavorTagDiscriminants::MultifoldGNNTool::m_props
GNNToolProperties m_props
Definition: MultifoldGNNTool.h:68
FlavorTagDiscriminants::MultifoldGNN
Definition: MultifoldGNN.h:22
athena.opts
opts
Definition: athena.py:88
FlavorTagDiscriminants::getOptions
GNNOptions getOptions(const GNNToolProperties &)
Definition: GNNToolifiers.cxx:24
FlavorTagDiscriminants::propify
void propify(asg::AsgTool &tool, GNNToolProperties *props)
Definition: GNNToolifiers.cxx:12