ATLAS Offline Software
PhysicsAnalysis
JetTagging
FlavorTagDiscriminants
Root
NNSharingSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
FlavorTagDiscriminants/NNSharingSvc.h
"
6
7
#include "
src/hash.h
"
8
9
namespace
FlavorTagDiscriminants
{
10
11
namespace
detail
{
12
std::size_t
NNKey::hash
()
const
{
13
return
combine
(
getHash
(
path
),
getHash
(
opts
));
14
}
15
16
// allow NNKey to be used as unordered map key
17
bool
NNKey::operator==
(
const
NNKey
&
key
)
const
{
18
return
path
==
key
.path &&
opts
==
key
.opts;
19
}
20
}
21
22
std::shared_ptr<const GNN>
NNSharingSvc::get
(
23
const
std::string& nn_name,
24
const
GNNOptions
&
opts
) {
25
detail::NNKey
key
{nn_name,
opts
};
26
if
(
m_gnns
.count(
key
)) {
27
ATH_MSG_INFO
(
"getting "
<< nn_name <<
" from cached NNs"
);
28
return
m_gnns
.at(
key
);
29
}
else
if
(
m_base_gnns
.count(nn_name) ) {
30
ATH_MSG_INFO
(
"adapting "
<< nn_name <<
" from cached NNs, new opts"
);
31
auto
nn = std::make_shared<const GNN>(*
m_base_gnns
.at(nn_name),
opts
);
32
m_gnns
[
key
] = nn;
33
return
nn;
34
}
35
ATH_MSG_INFO
(
"building "
<< nn_name <<
" from onnx file"
);
36
auto
nn = std::make_shared<const GNN>(nn_name,
opts
);
37
m_base_gnns
[nn_name] = nn;
38
m_gnns
[
key
] = nn;
39
return
nn;
40
}
41
42
43
}
FlavorTagDiscriminants::detail::NNKey::hash
std::size_t hash() const
Definition:
NNSharingSvc.cxx:12
FlavorTagDiscriminants::detail::NNKey::opts
FlavorTagDiscriminants::GNNOptions opts
Definition:
NNSharingSvc.h:20
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition:
AssociationEnums.h:11
FlavorTagDiscriminants::GNNOptions
Definition:
GNNOptions.h:16
NNSharingSvc.h
detail
Definition:
extract_histogram_tag.cxx:14
FlavorTagDiscriminants::detail::NNKey
Definition:
NNSharingSvc.h:18
FlavorTagDiscriminants::detail::NNKey::operator==
bool operator==(const NNKey &) const
Definition:
NNSharingSvc.cxx:17
FlavorTagDiscriminants::combine
size_t combine(size_t lhs, size_t rhs)
Definition:
hash.h:21
FlavorTagDiscriminants::NNSharingSvc::get
virtual std::shared_ptr< const GNN > get(const std::string &nn_name, const GNNOptions &opts) override
Definition:
NNSharingSvc.cxx:22
FlavorTagDiscriminants::NNSharingSvc::m_gnns
std::unordered_map< detail::NNKey, val_t, detail::NNHasher > m_gnns
Definition:
NNSharingSvc.h:41
FlavorTagDiscriminants::detail::NNKey::path
std::string path
Definition:
NNSharingSvc.h:19
FlavorTagDiscriminants::getHash
std::size_t getHash(const T &obj)
Definition:
hash.h:13
hash.h
FlavorTagDiscriminants::NNSharingSvc::m_base_gnns
std::unordered_map< std::string, val_t > m_base_gnns
Definition:
NNSharingSvc.h:42
athena.opts
opts
Definition:
athena.py:88
mapkey::key
key
Definition:
TElectronEfficiencyCorrectionTool.cxx:37
Generated on Sun Dec 22 2024 21:15:43 for ATLAS Offline Software by
1.8.18