ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::AuxInfoBase Class Referenceabstract

Common base class for auxiliary info objects. More...

#include <AuxInfoBase.h>

Inherits SG::IAuxStore, SG::IAuxStoreIO, SG::IAuxStoreHolder, and ILockable.

Inherited by DMTest::CInfoAuxContainer_v1, DMTest::CLinksAuxInfo_v1, DMTest::JVecAuxInfo_v1, DMTest::PLinksAuxInfo_v1, xAOD::CMMRoIAuxInfo_v1, xAOD::CTPResultAuxInfo_v1, xAOD::EnergySumRoIAuxInfo_v1, xAOD::EnergySumRoIAuxInfo_v2, xAOD::EventAuxInfo_v1, xAOD::EventAuxInfo_v2, xAOD::EventAuxInfo_v3, xAOD::EventShapeAuxInfo_v1, xAOD::FileMetaDataAuxInfo_v1, xAOD::JetEtRoIAuxInfo_v1, xAOD::RoiDescriptorStoreAuxInfo_v1, xAOD::TrigDecisionAuxInfo_v1, and xAOD::TrigNavigationAuxInfo_v1.

Public Types

typedef SG::auxid_t auxid_t
 The aux ID type definition.
typedef SG::auxid_set_t auxid_set_t
 The aux ID set type definition.
template<class T, class ALLOC = std::allocator<T>>
using AuxVariable_t = T
 Declare how to wrap variables for this sort of base.
template<class T, class ALLOC = std::allocator<T>>
using LinkedVariable_t = std::vector<T, ALLOC>
enum  AuxStoreType { AST_ObjectStore = 0 , AST_ContainerStore = 1 }
 Type of the auxiliary store. More...

Public Member Functions

 AuxInfoBase (bool allowDynamicVars=true)
 Default constructor.
 AuxInfoBase (const AuxInfoBase &parent)
 Copy constructor.
 AuxInfoBase (SG::IAuxStore *store)
 Constructor receiving a "dynamic auxiliary store".
 ~AuxInfoBase ()
 Destructor.
AuxInfoBase & operator= (const AuxInfoBase &rhs)
 Assignment operator.
template<typename T>
auxid_t getAuxID (const std::string &name, T &, SG::AuxVarFlags flags=SG::AuxVarFlags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
 Get the auxiliary ID for one of the persistent variables.
template<typename T>
void regAuxVar (auxid_t auxid, const std::string &name, T &info)
 Register one of the persistent variables internally.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore=SG::auxid_set_t())=0
 Move all elements from other to this store.
Functions implementing the SG::IAuxStoreHolder interface
virtual SG::IAuxStore * getStore () override
 Get the currently used internal store object.
virtual const SG::IAuxStore * getStore () const override
 Get the currently used internal store object.
virtual void setStore (SG::IAuxStore *store) override
 Set a different internal store object.
virtual AuxStoreType getStoreType () const override
 Return the type of the store object.
Functions implementing the SG::IConstAuxStore interface
virtual const void * getData (auxid_t auxid) const override
 Get a pointer to a given array.
virtual const SG::IAuxTypeVector * getVector (SG::auxid_t auxid) const override final
 Return vector interface for one aux data item.
virtual const auxid_set_t & getAuxIDs () const override
 Get the types(names) of variables handled by this container.
virtual const auxid_set_t & getDecorIDs () const override
 Get the types(names) of decorations handled by this container.
virtual SG::auxid_set_t getCopyIDs (bool warnUnlocked=false) const override
 Get the set of variables that we should deep copy.
virtual bool isDecoration (auxid_t auxid) const override
 Test if a variable is a decoration.
virtual void * getDecoration (auxid_t auxid, size_t size, size_t capacity) override
 Get a pointer to a given array, as a decoration.
virtual void lock () override
 Lock the container.
virtual bool clearDecorations () override
 Clear all decorations.
virtual size_t size () const override
 Get the size of the container.
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration.
virtual const SG::IAuxTypeVector * linkedVector (SG::auxid_t auxid) const override
 Return interface for a linked variable.
virtual void toTransient (const EventContext &ctx) override
 Perform processing on aux variable objects just after reading to make them usable as transient objects.
Functions implementing the SG::IAuxStore interface
virtual void * getData (auxid_t auxid, size_t size, size_t capacity) override
 Get a pointer to a given array, creating the array if necessary.
virtual const auxid_set_t & getWritableAuxIDs () const override
 Return a set of writable data identifiers.
virtual bool resize (size_t size) override
 Resize the arrays to a given size.
virtual void reserve (size_t size) override
 Reserve a given size for the arrays.
virtual void shift (size_t pos, ptrdiff_t offs) override
 Shift the contents of the stored arrays.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
 Insert contents of another store via move.
virtual bool setOption (auxid_t id, const SG::AuxDataOption &option) override
 Make an option setting on an aux variable.
virtual SG::IAuxTypeVector * linkedVector (SG::auxid_t auxid) override
 Return interface for a linked variable.
