@@ -98,10 +98,30 @@ void ROOTObjectReaderModule::init() {
98
98
99
99
// Read all the trees in the file
100
100
TList* keys = input_file_->GetListOfKeys ();
101
+ std::set<std::string> tree_names;
102
+
101
103
for (auto && object : *keys) {
102
104
auto & key = dynamic_cast <TKey&>(*object);
103
105
if (std::string (key.GetClassName ()) == " TTree" ) {
104
- trees_.push_back (static_cast <TTree*>(key.ReadObjectAny (nullptr )));
106
+ auto tree = static_cast <TTree*>(key.ReadObjectAny (nullptr ));
107
+
108
+ // Check if a version of this tree has already been read
109
+ if (tree_names.find (tree->GetName ()) != tree_names.end ()) {
110
+ LOG (TRACE) << " Skipping copy of tree with name " << tree->GetName ()
111
+ << " because one with identical name has already been processed" ;
112
+ continue ;
113
+ }
114
+ tree_names.insert (tree->GetName ());
115
+
116
+ // Check if this tree should be used
117
+ if ((!include_.empty () && include_.find (tree->GetName ()) == include_.end ()) ||
118
+ (!exclude_.empty () && exclude_.find (tree->GetName ()) != exclude_.end ())) {
119
+ LOG (TRACE) << " Ignoring tree with " << tree->GetName ()
120
+ << " objects because it has been excluded or not explicitly included" ;
121
+ continue ;
122
+ }
123
+
124
+ trees_.push_back (tree);
105
125
}
106
126
}
107
127
@@ -111,14 +131,6 @@ void ROOTObjectReaderModule::init() {
111
131
112
132
// Loop over all found trees
113
133
for (auto & tree : trees_) {
114
- // Check if this tree should be used
115
- if ((!include_.empty () && include_.find (tree->GetName ()) == include_.end ()) ||
116
- (!exclude_.empty () && exclude_.find (tree->GetName ()) != exclude_.end ())) {
117
- LOG (TRACE) << " Ignoring tree with " << tree->GetName ()
118
- << " objects because it has been excluded or not explicitly included" ;
119
- continue ;
120
- }
121
-
122
134
// Loop over the list of branches and create the set of receiver objects
123
135
TObjArray* branches = tree->GetListOfBranches ();
124
136
for (int i = 0 ; i < branches->GetEntries (); i++) {
0 commit comments