-
Notifications
You must be signed in to change notification settings - Fork 1.5k
TEntryList + TChain reads wrong number of entries if reading the same file multiple times #8505
Copy link
Copy link
Closed
Description
- Checked for duplicates
Describe the bug
It is possible to construct a TChain that reads the same tree from the same file twice. It appears that if I create a TEntryList for said chain, it will only read the entries the first time, while the second read of the same file will be ignored.
Let's create a file with a tree and 20 entries. Something like this is enough
ROOT.RDataFrame(20).Define("x","rdfentry_").Snapshot("entries","file_20entries_1.root")Then the following snippet
#include <ROOT/RDataFrame.hxx>
#include <TChain.h>
#include <TEntryList.h>
#include <iostream>
int main(){
auto start_1{0};
auto start_2{0};
auto end_1{20};
auto end_2{10};
TEntryList elists;
TEntryList elist1{"e","e","entries","file_20entries_1.root"};
TEntryList elist2{"e","e","entries","file_20entries_1.root"};
for(auto entry = start_1; entry < end_1; entry++){
elist1.Enter(entry);
}
for(auto entry = start_2; entry < end_2; entry++){
elist2.Enter(entry);
}
elists.Add(&elist1);
elists.Add(&elist2);
TChain chain{"entries"};
chain.Add("file_20entries_1.root");
chain.Add("file_20entries_1.root");
chain.SetEntryList(&elists);
ROOT::RDataFrame df{chain};
std::cout << df.Count().GetValue() << "\n";
}Will output the following
vpadulan@fedorathinkpad-T550 [~/Projects/rootcode]: g++ -o tentrylist_emptysource_twofiles tentrylist_emptysource_twofiles.cpp `root-config --cflags --glibs`
vpadulan@fedorathinkpad-T550 [~/Projects/rootcode]: ./tentrylist_emptysource_twofiles
20
Expected behavior
The expected result of the above snippet is 30, that is 20 entries from the first TEntryList and 10 entries from the second. Note that, if I create a second file identical to the first one and call it file_20entries_2.root, changing the above snippet with
- TEntryList elist2{"e","e","entries","file_20entries_1.root"};
+ TEntryList elist2{"e","e","entries","file_20entries_2.root"};
...
TChain chain{"entries"};
chain.Add("file_20entries_1.root");
- chain.Add("file_20entries_1.root");
+ chain.Add("file_20entries_2.root");yields the correct result:
vpadulan@fedorathinkpad-T550 [~/Projects/rootcode]: g++ -o tentrylist_emptysource_twofiles tentrylist_emptysource_twofiles.cpp `root-config --cflags --glibs`
vpadulan@fedorathinkpad-T550 [~/Projects/rootcode]: ./tentrylist_emptysource_twofiles
30
To Reproduce
Everything above should be enough
Setup
ROOT master built from source on Fedora32
Reactions are currently unavailable