189 fEntryList(entryList),
193 Error(
"TTreeReader",
"TTree is NULL!");
205 fEntryList(entryList),
218 for (std::deque<ROOT::Internal::TTreeReaderValueBase*>::const_iterator
220 (*i)->MarkTreeReaderUnavailable();
259 if (
fTree->GetTree()) {
281 "The current tree in the TChain %s has changed (e.g. by TTree::Process) "
282 "even though TTreeReader::SetEntry() was called, which switched the tree "
283 "again. Did you mean to call TTreeReader::SetLocalEntry()?",
293 "The TTree / TChain has an associated TEntryList. "
294 "TTreeReader ignores TEntryLists unless you construct the TTreeReader passing a TEntryList.");
302 value->NotifyNewTree(
fTree->GetTree());
316 for (
size_t i = 0; i <
fValues.size(); ++i) {
334 const auto curFile =
fTree->GetCurrentFile();
335 if (curFile &&
fTree->GetTree()->GetReadCache(curFile,
true)) {
342 fTree->AddBranchToCache(value->GetProxy()->GetBranchName(),
true);
344 fTree->StopCacheLearningPhase();
375 Error(
"SetEntriesRange()",
"first entry out of range 0..%lld",
GetEntries(
false));
379 if (endEntry > beginEntry)
383 if (beginEntry - 1 < 0)
388 Error(
"SetEntriesRange()",
"Error setting first entry %lld: %s",
403 if (
const auto curFile =
fTree->GetCurrentFile()) {
404 if (
auto tc =
fTree->GetTree()->GetReadCache(curFile,
true)) {
405 tc->DropBranch(
"*",
true);
425 return fTree->GetEntries();
426 return fTree->GetEntriesFast();
464 TTree* treeToCallLoadOn = local ?
fTree->GetTree() :
fTree;
467 const Long64_t loadResult = treeToCallLoadOn->LoadTree(entryAfterList);
470 if (loadResult < 0) {
481 value->NotifyNewTree(
fTree->GetTree());
485 "There was an issue opening the last file associated to the TChain "
491 if (loadResult == -2) {
495 value->NotifyNewTree(
fTree->GetTree());
502 if (loadResult == -1) {
508 if (loadResult == -4) {
514 value->NotifyNewTree(
fTree->GetTree());
522 "Unexpected error '%lld' in %s::LoadTree", loadResult,
523 treeToCallLoadOn->IsA()->GetName());
581 TTree*
tree =
nullptr;
594 Error(
"RegisterValueReader",
595 "Error registering reader for %s: TTreeReaderValue/Array objects must be created before the call to Next() / SetEntry() / SetLocalEntry(), or after TTreeReader::Restart()!",
608 std::deque<ROOT::Internal::TTreeReaderValueBase*>::iterator iReader
610 if (iReader ==
fValues.end()) {
611 Error(
"DeregisterValueReader",
"Cannot find reader of type %s for branch %s",
reader->GetDerivedTypeName(),
reader->fBranchName.Data());
void SetReadEntry(Long64_t entry)
Move to a new entry to read entry is the 'local' entry number; i.e.
TTree * SetTree(TTree *newtree)
Base class of TTreeReaderValue.
Describe directory structure in memory.
void GetObject(const char *namecycle, T *&ptr)
A List of entry numbers in a TTree or TChain.
virtual Long64_t GetEntry(Int_t index)
Return the number of the entry #index of this TEntryList in the TTree or TChain See also Next().
virtual Long64_t GetN() const
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
A simple, robust and fast interface to read values from ROOT colmnar datasets such as TTree,...
TTreeReader()
Default constructor. Call SetTree to connect to a TTree.
Bool_t fProxiesSet
True if the proxies have been set, false otherwise.
ELoadTreeStatus fLoadTreeStatus
Indicator on how LoadTree was called 'last' time.
EEntryStatus fEntryStatus
status of most recent read request
void SetTree(TTree *tree, TEntryList *entryList=nullptr)
Set (or update) the which tree to read from.
TNotifyLink< TTreeReader > fNotify
Bool_t SetProxies()
Tell readers we now have a tree.
@ kEntryNotFound
the tree entry number does not exist
@ kEntryUnknownError
LoadTree return less than -4, likely a 'newer' error code.
@ kEntryDictionaryError
problem reading dictionary info from tree
@ kEntryBeyondEnd
last entry loop has reached its end
@ kEntryChainFileError
problem in opening a chain's file
@ kEntryNoTree
the tree does not exist
@ kEntryValid
data read okay
std::deque< ROOT::Internal::TTreeReaderValueBase * > fValues
readers that use our director
Bool_t Notify()
Callback from TChain and TTree's LoadTree.
TTree * fTree
tree that's read
ROOT::Internal::TBranchProxyDirector * fDirector
proxying director, owned
~TTreeReader()
Tell all value readers that the tree reader does not exist anymore.
EEntryStatus SetEntriesRange(Long64_t beginEntry, Long64_t endEntry)
Set the begin and end entry numbers.
std::deque< ROOT::Internal::TFriendProxy * > fFriendProxies
proxying for friend TTrees, owned
Bool_t fSetEntryBaseCallingLoadTree
True if during the LoadTree execution triggered by SetEntryBase.
@ kInternalLoadTree
Notify/LoadTree was last called from SetEntryBase.
@ kNoTree
default state, no TTree is connected (formerly 'Zombie' state)
@ kExternalLoadTree
User code called LoadTree directly.
@ kLoadTreeNone
Notify has not been called yet.
static constexpr const char *const fgEntryStatusText[kEntryBeyondEnd+1]
void Initialize()
Initialization of the director.
void Restart()
Restart a Next() loop from entry 0 (of TEntryList index 0 of fEntryList is set).
EEntryStatus SetEntryBase(Long64_t entry, Bool_t local)
Load an entry into the tree, return the status of the read.
TEntryList * fEntryList
entry list to be used
Long64_t fEntry
Current (non-local) entry of fTree or of fEntryList if set.
Bool_t RegisterValueReader(ROOT::Internal::TTreeReaderValueBase *reader)
Add a value reader for this tree.
Long64_t fBeginEntry
This allows us to propagate the range to the TTreeCache.
void DeregisterValueReader(ROOT::Internal::TTreeReaderValueBase *reader)
Remove a value reader for this tree.
@ kBitHaveWarnedAboutEntryListAttachedToTTree
the tree had a TEntryList and we have warned about that
@ kBitIsChain
our tree is a chain
NamedProxies_t fProxies
attached ROOT::TNamedBranchProxies; owned
Long64_t GetEntries(Bool_t force) const
Returns the number of entries of the TEntryList if one is provided, else of the TTree / TChain,...
Long64_t fEndEntry
The end of the entry loop.
EEntryStatus SetEntry(Long64_t entry)
Set the next entry (or index of the TEntryList if that is set).
static constexpr Long64_t kMaxEntries