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

#include <xAODVariableProxyLoaders.h>

Inheritance diagram for ExpressionParsing::xAODElementProxyLoader:
Collaboration diagram for ExpressionParsing::xAODElementProxyLoader:

Public Types

enum  VariableType {
  VT_UNK, VT_INT, VT_DOUBLE, VT_VECINT,
  VT_VECDOUBLE, VT_VECEMPTY
}
 

Public Member Functions

 xAODElementProxyLoader ()=default
 
 xAODElementProxyLoader (const SG::AuxElement *auxElement)
 
void setData (const SG::AuxElement *auxElement)
 
virtual IProxyLoader::VariableType variableTypeFromString (const std::string &varname) const
 
virtual int loadIntVariableFromString (const std::string &varname) const
 
virtual double loadDoubleVariableFromString (const std::string &varname) const
 
virtual std::vector< int > loadVecIntVariableFromString (const std::string &varname) const
 
virtual std::vector< double > loadVecDoubleVariableFromString (const std::string &varname) const
 
virtual void reset ()
 

Protected Types

using accessorCache_t = CxxUtils::ConcurrentStrMap< BaseAccessorWrapper *, CxxUtils::SimpleUpdater >
 

Protected Member Functions

template<class TYPE , class AUX >
bool try_type (const std::string &varname, const std::type_info *ti, const AUX *data) const
 
template<class AUX >
IProxyLoader::VariableType try_all_known_types (const std::string &varname, const AUX *data, bool isVector) const
 

Protected Attributes

accessorCache_t m_accessorCache ATLAS_THREAD_SAFE
 

Private Attributes

const SG::AuxElementm_auxElement {nullptr}
 

Detailed Description

Definition at line 169 of file xAODVariableProxyLoaders.h.

Member Typedef Documentation

◆ accessorCache_t

Definition at line 164 of file xAODVariableProxyLoaders.h.

Member Enumeration Documentation

◆ VariableType

Enumerator
VT_UNK 
VT_INT 
VT_DOUBLE 
VT_VECINT 
VT_VECDOUBLE 
VT_VECEMPTY 

Definition at line 21 of file IProxyLoader.h.

Constructor & Destructor Documentation

◆ xAODElementProxyLoader() [1/2]

ExpressionParsing::xAODElementProxyLoader::xAODElementProxyLoader ( )
default

◆ xAODElementProxyLoader() [2/2]

ExpressionParsing::xAODElementProxyLoader::xAODElementProxyLoader ( const SG::AuxElement auxElement)

Definition at line 249 of file xAODVariableProxyLoaders.cxx.

250  : m_auxElement(auxElement)
251  {
252  }

Member Function Documentation

◆ loadDoubleVariableFromString()

double ExpressionParsing::xAODElementProxyLoader::loadDoubleVariableFromString ( const std::string &  varname) const
virtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 294 of file xAODVariableProxyLoaders.cxx.

295  {
296  return m_accessorCache.at(varname)->getDoubleValue(m_auxElement);
297  }

◆ loadIntVariableFromString()

int ExpressionParsing::xAODElementProxyLoader::loadIntVariableFromString ( const std::string &  varname) const
virtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 289 of file xAODVariableProxyLoaders.cxx.

290  {
291  return m_accessorCache.at(varname)->getIntValue(m_auxElement);
292  }

◆ loadVecDoubleVariableFromString()

std::vector< double > ExpressionParsing::xAODElementProxyLoader::loadVecDoubleVariableFromString ( const std::string &  varname) const
virtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 304 of file xAODVariableProxyLoaders.cxx.

305  {
306  throw std::runtime_error("xAODElementProxyLoader can't load vector types");
307  }

◆ loadVecIntVariableFromString()

std::vector< int > ExpressionParsing::xAODElementProxyLoader::loadVecIntVariableFromString ( const std::string &  varname) const
virtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 299 of file xAODVariableProxyLoaders.cxx.

300  {
301  throw std::runtime_error("xAODElementProxyLoader can't load vector types");
302  }

◆ reset()

void ExpressionParsing::xAODProxyLoader::reset ( )
virtualinherited

Implements ExpressionParsing::IProxyLoader.

Definition at line 196 of file xAODVariableProxyLoaders.cxx.

197  {
198  for (auto x : m_accessorCache) delete x.second;
199  // m_accessorCache.clear(); // not supported by ConcurrentStrMap
200  }

◆ setData()

void ExpressionParsing::xAODElementProxyLoader::setData ( const SG::AuxElement auxElement)

Definition at line 254 of file xAODVariableProxyLoaders.cxx.

255  {
256  m_auxElement = auxElement;
257  }

◆ try_all_known_types()

template<class AUX >
IProxyLoader::VariableType ExpressionParsing::xAODProxyLoader::try_all_known_types ( const std::string &  varname,
const AUX *  data,
bool  isVector 
) const
protectedinherited

Definition at line 220 of file xAODVariableProxyLoaders.cxx.

