ATLAS Offline Software
DL2HighLevel.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 
10 #include "lwtnn/parse_json.hh"
11 #include "lwtnn/LightweightGraph.hh"
12 #include "lwtnn/NanReplacer.hh"
13 
14 #define BOOST_BIND_GLOBAL_PLACEHOLDERS // Needed to silence Boost pragma message
15 #include <boost/property_tree/json_parser.hpp>
16 #include <boost/property_tree/exceptions.hpp>
17 
18 #include <fstream>
19 #include <utility>
20 
21 
22 namespace FlavorTagDiscriminants {
23 
24  DL2HighLevel::DL2HighLevel(const std::string& nn_file_name,
25  FlipTagConfig flip_config,
26  std::map<std::string,std::string> remap_scalar,
27  TrackLinkType track_link_type,
28  float default_output_value):
29  m_dl2(nullptr)
30  {
31  // get the graph
32  std::string nn_path = PathResolverFindCalibFile(nn_file_name);
33  if (nn_path.size() == 0) {
34  throw std::runtime_error("no file found at '" + nn_file_name + "'");
35  }
36  std::ifstream input_stream(nn_path);
37  lwt::GraphConfig config = lwt::parse_json_graph(input_stream);
38 
39  if (config.inputs.size() > 1) {
40  throw std::logic_error("DL2 doesn't support multiple inputs");
41  }
42 
43  auto [input_config, constituents_configs, options] = dataprep::createGetterConfig(
44  config, flip_config, std::move(remap_scalar), track_link_type);
45  options.default_output_value = default_output_value;
46 
47  m_dl2.reset(
48  new DL2(
49  config, // lwtnn config
50  input_config, // EDM input config
51  constituents_configs, // edm track input config
52  options
53  ));
54  }
55 
56  DL2HighLevel::~DL2HighLevel() = default;
58  DL2HighLevel::DL2HighLevel(const DL2HighLevel&) = default;
59 
60  void DL2HighLevel::decorate(const xAOD::BTagging& btag) const {
61  m_dl2->decorate(btag);
62  }
63  void DL2HighLevel::decorate(const xAOD::Jet& jet) const {
64  m_dl2->decorate(jet);
65  }
67  m_dl2->decorateWithDefaults(jet);
68  }
69 
71  {
72  return m_dl2->getDataDependencyNames();
73  }
74 
75 }
FlavorTagDiscriminants::DL2
Definition: DL2.h:20
FlavorTagDiscriminants::dataprep::createGetterConfig
std::tuple< std::vector< FTagInputConfig >, std::vector< ConstituentsInputConfig >, FTagOptions > createGetterConfig(lwt::GraphConfig &graph_config, FlipTagConfig flip_config, std::map< std::string, std::string > remap_scalar, TrackLinkType track_link_type)
Definition: PhysicsAnalysis/JetTagging/FlavorTagDiscriminants/Root/DataPrepUtilities.cxx:235
FlavorTagDiscriminants::DL2HighLevel::getDataDependencyNames
FTagDataDependencyNames getDataDependencyNames() const
Definition: DL2HighLevel.cxx:70
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::DL2HighLevel::~DL2HighLevel
~DL2HighLevel()
FlavorTagDiscriminants::DL2HighLevel
Definition: DL2HighLevel.h:27
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
FlavorTagDiscriminants::DL2HighLevel::decorate
void decorate(const xAOD::BTagging &btag) const
Definition: DL2HighLevel.cxx:60
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
FlavorTagDiscriminants::FTagDataDependencyNames
Definition: FTagDataDependencyNames.h:12
FlavorTagDiscriminants::TrackLinkType
TrackLinkType
Definition: AssociationEnums.h:12
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
PathResolver.h
DL2.h
FlavorTagDiscriminants::DL2HighLevel::decorateWithDefaults
void decorateWithDefaults(const SG::AuxElement &jet) const
Definition: DL2HighLevel.cxx:66
DL2HighLevel.h
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::FlipTagConfig
FlipTagConfig
Definition: FlipTagEnums.h:14
FlavorTagDiscriminants::DL2HighLevel::m_dl2
std::shared_ptr< const DL2 > m_dl2
Definition: DL2HighLevel.h:42
FlavorTagDiscriminants::DL2HighLevel::DL2HighLevel
DL2HighLevel(const std::string &nn_file_name, FlipTagConfig=FlipTagConfig::STANDARD, std::map< std::string, std::string > remap_scalar={}, TrackLinkType=TrackLinkType::TRACK_PARTICLE, float default_output_value=NAN)
Definition: DL2HighLevel.cxx:24