ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::VariableStruct Class Reference

Define structures for fast filling of xAOD objects. More...

#include <VariableStruct.h>

Inheritance diagram for xAOD::VariableStruct:
Collaboration diagram for xAOD::VariableStruct:

Public Member Functions

 VariableStruct (SG::AuxVectorData &cont)

Public Attributes

SG::AuxVectorDatam_cont

Detailed Description

Define structures for fast filling of xAOD objects.

Normally one initializes xAOD objects using the setter interfaces of individual objects. While these are designed to be fast, there is some overhead which can add up if one is creating very many objects. As a faster, but less convenient/safe alternative, one can retrieve pointers to each variable array and then fill those directly without going through the xAOD object interface. The code here provides some support for this. Declare a structure deriving from VariableStruct. Declare each variable using the AUXSTORE_VARSTRUCT_VAR macro. Then when an instance of that structure is created, it will contain pointers to the xAOD variables. For example, for a fictional Cluster xAOD object:

struct ClusterVars : public xAOD::VariableStruct
{
AUXSTORE_VARSTRUCT_VAR(float, xpos);
AUXSTORE_VARSTRUCT_VAR(float, ypos);
};
...
xAOD::ClusterContainer cont = ...;
cont.push_new (nclust, [](){ return new xAOD::Custer; });
ClusterVars vars (cont);
for (size_t i = 0; i < nclust; i++) {
vars.id[i] = clust_id(i);
vars.xpos[i] = clust_xpos(i);
vars.ypos[i] = clust_ypos(i);
}
#define AUXSTORE_VARSTRUCT_VAR(TYPE, NAME)
Declare a member of an xAOD variable struct, giving the type and xAOD variable name.
Define structures for fast filling of xAOD objects.
VariableStruct(SG::AuxVectorData &cont)

Definition at line 62 of file VariableStruct.h.

Constructor & Destructor Documentation

◆ VariableStruct()

xAOD::VariableStruct::VariableStruct ( SG::AuxVectorData & cont)
inline

Definition at line 65 of file VariableStruct.h.

65: m_cont (cont) {}
SG::AuxVectorData & m_cont

Member Data Documentation

◆ m_cont

SG::AuxVectorData& xAOD::VariableStruct::m_cont

Definition at line 66 of file VariableStruct.h.


The documentation for this class was generated from the following file: