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

#include <xAODVariableProxyLoaders.h>

Inheritance diagram for ExpressionParsing::TMethodCollectionWrapper:
Collaboration diagram for ExpressionParsing::TMethodCollectionWrapper:

Public Member Functions

 TMethodCollectionWrapper (const std::type_info &containerTypeinfo, const std::string &methodName)
 
 TMethodCollectionWrapper (const TMethodCollectionWrapper &)=delete
 
TMethodCollectionWrapperoperator= (const TMethodCollectionWrapper &)=delete
 
virtual ~TMethodCollectionWrapper ()
 
IProxyLoader::VariableType variableType ()
 
virtual bool isValid (const SG::AuxElement *auxElement) const
 
virtual bool isValid (const SG::AuxVectorData *auxVectorData) const
 
virtual int getIntValue (const SG::AuxElement *auxElement) const
 
virtual double getDoubleValue (const SG::AuxElement *auxElement) const
 
virtual std::vector< int > getVecIntValue (const SG::AuxVectorData *auxVectorData)
 
virtual std::vector< double > getVecDoubleValue (const SG::AuxVectorData *auxVectorData)
 

Private Attributes

TVirtualCollectionProxy * m_collectionProxy
 
RootUtils::TSMethodCall m_methodCall ATLAS_THREAD_SAFE
 
bool m_valid
 

Detailed Description

Definition at line 124 of file xAODVariableProxyLoaders.h.

Constructor & Destructor Documentation

◆ TMethodCollectionWrapper() [1/2]

ExpressionParsing::TMethodCollectionWrapper::TMethodCollectionWrapper ( const std::type_info &  containerTypeinfo,
const std::string &  methodName 
)

Definition at line 89 of file xAODVariableProxyLoaders.cxx.

91  : m_collectionProxy(nullptr),
92  m_valid(false)
93  {
94  TClass *containerClass = TClass::GetClass(containerTypeinfo);
95  if (!containerClass) {
96  containerClass = TClass::GetClass(SG::normalizedTypeinfoName(containerTypeinfo).c_str());
97  if (!containerClass) return;
98  }
99 
100  m_collectionProxy = containerClass->GetCollectionProxy();
101  if (!m_collectionProxy) return;
102 
103  TClass *elementClass = m_collectionProxy->GetValueClass();
104  if (!elementClass) return;
105 
106  m_methodCall.setProto (elementClass, methodName, "");
107 
108  m_valid = m_methodCall.call() != nullptr;
109  }

◆ TMethodCollectionWrapper() [2/2]

ExpressionParsing::TMethodCollectionWrapper::TMethodCollectionWrapper ( const TMethodCollectionWrapper )
delete

◆ ~TMethodCollectionWrapper()

ExpressionParsing::TMethodCollectionWrapper::~TMethodCollectionWrapper ( )
virtual

Definition at line 111 of file xAODVariableProxyLoaders.cxx.

112  {
113  }

Member Function Documentation

◆ getDoubleValue()

double ExpressionParsing::TMethodCollectionWrapper::getDoubleValue ( const SG::AuxElement auxElement) const
virtual

Implements ExpressionParsing::BaseAccessorWrapper.

Definition at line 146 of file xAODVariableProxyLoaders.cxx.

147  {
148  throw std::runtime_error("TMethodCollectionWrapper doesn't deal with scalars");
149  }

◆ getIntValue()

int ExpressionParsing::TMethodCollectionWrapper::getIntValue ( const SG::AuxElement auxElement) const
virtual

Implements ExpressionParsing::BaseAccessorWrapper.

Definition at line 141 of file xAODVariableProxyLoaders.cxx.

142  {
143  throw std::runtime_error("TMethodCollectionWrapper doesn't deal with scalars");
144  }

◆ getVecDoubleValue()

std::vector< double > ExpressionParsing::TMethodCollectionWrapper::getVecDoubleValue ( const SG::AuxVectorData auxVectorData)
virtual

Implements ExpressionParsing::BaseAccessorWrapper.

Definition at line 167 of file xAODVariableProxyLoaders.cxx.

168  {
169  double retDouble;
170  auto data_nc ATLAS_THREAD_SAFE = const_cast<SG::AuxVectorData*>(auxVectorData); // required by TVirtualCollectionProxy
171  m_collectionProxy->PushProxy(data_nc);
172  const UInt_t N = m_collectionProxy->Size();
173  std::vector<double> result(N);
174  for (UInt_t i = 0; i < N; ++i) {
175  void *element = (*m_collectionProxy)[i];
176  m_methodCall.call()->Execute(element, retDouble);
177  result[i] = (double) retDouble;
178  }
179  m_collectionProxy->PopProxy();
180  return result;
181  }

