Skip to content

Commit 4f04fe5

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

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
@@ -12,6 +12,8 @@
1212
#include "TLorentzVector.h"
1313
#include <Math/Vector3D.h>
1414
#include <ROOT/TestSupport.hxx>
15+
#include "ROOT/TTreeReaderValueFast.hxx"
16+
#include "TNtuple.h"
1517

1618
#include "TTreePlayer.h"
1719

@@ -340,6 +342,23 @@ TEST(TTreeReaderRegressions, XYZVectors)
340342
}
341343
}
342344

345+
// ROOT-8842 https://its.cern.ch/jira/browse/ROOT-8842
346+
TEST(TTreeReaderRegressions, ValueFastTuple)
347+
{
348+
TNtuple tree("tuple", "ROOT-8842", "px:py:pz:energy");
349+
for (auto i = 0; i < 1000000; ++i)
350+
tree.Fill(i, i + 1, i + 2, i + 3);
351+
ROOT::Experimental::TTreeReaderFast reader(&tree);
352+
ROOT::Experimental::TTreeReaderValueFast<float> px(reader, "px");
353+
ROOT::Experimental::TTreeReaderValueFast<float> py(reader, "py");
354+
ROOT::Experimental::TTreeReaderValueFast<float> pz(reader, "pz");
355+
double total = 0.0;
356+
// reader.SetEntry(0); If I uncomment this, the crash disappears
357+
for (auto it = reader.begin(); it != reader.end(); ++it)
358+
total += sqrt((*px) * (*px) + (*py) * (*py) + (*pz) * (*pz));
359+
EXPECT_NEAR(total, 866026269930.1345215, 100);
360+
}
361+
343362
// https://github.com/root-project/root/issues/20226
344363
TEST(TTreeScan, IntOverflow)
345364
{

0 commit comments

Comments
 (0)