17#include "AthLinks/ElementLinkBase.h"
18#include "AthLinks/DataLinkBase.h"
23#include "TVirtualCollectionProxy.h"
42 std::string tname =
cl->GetName();
43 tname +=
"::vector_type";
44 TDataType* typ = gROOT->GetType (tname.c_str());
46 return TClass::GetClass (typ->GetFullTypeName());
73 const TClass* vecClass = factory->vecClass();
74 m_proxy.reset (vecClass->GetCollectionProxy()->Generate());
75 m_obj = factory->objClass()->New ();
107 if (isPacked) std::abort();
108 const TClass* vecClass = factory->vecClass();
109 m_proxy.reset (vecClass->GetCollectionProxy()->Generate());
129 size_t sz = other.size();
134 const void* otherPtr = other.toPtr();
135 rootType.copyRange (this->
toPtr(), otherPtr,
sz);
157 return std::make_unique<RootAuxVector> (*
this);
254 size_t eltsz =
m_proxy->GetIncrement();
259 if (-offs >
static_cast<ptrdiff_t
>(pos)) offs = -pos;
260 char* beg =
reinterpret_cast<char*
>(
m_proxy->At(0));
261 rootType.copyRange (beg + eltsz*(pos+offs),
269 size_t oldsz =
m_proxy->Size();
270 m_proxy->Allocate (oldsz + offs,
false);
271 char* beg =
reinterpret_cast<char*
>(
m_proxy->At(0));
273 rootType.copyRange (beg + eltsz*(pos+offs),
276 rootType.clearRange (beg + eltsz*pos, offs);
303 void* src,
size_t src_pos,
size_t src_n,
306 size_t eltsz =
m_proxy->GetIncrement();
310 char* srcp =
reinterpret_cast<char*
> (src);
311 char* begp = srcp + src_pos*eltsz;
317 rootType.copyRange (
reinterpret_cast<char*
>(this->
toPtr()) + pos*eltsz,
337 return m_factory->objClass()->GetTypeInfo();
390 TVirtualCollectionProxy* proxy =
m_vecClass->GetCollectionProxy();
393 TClass* vecClass = lookupVectorType (objClass);
396 Int_t offs = objClass->GetBaseClassOffset (vecClass);
399 proxy = vecClass->GetCollectionProxy();
403 std::string(
"Can't find vector base class in ") +
404 objClass->GetName());
410 std::string err =
"Can't find collection proxy for ";
412 throw std::runtime_error (err.c_str());
416 ATHCONTAINERS_ERROR(
"RootAuxVectorFactory::RootAuxVectorFactory",
417 std::string(
"No type_info available for class ") +
418 m_vecClass->GetName() +
419 std::string(
". There is probably a missing dictionary. We will likely crash further on."));
422 TClass* eltClass = proxy->GetValueClass();
426 const std::type_info* ti = eltClass->GetTypeInfo();
435 CxxUtils::ClassName::match_t matches;
436 if (clname.match (pat1, matches)) {
438 if (eltClass->GetBaseClass (
"ElementLinkBase") ==
nullptr) {
442 else if (clname.match (pat2, matches)) {
445 TVirtualCollectionProxy* proxy2 = eltClass->GetCollectionProxy();
447 TClass* innerEltClass = proxy2->GetValueClass();
449 if (innerEltClass->GetBaseClass (
"ElementLinkBase") ==
nullptr) {
455 else if (clname.match (pat3, matches)) {
458 else if (clname.match (pat4, matches)) {
464 m_type.init (proxy->GetType());
483std::unique_ptr<SG::IAuxTypeVector>
489 return std::make_unique<RootAuxVector> (
this,
auxid,
size, capacity,
514std::unique_ptr<SG::IAuxTypeVector>
523 return std::make_unique<RootAuxVector> (
this,
auxid, data, isPacked, ownFlag,
537 if (n == 0)
return nullptr;
538 size_t eltsz =
m_type.getSize();
544 m_type.copyRange (dstptr + eltsz*dst_index, dstptr + eltsz*src_index, n);
545 return dstptr + eltsz*dst_index;
548 const char* srcptr =
reinterpret_cast<const char*
>(src.getDataArrayAllowMissing (
auxid));
550 m_type.copyRange (dstptr + eltsz*dst_index, srcptr + eltsz*src_index, n);
551 return dstptr + eltsz*dst_index;
554 m_type.clearRange (dstptr + eltsz*dst_index, n);
600 char* dstptr =
copyImpl (
auxid, dst, dst_index, src, src_index, n);
603 size_t eltsz =
m_type.getSize();
604 for (
size_t i = 0; i < n; i++) {
609 size_t eltsz =
m_type.getSize();
610 for (
size_t i = 0; i < n; i++) {
611 std::vector<ElementLinkBase>& v =
612 *
reinterpret_cast<std::vector<ElementLinkBase>*
> (dstptr +i*eltsz);
619 TVirtualCollectionProxy* proxy =
m_vecClass->GetCollectionProxy();
620 TClass* eltClass = proxy->GetValueClass();
622 std::format(
"Tried to copy an auxiliary variable of type {}. However, the target type is not a DataVector and does not have a pointer value type. Such types are only fully supported for fully specified Factory objects, not for this dynamic factory using ROOT reflection information. Perhaps you are trying to write this type by mistake. Otherwise, try creating a SG::Accessor object for this type during event processing to ensure a proper Factory is available.",
623 eltClass->GetName()));
646 void* aptr =
a.getDataArray (
auxid);
647 void* bptr = &
a == &b ? aptr : b.getDataArray (
auxid);
648 m_type.swapRange (aptr, aindex, bptr, bindex, n);
715 std::string alloc_name;
716 if (cn.ntargs() >= 2) {
717 alloc_name = cn.targ(1).fullName();
719 else if (cn.ntargs() == 1) {
720 alloc_name =
"std::allocator<" + cn.targ(0).fullName();
721 if (alloc_name[alloc_name.size()-1] ==
'>') alloc_name +=
" ";
746 std::string(
"Cannot call toTransient for ElementLink with non-pointer element: ") +
751 char* ptr =
reinterpret_cast<char*
> (
vec.toPtr());
752 size_t n =
vec.size();
754 size_t eltsz =
m_type.getSize();
757 for (
size_t i = 0; i < n; i++) {
762 for (
size_t i = 0; i < n; i++) {
763 std::vector<ElementLinkBase>& v =
764 *
reinterpret_cast<std::vector<ElementLinkBase>*
> (ptr +i*eltsz);
766 el.toTransient (pdict);
771 for (
size_t i = 0; i < n; i++) {
776 for (
size_t i = 0; i < n; i++) {
777 std::vector<DataLinkBase>& v =
778 *
reinterpret_cast<std::vector<DataLinkBase>*
> (ptr +i*eltsz);
780 dl.toTransient (pdict);
Manage lookup of vectors of auxiliary data.
std::vector< size_t > vec
Recursively separate out template arguments in a C++ class name.
Dynamic implementation of IAuxVectorFactory, relying on root's vector proxy.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Type-independent part of DataLink; holds the persistent state.
Base class for ElementLinks to vectors of pointers.
Manage lookup of vectors of auxiliary data.
const void * getDataArray(SG::auxid_t auxid) const
Return a const pointer to the start of an aux data vector.
Interface for non-const operations on an auxiliary store.
Abstract interface for manipulating vectors of arbitrary types.
bool isLinked() const
Return true if this variable is linked from another one.
auxid_t auxid() const
Return the auxid of the variable this vector represents.
void storeDataSpan(void *beg, size_t size)
Update the stored span.
const AuxDataSpanBase & getDataSpan() const
Return a reference to a description of this vector's start+size.
IAuxTypeVector(auxid_t auxid, bool isLinked)
Constructor.
Dynamic implementation of IAuxVectorFactory, relying on root's vector proxy.
RootAuxVectorFactory(TClass *objClass)
Constructor.
size_t offset() const
Return the offset of the vector within the object.
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const override
Copy elements between vectors.
virtual bool isDynamic() const override
True if the vectors created by this factory work by dynamic emulation (via TVirtualCollectionProxy or...
virtual ~RootAuxVectorFactory() override
Destructor.
virtual void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const override
Swap elements between vectors.
RootUtils::Type m_type
Wrapper for the ROOT type of the element.
char * copyImpl(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const
Helper for copy; returns a pointer to the first destination object, or nullptr if the destination was...
virtual const std::type_info * tiVec() const override
Return the type_info of the overall object.
size_t m_offset
Offset of the STL vector within the overall object.
enum SG::RootAuxVectorFactory::@071257101107162132204103261125230107154016006205 m_isEL
Flag to tell whether we need to do thinning / toTrasnsient.
virtual const std::type_info * tiAlloc() const override
Return the type_info of the vector allocator.
virtual std::string tiAllocName() const override
Return the (demangled) name of the vector allocator.
TClass * m_objClass
The TClass for the overall object.
TClass * m_vecClass
The TClass for the std::vector.
void toTransient(const EventContext &ctx, RootAuxVector &vec) const
Perform post-read processing for one variable.
virtual void copyForOutput(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const override
Copy elements between vectors, possibly applying thinning.
@ ELEMENT_LINK_NONPOINTER
virtual std::unique_ptr< SG::IAuxTypeVector > createFromData(SG::auxid_t auxid, void *data, IAuxTypeVector *linkedVector, bool isPacked, bool ownFlag, bool isLinked) const override
Create a vector object of this type from a data blob.
virtual std::unique_ptr< SG::IAuxTypeVector > create(SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked) const override
Create a vector object of this type.
virtual size_t getEltSize() const override
Return the size of an element of this vector type.
virtual void clear(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const override
Clear a range of elements within a vector.
Dynamic implementation of IAuxTypeVector, relying on root vector proxy.
const RootAuxVectorFactory * m_factory
Pointer back to the factory class for this type.
virtual void toTransient(const EventContext &ctx) override
Perform post-read processing on this auxiliary variable.
void * m_vec
Pointer to the vector object itself.
virtual void * toPtr() override
Return a pointer to the start of the vector's data.
std::unique_ptr< TVirtualCollectionProxy > m_proxy
The collection proxy for the vector.
bool m_ownFlag
Should be delete the vector object?
RootAuxVector(const RootAuxVectorFactory *factory, SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked)
Constructor.
virtual AuxDataSpanBase getDataSpanImpl() const override final
Return a span object describing the current vector.
virtual std::unique_ptr< SG::IAuxTypeVector > clone() const override
Make a copy of this vector.
virtual void * toVector() override
Return a pointer to the overall object.
virtual bool insertMove(size_t pos, void *src, size_t src_pos, size_t src_n, SG::IAuxStore &srcStore) override
Insert elements into the vector via move semantics.
void storeDataSpan()
Update the stored span.
virtual ~RootAuxVector() override
Destructor.
void * m_obj
Pointer to the overall object itself.
virtual bool resize(size_t sz) override
Change the size of the vector.
virtual bool shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the vector.
virtual const std::type_info * objType() const override
Return the type of the complete object to be saved.
virtual void reserve(size_t sz) override
Change the capacity of the vector.
virtual size_t size() const override
Return the size of the vector.
Helper for emitting error messages.
#define ATHCONTAINERS_ERROR(ctx, msg)
IProxyDict * proxyDictFromEventContext()
Return the IProxyDict for this thread's current context.
ClassName()
Default constructor.
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...
SG::auxid_t auxid() const
Return the aux id for this variable.
virtual IAuxTypeVector * linkedVector(SG::auxid_t auxid) override
Return interface for a linked variable.
virtual size_t size() const override
Return the number of elements in the store.
size_t auxid_t
Identifier for a particular aux data item.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
TClass * lookupVectorType(TClass &cl)
Internal function used by xAOD::TAuxStore and xAOD::RAuxStore.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Some out-of-line helpers for ExtendedEventContext.
Minimal span-like object describing the range of an auxiliary variable.
void * beg
Pointer to the start of the variable's vector.