ATLAS Offline Software
Public Member Functions | Private Types | Private Attributes | List of all members
FlavorTagDiscriminants::HbbTag Class Reference

#include <HbbTag.h>

Collaboration diagram for FlavorTagDiscriminants::HbbTag:

Public Member Functions

 HbbTag (const HbbTagConfig &config)
 
 HbbTag (HbbTag &&)
 
 ~HbbTag ()
 
void decorate (const xAOD::Jet &jet) const
 

Private Types

using JetLink = ElementLink< xAOD::JetContainer >
 
using PartLink = std::vector< ElementLink< xAOD::IParticleContainer > >
 
using Pg = std::function< std::pair< std::string, double >(const xAOD::Jet &)>
 
template<typename T >
using Decorator = SG::AuxElement::Decorator< T >
 
using NodeWriter = std::vector< std::pair< std::string, Decorator< float > >>
 

Private Attributes

SG::AuxElement::ConstAccessor< JetLinkm_parent_link
 
SG::AuxElement::ConstAccessor< PartLinkm_subjet_link_getter
 
std::vector< Pgm_fat_jet_getters
 
std::vector< Pgm_subjet_getters
 
size_t m_n_subjets
 
double m_min_subjet_pt
 
std::unique_ptr< lwt::LightweightGraph > m_graph
 
std::map< std::string, std::map< std::string, double > > m_defaults
 
std::vector< std::pair< std::string, NodeWriter > > m_outputs
 

Detailed Description

Definition at line 22 of file HbbTag.h.

Member Typedef Documentation

◆ Decorator

template<typename T >
using FlavorTagDiscriminants::HbbTag::Decorator = SG::AuxElement::Decorator<T>
private

Definition at line 48 of file HbbTag.h.

◆ JetLink

Definition at line 32 of file HbbTag.h.

◆ NodeWriter

using FlavorTagDiscriminants::HbbTag::NodeWriter = std::vector<std::pair<std::string, Decorator<float> >>
private

Definition at line 49 of file HbbTag.h.

◆ PartLink

Definition at line 34 of file HbbTag.h.

◆ Pg

using FlavorTagDiscriminants::HbbTag::Pg = std::function<std::pair<std::string, double>(const xAOD::Jet&)>
private

Definition at line 36 of file HbbTag.h.

Constructor & Destructor Documentation

◆ HbbTag() [1/2]

FlavorTagDiscriminants::HbbTag::HbbTag ( const HbbTagConfig config)

Definition at line 49 of file HbbTag.cxx.

49  :
50  m_parent_link("Parent"),
51  m_subjet_link_getter(config.subjet_link_name),
52  m_n_subjets(0),
53  m_min_subjet_pt(config.min_subjet_pt)
54  {
55  namespace fs = std::filesystem;
56  // setup NN
57  fs::path nn_path = config.input_file_path;
58  if (!fs::exists(nn_path)) {
59  nn_path = PathResolverFindCalibFile(nn_path.string());
60  if (nn_path.empty()) {
61  throw std::runtime_error(
62  "no file found at '" + config.input_file_path.string() + "'");
63  }
64  }
65  std::ifstream input_stream(nn_path.string());
66  lwt::GraphConfig graph_cfg = lwt::parse_json_graph(input_stream);
67  m_graph.reset(new lwt::LightweightGraph(graph_cfg));
68 
69  // setup large-R jet getters and defaults
70  HbbGraphConfig keys = getHbbGraphConfig(graph_cfg);
71  // add the getters
72  for (const std::string& key: keys.fatjet) {
73  m_fat_jet_getters.push_back(makePairGetter(key));
74  }
75  for (const std::string& key: keys.subjet) {
76  m_subjet_getters.push_back(makePairGetter(key));
77  }
78  m_defaults = keys.defaults;
79  m_n_subjets = keys.n_subjets;
80 
81  // setup outputs
82  for (const auto& output: graph_cfg.outputs) {
83  const std::string& node_name = output.first;
84  const lwt::OutputNodeConfig& node = output.second;
85  NodeWriter node_writer;
86  for (const std::string& varname: node.labels) {
87  std::string write_name = node_name + "_" + varname;
88  node_writer.emplace_back(varname, write_name);
89  }
90  m_outputs.emplace_back(node_name, node_writer);
91  }
92  }

◆ HbbTag() [2/2]

FlavorTagDiscriminants::HbbTag::HbbTag ( HbbTag &&  )
default

◆ ~HbbTag()

FlavorTagDiscriminants::HbbTag::~HbbTag ( )

Definition at line 94 of file HbbTag.cxx.

94 {}

Member Function Documentation

◆ decorate()

void FlavorTagDiscriminants::HbbTag::decorate ( const xAOD::Jet jet) const

Definition at line 96 of file HbbTag.cxx.

