Skip to content

Commit 30daea9

Browse files
committed
[tree] add unit test for ttreereadervaluefast bug
See https://its.cern.ch/jira/browse/ROOT-8842
1 parent 38cc14d commit 30daea9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tree/treeplayer/test/regressions.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "TString.h"
1111
#include "TLorentzVector.h"
1212
#include <ROOT/TestSupport.hxx>
13+
#include "ROOT/TTreeReaderValueFast.hxx"
14+
#include "TNtuple.h"
1315

1416
#include "gtest/gtest.h"
1517

@@ -291,3 +293,20 @@ TEST(TTreeReaderRegressions, UninitializedChain)
291293
}
292294
gSystem->Unlink(filename);
293295
}
296+
297+
// ROOT-8842
298+
TEST(TTreeReaderRegressions, ValueFastTuple)
299+
{
300+
TNtuple tree("tuple", "ROOT-8842", "px:py:pz:energy");
301+
for (auto i = 0; i < 1000000; ++i)
302+
tree.Fill(i, i + 1, i + 2, i + 3);
303+
ROOT::Experimental::TTreeReaderFast reader(&tree);
304+
ROOT::Experimental::TTreeReaderValueFast<float> px(reader, "px");
305+
ROOT::Experimental::TTreeReaderValueFast<float> py(reader, "py");
306+
ROOT::Experimental::TTreeReaderValueFast<float> pz(reader, "pz");
307+
double total = 0.0;
308+
// reader.SetEntry(0); If I uncomment this, the crash disappears
309+
for (auto it = reader.begin(); it != reader.end(); ++it)
310+
total += sqrt((*px) * (*px) + (*py) * (*py) + (*pz) * (*pz));
311+
EXPECT_NEAR(total, 866026269930.1345215, 1);
312+
}

0 commit comments

Comments
 (0)