Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AuxStoreBase.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 #ifndef XAODROOTACCESS_TOOLS_AUXSTOREBASE_H
3 #define XAODROOTACCESS_TOOLS_AUXSTOREBASE_H
4 
5 // Framework include(s).
11 #include "xAODCore/AuxSelection.h"
12 
13 // System include(s).
14 #include <memory>
15 #include <string>
16 #include <string_view>
17 
18 namespace xAOD::details {
19 
26 class AuxStoreBase : public SG::IAuxStore, public SG::IAuxStoreIO {
27 
28  public:
30  enum class EStructMode {
31  kUndefinedStore = 0,
32  kContainerStore = 1,
33  kObjectStore = 2
34  };
35 
37  AuxStoreBase(bool topStore = true,
40  virtual ~AuxStoreBase();
41 
43  EStructMode structMode() const;
46 
48  const std::string& prefix() const;
50  virtual void setPrefix(std::string_view prefix) = 0;
51 
53  bool isTopStore() const;
55  void setTopStore(bool value = true);
56 
59 
61  virtual const void* getData(SG::auxid_t auxid) const override;
62 
64  virtual const SG::IAuxTypeVector* getVector(SG::auxid_t auxid) const override;
65 
67  virtual const SG::auxid_set_t& getAuxIDs() const override;
68 
70  virtual const SG::auxid_set_t& getDecorIDs() const override;
71 
73  virtual void* getDecoration(SG::auxid_t auxid, std::size_t size,
74  std::size_t capacity) override;
75 
77  virtual bool isDecoration(SG::auxid_t auxid) const override;
78 
80  virtual void lock() override;
83  virtual bool clearDecorations() override;
84 
86  virtual void lockDecoration(SG::auxid_t auxid) override;
87 
89  virtual std::size_t size() const override;
90 
92  virtual const SG::IAuxTypeVector* linkedVector(
93  SG::auxid_t auxid) const override;
95  virtual SG::IAuxTypeVector* linkedVector(SG::auxid_t auxid) override;
96 
98 
101 
103  virtual void* getData(SG::auxid_t auxid, std::size_t size,
104  std::size_t capacity) override;
105 
107  virtual const SG::auxid_set_t& getWritableAuxIDs() const override;
108 
110  virtual bool resize(std::size_t size) override;
112  virtual void reserve(std::size_t size) override;
114  virtual void shift(std::size_t pos, std::ptrdiff_t offs) override;
116  virtual bool insertMove(std::size_t pos, SG::IAuxStore& other,
117  const SG::auxid_set_t& ignore) override;
118 
120 
123 
125  virtual const void* getIOData(SG::auxid_t auxid) const override;
126 
128  virtual const std::type_info* getIOType(SG::auxid_t auxid) const override;
129 
131  virtual const SG::auxid_set_t& getDynamicAuxIDs() const override;
132 
134  virtual void selectAux(const std::set<std::string>& attributes);
135 
137  virtual SG::auxid_set_t getSelectedAuxIDs() const override;
138 
140 
141  protected:
143  bool isAuxIDSelected(SG::auxid_t auxid) const;
144 
147 
149  virtual void reset() = 0;
150 
152  virtual bool hasEntryFor(SG::auxid_t auxid) const = 0;
154  virtual StatusCode getEntryFor(SG::auxid_t auxid) = 0;
156  virtual bool hasOutput() const = 0;
157 
162 
164  virtual const void* getInputObject(SG::auxid_t auxid) const = 0;
166  virtual const std::type_info* getInputType(SG::auxid_t auxid) const = 0;
167 
169 
171  struct Members {
172 
176  bool m_topStore = true;
178  std::string m_prefix{};
180  std::string m_dynPrefix{};
181 
183  std::unique_ptr<SG::AuxStoreInternal> m_transientStore{};
184 
191  std::vector<std::unique_ptr<SG::IAuxTypeVector> > m_vecs{};
193  std::size_t m_size = 0u;
194 
196  std::vector<bool> m_isDecoration{};
197 
198  }; // struct BaseMembers
199 
202 
206  using guard_t = AthContainers_detail::lock_guard<mutex_t>;
207 
208  private:
212  bool m_locked = false;
215 
216 }; // class AuxStoreBase
217 
218 } // namespace xAOD::details
219 
220 #endif // XAODROOTACCESS_TOOLS_AUXSTOREBASE_H
xAOD::details
Definition: AuxStoreBase.cxx:20
xAOD::details::AuxStoreBase::prefix
const std::string & prefix() const
Get the currently configured object name prefix.
Definition: AuxStoreBase.cxx:38
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
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:99
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()
xAOD::details::AuxStoreBase::getEntryFor
virtual StatusCode getEntryFor(SG::auxid_t auxid)=0
Load a single variable from the input.
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
xAOD::details::AuxStoreBase::selectAux
virtual void selectAux(const std::set< std::string > &attributes)
Select dynamic auxiliary attributes for writing.
Definition: AuxStoreBase.cxx:616
xAOD::details::AuxStoreBase::setTopStore
void setTopStore(bool value=true)
Set whether the object should behave as a "top store" or not.
Definition: AuxStoreBase.cxx:48
xAOD::details::AuxStoreBase::clearDecorations
virtual bool clearDecorations() override
Remove the decorations added so far.
Definition: AuxStoreBase.cxx:207
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::EStructMode
EStructMode
"Structural" modes of the object
Definition: AuxStoreBase.h:30
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::linkedVector
virtual const SG::IAuxTypeVector * linkedVector(SG::auxid_t auxid) const override
Return (const) interface for a linked variable.
Definition: AuxStoreBase.cxx:272
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
xAOD::details::AuxStoreBase::hasOutput
virtual bool hasOutput() const =0
Check if an output is being written by the object.
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::details::AuxStoreBase::structMode
EStructMode structMode() const
Get what structure mode the object was constructed with.
Definition: AuxStoreBase.cxx:27
xAOD::details::AuxStoreBase::EStructMode::kContainerStore
@ kContainerStore
The object describes an entire container.
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
xAOD::details::AuxStoreBase::size
virtual std::size_t size() const override
Return the number of elements in the store.
Definition: AuxStoreBase.cxx:244
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
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
xAOD::details::AuxStoreBase::getDynamicAuxIDs
virtual const SG::auxid_set_t & getDynamicAuxIDs() const override
Get the types(names) of variables created dynamically.
Definition: AuxStoreBase.cxx:608
xAOD::details::AuxStoreBase::getWritableAuxIDs
virtual const SG::auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
Definition: AuxStoreBase.cxx:366
xAOD::details::AuxStoreBase
Common base class for the auxiliary store implementations.
Definition: AuxStoreBase.h:26
xAOD::details::AuxStoreBase::setupInputData
virtual StatusCode setupInputData(SG::auxid_t auxid)=0
Connect a variable to the input.
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
xAOD::details::AuxStoreBase::~AuxStoreBase
virtual ~AuxStoreBase()
Destructor.
xAOD::details::AuxStoreBase::getDecorIDs
virtual const SG::auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
Definition: AuxStoreBase.cxx:104
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
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::details::AuxStoreBase::setStructMode
void setStructMode(EStructMode mode)
Set the structure mode of the object to a new value.
Definition: AuxStoreBase.cxx:32
xAOD::details::AuxStoreBase::mutex_t
AthContainers_detail::mutex mutex_t
Mutex type for multithread synchronization.
Definition: AuxStoreBase.h:204
xAOD::details::AuxStoreBase::getIOType
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.
Definition: AuxStoreBase.cxx:569
IAuxStoreIO.h
Interface providing I/O for a generic auxiliary store.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::details::AuxStoreBase::setPrefix
virtual void setPrefix(std::string_view prefix)=0
Set the object name prefix.
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:54
xAOD::details::AuxStoreBase::lock
virtual void lock() override
Lock the object, and don't let decorations be added.
Definition: AuxStoreBase.cxx:196
Preparation.mode
mode
Definition: Preparation.py:107
xAOD::details::AuxStoreBase::resize
virtual bool resize(std::size_t size) override
Resize the arrays to a given size.
Definition: AuxStoreBase.cxx:371
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:623
StatusCode.h
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:63
xAOD::details::AuxStoreBase::isAuxIDSelected
bool isAuxIDSelected(SG::auxid_t auxid) const
Check if an auxiliary variable is selected for ouput writing.
Definition: AuxStoreBase.cxx:639
xAOD::AuxSelection
Class helping in dealing with dynamic branch selection.
Definition: AuxSelection.h:31
xAOD::details::AuxStoreBase::AuxStoreBase
AuxStoreBase(bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore)
Constructor.
Definition: AuxStoreBase.cxx:22
xAOD::details::AuxStoreBase::Members::m_structMode
EStructMode m_structMode
The "structural" mode of the object.
Definition: AuxStoreBase.h:174
threading.h
Threading definitions.
xAOD::details::AuxStoreBase::insertMove
virtual bool insertMove(std::size_t pos, SG::IAuxStore &other, const SG::auxid_set_t &ignore) override
Insert contents of another store via move.
Definition: AuxStoreBase.cxx:460
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
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::details::AuxStoreBase::shift
virtual void shift(std::size_t pos, std::ptrdiff_t offs) override
Shift the contents of the stored arrays.
Definition: AuxStoreBase.cxx:428
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
xAOD::details::AuxStoreBase::m_locked
bool m_locked
Is this container locked?
Definition: AuxStoreBase.h:212
AuxSelection.h
xAOD::details::AuxStoreBase::reserve
virtual void reserve(std::size_t size) override
Reserve a given size for the arrays.
Definition: AuxStoreBase.cxx:404
xAOD::details::AuxStoreBase::isTopStore
bool isTopStore() const
Check if the object is a "top store", or not.
Definition: AuxStoreBase.cxx:43
xAOD::details::AuxStoreBase::getDecoration
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.
Definition: AuxStoreBase.cxx:109
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
xAOD::details::AuxStoreBase::lockDecoration
virtual void lockDecoration(SG::auxid_t auxid) override
Lock a decoration.
Definition: AuxStoreBase.cxx:237
IAuxStore.h
Interface for non-const operations on an auxiliary store.
xAOD::details::AuxStoreBase::getIOData
virtual const void * getIOData(SG::auxid_t auxid) const override
Get a pointer to the data being stored for one aux data item.
Definition: AuxStoreBase.cxx:510
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.
collListGuids.attributes
attributes
Definition: collListGuids.py:46
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
xAOD::details::AuxStoreBase::Members::m_isDecoration
std::vector< bool > m_isDecoration
Per variable lock status (indexed by auxiliary ID)
Definition: AuxStoreBase.h:196
AuxStoreInternal.h
An auxiliary data store that holds data internally.
xAOD::details::AuxStoreBase::Members::m_dynPrefix
std::string m_dynPrefix
Dynamic prefix for the branch names.
Definition: AuxStoreBase.h:180
xAOD::details::AuxStoreBase::isDecoration
virtual bool isDecoration(SG::auxid_t auxid) const override
Test if a variable is a decoration.
Definition: AuxStoreBase.cxx:184
xAOD::details::AuxStoreBase::Members::m_topStore
bool m_topStore
Flag stating whether this is a "top store".
Definition: AuxStoreBase.h:176
xAOD::details::AuxStoreBase::m_selection
AuxSelection m_selection
Object helping to select which auxiliary variables to write.
Definition: AuxStoreBase.h:210
xAOD::details::AuxStoreBase::Members
Struct collecting all member variables of this base class.
Definition: AuxStoreBase.h:171