222  {
224  const SG::auxid_t auxid = r.findAuxID(varname);
225  if (auxid != SG::null_auxid) {
226  const std::type_info *ti = r.getType(auxid);
227  // Try integer types:
228  if ( try_type<int>(varname, ti, data) ||
229  try_type<bool>(varname, ti, data) ||
230  try_type<unsigned int>(varname, ti, data) ||
231  try_type<char>(varname, ti, data) ||
232  try_type<uint8_t>(varname, ti, data) ||
233  try_type<unsigned short>(varname, ti, data) ||
234  try_type<short>(varname, ti, data) ) {
236  }
237  // Try floating point types:
238  if ( try_type<float>(varname, ti, data) ||
239  try_type<double>(varname, ti, data) ) {
241  }
242  }
243  return VT_UNK;
244  }

◆ try_type()

template<class TYPE , class AUX >
bool ExpressionParsing::xAODProxyLoader::try_type ( const std::string &  varname,
const std::type_info *  ti,
const AUX *  data 
) const
protectedinherited

Definition at line 203 of file xAODVariableProxyLoaders.cxx.

204  {
205  if (*ti == typeid(TYPE)) {
206  auto accWrap = std::make_unique<AccessorWrapper<TYPE>>(varname);
207  if (accWrap && accWrap->isValid(data)) {
208  m_accessorCache.insert_or_assign(varname, accWrap.release());
209  return true;
210  } else if (accWrap) {
212  const SG::auxid_t auxid = r.findAuxID(varname);
213  throw std::runtime_error("Unsupported aux element type '"+r.getTypeName(auxid)+"' for '"+varname+"'");
214  }
215  }
216  return false;
217  }

◆ variableTypeFromString()

IProxyLoader::VariableType ExpressionParsing::xAODElementProxyLoader::variableTypeFromString ( const std::string &  varname) const
virtual

Implements ExpressionParsing::IProxyLoader.

Definition at line 259 of file xAODVariableProxyLoaders.cxx.

260  {
261  // Try TMethodWrapper
262  auto container = m_auxElement->container();
263  const std::type_info &containerTypeinfo = typeid(*container);
264  TClass *containerClass = TClass::GetClass(containerTypeinfo);
265  if (!containerClass) {
266  containerClass = TClass::GetClass(SG::normalizedTypeinfoName(containerTypeinfo).c_str());
267  }
268  if (containerClass) {
269  std::unique_ptr<TMethodWrapper> accWrap;
270  if( !strcmp(containerClass->GetName(),"SG::AuxElementStandaloneData") ) { /* special case where the element type is the aux element */
271  accWrap = std::make_unique<TMethodWrapper>( typeid(*m_auxElement) , varname );
272  } else {
273  TVirtualCollectionProxy* collProxy = containerClass->GetCollectionProxy();
274  if(collProxy) {
275  const std::type_info &elementTypeinfo = *(collProxy->GetValueClass()->GetTypeInfo());
276  accWrap = std::make_unique<TMethodWrapper>(elementTypeinfo, varname);
277  }
278  }
279  if (accWrap && accWrap->isValid(m_auxElement)) {
280  const IProxyLoader::VariableType vtype = accWrap->variableType();
281  m_accessorCache.insert_or_assign(varname, accWrap.release());
282  return vtype;
283  }
284  }
285 
286  return try_all_known_types(varname, m_auxElement, false);
287  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

accessorCache_t m_accessorCache ExpressionParsing::xAODProxyLoader::ATLAS_THREAD_SAFE
mutableprotectedinherited

Definition at line 165 of file xAODVariableProxyLoaders.h.

◆ m_auxElement

const SG::AuxElement* ExpressionParsing::xAODElementProxyLoader::m_auxElement {nullptr}
private

Definition at line 183 of file xAODVariableProxyLoaders.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
ExpressionParsing::IProxyLoader::VT_VECEMPTY
@ VT_VECEMPTY
Definition: IProxyLoader.h:21
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:640
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::IProxyLoader::VT_VECDOUBLE
@ VT_VECDOUBLE
Definition: IProxyLoader.h:21
x
#define x
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
ExpressionParsing::IProxyLoader::VariableType
VariableType
Definition: IProxyLoader.h:21
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
ExpressionParsing::IProxyLoader::VT_DOUBLE
@ VT_DOUBLE
Definition: IProxyLoader.h:21
ExpressionParsing::IProxyLoader::VT_UNK
@ VT_UNK
Definition: IProxyLoader.h:21
ExpressionParsing::xAODElementProxyLoader::m_auxElement
const SG::AuxElement * m_auxElement
Definition: xAODVariableProxyLoaders.h:183
ExpressionParsing::xAODProxyLoader::try_all_known_types
IProxyLoader::VariableType try_all_known_types(const std::string &varname, const AUX *data, bool isVector) const
Definition: xAODVariableProxyLoaders.cxx:220
ExpressionParsing::IProxyLoader::VT_VECINT
@ VT_VECINT
Definition: IProxyLoader.h:21
ExpressionParsing::IProxyLoader::VT_INT
@ VT_INT
Definition: IProxyLoader.h:21
TYPE
#define TYPE(CODE, TYP, IOTYP)
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
runLayerRecalibration.isVector
string isVector
Definition: runLayerRecalibration.py:125
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.