ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
FlavorTagInference
Root
PassThroughModelSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
FlavorTagInference/PassThroughModelSvc.h
"
6
#include "
FlavorTagInference/PassThroughSaltModel.h
"
7
#include "
FlavorTagInference/ISaltModel.h
"
8
#include "
PathResolver/PathResolver.h
"
9
10
#include "nlohmann/json.hpp"
11
#include <fstream>
12
#include <stdexcept>
13
14
namespace
FlavorTagInference
{
15
16
StatusCode
PassThroughModelSvc::initialize
() {
17
if
(
m_jsonFile
.value().empty()) {
18
ATH_MSG_ERROR
(
"JsonFile property is empty"
);
19
return
StatusCode::FAILURE;
20
}
21
22
// Resolve the JSON file path
23
std::string resolved =
PathResolverFindCalibFile
(
m_jsonFile
);
24
if
(resolved.empty()) {
25
ATH_MSG_ERROR
(
"Could not resolve JSON file: "
<<
m_jsonFile
);
26
return
StatusCode::FAILURE;
27
}
28
29
// Load and parse the JSON
30
std::ifstream
file
(resolved);
31
if
(!
file
.is_open()) {
32
ATH_MSG_ERROR
(
"Could not open JSON file: "
<< resolved);
33
return
StatusCode::FAILURE;
34
}
35
36
nlohmann::json config;
37
try
{
38
file
>> config;
39
}
catch
(
const
nlohmann::json::parse_error& e) {
40
ATH_MSG_ERROR
(
"JSON parse error in "
<< resolved <<
": "
<< e.what());
41
return
StatusCode::FAILURE;
42
}
43
44
// Create the PassThroughSaltModel
45
try
{
46
auto
model = std::make_shared<const PassThroughSaltModel>(config);
47
ISaltModelPtr
salt_model = model;
48
49
// Create the GNN wrapper with variable remapping so that
50
// TracksLoader uses the correct aux variable names (e.g.
51
// GhostTrack instead of BTagTrackToJetAssociator)
52
GNNOptions
opts;
53
opts.variable_remapping =
m_variableRemapping
;
54
m_gnn
= std::make_shared<const GNN>(salt_model, opts);
55
}
catch
(
const
std::exception& e) {
56
ATH_MSG_ERROR
(
"Failed to create PassThroughSaltModel: "
<< e.what());
57
return
StatusCode::FAILURE;
58
}
59
60
ATH_MSG_INFO
(
"PassThroughModelSvc initialized from "
<< resolved);
61
return
StatusCode::SUCCESS;
62
}
63
64
std::shared_ptr<const GNN>
PassThroughModelSvc::get
(
65
const
std::string&
/*nn_name*/
,
66
const
GNNOptions
& opts)
67
{
68
// If options differ from defaults, create a new GNN sharing
69
// the underlying model but with new options
70
GNNOptions
default_opts;
71
if
(!(opts == default_opts)) {
72
return
std::make_shared<const GNN>(*
m_gnn
, opts);
73
}
74
return
m_gnn
;
75
}
76
77
}
// namespace FlavorTagInference
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ISaltModel.h
PassThroughModelSvc.h
PassThroughSaltModel.h
PathResolver.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition
PathResolver.cxx:325
FlavorTagInference::PassThroughModelSvc::m_jsonFile
Gaudi::Property< std::string > m_jsonFile
Definition
PassThroughModelSvc.h:33
FlavorTagInference::PassThroughModelSvc::initialize
virtual StatusCode initialize() override
Definition
PassThroughModelSvc.cxx:16
FlavorTagInference::PassThroughModelSvc::m_variableRemapping
Gaudi::Property< std::map< std::string, std::string > > m_variableRemapping
Definition
PassThroughModelSvc.h:37
FlavorTagInference::PassThroughModelSvc::get
virtual std::shared_ptr< const GNN > get(const std::string &nn_name, const GNNOptions &opts) override
Definition
PassThroughModelSvc.cxx:64
FlavorTagInference::PassThroughModelSvc::m_gnn
std::shared_ptr< const GNN > m_gnn
Definition
PassThroughModelSvc.h:42
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition
CaloClusterLoader.h:27
FlavorTagInference::ISaltModelPtr
std::shared_ptr< const ISaltModel > ISaltModelPtr
Definition
ISaltModel.h:56
FlavorTagInference::GNNOptions
Definition
GNNOptions.h:15
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0