ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
xAOD::TAuxStore Class Referenceabstract

"ROOT @c TTree implementation" of IAuxStore More...

#include <TAuxStore.h>

Inheritance diagram for xAOD::TAuxStore:
Collaboration diagram for xAOD::TAuxStore:

Classes

struct  impl
 

Public Types

enum  EStructMode { EStructMode::kUndefinedStore = 0, EStructMode::kContainerStore = 1, EStructMode::kObjectStore = 2 }
 "Structural" modes of the object More...
 

Public Member Functions

 TAuxStore (std::string_view prefix="", bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore, int basketSize=2048, int splitLevel=0)
 Constructor. More...
 
virtual ~TAuxStore ()
 Destructor. More...
 
virtual void setPrefix (std::string_view prefix) override
 Set the object name prefix. More...
 
int basketSize () const
 Get the size of the baskets created for the output branches. More...
 
void setBasketSize (int value)
 Set the size of the baskets created for the output branches. More...
 
int splitLevel () const
 Get the split level of the output branches. More...
 
void setSplitLevel (int value)
 Set the split level of the output branches. More...
 
StatusCode readFrom (::TTree &tree, bool printWarnings=true)
 Connect the object to an input TTree. More...
 
StatusCode writeTo (::TTree &tree)
 Connect the object to an output TTree. More...
 
int getEntry (int getall=0)
 Read the values from the TTree entry that was loaded with TTree::LoadTree() More...
 
EStructMode structMode () const
 Get what structure mode the object was constructed with. More...
 
void setStructMode (EStructMode mode)
 Set the structure mode of the object to a new value. More...
 
const std::string & prefix () const
 Get the currently configured object name prefix. More...
 
bool isTopStore () const
 Check if the object is a "top store", or not. More...
 
void setTopStore (bool value=true)
 Set whether the object should behave as a "top store" or not. More...
 
virtual void * getData (auxid_t auxid, size_t size, size_t capacity)=0
 Return the data vector for one aux data item. More...
 
virtual const void * getData (SG::auxid_t auxid) const=0
 Pick up the const version from the base class. More...
 
virtual void * getDecoration (auxid_t auxid, size_t size, size_t capacity)=0
 Return the data vector for one aux data decoration item. More...
 
virtual const IAuxTypeVector * linkedVector (SG::auxid_t) const
 Return interface for a linked variable. More...
 
virtual bool resize (size_t sz)=0
 Change the size of all aux data vectors. More...
 
virtual void reserve (size_t sz)=0
 Change the capacity of all aux data vectors. More...
 
virtual void shift (size_t pos, ptrdiff_t offs)=0
 Shift the elements of the container. More...
 
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. More...
 
virtual bool setOption (auxid_t, const AuxDataOption &)
 Set an option for a given auxiliary variable. More...
 
Functions implementing the @c SG::IConstAuxStore interface
virtual const void * getData (SG::auxid_t auxid) const override
 Get a pointer to a given array. More...
 
virtual const SG::IAuxTypeVectorgetVector (SG::auxid_t auxid) const override
 Return vector interface for one aux data item. More...
 
virtual const SG::auxid_set_tgetAuxIDs () const override
 Get the types(names) of variables handled by this container. More...
 
virtual const SG::auxid_set_tgetDecorIDs () const override
 Get the types(names) of decorations handled by this container. More...
 