Functions implementing the SG::IAuxStoreIO interface
virtual const void * getIOData (auxid_t auxid) const override
 Get a pointer to the data being stored for one aux data item.
virtual const std::type_info * getIOType (auxid_t auxid) const override
 Return the type of the data to be stored for one aux data item.
virtual const auxid_set_t & getDynamicAuxIDs () const override
 Get the types(names) of variables created dynamically.
virtual SG::auxid_set_t getSelectedAuxIDs () const override
 Get the IDs of the selected dynamic Aux variables (for writing).
Functions managing the instance name of the container
const char * name () const
 Get the name of the container instance.
void setName (const char *name)
 Set the name of the container instance.

Static Public Attributes

static constexpr bool supportsThinning = true
 Mark that this type supports thinning operations.

Private Types

typedef AthContainers_detail::mutex mutex_t
 Mutex for multithread synchronization.
typedef AthContainers_detail::lock_guard< mutex_t > guard_t

Private Attributes

auxid_set_t m_auxids
 Internal list of all available variables.
std::vector< SG::IAuxTypeVector * > m_vecs
 Internal list of all managed variables.
SG::IAuxStore * m_store
 Internal dynamic auxiliary store object.
SG::IAuxStoreIO * m_storeIO
 The IO interface to the internal auxiliary store.
bool m_ownsStore
 Flag deciding if the object owns the dynamic store or not.
bool m_locked
 Has the container been locked?
mutex_t m_mutex
std::string m_name
 Name of the container in memory. Set externally.

Detailed Description

Common base class for auxiliary info objects.

This class should be used as the base for classes describing auxiliary information about standalone objects. The most important example of this is the xAOD::EventInfo object...

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
793737
Date
2017-01-24 21:11:10 +0100 (Tue, 24 Jan 2017)

Definition at line 41 of file AuxInfoBase.h.

Member Typedef Documentation

◆ auxid_set_t

The aux ID set type definition.

Definition at line 51 of file AuxInfoBase.h.

◆ auxid_t

The aux ID type definition.

Definition at line 49 of file AuxInfoBase.h.

◆ AuxVariable_t

template<class T, class ALLOC = std::allocator<T>>
using xAOD::AuxInfoBase::AuxVariable_t = T

Declare how to wrap variables for this sort of base.

Definition at line 183 of file AuxInfoBase.h.

◆ guard_t

◆ LinkedVariable_t

template<class T, class ALLOC = std::allocator<T>>
using xAOD::AuxInfoBase::LinkedVariable_t = std::vector<T, ALLOC>

Definition at line 185 of file AuxInfoBase.h.

◆ mutex_t

Mutex for multithread synchronization.

Definition at line 215 of file AuxInfoBase.h.

Member Enumeration Documentation

◆ AuxStoreType

Type of the auxiliary store.

In the xAOD EDM we use auxiliary store objects in some cases to describe a single object, and in most cases to describe a container of objects. This enumeration declares which type the object implementing this interface is.

Enumerator
AST_ObjectStore 

The store describes a single object.

AST_ContainerStore 

The store describes a container.

Definition at line 68 of file IAuxStoreHolder.h.

68 {
69 AST_ObjectStore = 0,
71 };
@ AST_ContainerStore
The store describes a container.
@ AST_ObjectStore
The store describes a single object.

Constructor & Destructor Documentation

◆ AuxInfoBase() [1/3]

xAOD::AuxInfoBase::AuxInfoBase ( bool allowDynamicVars = true)

Default constructor.

Definition at line 26 of file AuxInfoBase.cxx.

27 : SG::IAuxStore(),
28 m_auxids(), m_vecs(), m_store( nullptr ), m_storeIO( nullptr ),
29 m_ownsStore( true ),
30 m_locked( false ),
31 m_name( "UNKNOWN" ) {
32
33 if( allowDynamicVars ) {
34 m_store = new SG::AuxStoreStandalone();
35 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
36 }
37 }
bool m_ownsStore
Flag deciding if the object owns the dynamic store or not.
auxid_set_t m_auxids
Internal list of all available variables.
SG::IAuxStoreIO * m_storeIO
The IO interface to the internal auxiliary store.
std::vector< SG::IAuxTypeVector * > m_vecs
Internal list of all managed variables.
bool m_locked
Has the container been locked?
std::string m_name
Name of the container in memory. Set externally.
SG::IAuxStore * m_store
Internal dynamic auxiliary store object.

◆ AuxInfoBase() [2/3]

xAOD::AuxInfoBase::AuxInfoBase ( const AuxInfoBase & parent)

Copy constructor.

This is an interesting one.

The internal variables of AuxInfoBase are set up by the derived class(es) at construction. So, this internal state is not to be copied!

However, since the derived classes (the contents of their regular members) are allowed to be copied, let's not make this constructor private.

Definition at line 47 of file AuxInfoBase.cxx.