◆ getVecIntValue()

std::vector< int > ExpressionParsing::TMethodCollectionWrapper::getVecIntValue ( const SG::AuxVectorData auxVectorData)
virtual

Implements ExpressionParsing::BaseAccessorWrapper.

Definition at line 151 of file xAODVariableProxyLoaders.cxx.

152  {
153  long retLong;
154  auto data_nc ATLAS_THREAD_SAFE = const_cast<SG::AuxVectorData*>(auxVectorData); // required by TVirtualCollectionProxy
155  m_collectionProxy->PushProxy(data_nc);
156  const UInt_t N = m_collectionProxy->Size();
157  std::vector<int> result(N);
158  for (UInt_t i = 0; i < N; ++i) {
159  void *element = (*m_collectionProxy)[i];
160  m_methodCall.call()->Execute(element, retLong);
161  result[i] = (int) retLong;
162  }
163  m_collectionProxy->PopProxy();
164  return result;
165  }

◆ isValid() [1/2]

bool ExpressionParsing::TMethodCollectionWrapper::isValid ( const SG::AuxElement auxElement) const
virtual

Implements ExpressionParsing::BaseAccessorWrapper.

Definition at line 131 of file xAODVariableProxyLoaders.cxx.

132  {
133  return m_valid;
134  }

◆ isValid() [2/2]

bool ExpressionParsing::TMethodCollectionWrapper::isValid ( const SG::AuxVectorData auxVectorData) const
virtual

Implements ExpressionParsing::BaseAccessorWrapper.

Definition at line 136 of file xAODVariableProxyLoaders.cxx.

137  {
138  return m_valid;
139  }

◆ operator=()

TMethodCollectionWrapper& ExpressionParsing::TMethodCollectionWrapper::operator= ( const TMethodCollectionWrapper )
delete

◆ variableType()

IProxyLoader::VariableType ExpressionParsing::TMethodCollectionWrapper::variableType ( )

Definition at line 115 of file xAODVariableProxyLoaders.cxx.

116  {
117  TMethodCall* mc = m_methodCall.call();
118  if (!mc) return IProxyLoader::VT_UNK;
119  switch (mc->ReturnType()) {
120  case TMethodCall::kLong:
122  case TMethodCall::kDouble:
124  case TMethodCall::kString:
125  case TMethodCall::kOther:
126  case TMethodCall::kNone:
127  default: return IProxyLoader::VT_UNK;
128  }
129  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

RootUtils::TSMethodCall m_methodCall ExpressionParsing::TMethodCollectionWrapper::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 141 of file xAODVariableProxyLoaders.h.

◆ m_collectionProxy

TVirtualCollectionProxy* ExpressionParsing::TMethodCollectionWrapper::m_collectionProxy
private

Definition at line 140 of file xAODVariableProxyLoaders.h.

◆ m_valid

bool ExpressionParsing::TMethodCollectionWrapper::m_valid
private

Definition at line 142 of file xAODVariableProxyLoaders.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ExpressionParsing::TMethodCollectionWrapper::m_valid
bool m_valid
Definition: xAODVariableProxyLoaders.h:142
SG::normalizedTypeinfoName
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Definition: normalizedTypeinfoName.cxx:120
ExpressionParsing::TMethodCollectionWrapper::ATLAS_THREAD_SAFE
RootUtils::TSMethodCall m_methodCall ATLAS_THREAD_SAFE
Definition: xAODVariableProxyLoaders.h:141
ExpressionParsing::IProxyLoader::VT_VECDOUBLE
@ VT_VECDOUBLE
Definition: IProxyLoader.h:21
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
ExpressionParsing::IProxyLoader::VT_UNK
@ VT_UNK
Definition: IProxyLoader.h:21
mc
Definition: mc.PG_single_nu_valid.py:1
lumiFormat.i
int i
Definition: lumiFormat.py:85
ExpressionParsing::IProxyLoader::VT_VECINT
@ VT_VECINT
Definition: IProxyLoader.h:21
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
ExpressionParsing::TMethodCollectionWrapper::m_collectionProxy
TVirtualCollectionProxy * m_collectionProxy
Definition: xAODVariableProxyLoaders.h:140
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168