virtual void * getDecoration (SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
 Get a pointer to a given array, creating the array if necessary. More...
 
virtual bool isDecoration (SG::auxid_t auxid) const override
 Test if a variable is a decoration. More...
 
virtual void lock () override
 Lock the object, and don't let decorations be added. More...
 
virtual bool clearDecorations () override
 Remove the decorations added so far. More...
 
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration. More...
 
virtual std::size_t size () const override
 Return the number of elements in the store. More...
 
virtual const SG::IAuxTypeVectorlinkedVector (SG::auxid_t auxid) const override
 Return (const) interface for a linked variable. More...
 
virtual SG::IAuxTypeVectorlinkedVector (SG::auxid_t auxid) override
 Return (non-const) interface for a linked variable. More...
 
Functions implementing the @c SG::IAuxStore interface
virtual void * getData (SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
 Get a pointer to a given array, creating the array if necessary. More...
 
virtual const SG::auxid_set_tgetWritableAuxIDs () const override
 Return a set of writable data identifiers. More...
 
virtual bool resize (std::size_t size) override
 Resize the arrays to a given size. More...
 
virtual void reserve (std::size_t size) override
 Reserve a given size for the arrays. More...
 
virtual void shift (std::size_t pos, std::ptrdiff_t offs) override
 Shift the contents of the stored arrays. More...
 
virtual bool insertMove (std::size_t pos, SG::IAuxStore &other, const SG::auxid_set_t &ignore) override
 Insert contents of another store via move. More...
 
Functions implementing the SG::IAuxStoreIO interface
virtual const void * getIOData (SG::auxid_t auxid) const override
 Get a pointer to the data being stored for one aux data item. More...
 
virtual const std::type_info * getIOType (SG::auxid_t auxid) const override
 Return the type of the data to be stored for one aux data item. More...
 
virtual const SG::auxid_set_tgetDynamicAuxIDs () const override
 Get the types(names) of variables created dynamically. More...
 
virtual void selectAux (const std::set< std::string > &attributes)
 Select dynamic auxiliary attributes for writing. More...
 
virtual SG::auxid_set_t getSelectedAuxIDs () const override
 Get the IDs of the selected aux variables. More...
 
Functions implementing the @c SG::IConstAuxStore interface
virtual const void * getData (SG::auxid_t auxid) const override
 Get a pointer to a given array. More...
 
virtual const SG::IAuxTypeVectorgetVector (SG::auxid_t auxid) const override
 Return vector interface for one aux data item. More...
 
virtual const SG::auxid_set_tgetAuxIDs () const override
 Get the types(names) of variables handled by this container. More...
 
virtual const SG::auxid_set_tgetDecorIDs () const override
 Get the types(names) of decorations handled by this container. More...
 
virtual void * getDecoration (SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
 Get a pointer to a given array, creating the array if necessary. More...
 
virtual bool isDecoration (SG::auxid_t auxid) const override
 Test if a variable is a decoration. More...
 
virtual void lock () override
 Lock the object, and don't let decorations be added. More...
 
virtual bool clearDecorations () override
 Remove the decorations added so far. More...
 
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration. More...
 
virtual std::size_t size () const override
 Return the number of elements in the store. More...
 
virtual const SG::IAuxTypeVectorlinkedVector (SG::auxid_t auxid) const override
 Return (const) interface for a linked variable. More...
 
virtual SG::IAuxTypeVectorlinkedVector (SG::auxid_t auxid) override
 Return (non-const) interface for a linked variable. More...
 
Functions implementing the @c SG::IAuxStore interface
virtual void * getData (SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
 Get a pointer to a given array, creating the array if necessary. More...
 
virtual const SG::auxid_set_tgetWritableAuxIDs () const override
 Return a set of writable data identifiers. More...
 
virtual bool resize (std::size_t size) override
 Resize the arrays to a given size. More...
 
virtual void reserve (std::size_t size) override
 Reserve a given size for the arrays. More...
 
virtual void shift (std::size_t pos, std::ptrdiff_t offs) override
 Shift the contents of the stored arrays. More...
 
virtual bool insertMove (std::size_t pos, SG::IAuxStore &other, const SG::auxid_set_t &ignore) override
 Insert contents of another store via move. More...
 
Functions implementing the SG::IAuxStoreIO interface
virtual const void * getIOData (SG::auxid_t auxid) const override
 Get a pointer to the data being stored for one aux data item. More...
 
virtual const std::type_info * getIOType (SG::auxid_t auxid) const override
 Return the type of the data to be stored for one aux data item. More...
 
virtual const SG::auxid_set_tgetDynamicAuxIDs () const override
 Get the types(names) of variables created dynamically. More...
 
virtual void selectAux (const std::set< std::string > &attributes)
 Select dynamic auxiliary attributes for writing. More...
 
virtual SG::auxid_set_t getSelectedAuxIDs () const override
 Get the IDs of the selected aux variables. More...
 
Functions implementing the @c SG::IConstAuxStore interface
virtual const void * getData (SG::auxid_t auxid) const override
 Get a pointer to a given array. More...
 
virtual const SG::IAuxTypeVectorgetVector (SG::auxid_t auxid) const override
 Return vector interface for one aux data item. More...
 
virtual const SG::auxid_set_tgetAuxIDs () const override
 Get the types(names) of variables handled by this container. More...
 
virtual const SG::auxid_set_tgetDecorIDs () const override
 Get the types(names) of decorations handled by this container. More...
 
virtual void * getDecoration (SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
 Get a pointer to a given array, creating the array if necessary. More...
 
virtual bool isDecoration (SG::auxid_t auxid) const override
 Test if a variable is a decoration. More...
 
virtual void lock () override
 Lock the object, and don't let decorations be added. More...
 
virtual bool clearDecorations () override
 Remove the decorations added so far. More...
 
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration. More...
 
virtual std::size_t size () const override
 Return the number of elements in the store. More...
 
virtual const SG::IAuxTypeVectorlinkedVector (SG::auxid_t auxid) const override
 Return (const) interface for a linked variable. More...
 
virtual SG::IAuxTypeVectorlinkedVector (SG::auxid_t auxid) override
 Return (non-const) interface for a linked variable. More...
 
Functions implementing the @c SG::IAuxStore interface
virtual void * getData (SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
 Get a pointer to a given array, creating the array if necessary. More...
 
virtual const SG::auxid_set_tgetWritableAuxIDs () const override
 Return a set of writable data identifiers. More...
 
virtual bool resize (std::size_t size) override
 Resize the arrays to a given size. More...
 
virtual void reserve (std::size_t size) override
 Reserve a given size for the arrays. More...
 
virtual void shift (std::size_t pos, std::ptrdiff_t offs) override
 Shift the contents of the stored arrays. More...
 
virtual bool insertMove (std::size_t pos, SG::IAuxStore &other, const SG::auxid_set_t &ignore) override
 Insert contents of another store via move. More...
 
Functions implementing the SG::IAuxStoreIO interface
virtual const void * getIOData (SG::auxid_t auxid) const override
 Get a pointer to the data being stored for one aux data item. More...
 
virtual const std::type_info * getIOType (SG::auxid_t auxid) const override
 Return the type of the data to be stored for one aux data item. More...
 
virtual const SG::auxid_set_tgetDynamicAuxIDs () const override
 Get the types(names) of variables created dynamically. More...
 
virtual void selectAux (const std::set< std::string > &attributes)
 Select dynamic auxiliary attributes for writing. More...
 
virtual SG::auxid_set_t getSelectedAuxIDs () const override
 Get the IDs of the selected aux variables. More...
 

Static Public Attributes

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

Protected Types

using mutex_t = AthContainers_detail::mutex
 Mutex type for multithread synchronization. More...
 
using guard_t = AthContainers_detail::lock_guard< mutex_t >
 Guard type for multithreaded synchronisation. More...
 

Protected Member Functions

bool isAuxIDSelected (SG::auxid_t auxid) const
 Check if an auxiliary variable is selected for ouput writing. More...
 

Protected Attributes

Members m_data
 Member variables of the base class. More...
 

Private Attributes

std::unique_ptr< implm_impl
 Pointer to the internal object. More...
 
AuxSelection m_selection
 Object helping to select which auxiliary variables to write. More...
 
bool m_locked = false
 Is this container locked? More...
 
mutex_t m_mutex1
 Mutex objects used for multithreaded synchronisation. More...
 
mutex_t m_mutex2
 

Functions implementing functionality for @c AuxStoreBase

virtual void reset () override
 Tell the object that all branches will need to be re-read. More...
 
virtual bool hasEntryFor (SG::auxid_t auxid) const override
 Check if a given variable is available from the input. More...
 
virtual StatusCode getEntryFor (SG::auxid_t auxid) override
 Load a single variable from the input. More...
 
virtual bool hasOutput () const override
 Check if an output is being written by the object. More...
 
virtual StatusCode setupInputData (SG::auxid_t auxid) override
 Connect a variable to the input. More...
 
virtual StatusCode setupOutputData (SG::auxid_t auxid) override
 Connect a variable to the output. More...
 
virtual const void * getInputObject (SG::auxid_t auxid) const override
 Get a pointer to an input object, as it is in memory, for getIOData() More...
 
virtual const std::type_info * getInputType (SG::auxid_t auxid) const override
 Get the type of an input object, for getIOType() More...
 

Detailed Description

"ROOT @c TTree implementation" of IAuxStore

This is a "D3PDReader-like" implementation for the auxiliary store interface. It is meant to provide very efficient access to a relatively small number of auxiliary variables.

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

Definition at line 30 of file TAuxStore.h.

Member Typedef Documentation

◆ guard_t

using xAOD::details::AuxStoreBase::guard_t = AthContainers_detail::lock_guard<mutex_t>
protectedinherited

Guard type for multithreaded synchronisation.

Definition at line 206 of file AuxStoreBase.h.

◆ mutex_t

using xAOD::details::AuxStoreBase::mutex_t = AthContainers_detail::mutex
protectedinherited

Mutex type for multithread synchronization.

Definition at line 204 of file AuxStoreBase.h.

Member Enumeration Documentation

◆ EStructMode

"Structural" modes of the object

Enumerator
kUndefinedStore 

The structure mode is not defined.

kContainerStore 

The object describes an entire container.

kObjectStore 

The object describes a single object.

Definition at line 30 of file AuxStoreBase.h.

30  {
31  kUndefinedStore = 0,
32  kContainerStore = 1,
33  kObjectStore = 2
34  };

Constructor & Destructor Documentation

◆ TAuxStore()

xAOD::TAuxStore::TAuxStore ( std::string_view  prefix = "",
bool  topStore = true,
EStructMode  mode = EStructMode::kUndefinedStore,
int  basketSize = 2048,
int  splitLevel = 0 
)

Constructor.

Definition at line 818 of file TAuxStore.cxx.

820  : details::AuxStoreBase(topStore, mode),
821  m_impl{std::make_unique<impl>(m_data, basketSize, splitLevel)} {
822 
823  setPrefix(prefix);
824 }

◆ ~TAuxStore()

xAOD::TAuxStore::~TAuxStore ( )
virtualdefault

Destructor.

Member Function Documentation

◆ basketSize()

int xAOD::TAuxStore::basketSize ( ) const

Get the size of the baskets created for the output branches.

Definition at line 835 of file TAuxStore.cxx.

835  {
836 
837  assert(m_impl);
838  return m_impl->m_basketSize;
839 }

◆ clearDecorations()

bool xAOD::details::AuxStoreBase::clearDecorations ( )
overridevirtualinherited

Remove the decorations added so far.

Only works for transient decorations.

Implements SG::IConstAuxStore.

Definition at line 211 of file AuxStoreBase.cxx.

211  {
212 
213  // Guard against multi-threaded execution:
214  guard_t guard(m_mutex1);
215 
216  // Clear the transient decorations:
217  bool anycleared = false;
218  if (m_data.m_transientStore) {
219  SG::auxid_set_t old_id_set = m_data.m_transientStore->getAuxIDs();
220 
221  // Clear the decorations from the transient store:
222  anycleared = m_data.m_transientStore->clearDecorations();
223 
224  // Now remove ids that were cleared.
225  if (anycleared) {
226  old_id_set -= m_data.m_transientStore->getAuxIDs();
227  // old_id_set is now the set of ids that were cleared.
228  m_data.m_auxIDs -= old_id_set;
230  }
231  }
232 
233  // The decorations which are going into the output file, are here to stay.
234  // Removing their IDs from the internal set would just cause more problems
235  // in my mind than just leaving them be.
236 
237  return anycleared;
238 }

◆ getAuxIDs()

const SG::auxid_set_t & xAOD::details::AuxStoreBase::getAuxIDs ( ) const
overridevirtualinherited

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

Implements SG::IConstAuxStore.

Definition at line 101 of file AuxStoreBase.cxx.

101  {
102 
103  return m_data.m_auxIDs;
104 }

◆ getData() [1/4]

virtual void* SG::IAuxStore::getData ( auxid_t  auxid,
size_t  size,
size_t  capacity 
)
pure virtualinherited

Return the data vector for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.
sizeThe current size of the container (in case the data item does not already exist).
capacityThe current capacity of the container (in case the data item does not already exist).

Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.

If the data item does not exist, it should be created and initialized to default values. size and capacity give the size for the new aux data item vector.

If the container is locked, throw an exception.

Implemented in SG::AuxStoreInternal, APRTest::AuxStore, RootAuxDynStore, xAOD::AuxContainerBase, xAOD::ShallowAuxContainer, xAOD::AuxInfoBase, and xAOD::ByteStreamAuxContainer_v1.

◆ getData() [2/4]

const void * xAOD::details::AuxStoreBase::getData ( SG::auxid_t  auxid) const
overridevirtualinherited

Get a pointer to a given array.

Implements SG::IConstAuxStore.

Definition at line 56 of file AuxStoreBase.cxx.

56  {
57 
58  const SG::IAuxTypeVector* v = getVector(auxid);
59  if (v) {
60  return v->toPtr();
61  }
62  return nullptr;
63 }

◆ getData() [3/4]

virtual const void* SG::IConstAuxStore::getData
inherited

Pick up the const version from the base class.

◆ getData() [4/4]

void * xAOD::details::AuxStoreBase::getData ( SG::auxid_t  auxid,
std::size_t  size,
std::size_t  capacity 
)
overridevirtualinherited

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

Definition at line 303 of file AuxStoreBase.cxx.

304  {
305 
306  // Guard against multi-threaded execution:
307  guard_t guard(m_mutex2);
308 
309  // Remember the size:
310  m_data.m_size = size;
311 
312  // Check if we want to write this variable to the output:
313  if (!(isAuxIDSelected(auxid) && hasOutput())) {
314  // Create the store only when necessary:
315  if (!m_data.m_transientStore) {
316  m_data.m_transientStore = std::make_unique<SG::AuxStoreInternal>(
318  if (m_locked) {
319  m_data.m_transientStore->lock();
320  }
321  }
322  // Let the transient store create the variable:
323  std::size_t nids = m_data.m_transientStore->getAuxIDs().size();
324  void* result = m_data.m_transientStore->getData(auxid, size, capacity);
325  if (result && (nids != m_data.m_transientStore->getAuxIDs().size())) {
326  m_data.m_auxIDs.insert(auxid);
327  }
328  // Return the address in the transient memory:
329  return result;
330  }
331 
332  // If the variable exists already, and this is a locked store, then
333  // we are in trouble.
334  if (m_locked && (auxid < m_data.m_vecs.size()) && m_data.m_vecs[auxid]) {
335  if (!((auxid < m_data.m_isDecoration.size()) &&
336  m_data.m_isDecoration[auxid])) {
337  throw SG::ExcStoreLocked(auxid);
338  }
339  }
340 
341  // Connect this auxiliary variable just to the output:
342  if (setupOutputData(auxid).isFailure()) {
343  ::Error("xAOD::AuxStoreBase::getData",
344  XAOD_MESSAGE("Failed to set up variable %s"),
345  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
346  return nullptr;
347  }
348 
349  // Check whether things make sense:
350  if ((m_data.m_structMode == EStructMode::kObjectStore) && (size != 1)) {
351  ::Error("xAOD::AuxStoreBase::getData",
352  XAOD_MESSAGE("Branch creation requested with:"));
353  ::Error("xAOD::AuxStoreBase::getData", XAOD_MESSAGE(" name = %s"),
354  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
355  ::Error("xAOD::AuxStoreBase::getData", XAOD_MESSAGE(" size = %i"),
356  static_cast<int>(size));
357  ::Error("xAOD::AuxStoreBase::getData",
358  XAOD_MESSAGE(" m_structMode = EStructMode::kObjectStore"));
359  return nullptr;
360  }
361 
362  // Make sure the variable is of the right size:
363  m_data.m_vecs[auxid]->reserve(capacity);
364  m_data.m_vecs[auxid]->resize(size);
365 
366  // Return the object:
367  return m_data.m_vecs[auxid]->toPtr();
368 }

◆ getDecoration() [1/2]

virtual void* SG::IConstAuxStore::getDecoration ( auxid_t  auxid,
size_t  size,
size_t  capacity 
)
pure virtualinherited

Return the data vector for one aux data decoration item.

Parameters
auxidThe identifier of the desired aux data item.
sizeThe current size of the container (in case the data item does not already exist).
capacityThe current capacity of the container (in case the data item does not already exist).

Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.

If the data item does not exist, it then it will be created and initialized with default values. If the container is locked, then the new item will be marked as a decoration. size and capacity give the size for the new aux data item vector.

If the data item already exists, then we return it if either the container is not locked or the item is marked as a decoration. Otherwise we throw an exception.

Implemented in xAOD::EventAuxInfo_v1, xAOD::EventInfoAuxContainer_v1, xAOD::EventAuxInfo_v2, xAOD::EventAuxInfo_v3, RootAuxDynStore, SG::AuxStoreInternal, xAOD::AuxContainerBase, xAOD::ShallowAuxContainer, xAOD::AuxInfoBase, SG::AuxStoreConstMem, and xAOD::ByteStreamAuxContainer_v1.

◆ getDecoration() [2/2]

void * xAOD::details::AuxStoreBase::getDecoration ( SG::auxid_t  auxid,
std::size_t  size,
std::size_t  capacity 
)
overridevirtualinherited

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

Definition at line 111 of file AuxStoreBase.cxx.

112  {
113 
114  // Guard against multi-threaded execution:
115  guard_t guard(m_mutex1);
116 
117  // Remember the requested size:
118  m_data.m_size = size;
119 
120  // If this is a locked object, deal with it correctly:
121  if (m_locked) {
122  // If the variable exists already and it's a decoration, then let's
123  // give it back.
124  if ((auxid < m_data.m_vecs.size()) && m_data.m_vecs[auxid] &&
125  (auxid < m_data.m_isDecoration.size() &&
126  m_data.m_isDecoration[auxid])) {
127  // Things look okay...
128  m_data.m_vecs[auxid]->reserve(capacity);
129  m_data.m_vecs[auxid]->resize(size);
130  return m_data.m_vecs[auxid]->toPtr();
131  }
132  // If it's in the transient store already, return it from there.
133  // Since in a locked store *everything* is a decoration in the
134  // transient store.
135  if (m_data.m_transientStore &&
136  m_data.m_transientStore->getAuxIDs().test(auxid)) {
137  return m_data.m_transientStore->getDecoration(auxid, size, capacity);
138  }
139  // If we know this auxiliary ID, but it was not found as a decoration
140  // by the previous checks, then we're in trouble.
141  if (m_data.m_auxIDs.test(auxid)) {
142  throw SG::ExcStoreLocked(auxid);
143  }
144  }
145 
146  // Check if we want to write this variable to the output:
147  if (!(isAuxIDSelected(auxid) && hasOutput())) {
148 
149  // Create the store only when necessary:
150  if (!m_data.m_transientStore) {
151  m_data.m_transientStore = std::make_unique<SG::AuxStoreInternal>(
153  if (m_locked) {
154  m_data.m_transientStore->lock();
155  }
156  }
157  // Let the transient store create the decoration:
158  const std::size_t nids = m_data.m_transientStore->getAuxIDs().size();
159  void* result =
160  m_data.m_transientStore->getDecoration(auxid, size, capacity);
161  if (result && (nids != m_data.m_transientStore->getAuxIDs().size())) {
162  if (m_data.m_transientStore->isDecoration(auxid)) {
163  m_data.m_decorIDs.insert(auxid);
164  }
165  std::atomic_thread_fence( std::memory_order_seq_cst );
166  m_data.m_auxIDs.insert(auxid);
167  }
168  // Return the memory address from the transient store:
169  return result;
170  }
171 
172  // Doesn't exist yet. So let's make it:
173  if (m_locked) {
174  // If the container is locked, remember that this is a decoration:
175  if (m_data.m_isDecoration.size() <= auxid) {
176  m_data.m_isDecoration.resize(auxid + 1);
177  }
178  m_data.m_isDecoration[auxid] = true;
179  m_data.m_decorIDs.insert(auxid);
180  std::atomic_thread_fence( std::memory_order_seq_cst );
181  }
182  void* result = getData(auxid, size, capacity);
183 
184  // Return the pointer made by getData(...):
185  return result;
186 }

◆ getDecorIDs()

const SG::auxid_set_t & xAOD::details::AuxStoreBase::getDecorIDs ( ) const
overridevirtualinherited

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

Implements SG::IConstAuxStore.

Definition at line 106 of file AuxStoreBase.cxx.

106  {
107 
108  return m_data.m_decorIDs;
109 }

◆ getDynamicAuxIDs()

const SG::auxid_set_t & xAOD::details::AuxStoreBase::getDynamicAuxIDs ( ) const
overridevirtualinherited

Get the types(names) of variables created dynamically.

Implements SG::IAuxStoreIO.

Definition at line 612 of file AuxStoreBase.cxx.

612  {
613 
614  // All the auxiliary decorations handled by this object are considered
615  // dynamic:
616  return getAuxIDs();
617 }

◆ getEntry()

int xAOD::TAuxStore::getEntry ( int  getall = 0)

Read the values from the TTree entry that was loaded with TTree::LoadTree()

Definition at line 931 of file TAuxStore.cxx.

931  {
932 
933  assert(m_impl);
934 
935  // Guard against multi-threaded execution:
936  guard_t guard(m_impl->m_mutex);
937 
938  // Reset the transient store. TEvent::fill() calls this function with
939  // getall==99. When that is happening, we need to keep the transient
940  // store still around. Since the user may want to interact with the
941  // object after it was written out. (And since TEvent::fill() asks for
942  // the transient decorations after calling getEntry(...).)
943  if (m_data.m_transientStore && (getall != 99)) {
944  // Remove the transient auxiliary IDs from the internal list:
945  m_data.m_auxIDs -= m_data.m_transientStore->getAuxIDs();
946  m_data.m_decorIDs -= m_data.m_transientStore->getDecorIDs();
947  // Delete the object:
948  m_data.m_transientStore.reset();
949  }
950 
951  // Now remove the IDs of the decorations that are getting persistified:
952  if (getall != 99) {
953  for (SG::auxid_t auxid = 0; auxid < m_data.m_isDecoration.size(); ++auxid) {
954  if (!m_data.m_isDecoration[auxid]) {
955  continue;
956  }
957  m_data.m_auxIDs.erase(auxid);
958  m_data.m_decorIDs.erase(auxid);
959  }
960  }
961 
962  // If we don't need everything loaded, return now:
963  if (!getall) {
964  return 0;
965  }
966 
967  // Get all the variables at once:
968  int bytesRead = 0;
969  for (auto& branchHandle : m_impl->m_branches) {
970  if (branchHandle) {
971  bytesRead += branchHandle->getEntry();
972  }
973  }
974  return bytesRead;
975 }

◆ getEntryFor()

StatusCode xAOD::TAuxStore::getEntryFor ( SG::auxid_t  auxid)
overrideprivatevirtual

Load a single variable from the input.

Implements xAOD::details::AuxStoreBase.

Definition at line 995 of file TAuxStore.cxx.

995  {
996 
997  assert(m_impl);
998  assert(m_impl->m_branches.size() > auxid);
999  assert(m_impl->m_branches[auxid]);
1000  const ::Int_t readBytes = m_impl->m_branches[auxid]->getEntry();
1001  if (readBytes < 0) {
1002  ::Error("xAOD::TAuxStore::getEntryFor",
1003  XAOD_MESSAGE("Couldn't read in variable %s"),
1004  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
1005  return StatusCode::FAILURE;
1006  }
1007  return StatusCode::SUCCESS;
1008 }

◆ getInputObject()

const void * xAOD::TAuxStore::getInputObject ( SG::auxid_t  auxid) const
overrideprivatevirtual

Get a pointer to an input object, as it is in memory, for getIOData()

Implements xAOD::details::AuxStoreBase.

Definition at line 1523 of file TAuxStore.cxx.

1523  {
1524 
1525  assert(m_impl);
1526  assert(m_impl->m_branches.size() > auxid);
1527  assert(m_impl->m_branches[auxid]);
1528  return m_impl->m_branches[auxid]->objectPtr();
1529 }

◆ getInputType()

const std::type_info * xAOD::TAuxStore::getInputType ( SG::auxid_t  auxid) const
overrideprivatevirtual

Get the type of an input object, for getIOType()

Implements xAOD::details::AuxStoreBase.

Definition at line 1531 of file TAuxStore.cxx.

1531  {
1532 
1533  assert(m_impl);
1534  assert(m_impl->m_branches.size() > auxid);
1535  assert(m_impl->m_branches[auxid]);
1536  return m_impl->m_branches[auxid]->typeInfo();
1537 }

◆ getIOData()

const void * xAOD::details::AuxStoreBase::getIOData ( SG::auxid_t  auxid) const
overridevirtualinherited

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

Implements SG::IAuxStoreIO.

Definition at line 514 of file AuxStoreBase.cxx.

514  {
515 
516  // Guard against multi-threaded execution:
517  guard_t guard(m_mutex1);
518 
519  auto this_nc ATLAS_THREAD_SAFE =
520  const_cast<AuxStoreBase*>(this); // locked above
521 
522  // If the variable is coming from the input, and is connected to already.
523  if (hasEntryFor(auxid)) {
524  if (!this_nc->getEntryFor(auxid).isSuccess()) {
525  ::Error("xAOD::AuxStoreBase::getIOData",
526  XAOD_MESSAGE("Couldn't read in variable %s"),
527  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
528  return nullptr;
529  }
530  return getInputObject(auxid);
531  }
532 
533  // Check if it's in the transient store:
534  if (m_data.m_transientStore &&
535  m_data.m_transientStore->getAuxIDs().test(auxid)) {
536  return m_data.m_transientStore->getIOData(auxid);
537  }
538 
539  // If not, try connecting to it now:
540  if (!this_nc->setupInputData(auxid).isSuccess()) {
541  // This is not actually an error condition anymore. We can end up here
542  // when we decorate constant objects coming from the input file, but
543  // on one event we can't set any decorations. For instance when the
544  // input container is empty. In that case the object will still list
545  // the auxiliary ID belonging to that decoration as being available,
546  // but it really isn't.
547  //
548  // Later on it might be needed to tweak the logic of all of this, but
549  // for now just silently returning 0 seems to do the right thing.
550  return nullptr;
551  }
552 
553  // Now we should know this variable:
554  if (!hasEntryFor(auxid)) {
555  ::Fatal("xAOD::AuxStoreBase::getIOData",
556  XAOD_MESSAGE("Internal logic error detected"));
557  return nullptr;
558  }
559 
560  // Make sure that the right payload is in memory:
561  if (!this_nc->getEntryFor(auxid).isSuccess()) {
562  ::Error("xAOD::AuxStoreBase::getIOData",
563  XAOD_MESSAGE("Couldn't read in variable %s"),
564  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
565  return nullptr;
566  }
567 
568  // Return the pointer.
569  return getInputObject(auxid);
570 }

◆ getIOType()

const std::type_info * xAOD::details::AuxStoreBase::getIOType ( SG::auxid_t  auxid) const
overridevirtualinherited

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

Implements SG::IAuxStoreIO.

Definition at line 573 of file AuxStoreBase.cxx.

573  {
574 
575  // Guard against multi-threaded execution:
576  guard_t guard(m_mutex1);
577 
578  // If the variable is connected to already:
579  if (hasEntryFor(auxid)) {
580  return getInputType(auxid);
581  }
582 
583  // Check if it's in the transient store:
584  if (m_data.m_transientStore &&
585  m_data.m_transientStore->getAuxIDs().test(auxid)) {
586  return m_data.m_transientStore->getIOType(auxid);
587  }
588 
589  // If not, try connecting to it now:
590  auto this_nc ATLAS_THREAD_SAFE =
591  const_cast<AuxStoreBase*>(this); // locked above
592  if (!this_nc->setupInputData(auxid).isSuccess()) {
593  ::Error("xAOD::AuxStoreBase::getIOType",
594  XAOD_MESSAGE("Couldn't connect to auxiliary variable "
595  "%i %s"),
596  static_cast<int>(auxid),
597  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
598  return nullptr;
599  }
600 
601  // Now we should know this variable:
602  if (!hasEntryFor(auxid)) {
603  ::Fatal("xAOD::AuxStoreBase::getIOType",
604  XAOD_MESSAGE("Internal logic error detected"));
605  return nullptr;
606  }
607 
608  // Return the type info:
609  return getInputType(auxid);
610 }

◆ getSelectedAuxIDs()

SG::auxid_set_t xAOD::details::AuxStoreBase::getSelectedAuxIDs ( ) const
overridevirtualinherited

Get the IDs of the selected aux variables.

Reimplemented from SG::IAuxStoreIO.

Definition at line 627 of file AuxStoreBase.cxx.

627  {
628 
629  // Guard against multi-threaded execution:
630  guard_t guard(m_mutex1);
631  // Leave the calculation up to the internal object:
633 }

◆ getVector()

const SG::IAuxTypeVector * xAOD::details::AuxStoreBase::getVector ( SG::auxid_t  auxid) const
overridevirtualinherited

Return vector interface for one aux data item.

Implements SG::IConstAuxStore.

Definition at line 65 of file AuxStoreBase.cxx.

65  {
66 
67  // Guard against multi-threaded execution:
68  guard_t guard(m_mutex1);
69 
70  // Check if the transient store already handles this variable:
72  (m_data.m_transientStore->getAuxIDs().test(auxid))) {
73  return m_data.m_transientStore->getVector(auxid);
74  }
75 
76  // Access the object through a non-const pointer. This is "safe" because
77  // of the mutex lock above.
78  auto this_nc ATLAS_THREAD_SAFE = const_cast<AuxStoreBase*>(this);
79 
80  // Connect this auxiliary variable both to the input and output
81  // if needed:
82  if ((auxid >= m_data.m_vecs.size()) || (!m_data.m_vecs[auxid])) {
83  if ((!this_nc->setupInputData(auxid).isSuccess()) ||
84  (!this_nc->setupOutputData(auxid).isSuccess())) {
85  return nullptr;
86  }
87  }
88 
89  // Make sure the variable is up to date:
90  if (this_nc->getEntryFor(auxid).isSuccess() == false) {
91  ::Error("xAOD::AuxStoreBase::getVector",
92  XAOD_MESSAGE("Couldn't read in variable %s"),
93  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
94  return nullptr;
95  }
96 
97  // Return the pointer to the object:
98  return m_data.m_vecs[auxid].get();
99 }

◆ getWritableAuxIDs()

const SG::auxid_set_t & xAOD::details::AuxStoreBase::getWritableAuxIDs ( ) const
overridevirtualinherited

Return a set of writable data identifiers.

Implements SG::IAuxStore.

Definition at line 370 of file AuxStoreBase.cxx.

370  {
371 
372  return getAuxIDs();
373 }

◆ hasEntryFor()

bool xAOD::TAuxStore::hasEntryFor ( SG::auxid_t  auxid) const
overrideprivatevirtual

Check if a given variable is available from the input.

Implements xAOD::details::AuxStoreBase.

Definition at line 989 of file TAuxStore.cxx.

989  {
990 
991  assert(m_impl);
992  return ((m_impl->m_branches.size() > auxid) && m_impl->m_branches[auxid]);
993 }

◆ hasOutput()

bool xAOD::TAuxStore::hasOutput ( ) const
overrideprivatevirtual

Check if an output is being written by the object.

Implements xAOD::details::AuxStoreBase.

Definition at line 1010 of file TAuxStore.cxx.

1010  {
1011 
1012  assert(m_impl);
1013  return (m_impl->m_outTree != nullptr);
1014 }

◆ 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.

Implemented in SG::AuxStoreInternal.

◆ insertMove() [2/2]

bool xAOD::details::AuxStoreBase::insertMove ( std::size_t  pos,
SG::IAuxStore other,
const SG::auxid_set_t ignore 
)
overridevirtualinherited

Insert contents of another store via move.

Definition at line 464 of file AuxStoreBase.cxx.

465  {
466  // Guard against multi-threaded execution:
467  guard_t guard(m_mutex1);
468 
469  // A sanity check:
471  ::Error("xAOD::AuxStoreBase::insertMove",
472  XAOD_MESSAGE("Should not have been called for single-object "
473  "store"));
474  return false;
475  }
476 
477  bool nomove = true;
478  std::size_t other_size = other.size();
479 
480  SG::auxid_set_t ignore = ignore_in;
481 
482  for (SG::auxid_t id : m_data.m_auxIDs) {
483  SG::IAuxTypeVector* v_dst = nullptr;
484  if (id < m_data.m_vecs.size()) {
485  v_dst = m_data.m_vecs[id].get();
486  }
487  if (v_dst && !v_dst->isLinked()) {
488  ignore.insert(id);
489  if (other.getData(id)) {
490  void* src_ptr = other.getData(id, other_size, other_size);
491  if (src_ptr) {
492  if (!v_dst->insertMove(pos, src_ptr, 0, other_size, other)) {
493  nomove = false;
494  }
495  }
496  } else {
497  const void* orig = v_dst->toPtr();
498  v_dst->shift(pos, other_size);
499  if (orig != v_dst->toPtr()) {
500  nomove = false;
501  }
502  }
503  }
504  }
505 
506  if (m_data.m_transientStore) {
507  if (!m_data.m_transientStore->insertMove(pos, other, ignore))
508  nomove = false;
509  }
510 
511  return nomove;
512 }

◆ isAuxIDSelected()

bool xAOD::details::AuxStoreBase::isAuxIDSelected ( SG::auxid_t  auxid) const
protectedinherited

Check if an auxiliary variable is selected for ouput writing.

This is a tricky one.

The function can't just rely on getSelectedAuxIDs, as the aux ID received here may be a new ID that the object doesn't yet know about. So we have no other choice but to check this ID explicitly.

@apram auxid The auxiliary ID that should be checked

Returns
true if the variable needs to be written out, false if not

Definition at line 643 of file AuxStoreBase.cxx.

643  {
644 
645  // A temporary object:
646  SG::auxid_set_t auxids;
647  auxids.insert(auxid);
648 
649  // Check if the auxid is returned as a selected ID:
650  return m_selection.getSelectedAuxIDs(auxids).size();
651 }

◆ isDecoration()

bool xAOD::details::AuxStoreBase::isDecoration ( SG::auxid_t  auxid) const
overridevirtualinherited

Test if a variable is a decoration.

Implements SG::IConstAuxStore.

Definition at line 188 of file AuxStoreBase.cxx.

188  {
189  if (m_locked) {
190  if (auxid < m_data.m_isDecoration.size() && m_data.m_isDecoration[auxid]) {
191  return true;
192  }
193  if (m_data.m_transientStore) {
194  return m_data.m_transientStore->isDecoration(auxid);
195  }
196  }
197  return false;
198 }

◆ isTopStore()

bool xAOD::details::AuxStoreBase::isTopStore ( ) const
inherited

Check if the object is a "top store", or not.

Definition at line 45 of file AuxStoreBase.cxx.

45  {
46 
47  return m_data.m_topStore;
48 }

◆ linkedVector() [1/3]

const SG::IAuxTypeVector * xAOD::details::AuxStoreBase::linkedVector ( SG::auxid_t  auxid) const
overridevirtualinherited

Return (const) interface for a linked variable.

Reimplemented from SG::IConstAuxStore.

Definition at line 276 of file AuxStoreBase.cxx.

276  {
278  SG::auxid_t linked_id = r.linkedVariable(auxid);
279  guard_t guard(m_mutex1);
280  if (linked_id < m_data.m_vecs.size()) {
281  return m_data.m_vecs[linked_id].get();
282  }
283  if (m_data.m_transientStore) {
285  ->linkedVector(auxid);
286  }
287  return nullptr;
288 }

◆ linkedVector() [2/3]

SG::IAuxTypeVector * xAOD::details::AuxStoreBase::linkedVector ( SG::auxid_t  auxid)
overridevirtualinherited

Return (non-const) interface for a linked variable.

Reimplemented from SG::IAuxStore.

Definition at line 290 of file AuxStoreBase.cxx.

290  {
292  SG::auxid_t linked_id = r.linkedVariable(auxid);
293  guard_t guard(m_mutex1);
294  if (linked_id < m_data.m_vecs.size()) {
295  return m_data.m_vecs[linked_id].get();
296  }
297  if (m_data.m_transientStore) {
298  return m_data.m_transientStore->linkedVector(auxid);
299  }
300  return nullptr;
301 }

◆ linkedVector() [3/3]

virtual const IAuxTypeVector* SG::IConstAuxStore::linkedVector
inlineinherited

Return interface for a linked variable.

Parameters
auxidThe ID of the parent variable.

If auxid has a linked variable, then return the IAuxTypeVector describing it. Otherwise, return nullptr. May return nullptr unconditionally if this store does not support linked variables.

Definition at line 189 of file IConstAuxStore.h.

190  { return nullptr; }

◆ lock()

void xAOD::details::AuxStoreBase::lock ( )
overridevirtualinherited

Lock the object, and don't let decorations be added.

Implements SG::IConstAuxStore.

Definition at line 200 of file AuxStoreBase.cxx.

200  {
201 
202  // Guard against multi-threaded execution:
203  guard_t guard(m_mutex1);
204 
205  m_locked = true;
206  if (m_data.m_transientStore) {
207  m_data.m_transientStore->lock();
208  }
209 }

◆ lockDecoration()

void xAOD::details::AuxStoreBase::lockDecoration ( SG::auxid_t  auxid)
overridevirtualinherited

Lock a decoration.

Implements SG::IConstAuxStore.

Definition at line 241 of file AuxStoreBase.cxx.

241  {
242  if (m_data.m_transientStore) {
243  m_data.m_transientStore->lockDecoration(auxid);
244  }
245  m_data.m_decorIDs.erase(auxid);
246 }

◆ prefix()

const std::string & xAOD::details::AuxStoreBase::prefix ( ) const
inherited

Get the currently configured object name prefix.

Definition at line 40 of file AuxStoreBase.cxx.

40  {
41 
42  return m_data.m_prefix;
43 }

◆ readFrom()

StatusCode xAOD::TAuxStore::readFrom ( ::TTree &  tree,
bool  printWarnings = true 
)

Connect the object to an input TTree.

This function is called by the infrastructure to connect the object to an input TTree whenever a new input file is opened.

Parameters
treePointer to the TTree that is being read from

Definition at line 864 of file TAuxStore.cxx.

864  {
865 
866  assert(m_impl);
867 
868  // Make sure that everything will be re-read after this:
869  reset();
870 
871  // We will need to check again which branches are available:
872  m_impl->m_missingBranches.clear();
873 
874  // Remember the tree:
875  m_impl->m_inTree = &tree;
876 
877  // Catalogue all the branches:
878  RETURN_CHECK("xAOD::TAuxStore::readFrom", m_impl->scanInputTree());
879 
880  // Check if we'll be likely to be able to read the "static"
881  // variables:
882  assert(m_impl->m_inTree != nullptr);
883  TBranch* br = m_impl->m_inTree->GetBranch(m_data.m_prefix.data());
884  if (br == nullptr) {
885  // We might not even have static branches, so this is not an error
886  // by itself...
887  return StatusCode::SUCCESS;
888  }
889  // In order to read complex objects, like smart pointers from an
890  // auxiliary container variable-by-variable, the split level of the
891  // branch must be exactly 1.
892  if ((br->GetSplitLevel() != 1) && m_data.m_topStore && printWarnings) {
893  ::Warning("xAOD::TAuxStore::readFrom",
894  "Static branch (%s) with split level %i discovered",
895  m_data.m_prefix.data(), br->GetSplitLevel());
896  ::Warning("xAOD::TAuxStore::readFrom",
897  "The reading of complex variables from it may/will fail!");
898  }
899 
900  // Return gracefully.
901  return StatusCode::SUCCESS;
902 }

◆ reserve() [1/2]

virtual void SG::IAuxStore::reserve ( size_t  sz)
pure virtualinherited

Change the capacity of all aux data vectors.

Parameters
szThe new capacity.

This should be called when the capacity of the container changes (by reserve). This should change the capacity for the vectors for all aux data items.

Implemented in SG::AuxStoreInternal, xAOD::AuxContainerBase, xAOD::ShallowAuxContainer, xAOD::AuxInfoBase, and xAOD::ByteStreamAuxContainer_v1.

◆ reserve() [2/2]

void xAOD::details::AuxStoreBase::reserve ( std::size_t  size)
overridevirtualinherited

Reserve a given size for the arrays.

Definition at line 408 of file AuxStoreBase.cxx.

408  {
409 
410  // Guard against multi-threaded execution:
411  guard_t guard(m_mutex1);
412 
413  // A sanity check:
414  if ((m_data.m_structMode == EStructMode::kObjectStore) && (size != 1)) {
415  ::Error("xAOD::AuxStoreBase::reserve",
416  XAOD_MESSAGE("size = %i for single-object store"),
417  static_cast<int>(size));
418  return;
419  }
420 
421  for (auto& v : m_data.m_vecs) {
422  if (v && !v->isLinked()) {
423  v->reserve(size);
424  }
425  }
426 
427  if (m_data.m_transientStore) {
428  m_data.m_transientStore->reserve(size);
429  }
430 }

◆ reset()

void xAOD::TAuxStore::reset ( )
overridevirtual

Tell the object that all branches will need to be re-read.

Implements xAOD::details::AuxStoreBase.

Definition at line 977 of file TAuxStore.cxx.

977  {
978 
979  assert(m_impl);
980 
981  for (auto& branchHandle : m_impl->m_branches) {
982  if (branchHandle) {
983  branchHandle->reset();
984  }
985  }
986  m_impl->m_inputScanned = false;
987 }

◆ resize() [1/2]

virtual bool SG::IAuxStore::resize ( size_t  sz)
pure virtualinherited

Change the size of all aux data vectors.

Parameters
szThe new size.

This should be called when the size of the container changes. This should resize the vectors for all aux data items.

If the size of the container grows, the new elements should be default-initialized; if it shrinks, destructors should be run as appropriate.

Should return true if it is known that none of the data pointers changed (and thus the cache does not need to be cleared), false otherwise.

Implemented in SG::AuxStoreInternal, xAOD::AuxContainerBase, xAOD::ShallowAuxContainer, xAOD::AuxInfoBase, and xAOD::ByteStreamAuxContainer_v1.

◆ resize() [2/2]

bool xAOD::details::AuxStoreBase::resize ( std::size_t  size)
overridevirtualinherited

Resize the arrays to a given size.

Definition at line 375 of file AuxStoreBase.cxx.

375  {
376 
377  // Guard against multi-threaded execution:
378  guard_t guard(m_mutex1);
379 
380  // A sanity check:
381  if ((m_data.m_structMode == EStructMode::kObjectStore) && (size != 1)) {
382  ::Error("xAOD::AuxStoreBase::resize",
383  XAOD_MESSAGE("size = %i for single-object store"),
384  static_cast<int>(size));
385  return false;
386  }
387 
388  // Remember the new size:
389  m_data.m_size = size;
390 
391  bool nomoves = true;
392  for (auto& v : m_data.m_vecs) {
393  if (v && !v->isLinked()) {
394  if (!v->resize(size)) {
395  nomoves = false;
396  }
397  }
398  }
399  if (m_data.m_transientStore) {
400  if (!m_data.m_transientStore->resize(size)) {
401  nomoves = false;
402  }
403  }
404 
405  return nomoves;
406 }

◆ selectAux()

void xAOD::details::AuxStoreBase::selectAux ( const std::set< std::string > &  attributes)
virtualinherited

Select dynamic auxiliary attributes for writing.

Definition at line 620 of file AuxStoreBase.cxx.

620  {
621 
622  guard_t guard(m_mutex1);
624 }

◆ setBasketSize()

void xAOD::TAuxStore::setBasketSize ( int  value)

Set the size of the baskets created for the output branches.

Definition at line 841 of file TAuxStore.cxx.

841  {
842 
843  assert(m_impl);
844  m_impl->m_basketSize = value;
845 }

◆ setOption()

virtual bool SG::IAuxStore::setOption ( auxid_t  ,
const AuxDataOption  
)
inlinevirtualinherited

Set an option for a given auxiliary variable.

Parameters
auxidThe identifier of the desired aux data item.
optionThe option to set.

The interpretation of the option depends on the particular representation of the variable.

Returns true if the option setting was successful; false otherwise.

Reimplemented in xAOD::AuxContainerBase, xAOD::AuxInfoBase, and SG::AuxStoreInternal.

Definition at line 173 of file IAuxStore.h.

174  { return false; }

◆ setPrefix()

void xAOD::TAuxStore::setPrefix ( std::string_view  prefix)
overridevirtual

Set the object name prefix.

Implements xAOD::details::AuxStoreBase.

Definition at line 828 of file TAuxStore.cxx.

828  {
829 
832  reset();
833 }

◆ setSplitLevel()

void xAOD::TAuxStore::setSplitLevel ( int  value)

Set the split level of the output branches.

Definition at line 853 of file TAuxStore.cxx.

853  {
854 
855  assert(m_impl);
856  m_impl->m_splitLevel = value;
857 }

◆ setStructMode()

void xAOD::details::AuxStoreBase::setStructMode ( EStructMode  mode)
inherited

Set the structure mode of the object to a new value.

Definition at line 34 of file AuxStoreBase.cxx.

34  {
35 
37  reset();
38 }

◆ setTopStore()

void xAOD::details::AuxStoreBase::setTopStore ( bool  value = true)
inherited

Set whether the object should behave as a "top store" or not.

Definition at line 50 of file AuxStoreBase.cxx.

50  {
51 
53  reset();
54 }

◆ setupInputData()

StatusCode xAOD::TAuxStore::setupInputData ( SG::auxid_t  auxid)
overrideprivatevirtual

Connect a variable to the input.

Connect a variable to the input tree.

This internal function takes care of connecting to an individual (sub-)branch in the input file for a given auxiliary variable. It needs to handle a number of different use cases, so it's a bit long.

Parameters
auxidThe ID of the variable to connect to
Returns
StatusCode::SUCCESS if the function was successful, something else otherwise

Implements xAOD::details::AuxStoreBase.

Definition at line 1026 of file TAuxStore.cxx.

1026  {
1027 
1028  assert(m_impl);
1029 
1030  // Return right away if we already know that the branch is missing.
1031  if ((auxid < m_impl->m_missingBranches.size()) &&
1032  m_impl->m_missingBranches[auxid]) {
1033  return StatusCode::RECOVERABLE;
1034  }
1035 
1036  // Make sure the internal storage is large enough:
1037  if (m_data.m_vecs.size() <= auxid) {
1038  m_data.m_vecs.resize(auxid + 1);
1039  }
1040  if (m_impl->m_branches.size() <= auxid) {
1041  m_impl->m_branches.resize(auxid + 1);
1042  }
1043 
1044  // Check if we need to do anything:
1045  if (m_data.m_vecs[auxid] && m_impl->m_branches[auxid]) {
1046  return StatusCode::SUCCESS;
1047  }
1048 
1049  // A little sanity check.
1050  if (m_impl->m_inTree == nullptr) {
1051  ::Error("xAOD::TAuxStore::setupInputData",
1052  XAOD_MESSAGE("No input TTree set up!"));
1053  return StatusCode::FAILURE;
1054  }
1055 
1056  // Another sanity check.
1057  if (m_data.m_vecs[auxid] || m_impl->m_branches[auxid]) {
1058  ::Error("xAOD::TAuxStore::setupInputData",
1059  XAOD_MESSAGE("Internal logic error!"));
1060  return StatusCode::FAILURE;
1061  }
1062 
1063  // Convenience access to the registry.
1065 
1066  // Get the property name:
1067  const TString statBrName =
1068  std::format("{}{}", m_data.m_prefix, r.getName(auxid));
1069  const TString dynBrName =
1070  std::format("{}{}", m_data.m_dynPrefix, r.getName(auxid));
1071 
1072  // Check if the branch exists:
1073  Bool_t staticBranch = true;
1074  TString brName = statBrName;
1075 
1076  TBranch* br = m_impl->m_inTree->GetBranch(statBrName);
1077  if (!br) {
1078  br = m_impl->m_inTree->GetBranch(dynBrName);
1079  if (!br) {
1080  // Since TTree::GetBranch / TTObjArray::FindObject is expensive,
1081  // remember that we didn't find this branch in this file.
1082  if (m_impl->m_missingBranches.size() <= auxid) {
1083  m_impl->m_missingBranches.resize(auxid + 1);
1084  }
1085  m_impl->m_missingBranches[auxid] = true;
1086  // The branch doesn't exist, but this is not an error per se.
1087  // The user may just be calling isAvailable(...) on the variable.
1088  return StatusCode::RECOVERABLE;
1089  }
1090  // We have a dynamic branch:
1091  staticBranch = false;
1092  brName = dynBrName;
1093  }
1094 
1095  // Check if it's a "primitive branch":
1096  const Bool_t primitiveBranch = isPrimitiveBranch(*br);
1097  // Check if it's a "container branch":
1098  const Bool_t containerBranch =
1099  (primitiveBranch ? false : isContainerBranch(*br, auxid));
1100 
1101  // Set the structure mode if it has not been defined externally:
1103  m_data.m_structMode = (containerBranch ? EStructMode::kContainerStore
1105  }
1106 
1107  // Check that the branch type makes sense:
1108  if ((containerBranch &&
1110  !r.isLinked(auxid)) ||
1111  ((!containerBranch) &&
1113  ::Error("xAOD::TAuxStore::setupInputData",
1114  XAOD_MESSAGE("Branch type and requested structure mode "
1115  "differ for branch: %s"),
1116  brName.Data());
1117  return StatusCode::FAILURE;
1118  }
1119 
1120  // Check what variable it is:
1121  ::TClass* clDummy = 0;
1122  ::EDataType dType = kOther_t;
1123  if (br->GetExpectedType(clDummy, dType)) {
1124  ::Error("xAOD::TAuxStore::setupInputData",
1125  XAOD_MESSAGE("Couldn't determine the type of branch \"%s\""),
1126  brName.Data());
1127  return StatusCode::FAILURE;
1128  }
1129 
1130  // Get the property type:
1131  const std::type_info* brType = 0;
1132  if (details::isRegisteredType(auxid)) {
1133  // Get the type from the auxiliary type registry:
1134  brType = (containerBranch ? r.getVecType(auxid) : r.getType(auxid));
1135  } else {
1136  // Get the type from the input branch itself:
1137  brType = (clDummy ? clDummy->GetTypeInfo() : &(Utils::getTypeInfo(dType)));
1138  }
1139  if (!brType) {
1140  ::Error("xAOD::TAuxStore::setupInputData",
1141  XAOD_MESSAGE("Can't read/copy variable %s (%s)"), brName.Data(),
1142  clDummy->GetName());
1143  return StatusCode::RECOVERABLE;
1144  }
1145  const TString brTypeName = Utils::getTypeName(*brType).c_str();
1146 
1147  // Check if we have the needed dictionary for an object branch:
1148  ::TClass* brClass = 0;
1149  if (!primitiveBranch) {
1150  // Get the property's class:
1151  brClass = ::TClass::GetClass(*brType, true, true);
1152  if (!brClass) {
1153  brClass = ::TClass::GetClass(brTypeName);
1154  }
1155  if (!brClass) {
1156  ::Error("xAOD::TAuxStore::setupInputData",
1157  XAOD_MESSAGE("No dictionary available for class \"%s\""),
1158  brTypeName.Data());
1159  return StatusCode::FAILURE;
1160  }
1161  }
1162 
1163  // Create the smart object holding this vector:
1164  if (details::isRegisteredType(auxid)) {
1165  m_data.m_vecs[auxid] = r.makeVector(auxid, (size_t)0, (size_t)0);
1166  if (!containerBranch) {
1167  m_data.m_vecs[auxid]->resize(1);
1168  }
1169  if (clDummy &&
1170  strncmp(clDummy->GetName(), "SG::PackedContainer<", 20) == 0) {
1171  std::unique_ptr<SG::IAuxTypeVector> packed =
1172  m_data.m_vecs[auxid]->toPacked();
1173  std::swap(m_data.m_vecs[auxid], packed);
1174  }
1175  } else {
1176  ::Error("xAOD::TAuxStore::setupInputData",
1177  XAOD_MESSAGE("Couldn't create in-memory vector for "
1178  "variable %s (%i)"),
1179  brName.Data(), static_cast<int>(auxid));
1180  return StatusCode::FAILURE;
1181  }
1182 
1183  // Create a new branch handle:
1184  const std::type_info* objType = brType;
1185  if (containerBranch) {
1186  objType = m_data.m_vecs[auxid]->objType();
1187  if (!objType)
1188  objType = r.getType(auxid);
1189  }
1190  m_impl->m_branches[auxid] = std::make_unique<TBranchHandle>(
1191  staticBranch, primitiveBranch, objType,
1192  (containerBranch ? m_data.m_vecs[auxid]->toVector()
1193  : m_data.m_vecs[auxid]->toPtr()),
1194  auxid, m_data.m_prefix);
1195 
1196  // Set the tree/branch in the "right mode":
1197  if (staticBranch) {
1198  br->SetMakeClass();
1199  }
1200 
1201  // Connect to the branch:
1202  ::Int_t status = 0;
1203  if (clDummy && ::TString(clDummy->GetName()).Contains("basic_string<char>")) {
1204  // This is pretty much just a hack. As it happens, Athena I/O can
1205  // create dynamic branches that consider themselves to be of type
1206  // "vector<basic_string<char> >" and similar. (Instead of the
1207  // canonical "vector<string>" name.) When we encounter such a branch,
1208  // we just connect to it without performing any compatibility checks.
1209  // Since we don't need to apply any read rules in this case anyway.
1210  status = m_impl->m_inTree->SetBranchAddress(
1211  brName, m_impl->m_branches[auxid]->inputObjectPtr(),
1212  m_impl->m_branches[auxid]->branchPtr());
1213  } else {
1214  status = m_impl->m_inTree->SetBranchAddress(
1215  brName, m_impl->m_branches[auxid]->inputObjectPtr(),
1216  m_impl->m_branches[auxid]->branchPtr(), brClass, dType,
1217  ((!staticBranch) && (!primitiveBranch)));
1218  }
1219  if (status < 0) {
1220  ::Error("xAOD::TAuxStore::setupInputData",
1221  XAOD_MESSAGE("Coulnd't connect to branch \"%s\""), brName.Data());
1222  ::Error("xAOD::TAuxStore::setupInputData", XAOD_MESSAGE("Return code: %i"),
1223  status);
1224  m_data.m_vecs[auxid].reset();
1225  m_impl->m_branches[auxid].reset();
1226  return StatusCode::FAILURE;
1227  }
1228 
1229  // Get the current entry:
1230  m_impl->m_branches[auxid]->getEntry();
1231 
1232  // Remember which variable got created:
1233  m_data.m_auxIDs.insert(auxid);
1234 
1235  // Check if we just replaced a generic object:
1236  if (details::isRegisteredType(auxid)) {
1237  // The name of the variable we just created:
1238  const std::string auxname = r.getName(auxid);
1239  // Check if there's another variable with this name already:
1240  for (SG::auxid_t i = 0; i < m_data.m_vecs.size(); ++i) {
1241  // Check if we have this aux ID:
1242  if (!m_data.m_vecs[i]) {
1243  continue;
1244  }
1245  // Ingore the object that we *just* created:
1246  if (i == auxid) {
1247  continue;
1248  }
1249  // The name of the variable:
1250  const std::string testname = r.getName(i);
1251  // Check if it has the same name:
1252  if (testname != auxname) {
1253  continue;
1254  }
1255  // Check that the other one is a non-registered type:
1257  ::Error("xAOD::TAuxStore::setupInputData",
1258  XAOD_MESSAGE("Internal logic error!"));
1259  continue;
1260  }
1261  // Okay, we do need to remove this object:
1262  m_data.m_vecs[i].reset();
1263  m_impl->m_branches[i].reset();
1265  }
1266  }
1267 
1268  SG::auxid_t linked_auxid = r.linkedVariable(auxid);
1269  if (linked_auxid != SG::null_auxid) {
1270  return setupInputData(linked_auxid);
1271  }
1272 
1273  // Return gracefully.
1274  return StatusCode::SUCCESS;
1275 }

◆ setupOutputData()

StatusCode xAOD::TAuxStore::setupOutputData ( SG::auxid_t  auxid)
overrideprivatevirtual

Connect a variable to the output.

Connect a variable to the output tree.

This function is used internally to create a "simple" output branch with the contents of a single auxiliary variable.

Parameters
auxidThe ID of the variable to create an output branch for
Returns
StatusCode::SUCCESS if the function was successful, something else otherwise

Implements xAOD::details::AuxStoreBase.

Definition at line 1286 of file TAuxStore.cxx.

1286  {
1287 
1288  assert(m_impl);
1289 
1290  // Check whether we need to do anything:
1291  if (!m_impl->m_outTree) {
1292  return StatusCode::SUCCESS;
1293  }
1294 
1295  // Check if the variable needs to be written out:
1296  if (!isAuxIDSelected(auxid)) {
1297  return StatusCode::SUCCESS;
1298  }
1299 
1300  // Make sure that containers are large enough:
1301  if (m_data.m_vecs.size() <= auxid) {
1302  m_data.m_vecs.resize(auxid + 1);
1303  }
1304  if (m_impl->m_branches.size() <= auxid) {
1305  m_impl->m_branches.resize(auxid + 1);
1306  }
1307  if (m_impl->m_branchesWritten.size() <= auxid) {
1308  m_impl->m_branchesWritten.resize(auxid + 1);
1309  }
1310 
1311  // Check if this auxiliary variable is already in the output:
1312  if (m_impl->m_branchesWritten[auxid]) {
1313  return StatusCode::SUCCESS;
1314  }
1315 
1316  // The registry:
1318 
1319  // Check if the variable was put into the transient store as a
1320  // decoration, and now needs to be put into the output file:
1321  if ((!m_data.m_vecs[auxid]) && m_data.m_transientStore &&
1322  (m_data.m_transientStore->getAuxIDs().test(auxid))) {
1323 
1324  // Get the variable from the transient store:
1325  const void* pptr = m_data.m_transientStore->getData(auxid);
1326  if (!pptr) {
1327  ::Fatal("xAOD::TAuxStore::setupOutputData",
1328  XAOD_MESSAGE("Internal logic error detected"));
1329  return StatusCode::FAILURE;
1330  }
1331 
1332  // Create the new object:
1333  m_data.m_vecs[auxid] = reg.makeVector(auxid, m_data.m_size, m_data.m_size);
1334  void* ptr = m_data.m_vecs[auxid]->toPtr();
1335  if (!ptr) {
1336  ::Error("xAOD::TAuxStore::setupOutputData",
1337  XAOD_MESSAGE("Couldn't create decoration in memory "
1338  "for writing"));
1339  return StatusCode::FAILURE;
1340  }
1341 
1342  // Get the type of this variable:
1343  const std::type_info* type = reg.getType(auxid);
1344  if (!type) {
1345  ::Error("xAOD::TAuxStore::setupOutputData",
1346  XAOD_MESSAGE("Couldn't get the type of transient "
1347  "variable %i"),
1348  static_cast<int>(auxid));
1349  return StatusCode::FAILURE;
1350  }
1351  // Now get the factory for this variable:
1352  const SG::IAuxTypeVectorFactory* factory = reg.getFactory(auxid);
1353  if (!factory) {
1354  ::Error("xAOD::TAuxStore::setupOutputData",
1355  XAOD_MESSAGE("No factory found for transient variable "
1356  "%i"),
1357  static_cast<int>(auxid));
1358  return StatusCode::FAILURE;
1359  }
1360 
1361  // Mark it as a decoration already, otherwise the copy may fail.
1362  if (m_data.m_isDecoration.size() <= auxid) {
1363  m_data.m_isDecoration.resize(auxid + 1);
1364  }
1365  m_data.m_isDecoration[auxid] = true;
1366 
1367  // Finally, do the copy:
1368  factory->copy(auxid, SG::AuxVectorInterface(*this), 0,
1370  m_data.m_size);
1371  }
1372 
1373  // Check if we know about this variable to be on the input,
1374  // but haven't connected to it yet:
1375  if ((m_data.m_auxIDs.test(auxid)) && (!m_data.m_vecs[auxid]) &&
1376  (!m_impl->m_branches[auxid])) {
1377  RETURN_CHECK("xAOD::TAuxStore::setupOutputData", setupInputData(auxid));
1378  }
1379 
1380  // Check that we know the store's type:
1383  ::Error("xAOD::TAuxStore::setupOutputData",
1384  XAOD_MESSAGE("Structure mode unknown for variable %s"),
1385  SG::AuxTypeRegistry::instance().getName(auxid).c_str());
1386  return StatusCode::FAILURE;
1387  }
1388 
1389  // Check if the variable exists already in memory:
1390  if (!m_data.m_vecs[auxid]) {
1391  m_data.m_vecs[auxid] =
1392  SG::AuxTypeRegistry::instance().makeVector(auxid, (size_t)0, (size_t)0);
1394  m_data.m_vecs[auxid]->resize(1);
1395  }
1396  }
1397 
1398  // Check if the branch handle exists already:
1399  if (!m_impl->m_branches[auxid]) {
1400  // Get the property type:
1401  const std::type_info* brType =
1405  // Create the handle object:
1406  bool primitiveBranch = (strlen(brType->name()) == 1);
1407  m_impl->m_branches[auxid] = std::make_unique<TBranchHandle>(
1408  false, (strlen(brType->name()) == 1),
1409  (primitiveBranch ? brType : m_data.m_vecs[auxid]->objType()),
1411  ? m_data.m_vecs[auxid]->toPtr()
1412  : m_data.m_vecs[auxid]->toVector()),
1413  auxid, m_data.m_prefix);
1414  }
1415 
1416  // Construct a name for the branch:
1417  const TString brName =
1418  std::format("{}{}", m_data.m_dynPrefix,
1420 
1421  // If the output branch exists already, assume that it was us making
1422  // it:
1423  ::TBranch* br = m_impl->m_outTree->GetBranch(brName);
1424  if (br) {
1425  // Apparently a branch that was already set up for copying as a basic
1426  // variable, now got accessed explicitly. So let's update the output
1427  // branch to point to this new location now.
1428  br->SetAddress(m_impl->m_branches[auxid]->outputObjectPtr());
1429  // Update the cache. Notice that the "write status" of the typeless
1430  // auxiliary ID is not turned off. But it shouldn't matter, as the
1431  // variable will not be accessed in a typeless way anymore.
1432  m_impl->m_branchesWritten[auxid] = true;
1433  // Return gracefully:
1434  return StatusCode::SUCCESS;
1435  }
1436 
1437  // Check that we know the type of the branch:
1438  const std::type_info* brType = m_impl->m_branches[auxid]->typeInfo();
1439  if (!brType) {
1440  ::Error("xAOD::TAuxStore::setupOutputData",
1441  XAOD_MESSAGE("There's an internal logic error in the "
1442  "code"));
1443  return StatusCode::FAILURE;
1444  }
1445  const std::string brTypeName = Utils::getTypeName(*brType);
1446 
1447  // Decide if this is a primitive branch:
1448  const Bool_t primitiveBranch = (strlen(brType->name()) == 1);
1449 
1450  // Let's create the branch now:
1451  if (primitiveBranch) {
1452 
1453  // Get the "ROOT type" belonging to this primitive:
1454  const char rootType = Utils::rootType(brType->name()[0]);
1455  if (rootType == '\0') {
1456  ::Error("xAOD::TAuxStore::setupOutputData",
1457  XAOD_MESSAGE("Type not known for variable \"%s\" "
1458  "of type \"%s\""),
1459  brName.Data(), brTypeName.c_str());
1460  return StatusCode::FAILURE;
1461  }
1462 
1463  // Construct the type description:
1464  std::ostringstream typeDesc;
1465  typeDesc << brName << "/" << rootType;
1466 
1467  // Create the branch:
1468  br = m_impl->m_outTree->Branch(
1469  brName, m_impl->m_branches[auxid]->outputObjectPtr(),
1470  typeDesc.str().c_str(), m_impl->m_basketSize);
1471 
1472  } else {
1473 
1474  // Access the dictionary for the type:
1475  TClass* cl = TClass::GetClass(*brType);
1476  if (!cl) {
1477  cl = TClass::GetClass(brTypeName.c_str());
1478  }
1479  if (!cl) {
1480  ::Error("xAOD::TAuxStore::setupOutputData",
1481  XAOD_MESSAGE("Couldn't find dictionary for type: %s"),
1482  brTypeName.c_str());
1483  return StatusCode::FAILURE;
1484  }
1485  if (!cl->GetStreamerInfo()) {
1486  ::Error("xAOD::TAuxStore::setupOutputData",
1487  XAOD_MESSAGE("No streamer info available for type %s"),
1488  cl->GetName());
1489  return StatusCode::FAILURE;
1490  }
1491 
1492  // Create the branch:
1493  br = m_impl->m_outTree->Branch(brName, cl->GetName(),
1494  m_impl->m_branches[auxid]->outputObjectPtr(),
1495  m_impl->m_basketSize, m_impl->m_splitLevel);
1496  }
1497 
1498  // Check if we succeeded:
1499  if (!br) {
1500  ::Error("xAOD::TAuxStore::setupOutputData",
1501  XAOD_MESSAGE("Failed creating branch \"%s\" of type "
1502  "\"%s\""),
1503  brName.Data(), brTypeName.c_str());
1504  return StatusCode::FAILURE;
1505  }
1506 
1507  // If this is not the first event, fill up the branch with dummy
1508  // info:
1509  for (Long64_t i = 0; i < m_impl->m_outTree->GetEntries(); ++i) {
1510  br->Fill();
1511  }
1512 
1513  // Update the cache:
1514  m_impl->m_branchesWritten[auxid] = true;
1515 
1516  // Also, remember that we now handle this variable:
1517  m_data.m_auxIDs.insert(auxid);
1518 
1519  // We were successful:
1520  return StatusCode::SUCCESS;
1521 }

◆ shift() [1/2]

virtual void SG::IAuxStore::shift ( size_t  pos,
ptrdiff_t  offs 
)
pure virtualinherited

Shift the elements of the container.

Parameters
posThe starting index for the shift.
offsThe (signed) amount of the shift.

This operation shifts the elements in the vectors for all aux data items, to implement an insertion or deletion. offs may be either positive or negative.

If offs is positive, then the container is growing. The container size should be increased by offs, the element at pos moved to pos + offs, and similarly for following elements. The elements between pos and pos + offs should be default-initialized.

If offs is negative, then the container is shrinking. The element at pos should be moved to pos + offs, and similarly for following elements. The container should then be shrunk by -offs elements (running destructors as appropriate).

Implemented in SG::AuxStoreInternal, xAOD::AuxContainerBase, xAOD::ShallowAuxContainer, xAOD::AuxInfoBase, and xAOD::ByteStreamAuxContainer_v1.

◆ shift() [2/2]

void xAOD::details::AuxStoreBase::shift ( std::size_t  pos,
std::ptrdiff_t  offs 
)
overridevirtualinherited

Shift the contents of the stored arrays.

Definition at line 432 of file AuxStoreBase.cxx.

432  {
433 
434  // Guard against multi-threaded execution:
435  guard_t guard(m_mutex1);
436 
437  // A sanity check:
439  ::Error("xAOD::AuxStoreBase::shift",
440  XAOD_MESSAGE("Should not have been called for single-object "
441  "store"));
442  return;
443  }
444 
445  // Adjust the size of the container:
446  if ((static_cast<std::size_t>(std::abs(offs)) > m_data.m_size) &&
447  (offs < 0)) {
448  m_data.m_size = 0;
449  } else {
450  m_data.m_size += offs;
451  }
452 
453  for (auto& v : m_data.m_vecs) {
454  if (v && !v->isLinked()) {
455  v->shift(pos, offs);
456  }
457  }
458 
459  if (m_data.m_transientStore) {
460  m_data.m_transientStore->shift(pos, offs);
461  }
462 }

◆ size()

std::size_t xAOD::details::AuxStoreBase::size ( ) const
overridevirtualinherited

Return the number of elements in the store.

Implements SG::IConstAuxStore.

Definition at line 248 of file AuxStoreBase.cxx.

248  {
249 
250  // First, try to find a managed vector in the store:
251  for (SG::auxid_t id : m_data.m_auxIDs) {
252  // Make sure that we are still within the bounds of our vector:
253  if (id >= m_data.m_vecs.size())
254  break;
255  // Skip non-existent or linked objects:
256  if (!m_data.m_vecs[id] || m_data.m_vecs[id]->isLinked()) {
257  continue;
258  }
259  // Ask the vector for its size:
260  const std::size_t size = m_data.m_vecs[id]->size();
261  // Only accept a non-zero size. Not sure why...
262  if (size > 0) {
263  return size;
264  }
265  }
266 
267  // Check if we have a transient store, and get the size from that:
268  if (m_data.m_transientStore) {
269  return m_data.m_transientStore->size();
270  }
271 
272  // Apparently the store is empty:
273  return 0;
274 }

◆ splitLevel()

int xAOD::TAuxStore::splitLevel ( ) const

Get the split level of the output branches.

Definition at line 847 of file TAuxStore.cxx.

847  {
848 
849  assert(m_impl);
850  return m_impl->m_splitLevel;
851 }

◆ structMode()

auto xAOD::details::AuxStoreBase::structMode ( ) const
inherited

Get what structure mode the object was constructed with.

Definition at line 29 of file AuxStoreBase.cxx.

29  {
30 
31  return m_data.m_structMode;
32 }

◆ writeTo()

StatusCode xAOD::TAuxStore::writeTo ( ::TTree &  tree)

Connect the object to an output TTree.

This function is called by the infrastructure to connect the object to an output TTree.

Parameters
treePointer to the TTree that is being written to

Definition at line 909 of file TAuxStore.cxx.

909  {
910 
911  assert(m_impl);
912 
913  // Look for any auxiliary branches that have not been connected to yet:
914  RETURN_CHECK("xAOD::TAuxStore::writeTo", m_impl->scanInputTree());
915 
916  // Store the TTree pointer:
917  m_impl->m_outTree = &tree;
918 
919  // Create all the variables that we already know about. Notice that the
920  // code makes a copy of the auxid set on purpose. Because the underlying
921  // AuxSelection object gets modified while doing the for loop.
922  const SG::auxid_set_t selAuxIDs = getSelectedAuxIDs();
923  for (SG::auxid_t id : selAuxIDs) {
924  RETURN_CHECK("xAOD::TAuxStore::writeTo", setupOutputData(id));
925  }
926 
927  // Return gracefully.
928  return StatusCode::SUCCESS;
929 }

Member Data Documentation

◆ m_data

Members xAOD::details::AuxStoreBase::m_data
protectedinherited

Member variables of the base class.

Definition at line 201 of file AuxStoreBase.h.

◆ m_impl

std::unique_ptr<impl> xAOD::TAuxStore::m_impl
private

Pointer to the internal object.

Definition at line 91 of file TAuxStore.h.

◆ m_locked

bool xAOD::details::AuxStoreBase::m_locked = false
privateinherited

Is this container locked?

Definition at line 212 of file AuxStoreBase.h.

◆ m_mutex1

mutex_t xAOD::details::AuxStoreBase::m_mutex1
mutableprivateinherited

Mutex objects used for multithreaded synchronisation.

Definition at line 214 of file AuxStoreBase.h.

◆ m_mutex2

mutex_t xAOD::details::AuxStoreBase::m_mutex2
privateinherited

Definition at line 214 of file AuxStoreBase.h.

◆ m_selection

AuxSelection xAOD::details::AuxStoreBase::m_selection
privateinherited

Object helping to select which auxiliary variables to write.

Definition at line 210 of file AuxStoreBase.h.

◆ supportsThinning

constexpr 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 199 of file IAuxStore.h.


The documentation for this class was generated from the following files:
SG::AuxTypeRegistry::getFactory
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
Definition: AuxTypeRegistry.cxx:1110
xAOD::details::AuxStoreBase::prefix
const std::string & prefix() const
Get the currently configured object name prefix.
Definition: AuxStoreBase.cxx:40
SG::IAuxTypeVector::shift
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
SG::IAuxTypeVector::isLinked
bool isLinked() const
Return true if this variable is linked from another one.
Definition: IAuxTypeVector.h:226
beamspotman.r
def r
Definition: beamspotman.py:672
xAOD::TAuxStore::setupOutputData
virtual StatusCode setupOutputData(SG::auxid_t auxid) override
Connect a variable to the output.
Definition: TAuxStore.cxx:1286
RETURN_CHECK
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition: ReturnCheck.h:26
checkxAOD.brName
brName
Definition: Tools/PyUtils/bin/checkxAOD.py:125
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::TAuxStore::setupInputData
virtual StatusCode setupInputData(SG::auxid_t auxid) override
Connect a variable to the input.
Definition: TAuxStore.cxx:1026
vtune_athena.format
format
Definition: vtune_athena.py:14
xAOD::details::AuxStoreBase::Members::m_vecs
std::vector< std::unique_ptr< SG::IAuxTypeVector > > m_vecs
Variables handled currently by the object (indexed by auxiliary ID)
Definition: AuxStoreBase.h:191
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
xAOD::details::AuxStoreBase::getAuxIDs
virtual const SG::auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition: AuxStoreBase.cxx:101
xAOD::details::AuxStoreBase::getInputType
virtual const std::type_info * getInputType(SG::auxid_t auxid) const =0
Get the type of an input object, for getIOType()
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:881
SG::ExcStoreLocked
Exception — Attempted to modify auxiliary data in a locked store.
Definition: Control/AthContainers/AthContainers/exceptions.h:183
tree
TChain * tree
Definition: tile_monitor.h:30
xAOD::details::AuxStoreBase::Members::m_auxIDs
SG::auxid_set_t m_auxIDs
Internal list of auxiliary variable IDs handled currently by the object.
Definition: AuxStoreBase.h:186
xAOD::details::AuxStoreBase::guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
Definition: AuxStoreBase.h:206
xAOD::details::AuxStoreBase::Members::m_transientStore
std::unique_ptr< SG::AuxStoreInternal > m_transientStore
Store for the in-memory-only variables.
Definition: AuxStoreBase.h:183
xAOD::other
@ other
Definition: TrackingPrimitives.h:510
athena.value
value
Definition: athena.py:124
xAOD::details::AuxStoreBase::Members::m_size
std::size_t m_size
The current size of the container being described.
Definition: AuxStoreBase.h:193
SG::IAuxTypeVector::insertMove
virtual bool insertMove(size_t pos, void *src, size_t src_pos, size_t src_n, IAuxStore &srcStore)=0
Insert elements into the vector via move semantics.
xAOD::details::AuxStoreBase::hasOutput
virtual bool hasOutput() const =0
Check if an output is being written by the object.
xAOD::details::isRegisteredType
bool isRegisteredType(SG::auxid_t auxid)
Check if the auxiliary variable has a registered type.
Definition: isRegisteredType.cxx:11
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
xAOD::details::AuxStoreBase::hasEntryFor
virtual bool hasEntryFor(SG::auxid_t auxid) const =0
Check if a given variable is available from the input.
xAOD::details::AuxStoreBase::EStructMode::kObjectStore
@ kObjectStore
The object describes a single object.
xAOD::TAuxStore::reset
virtual void reset() override
Tell the object that all branches will need to be re-read.
Definition: TAuxStore.cxx:977
xAOD::details::AuxStoreBase::EStructMode::kContainerStore
@ kContainerStore
The object describes an entire container.
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
CxxUtils::ConcurrentBitset::clear
ConcurrentBitset & clear()
Clear all bits in the set.
xAOD::details::AuxStoreBase::size
virtual std::size_t size() const override
Return the number of elements in the store.
Definition: AuxStoreBase.cxx:248
dumpTruth.getName
getName
Definition: dumpTruth.py:34
xAOD::Utils::dynBranchPrefix
std::string dynBranchPrefix(const std::string &key)
This function is used to figure out what to name dynamic auxiliary branches coming from a container c...
Definition: Control/xAODRootAccess/Root/Utils.cxx:144
xAOD::details::AuxStoreBase::Members::m_decorIDs
SG::auxid_set_t m_decorIDs
Internal list of auxiliary decoration IDs handled currently by the object.
Definition: AuxStoreBase.h:189
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxTypeRegistry::getType
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
Definition: AuxTypeRegistry.cxx:908
H5Utils::internal::packed
H5::CompType packed(H5::CompType in)
Definition: common.cxx:16
CxxUtils::ConcurrentBitset::size
bit_t size() const
Count the number of 1 bits in the set.
xAOD::details::AuxStoreBase::reset
virtual void reset()=0
Reset all (transient) information in the object.
xAOD::details::AuxStoreBase::m_data
Members m_data
Member variables of the base class.
Definition: AuxStoreBase.h:201
xAOD::Utils::getTypeName
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
Definition: Control/xAODRootAccess/Root/Utils.cxx:353
lumiFormat.i
int i
Definition: lumiFormat.py:85
CxxUtils::ConcurrentBitset::insert
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
xAOD::TAuxStore::setPrefix
virtual void setPrefix(std::string_view prefix) override
Set the object name prefix.
Definition: TAuxStore.cxx:828
SG::IAuxTypeVectorFactory
Interface for factory objects that create vectors.
Definition: IAuxTypeVectorFactory.h:50
xAOD::details::AuxStoreBase::m_mutex2
mutex_t m_mutex2
Definition: AuxStoreBase.h:214
xAOD::details::AuxStoreBase::Members::m_prefix
std::string m_prefix
Static prefix for the branch names.
Definition: AuxStoreBase.h:178
xAOD::details::AuxStoreBase::getData
virtual const void * getData(SG::auxid_t auxid) const override
Get a pointer to a given array.
Definition: AuxStoreBase.cxx:56
Preparation.mode
mode
Definition: Preparation.py:107
SG::IAuxTypeVectorFactory::copy
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.
SG::AuxTypeRegistry::getVecType
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
Definition: AuxTypeRegistry.cxx:936
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
xAOD::details::AuxStoreBase::setupOutputData
virtual StatusCode setupOutputData(SG::auxid_t auxid)=0
Connect a variable to the output.
xAOD::details::AuxStoreBase::getSelectedAuxIDs
virtual SG::auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected aux variables.
Definition: AuxStoreBase.cxx:627
xAOD::details::AuxStoreBase::getVector
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
Definition: AuxStoreBase.cxx:65
xAOD::details::AuxStoreBase::isAuxIDSelected
bool isAuxIDSelected(SG::auxid_t auxid) const
Check if an auxiliary variable is selected for ouput writing.
Definition: AuxStoreBase.cxx:643
xAOD::details::AuxStoreBase::AuxStoreBase
AuxStoreBase(bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore)
Constructor.
Definition: AuxStoreBase.cxx:24
SG::AuxTypeRegistry::makeVector
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.
Definition: AuxTypeRegistry.cxx:817
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
xAOD::details::AuxStoreBase::Members::m_structMode
EStructMode m_structMode
The "structural" mode of the object.
Definition: AuxStoreBase.h:174
CxxUtils::as_const_ptr
const T * as_const_ptr(const T *p)
Helper for getting a const version of a pointer.
Definition: as_const_ptr.h:32
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
xAOD::details::AuxStoreBase::getInputObject
virtual const void * getInputObject(SG::auxid_t auxid) const =0
Get a pointer to an input object, as it is in memory, for getIOData()
xAOD::Utils::getTypeInfo
const std::type_info & getTypeInfo(EDataType type)
This function is used when reading a primitive branch from an input file without the user explicitly ...
Definition: Control/xAODRootAccess/Root/Utils.cxx:194
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::AuxVectorInterface
Make an AuxVectorData object from either a raw array or an aux store.
Definition: AuxVectorInterface.h:33
xAOD::details::AuxStoreBase::m_locked
bool m_locked
Is this container locked?
Definition: AuxStoreBase.h:212
xAOD::TAuxStore::m_impl
std::unique_ptr< impl > m_impl
Pointer to the internal object.
Definition: TAuxStore.h:89
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
xAOD::details::AuxStoreBase::m_mutex1
mutex_t m_mutex1
Mutex objects used for multithreaded synchronisation.
Definition: AuxStoreBase.h:214
xAOD::details::AuxStoreBase::EStructMode::kUndefinedStore
@ kUndefinedStore
The structure mode is not defined.
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
merge.status
status
Definition: merge.py:16
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
xAOD::TAuxStore::splitLevel
int splitLevel() const
Get the split level of the output branches.
Definition: TAuxStore.cxx:847
xAOD::AuxSelection::selectAux
virtual void selectAux(const std::set< std::string > &attributes)
Select which variables should be written out.
Definition: AuxSelection.cxx:47
CxxUtils::ConcurrentBitset::erase
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
xAOD::details::AuxStoreBase::Members::m_isDecoration
std::vector< bool > m_isDecoration
Per variable lock status (indexed by auxiliary ID)
Definition: AuxStoreBase.h:196
xAOD::AuxSelection::getSelectedAuxIDs
virtual SG::auxid_set_t getSelectedAuxIDs(const SG::auxid_set_t &fullset) const
Return which variables were selected to be written out.
Definition: AuxSelection.cxx:62
xAOD::details::AuxStoreBase::Members::m_dynPrefix
std::string m_dynPrefix
Dynamic prefix for the branch names.
Definition: AuxStoreBase.h:180
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:25
xAOD::details::AuxStoreBase::Members::m_topStore
bool m_topStore
Flag stating whether this is a "top store".
Definition: AuxStoreBase.h:176
xAOD::Utils::rootType
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
Definition: Control/xAODRootAccess/Root/Utils.cxx:294
python.TransformConfig.attributes
def attributes(self)
Definition: TransformConfig.py:383
xAOD::details::AuxStoreBase::m_selection
AuxSelection m_selection
Object helping to select which auxiliary variables to write.
Definition: AuxStoreBase.h:210
SG::IAuxTypeVector::toPtr
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.
xAOD::TAuxStore::basketSize
int basketSize() const
Get the size of the baskets created for the output branches.
Definition: TAuxStore.cxx:835
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355
CxxUtils::ConcurrentBitset::test
bool test(bit_t bit) const
Test to see if a bit is set.