ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper > Class Template Reference

Generic accessor to access xAOD object content. More...

#include <GenAccessor.h>

Inheritance diagram for ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >:
Collaboration diagram for ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >:

Public Member Functions

 GenAccessor (const SG::ReadHandleKey< T_Cont > &key, T_HelperKit &&helper_kit, IProxyLoader::VariableType variable_type)
 
virtual int loadInt (const EventContext &ctx) const override
 
virtual double loadDouble (const EventContext &ctx) const override
 
virtual std::vector< int > loadVecInt (const EventContext &ctx) const override
 
virtual std::vector< double > loadVec (const EventContext &ctx) const override
 
virtual IProxyLoader::VariableType variableType () const override
 

Static Public Member Functions

static void throwInvalidHandle (const std::string &key)
 
static void throwVectorContainsNotOneElement (const std::string &key, std::size_t n_elements)
 

Protected Member Functions

template<class T_Dest >
std::vector< T_Dest > loadVector (const EventContext &ctx) const
 
template<class T_Dest >
T_Dest loadScalar (const EventContext &ctx) const
 

Protected Attributes

const SG::ReadHandleKey< T_Cont > * m_key
 
T_HelperKit m_helperKit
 

Private Attributes

IProxyLoader::VariableType m_variableType
 

Detailed Description

template<class T_Cont, class T_HelperKit, class T_ScalarVectorHelper>
class ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >

Generic accessor to access xAOD object content.

It uses several auxiliary classes to provide accessor, decoration handle, or method call based access to content of AuxVectorBase or AuxElement containers.

Definition at line 63 of file GenAccessor.h.

Constructor & Destructor Documentation

◆ GenAccessor()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::GenAccessor ( const SG::ReadHandleKey< T_Cont > &  key,
T_HelperKit &&  helper_kit,
IProxyLoader::VariableType  variable_type 
)
inline

Definition at line 65 of file GenAccessor.h.

66  : BaseAccessor(variable_type),
67  m_key(&key),
68  m_helperKit(std::move(helper_kit))
69  {}

Member Function Documentation

◆ loadDouble()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
virtual double ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::loadDouble ( const EventContext &  ctx) const
inlineoverridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 74 of file GenAccessor.h.

74  {
75  return this->loadScalar<double>(ctx);
76  }

◆ loadInt()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
virtual int ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::loadInt ( const EventContext &  ctx) const
inlineoverridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 71 of file GenAccessor.h.

71  {
72  return this->loadScalar<int>(ctx);
73  }

◆ loadScalar()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
template<class T_Dest >
T_Dest ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::loadScalar ( const EventContext &  ctx) const
inlineprotected

Definition at line 99 of file GenAccessor.h.

99  {
100  SG::ReadHandle<T_Cont> handle(*this->m_key, ctx);
101  if (!handle.isValid()) {
102  this->throwInvalidHandle(this->m_key->key());
103  }
104  auto helper( m_helperKit.create(ctx, handle));
105  T_Dest dummy {};
106  return T_ScalarVectorHelper::getScalar(helper, handle, dummy);
107  }

◆ loadVec()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
virtual std::vector<double> ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::loadVec ( const EventContext &  ctx) const
inlineoverridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 80 of file GenAccessor.h.

80  {
81  return this->loadVector<double>(ctx);
82  }

◆ loadVecInt()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
virtual std::vector<int> ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::loadVecInt ( const EventContext &  ctx) const
inlineoverridevirtual

Implements ExpressionParsing::IAccessor.

Definition at line 77 of file GenAccessor.h.

77  {
78  return this->loadVector<int>(ctx);
79  }

◆ loadVector()

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
template<class T_Dest >
std::vector<T_Dest> ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::loadVector ( const EventContext &  ctx) const
inlineprotected

Definition at line 85 of file GenAccessor.h.

85  {
86  SG::ReadHandle<T_Cont> handle(*this->m_key, ctx);
87  if (!handle.isValid()) {
88  this->throwInvalidHandle(this->m_key->key());
89  }
90  std::vector<T_Dest> result;
91  if (getContainerSize(*handle)>0) {
92  auto helper( m_helperKit.create(ctx, handle));
93  T_ScalarVectorHelper::fillVector(helper, handle,result);
94  }
95  return result;
96  }

◆ throwInvalidHandle()

static void ExpressionParsing::BaseAccessor::throwInvalidHandle ( const std::string &  key)
inlinestaticinherited

Definition at line 20 of file BaseAccessor.h.

20  {
21  std::stringstream msg;
22  msg << "Failed to create read handle for " << key;
23  throw std::runtime_error(key);
24  }

◆ throwVectorContainsNotOneElement()

static void ExpressionParsing::BaseAccessor::throwVectorContainsNotOneElement ( const std::string &  key,
std::size_t  n_elements 
)
inlinestaticinherited

Definition at line 25 of file BaseAccessor.h.

25  {
26  std::stringstream msg;
27  msg << "Cannot convert to scalar since the aux vector data container " << key << " does not contain exactly one element but " << n_elements;
28  throw std::runtime_error(key);
29  }

◆ variableType()

virtual IProxyLoader::VariableType ExpressionParsing::BaseAccessor::variableType ( ) const
inlineoverridevirtualinherited

Implements ExpressionParsing::IAccessor.

Definition at line 30 of file BaseAccessor.h.

30  {
31  return m_variableType;
32  }

Member Data Documentation

◆ m_helperKit

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
T_HelperKit ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::m_helperKit
protected

Definition at line 110 of file GenAccessor.h.

◆ m_key

template<class T_Cont , class T_HelperKit , class T_ScalarVectorHelper >
const SG::ReadHandleKey<T_Cont>* ExpressionParsing::GenAccessor< T_Cont, T_HelperKit, T_ScalarVectorHelper >::m_key
protected

Definition at line 109 of file GenAccessor.h.

◆ m_variableType

IProxyLoader::VariableType ExpressionParsing::BaseAccessor::m_variableType
privateinherited

Definition at line 35 of file BaseAccessor.h.


The documentation for this class was generated from the following file:
get_generator_info.result
result
Definition: get_generator_info.py:21
ExpressionParsing::GenAccessor::m_key
const SG::ReadHandleKey< T_Cont > * m_key
Definition: GenAccessor.h:109
SG::ReadHandle< T_Cont >
ExpressionParsing::BaseAccessor::m_variableType
IProxyLoader::VariableType m_variableType
Definition: BaseAccessor.h:35
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
python.xAODType.dummy
dummy
Definition: xAODType.py:4
ExpressionParsing::BaseAccessor::throwInvalidHandle
static void throwInvalidHandle(const std::string &key)
Definition: BaseAccessor.h:20
ExpressionParsing::GenAccessor::m_helperKit
T_HelperKit m_helperKit
Definition: GenAccessor.h:110
ExpressionParsing::getContainerSize
std::size_t getContainerSize(const T &cont)
Definition: PhysicsAnalysis/CommonTools/ExpressionEvaluation/src/Utils.h:73
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ExpressionParsing::BaseAccessor::BaseAccessor
BaseAccessor(IProxyLoader::VariableType variable_type)
Definition: BaseAccessor.h:18
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37