48 : SG::IAuxStore(),
49 m_auxids(), m_vecs(), m_store( nullptr ), m_storeIO( nullptr ),
50 m_ownsStore( true ),
51 m_locked( false )
52 {
53 // Keep the source unmutable during copy
54 guard_t guard( parent.m_mutex );
55 m_name = parent.m_name;
56
57 // Unfortunately the dynamic variables can not be copied this easily...
58 if( parent.m_store ) {
59 m_ownsStore = false;
60 // cppcheck-suppress copyCtorPointerCopying
61 m_store = parent.m_store;
62 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
63 m_auxids.insert( m_store->getAuxIDs().begin(),
64 m_store->getAuxIDs().end() );
65 }
66 }
AthContainers_detail::lock_guard< mutex_t > guard_t

◆ AuxInfoBase() [3/3]

xAOD::AuxInfoBase::AuxInfoBase ( SG::IAuxStore * store)

Constructor receiving a "dynamic auxiliary store".

This constructor is used to wrap another object that is stored in StoreGate, and hence we should not take ownership of.

Parameters
storeAnother store that should be wrapped, but not owned

Definition at line 73 of file AuxInfoBase.cxx.

74 : SG::IAuxStore(),
75 m_auxids(), m_vecs(),
76 m_store( store ),
77 m_storeIO( nullptr ), m_ownsStore( false ),
78 m_locked( false ),
79 m_name( "UNKNOWN" ) {
80
81 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
82 if( m_store ) {
83 m_auxids.insert (m_store->getAuxIDs());
84 }
85 }

◆ ~AuxInfoBase()

xAOD::AuxInfoBase::~AuxInfoBase ( )

Destructor.

Definition at line 87 of file AuxInfoBase.cxx.

87 {
88
89 std::vector< SG::IAuxTypeVector* >::iterator itr = m_vecs.begin();
90 std::vector< SG::IAuxTypeVector* >::iterator end = m_vecs.end();
91 for( ; itr != end; ++itr ) {
92 if( ! *itr ) continue;
93 delete *itr;
94 }
95
96 if( m_store && m_ownsStore ) delete m_store;
97 }

Member Function Documentation

◆ clearDecorations()

bool xAOD::AuxInfoBase::clearDecorations ( )
overridevirtual

Clear all decorations.

Definition at line 326 of file AuxInfoBase.cxx.

326 {
327
328 // Guard against multi-threaded execution:
329 guard_t guard( m_mutex );
330
331 // Clear the decorations that are in the dynamic store:
332 bool anycleared = false;
333 if( m_store ) {
334 anycleared = m_store->clearDecorations();
335 }
336 // Early exit if there were no decorations.
337 if (!anycleared) return false;
338
339 // Reconstruct the list of managed auxiliary IDs from scratch:
341 for( auxid_t auxid = 0; auxid < m_vecs.size(); ++auxid ) {
342 if( m_vecs[ auxid ] ) {
343 ids.insert( auxid );
344 }
345 }
346 if( m_store ) {
347 ids.insert (m_store->getAuxIDs());
348 }
349 m_auxids = std::move(ids);
350
351 return true;
352 }
SG::auxid_t auxid_t
The aux ID type definition.
Definition AuxInfoBase.h:49
SG::auxid_set_t auxid_set_t
The aux ID set type definition.
Definition AuxInfoBase.h:51
SG::auxid_t auxid() const
Return the aux id for this variable.

◆ getAuxID()

template<typename T>
auxid_t xAOD::AuxInfoBase::getAuxID ( const std::string & name,
T & ,
SG::AuxVarFlags flags = SG::AuxVarFlags::None,
const SG::auxid_t linkedVariable = SG::null_auxid )

Get the auxiliary ID for one of the persistent variables.

◆ getAuxIDs()

const AuxInfoBase::auxid_set_t & xAOD::AuxInfoBase::getAuxIDs ( ) const
overridevirtual

Get the types(names) of variables handled by this container.

Definition at line 254 of file AuxInfoBase.cxx.

254 {
255
256 // Return the full list of IDs:
257 return getWritableAuxIDs();
258 }
virtual const auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.

◆ getCopyIDs()

SG::auxid_set_t xAOD::AuxInfoBase::getCopyIDs ( bool warnUnlocked = false) const
overridevirtual

Get the set of variables that we should deep copy.

Reimplemented in xAOD::EventAuxInfo_v3.

Definition at line 239 of file AuxInfoBase.cxx.

240 {
241 return SG::getCopyIDs (getAuxIDs(), getDecorIDs(), warnUnlocked, {});
242 }
virtual const auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Return the set of variables to copy in a deep copy.

◆ getData() [1/2]

const void * xAOD::AuxInfoBase::getData ( auxid_t auxid) const
overridevirtual

Get a pointer to a given array.

Definition at line 196 of file AuxInfoBase.cxx.

196 {
197
198 const SG::IAuxTypeVector* v = getVector( auxid );
199 if( v ) {
200 return v->toPtr();
201 }
202 return nullptr;
203 }
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override final
Return vector interface for one aux data item.

