ATLAS Offline Software
|
"ROOT implementation" of IAuxStore More...
#include <TAuxStore.h>
Classes | |
class | TBranchHandle |
Class used internally to implement just-in-time reading. More... | |
Public Types | |
enum | EStructMode { kUndefinedStore = 0, kContainerStore = 1, kObjectStore = 2 } |
"Structural" modes of the object More... | |
typedef SG::auxid_t | auxid_t |
Convenience type declaration. More... | |
typedef SG::auxid_set_t | auxid_set_t |
Convenience type declaration. More... | |
Public Member Functions | |
TAuxStore (const char *prefix="", Bool_t topStore=kTRUE, EStructMode mode=kUndefinedStore, Int_t basketSize=2048, Int_t splitLevel=0) | |
Default constructor. More... | |
~TAuxStore () | |
Destructor. More... | |
EStructMode | structMode () const |
Get what structure mode the object was constructed with. More... | |
StatusCode | setStructMode (EStructMode mode) |
Set the structure mode of the object to a new value. More... | |
const char * | prefix () const |
Get the currently configured branch name prefix. More... | |
void | setPrefix (const char *prefix) |
Set the branch name prefix. More... | |
Bool_t | isTopStore () const |
Check if the object is a "top store", or not. More... | |
void | setTopStore (Bool_t value=kTRUE) |
Set whether the object should behave as a "top store" or not. More... | |
Int_t | basketSize () const |
Get the size of the baskets created for the output branches. More... | |
void | setBasketSize (Int_t value) |
Set the size of the baskets created for the output branches. More... | |
Int_t | splitLevel () const |
Get the split level of the output branches. More... | |
void | setSplitLevel (Int_t value) |
Set the split level of the output branches. More... | |
StatusCode | readFrom (::TTree *tree, ::Bool_t printWarnings=kTRUE) |
Connect the object to an input TTree. More... | |
StatusCode | writeTo (::TTree *tree) |
Connect the object to an output TTree. More... | |
Int_t | getEntry (Int_t getall=0) |
Read the values from the TTree entry that was loaded with TTree::LoadTree() More... | |
void | reset () |
Tell the object that all branches will need to be re-read. More... | |
virtual const void * | getData (SG::auxid_t auxid) const=0 |
Pick up the const version from the base class. 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... | |
virtual const IAuxTypeVector * | linkedVector (SG::auxid_t) const |
Return interface for a linked variable. More... | |
Functions implementing the SG::IConstAuxStore interface | |
virtual const void * | getData (auxid_t auxid) const override |
Get a pointer to a given array. More... | |
virtual const SG::IAuxTypeVector * | getVector (SG::auxid_t auxid) const override |
Return vector interface for one aux data item. More... | |
virtual const auxid_set_t & | getAuxIDs () const override |
Get the types(names) of variables handled by this container. More... | |
virtual const auxid_set_t & | getDecorIDs () const override |
Get the types(names) of decorations handled by this container. More... | |
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. More... | |
virtual bool | isDecoration (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 size_t | size () const override |
Return the number of elements in the store. More... | |
virtual const SG::IAuxTypeVector * | linkedVector (SG::auxid_t auxid) const override |
Return interface for a linked variable. More... | |
virtual SG::IAuxTypeVector * | linkedVector (SG::auxid_t auxid) override |
Functions implementing the SG::IAuxStore interface | |
virtual void * | getData (auxid_t auxid, size_t size, size_t capacity) override |
Get a pointer to a given array, creating the array if necessary. More... | |
virtual const auxid_set_t & | getWritableAuxIDs () const override |
Return a set of writable data identifiers. More... | |
virtual bool | resize (size_t size) override |
Resize the arrays to a given size. More... | |
virtual void | reserve (size_t size) override |
Reserve a given size for the arrays. More... | |
virtual void | shift (size_t pos, ptrdiff_t offs) override |
Shift the contents of the stored arrays. More... | |
virtual bool | insertMove (size_t pos, 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 (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 (auxid_t auxid) const override |
Return the type of the data to be stored for one aux data item. More... | |
virtual const auxid_set_t & | getDynamicAuxIDs () 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 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... | |
Private Types | |
typedef AthContainers_detail::mutex | mutex_t |
Mutex type for multithread synchronization. More... | |
typedef AthContainers_detail::lock_guard< mutex_t > | guard_t |
Guard type for multithreaded synchronisation. More... | |
Private Member Functions | |
StatusCode | initStats (::TTree *tree) |
Function used for setting up the statistics info about the managed branches. More... | |
StatusCode | setupInputData (auxid_t auxid) |
Connect a variable to the input tree. More... | |
StatusCode | setupOutputData (auxid_t auxid) |
Connect a variable to the output tree. More... | |
StatusCode | scanInputTree () |
Scan the input TTree for auxiliary branches. More... | |
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. More... | |
StatusCode | setupAuxBranch (::TBranch *br, const char *auxName, ::Bool_t staticBranch) |
Register one input branch as an available auxiliary variable. More... | |
::Bool_t | isAuxIDSelected (auxid_t auxid) const |
Check if this auxiliary variable needs to go to the output. More... | |
Static Private Member Functions | |
::Bool_t | isPrimitiveBranch (TBranch *br) |
Check if a branch holds a primitive variable or not. More... | |
::Bool_t | isContainerBranch (TBranch *br, auxid_t auxid) |
Check if a branch describes a container or a single object. More... | |
::Bool_t | isRegisteredType (auxid_t auxid) |
Check if the auxiliary variable has a registered type. More... | |
Private Attributes | |
std::string | m_prefix |
Static prefix for the branch names. More... | |
std::string | m_dynPrefix |
Dynamic prefix for the branch names. More... | |
::Bool_t | m_topStore |
Flag stating whether this is a "top store". More... | |
EStructMode | m_structMode |
The "structural" mode of the object. More... | |
::Int_t | m_basketSize |
The basket size for the output branches. More... | |
::Int_t | m_splitLevel |
The split level for the output branches. More... | |
::TTree * | m_inTree |
The TTree being read from. More... | |
::TTree * | m_outTree |
The TTree being written to. More... | |
::Bool_t | m_inputScanned |
"Scan status" of the input TTree More... | |
AuxSelection | m_selection |
Object helping to select which auxiliary variables to write. More... | |
SG::AuxStoreInternal * | m_transientStore |
Store for the in-memory-only variables. More... | |
auxid_set_t | m_auxIDs |
Internal list of variable IDs handled currently by the object. More... | |
auxid_set_t | m_decorIDs |
std::vector< SG::IAuxTypeVector * > | m_vecs |
Variables handled currently by the object. More... | |
std::size_t | m_size |
The current size of the container being described. More... | |
::Bool_t | m_locked |
Is this container locked? More... | |
std::vector< ::Bool_t > | m_isDecoration |
Flags items as decorations. More... | |
mutex_t | m_mutex1 |
Mutexes object used for multithreaded synchronisation. More... | |
mutex_t | m_mutex2 |
std::vector< TBranchHandle * > | m_branches |
Branches reading the various auxiliary variables. More... | |
std::vector< bool > | m_branchesWritten |
"Write status" of the different variables More... | |
std::vector< bool > | m_missingBranches |
Mark branches we've found to be missing. More... | |
Friends | |
class | TEvent |
Make TEvent a friend of this class. More... | |
"ROOT 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.
Definition at line 45 of file TAuxStore.h.
Convenience type declaration.
Definition at line 61 of file TAuxStore.h.
typedef SG::auxid_t xAOD::TAuxStore::auxid_t |
Convenience type declaration.
Definition at line 59 of file TAuxStore.h.
|
private |
Guard type for multithreaded synchronisation.
Definition at line 258 of file TAuxStore.h.
|
private |
Mutex type for multithread synchronization.
Definition at line 256 of file TAuxStore.h.
"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 53 of file TAuxStore.h.
xAOD::TAuxStore::TAuxStore | ( | const char * | prefix = "" , |
Bool_t | topStore = kTRUE , |
||
EStructMode | mode = kUndefinedStore , |
||
Int_t | basketSize = 2048 , |
||
Int_t | splitLevel = 0 |
||
) |
xAOD::TAuxStore::~TAuxStore | ( | ) |
|
private |
Find the type_info to use as the aux type for a given branch.
Definition at line 1512 of file TAuxStore.cxx.
Int_t xAOD::TAuxStore::basketSize | ( | ) | const |
Get the size of the baskets created for the output branches.
Definition at line 140 of file TAuxStore.cxx.
|
overridevirtual |
Remove the decorations added so far.
Only works for transient decorations.
Implements SG::IConstAuxStore.
Definition at line 447 of file TAuxStore.cxx.
|
overridevirtual |
Get the types(names) of variables handled by this container.
Implements SG::IConstAuxStore.
Definition at line 333 of file TAuxStore.cxx.
Get a pointer to a given array.
Implements SG::IConstAuxStore.
Definition at line 289 of file TAuxStore.cxx.
|
overridevirtual |
Get a pointer to a given array, creating the array if necessary.
Implements SG::IAuxStore.
Definition at line 537 of file TAuxStore.cxx.
|
inherited |
Pick up the const version from the base class.
|
overridevirtual |
Get a pointer to a given array, creating the array if necessary.
Implements SG::IConstAuxStore.
Definition at line 343 of file TAuxStore.cxx.
|
overridevirtual |
Get the types(names) of decorations handled by this container.
Implements SG::IConstAuxStore.
Definition at line 338 of file TAuxStore.cxx.
|
overridevirtual |
Get the types(names) of variables created dynamically.
Implements SG::IAuxStoreIO.
Definition at line 838 of file TAuxStore.cxx.
Int_t xAOD::TAuxStore::getEntry | ( | Int_t | getall = 0 | ) |
Read the values from the TTree entry that was loaded with TTree::LoadTree()
Definition at line 228 of file TAuxStore.cxx.
Get a pointer to the data being stored for one aux data item.
Implements SG::IAuxStoreIO.
Definition at line 754 of file TAuxStore.cxx.
Return the type of the data to be stored for one aux data item.
Implements SG::IAuxStoreIO.
Definition at line 801 of file TAuxStore.cxx.
|
overridevirtual |
Get the IDs of the selected aux variables.
Reimplemented from SG::IAuxStoreIO.
Definition at line 854 of file TAuxStore.cxx.
|
overridevirtual |
Return vector interface for one aux data item.
Implements SG::IConstAuxStore.
Definition at line 298 of file TAuxStore.cxx.
|
overridevirtual |
Return a set of writable data identifiers.
Implements SG::IAuxStore.
Definition at line 606 of file TAuxStore.cxx.
|
private |
Function used for setting up the statistics info about the managed branches.
This function is used to initialise the statistics registry with information about the branches managed by this object.
It is used by TEvent when connecting to new input files/chains.
tree | The tree to collect the information from |
StatusCode::SUCCESS
if the function was successful, something else otherwise Definition at line 871 of file TAuxStore.cxx.
|
overridevirtual |
|
pure virtualinherited |
Move all elements from other
to this store.
pos | The starting index of the insertion. |
other | Store from which to do the move. |
ignore | Set 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.
|
private |
Check if this auxiliary variable needs to go to the output.
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
kTRUE
if the variable needs to be written out, kFALSE
if not Definition at line 1766 of file TAuxStore.cxx.
|
staticprivate |
Check if a branch describes a container or a single object.
The code needs to know if a given branch describes a single object, or a container of objects.
This function decides about this.
In case the function encounters a problem it returns kFALSE
, as that is more likely to cause a crash a little later...
The function should probably be a bit optimisied in the future, as it makes a lot of security checks at the moment.
br | The branch whose type we're interested in |
auxid | The auxiliary ID of the variable described by the branch |
kTRUE
if the branch describes a container, kFALSE
if it describes a single object Definition at line 1817 of file TAuxStore.cxx.
|
overridevirtual |
Test if a variable is a decoration.
Implements SG::IConstAuxStore.
Definition at line 420 of file TAuxStore.cxx.
|
staticprivate |
Check if a branch holds a primitive variable or not.
The code needs to be fairly smart to figure out whether a branch is a primitive one, or an std::vector<T> one.
The check is done in this function.
br | The branch that should be checked |
kTRUE
if the branch describes a primitive variable, kFALSE
otherwise Definition at line 1783 of file TAuxStore.cxx.
|
staticprivate |
Check if the auxiliary variable has a registered type.
This function is used to test if a given auxiliary variable is known in the registry with a proper type.
kTRUE
if the full type of the auxiliary property is known, kFALSE
otherwise Definition at line 1949 of file TAuxStore.cxx.
Bool_t xAOD::TAuxStore::isTopStore | ( | ) | const |
Check if the object is a "top store", or not.
Definition at line 128 of file TAuxStore.cxx.
|
overridevirtual |
Return interface for a linked variable.
Reimplemented from SG::IConstAuxStore.
Definition at line 511 of file TAuxStore.cxx.
|
overridevirtual |
|
inlineinherited |
Return interface for a linked variable.
auxid | The 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.
|
overridevirtual |
Lock the object, and don't let decorations be added.
Implements SG::IConstAuxStore.
Definition at line 434 of file TAuxStore.cxx.
|
overridevirtual |
Get the currently configured branch name prefix.
Definition at line 115 of file TAuxStore.cxx.
StatusCode xAOD::TAuxStore::readFrom | ( | ::TTree * | tree, |
::Bool_t | printWarnings = kTRUE |
||
) |
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.
tree | Pointer to the TTree that is being read from |
Definition at line 167 of file TAuxStore.cxx.
|
overridevirtual |
Reserve a given size for the arrays.
Implements SG::IAuxStore.
Definition at line 642 of file TAuxStore.cxx.
void xAOD::TAuxStore::reset | ( | ) |
Tell the object that all branches will need to be re-read.
Definition at line 274 of file TAuxStore.cxx.
|
overridevirtual |
Resize the arrays to a given size.
Implements SG::IAuxStore.
Definition at line 611 of file TAuxStore.cxx.
|
private |
Scan the input TTree for auxiliary branches.
When writing an output tree, while reading information from an input tree, it can often happen that we want to copy the contents of some variables that we don't actually need during the event processing of this particular job.
Since the user doesn't ask for all the possible input variables, this function needs to look at the input TTree, and try to figure out which of the branches in the tree belong to this object.
The function creates a "proper" or "virtual" auxiliary ID for each of the branches found, so they can be referenced in the "usual way" in the other parts of the code later on.
kTRUE
if the operation was successful, kFALSE
if not Definition at line 1405 of file TAuxStore.cxx.
|
virtual |
void xAOD::TAuxStore::setBasketSize | ( | Int_t | value | ) |
Set the size of the baskets created for the output branches.
Definition at line 145 of file TAuxStore.cxx.
|
inlinevirtualinherited |
Set an option for a given auxiliary variable.
auxid | The identifier of the desired aux data item. |
option | The 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.
void xAOD::TAuxStore::setSplitLevel | ( | Int_t | value | ) |
Set the split level of the output branches.
Definition at line 156 of file TAuxStore.cxx.
StatusCode xAOD::TAuxStore::setStructMode | ( | EStructMode | mode | ) |
Set the structure mode of the object to a new value.
This function should be used with great care.
It makes it possible for the TEvent code to set the type of the object once the type is known. But user code should probably not fiddle with this function.
mode | The structure mode to set |
Definition at line 100 of file TAuxStore.cxx.
void xAOD::TAuxStore::setTopStore | ( | Bool_t | value = kTRUE | ) |
Set whether the object should behave as a "top store" or not.
Definition at line 133 of file TAuxStore.cxx.
|
private |
Register one input branch as an available auxiliary variable.
This function takes care of assigning an auxiliary ID to a given branch.
It tries its best to find an auxiliary vector factory for the branch's type, but if it fails, it still falls back to using SG::AuxTypePlaceholder
as the type. In which case of course only dumb copying will be possible for the given branch. (And no vector operations on the branch's payload until the variable of the branch is accessed explicitly.)
br | Pointer to the branch under investigation |
auxName | The name of the auxiliary property, extracted from the branch's name |
staticBranch | kTRUE if this is a "static branch", and kFALSE if it's a dynamic one |
kTRUE
if successful, kFALSE
if not Definition at line 1609 of file TAuxStore.cxx.
|
private |
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.
auxid | The ID of the variable to connect to |
kTRUE
if the operation was successful, kFALSE
if not Definition at line 901 of file TAuxStore.cxx.
|
private |
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.
auxid | The ID of the variable to create an output branch for |
kTRUE
if the operation was successful, kFALSE
if not Definition at line 1158 of file TAuxStore.cxx.
|
overridevirtual |
Shift the contents of the stored arrays.
Implements SG::IAuxStore.
Definition at line 668 of file TAuxStore.cxx.
|
overridevirtual |
Return the number of elements in the store.
Implements SG::IConstAuxStore.
Definition at line 486 of file TAuxStore.cxx.
Int_t xAOD::TAuxStore::splitLevel | ( | ) | const |
Get the split level of the output branches.
Definition at line 151 of file TAuxStore.cxx.
TAuxStore::EStructMode xAOD::TAuxStore::structMode | ( | ) | const |
Get what structure mode the object was constructed with.
Definition at line 88 of file TAuxStore.cxx.
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.
tree | Pointer to the TTree that is being written to |
Definition at line 209 of file TAuxStore.cxx.
|
friend |
Make TEvent a friend of this class.
Definition at line 49 of file TAuxStore.h.
|
private |
Internal list of variable IDs handled currently by the object.
Definition at line 243 of file TAuxStore.h.
|
private |
The basket size for the output branches.
Definition at line 225 of file TAuxStore.h.
|
private |
Branches reading the various auxiliary variables.
Definition at line 313 of file TAuxStore.h.
|
private |
"Write status" of the different variables
Definition at line 315 of file TAuxStore.h.
|
private |
Definition at line 244 of file TAuxStore.h.
|
private |
Dynamic prefix for the branch names.
Definition at line 217 of file TAuxStore.h.
|
private |
"Scan status" of the input TTree
Definition at line 235 of file TAuxStore.h.
|
private |
The TTree being read from.
Definition at line 230 of file TAuxStore.h.
|
private |
Flags items as decorations.
Definition at line 253 of file TAuxStore.h.
|
private |
Is this container locked?
Definition at line 251 of file TAuxStore.h.
|
private |
Mark branches we've found to be missing.
(Because TTree::GetBranch is very expensive.)
Definition at line 318 of file TAuxStore.h.
|
mutableprivate |
Mutexes object used for multithreaded synchronisation.
Definition at line 260 of file TAuxStore.h.
|
private |
Definition at line 260 of file TAuxStore.h.
|
private |
The TTree being written to.
Definition at line 232 of file TAuxStore.h.
|
private |
Static prefix for the branch names.
Definition at line 215 of file TAuxStore.h.
|
private |
Object helping to select which auxiliary variables to write.
Definition at line 238 of file TAuxStore.h.
|
private |
The current size of the container being described.
Definition at line 248 of file TAuxStore.h.
|
private |
The split level for the output branches.
Definition at line 227 of file TAuxStore.h.
|
private |
The "structural" mode of the object.
Definition at line 223 of file TAuxStore.h.
|
private |
Flag stating whether this is a "top store".
Definition at line 220 of file TAuxStore.h.
|
private |
Store for the in-memory-only variables.
Definition at line 240 of file TAuxStore.h.
|
private |
Variables handled currently by the object.
Definition at line 246 of file TAuxStore.h.
|
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.