An interface for reading values stored in ROOT columnar datasets.
The TTreeReaderValue is a type-safe tool to be used in association with a TTreeReader to access the values stored in TTree, TNtuple and TChain datasets. TTreeReaderValue can be also used to access collections such as std::vectors or TClonesArray stored in columnar datasets but it is recommended to use TTreeReaderArray instead as it offers several advantages.
See the documentation of TTreeReader for more details and examples.
Definition at line 205 of file TTreeReaderValue.h.
Public Types | |
| typedef bool(ROOT::Detail::TBranchProxy::* | BranchProxyRead_t) () |
| enum | EReadStatus { kReadSuccess = 0 , kReadNothingYet , kReadError } |
| enum | ESetupStatus { kSetupMatchButEntryBeyondEnd , kSetupMakeClassModeMismatch = -9 , kSetupTreeDestructed = -8 , kSetupNotSetup = -7 , kSetupMissingCounterBranch = -6 , kSetupMissingBranch = -5 , kSetupInternalError = -4 , kSetupMissingDictionary = -3 , kSetupMismatch = -2 , kSetupNotACollection = -1 , kSetupMatch , kSetupNoCheck = 5 , kSetupMatchLeaf = 6 , kSetupMatchBranch } |
| Status flags, 0 is good. More... | |
| using | NonConstT_t = typename std::remove_const<T>::type |
Public Member Functions | |
| TTreeReaderValue ()=delete | |
| TTreeReaderValue (TTreeReader &tr, const char *branchname) | |
| T * | Get () |
| Return a pointer to the value of the current entry. | |
| void * | GetAddress () |
| Returns the memory address of the object being read. | |
| const char * | GetBranchName () const |
| TLeaf * | GetLeaf () |
| If we are reading a leaf, return the corresponding TLeaf. | |
| virtual EReadStatus | GetReadStatus () const |
| ESetupStatus | GetSetupStatus () const |
| Return this TTreeReaderValue's setup status. | |
| bool | IsValid () const |
| Return true if the branch was setup and read correctly. | |
| T & | operator* () |
| Return a reference to the value of the current entry. | |
| T * | operator-> () |
| Return a pointer to the value of the current entry. | |
| EReadStatus | ProxyRead () |
| EReadStatus | ProxyReadDefaultImpl () |
| template<BranchProxyRead_t Func> | |
| ROOT::Internal::TTreeReaderValueBase::EReadStatus | ProxyReadTemplate () |
| Try to read the value from the TBranchProxy, returns the status of the read. | |
Protected Types | |
| typedef EReadStatus(TTreeReaderValueBase::* | Read_t) () |
Protected Member Functions | |
| virtual void | CreateProxy () |
| Create the proxy object for our branch. | |
| void | ErrorAboutMissingProxyIfNeeded () |
| const char * | GetDerivedTypeName () const override |
| Get the template argument as a string. | |
| Detail::TBranchProxy * | GetProxy () const |
| void | MarkTreeReaderUnavailable () |
| void | NotifyNewTree (TTree *newTree) |
| The TTreeReader has switched to a new TTree. Update the leaf. | |
| void | RegisterWithTreeReader () |
| Register with tree reader. | |
| TBranch * | SearchBranchWithCompositeName (TLeaf *&myleaf, TDictionary *&branchActualType, std::string &err) |
| Search a branch the name of which contains a ".". | |
Static Protected Member Functions | |
| static const char * | GetBranchDataType (TBranch *branch, TDictionary *&dict, TDictionary const *curDict) |
| Retrieve the type of data stored by branch; put its dictionary into dict, return its type name. | |
| static std::string | GetElementTypeName (const std::type_info &ti) |
| Stringify the template argument. | |
Protected Attributes | |
| TString | fBranchName |
| Name of the branch to read data from. | |
| TDictionary * | fDict |
| Type that the branch should contain. | |
| bool | fHaveLeaf: 1 |
| Whether the data is in a leaf. | |
| bool | fHaveStaticClassOffsets: 1 |
| Whether !fStaticClassOffsets.empty(). | |
| TLeaf * | fLeaf = nullptr |
| TString | fLeafName |
| bool | fOpaqueRead {false} |
| If true, the reader will not do any type-checking against the actual type held by the branch. | |
| Detail::TBranchProxy * | fProxy = nullptr |
| Proxy for this branch, owned by TTreeReader. | |
| Read_t | fProxyReadFunc = &TTreeReaderValueBase::ProxyReadDefaultImpl |
| ! Pointer to the Read implementation to use. | |
| EReadStatus | fReadStatus: 2 |
| Read status of this data access. | |
| ESetupStatus | fSetupStatus = kSetupNotSetup |
| Setup status of this data access. | |
| std::vector< Long64_t > | fStaticClassOffsets |
| TTreeReader * | fTreeReader |
| Tree reader we belong to. | |
#include <TTreeReaderValue.h>
|
inherited |
Definition at line 84 of file TTreeReaderValue.h.
| using TTreeReaderValue< T >::NonConstT_t = typename std::remove_const<T>::type |
Definition at line 209 of file TTreeReaderValue.h.
|
protectedinherited |
Definition at line 143 of file TTreeReaderValue.h.
|
inherited |
| Enumerator | |
|---|---|
| kReadSuccess | Data read okay. |
| kReadNothingYet | Data now yet accessed. |
| kReadError | Problem reading data. |
Definition at line 74 of file TTreeReaderValue.h.
|
inherited |
Status flags, 0 is good.
Definition at line 48 of file TTreeReaderValue.h.
|
delete |
|
inline |
Definition at line 211 of file TTreeReaderValue.h.
|
protectedvirtualinherited |
Create the proxy object for our branch.
Reimplemented in ROOT::Internal::TTreeReaderArrayBase.
Definition at line 462 of file TTreeReaderValue.cxx.
|
protectedinherited |
Definition at line 842 of file TTreeReaderValue.cxx.
|
inline |
Return a pointer to the value of the current entry.
Return a nullptr and print an error if no entry has been loaded yet. The returned address is guaranteed to stay constant while a given TTree is being read from a given file, unless the branch addresses are manipulated directly (e.g. through TTree::SetBranchAddress()). The address might also change when the underlying TTree/TFile is switched, e.g. when a TChain switches files.
Definition at line 221 of file TTreeReaderValue.h.
|
inherited |
Returns the memory address of the object being read.
Definition at line 266 of file TTreeReaderValue.cxx.
|
staticprotectedinherited |
Retrieve the type of data stored by branch; put its dictionary into dict, return its type name.
If no dictionary is available, at least its type name should be returned.
Definition at line 713 of file TTreeReaderValue.cxx.
|
inlineinherited |
Definition at line 101 of file TTreeReaderValue.h.
|
inlineoverrideprotectedvirtual |
Get the template argument as a string.
Implements ROOT::Internal::TTreeReaderValueBase.
Definition at line 243 of file TTreeReaderValue.h.
|
staticprotectedinherited |
Stringify the template argument.
Definition at line 226 of file TTreeReaderValue.cxx.
|
inlineinherited |
If we are reading a leaf, return the corresponding TLeaf.
Definition at line 97 of file TTreeReaderValue.h.
|
inlineprotectedinherited |
Definition at line 119 of file TTreeReaderValue.h.
|
inlinevirtualinherited |
Reimplemented in ROOT::Internal::TTreeReaderArrayBase.
Definition at line 94 of file TTreeReaderValue.h.
|
inlineinherited |
Return this TTreeReaderValue's setup status.
Use this method to check e.g. whether the TTreeReaderValue is correctly setup and ready for reading.
Definition at line 93 of file TTreeReaderValue.h.
|
inlineinherited |
Return true if the branch was setup and read correctly.
Use GetSetupStatus() to only check the setup status.
Definition at line 90 of file TTreeReaderValue.h.
|
inlineprotectedinherited |
Definition at line 121 of file TTreeReaderValue.h.
|
protectedinherited |
The TTreeReader has switched to a new TTree. Update the leaf.
Definition at line 238 of file TTreeReaderValue.cxx.
|
inline |
Return a reference to the value of the current entry.
Equivalent to dereferencing the pointer returned by Get(). Behavior is undefined if no entry has been loaded yet. Most likely a crash will occur.
Definition at line 238 of file TTreeReaderValue.h.
|
inline |
Return a pointer to the value of the current entry.
Equivalent to Get().
Definition at line 233 of file TTreeReaderValue.h.
|
inlineinherited |
Definition at line 80 of file TTreeReaderValue.h.
|
inherited |
Definition at line 158 of file TTreeReaderValue.cxx.
|
inherited |
Try to read the value from the TBranchProxy, returns the status of the read.
Definition at line 148 of file TTreeReaderValue.cxx.
|
protectedinherited |
Register with tree reader.
Definition at line 134 of file TTreeReaderValue.cxx.
|
protectedinherited |
Search a branch the name of which contains a ".".
| [out] | myLeaf | The leaf identified by the name if found (can be untouched). |
| [out] | branchActualType | Dictionary associated to the type of the leaf (can be untouched). |
| [out] | errMsg | The error message (can be untouched). |
Definition at line 315 of file TTreeReaderValue.cxx.
|
protectedinherited |
Name of the branch to read data from.
Definition at line 136 of file TTreeReaderValue.h.
|
protectedinherited |
Type that the branch should contain.
Definition at line 139 of file TTreeReaderValue.h.
|
protectedinherited |
Whether the data is in a leaf.
Definition at line 132 of file TTreeReaderValue.h.
|
protectedinherited |
Whether !fStaticClassOffsets.empty().
Definition at line 133 of file TTreeReaderValue.h.
|
protectedinherited |
Definition at line 141 of file TTreeReaderValue.h.
|
protectedinherited |
Definition at line 137 of file TTreeReaderValue.h.
|
protectedinherited |
If true, the reader will not do any type-checking against the actual type held by the branch.
Useful to just check if the current entry can be read or not without caring about its value.
Definition at line 151 of file TTreeReaderValue.h.
|
protectedinherited |
Proxy for this branch, owned by TTreeReader.
Definition at line 140 of file TTreeReaderValue.h.
|
protectedinherited |
! Pointer to the Read implementation to use.
Definition at line 144 of file TTreeReaderValue.h.
|
protectedinherited |
Read status of this data access.
Definition at line 134 of file TTreeReaderValue.h.
|
protectedinherited |
Setup status of this data access.
Definition at line 135 of file TTreeReaderValue.h.
|
protectedinherited |
Definition at line 142 of file TTreeReaderValue.h.
|
protectedinherited |
Tree reader we belong to.
Definition at line 138 of file TTreeReaderValue.h.