◆ getData() [2/2]

void * xAOD::AuxInfoBase::getData ( auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Get a pointer to a given array, creating the array if necessary.

Implements SG::IAuxStore.

Definition at line 446 of file AuxInfoBase.cxx.

447 {
448
449 // Guard against multi-threaded execution:
450 guard_t guard( m_mutex );
451
452 if( ( auxid >= m_vecs.size() ) || ( ! m_vecs[ auxid ] ) ) {
453
454 if( m_store ) {
455 void* result = m_store->getData( auxid, size, capacity );
456 if( result ) {
457 m_auxids.insert( auxid );
458 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
459 auxid_t linked_id = r.linkedVariable( auxid );
460 if (linked_id != SG::null_auxid) {
461 m_auxids.insert( linked_id );
462 }
463 }
464 return result;
465 } else {
466 std::println( "ERROR xAOD::AuxInfoBase::getData "
467 "Unknown variable ({}) requested",
469 return nullptr;
470 }
471 }
472 m_vecs[ auxid ]->reserve( capacity );
473 if (m_vecs[ auxid ]->size() < size) {
474 m_vecs[ auxid ]->resize( size );
475 }
476
477 return m_vecs[ auxid ]->toPtr();
478 }
static AuxTypeRegistry & instance()
Return the singleton registry instance.
virtual size_t size() const override
Get the size of the container.
int r
Definition globals.cxx:22
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30

◆ getDecoration()

void * xAOD::AuxInfoBase::getDecoration ( auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Get a pointer to a given array, as a decoration.

Reimplemented in xAOD::EventAuxInfo_v1, xAOD::EventAuxInfo_v2, and xAOD::EventAuxInfo_v3.

Definition at line 270 of file AuxInfoBase.cxx.

271 {
272 {
273 // Guard against multi-threaded execution:
274 guard_t guard( m_mutex );
275
276 // Check if we have it as a static variable:
277 if( ( auxid >= m_vecs.size() ) || ( ! m_vecs[ auxid ] ) ) {
278 // If not, but we have a dynamic store, push it in there:
279 if( m_store ) {
280 void* result = m_store->getDecoration( auxid, size, capacity );
281 if( result ) {
282 m_auxids.insert( auxid );
283 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
284 auxid_t linked_id = r.linkedVariable( auxid );
285 if (linked_id != SG::null_auxid) {
286 m_auxids.insert( linked_id );
287 }
288 }
289 return result;
290 }
291 // If we don't have a dynamic store, complain:
292 else {
293 std::println( "ERROR xAOD::AuxInfoBase::getDecoration "
294 "Can't provide variable {}",
296 return nullptr;
297 }
298 }
299
300 // If the container is locked, static variables can't be accessed this
301 // way:
302 if( m_locked ) {
303 throw SG::ExcStoreLocked( auxid );
304 }
305 }
306
307 // If the container is not locked, then fall back on the normal accessor
308 // function:
309 return getData( auxid, size, capacity );
310 }
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.

◆ getDecorIDs()

const AuxInfoBase::auxid_set_t & xAOD::AuxInfoBase::getDecorIDs ( ) const
overridevirtual

Get the types(names) of decorations handled by this container.

Definition at line 261 of file AuxInfoBase.cxx.

261 {
262
263 if( m_store ) {
264 return m_store->getDecorIDs();
265 }
266 static const auxid_set_t empty;
267 return empty;
268 }
static const Attributes_t empty

◆ getDynamicAuxIDs()

const AuxInfoBase::auxid_set_t & xAOD::AuxInfoBase::getDynamicAuxIDs ( ) const
overridevirtual

Get the types(names) of variables created dynamically.

Implements SG::IAuxStoreIO.

Definition at line 655 of file AuxInfoBase.cxx.

655 {
656
657 // Guard against multi-threaded execution:
658 guard_t guard( m_mutex );
659
660 // All the variables handled by the internal store are dynamic
661 // if such a store exists:
662 if( m_storeIO ) {
663 // I mean, all the variables. Not just the ones reported as dynamic
664 // by the internal object. Because the internal object may be something
665 // that was put into this one in order to achieve data slimming.
666 return m_store->getAuxIDs();
667 }
668
669 // In case we don't use an internal store, there are no dynamic
670 // variables:
671 static const auxid_set_t dummy (0);
672 return dummy;
673 }

◆ getIOData()

const void * xAOD::AuxInfoBase::getIOData ( auxid_t auxid) const
overridevirtual

Get a pointer to the data being stored for one aux data item.

Implements SG::IAuxStoreIO.

Definition at line 606 of file AuxInfoBase.cxx.

606 {
607
608 // Guard against multi-threaded execution:
609 guard_t guard( m_mutex );
610
611 if( ( auxid >= m_vecs.size() ) || ( ! m_vecs[ auxid ] ) ) {
612 if( m_storeIO ) {
613 return m_storeIO->getIOData( auxid );
614 } else {
615 std::println( "ERROR xAOD::AuxInfoBase::getIOData "
616 "Unknown variable ({}) requested",
618 return nullptr;
619 }
620 }
621
622 // Update the statistics for this variable. The dynamic store registers
623 // its own variable accesses.
625
626 if( m_vecs[ auxid ]->isLinked() )
627 return m_vecs[ auxid ]->toVector();
628 else
629 return m_vecs[ auxid ]->toPtr();
630 }
ReadStats & stats()
Access the object belonging to the current thread.
Definition IOStats.cxx:17
static IOStats & instance()
Singleton object accessor.
Definition IOStats.cxx:11
void readBranch(const std::string &prefix, SG::auxid_t auxid)
Function incrementing the read counter on a specific branch.

◆ getIOType()

const std::type_info * xAOD::AuxInfoBase::getIOType ( auxid_t auxid) const
overridevirtual

Return the type of the data to be stored for one aux data item.

Implements SG::IAuxStoreIO.

Definition at line 632 of file AuxInfoBase.cxx.

632 {
633
634 // Guard against multi-threaded execution:
635 guard_t guard( m_mutex );
636
637 if( ( auxid >= m_vecs.size() ) || ( ! m_vecs[ auxid ] ) ) {
638 if( m_storeIO ) {
639 return m_storeIO->getIOType( auxid );
640 } else {
641 std::println ("ERROR xAOD::AuxInfoBase::getIOType "
642 "Unknown variable ({}) requested",
644 return nullptr;
645 }
646 }
647
648 if( m_vecs[ auxid ]->isLinked() )
649 return SG::AuxTypeRegistry::instance().getType( auxid );
650 else
652 }
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.

◆ getSelectedAuxIDs()

AuxInfoBase::auxid_set_t xAOD::AuxInfoBase::getSelectedAuxIDs ( ) const
overridevirtual

Get the IDs of the selected dynamic Aux variables (for writing).

Reimplemented from SG::IAuxStoreIO.

Definition at line 676 of file AuxInfoBase.cxx.

676 {
677
678 // Guard against multi-threaded execution:
679 guard_t guard( m_mutex );
680
681 // All the variables handled by the internal store are dynamic
682 // if such a store exists:
683 if( m_storeIO && m_store) {
684 // I mean, all the variables. Not just the ones reported as dynamic
685 // by the internal object. Because the internal object may be something
686 // that was put into this one in order to achieve data slimming.
687 return m_store->getAuxIDs();
688 }
689
690 // In case we don't use an internal store, there are no dynamic
691 // variables:
692 return auxid_set_t();
693 }

◆ getStore() [1/2]

const SG::IAuxStore * xAOD::AuxInfoBase::getStore ( ) const
overridevirtual

Get the currently used internal store object.

Implements SG::IAuxStoreHolder.

Definition at line 147 of file AuxInfoBase.cxx.

148 {
149 return m_store;
150 }

◆ getStore() [2/2]

SG::IAuxStore * xAOD::AuxInfoBase::getStore ( )
overridevirtual

Get the currently used internal store object.

Implements SG::IAuxStoreHolder.

Definition at line 141 of file AuxInfoBase.cxx.

142 {
143 return m_store;
144 }

◆ getStoreType()

virtual AuxStoreType xAOD::AuxInfoBase::getStoreType ( ) const
inlineoverridevirtual

Return the type of the store object.

Implements SG::IAuxStoreHolder.

Definition at line 75 of file AuxInfoBase.h.

75{ return AST_ObjectStore; }

◆ getVector()

const SG::IAuxTypeVector * xAOD::AuxInfoBase::getVector ( SG::auxid_t auxid) const
finaloverridevirtual

Return vector interface for one aux data item.

Definition at line 205 of file AuxInfoBase.cxx.

205 {
206
207 // Guard against multi-threaded execution:
208 guard_t guard( m_mutex );
209
210 if( ( auxid >= m_vecs.size() ) || ( ! m_vecs[ auxid ] ) ) {
211 if( m_store ) {
212 const SG::IAuxTypeVector* result = m_store->getVector( auxid );
213 if( result ) {
214 auxid_set_t& auxids_nc ATLAS_THREAD_SAFE =
215 const_cast<auxid_set_t&> (m_auxids);
216 auxids_nc.insert( auxid );
217 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
218 auxid_t linked_id = r.linkedVariable( auxid );
219 if (linked_id != SG::null_auxid) {
220 auxids_nc.insert( linked_id );
221 }
222 }
223 return result;
224 } else {
225 std::println( "ERROR xAOD::AuxInfoBase::getData "
226 "Unknown variable ({}) requested",
228 return nullptr;
229 }
230 }
231
232 // Update the statistics for this variable. The dynamic store registers
233 // its own variable accesses.
235
236 return m_vecs[ auxid ];
237 }
#define ATLAS_THREAD_SAFE

◆ getWritableAuxIDs()

const AuxInfoBase::auxid_set_t & xAOD::AuxInfoBase::getWritableAuxIDs ( ) const
overridevirtual

Return a set of writable data identifiers.

Implements SG::IAuxStore.

Definition at line 481 of file AuxInfoBase.cxx.

481 {
482
483 // Return the full list of known IDs. The constness of this object's
484 // members comes from the object being const or not.
485 return m_auxids;
486 }

◆ insertMove() [1/2]

virtual bool SG::IAuxStore::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore = SG::auxid_set_t() )
pure virtualinherited

Move all elements from other to this store.

Parameters
posThe starting index of the insertion.
otherStore from which to do the move.
ignoreSet of variables that should not be added to the store.

Let len be the size of other. The store will be increased in size by len elements, with the elements at pos being copied to pos+len. Then, for each auxiliary variable, the entire contents of that variable for other will be moved to this store at index pos. This will be done via move semantics if possible; otherwise, it will be done with a copy. Variables present in this store but not in other will have the corresponding elements default-initialized. Variables in other but not in this store will be added unless they are in ignore.

Returns true if it is known that none of the vectors' memory moved, false otherwise.

◆ insertMove() [2/2]

bool xAOD::AuxInfoBase::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore )
overridevirtual

Insert contents of another store via move.

Definition at line 570 of file AuxInfoBase.cxx.

571 {
572
573 // Guard against multi-threaded execution:
574 guard_t guard( m_mutex );
575
576 // Check if the container is locked:
577 if( m_locked ) {
578 throw SG::ExcStoreLocked( "insertMove" );
579 }
580
581 // We are just not allowed to do this...
582 throw std::runtime_error( "Calling insertMove on a non-vector" );
583
584 return false;
585 }

◆ isDecoration()

bool xAOD::AuxInfoBase::isDecoration ( auxid_t auxid) const
overridevirtual

Test if a variable is a decoration.

Reimplemented in xAOD::EventAuxInfo_v1, xAOD::EventAuxInfo_v2, and xAOD::EventAuxInfo_v3.

Definition at line 244 of file AuxInfoBase.cxx.

245 {
246 guard_t guard( m_mutex );
247 if (m_store) {
248 return m_store->isDecoration (auxid);
249 }
250 return false;
251 }

◆ linkedVector() [1/2]

const SG::IAuxTypeVector * xAOD::AuxInfoBase::linkedVector ( SG::auxid_t auxid) const
overridevirtual

Return interface for a linked variable.

Definition at line 363 of file AuxInfoBase.cxx.

364 {
365 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
366 auxid_t linked_id = r.linkedVariable( auxid );
367 if (linked_id != SG::null_auxid) {
368 guard_t guard( m_mutex );
369 if (linked_id < m_vecs.size() && m_vecs[ linked_id ]) {
370 return m_vecs[ linked_id ];
371 }
372 if (m_store) {
373 return CxxUtils::as_const_ptr(m_store)->linkedVector( auxid );
374 }
375 }
376 return nullptr;
377 }
const T * as_const_ptr(const T *p)
Helper for getting a const version of a pointer.

◆ linkedVector() [2/2]

SG::IAuxTypeVector * xAOD::AuxInfoBase::linkedVector ( SG::auxid_t auxid)
overridevirtual

Return interface for a linked variable.

Reimplemented from SG::IAuxStore.

Definition at line 380 of file AuxInfoBase.cxx.

381 {
382 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
383 auxid_t linked_id = r.linkedVariable( auxid );
384 if (linked_id != SG::null_auxid) {
385 guard_t guard( m_mutex );
386 if (linked_id < m_vecs.size() && m_vecs[ linked_id ]) {
387 return m_vecs[ linked_id ];
388 }
389 if (m_store) {
390 return m_store->linkedVector( auxid );
391 }
392 }
393 return nullptr;
394 }

◆ lock()

void xAOD::AuxInfoBase::lock ( )
overridevirtual

Lock the container.

Definition at line 312 of file AuxInfoBase.cxx.

312 {
313
314 // Guard against multi-threaded execution:
315 guard_t guard( m_mutex );
316
317 // Lock the container and the dynamic store:
318 m_locked = true;
319 if( m_store ) {
320 m_store->lock();
321 }
322
323 return;
324 }

◆ lockDecoration()

void xAOD::AuxInfoBase::lockDecoration ( SG::auxid_t auxid)
overridevirtual

Lock a decoration.

Reimplemented in xAOD::EventAuxInfo_v1, xAOD::EventAuxInfo_v2, and xAOD::EventAuxInfo_v3.

Definition at line 355 of file AuxInfoBase.cxx.

356 {
357 guard_t guard (m_mutex);
358 if (m_store) {
359 m_store->lockDecoration (auxid);
360 }
361 }

◆ name()

const char * xAOD::AuxInfoBase::name ( ) const

Get the name of the container instance.

Definition at line 698 of file AuxInfoBase.cxx.

698 {
699
700 return m_name.c_str();
701 }

◆ operator=()

AuxInfoBase & xAOD::AuxInfoBase::operator= ( const AuxInfoBase & rhs)

Assignment operator.

Just like the copy constructor, this operator doesn't actually copy anything either.

It's just here to make it clear to C++ that the internal state of these objects is not to be messed with.

Returns
A reference to this same object

Definition at line 106 of file AuxInfoBase.cxx.

106 {
107
108 // Protect against self-assignment:
109 if( this == &rhs ) return *this;
110
111 // Keep the source unmutable during copy
112 std::scoped_lock lck{m_mutex, rhs.m_mutex};
113
114 // Clean up after the old dynamic store:
115 if( m_store && m_ownsStore ) {
116 m_auxids -= m_store->getAuxIDs();
117 delete m_store;
118 }
119 m_store = nullptr;
120 m_storeIO = nullptr;
121 m_ownsStore = true;
122
123 // Take posession of the new dynamic store:
124 if( rhs.m_store ) {
125 m_ownsStore = false;
126 m_store = rhs.m_store;
127 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
128 m_auxids.insert (m_store->getAuxIDs());
129 }
130
131 m_name = rhs.m_name;
132
133 return *this;
134 }

◆ regAuxVar()

template<typename T>
void xAOD::AuxInfoBase::regAuxVar ( auxid_t auxid,
const std::string & name,
T & info )

Register one of the persistent variables internally.

◆ reserve()

void xAOD::AuxInfoBase::reserve ( size_t size)
overridevirtual

Reserve a given size for the arrays.

Implements SG::IAuxStore.

Definition at line 522 of file AuxInfoBase.cxx.

522 {
523
524 // Guard against multi-threaded execution:
525 guard_t guard( m_mutex );
526
527 // Check if the container is locked:
528 if( m_locked ) {
529 throw SG::ExcStoreLocked( "reserve" );
530 }
531
532 // Do a test already here:
533 if( size != 1 ) {
534 throw std::runtime_error( "Calling reserve with != 1 on a "
535 "non-vector" );
536 }
537
538 // Do the operation on the static variables:
539 for (SG::IAuxTypeVector* v : m_vecs) {
540 if(v && !v->isLinked()) {
541 v->reserve( size );
542 }
543 }
544
545 // Do the operation on the dynamic variables:
546 if( m_store ) {
547 m_store->reserve( size );
548 }
549
550 return;
551 }

◆ resize()

bool xAOD::AuxInfoBase::resize ( size_t size)
overridevirtual

Resize the arrays to a given size.

Implements SG::IAuxStore.

Definition at line 488 of file AuxInfoBase.cxx.

488 {
489
490 // Guard against multi-threaded execution:
491 guard_t guard( m_mutex );
492
493 // Check if the container is locked:
494 if( m_locked ) {
495 throw SG::ExcStoreLocked( "resize" );
496 }
497
498 // Do a test already here:
499 if( size != 1 ) {
500 throw std::runtime_error( "Calling resize with != 1 on a "
501 "non-vector" );
502 }
503
504 // Do the operation on the static variables:
505 bool nomoves = true;
506 for (SG::IAuxTypeVector* v : m_vecs) {
507 if(v && !v->isLinked()) {
508 if (!v->resize( size ))
509 nomoves = false;
510 }
511 }
512
513 // Do the operation on the dynamic variables:
514 if( m_store ) {
515 if (!m_store->resize( size ))
516 nomoves = false;
517 }
518
519 return nomoves;
520 }

◆ setName()

void xAOD::AuxInfoBase::setName ( const char * name)

Set the name of the container instance.

Definition at line 703 of file AuxInfoBase.cxx.

703 {
704
705 m_name = name;
706 return;
707 }
const char * name() const
Get the name of the container instance.

◆ setOption()

bool xAOD::AuxInfoBase::setOption ( auxid_t id,
const SG::AuxDataOption & option )
overridevirtual

Make an option setting on an aux variable.

Reimplemented from SG::IAuxStore.

Definition at line 588 of file AuxInfoBase.cxx.

588 {
589
590 if (id < m_vecs.size() && m_vecs[id] != nullptr)
591 return m_vecs[id]->setOption( option );
592 if (m_store)
593 return m_store->setOption( id, option );
594 return false;
595 }

◆ setStore()

void xAOD::AuxInfoBase::setStore ( SG::IAuxStore * store)
overridevirtual

Set a different internal store object.

This function is used by the I/O infrastructure to possibly put a store object into this one, which can interact with dynamic variables directly.

Note that the object takes ownership of the received store.

Parameters
storeThe store that should be used for dynamic variable handling inside the object from now on

Implements SG::IAuxStoreHolder.

Definition at line 161 of file AuxInfoBase.cxx.

161 {
162
163 // Guard against multi-threaded execution:
164 guard_t guard( m_mutex );
165
166 // Check that no funny business is going on:
167 if( m_store == store ) return;
168
169 // Clean up the current store object:
170 if( m_store && m_ownsStore ) {
171 m_auxids -= m_store->getAuxIDs();
172 delete m_store;
173 }
174 m_store = nullptr;
175 m_storeIO = nullptr;
176
177 // Take posession of the new object:
178 m_store = store;
179 m_storeIO = dynamic_cast< SG::IAuxStoreIO* >( m_store );
180 m_ownsStore = true;
181 if( m_store ) {
182 m_auxids.insert (m_store->getAuxIDs());
183 }
184
185 return;
186 }
TestStore store
Definition TestStore.cxx:23

◆ shift()

void xAOD::AuxInfoBase::shift ( size_t pos,
ptrdiff_t offs )
overridevirtual

Shift the contents of the stored arrays.

Implements SG::IAuxStore.

Definition at line 553 of file AuxInfoBase.cxx.

553 {
554
555 // Guard against multi-threaded execution:
556 guard_t guard( m_mutex );
557
558 // Check if the container is locked:
559 if( m_locked ) {
560 throw SG::ExcStoreLocked( "shift" );
561 }
562
563 // We are just not allowed to do this...
564 throw std::runtime_error( "Calling shift on a non-vector" );
565
566 return;
567 }

◆ size()

size_t xAOD::AuxInfoBase::size ( ) const
overridevirtual

Get the size of the container.

Definition at line 415 of file AuxInfoBase.cxx.

415 {
416
417 // Should really always be 1, but do the general thing anyway...
418
419 // Guard against multi-threaded execution:
420 guard_t guard( m_mutex );
421
422 // Try to find a variable:
423 for (SG::auxid_t i : m_auxids) {
424 if( ( i < m_vecs.size() ) && m_vecs[ i ] && !m_vecs[ i ]->isLinked()) {
425 size_t sz = m_vecs[ i ]->size();
426 if( sz > 0 ) {
427 return sz;
428 }
429 }
430 }
431
432 // If we didn't find any statically defined variables, then we just
433 // need to claim 1. Because pool::AuxStoreAPR at the moment always
434 // returns 0 for the size.
435 return 1;
436 }
static Double_t sz
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27

◆ toTransient()

void xAOD::AuxInfoBase::toTransient ( const EventContext & ctx)
overridevirtual

Perform processing on aux variable objects just after reading to make them usable as transient objects.

Implements SG::IAuxStore.

Reimplemented in xAOD::EventAuxInfo_v1, xAOD::EventAuxInfo_v2, and xAOD::EventAuxInfo_v3.

Definition at line 397 of file AuxInfoBase.cxx.

398 {
399 // Guard against multi-threaded execution:
400 guard_t guard (m_mutex);
401
402 for (SG::IAuxTypeVector* v : m_vecs) {
403 if(v) {
404 v->toTransient( ctx );
405 }
406 }
407
408 // Do the operation on the dynamic variables:
409 if( m_store ) {
410 m_store->toTransient( ctx );
411 }
412 }

Member Data Documentation

◆ m_auxids

auxid_set_t xAOD::AuxInfoBase::m_auxids
private

Internal list of all available variables.

Definition at line 201 of file AuxInfoBase.h.

◆ m_locked

bool xAOD::AuxInfoBase::m_locked
private

Has the container been locked?

Definition at line 212 of file AuxInfoBase.h.

◆ m_mutex

mutex_t xAOD::AuxInfoBase::m_mutex
mutableprivate

Definition at line 217 of file AuxInfoBase.h.

◆ m_name

std::string xAOD::AuxInfoBase::m_name
private

Name of the container in memory. Set externally.

Definition at line 220 of file AuxInfoBase.h.

◆ m_ownsStore

bool xAOD::AuxInfoBase::m_ownsStore
private

Flag deciding if the object owns the dynamic store or not.

Definition at line 210 of file AuxInfoBase.h.

◆ m_store

SG::IAuxStore* xAOD::AuxInfoBase::m_store
private

Internal dynamic auxiliary store object.

Definition at line 206 of file AuxInfoBase.h.

◆ m_storeIO

SG::IAuxStoreIO* xAOD::AuxInfoBase::m_storeIO
private

The IO interface to the internal auxiliary store.

Definition at line 208 of file AuxInfoBase.h.

◆ m_vecs

std::vector< SG::IAuxTypeVector* > xAOD::AuxInfoBase::m_vecs
private

Internal list of all managed variables.

Definition at line 203 of file AuxInfoBase.h.

◆ supportsThinning

bool SG::IAuxStore::supportsThinning = true
staticconstexprinherited

Mark that this type supports thinning operations.

See AthContainers/supportsThinning.h and AthenaPoolCnvSvc/T_AthenaPoolCnv.h. Helps guide which pool converter template will be used. If false, the default pool converter will be used rather than the aux store-specific one. Ordinary xAOD type should not touch this, but may be overridden in a derived class to handle certain special cases.

Definition at line 216 of file IAuxStore.h.


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