ATLAS Offline Software
TAuxStore.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef XAODROOTACCESS_TAUXSTORE_H
6 #define XAODROOTACCESS_TAUXSTORE_H
7 
8 // STL include(s):
9 #include <vector>
10 #include <string>
11 
12 // EDM include(s):
16 #include "xAODCore/AuxSelection.h"
17 
18 // Local include(s):
20 
21 #include "Rtypes.h"
22 
23 // Forward declaration(s):
24 class TTree;
25 class TBranch;
26 namespace SG {
27  class IAuxTypeVector;
28  class AuxStoreInternal;
29 }
30 
31 namespace xAOD {
32 
33  // Forward declaration(s):
34  class TEvent;
35 
45  class TAuxStore : public SG::IAuxStore,
46  public SG::IAuxStoreIO {
47 
49  friend class TEvent;
50 
51  public:
53  enum EStructMode {
56  kObjectStore = 2
57  };
62 
64  TAuxStore( const char* prefix = "", Bool_t topStore = kTRUE,
66  Int_t basketSize = 2048, Int_t splitLevel = 0 );
68  ~TAuxStore();
69 
71  EStructMode structMode() const;
74 
76  const char* prefix() const;
78  void setPrefix( const char* prefix );
79 
81  Bool_t isTopStore() const;
83  void setTopStore( Bool_t value = kTRUE );
84 
86  Int_t basketSize() const;
88  void setBasketSize( Int_t value );
89 
91  Int_t splitLevel() const;
93  void setSplitLevel( Int_t value );
94 
96  StatusCode readFrom( ::TTree* tree, ::Bool_t printWarnings = kTRUE );
98  StatusCode writeTo( ::TTree* tree );
99 
101  Int_t getEntry( Int_t getall = 0 );
102 
104  void reset();
105 
108 
110  virtual const void* getData( auxid_t auxid ) const override;
111 
113  virtual const SG::IAuxTypeVector* getVector (SG::auxid_t auxid) const override;
114 
116  virtual const auxid_set_t& getAuxIDs() const override;
117 
119  virtual const auxid_set_t& getDecorIDs() const override;
120 
122  virtual void* getDecoration( auxid_t auxid, size_t size,
123  size_t capacity ) override;
124 
126  virtual bool isDecoration (auxid_t auxid) const override;
127 
129  virtual void lock() override;
132  virtual bool clearDecorations() override;
133 
135  virtual void lockDecoration (SG::auxid_t auxid) override;
136 
138  virtual size_t size() const override;
139 
141  virtual const SG::IAuxTypeVector* linkedVector( SG::auxid_t auxid ) const override;
142  virtual SG::IAuxTypeVector* linkedVector( SG::auxid_t auxid ) override;
144 
147 
149  virtual void* getData( auxid_t auxid, size_t size,
150  size_t capacity ) override;
151 
153  virtual const auxid_set_t& getWritableAuxIDs() const override;
154 
156  virtual bool resize( size_t size ) override;
158  virtual void reserve( size_t size ) override;
160  virtual void shift( size_t pos, ptrdiff_t offs ) override;
162  virtual bool insertMove (size_t pos,
163  IAuxStore& other,
164  const SG::auxid_set_t& ignore) override;
165 
167 
170 
172  virtual const void* getIOData( auxid_t auxid ) const override;
173 
175  virtual const std::type_info* getIOType( auxid_t auxid ) const override;
176 
178  virtual const auxid_set_t& getDynamicAuxIDs() const override;
179 
181  virtual void
182  selectAux( const std::set< std::string >& attributes );
183 
185  virtual auxid_set_t getSelectedAuxIDs() const override;
186 
188 
189  private:
192  StatusCode initStats( ::TTree* tree );
200  const std::type_info* auxBranchType( ::TBranch* br, const char* auxName,
201  ::Bool_t staticBranch,
202  std::string* expectedClassName = nullptr );
204  StatusCode setupAuxBranch( ::TBranch* br, const char* auxName,
205  ::Bool_t staticBranch );
207  ::Bool_t isAuxIDSelected( auxid_t auxid ) const;
209  static ::Bool_t isPrimitiveBranch( TBranch* br );
211  static ::Bool_t isContainerBranch( TBranch* br, auxid_t auxid );
213  static ::Bool_t isRegisteredType( auxid_t auxid );
215  std::string m_prefix;
217  std::string m_dynPrefix;
218 
220  ::Bool_t m_topStore;
221 
225  ::Int_t m_basketSize;
227  ::Int_t m_splitLevel;
228 
230  ::TTree* m_inTree;
232  ::TTree* m_outTree;
233 
235  ::Bool_t m_inputScanned;
236 
241 
246  std::vector< SG::IAuxTypeVector* > m_vecs;
248  std::size_t m_size;
249 
251  ::Bool_t m_locked;
253  std::vector< ::Bool_t > m_isDecoration;
254 
258  typedef AthContainers_detail::lock_guard< mutex_t > guard_t;
261 
268 
269  public:
271  TBranchHandle( ::Bool_t staticBranch, ::Bool_t primitiveBranch,
272  const std::type_info* ti, void* obj,
273  SG::auxid_t auxid, const std::string* prefix );
274 
276  ::Int_t getEntry();
278  ::TBranch** branchPtr();
280  void* objectPtr();
282  void* inputObjectPtr();
284  void* outputObjectPtr();
286  const std::type_info* typeInfo() const;
288  void reset();
289 
290  private:
292  ::TBranch* m_branch;
294  ::Long64_t m_entry;
296  void* m_object;
298  ::Bool_t m_static;
300  ::Bool_t m_primitive;
302  const std::type_info* m_typeInfo;
304  ::Bool_t m_needsRead;
308  const std::string* m_prefix;
309 
310  }; // class TBranchHandle
311 
313  std::vector< TBranchHandle* > m_branches;
315  std::vector< bool > m_branchesWritten;
318  std::vector< bool > m_missingBranches;
319 
320  }; // class TAuxStore
321 
322 } // namespace xAOD
323 
324 #endif // XAODROOTACCESS_TAUXSTORE_H
xAOD::TAuxStore::setTopStore
void setTopStore(Bool_t value=kTRUE)
Set whether the object should behave as a "top store" or not.
Definition: TAuxStore.cxx:133
xAOD::TAuxStore::m_missingBranches
std::vector< bool > m_missingBranches
Mark branches we've found to be missing.
Definition: TAuxStore.h:318
xAOD::TAuxStore::getSelectedAuxIDs
virtual auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected aux variables.
Definition: TAuxStore.cxx:854
xAOD::TAuxStore::TBranchHandle::typeInfo
const std::type_info * typeInfo() const
Get the type of the variable in memory.
Definition: TAuxStore.cxx:2118
xAOD::TAuxStore::getAuxIDs
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition: TAuxStore.cxx:333
xAOD::TAuxStore::TBranchHandle::reset
void reset()
Tell the object that the branch contents need to be re-read.
Definition: TAuxStore.cxx:2134
xAOD::TAuxStore::isDecoration
virtual bool isDecoration(auxid_t auxid) const override
Test if a variable is a decoration.
Definition: TAuxStore.cxx:420
xAOD::TAuxStore::TBranchHandle::m_entry
::Long64_t m_entry
The last entry that was loaded for this branch.
Definition: TAuxStore.h:294
xAOD::TAuxStore::basketSize
Int_t basketSize() const
Get the size of the baskets created for the output branches.
Definition: TAuxStore.cxx:140
xAOD::TAuxStore::TBranchHandle::m_prefix
const std::string * m_prefix
Pointer to the m_prefix string of the parent object.
Definition: TAuxStore.h:308
xAOD::TAuxStore::readFrom
StatusCode readFrom(::TTree *tree, ::Bool_t printWarnings=kTRUE)
Connect the object to an input TTree.
Definition: TAuxStore.cxx:167
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
xAOD::TAuxStore::m_isDecoration
std::vector< ::Bool_t > m_isDecoration
Flags items as decorations.
Definition: TAuxStore.h:253
xAOD::TAuxStore::m_prefix
std::string m_prefix
Static prefix for the branch names.
Definition: TAuxStore.h:215
xAOD::TAuxStore::auxid_set_t
SG::auxid_set_t auxid_set_t
Convenience type declaration.
Definition: TAuxStore.h:61
xAOD::TAuxStore::TBranchHandle::m_primitive
::Bool_t m_primitive
Is this a primitive variable?
Definition: TAuxStore.h:300
tree
TChain * tree
Definition: tile_monitor.h:30
xAOD::TAuxStore::isTopStore
Bool_t isTopStore() const
Check if the object is a "top store", or not.
Definition: TAuxStore.cxx:128
xAOD::TAuxStore::m_splitLevel
::Int_t m_splitLevel
The split level for the output branches.
Definition: TAuxStore.h:227
xAOD::TAuxStore::TBranchHandle::m_branch
::TBranch * m_branch
The branch that this object is handling.
Definition: TAuxStore.h:292
xAOD::TAuxStore::m_auxIDs
auxid_set_t m_auxIDs
Internal list of variable IDs handled currently by the object.
Definition: TAuxStore.h:243
xAOD::TAuxStore::setBasketSize
void setBasketSize(Int_t value)
Set the size of the baskets created for the output branches.
Definition: TAuxStore.cxx:145
xAOD::TAuxStore::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition: TAuxStore.cxx:611
xAOD::other
@ other
Definition: TrackingPrimitives.h:509
xAOD::TAuxStore::setStructMode
StatusCode setStructMode(EStructMode mode)
Set the structure mode of the object to a new value.
Definition: TAuxStore.cxx:100
xAOD::TAuxStore
"ROOT implementation" of IAuxStore
Definition: TAuxStore.h:46
athena.value
value
Definition: athena.py:124
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::TAuxStore::EStructMode
EStructMode
"Structural" modes of the object
Definition: TAuxStore.h:53
xAOD::TAuxStore::m_basketSize
::Int_t m_basketSize
The basket size for the output branches.
Definition: TAuxStore.h:225
xAOD::TAuxStore::m_locked
::Bool_t m_locked
Is this container locked?
Definition: TAuxStore.h:251
xAOD::TAuxStore::scanInputTree
StatusCode scanInputTree()
Scan the input TTree for auxiliary branches.
Definition: TAuxStore.cxx:1405
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
xAOD::TAuxStore::getVector
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
Definition: TAuxStore.cxx:298
xAOD::TAuxStore::m_inTree
::TTree * m_inTree
The TTree being read from.
Definition: TAuxStore.h:230
xAOD::TAuxStore::m_dynPrefix
std::string m_dynPrefix
Dynamic prefix for the branch names.
Definition: TAuxStore.h:217
xAOD::TAuxStore::insertMove
virtual bool insertMove(size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
Insert contents of another store via move.
Definition: TAuxStore.cxx:702
xAOD::TAuxStore::guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
Definition: TAuxStore.h:258
xAOD::TAuxStore::reset
void reset()
Tell the object that all branches will need to be re-read.
Definition: TAuxStore.cxx:274
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
xAOD::TAuxStore::auxBranchType
const std::type_info * auxBranchType(::TBranch *br, const char *auxName, ::Bool_t staticBranch, std::string *expectedClassName=nullptr)
Find the type_info to use as the aux type for a given branch.
Definition: TAuxStore.cxx:1512
xAOD::TAuxStore::lock
virtual void lock() override
Lock the object, and don't let decorations be added.
Definition: TAuxStore.cxx:434
xAOD::TAuxStore::m_outTree
::TTree * m_outTree
The TTree being written to.
Definition: TAuxStore.h:232
xAOD::TAuxStore::getWritableAuxIDs
virtual const auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
Definition: TAuxStore.cxx:606
xAOD::TAuxStore::isRegisteredType
::Bool_t isRegisteredType(auxid_t auxid)
Check if the auxiliary variable has a registered type.
Definition: TAuxStore.cxx:1949
xAOD::TAuxStore::getDecorIDs
virtual const auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
Definition: TAuxStore.cxx:338
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::TAuxStore::getIOType
virtual const std::type_info * getIOType(auxid_t auxid) const override
Return the type of the data to be stored for one aux data item.
Definition: TAuxStore.cxx:801
xAOD::TAuxStore::kObjectStore
@ kObjectStore
The object describes a single object.
Definition: TAuxStore.h:56
xAOD::TAuxStore::writeTo
StatusCode writeTo(::TTree *tree)
Connect the object to an output TTree.
Definition: TAuxStore.cxx:209
xAOD::TAuxStore::isAuxIDSelected
::Bool_t isAuxIDSelected(auxid_t auxid) const
Check if this auxiliary variable needs to go to the output.
Definition: TAuxStore.cxx:1766
xAOD::TAuxStore::reserve
virtual void reserve(size_t size) override
Reserve a given size for the arrays.
Definition: TAuxStore.cxx:642
xAOD::TAuxStore::isContainerBranch
::Bool_t isContainerBranch(TBranch *br, auxid_t auxid)
Check if a branch describes a container or a single object.
Definition: TAuxStore.cxx:1817
xAOD::TAuxStore::m_mutex1
mutex_t m_mutex1
Mutexes object used for multithreaded synchronisation.
Definition: TAuxStore.h:260
xAOD::TAuxStore::m_mutex2
mutex_t m_mutex2
Definition: TAuxStore.h:260
xAOD::TAuxStore::splitLevel
Int_t splitLevel() const
Get the split level of the output branches.
Definition: TAuxStore.cxx:151
xAOD::TAuxStore::shift
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the contents of the stored arrays.
Definition: TAuxStore.cxx:668
Preparation.mode
mode
Definition: Preparation.py:94
xAOD::TAuxStore::m_decorIDs
auxid_set_t m_decorIDs
Definition: TAuxStore.h:244
xAOD::TAuxStore::m_transientStore
SG::AuxStoreInternal * m_transientStore
Store for the in-memory-only variables.
Definition: TAuxStore.h:240
xAOD::TAuxStore::TBranchHandle::m_object
void * m_object
The pointer to the object in memory.
Definition: TAuxStore.h:296
xAOD::TAuxStore::mutex_t
AthContainers_detail::mutex mutex_t
Mutex type for multithread synchronization.
Definition: TAuxStore.h:256
xAOD::TAuxStore::getData
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.
Definition: TAuxStore.cxx:289
xAOD::TAuxStore::getEntry
Int_t getEntry(Int_t getall=0)
Read the values from the TTree entry that was loaded with TTree::LoadTree()
Definition: TAuxStore.cxx:228
xAOD::TAuxStore::initStats
StatusCode initStats(::TTree *tree)
Function used for setting up the statistics info about the managed branches.
Definition: TAuxStore.cxx:871
StatusCode.h
xAOD::TAuxStore::kContainerStore
@ kContainerStore
The object describes an entire container.
Definition: TAuxStore.h:55
xAOD::TAuxStore::m_structMode
EStructMode m_structMode
The "structural" mode of the object.
Definition: TAuxStore.h:223
xAOD::TAuxStore::getDecoration
virtual void * getDecoration(auxid_t auxid, size_t size, size_t capacity) override
Get a pointer to a given array, creating the array if necessary.
Definition: TAuxStore.cxx:343
xAOD::TAuxStore::m_vecs
std::vector< SG::IAuxTypeVector * > m_vecs
Variables handled currently by the object.
Definition: TAuxStore.h:246
xAOD::AuxSelection
Class helping in dealing with dynamic branch selection.
Definition: AuxSelection.h:31
xAOD::TAuxStore::getDynamicAuxIDs
virtual const auxid_set_t & getDynamicAuxIDs() const override
Get the types(names) of variables created dynamically.
Definition: TAuxStore.cxx:838
xAOD::TAuxStore::m_inputScanned
::Bool_t m_inputScanned
"Scan status" of the input TTree
Definition: TAuxStore.h:235
xAOD::TAuxStore::TBranchHandle::inputObjectPtr
void * inputObjectPtr()
Get a pointer to the object (or its pointer) in memory for reading.
Definition: TAuxStore.cxx:2089
xAOD::TAuxStore::TBranchHandle::m_auxid
SG::auxid_t m_auxid
The auxiliary ID of the branch.
Definition: TAuxStore.h:306
xAOD::TAuxStore::TBranchHandle::m_needsRead
::Bool_t m_needsRead
Read status flag.
Definition: TAuxStore.h:304
threading.h
Threading definitions.
xAOD::TAuxStore::TBranchHandle::m_typeInfo
const std::type_info * m_typeInfo
Type info for the variable.
Definition: TAuxStore.h:302
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::TAuxStore::setSplitLevel
void setSplitLevel(Int_t value)
Set the split level of the output branches.
Definition: TAuxStore.cxx:156
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::AuxStoreInternal
An auxiliary data store that holds data internally.
Definition: AuxStoreInternal.h:43
xAOD::TAuxStore::lockDecoration
virtual void lockDecoration(SG::auxid_t auxid) override
Lock a decoration.
Definition: TAuxStore.cxx:477
AuxSelection.h
xAOD::TAuxStore::m_topStore
::Bool_t m_topStore
Flag stating whether this is a "top store".
Definition: TAuxStore.h:220
xAOD::TAuxStore::kUndefinedStore
@ kUndefinedStore
The structure mode is not defined.
Definition: TAuxStore.h:54
xAOD::TAuxStore::selectAux
virtual void selectAux(const std::set< std::string > &attributes)
Select dynamic auxiliary attributes for writing.
Definition: TAuxStore.cxx:845
xAOD::TAuxStore::auxid_t
SG::auxid_t auxid_t
Convenience type declaration.
Definition: TAuxStore.h:59
xAOD::TAuxStore::TBranchHandle::objectPtr
void * objectPtr()
Get a pointer to the object.
Definition: TAuxStore.cxx:2069
xAOD::TAuxStore::TBranchHandle::getEntry
::Int_t getEntry()
Get entry from the branch that was loaded with TTree::LoadTree()
Definition: TAuxStore.cxx:1978
xAOD::TAuxStore::TBranchHandle::branchPtr
::TBranch ** branchPtr()
Get a pointer to the branch being held.
Definition: TAuxStore.cxx:2059
xAOD::TAuxStore::size
virtual size_t size() const override
Return the number of elements in the store.
Definition: TAuxStore.cxx:486
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
xAOD::TAuxStore::m_size
std::size_t m_size
The current size of the container being described.
Definition: TAuxStore.h:248
xAOD::TAuxStore::TAuxStore
TAuxStore(const char *prefix="", Bool_t topStore=kTRUE, EStructMode mode=kUndefinedStore, Int_t basketSize=2048, Int_t splitLevel=0)
Default constructor.
Definition: TAuxStore.cxx:57
xAOD::TAuxStore::getIOData
virtual const void * getIOData(auxid_t auxid) const override
Get a pointer to the data being stored for one aux data item.
Definition: TAuxStore.cxx:754
xAOD::TAuxStore::structMode
EStructMode structMode() const
Get what structure mode the object was constructed with.
Definition: TAuxStore.cxx:88
IAuxStore.h
Interface for non-const operations on an auxiliary store.
xAOD::TAuxStore::m_branches
std::vector< TBranchHandle * > m_branches
Branches reading the various auxiliary variables.
Definition: TAuxStore.h:313
xAOD::TAuxStore::setupAuxBranch
StatusCode setupAuxBranch(::TBranch *br, const char *auxName, ::Bool_t staticBranch)
Register one input branch as an available auxiliary variable.
Definition: TAuxStore.cxx:1609
collListGuids.attributes
attributes
Definition: collListGuids.py:46
xAOD::TAuxStore::TBranchHandle::TBranchHandle
TBranchHandle(::Bool_t staticBranch, ::Bool_t primitiveBranch, const std::type_info *ti, void *obj, SG::auxid_t auxid, const std::string *prefix)
Constructor.
Definition: TAuxStore.cxx:1962
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
xAOD::TAuxStore::~TAuxStore
~TAuxStore()
Destructor.
Definition: TAuxStore.cxx:71
xAOD::TAuxStore::TBranchHandle::outputObjectPtr
void * outputObjectPtr()
Get a pointer to the object (or its pointer) in memory for writing.
Definition: TAuxStore.cxx:2108
xAOD::TAuxStore::setupOutputData
StatusCode setupOutputData(auxid_t auxid)
Connect a variable to the output tree.
Definition: TAuxStore.cxx:1158
xAOD::TAuxStore::clearDecorations
virtual bool clearDecorations() override
Remove the decorations added so far.
Definition: TAuxStore.cxx:447
xAOD::TAuxStore::TBranchHandle::m_static
::Bool_t m_static
Is this a static variable in question?
Definition: TAuxStore.h:298
xAOD::TAuxStore::isPrimitiveBranch
::Bool_t isPrimitiveBranch(TBranch *br)
Check if a branch holds a primitive variable or not.
Definition: TAuxStore.cxx:1783
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::TAuxStore::setupInputData
StatusCode setupInputData(auxid_t auxid)
Connect a variable to the input tree.
Definition: TAuxStore.cxx:901
xAOD::TAuxStore::linkedVector
virtual const SG::IAuxTypeVector * linkedVector(SG::auxid_t auxid) const override
Return interface for a linked variable.
Definition: TAuxStore.cxx:511
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
xAOD::TAuxStore::TBranchHandle
Class used internally to implement just-in-time reading.
Definition: TAuxStore.h:267
xAOD::TAuxStore::setPrefix
void setPrefix(const char *prefix)
Set the branch name prefix.
Definition: TAuxStore.cxx:120
xAOD::TAuxStore::m_branchesWritten
std::vector< bool > m_branchesWritten
"Write status" of the different variables
Definition: TAuxStore.h:315
xAOD::TAuxStore::prefix
const char * prefix() const
Get the currently configured branch name prefix.
Definition: TAuxStore.cxx:115
xAOD::TAuxStore::m_selection
AuxSelection m_selection
Object helping to select which auxiliary variables to write.
Definition: TAuxStore.h:238
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355