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 auxid_set_t& getAuxIDs() const override;
114 
116  virtual void* getDecoration( auxid_t auxid, size_t size,
117  size_t capacity ) override;
118 
120  virtual bool isDecoration (auxid_t auxid) const override;
121 
123  virtual void lock() override;
126  virtual bool clearDecorations() override;
127 
129  virtual void lockDecoration (SG::auxid_t auxid) override;
130 
132  virtual size_t size() const override;
133 
135  virtual const SG::IAuxTypeVector* linkedVector( SG::auxid_t auxid ) const override;
136  virtual SG::IAuxTypeVector* linkedVector( SG::auxid_t auxid ) override;
138 
141 
143  virtual void* getData( auxid_t auxid, size_t size,
144  size_t capacity ) override;
145 
147  virtual const auxid_set_t& getWritableAuxIDs() const override;
148 
150  virtual bool resize( size_t size ) override;
152  virtual void reserve( size_t size ) override;
154  virtual void shift( size_t pos, ptrdiff_t offs ) override;
156  virtual bool insertMove (size_t pos,
157  IAuxStore& other,
158  const SG::auxid_set_t& ignore) override;
159 
161 
164 
166  virtual const void* getIOData( auxid_t auxid ) const override;
167 
169  virtual const std::type_info* getIOType( auxid_t auxid ) const override;
170 
172  virtual const auxid_set_t& getDynamicAuxIDs() const override;
173 
175  virtual void
176  selectAux( const std::set< std::string >& attributes );
177 
179  virtual auxid_set_t getSelectedAuxIDs() const override;
180 
182 
183  private:
186  StatusCode initStats( ::TTree* tree );
194  const std::type_info* auxBranchType( ::TBranch* br, const char* auxName,
195  ::Bool_t staticBranch,
196  std::string* expectedClassName = nullptr );
198  StatusCode setupAuxBranch( ::TBranch* br, const char* auxName,
199  ::Bool_t staticBranch );
201  ::Bool_t isAuxIDSelected( auxid_t auxid ) const;
203  static ::Bool_t isPrimitiveBranch( TBranch* br );
205  static ::Bool_t isContainerBranch( TBranch* br, auxid_t auxid );
207  static ::Bool_t isRegisteredType( auxid_t auxid );
209  std::string m_prefix;
211  std::string m_dynPrefix;
212 
214  ::Bool_t m_topStore;
215 
219  ::Int_t m_basketSize;
221  ::Int_t m_splitLevel;
222 
224  ::TTree* m_inTree;
226  ::TTree* m_outTree;
227 
229  ::Bool_t m_inputScanned;
230 
235 
239  std::vector< SG::IAuxTypeVector* > m_vecs;
241  std::size_t m_size;
242 
244  ::Bool_t m_locked;
246  std::vector< ::Bool_t > m_isDecoration;
247 
251  typedef AthContainers_detail::lock_guard< mutex_t > guard_t;
254 
261 
262  public:
264  TBranchHandle( ::Bool_t staticBranch, ::Bool_t primitiveBranch,
265  const std::type_info* ti, void* obj,
266  SG::auxid_t auxid, const std::string* prefix );
267 
269  ::Int_t getEntry();
271  ::TBranch** branchPtr();
273  void* objectPtr();
275  void* inputObjectPtr();
277  void* outputObjectPtr();
279  const std::type_info* typeInfo() const;
281  void reset();
282 
283  private:
285  ::TBranch* m_branch;
287  ::Long64_t m_entry;
289  void* m_object;
291  ::Bool_t m_static;
293  ::Bool_t m_primitive;
295  const std::type_info* m_typeInfo;
297  ::Bool_t m_needsRead;
301  const std::string* m_prefix;
302 
303  }; // class TBranchHandle
304 
306  std::vector< TBranchHandle* > m_branches;
308  std::vector< bool > m_branchesWritten;
311  std::vector< bool > m_missingBranches;
312 
313  }; // class TAuxStore
314 
315 } // namespace xAOD
316 
317 #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:311
xAOD::TAuxStore::getSelectedAuxIDs
virtual auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected aux variables.
Definition: TAuxStore.cxx:834
xAOD::TAuxStore::TBranchHandle::typeInfo
const std::type_info * typeInfo() const
Get the type of the variable in memory.
Definition: TAuxStore.cxx:2098
xAOD::TAuxStore::getAuxIDs
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition: TAuxStore.cxx:322
xAOD::TAuxStore::TBranchHandle::reset
void reset()
Tell the object that the branch contents need to be re-read.
Definition: TAuxStore.cxx:2114
xAOD::TAuxStore::isDecoration
virtual bool isDecoration(auxid_t auxid) const override
Test if a variable is a decoration.
Definition: TAuxStore.cxx:400
xAOD::TAuxStore::TBranchHandle::m_entry
::Long64_t m_entry
The last entry that was loaded for this branch.
Definition: TAuxStore.h:287
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:301
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:246
xAOD::TAuxStore::m_prefix
std::string m_prefix
Static prefix for the branch names.
Definition: TAuxStore.h:209
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:293
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:221
xAOD::TAuxStore::TBranchHandle::m_branch
::TBranch * m_branch
The branch that this object is handling.
Definition: TAuxStore.h:285
xAOD::TAuxStore::m_auxIDs
auxid_set_t m_auxIDs
Internal list of variable IDs handled currently by the object.
Definition: TAuxStore.h:237
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:589
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:122
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:219
xAOD::TAuxStore::m_locked
::Bool_t m_locked
Is this container locked?
Definition: TAuxStore.h:244
xAOD::TAuxStore::scanInputTree
StatusCode scanInputTree()
Scan the input TTree for auxiliary branches.
Definition: TAuxStore.cxx:1385
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
xAOD::TAuxStore::m_inTree
::TTree * m_inTree
The TTree being read from.
Definition: TAuxStore.h:224
xAOD::TAuxStore::m_dynPrefix
std::string m_dynPrefix
Dynamic prefix for the branch names.
Definition: TAuxStore.h:211
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:680
xAOD::TAuxStore::guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
Definition: TAuxStore.h:251
xAOD::TAuxStore::reset
void reset()
Tell the object that all branches will need to be re-read.
Definition: TAuxStore.cxx:272
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:54
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:1492
xAOD::TAuxStore::lock
virtual void lock() override
Lock the object, and don't let decorations be added.
Definition: TAuxStore.cxx:414
xAOD::TAuxStore::m_outTree
::TTree * m_outTree
The TTree being written to.
Definition: TAuxStore.h:226
xAOD::TAuxStore::getWritableAuxIDs
virtual const auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
Definition: TAuxStore.cxx:584
xAOD::TAuxStore::isRegisteredType
::Bool_t isRegisteredType(auxid_t auxid)
Check if the auxiliary variable has a registered type.
Definition: TAuxStore.cxx:1929
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:781
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:1746
xAOD::TAuxStore::reserve
virtual void reserve(size_t size) override
Reserve a given size for the arrays.
Definition: TAuxStore.cxx:620
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:1797
xAOD::TAuxStore::m_mutex1
mutex_t m_mutex1
Mutexes object used for multithreaded synchronisation.
Definition: TAuxStore.h:253
xAOD::TAuxStore::m_mutex2
mutex_t m_mutex2
Definition: TAuxStore.h:253
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:646
Preparation.mode
mode
Definition: Preparation.py:95
xAOD::TAuxStore::m_transientStore
SG::AuxStoreInternal * m_transientStore
Store for the in-memory-only variables.
Definition: TAuxStore.h:234
xAOD::TAuxStore::TBranchHandle::m_object
void * m_object
The pointer to the object in memory.
Definition: TAuxStore.h:289
xAOD::TAuxStore::mutex_t
AthContainers_detail::mutex mutex_t
Mutex type for multithread synchronization.
Definition: TAuxStore.h:249
xAOD::TAuxStore::getData
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.
Definition: TAuxStore.cxx:287
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:851
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:217
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:327
xAOD::TAuxStore::m_vecs
std::vector< SG::IAuxTypeVector * > m_vecs
Variables handled currently by the object.
Definition: TAuxStore.h:239
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:818
xAOD::TAuxStore::m_inputScanned
::Bool_t m_inputScanned
"Scan status" of the input TTree
Definition: TAuxStore.h:229
xAOD::TAuxStore::TBranchHandle::inputObjectPtr
void * inputObjectPtr()
Get a pointer to the object (or its pointer) in memory for reading.
Definition: TAuxStore.cxx:2069
xAOD::TAuxStore::TBranchHandle::m_auxid
SG::auxid_t m_auxid
The auxiliary ID of the branch.
Definition: TAuxStore.h:299
xAOD::TAuxStore::TBranchHandle::m_needsRead
::Bool_t m_needsRead
Read status flag.
Definition: TAuxStore.h:297
threading.h
Threading definitions.
xAOD::TAuxStore::TBranchHandle::m_typeInfo
const std::type_info * m_typeInfo
Type info for the variable.
Definition: TAuxStore.h:295
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:456
AuxSelection.h
xAOD::TAuxStore::m_topStore
::Bool_t m_topStore
Flag stating whether this is a "top store".
Definition: TAuxStore.h:214
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:825
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:2049
xAOD::TAuxStore::TBranchHandle::getEntry
::Int_t getEntry()
Get entry from the branch that was loaded with TTree::LoadTree()
Definition: TAuxStore.cxx:1958
xAOD::TAuxStore::TBranchHandle::branchPtr
::TBranch ** branchPtr()
Get a pointer to the branch being held.
Definition: TAuxStore.cxx:2039
xAOD::TAuxStore::size
virtual size_t size() const override
Return the number of elements in the store.
Definition: TAuxStore.cxx:464
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:40
xAOD::TAuxStore::m_size
std::size_t m_size
The current size of the container being described.
Definition: TAuxStore.h:241
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:734
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:306
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:1589
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:1942
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:2088
xAOD::TAuxStore::setupOutputData
StatusCode setupOutputData(auxid_t auxid)
Connect a variable to the output tree.
Definition: TAuxStore.cxx:1138
xAOD::TAuxStore::clearDecorations
virtual bool clearDecorations() override
Remove the decorations added so far.
Definition: TAuxStore.cxx:427
xAOD::TAuxStore::TBranchHandle::m_static
::Bool_t m_static
Is this a static variable in question?
Definition: TAuxStore.h:291
xAOD::TAuxStore::isPrimitiveBranch
::Bool_t isPrimitiveBranch(TBranch *br)
Check if a branch holds a primitive variable or not.
Definition: TAuxStore.cxx:1763
python.PyAthena.obj
obj
Definition: PyAthena.py:135
xAOD::TAuxStore::setupInputData
StatusCode setupInputData(auxid_t auxid)
Connect a variable to the input tree.
Definition: TAuxStore.cxx:881
xAOD::TAuxStore::linkedVector
virtual const SG::IAuxTypeVector * linkedVector(SG::auxid_t auxid) const override
Return interface for a linked variable.
Definition: TAuxStore.cxx:489
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
xAOD::TAuxStore::TBranchHandle
Class used internally to implement just-in-time reading.
Definition: TAuxStore.h:260
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:308
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:232
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355