Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tree/treeplayer/inc/ROOT/TTreeReaderValueFast.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class TTreeReaderValueFastBase {
}
fRemaining -= adjust;
} else {
if (!fBranch) {
fReadStatus = ROOT::Internal::TTreeReaderValueBase::kReadError;
// printf("Failed to retrieve branch.\n");
return -1;
}
fRemaining = fBranch->GetBulkRead().GetEntriesSerialized(eventNum, fBuffer);
if (R__unlikely(fRemaining < 0)) {
fReadStatus = ROOT::Internal::TTreeReaderValueBase::kReadError;
Expand Down
7 changes: 7 additions & 0 deletions tree/treeplayer/src/TTreeReaderFast.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ TTreeReaderFast::SetEntry(Long64_t entry)
void TTreeReaderFast::RegisterValueReader(ROOT::Experimental::Internal::TTreeReaderValueFastBase* reader)
{
fValues.push_back(reader);
if (fTree && reader) { // A subpart of Initialize() must be called if we register new readers after the constructor.
reader->CreateProxy();
if (reader->GetSetupStatus() != ROOT::Internal::TTreeReaderValueBase::kSetupMatch) {
//printf("Reader setup failed. Status: %d\n", reader->GetSetupStatus());
fEntryStatus = TTreeReader::kEntryBadReader;
}
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
19 changes: 19 additions & 0 deletions tree/treeplayer/test/regressions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "TLorentzVector.h"
#include <Math/Vector3D.h>
#include <ROOT/TestSupport.hxx>
#include "ROOT/TTreeReaderValueFast.hxx"
#include "TNtuple.h"

#include "TTreePlayer.h"

Expand Down Expand Up @@ -340,6 +342,23 @@ TEST(TTreeReaderRegressions, XYZVectors)
}
}

// ROOT-8842 https://its.cern.ch/jira/browse/ROOT-8842
TEST(TTreeReaderRegressions, ValueFastTuple)
{
TNtuple tree("tuple", "ROOT-8842", "px:py:pz:energy");
for (auto i = 0; i < 1000000; ++i)
tree.Fill(i, i + 1, i + 2, i + 3);
ROOT::Experimental::TTreeReaderFast reader(&tree);
ROOT::Experimental::TTreeReaderValueFast<float> px(reader, "px");
ROOT::Experimental::TTreeReaderValueFast<float> py(reader, "py");
ROOT::Experimental::TTreeReaderValueFast<float> pz(reader, "pz");
double total = 0.0;
// reader.SetEntry(0); If I uncomment this, the crash disappears
for (auto it = reader.begin(); it != reader.end(); ++it)
total += sqrt((*px) * (*px) + (*py) * (*py) + (*pz) * (*pz));
EXPECT_NEAR(total, 866026269930.1345215, 100);
}

// https://github.com/root-project/root/issues/20226
TEST(TTreeScan, IntOverflow)
{
Expand Down
Loading