8#ifndef COLUMNAR_VARIANT_VARIANT_LINK_COLUMN_H
9#define COLUMNAR_VARIANT_VARIANT_LINK_COLUMN_H
66 explicit operator bool ()
const noexcept
88 template<ContainerIdConcept CI2>
91 static constexpr unsigned variantIndex = CI::template getVariantIndex<CI2>();
93 return m_link->isValid() &&
dynamic_cast<typename CI2::xAODObjectRangeType*
>(
m_link->getStorableObjectPointer());
97 template<ContainerIdConcept CI2>
100 static constexpr unsigned variantIndex = CI::template getVariantIndex<CI2>();
101 static_assert (variantIndex <
CI::numVariants,
"invalid container id");
102 return m_link->isValid() && (**m_link) == &
id.getXAODObject();
116 template<ContainerIdConcept CI2>
119 static constexpr unsigned variantIndex = CI::template getVariantIndex<CI2>();
120 static_assert (variantIndex <
CI::numVariants,
"invalid container id");
134 template<
typename... CIList>
137 return str << obj.getXAODObject() <<
"/" << obj.getXAODObject()->type();
144 template<ContainerIdConcept CIBase,
typename... CIList>
169 template<ContainerIdConcept CI2>
170 requires (CI::template isValidContainer<CI2>())
173 auto*
container =
static_cast<const typename CIBase::xAODElementLinkType*
>(obj.getXAODObjectNoexcept().
container());
186 template<ContainerIdConcept CIBase,ContainerIdConcept... CIList, ColumnarArrayMode CM>
195 ObjectLink (
typename CM::LinkIndexType val_link,
const typename CM::LinkKeyType* val_keys,
void** val_dataArea)
201 throw std::logic_error (
"can't call xAOD function in columnar mode");
205 explicit operator bool ()
const noexcept
219 if (
m_link == CM::invalidLinkValue)
230 throw std::runtime_error (
"link key does not match any known container: " + std::to_string(key));
238 template<ContainerIdConcept CI2>
241 static constexpr unsigned variantIndex = CI::template getVariantIndex<CI2>();
242 static_assert (variantIndex <
CI::numVariants,
"invalid container id");
247 template<ContainerIdConcept CI2>
250 static constexpr unsigned variantIndex = CI::template getVariantIndex<CI2>();
251 static_assert (variantIndex <
CI::numVariants,
"invalid container id");
263 return m_link == obj.m_link;
267 const auto thatKey = obj.getLinkKey();
272 if (obj.m_keys[i] == thatKey)
276 }
else if (obj.m_keys[i] == thatKey)
283 template<ContainerIdConcept CI2>
286 static constexpr unsigned variantIndex = CI::template getVariantIndex<CI2>();
287 static_assert (variantIndex <
CI::numVariants,
"invalid container id");
296 return CM::getLinkIndex (
m_link);
301 return CM::getLinkKey (
m_link);
315 return str << obj.getLinkKey() <<
"/" << obj.getLinkIndex();
324 template<
ColumnAccessMode CAM,ContainerIdConcept CIBase,ContainerIdConcept... CIList, ColumnarArrayMode CM>
341 std::string dataName = optionsArray.baseName + optionsArray.dataSuffix;
342 std::string keysName = optionsArray.baseName +
".keys";
344 auto dataInfo = options.makeColumnInfo();
345 dataInfo.offsetName = optionsArray.offsetName;
346 dataInfo.variantLinkKeyColumn = keysName;
350 auto keyInfo = options.makeColumnInfo();
355 columnarTool.addColumn (dataName,
m_dataData.get(), std::move (dataInfo));
357 columnarTool.addColumn (keysName,
m_keysData.get(), std::move (keyInfo));
376 auto operator () (
void** dataArea, std::size_t
index)
const noexcept
379 auto *
data =
static_cast<const typename CM::LinkIndexType*
>(dataArea[
m_dataIndex]);
380 auto *keys =
static_cast<const typename CM::LinkKeyType*
>(dataArea[
m_keysIndex]);
384 [[nodiscard]]
auto operator () (
void** dataArea, std::size_t beginIndex, std::size_t endIndex)
const noexcept
387 auto *
data =
static_cast<const typename CM::LinkIndexType*
>(dataArea[
m_dataIndex]);
388 auto *keys =
static_cast<const typename CM::LinkKeyType*
>(dataArea[
m_keysIndex]);
392 template<ContainerIdConcept CI2>
396 auto *
data =
static_cast<typename CM::LinkIndexType*
>(dataArea[
m_dataIndex]);
397 auto *keys =
static_cast<const typename CM::LinkKeyType*
>(dataArea[
m_keysIndex]);
398 data[
index] = CM::mergeLinkKeyIndex (keys[VariantCI::template getVariantIndex<CI2>()], obj.getIndex());
403 auto *
data =
static_cast<const typename CM::LinkIndexType*
>(dataArea[
m_dataIndex]);
404 return data !=
nullptr;
442 auto operator () (
void** dataArea, std::size_t
index)
const noexcept
447 auto operator () (
void** dataArea, std::size_t beginIndex, std::size_t endIndex)
const noexcept
char data[hepevt_bytes_allocation_ATLAS]
ElementLink implementation for ROOT usage.
a class representing a single object (electron, muons, etc.)
OptObjectId< CI, CM > opt_value() const
get an OptObjectId for this link
ObjectLink(typename CM::LinkIndexType val_link, const typename CM::LinkKeyType *val_keys, void **val_dataArea)
bool isContainer() const
whether this link is valid and points to an object of the given container
auto getLinkIndex() const noexcept
VariantContainerId< CIBase, CIList... > CI
auto getLinkKey() const noexcept
OptObjectId< CI2, CM > tryGetVariant() const
return the ObjectId if it is in the given container or nullopt otherwise
const CI::xAODObjectIdType * getXAODObject() const
const CM::LinkKeyType * m_keys
bool has_value() const noexcept
whether this is a valid link
bool has_value() const noexcept
whether this is a valid link
ElementLink< typename CI::xAODElementLinkType > LinkType
OptObjectId< CI, CM > opt_value() const
get an OptObjectId for this link
VariantContainerId< CIBase, CIList... > CI
const CI::xAODObjectIdType * getXAODObject() const
ObjectLink(const LinkType *val_link)
bool isContainer() const
whether this link is valid and points to an object of the given container
OptObjectId< CI2, CM > tryGetVariant() const
return the ObjectId if it is in the given container or nullopt otherwise
a class representing a single optional object (electron, muons, etc.)
static constexpr bool isDefined
VariantContainerId< CIBase, CIList... > CI
ContainerFreeAccessor()=default
static constexpr unsigned internalOffsetColumns
ContainerFreeAccessor(ColumnarTool< CM > &columnarTool, ColumnAccessorOptions &&options, ColumnAccessorOptionsArray &&optionsArray)
bool isAvailable(void **dataArea) const noexcept
static constexpr ColumnAccessMode CAM
ContainerFreeAccessor< ObjectLink< CI, CM >, CAM, CM > BaseAccessor
static constexpr unsigned internalOffsetColumns
VariantContainerId< CIBase, CIList... > VariantCI
void set(void **dataArea, std::size_t index, ObjectId< CI2, CM > obj) const noexcept
bool isAvailable(void **dataArea) const noexcept
std::unique_ptr< ColumnAccessorDataArray > m_keysData
static constexpr std::array containerIdNames
std::unique_ptr< ColumnAccessorDataArray > m_dataData
ContainerFreeAccessor()=default
ContainerFreeAccessor(ColumnarTool< CM > &columnarTool, ColumnAccessorOptions &&options, ColumnAccessorOptionsArray &&optionsArray)
static constexpr bool isDefined
ContainerFreeAccessor(ContainerFreeAccessor &&that)
static constexpr bool isDefined
VariantContainerId< CIBase, CIList... > CI
static constexpr bool hasSetter
static constexpr bool viewIsReference
static void updateColumnInfo(ColumnInfo &)
ElementLink< typename CI::xAODElementLinkType > MemoryType
static auto makeSetter(void **)
static auto makeViewer(void **)
a help implementation of AccessorTemplate that handles type conversions
concept for a container id
VectorConvertView(FunctionType &&, ViewType &&) -> VectorConvertView< std::decay_t< FunctionType >, std::decay_t< ViewType > >
void moveAccessor(unsigned &dataIndex, std::unique_ptr< ColumnAccessorDataArray > &accessorData, unsigned &sourceIndex, std::unique_ptr< ColumnAccessorDataArray > &sourceData)
bool operator==(const ObjectId< CI, ColumnarModeXAOD > &lhs, const ObjectId< CI, ColumnarModeXAOD > &rhs)
ColumnAccessMode
an enum for the different access modes for a column
constexpr ColumnarOffsetType invalidObjectIndex
the value for an invalid element index
std::ostream & operator<<(std::ostream &str, const ObjectId< CI, ColumnarModeXAOD > &obj)
a struct that contains meta-information about each column that's needed to interface the column with ...
a special column type that behaves like an OptObjectId, but applies an internal cast in xAOD mode
static constexpr std::size_t numVariants
typename CIBase::xAODObjectIdType xAODObjectIdType