@@ -109,6 +109,34 @@ public:
109
109
UntypedSnapshotRNTupleHelper MakeNew (void *newName);
110
110
};
111
111
112
+ // / Stores properties of each output branch in a Snapshot.
113
+ struct RBranchData {
114
+ std::string fInputBranchName ; // This contains resolved aliases
115
+ std::string fOutputBranchName ;
116
+ const std::type_info *fInputTypeID = nullptr ;
117
+ TBranch *fOutputBranch = nullptr ;
118
+ void *fBranchAddressForCArrays = nullptr ; // Used to detect if branch addresses need to be updated
119
+
120
+ std::unique_ptr<void , std::function<void (void *)>> fEmptyInstance ;
121
+ bool fIsCArray = false ;
122
+ bool fIsDefine = false ;
123
+
124
+ RBranchData (std::string inputBranchName, std::string outputBranchName, bool isDefine, const std::type_info *typeID,
125
+ TBranch *outputBranch = nullptr )
126
+ : fInputBranchName {std::move (inputBranchName)},
127
+ fOutputBranchName {std::move (outputBranchName)},
128
+ fInputTypeID {typeID},
129
+ fOutputBranch {outputBranch},
130
+ fIsDefine (isDefine)
131
+ {
132
+ }
133
+ void ClearBranchPointers ()
134
+ {
135
+ fOutputBranch = nullptr ;
136
+ fBranchAddressForCArrays = nullptr ;
137
+ }
138
+ };
139
+
112
140
class R__CLING_PTRCHECK (off) UntypedSnapshotTTreeHelper final : public RActionImpl<UntypedSnapshotTTreeHelper> {
113
141
std::string fFileName ;
114
142
std::string fDirName ;
@@ -117,17 +145,10 @@ class R__CLING_PTRCHECK(off) UntypedSnapshotTTreeHelper final : public RActionIm
117
145
std::unique_ptr<TFile> fOutputFile ;
118
146
std::unique_ptr<TTree> fOutputTree ; // must be a ptr because TTrees are not copy/move constructible
119
147
bool fBranchAddressesNeedReset {true };
120
- ColumnNames_t fInputBranchNames ; // This contains the resolved aliases
121
- ColumnNames_t fOutputBranchNames ;
122
148
TTree *fInputTree = nullptr ; // Current input tree. Set at initialization time (`InitTask`)
123
- // TODO we might be able to unify fBranches, fBranchAddresses and fOutputBranches
124
- std::vector<TBranch *> fBranches ; // Addresses of branches in output, non-null only for the ones holding C arrays
125
- std::vector<void *> fBranchAddresses ; // Addresses of objects associated to output branches
126
- RBranchSet fOutputBranches ;
127
- std::vector<bool > fIsDefine ;
149
+ std::vector<RBranchData> fBranchData ; // Information for all output branches
128
150
ROOT::Detail::RDF::RLoopManager *fOutputLoopManager ;
129
151
ROOT::Detail::RDF::RLoopManager *fInputLoopManager ;
130
- std::vector<const std::type_info *> fInputColumnTypeIDs ; // Types for the input columns
131
152
132
153
public:
133
154
UntypedSnapshotTTreeHelper (std::string_view filename, std::string_view dirname, std::string_view treename,
@@ -176,11 +197,7 @@ class R__CLING_PTRCHECK(off) UntypedSnapshotTTreeHelperMT final : public RAction
176
197
std::vector<std::unique_ptr<TTree>> fOutputTrees ;
177
198
std::vector<int > fBranchAddressesNeedReset ; // vector<bool> does not allow concurrent writing of different elements
178
199
std::vector<TTree *> fInputTrees ; // Current input trees, one per slot. Set at initialization time (`InitTask`)
179
- // Addresses of branches in output per slot, non-null only for the ones holding C arrays
180
- std::vector<std::vector<TBranch *>> fBranches ;
181
- // Addresses of objects associated to output branches per slot, non-null only for the ones holding C arrays
182
- std::vector<std::vector<void *>> fBranchAddresses ;
183
- std::vector<RBranchSet> fOutputBranches ; // Unique set of output branches, one per slot.
200
+ std::vector<std::vector<RBranchData>> fBranchData ; // Information for all output branches of each slot
184
201
185
202
// Attributes of the output TTree
186
203
@@ -189,16 +206,11 @@ class R__CLING_PTRCHECK(off) UntypedSnapshotTTreeHelperMT final : public RAction
189
206
std::string fTreeName ;
190
207
TFile *fOutputFile ; // Non-owning view on the output file
191
208
RSnapshotOptions fOptions ;
192
- std::vector<std::string> fOutputBranchNames ;
193
209
194
210
// Attributes related to the computation graph
195
211
196
212
ROOT::Detail::RDF::RLoopManager *fOutputLoopManager ;
197
213
ROOT::Detail::RDF::RLoopManager *fInputLoopManager ;
198
- std::vector<std::string> fInputBranchNames ; // This contains the resolved aliases
199
- std::vector<const std::type_info *> fInputColumnTypeIDs ; // Types for the input columns
200
-
201
- std::vector<bool > fIsDefine ;
202
214
203
215
public:
204
216
UntypedSnapshotTTreeHelperMT (unsigned int nSlots, std::string_view filename, std::string_view dirname,
0 commit comments