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

#include <NNSharingSvc.h>

Inheritance diagram for FlavorTagDiscriminants::NNSharingSvc:
Collaboration diagram for FlavorTagDiscriminants::NNSharingSvc:

Public Member Functions

 NNSharingSvc (const std::string &name, ISvcLocator *svc)
 
virtual std::shared_ptr< const GNNget (const std::string &nn_name, const GNNOptions &opts) override
 
virtual void print () const
 Print the state of the service. More...
 
template<typename T >
void declareServiceInterface ()
 add the given interface to the list of interfaces More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvi)
 query interface for gaudi More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
 DeclareInterfaceID (FlavorTagDiscriminants::INNSharingSvc, 1, 0)
 

Private Types

using val_t = std::shared_ptr< const GNN >
 

Private Attributes

std::unordered_map< detail::NNKey, val_t, detail::NNHasherm_gnns
 
std::unordered_map< std::string, val_tm_base_gnns
 
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
 list of interfaces we have More...
 
virtual StatusCode initialize ()
 set up/tear down functions More...
 
virtual StatusCode finalize ()
 

Detailed Description

Definition at line 31 of file NNSharingSvc.h.

Member Typedef Documentation

◆ val_t

using FlavorTagDiscriminants::NNSharingSvc::val_t = std::shared_ptr<const GNN>
private

Definition at line 39 of file NNSharingSvc.h.

Constructor & Destructor Documentation

◆ NNSharingSvc()

FlavorTagDiscriminants::NNSharingSvc::NNSharingSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 22 of file NNSharingSvc.cxx.

22  :
24  {
25  declareServiceInterface<INNSharingSvc>();
26  }

Member Function Documentation

◆ DeclareInterfaceID()

FlavorTagDiscriminants::INNSharingSvc::DeclareInterfaceID ( FlavorTagDiscriminants::INNSharingSvc  ,
,
 
)
inherited

◆ declareServiceInterface()

template<typename T >
void asg::AsgService::declareServiceInterface
inherited

add the given interface to the list of interfaces

Definition at line 76 of file AsgService.h.

77  {
78 #ifndef XAOD_STANDALONE
79  m_interfaces.emplace_back (T::interfaceID, [] (AsgService *self) -> void* {return dynamic_cast<T*>(self);});
80 #endif
81  }

◆ finalize()

StatusCode asg::AsgService::finalize ( )
virtualinherited

Reimplemented in TrackAnalysisDefinitionSvc, CP::SystematicsSvc, PlotsDefinitionSvc, and AthOnnx::OnnxRuntimeSvc.

Definition at line 40 of file AsgService.cxx.

42  {
43  return StatusCode::SUCCESS;
44  }

◆ get()

std::shared_ptr< const GNN > FlavorTagDiscriminants::NNSharingSvc::get ( const std::string &  nn_name,
const GNNOptions opts 
)
overridevirtual

Implements FlavorTagDiscriminants::INNSharingSvc.

Definition at line 27 of file NNSharingSvc.cxx.

29  {
30  detail::NNKey key{nn_name, opts};
31  if (m_gnns.count(key)) {
32  ATH_MSG_INFO("getting " << nn_name << " from cached NNs");
33  return m_gnns.at(key);
34  } else if (m_base_gnns.count(nn_name) ) {
35  ATH_MSG_INFO("adapting " << nn_name << " from cached NNs, new opts");
36  auto nn = std::make_shared<const GNN>(*m_base_gnns.at(nn_name), opts);
37  m_gnns[key] = nn;
38  return nn;
39  }
40  ATH_MSG_INFO("building " << nn_name << " from onnx file");
41  auto nn = std::make_shared<const GNN>(nn_name, opts);
42  m_base_gnns[nn_name] = nn;
43  m_gnns[key] = nn;
44  return nn;
45  }

◆ initialize()

StatusCode asg::AsgService::initialize ( )
virtualinherited

set up/tear down functions

Reimplemented in TrackAnalysisDefinitionSvc, CP::SelectionNameSvc, CP::SystematicsSvc, PlotsDefinitionSvc, asg::UnitTestService1, AthOnnx::OnnxRuntimeSvc, and egammaMVASvc.

Definition at line 32 of file AsgService.cxx.

34  {
35  return StatusCode::SUCCESS;
36  }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ print()

void asg::AsgService::print ( ) const
virtualinherited

Print the state of the service.

Implements asg::IAsgService.

Definition at line 48 of file AsgService.cxx.

49  {
50  ATH_MSG_INFO( "AsgService " << name() << " @ " << this );
51  return;
52  }

◆ queryInterface()

StatusCode asg::AsgService::queryInterface ( const InterfaceID &  riid,
void **  ppvi 
)
virtualinherited

query interface for gaudi

Definition at line 57 of file AsgService.cxx.

59  {
60  for (const auto& interface : m_interfaces)
61  {
62  if (riid == interface.first())
63  {
64  *ppvi = interface.second (this);
65  addRef();
66  return StatusCode::SUCCESS;
67  }
68  }
69  return AsgServiceBase::queryInterface (riid, ppvi);
70  }

Member Data Documentation

◆ m_base_gnns

std::unordered_map<std::string, val_t> FlavorTagDiscriminants::NNSharingSvc::m_base_gnns
private

Definition at line 41 of file NNSharingSvc.h.

◆ m_gnns

std::unordered_map<detail::NNKey, val_t, detail::NNHasher> FlavorTagDiscriminants::NNSharingSvc::m_gnns
private

Definition at line 40 of file NNSharingSvc.h.

◆ m_interfaces

std::vector<std::pair<const InterfaceID& (*)(),void *(*)(AsgService*)> > asg::AsgService::m_interfaces
privateinherited

list of interfaces we have

Definition at line 68 of file AsgService.h.


The documentation for this class was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
asg::AsgService::m_interfaces
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
list of interfaces we have
Definition: AsgService.h:68
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
FlavorTagDiscriminants::NNSharingSvc::m_gnns
std::unordered_map< detail::NNKey, val_t, detail::NNHasher > m_gnns
Definition: NNSharingSvc.h:40
asg::AsgService::AsgService
AsgService(const std::string &name, ISvcLocator *pSvcLocator)
Definition: AsgService.cxx:19
FlavorTagDiscriminants::NNSharingSvc::m_base_gnns
std::unordered_map< std::string, val_t > m_base_gnns
Definition: NNSharingSvc.h:41
athena.opts
opts
Definition: athena.py:86
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37