ATLAS Offline Software
Loading...
Searching...
No Matches
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
8
10
11#include "lwtnn/parse_json.hh"
12#include "lwtnn/LightweightGraph.hh"
13#include "lwtnn/NanReplacer.hh"
14
15#define BOOST_BIND_GLOBAL_PLACEHOLDERS // Needed to silence Boost pragma message
16#include <boost/property_tree/json_parser.hpp>
17#include <boost/property_tree/exceptions.hpp>
18
19#include <fstream>
20#include <utility>
21
22
23namespace FlavorTagDiscriminants {
24
25 DL2HighLevel::DL2HighLevel(const std::string& nn_file_name,
26 FlipTagConfig flip_config,
27 std::map<std::string,std::string> remap_scalar,
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 auto [input_config, constituents_configs, options] = dataprep::createGetterConfig<lwt::GraphConfig, lwt::OutputNodeConfig>(
43 config, flip_config, std::move(remap_scalar));
44 options.default_output_value = default_output_value;
45
46 m_dl2.reset(
47 new DL2(
48 config, // lwtnn config
49 input_config, // EDM input config
50 constituents_configs, // edm track input config
51 options
52 ));
53 }
54
58
59 void DL2HighLevel::decorate(const xAOD::IParticle& i_jet) const {
60 m_dl2->decorate(i_jet);
61 }
63 m_dl2->decorateWithDefaults(i_jet);
64 }
65
67 {
68 return m_dl2->getDataDependencyNames();
69 }
70}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void decorateWithDefaults(const xAOD::IParticle &i_jet) const
DL2HighLevel(const std::string &nn_file_name, FlipTagConfig=FlipTagConfig::STANDARD, std::map< std::string, std::string > remap_scalar={}, float default_output_value=NAN)
std::shared_ptr< const DL2 > m_dl2
FTagDataDependencyNames getDataDependencyNames() const
void decorate(const xAOD::IParticle &i_jet) const
Class providing the definition of the 4-vector interface.
template std::tuple< std::vector< FTagInputConfig >, std::vector< ConstituentsInputConfig >, FTagOptions > createGetterConfig< lwt::GraphConfig, lwt::OutputNodeConfig >(lwt::GraphConfig &config, FlipTagConfig flip_config, std::map< std::string, std::string > remap_scalar)