ATLAS Offline Software
MultifoldGNN.cxx
Go to the documentation of this file.
1 /*
2 + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "xAODJet/JetContainer.h"
9 
10 using namespace FlavorTagInference;
11 
12 namespace {
13  const std::string jetLinkName = "jetLink";
14  auto getNNs(
15  const std::vector<std::string>& nn_files,
16  const GNNOptions& o)
17  {
18  std::vector<std::shared_ptr<const GNN>> nns;
19  for (const auto& nn_file: nn_files) {
20  nns.emplace_back(std::make_shared<const GNN>(nn_file, o));
21  }
22  return nns;
23  }
24 }
25 
26 namespace FlavorTagInference {
27 
29  const std::vector<std::string>& nn_files,
30  const std::string& fold_hash_name,
31  const GNNOptions& o):
32  MultifoldGNN(getNNs(nn_files, o), fold_hash_name)
33  {
34  }
36  const std::vector<std::shared_ptr<const GNN>>& nns,
37  const std::string& fold_hash_name):
38  m_folds(nns),
39  m_fold_hash(fold_hash_name),
40  m_jetLink(jetLinkName)
41  {
42  }
44  MultifoldGNN::MultifoldGNN(const MultifoldGNN&) = default;
45  MultifoldGNN::~MultifoldGNN() = default;
46 
47  void MultifoldGNN::decorate(const xAOD::IParticle& i_jet) const {
48  getFold(i_jet).decorate(i_jet);
49  }
51  getFold(i_jet).decorateWithDefaults(i_jet);
52  }
53 
54  // Dependencies
56  auto first = m_folds.at(0)->getDependencies();
57  for (size_t idx = 1; idx< m_folds.size(); idx++) {
58  if (m_folds.at(idx)->getDependencies() != first) {
59  throw std::runtime_error("inconsistent dependencies in folds");
60  }
61  }
62  // this algorithm also depends on the jet fold hash, make sure
63  // it's declared.
64  first.bTagInputs.insert(
66  return first;
67  }
68 
69  const GNN& MultifoldGNN::getFold(const SG::AuxElement& element) const {
70  return *m_folds.at(m_fold_hash(element) % m_folds.size());
71  }
72 
73 
74 }
FlavorTagInference::GNN::decorateWithDefaults
virtual void decorateWithDefaults(const xAOD::IParticle &jet) const
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/Root/GNN.cxx:100
GNN.h
FlavorTagInference::MultifoldGNN
Definition: MultifoldGNN.h:25
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:27
FlavorTagInference::MultifoldGNN::decorate
void decorate(const xAOD::IParticle &i_jet) const
Definition: MultifoldGNN.cxx:47
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:640
FlavorTagInference::MultifoldGNN::decorateWithDefaults
void decorateWithDefaults(const xAOD::IParticle &i_jet) const
Definition: MultifoldGNN.cxx:50
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
FlavorTagInference::MultifoldGNN::getDependencies
FTagDataDependencyNames getDependencies() const
Definition: MultifoldGNN.cxx:55
BTaggingConfigFlags.getNNs
def getNNs(flags)
Definition: BTaggingConfigFlags.py:78
dumpTruth.getName
getName
Definition: dumpTruth.py:34
FlavorTagInference::MultifoldGNN::~MultifoldGNN
~MultifoldGNN()
FlavorTagInference::FTagDataDependencyNames
Definition: FTagDataDependencyNames.h:12
FlavorTagInference::MultifoldGNN::MultifoldGNN
MultifoldGNN(const std::vector< std::string > &folds, const std::string &fold_hash_name, const FlavorTagInference::GNNOptions &opts)
Definition: MultifoldGNN.cxx:28
FlavorTagInference::GNNOptions
Definition: GNNOptions.h:15
MultifoldGNN.h
FlavorTagInference::GNN::decorate
virtual void decorate(const xAOD::IParticle &i_jet) const
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/Root/GNN.cxx:119
JetContainer.h
DeMoScan.first
bool first
Definition: DeMoScan.py:534
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
FlavorTagInference::MultifoldGNN::getFold
const FlavorTagInference::GNN & getFold(const SG::AuxElement &element) const
Definition: MultifoldGNN.cxx:69
FlavorTagInference::GNN
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/GNN.h:36
FlavorTagInference::MultifoldGNN::m_folds
std::vector< std::shared_ptr< const FlavorTagInference::GNN > > m_folds
Definition: MultifoldGNN.h:42
FlavorTagInference::MultifoldGNN::m_fold_hash
SG::AuxElement::ConstAccessor< uint32_t > m_fold_hash
Definition: MultifoldGNN.h:43