ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
JetHelper::JetContext Class Reference

Class JetContext Designed to read AOD information related to the event, N vertices, Ntracks, mu etc ... More...

#include <JetContext.h>

Collaboration diagram for JetHelper::JetContext:

Public Member Functions

template<typename T >
bool setValue (const std::string &name, const T value, bool allowOverwrite=false)
 
template<typename T >
void getValue (const std::string &name, T &value) const
 
template<typename T >
getValue (const std::string &name) const
 
bool isAvailable (const std::string &name) const
 

Private Attributes

std::unordered_map< std::string, std::variant< int, float > > m_dict_
 

Detailed Description

Class JetContext Designed to read AOD information related to the event, N vertices, Ntracks, mu etc ...

Definition at line 24 of file JetContext.h.

Member Function Documentation

◆ getValue() [1/2]

template<typename T >
T JetHelper::JetContext::getValue ( const std::string &  name) const

Definition at line 46 of file JetContext.h.

46  {
47  T value;
49  return value;
50 }

◆ getValue() [2/2]

template<typename T >
void JetHelper::JetContext::getValue ( const std::string &  name,
T &  value 
) const

Definition at line 39 of file JetContext.h.

39  {
40  if(isAvailable(name))
41  value = std::get<T>(m_dict_.at(name));
42  else
43  throw std::invalid_argument(std::string("Key Error : ") + name + std::string(" not found in JetContext."));
44 }

◆ isAvailable()

bool JetHelper::JetContext::isAvailable ( const std::string &  name) const
inline

Definition at line 31 of file JetContext.h.

31  {
32  return m_dict_.find(name) != m_dict_.end();
33  };

◆ setValue()

template<typename T >
bool JetHelper::JetContext::setValue ( const std::string &  name,
const value,
bool  allowOverwrite = false 
)

Definition at line 52 of file JetContext.h.

52  {
53  if(( !allowOverwrite && isAvailable(name)) ) return false;
54 
56  static_assert(std::is_same<T, double>::value, "Unsupported type provided, please use integers or doubles.");
57  m_dict_.insert_or_assign(name, (float) value);
58  } else {
59  m_dict_.insert_or_assign(name, value); // insert returns pair with iterator and return code
60  }
61  return true; // if true => insertion, if false => assignement.
62 }

Member Data Documentation

◆ m_dict_

std::unordered_map<std::string, std::variant<int, float> > JetHelper::JetContext::m_dict_
private

Definition at line 36 of file JetContext.h.


The documentation for this class was generated from the following file:
athena.value
value
Definition: athena.py:122
JetHelper::JetContext::isAvailable
bool isAvailable(const std::string &name) const
Definition: JetContext.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
JetHelper::JetContext::m_dict_
std::unordered_map< std::string, std::variant< int, float > > m_dict_
Definition: JetContext.h:33
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
JetHelper::JetContext::getValue
void getValue(const std::string &name, T &value) const
Definition: JetContext.h:39