ATLAS Offline Software
Control/AthContainers/AthContainers/PackedLink.h File Reference

Auxiliary variable type allowing to store ElementLinks as packed 32-bit values. More...

#include "AthContainers/PackedLinkImpl.h"
#include "AthContainers/tools/PackedLinkVectorFactory.h"
#include "AthContainers/PackedLinkConstAccessor.h"
#include "AthContainers/PackedLinkAccessor.h"
#include "AthContainers/PackedLinkDecorator.h"
Include dependency graph for Control/AthContainers/AthContainers/PackedLink.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

Auxiliary variable type allowing to store ElementLinks as packed 32-bit values.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Sep, 2023 Packed links allow representing ElementLinks as an auxiliary variable that is a 32-bit integer. Individual links are stored as a 24-bit index and an 8-bit container index, which is an index into a linked variable of DataLinks. This saves space, but will add time overhead when accessing the variable due to conversions back and forth from ElementLink.

The usual way of declaring a packed link variable in an xAOD container class is to use the macros defined in xAODCore/PackedLink.h:

...
class FooAuxContainer_v1 : public xAOD::AuxContainerBase {
...
private:
AUXVAR_PACKEDLINKVEC_DECL (std::vector, Container, cvec);
};

This will declare the auxilary variable clink to be a packed link to elements of Container, and cvec to ba a vector of such packed links.

Packed link variables are accessed using Accesor classes as usual, where the type is given as SG::PackedLink<Container>. So one can write, for example,

Foo& foo = ...;
static const SG::Accessor<SG::PackedLink<Container> > clinkAcc ("clink");
ElementLink<Container> l = clinkAcc (foo);
size_t index = clinkAcc (foo).index();
clinkAcc(foo) = ElementLink<Container> (...);
cvecAcc ("cvec");
size_t sz = cvecAcc (foo).size();
ElementLink<Container> l2 = cvecAcc (foo)[1];
for (ElementLink<Container> l3 = cvecAcc (foo)) { ... }
std::vector<ElementLink<Container> > lvec = cvecAcc (foo);
cvecAcc (foo)[1] = ElementLink<Container> (...);
cvecAcc (foo) = std::vector<ElementLink<Container> > (...);

ConstAccessor and Decorator should work as expected. The accessors can also be used to create dynamic packed link variables.

For each packed link variable, there is an additional ‘linked’ variable created automatically. In the example above, these would be named clink_linked and cvec_linked. Normally you don't need to refer to these directly, but you may need to name them if you are selecting individual variables to write.

Definition in file Control/AthContainers/AthContainers/PackedLink.h.

Foo
Definition: FooBar.h:9
fitman.sz
sz
Definition: fitman.py:527
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
index
Definition: index.py:1
xAOD::AuxContainerBase
Common base class for the auxiliary containers.
Definition: AuxContainerBase.h:59
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
Container
storage of the time histories of all the cells
skel.l2
l2
Definition: skel.GENtoEVGEN.py:399