diff --git a/tree/treeplayer/test/CMakeLists.txt b/tree/treeplayer/test/CMakeLists.txt index c646594d889a0..e379b51ff5866 100644 --- a/tree/treeplayer/test/CMakeLists.txt +++ b/tree/treeplayer/test/CMakeLists.txt @@ -29,7 +29,8 @@ configure_file(data.h . COPYONLY) ROOT_ADD_GTEST(treeplayer_readerarray_iterator readerarray_iterator.cxx LIBRARIES TreePlayer) -ROOT_ADD_GTEST(treeplayer_regressions regressions.cxx LIBRARIES TreePlayer Physics) +ROOT_GENERATE_DICTIONARY(STLContInTObjDict ${CMAKE_CURRENT_SOURCE_DIR}/STLContInTObj.hxx LINKDEF STLContInTObjLinkDef.hxx DEPENDENCIES Core RIO) +ROOT_ADD_GTEST(treeplayer_regressions regressions.cxx STLContInTObjDict.cxx LIBRARIES TreePlayer Physics) ROOT_ADD_GTEST(ttreeindex_clone ttreeindex_clone.cxx LIBRARIES TreePlayer) diff --git a/tree/treeplayer/test/STLContInTObj.hxx b/tree/treeplayer/test/STLContInTObj.hxx new file mode 100644 index 0000000000000..f3811f0d7eae1 --- /dev/null +++ b/tree/treeplayer/test/STLContInTObj.hxx @@ -0,0 +1,16 @@ +#ifndef __Track_TObject__ +#define __Track_TObject__ + +#include "TObject.h" + +class Track : public TObject { +public: + std::vector hitEnergies; + int id = 42; + + Track(const std::vector &v = {}) : hitEnergies{v} {}; + + ClassDefOverride(Track, 1); +}; + +#endif diff --git a/tree/treeplayer/test/STLContInTObjLinkDef.hxx b/tree/treeplayer/test/STLContInTObjLinkDef.hxx new file mode 100644 index 0000000000000..df96535d51c19 --- /dev/null +++ b/tree/treeplayer/test/STLContInTObjLinkDef.hxx @@ -0,0 +1,5 @@ +#ifdef __CLING__ + +#pragma link C++ class Track+; + +#endif diff --git a/tree/treeplayer/test/regressions.cxx b/tree/treeplayer/test/regressions.cxx index 70a1ec839c87b..a3beba6aa3046 100644 --- a/tree/treeplayer/test/regressions.cxx +++ b/tree/treeplayer/test/regressions.cxx @@ -1,10 +1,12 @@ #include "TFile.h" #include "TSystem.h" #include "TClass.h" +#include "TClonesArray.h" #include "TChain.h" #include "TTree.h" #include "TTreeReader.h" #include "TTreeReaderValue.h" +#include "TTreeReaderArray.h" #include "TROOT.h" #include "TH1.h" #include "TTreeFormula.h" @@ -359,6 +361,32 @@ TEST(TTreeReaderRegressions, ValueFastTuple) EXPECT_NEAR(total, 866026269930.1345215, 100); } +// https://github.com/root-project/root/issues/11769 +TEST(TTreeReaderRegressions, STLContainerNestedInTClonesArray) +{ + const auto fileName = "tree_11769.root"; + const auto treeName = "tree_11769"; + gInterpreter->AutoLoad("Track"); + ROOT::TestSupport::FileRaii fileGuard{fileName}; + { + std::unique_ptr file{TFile::Open(fileGuard.GetPath().c_str(), "recreate")}; + auto tree = std::make_unique(treeName, treeName); + auto arr = std::make_unique("Track", 1); + + tree->Branch("Tracks", arr.get()); + + tree->Fill(); + tree->Write(); + //file->Close(); + } + std::unique_ptr file{TFile::Open(fileName)}; + TTreeReader r(treeName, file.get()); + TTreeReaderArray> tracks(r, "Tracks.hitEnergies"); + ROOT::TestSupport::CheckDiagsRAII diags; + diags.requiredDiag(kError, "TTreeReaderArrayBase::SetImpl", "STL Collection nested in a TClonesArray not yet supported", /*matchFullMessage=*/false); + r.Next(); +} + // ROOT-8000 https://its.cern.ch/jira/browse/ROOT-8000 // An unrelated file lying around in the current directory whose name matches // the leading part of a formula (e.g. a file named "abs") must not make