12 #ifndef ROOT_TTreeReader 13 #define ROOT_TTreeReader 31 #include <unordered_map> 39 class TBranchProxyDirector;
56 public std::iterator<std::input_iterator_tag, const Long64_t, Long64_t> {
62 bool IsValid()
const {
return fEntry >= 0; }
71 fEntry(entry), fReader(&reader) {}
76 if (!IsValid() && !lhs.
IsValid())
return true;
82 return !(*
this == lhs);
109 if (fReader->
SetEntry(fEntry) != kEntryValid) {
135 static constexpr
const char *
const fgEntryStatusText[kEntryBeyondEnd + 1] = {
137 "the tree does not exist",
138 "the tree entry number does not exist",
139 "cannot access chain element",
140 "problem in opening a chain's file",
141 "problem reading dictionary info from tree",
142 "last entry loop has reached its end" 156 SetTree(keyname,
nullptr, entryList);
172 return SetEntry(GetCurrentEntry() + 1) == kEntryValid;
225 using NamedProxies_t = std::unordered_map<std::string, std::unique_ptr<ROOT::Internal::TNamedBranchProxy>>;
229 const auto proxyIt = fProxies.find(branchname);
230 return fProxies.end() != proxyIt ? proxyIt->second.get() :
nullptr;
237 if (fProxies.end() != fProxies.find(bpName)) {
238 std::string err =
"A proxy with key " + std::string(bpName) +
" was already stored!";
239 throw std::runtime_error(err);
243 fProxies[bpName].reset(p);
255 std::string key(branchname);
262 kBitHaveWarnedAboutEntryListAttachedToTTree =
BIT(15)
270 std::deque<ROOT::Internal::TTreeReaderValueBase*>
fValues;
287 #endif // defined TTreeReader ROOT::Internal::TNamedBranchProxy * FindProxy(const char *branchname) const
Iterate through the entries of a TTree.
bool operator!=(const Iterator_t &lhs) const
Compare two iterators for inequality.
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
Namespace for new ROOT classes and functions.
Long64_t GetCurrentEntry() const
Returns the index of the current entry being read.
std::string GetProxyKey(const char *branchname)
TTreeReader(const char *keyname, TEntryList *entryList=nullptr)
std::deque< ROOT::Internal::TTreeReaderValueBase * > fValues
readers that use our director
void SetTree(const char *keyname, TEntryList *entryList=nullptr)
Long64_t fEntry
Entry number of the tree referenced by this iterator; -1 is invalid.
const char * GetName() const
bool IsValid() const
Whether the iterator points to a valid entry.
#define ClassDef(name, id)
the tree entry number does not exist
Iterator_t begin()
Return an iterator to the 0th TTree entry.
const Long64_t & operator*()
Set the entry number in the reader and return it.
Iterator_t()
Default-initialize the iterator as "past the end".
NamedProxies_t fProxies
attached ROOT::TNamedBranchProxies; owned
Iterator_t end() const
Return an iterator beyond the last TTree entry.
void Initialize(Bool_t useTMVAStyle=kTRUE)
This class defines an abstract interface that must be implemented by all classes that contain diction...
TTime operator*(const TTime &t1, const TTime &t2)
void AddProxy(ROOT::Internal::TNamedBranchProxy *p)
EEntryStatus SetEntry(Long64_t entry)
Set the next entry (or index of the TEntryList if that is set).
no entry has been loaded yet
const Long64_t & operator*() const
problem in opening a chain's file
problem in accessing a chain element, e.g. file without the tree
Iterator_t operator++(int)
Increment the iterator (postfix i++).
EEntryStatus SetLocalEntry(Long64_t entry)
Set the next local tree entry.
Describe directory structure in memory.
problem reading dictionary info from tree
EEntryStatus GetEntryStatus() const
Iterator_t & operator++()
Increment the iterator (prefix ++i).
TEntryList * GetEntryList() const
Mother of all ROOT objects.
Bool_t Next()
Move to the next entry (or index of the TEntryList if that is set).
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
bool operator==(const Iterator_t &lhs) const
Compare two iterators for equality.
A TTree object has a header with a name and a title.
TTreeReader * fReader
The reader we select the entries on.
A List of entry numbers in a TTree or TChain.
Iterator_t(TTreeReader &reader, Long64_t entry)
Initialize the iterator with the reader it steers and a tree entry number; -1 is invalid.
std::unordered_map< std::string, std::unique_ptr< ROOT::Internal::TNamedBranchProxy > > NamedProxies_t