Skip to content

Commit cfc520f

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

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

@@ -263,3 +265,20 @@ TEST(TTreeFormulaRegressions, WrongName)
263265
EXPECT_EQ(t.Draw("s.Eta()", ""), -1);
264266
}
265267
}
268+
269+
// ROOT-8842
270+
TEST(TTreeReaderRegressions, ValueFastTuple)
271+
{
272+
TNtuple tree("tuple", "ROOT-8842", "px:py:pz:energy");
273+
for(auto i=0; i<1000000; ++i)
274+
tree.Fill(i,i+1,i+2,i+3);
275+
ROOT::Experimental::TTreeReaderFast reader(&tree);
276+
ROOT::Experimental::TTreeReaderValueFast<float> px(reader, "px");
277+
ROOT::Experimental::TTreeReaderValueFast<float> py(reader, "py");
278+
ROOT::Experimental::TTreeReaderValueFast<float> pz(reader, "pz");
279+
double total = 0.0;
280+
// reader.SetEntry(0); If I uncomment this, the crash disappears
281+
for (auto it = reader.begin(); it != reader.end(); ++it)
282+
total += sqrt((*px)*(*px) + (*py)*(*py) + (*pz)*(*pz));
283+
EXPECT_EQ(total, 8.6602627e+11);
284+
}

0 commit comments

Comments
 (0)