Skip to content

Commit 541edd8

Browse files
eguirauddpiparo
authored andcommitted
[TDF] Validate columns in Defines
1 parent f05b7e9 commit 541edd8

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tree/treeplayer/inc/ROOT/TDFInterface.hxx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public:
259259
/// \param[in] name The name of the temporary branch.
260260
/// \param[in] expression Function, lambda expression, functor class or any other callable object producing the
261261
/// temporary value. Returns the value that will be assigned to the temporary branch.
262-
/// \param[in] bl Names of the branches in input to the producer function.
262+
/// \param[in] columns Names of the branches in input to the producer function.
263263
///
264264
/// Create a temporary branch that will be visible from all subsequent nodes
265265
/// of the functional chain. The `expression` is only evaluated for entries that pass
@@ -276,19 +276,17 @@ public:
276276
/// An exception is thrown if the name of the new branch is already in use
277277
/// for another branch in the TTree.
278278
template <typename F, typename std::enable_if<!std::is_convertible<F, std::string>::value, int>::type = 0>
279-
TInterface<TCustomColumnBase> Define(std::string_view name, F expression, const ColumnNames_t &bl = {})
279+
TInterface<TCustomColumnBase> Define(std::string_view name, F expression, const ColumnNames_t &columns = {})
280280
{
281-
auto df = GetDataFrameChecked();
282-
TDFInternal::CheckTmpBranch(name, df->GetTree());
283-
const ColumnNames_t &defBl = df->GetDefaultColumnNames();
284-
auto nArgs = TTraits::CallableTraits<F>::arg_types::list_size;
285-
const auto actualBl = TDFInternal::SelectColumns(nArgs, bl, defBl);
286-
using DFB_t = TDFDetail::TCustomColumn<F, Proxied>;
281+
auto loopManager = GetDataFrameChecked();
282+
TDFInternal::CheckTmpBranch(name, loopManager->GetTree());
283+
auto nColumns = TTraits::CallableTraits<F>::arg_types::list_size;
284+
const auto validColumnNames = GetValidatedColumnNames(*loopManager, nColumns, columns);
285+
using loopManagerB_t = TDFDetail::TCustomColumn<F, Proxied>;
287286
const std::string nameInt(name);
288-
auto BranchPtr = std::make_shared<DFB_t>(nameInt, std::move(expression), actualBl, *fProxiedPtr);
289-
df->Book(BranchPtr);
290-
TInterface<TCustomColumnBase> tdf_b(BranchPtr, fImplWeakPtr);
291-
return tdf_b;
287+
auto BranchPtr = std::make_shared<loopManagerB_t>(nameInt, std::move(expression), validColumnNames, *fProxiedPtr);
288+
loopManager->Book(BranchPtr);
289+
return TInterface<TCustomColumnBase>(BranchPtr, fImplWeakPtr);
292290
}
293291

294292
////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)