ATLAS Offline Software
Loading...
Searching...
No Matches
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;
48 getValue(name, value);
49 return value;
50}
void getValue(const std::string &name, T &value) const
Definition JetContext.h:39
unsigned long long T

◆ 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}
std::unordered_map< std::string, std::variant< int, float > > m_dict_
Definition JetContext.h:36
bool isAvailable(const std::string &name) const
Definition JetContext.h:31

◆ 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 T value,
bool allowOverwrite = false )

Definition at line 52 of file JetContext.h.

52 {
53 if(( !allowOverwrite && isAvailable(name)) ) return false;
54
55 if constexpr (!std::is_same<T, int>::value && !std::is_same<T, float>::value) {
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: