@@ -82,7 +82,7 @@ class TRestDataSet : public TRestMetadata {
82
82
std::map<std::string, RelevantQuantity> fQuantity ; // <
83
83
84
84
// / Parameter cuts over the selected dataset
85
- TRestCut* fCut = nullptr ;
85
+ TRestCut* fCut = nullptr ; // <
86
86
87
87
// / The total integrated run time of selected files
88
88
Double_t fTotalDuration = 0 ; // <
@@ -103,12 +103,14 @@ class TRestDataSet : public TRestMetadata {
103
103
std::vector<std::string> fImportedFiles ; // <
104
104
105
105
// / A list of new columns together with its corresponding expressions added to the dataset
106
- std::vector<std::pair<std::string, std::string>> fColumnNameExpressions ;
106
+ std::vector<std::pair<std::string, std::string>> fColumnNameExpressions ; // <
107
107
108
108
// / A flag to enable Multithreading during dataframe generation
109
109
Bool_t fMT = false ; // <
110
110
111
- inline auto GetAddedColumns () const { return fColumnNameExpressions ; }
111
+ // If the dataframe was defined externally it will be true
112
+ Bool_t fExternal = false ; // <
113
+
112
114
// / The resulting RDF::RNode object after initialization
113
115
ROOT::RDF::RNode fDataSet = ROOT::RDataFrame(0 ); // !
114
116
@@ -123,20 +125,28 @@ class TRestDataSet : public TRestMetadata {
123
125
public:
124
126
// / Gives access to the RDataFrame
125
127
ROOT::RDF::RNode GetDataFrame () const {
126
- if (fTree == nullptr ) RESTWarning << " DataFrame has not been yet initialized" << RESTendl;
128
+ if (!fExternal && fTree == nullptr )
129
+ RESTWarning << " DataFrame has not been yet initialized" << RESTendl;
127
130
return fDataSet ;
128
131
}
129
132
130
- void SetDataFrame (const ROOT::RDF::RNode& dS) { fDataSet = dS; }
131
-
132
133
void EnableMultiThreading (Bool_t enable = true ) { fMT = enable; }
133
134
134
135
// / Gives access to the tree
135
136
TTree* GetTree () const {
137
+ if (fTree == nullptr && fExternal ) {
138
+ RESTInfo << " The tree is not accessible. Only GetDataFrame can be used in an externally "
139
+ " generated dataset"
140
+ << RESTendl;
141
+ RESTInfo << " You may write a tree using GetDataFrame()->Snapshot(\" MyTree\" , \" output.root\" );"
142
+ << RESTendl;
143
+ return fTree ;
144
+ }
145
+
136
146
if (fTree == nullptr ) {
137
147
RESTError << " Tree has not been yet initialized" << RESTendl;
138
- RESTError << " You should invoke TRestDataSet::GenerateDataSet() before trying to access the tree "
139
- << RESTendl;
148
+ RESTError << " You should invoke TRestDataSet::GenerateDataSet() or " << RESTendl;
149
+ RESTError << " TRestDataSet::Import( fname ) before trying to access the tree " << RESTendl;
140
150
}
141
151
return fTree ;
142
152
}
@@ -167,21 +177,27 @@ class TRestDataSet : public TRestMetadata {
167
177
inline auto GetFilterLowerThan () const { return fFilterLowerThan ; }
168
178
inline auto GetFilterEqualsTo () const { return fFilterEqualsTo ; }
169
179
inline auto GetQuantity () const { return fQuantity ; }
180
+ inline auto GetAddedColumns () const { return fColumnNameExpressions ; }
170
181
inline auto GetCut () const { return fCut ; }
171
182
inline auto IsMergedDataSet () const { return fMergedDataset ; }
172
183
173
184
inline void SetObservablesList (const std::vector<std::string>& obsList) { fObservablesList = obsList; }
174
185
inline void SetFilePattern (const std::string& pattern) { fFilePattern = pattern; }
175
186
inline void SetQuantity (const std::map<std::string, RelevantQuantity>& quantity) { fQuantity = quantity; }
176
187
188
+ void SetTotalTimeInSeconds (Double_t seconds) { fTotalDuration = seconds; }
189
+ void SetDataFrame (const ROOT::RDF::RNode& dS) {
190
+ fDataSet = dS;
191
+ fExternal = true ;
192
+ }
193
+
177
194
TRestDataSet& operator =(TRestDataSet& dS);
178
195
Bool_t Merge (const TRestDataSet& dS);
179
196
void Import (const std::string& fileName);
180
197
void Import (std::vector<std::string> fileNames);
181
- void Export (const std::string& filename);
198
+ void Export (const std::string& filename, std::vector<std::string> excludeColumns = {} );
182
199
183
200
ROOT::RDF::RNode MakeCut (const TRestCut* cut);
184
-
185
201
ROOT::RDF::RNode DefineColumn (const std::string& columnName, const std::string& formula);
186
202
187
203
void PrintMetadata () override ;
@@ -193,6 +209,6 @@ class TRestDataSet : public TRestMetadata {
193
209
TRestDataSet (const char * cfgFileName, const std::string& name = " " );
194
210
~TRestDataSet ();
195
211
196
- ClassDefOverride (TRestDataSet, 5 );
212
+ ClassDefOverride (TRestDataSet, 7 );
197
213
};
198
214
#endif
0 commit comments