ATLAS Offline Software
HbbGraphConfig.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Note: please don't include any ROOT in here (i.e. xAOD::Jet or
6 // anything from the EDM), it's not a stable dependency (in particular
7 // the TString overloads change between releases).
8 
11 
12 #include "lwtnn/lightweight_network_config.hh"
13 
14 #include <regex>
15 
16 namespace {
17  std::string formatSet(const std::set<std::string>& s) {
18  std::string out("{");
19  for (const std::string& var: s) {
20  out.append(var);
21  if (var != *s.rbegin()) out.append(", ");
22  }
23  out.append("}");
24  return out;
25  }
26 }
27 
28 namespace FlavorTagDiscriminants {
29  HbbGraphConfig getHbbGraphConfig(const lwt::GraphConfig& graph_cfg){
30  namespace hk = FlavorTagDiscriminants::hbb_key;
32  k.n_subjets = 0;
33  std::regex subjet_match(hk::subjet + "[0-9]+");
34  std::string first_match;
35  for (const auto& node: graph_cfg.inputs) {
36  for (const auto& var: node.variables) {
37  const std::string& name = var.name;
38  k.defaults[node.name][name] = node.defaults.at(name);
39  }
40  if (node.name == hk::fatjet) {
41  for (const auto& var: node.variables) {
42  k.fatjet.insert(var.name);
43  }
44  } else if (std::regex_match(node.name, subjet_match)) {
45  std::set<std::string> subjet_set;
46  for (const auto& var: node.variables) {
47  subjet_set.insert(var.name);
48  }
49  if (k.n_subjets == 0) {
50  k.subjet = subjet_set;
51  first_match = node.name;
52  } else if (k.subjet != subjet_set) {
53  std::string error = "mismatch in subjet keys: we expect the same"
54  " variables to be read from each subjet. ";
55  error.append("first subjet (" + first_match + ") "
56  + formatSet(k.subjet) + ", match "
57  + std::to_string(k.n_subjets)
58  + ", (" + node.name + ") " + formatSet(subjet_set));
59  throw std::runtime_error(error);
60  }
61  k.n_subjets++;
62  } else {
63  throw std::runtime_error("no way to match '" + node.name + "'");
64  }
65  }
66  return k;
67  }
68 }
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
FlavorTagDiscriminants::hbb_key::subjet
const std::string subjet
Definition: HbbConstants.h:18
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
FlavorTagDiscriminants::HbbGraphConfig
Definition: HbbGraphConfig.h:23
FlavorTagDiscriminants::hbb_key
Definition: HbbConstants.h:14
node::name
void name(const std::string &n)
Definition: node.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
FlavorTagDiscriminants::getHbbGraphConfig
HbbGraphConfig getHbbGraphConfig(const lwt::GraphConfig &cfg)
Definition: HbbGraphConfig.cxx:29
HbbConstants.h
FlavorTagDiscriminants::hbb_key::fatjet
const std::string fatjet
Definition: HbbConstants.h:19
HbbGraphConfig.h
error
Definition: IImpactPoint3dEstimator.h:70
node
Definition: memory_hooks-stdcmalloc.h:74
fitman.k
k
Definition: fitman.py:528