10#include <TClassEdit.h>
12#include <TBaseClass.h>
13#include <TCollectionProxyInfo.h>
29const bool mn = getenv(
"MN_DEBUG");
43 return cls->GetBaseClassOffset(
base );
53 std::vector< std::string > args;
59 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
60 TClassEdit::GetSplit( dvclass->GetName(), args, tailloc );
62 assert( args.size() > 1 );
65 std::string elname = args[ 1 ];
66 assert( elname.size() > 0 );
69 TClass* elclass = TClass::GetClass( elname.c_str() );
71 ::Error(
"xAOD::TDVCollectionProxy",
"Cannot find class %s",
90 TIter next( dvclass->GetListOfBases() );
91 while( TBaseClass* bcl =
dynamic_cast< TBaseClass*
>( next() ) ) {
92 TClass* cc = bcl->GetClassPointer();
93 if( strncmp( cc->GetName(),
"DataVector", 10 ) == 0 ) {
96 if( strncmp( cc->GetName(),
"DataVector<", 11 ) == 0 )
113 std::string findDVElement( TClass* cl ) {
117 TClass::GetClass(
"DataVector<xAOD::TDVCollectionProxyDummy>" );
119 Error(
"xAOD::findDVElement",
120 "Couldn't load the dictionary for "
121 "DataVector<xAOD::TDVCollectionProxyDummy>" );
127 const char*
name =
cl->GetName();
128 if( strncmp(
name,
"DataVector<", 11 ) == 0 ) {
130 elt = std::string(
name + 11, strlen(
name ) - 11 - 1 );
134 const std::string::size_type comma = elt.find(
',' );
135 if( comma != std::string::npos ) {
143 TIter
next(
cl->GetListOfBases() );
144 while( TBaseClass* bcl =
dynamic_cast< TBaseClass*
>(
next() ) ) {
145 TClass*
cc = bcl->GetClassPointer();
146 elt = findDVElement( cc );
147 if( ! elt.empty() ) {
194 using Env_t = ROOT::TCollectionProxyInfo::Environ<TEnvBuff>;
201 Env_t& e = *
reinterpret_cast< Env_t*
>( env );
213 Env_t& e = *
reinterpret_cast< Env_t*
>( env );
221 char* start = c[ 0 ];
222 buff.fEltPtr = start + buff.fOffset;
234 static void*
next(
void* env ) {
236 Env_t& e = *
reinterpret_cast< Env_t*
>( env );
239 buff.fIndex += e.fIdx;
241 if( buff.fIndex >= e.fSize ) {
244 char* ptr = c[ buff.fIndex ];
245 buff.fEltPtr = ptr + buff.fOffset;
252 static void*
size(
void* env ) {
255 e->fSize =
cont( env )->size();
256 return &( e->fSize );
264 cont( env )->clear();
281 ::Fatal(
"xAOD::TDVCollectionProxy",
"resize function not specified!" );
286 ::Fatal(
"xAOD::TDVCollectionProxy",
"construct not implemented" );
292 ::Fatal(
"xAOD::TDVCollectionProxy",
"destruct not implemented" );
300 const std::type_info &elem_typeinfo = dv->dvlinfo_v().elt_tinfo();
303 if(
mn) cout <<
"PROX: feed, typename=" << ru_type.getTypeName() <<
" typesize=" << ru_type.getSize() <<endl;
306 for(
size_t i=0; i<
size; i++) {
307 void *obj = ru_type.create();
309 dv->dvlinfo_v().push(dv,obj);
317 ::Fatal(
"xAOD::TDVCollectionProxy",
"collect not implemented" );
336 fValDiff =
sizeof(
void* );
354 delete fValue.exchange(
nullptr );
372 : TGenCollectionProxy( rhs ),
384 delete fValue.exchange(
nullptr );
400 ::TGenCollectionProxy::PushProxy( objstart );
407 buff.fOffset = fOffset;
411 char* dvstart =
reinterpret_cast< char*
>( objstart ) + fContoff;
419 const std::vector< char* >&
vec = dv->stdcont();
422 const_cast< std::vector< char* >*
>( &
vec );
452 TClass* cl = TClass::GetClass(
fName );
454 ::Fatal(
"xAOD::TDVCollectionProxy::InitializeEx",
455 "Couldn't find dictionary for class %s",
461 const std::string eltname = findDVElement( cl );
462 if( eltname.empty() ) {
463 ::Fatal(
"xAOD::TDVCollectionProxy::InitializeEx",
464 "Class \"%s\" doesn't seem to be a DataVector",
480 fValDiff =
sizeof(
void* );
485 TGenCollectionProxy::InitializeEx( silent );
488 fSTL_type = ROOT::kSTLlist;
492 delete fValue.exchange(
nullptr );
494 if( fVal )
delete fVal;
495 fValue =
new TGenCollectionProxy::Value( eltname.c_str(),
false );
496 fVal =
new TGenCollectionProxy::Value( *fValue );
531 const char* conttype ) {
538 TClass* dvclass = TClass::GetClass( conttype );
540 ::Fatal(
"xAOD::TDVCollectionProxy::FindOffsets",
541 "Cannot find class %s", conttype );
550 ::Fatal(
"xAOD::TDVCollectionProxy::FindOffsets",
551 "Couldn't find element type of %s",
552 dvclass->GetName() );
566 std::string elttype2 = elttype;
567 if( elttype2[ elttype2.size() - 1 ] ==
'*' ) {
568 elttype2.erase( elttype2.size() - 1 );
570 fEltType = TClass::GetClass( elttype2.c_str() );
574 ::Fatal(
"xAOD::TDVCollectionProxy::FindOffsets",
575 "Couldn't find dictionaries for DV element "
576 "type(s) for %s", conttype );
std::vector< size_t > vec
An STL vector of pointers that by default owns its pointed-to elements.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Helper functions for accessing the container data via the proxy.
static void * feed(void *, void *to, size_t size)
static void * next(void *env)
Return a following element of the container.
static void * create_env()
Return a new environment structure.
std::vector< char * > Cont_t
The container type.
static void * clear(void *env)
Erase the container.
ROOT::TCollectionProxyInfo::Environ< TEnvBuff > Env_t
The Root proxy environment structure.
static void * first(void *env)
Return the first element of the container.
static void resize(void *, size_t)
Not implemented for xAOD.
static void * collect(void *, void *)
Not implemented for xAOD.
static void * size(void *env)
Return the size of the container.
static void destruct(void *, size_t)
Not implemented for xAOD.
static Cont_t * cont(void *env)
Fetch the container from a proxy environment.
static void * construct(void *, size_t)
Not implemented for xAOD.
Dummy class to use as the DataVector template argument for the class we give to the Root proxy.
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Function initialising the proxy just in time.
void FindOffsets(const char *elttype, const char *conttype)
Initialize the cached pointer offsets.
TClass * fEltBase
The element type to which the DV representation points.
Bool_t fInitialized
Flag for knowing whether the class was initialised already.
TClass * fEltType
The declared element type of the DV.
void SetResize(Sizing_t func)
Set the resize(...) function used by the proxy.
virtual TVirtualCollectionProxy * Generate() const
Clone this object.
TString fName
Name of the container that this class proxies.
virtual void PushProxy(void *objstart)
Start working with a new collection.
ptrdiff_t fContoff
The offset of the underlying DataVector in the declared type.
ptrdiff_t fOffset
Offset between the DV base pointer and the full DV pointer.
TGenCollectionProxy::Sizing_t Sizing_t
Make the definition of Sizing_t public.
TDVCollectionProxy(const char *conttype)
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...
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
int safeGetBaseOffset(TClass *cls, TClass *base)
Find base class offset using Reflex.
TClass * classFromDVClass(TClass *dvclass)
Find the contained class in a DataVector.
TClass * findDVBase(TClass *dvclass)
Find the unique base DataVector class.
Helper to disable undefined behavior sanitizer for a function.
#define NO_SANITIZE_UNDEFINED
Proxy environment buffer.
void * fEltPtr
The last element pointer to have been returned.
size_t fIndex
The index of the last element retrieved.
Cont_t * fCont
Pointer to the container.
int fOffset
Offset between the pointer held by the DV and the start of the object.