96  {
97  namespace hk = hbb_key;
98  std::map<std::string, std::map<std::string, double>> inputs = m_defaults;
99  for (const auto& getter: m_fat_jet_getters) {
100  requireOverwrite(inputs.at(hk::fatjet),getter(jet));
101  }
102 
103  std::vector<const xAOD::IParticle*> subjets;
104  const xAOD::Jet* parent = *m_parent_link(jet);
105  if (!parent) throw std::runtime_error("can't resolve parent jet");
106  for (const auto& link: m_subjet_link_getter(*parent)) {
107  const xAOD::IParticle* subjet = *link;
108  if (!subjet) throw std::runtime_error("can't resolve subjet link");
109  if (subjet->pt() >= m_min_subjet_pt) {
110  subjets.push_back(subjet);
111  }
112  }
113  std::sort(subjets.begin(), subjets.end(),
114  [](auto* a, auto* b) { return a->pt() > b->pt(); });
115 
116  size_t n_jets = std::min(subjets.size(), m_n_subjets);
117  for (size_t jet_n = 0; jet_n < n_jets; jet_n++) {
118  const auto* subjet = dynamic_cast<const xAOD::Jet*>(subjets.at(jet_n));
119  if (!subjet) throw std::runtime_error("IParticle is not a Jet");
120  std::string subjet_name = hk::subjet + std::to_string(jet_n);
121  for (const auto& getter: m_subjet_getters) {
122  requireOverwrite(inputs.at(subjet_name),getter(*subjet));
123  }
124  }
125 
126  // calculate and write
127  for (const auto& node: m_outputs) {
128  const auto& result = m_graph->compute(inputs, {}, node.first);
129  for (const auto& var_writer: node.second) {
130  var_writer.second(jet) = result.at(var_writer.first);
131  }
132  }
133 
134  }

Member Data Documentation

◆ m_defaults

std::map<std::string, std::map<std::string,double> > FlavorTagDiscriminants::HbbTag::m_defaults
private

Definition at line 44 of file HbbTag.h.

◆ m_fat_jet_getters

std::vector<Pg> FlavorTagDiscriminants::HbbTag::m_fat_jet_getters
private

Definition at line 37 of file HbbTag.h.

◆ m_graph

std::unique_ptr<lwt::LightweightGraph> FlavorTagDiscriminants::HbbTag::m_graph
private

Definition at line 43 of file HbbTag.h.

◆ m_min_subjet_pt

double FlavorTagDiscriminants::HbbTag::m_min_subjet_pt
private

Definition at line 40 of file HbbTag.h.

◆ m_n_subjets

size_t FlavorTagDiscriminants::HbbTag::m_n_subjets
private

Definition at line 39 of file HbbTag.h.

◆ m_outputs

std::vector<std::pair<std::string, NodeWriter> > FlavorTagDiscriminants::HbbTag::m_outputs
private

Definition at line 50 of file HbbTag.h.

◆ m_parent_link

SG::AuxElement::ConstAccessor<JetLink> FlavorTagDiscriminants::HbbTag::m_parent_link
private

Definition at line 33 of file HbbTag.h.

◆ m_subjet_getters

std::vector<Pg> FlavorTagDiscriminants::HbbTag::m_subjet_getters
private

Definition at line 38 of file HbbTag.h.

◆ m_subjet_link_getter

SG::AuxElement::ConstAccessor<PartLink> FlavorTagDiscriminants::HbbTag::m_subjet_link_getter
private

Definition at line 35 of file HbbTag.h.


The documentation for this class was generated from the following files:
FlavorTagDiscriminants::hbb_key::subjet
const std::string subjet
Definition: HbbConstants.h:18
FlavorTagDiscriminants::HbbTag::m_defaults
std::map< std::string, std::map< std::string, double > > m_defaults
Definition: HbbTag.h:44
get_generator_info.result
result
Definition: get_generator_info.py:21
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
FlavorTagDiscriminants::HbbTag::m_outputs
std::vector< std::pair< std::string, NodeWriter > > m_outputs
Definition: HbbTag.h:50
FlavorTagDiscriminants::HbbTag::m_graph
std::unique_ptr< lwt::LightweightGraph > m_graph
Definition: HbbTag.h:43
FlavorTagDiscriminants::HbbTag::m_fat_jet_getters
std::vector< Pg > m_fat_jet_getters
Definition: HbbTag.h:37
FlavorTagDiscriminants::HbbTag::NodeWriter
std::vector< std::pair< std::string, Decorator< float > >> NodeWriter
Definition: HbbTag.h:49
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
FlavorTagDiscriminants::HbbTag::m_n_subjets
size_t m_n_subjets
Definition: HbbTag.h:39
test_pyathena.parent
parent
Definition: test_pyathena.py:15
FlavorTagDiscriminants::HbbTag::m_parent_link
SG::AuxElement::ConstAccessor< JetLink > m_parent_link
Definition: HbbTag.h:33
min
#define min(a, b)
Definition: cfImp.cxx:40
merge.output
output
Definition: merge.py:17
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
FlavorTagDiscriminants::getHbbGraphConfig
HbbGraphConfig getHbbGraphConfig(const lwt::GraphConfig &cfg)
Definition: HbbGraphConfig.cxx:29
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
lwtDev::parse_json_graph
GraphConfig parse_json_graph(std::istream &json)
Definition: parse_json.cxx:71
FlavorTagDiscriminants::hbb_key::fatjet
const std::string fatjet
Definition: HbbConstants.h:19
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
a
TList * a
Definition: liststreamerinfos.cxx:10
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
FlavorTagDiscriminants::HbbTag::m_subjet_getters
std::vector< Pg > m_subjet_getters
Definition: HbbTag.h:38
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
FlavorTagDiscriminants::HbbTag::m_subjet_link_getter
SG::AuxElement::ConstAccessor< PartLink > m_subjet_link_getter
Definition: HbbTag.h:35
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
FlavorTagDiscriminants::HbbTag::m_min_subjet_pt
double m_min_subjet_pt
Definition: HbbTag.h:40
node
Definition: memory_hooks-stdcmalloc.h:74
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37