Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MultifoldGNN.cxx
Go to the documentation of this file.
1 /*
2 + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9 #include "xAODJet/JetContainer.h"
10 
11 using namespace FlavorTagInference;
12 
13 namespace {
14  const std::string jetLinkName = "jetLink";
15  template<typename T, typename C>
16  std::set<std::string> merged(T get, const C& c) {
17  auto first = get(*c.at(0));
18  for (size_t idx = 1; idx < c.size(); idx++) {
19  if (get(*c.at(idx)) != first) {
20  throw std::runtime_error("inconsistent dependencies in folds");
21  }
22  }
23  return first;
24  }
25  auto getNNs(
26  const std::vector<std::string>& nn_files,
27  const GNNOptions& o)
28  {
29  std::vector<std::shared_ptr<const GNN>> nns;
30  for (const auto& nn_file: nn_files) {
31  nns.emplace_back(std::make_shared<const GNN>(nn_file, o));
32  }
33  return nns;
34  }
35 }
36 
37 namespace FlavorTagInference {
38 
40  const std::vector<std::string>& nn_files,
41  const std::string& fold_hash_name,
42  const GNNOptions& o):
43  MultifoldGNN(getNNs(nn_files, o), fold_hash_name)
44  {
45  }
47  const std::vector<std::shared_ptr<const GNN>>& nns,
48  const std::string& fold_hash_name):
49  m_folds(nns),
50  m_fold_hash(fold_hash_name),
51  m_jetLink(jetLinkName)
52  {
53  }
55  MultifoldGNN::MultifoldGNN(const MultifoldGNN&) = default;
56  MultifoldGNN::~MultifoldGNN() = default;
57 
58  void MultifoldGNN::decorate(const xAOD::BTagging& btag) const {
59  getFold(**m_jetLink(btag)).decorate(btag);
60  }
61  void MultifoldGNN::decorate(const xAOD::Jet& jet) const {
63  }
66  }
68  getFold(**m_jetLink(btag)).decorateWithDefaults(btag);
69  }
70 
71  // Dependencies
72  std::set<std::string> MultifoldGNN::getDecoratorKeys() const {
73  return merged([](const auto& f){ return f.getDecoratorKeys(); }, m_folds);
74  }
75  std::set<std::string> MultifoldGNN::getAuxInputKeys() const {
76  return merged([](const auto& f){ return f.getAuxInputKeys(); }, m_folds);
77  }
78  std::set<std::string> MultifoldGNN::getConstituentAuxInputKeys() const {
79  return merged([](const auto& f){ return f.getConstituentAuxInputKeys(); }, m_folds);
80  }
81 
82  const GNN& MultifoldGNN::getFold(const SG::AuxElement& element) const {
83  return *m_folds.at(m_fold_hash(element) % m_folds.size());
84  }
85 
86 
87 }
FlavorTagInference::MultifoldGNN::decorate
void decorate(const xAOD::BTagging &btag) const
Definition: MultifoldGNN.cxx:58
GNN.h
FlavorTagInference::MultifoldGNN
Definition: MultifoldGNN.h:26
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
BTagging.h
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
FlavorTagInference::MultifoldGNN::getDecoratorKeys
std::set< std::string > getDecoratorKeys() const
Definition: MultifoldGNN.cxx:72
FlavorTagInference::GNN::decorateWithDefaults
virtual void decorateWithDefaults(const SG::AuxElement &jet) const
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/Root/GNN.cxx:152
BTaggingConfigFlags.getNNs
def getNNs(flags)
Definition: BTaggingConfigFlags.py:78
FlavorTagInference::MultifoldGNN::getConstituentAuxInputKeys
std::set< std::string > getConstituentAuxInputKeys() const
Definition: MultifoldGNN.cxx:78
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
FlavorTagInference::MultifoldGNN::~MultifoldGNN
~MultifoldGNN()
hist_file_dump.f
f
Definition: hist_file_dump.py:141
FlavorTagInference::MultifoldGNN::m_jetLink
SG::AuxElement::ConstAccessor< ElementLink< xAOD::JetContainer > > m_jetLink
Definition: MultifoldGNN.h:48
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
FlavorTagInference::MultifoldGNN::decorateWithDefaults
void decorateWithDefaults(const SG::AuxElement &jet) const
Definition: MultifoldGNN.cxx:64
FlavorTagInference::MultifoldGNN::MultifoldGNN
MultifoldGNN(const std::vector< std::string > &folds, const std::string &fold_hash_name, const FlavorTagInference::GNNOptions &opts)
Definition: MultifoldGNN.cxx:39
FlavorTagInference::GNNOptions
Definition: GNNOptions.h:16
MultifoldGNN.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetContainer.h
DeMoScan.first
bool first
Definition: DeMoScan.py:536
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
FlavorTagInference::GNN::decorate
virtual void decorate(const xAOD::BTagging &btag) const
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/Root/GNN.cxx:137
FlavorTagInference::MultifoldGNN::getAuxInputKeys
std::set< std::string > getAuxInputKeys() const
Definition: MultifoldGNN.cxx:75
FlavorTagInference::MultifoldGNN::getFold
const FlavorTagInference::GNN & getFold(const SG::AuxElement &element) const
Definition: MultifoldGNN.cxx:82
python.compressB64.c
def c
Definition: compressB64.py:93
FlavorTagInference::GNN
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/GNN.h:39
FlavorTagInference::MultifoldGNN::m_folds
std::vector< std::shared_ptr< const FlavorTagInference::GNN > > m_folds
Definition: MultifoldGNN.h:46
FlavorTagInference::MultifoldGNN::m_fold_hash
SG::AuxElement::ConstAccessor< uint32_t > m_fold_hash
Definition: MultifoldGNN.h:47