11#ifndef ROOT_RDF_TINTERFACE_UTILS
12#define ROOT_RDF_TINTERFACE_UTILS
33#include <RConfigure.h>
55template <
typename Proxied>
71std::string DemangleTypeIdName(
const std::type_info &typeInfo);
74ConvertRegexToColumns(
const ColumnNames_t &colNames, std::string_view columnNameRegexp, std::string_view callerName);
77class RIgnoreErrorLevelRAII {
82 RIgnoreErrorLevelRAII(
int errorIgnoreLevel) {
gErrorIgnoreLevel = errorIgnoreLevel; }
95struct HistoNSparseD{};
97struct HistWithWeight{};
99struct GraphAsymmErrors{};
103struct ProfileWithWeight{};
117template <
typename T,
bool ISV6HISTO = std::is_base_of<TH1, std::decay_t<T>>::value>
119 static bool HasAxisLimits(T &
h)
121 auto xaxis =
h.GetXaxis();
122 return !(xaxis->GetXmin() == 0. && xaxis->GetXmax() == 0.);
127struct HistoUtils<T, false> {
128 static bool HasAxisLimits(T &) {
return true; }
132template <
typename... ColTypes,
typename ActionTag,
typename ActionResultType,
typename PrevNodeType>
133std::unique_ptr<RActionBase>
134BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<ActionResultType> &
h,
const unsigned int nSlots,
135 std::shared_ptr<PrevNodeType> prevNode, ActionTag,
const RColumnRegister &colRegister)
137 using Helper_t = FillHelper<ActionResultType>;
138 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
139 return std::make_unique<Action_t>(Helper_t(
h, nSlots), bl, std::move(prevNode), colRegister);
143template <
typename... ColTypes,
typename PrevNodeType>
144std::unique_ptr<RActionBase>
145BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<::TH1D> &
h,
const unsigned int nSlots,
146 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Histo1D,
const RColumnRegister &colRegister)
148 auto hasAxisLimits = HistoUtils<::TH1D>::HasAxisLimits(*
h);
151 using Helper_t = FillHelper<::TH1D>;
152 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
153 return std::make_unique<Action_t>(Helper_t(
h, nSlots), bl, std::move(prevNode), colRegister);
155 using Helper_t = BufferedFillHelper;
156 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
157 return std::make_unique<Action_t>(Helper_t(
h, nSlots), bl, std::move(prevNode), colRegister);
162template <
typename... ColTypes,
typename ActionResultType,
typename PrevNodeType>
163std::unique_ptr<RActionBase>
164BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<ActionResultType> &
h,
const unsigned int nSlots,
165 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Histo3D,
const RColumnRegister &colRegister)
168 using Helper_t = FillHelper<ActionResultType>;
169 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
170 return std::make_unique<Action_t>(Helper_t(
h, nSlots), bl, std::move(prevNode), colRegister);
172 using Helper_t = ThreadSafeFillHelper<ActionResultType>;
173 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
174 if constexpr (
sizeof...(ColTypes) > 3) {
178 return std::make_unique<Action_t>(Helper_t(
h, histoSlots), bl, std::move(prevNode), colRegister);
184template <
typename... ColTypes,
typename BinContentType,
typename PrevNodeType>
185std::unique_ptr<RActionBase>
187 const unsigned int nSlots, std::shared_ptr<PrevNodeType> prevNode, ActionTags::Hist,
188 const RColumnRegister &colRegister)
190 using Helper_t = RHistFillHelper<BinContentType>;
191 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
192 return std::make_unique<Action_t>(Helper_t(
h, nSlots), columnList, std::move(prevNode), colRegister);
196template <
typename... ColTypes,
typename BinContentType,
typename PrevNodeType>
197std::unique_ptr<RActionBase>
199 const unsigned int nSlots, std::shared_ptr<PrevNodeType> prevNode, ActionTags::HistWithWeight,
200 const RColumnRegister &colRegister)
202 using Helper_t = RHistFillHelper<BinContentType, true>;
203 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
204 return std::make_unique<Action_t>(Helper_t(
h, nSlots), columnList, std::move(prevNode), colRegister);
208template <
typename... ColTypes,
typename BinContentType,
typename PrevNodeType>
209std::unique_ptr<RActionBase>
211 const unsigned int, std::shared_ptr<PrevNodeType> prevNode, ActionTags::Hist,
212 const RColumnRegister &colRegister)
214 using Helper_t = RHistEngineFillHelper<BinContentType>;
215 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
216 return std::make_unique<Action_t>(Helper_t(
h), columnList, std::move(prevNode), colRegister);
220template <
typename... ColTypes,
typename BinContentType,
typename PrevNodeType>
221std::unique_ptr<RActionBase>
223 const unsigned int, std::shared_ptr<PrevNodeType> prevNode, ActionTags::HistWithWeight,
224 const RColumnRegister &colRegister)
226 using Helper_t = RHistEngineFillHelper<BinContentType, true>;
227 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
228 return std::make_unique<Action_t>(Helper_t(
h), columnList, std::move(prevNode), colRegister);
232template <
typename... ColTypes,
typename PrevNodeType>
233std::unique_ptr<RActionBase>
234BuildAction(
const ColumnNames_t &columnList,
const std::shared_ptr<ROOT::Experimental::RProfile> &
p,
235 const unsigned int nSlots, std::shared_ptr<PrevNodeType> prevNode, ActionTags::Profile,
236 const RColumnRegister &colRegister)
238 using Helper_t = RProfileFillHelper<>;
239 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
240 return std::make_unique<Action_t>(Helper_t(
p, nSlots), columnList, std::move(prevNode), colRegister);
244template <
typename... ColTypes,
typename PrevNodeType>
245std::unique_ptr<RActionBase>
246BuildAction(
const ColumnNames_t &columnList,
const std::shared_ptr<ROOT::Experimental::RProfile> &
p,
247 const unsigned int nSlots, std::shared_ptr<PrevNodeType> prevNode, ActionTags::ProfileWithWeight,
248 const RColumnRegister &colRegister)
250 using Helper_t = RProfileFillHelper<true>;
251 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
252 return std::make_unique<Action_t>(Helper_t(
p, nSlots), columnList, std::move(prevNode), colRegister);
256template <
typename... ColTypes,
typename PrevNodeType>
257std::unique_ptr<RActionBase>
258BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<TGraph> &
g,
const unsigned int nSlots,
259 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Graph,
const RColumnRegister &colRegister)
261 using Helper_t = FillTGraphHelper;
262 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
263 return std::make_unique<Action_t>(Helper_t(
g, nSlots), bl, std::move(prevNode), colRegister);
266template <
typename... ColTypes,
typename PrevNodeType>
267std::unique_ptr<RActionBase>
268BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<TGraphAsymmErrors> &
g,
const unsigned int nSlots,
269 std::shared_ptr<PrevNodeType> prevNode, ActionTags::GraphAsymmErrors,
const RColumnRegister &colRegister)
271 using Helper_t = FillTGraphAsymmErrorsHelper;
272 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
273 return std::make_unique<Action_t>(Helper_t(
g, nSlots), bl, std::move(prevNode), colRegister);
277template <
typename ColType,
typename PrevNodeType,
typename ActionResultType>
278std::unique_ptr<RActionBase>
279BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<ActionResultType> &minV,
const unsigned int nSlots,
280 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Min,
const RColumnRegister &colRegister)
282 using Helper_t = MinHelper<ActionResultType>;
283 using Action_t = RAction<Helper_t, PrevNodeType, TTraits::TypeList<ColType>>;
284 return std::make_unique<Action_t>(Helper_t(minV, nSlots), bl, std::move(prevNode), colRegister);
288template <
typename ColType,
typename PrevNodeType,
typename ActionResultType>
289std::unique_ptr<RActionBase>
290BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<ActionResultType> &maxV,
const unsigned int nSlots,
291 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Max,
const RColumnRegister &colRegister)
293 using Helper_t = MaxHelper<ActionResultType>;
294 using Action_t = RAction<Helper_t, PrevNodeType, TTraits::TypeList<ColType>>;
295 return std::make_unique<Action_t>(Helper_t(maxV, nSlots), bl, std::move(prevNode), colRegister);
299template <
typename ColType,
typename PrevNodeType,
typename ActionResultType>
300std::unique_ptr<RActionBase>
301BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<ActionResultType> &sumV,
const unsigned int nSlots,
302 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Sum,
const RColumnRegister &colRegister)
304 using Helper_t = SumHelper<ActionResultType>;
305 using Action_t = RAction<Helper_t, PrevNodeType, TTraits::TypeList<ColType>>;
306 return std::make_unique<Action_t>(Helper_t(sumV, nSlots), bl, std::move(prevNode), colRegister);
310template <
typename ColType,
typename PrevNodeType>
311std::unique_ptr<RActionBase>
312BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<double> &meanV,
const unsigned int nSlots,
313 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Mean,
const RColumnRegister &colRegister)
315 using Helper_t = MeanHelper;
316 using Action_t = RAction<Helper_t, PrevNodeType, TTraits::TypeList<ColType>>;
317 return std::make_unique<Action_t>(Helper_t(meanV, nSlots), bl, std::move(prevNode), colRegister);
321template <
typename ColType,
typename PrevNodeType>
322std::unique_ptr<RActionBase>
323BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<double> &stdDeviationV,
const unsigned int nSlots,
324 std::shared_ptr<PrevNodeType> prevNode, ActionTags::StdDev,
const RColumnRegister &colRegister)
326 using Helper_t = StdDevHelper;
327 using Action_t = RAction<Helper_t, PrevNodeType, TTraits::TypeList<ColType>>;
328 return std::make_unique<Action_t>(Helper_t(stdDeviationV, nSlots), bl, prevNode, colRegister);
332template <
typename ColType,
typename PrevNodeType>
333std::unique_ptr<RActionBase>
334BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<double> &meanV,
const unsigned int nSlots,
335 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Median,
const RColumnRegister &colRegister)
337 using Helper_t = MedianHelper;
338 using Action_t = RAction<Helper_t, PrevNodeType, TTraits::TypeList<ColType>>;
339 return std::make_unique<Action_t>(Helper_t(meanV, nSlots), bl, std::move(prevNode), colRegister);
342using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<ROOT::RDF::RDisplay>>;
345template <
typename... ColTypes,
typename PrevNodeType>
346std::unique_ptr<RActionBase>
347BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<displayHelperArgs_t> &helperArgs,
const unsigned int,
348 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Display,
const RColumnRegister &colRegister)
350 using Helper_t = DisplayHelper<PrevNodeType>;
351 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
352 return std::make_unique<Action_t>(Helper_t(helperArgs->first, helperArgs->second, prevNode), bl, prevNode,
356struct SnapshotHelperArgs {
357 std::string fFileName;
358 std::string fDirName;
359 std::string fTreeName;
360 std::vector<std::string> fOutputColNames;
365 bool fIncludeVariations;
368template <
typename PrevNodeType>
369std::unique_ptr<RActionBase>
370BuildAction(
const ColumnNames_t &colNames,
const std::shared_ptr<SnapshotHelperArgs> &snapHelperArgs,
371 const unsigned int nSlots, std::shared_ptr<PrevNodeType> prevNode,
const RColumnRegister &colRegister,
372 const std::vector<const std::type_info *> &colTypeIDs)
374 const auto &
filename = snapHelperArgs->fFileName;
375 const auto &dirname = snapHelperArgs->fDirName;
376 const auto &treename = snapHelperArgs->fTreeName;
377 const auto &outputColNames = snapHelperArgs->fOutputColNames;
378 const auto &options = snapHelperArgs->fOptions;
379 const auto &outputLM = snapHelperArgs->fOutputLoopManager;
380 const auto &inputLM = snapHelperArgs->fInputLoopManager;
382 auto sz = colNames.size();
383 std::vector<bool> isDefine(sz);
384 for (
auto i = 0u; i < sz; ++i)
385 isDefine[i] = colRegister.IsDefineOrAlias(colNames[i]);
387 std::unique_ptr<RActionBase> actionPtr;
388 if (snapHelperArgs->fToNTuple) {
390 using Helper_t = UntypedSnapshotRNTupleHelper;
391 using Action_t = RActionSnapshot<Helper_t, PrevNodeType>;
393 actionPtr.reset(
new Action_t(Helper_t(nSlots,
filename, dirname, treename, colNames, outputColNames, options,
394 inputLM, outputLM, colTypeIDs),
395 colNames, colTypeIDs, prevNode, colRegister));
399 if (snapHelperArgs->fIncludeVariations) {
400 using Helper_t = SnapshotHelperWithVariations;
401 using Action_t = RActionSnapshot<Helper_t, PrevNodeType>;
402 actionPtr.reset(
new Action_t(Helper_t(
filename, dirname, treename, colNames, outputColNames, options,
403 std::move(isDefine), outputLM, inputLM, colTypeIDs),
404 colNames, colTypeIDs, prevNode, colRegister));
406 using Helper_t = UntypedSnapshotTTreeHelper;
407 using Action_t = RActionSnapshot<Helper_t, PrevNodeType>;
408 actionPtr.reset(
new Action_t(Helper_t(
filename, dirname, treename, colNames, outputColNames, options,
409 std::move(isDefine), outputLM, inputLM, colTypeIDs),
410 colNames, colTypeIDs, prevNode, colRegister));
413 if (snapHelperArgs->fIncludeVariations) {
414 throw std::invalid_argument(
"Multi-threaded snapshot with variations is not supported yet.");
417 using Helper_t = UntypedSnapshotTTreeHelperMT;
418 using Action_t = RActionSnapshot<Helper_t, PrevNodeType>;
419 actionPtr.reset(
new Action_t(Helper_t(nSlots,
filename, dirname, treename, colNames, outputColNames, options,
420 std::move(isDefine), outputLM, inputLM, colTypeIDs),
421 colNames, colTypeIDs, prevNode, colRegister));
428template <
typename PrevNodeType>
429std::unique_ptr<RActionBase>
430BuildAction(
const ColumnNames_t &colNames,
const std::vector<const std::type_info *> &colTypeIDs,
431 const std::shared_ptr<ROOT::RVecF> &location,
const std::vector<std::size_t> &vecSizes,
float vecPadding,
432 std::shared_ptr<PrevNodeType> prevNode,
const RColumnRegister &colRegister)
436 return std::make_unique<Action_t>(Helper_t(location, colTypeIDs, vecSizes, vecPadding), colNames, colTypeIDs,
437 prevNode, colRegister);
441template <
typename... ColTypes,
typename PrevNodeType,
typename Helper_t>
442std::unique_ptr<RActionBase>
443BuildAction(
const ColumnNames_t &bl,
const std::shared_ptr<Helper_t> &
h,
const unsigned int ,
444 std::shared_ptr<PrevNodeType> prevNode, ActionTags::Book,
const RColumnRegister &colRegister)
446 using Action_t = RAction<Helper_t, PrevNodeType,
TTraits::TypeList<ColTypes...>>;
447 return std::make_unique<Action_t>(Helper_t(std::move(*
h)), bl, std::move(prevNode), colRegister);
452template <
typename Filter>
453void CheckFilter(Filter &)
455 using FilterRet_t =
typename RDF::CallableTraits<Filter>::ret_type;
456 static_assert(std::is_convertible<FilterRet_t, bool>::value,
457 "filter expression returns a type that is not convertible to bool");
460ColumnNames_t FilterArraySizeColNames(
const ColumnNames_t &columnNames,
const std::string &action);
462void CheckValidCppVarName(std::string_view var,
const std::string &where);
464void CheckForRedefinition(
const std::string &where, std::string_view definedCol,
const RColumnRegister &colRegister,
465 const ColumnNames_t &dataSourceColumns);
467void CheckForDefinition(
const std::string &where, std::string_view definedColView,
const RColumnRegister &colRegister,
468 const ColumnNames_t &dataSourceColumns);
470void CheckForNoVariations(
const std::string &where, std::string_view definedColView,
471 const RColumnRegister &colRegister);
475std::shared_ptr<RJittedFilter> BookFilterJit(std::shared_ptr<RNodeBase> prevNode, std::string_view
name,
476 std::string_view expression,
const RColumnRegister &colRegister,
479std::shared_ptr<RJittedDefine> BookDefineJit(std::string_view
name, std::string_view expression,
RLoopManager &lm,
480 RDataSource *ds,
const RColumnRegister &colRegister);
482std::shared_ptr<RJittedDefine> BookDefinePerSampleJit(std::string_view
name, std::string_view expression,
485std::shared_ptr<RJittedVariation>
486BookVariationJit(
const std::vector<std::string> &colNames, std::string_view variationName,
487 const std::vector<std::string> &variationTags, std::string_view expression,
RLoopManager &lm,
488 RDataSource *ds,
const RColumnRegister &colRegister,
bool isSingleColumn,
489 const std::string &varyColType);
491std::string JitBuildAction(
const ColumnNames_t &bl,
const std::type_info &art,
const std::type_info &at,
TTree *tree,
492 const unsigned int nSlots,
const RColumnRegister &colRegister,
RDataSource *ds,
493 const bool vector2RVec =
true);
495bool AtLeastOneEmptyString(
const std::vector<std::string_view> strings);
499std::shared_ptr<RNodeBase> UpcastNode(std::shared_ptr<RNodeBase> ptr);
501ColumnNames_t GetValidatedColumnNames(
RLoopManager &lm,
const unsigned int nColumns,
const ColumnNames_t &columns,
502 const RColumnRegister &validDefines,
RDataSource *ds);
504std::vector<std::string> GetValidatedArgTypes(
const ColumnNames_t &colNames,
const RColumnRegister &colRegister,
509void AddDSColumnsHelper(
const std::string &colName,
RLoopManager &lm,
RDataSource &ds, RColumnRegister &colRegister)
512 if (colRegister.IsDefineOrAlias(colName))
523 std::vector<std::unique_ptr<RColumnReaderBase>> colReaders;
524 colReaders.reserve(nSlots);
527 if (!valuePtrs.empty()) {
528 for (
auto *ptr : valuePtrs)
529 colReaders.emplace_back(
new RDSColumnReader<T>(ptr));
533 for (
auto slot = 0u; slot < lm.
GetNSlots(); ++slot)
534 colReaders.emplace_back(
543template <
typename... ColumnTypes>
548 using expander =
int[];
550 (void)expander{(AddDSColumnsHelper<ColumnTypes>(requiredCols[i], lm, ds, colRegister), ++i)..., 0};
559void JitFilterHelper(F &&
f,
const ColumnNames_t &cols, RColumnRegister &colRegister,
569 using Callable_t = std::decay_t<F>;
571 using PrevNode_t =
typename decltype(prevNode)::element_type;
573 using ColTypes_t =
typename TTraits::CallableTraits<Callable_t>::arg_types;
574 constexpr auto nColumns = ColTypes_t::list_size;
579 if (ds !=
nullptr && !cols.empty())
580 AddDSColumns(cols, lm, *ds, ColTypes_t(), colRegister);
583 std::unique_ptr<RFilterBase>(
new F_t(std::forward<F>(
f), cols, prevNode, colRegister, jittedFilter->
GetName())));
586namespace DefineTypes {
588struct RDefinePerSampleTag {};
592auto MakeDefineNode(DefineTypes::RDefineTag, std::string_view
name, std::string_view dummyType, F &&
f,
593 const ColumnNames_t &cols, RColumnRegister &colRegister,
RLoopManager &lm)
596 name, dummyType, std::forward<F>(
f), cols, colRegister, lm));
600auto MakeDefineNode(DefineTypes::RDefinePerSampleTag, std::string_view
name, std::string_view dummyType, F &&
f,
601 const ColumnNames_t &, RColumnRegister &,
RLoopManager &lm)
603 return std::unique_ptr<RDefineBase>(
610template <
typename RDefineTypeTag,
typename F>
611void JitDefineHelper(F &&
f,
const ColumnNames_t &cols, RColumnRegister &colRegister,
621 using Callable_t = std::decay_t<F>;
622 using ColTypes_t =
typename TTraits::CallableTraits<Callable_t>::arg_types;
625 if (ds !=
nullptr && !cols.empty())
626 AddDSColumns(cols, lm, *ds, ColTypes_t(), colRegister);
630 const auto dummyType =
"jittedCol_t";
632 std::unique_ptr<RDefineBase> newCol{
633 MakeDefineNode(RDefineTypeTag{}, jittedDefine->
GetName(), dummyType, std::forward<F>(
f), cols, colRegister, lm)};
634 jittedDefine->
SetDefine(std::move(newCol));
637template <
bool IsSingleColumn,
typename F>
638void JitVariationHelper(F &&
f,
const ColumnNames_t &inputColNames, RColumnRegister &colRegister,
640 const ColumnNames_t &variedColNames,
const ColumnNames_t &variationTags)
noexcept
643 if (!jittedVariation) {
649 using Callable_t = std::decay_t<F>;
650 using ColTypes_t =
typename TTraits::CallableTraits<Callable_t>::arg_types;
653 if (ds !=
nullptr && !inputColNames.empty())
654 AddDSColumns(inputColNames, lm, *ds, ColTypes_t(), colRegister);
657 std::unique_ptr<RVariationBase> newVariation{
new RVariation<std::decay_t<F>, IsSingleColumn>(
658 variedColNames, jittedVariation->GetVariationName(), std::forward<F>(
f), variationTags,
659 jittedVariation->GetTypeName(), colRegister, lm, inputColNames)};
660 jittedVariation->SetVariation(std::move(newVariation));
664template <
typename ActionTag,
typename... ColTypes,
typename HelperArgType>
666 RJittedAction *jittedAction,
unsigned int nSlots,
667 std::shared_ptr<HelperArgType> *helperArg)
noexcept
675 using ColTypes_t =
TypeList<ColTypes...>;
676 constexpr auto nColumns = ColTypes_t::list_size;
678 if (ds !=
nullptr && !cols.empty())
679 AddDSColumns(cols, lm, *ds, ColTypes_t(), colRegister);
682 BuildAction<ColTypes...>(cols, *helperArg, nSlots, jittedAction->MoveOutPrevNode(), ActionTag{}, colRegister);
683 jittedAction->SetAction(std::move(actionPtr));
687template <typename T, bool Container = IsDataContainer<T>::value && !std::is_same<T, std::string>::value>
688struct RMinReturnType {
698struct RMinReturnType<T, true> {
699 using type = TTraits::TakeFirstParameter_t<T>;
703template <
typename R,
typename F,
typename... Args>
706 return [
f](
unsigned int, Args...
a)
mutable ->
R {
return f(
a...); };
709template <
typename ColType,
typename... Rest>
710struct RNeedJittingHelper {
711 static constexpr bool value = RNeedJittingHelper<Rest...>
::value;
714template <
typename... Rest>
716 static constexpr bool value =
true;
720struct RNeedJittingHelper<T> {
721 static constexpr bool value =
false;
726 static constexpr bool value =
true;
729template <
typename ...ColTypes>
731 static constexpr bool value = RNeedJittingHelper<ColTypes...>
::value;
735struct RNeedJitting<> {
736 static constexpr bool value =
false;
743template <
typename R,
typename Merge,
typename U,
typename T,
typename decayedU = std::decay_t<U>,
744 typename mergeArgsNoDecay_t =
typename CallableTraits<Merge>::arg_types_nodecay,
745 typename mergeArgs_t =
typename CallableTraits<Merge>::arg_types,
746 typename mergeRet_t =
typename CallableTraits<Merge>::ret_type>
749 constexpr bool isAggregatorOk =
750 (std::is_same<R, decayedU>::value) || (std::is_same<R, void>::value && std::is_lvalue_reference<U>::value);
751 static_assert(isAggregatorOk,
"aggregator function must have signature `U(U,T)` or `void(U&,T)`");
752 constexpr bool isMergeOk =
753 (std::is_same<TypeList<decayedU, decayedU>, mergeArgs_t>
::value && std::is_same<decayedU, mergeRet_t>::value) ||
754 (std::is_same<
TypeList<std::vector<decayedU> &>, mergeArgsNoDecay_t>
::value &&
755 std::is_same<void, mergeRet_t>::value);
756 static_assert(isMergeOk,
"merge function must have signature `U(U,U)` or `void(std::vector<U>&)`");
761template <
typename R,
typename T>
762void CheckAggregate(T)
764 static_assert(
sizeof(T) == 0,
"aggregator function must take exactly two arguments");
769void CheckTypesAndPars(
unsigned int nTemplateParams,
unsigned int nColumnNames);
772const ColumnNames_t SelectColumns(
unsigned int nArgs,
const ColumnNames_t &bl,
const ColumnNames_t &defBl);
775ColumnNames_t FindUnknownColumns(
const ColumnNames_t &requiredCols,
const RColumnRegister &definedCols,
776 const ColumnNames_t &dataSourceColumns);
779std::vector<std::string> GetFilterNames(
const std::shared_ptr<RLoopManager> &loopManager);
782template <
typename NodeType>
783std::vector<std::string> GetFilterNames(
const std::shared_ptr<NodeType> &node)
785 std::vector<std::string> filterNames;
786 node->AddFilterName(filterNames);
790struct ParsedTreePath {
791 std::string fTreeName;
792 std::string fDirName;
795ParsedTreePath ParseTreePath(std::string_view fullTreeName);
802using IsTrueForAllImpl_t =
typename std::is_same<TBoolPack<bs...,
true>, TBoolPack<
true, bs...>>;
804template <
bool... Conditions>
806 static constexpr bool value = IsTrueForAllImpl_t<Conditions...>
::value;
813struct IsList_t : std::false_type {};
816struct IsList_t<std::list<T>> : std::true_type {};
819struct IsDeque_t : std::false_type {};
822struct IsDeque_t<std::deque<T>> : std::true_type {};
825void CheckForDuplicateSnapshotColumns(
const ColumnNames_t &cols);
830struct InnerValueType {
834template <
typename Elem>
840using InnerValueType_t =
typename InnerValueType<T>::type;
842std::pair<std::vector<std::string>, std::vector<std::string>>
844 std::vector<std::string> &&colsWithAliases);
846void RemoveDuplicates(ColumnNames_t &columnNames);
847void RemoveRNTupleSubfields(ColumnNames_t &columnNames);
857using MinReturnType_t =
typename RDFInternal::RMinReturnType<T>::type;
860using MaxReturnType_t = MinReturnType_t<T>;
863using SumReturnType_t = MinReturnType_t<T>;
#define R(a, b, c, d, e, f, g, h, i)
Int_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
std::string GetName() const
std::string GetName() const
A wrapper around a concrete RDefine, which forwards all calls to it RJittedDefine is a placeholder th...
void SetDefine(std::unique_ptr< RDefineBase > c)
A wrapper around a concrete RFilter, which forwards all calls to it RJittedFilter is the type of the ...
std::shared_ptr< RNodeBase > MoveOutPrevNode()
void SetFilter(std::unique_ptr< RFilterBase > f)
The head node of a RDF computation graph.
const std::set< std::string > & GetSuppressErrorsForMissingBranches() const
void AddDataSourceColumnReaders(std::string_view col, std::vector< std::unique_ptr< RColumnReaderBase > > &&readers, const std::type_info &ti)
RDataSource * GetDataSource() const
unsigned int GetNSlots() const
bool HasDataSourceColumnReaders(std::string_view col, const std::type_info &ti) const
Return true if AddDataSourceColumnReaders was called for column name col.
A histogram data structure to bin data along multiple dimensions.
A histogram for aggregation of data along multiple dimensions.
A binder for user-defined columns, variations and aliases.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
virtual bool HasColumn(std::string_view colName) const =0
Checks if the dataset has a certain column.
std::vector< T ** > GetColumnReaders(std::string_view columnName)
Called at most once per column by RDF.
The public interface to the RDataFrame federation of classes.
A "std::vector"-like collection of values implementing handy operation to analyse them.
A TTree represents a columnar dataset.
std::string PrettyPrintAddr(const void *const addr)
std::unique_ptr< ROOT::Detail::RDF::RColumnReaderBase > CreateColumnReader(ROOT::RDF::RDataSource &ds, unsigned int slot, std::string_view col, const std::type_info &tid, TTreeReader *treeReader)
unsigned int & NThreadPerTH3()
Obtain or set the number of threads that will share a clone of a thread-safe 3D histogram.
ROOT type_traits extensions.
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
A collection of options to steer the creation of the dataset on disk through Snapshot().
Lightweight storage for a collection of types.