From f7982b9ce82714405fd06d5dd0eeeef6dc430876 Mon Sep 17 00:00:00 2001 From: Danilo Piparo <danilo.piparo@cern.ch> Date: Thu, 9 May 2019 12:09:37 +0200 Subject: [PATCH] [TTreeProcessorMT] Properly reconstruct TEntryList in the TChain case for example when the TEntryList contains sub lists, matching with the name of the file and tree whenever needed. --- tree/treeplayer/src/TTreeProcessorMT.cxx | 42 +++++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tree/treeplayer/src/TTreeProcessorMT.cxx b/tree/treeplayer/src/TTreeProcessorMT.cxx index b216e287347..794c3216803 100644 --- a/tree/treeplayer/src/TTreeProcessorMT.cxx +++ b/tree/treeplayer/src/TTreeProcessorMT.cxx @@ -82,17 +82,41 @@ TTreeView::MakeReaderWithEntryList(TEntryList &globalList, Long64_t start, Long6 { // TEntryList and SetEntriesRange do not work together (the former has precedence). // We need to construct a TEntryList that contains only those entry numbers in our desired range. + + std::vector<TEntryList*> globalEntryLists; + auto innerLists = globalList.GetLists(); + if (!innerLists) { + globalEntryLists.emplace_back(&globalList); + } else { + for (auto lp : *innerLists) { + globalEntryLists.emplace_back(static_cast<TEntryList*>(lp)); + } + } + auto localList = std::make_unique<TEntryList>(); - // We call GetEntry twice: workaround for ROOT-10113 (the return value for 1 call only could be -1) - globalList.GetEntry(0); - Long64_t entry = globalList.GetEntry(0); - do { - if (entry >= end) { - break; - } else if (entry >= start) { - localList->Enter(entry); + + for (auto gl : globalEntryLists) { + // We call GetEntry twice: workaround for ROOT-10113 (the return value for 1 call only could be -1) + gl->GetEntry(0); + Long64_t entry = gl->GetEntry(0); + + // this may be owned by the local list + auto tmp_list = new TEntryList(gl->GetName(), gl->GetTitle(), gl->GetFileName(), gl->GetTreeName()); + + do { + if (entry >= end) { + break; + } else if (entry >= start) { + tmp_list->Enter(entry); + } + } while ((entry = gl->Next()) >= 0); + + if (tmp_list->GetN() > 0) { + localList->Add(tmp_list); + } else { + delete tmp_list; } - } while ((entry = globalList.Next()) >= 0); + } auto reader = std::make_unique<TTreeReader>(fChain.get(), localList.get()); return std::make_pair(std::move(reader), std::move(localList)); -- GitLab