11#ifndef ROOT_RDF_TINTERFACE
12#define ROOT_RDF_TINTERFACE
47#include <initializer_list>
57#include <unordered_set>
80template <
typename Proxied,
typename DataSource>
83using RNode = RInterface<::ROOT::Detail::RDF::RNodeBase, void>;
109template <
typename Proxied,
typename DataSource =
void>
118 template <
typename T,
typename W>
147 template <typename T = Proxied, typename = std::enable_if_t<std::is_same<T, RLoopManager>::value,
int>>
214 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
218 RDFInternal::CheckFilter(
f);
219 using ColTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
220 constexpr auto nColumns = ColTypes_t::list_size;
238 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
254 template <
typename F>
289 using BaseNodeType_t =
typename std::remove_pointer_t<
decltype(upcastNodeOnHeap)>::element_type;
291 const auto jittedFilter =
337 template <typename F, typename std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
340 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::None>(
name, std::move(expression), columns,
"Define");
366 template <
typename F>
369 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::Slot>(
name, std::move(expression), columns,
"DefineSlot");
396 template <
typename F>
399 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::SlotAndEntry>(
name, std::move(expression), columns,
427 constexpr auto where =
"Define";
438 newCols.
AddDefine(std::move(jittedDefine));
456 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
459 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::None>(
name, std::move(expression), columns,
"Redefine");
475 template <
typename F>
478 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::Slot>(
name, std::move(expression), columns,
"RedefineSlot");
494 template <
typename F>
497 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::SlotAndEntry>(
name, std::move(expression), columns,
498 "RedefineSlotEntry");
517 constexpr auto where =
"Redefine";
528 newCols.
AddDefine(std::move(jittedDefine));
565 template <typename F, typename RetType_t = typename TTraits::CallableTraits<F>::ret_type>
573 if (retTypeName.empty()) {
577 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
581 std::make_shared<RDFDetail::RDefinePerSample<F>>(
name, retTypeName, std::move(expression), *
fLoopManager);
584 newCols.AddDefine(std::move(newColumn));
639 newCols.
AddDefine(std::move(jittedDefine));
687 template <
typename F>
689 const std::vector<std::string> &variationTags, std::string_view variationName =
"")
691 std::vector<std::string> colNames{{std::string(colName)}};
692 const std::string theVariationName{variationName.empty() ? colName : variationName};
694 return VaryImpl<true>(std::move(colNames), std::forward<F>(expression), inputColumns, variationTags,
702 template <
typename F>
704 std::size_t nVariations, std::string_view variationName =
"")
706 R__ASSERT(nVariations > 0 &&
"Must have at least one variation.");
708 std::vector<std::string> variationTags;
709 variationTags.reserve(nVariations);
710 for (std::size_t i = 0u; i < nVariations; ++i)
711 variationTags.emplace_back(std::to_string(i));
713 const std::string theVariationName{variationName.empty() ? colName : variationName};
715 return Vary(colName, std::forward<F>(expression), inputColumns, std::move(variationTags), theVariationName);
732 template <
typename F>
735 const std::vector<std::string> &variationTags, std::string_view variationName)
737 return VaryImpl<false>(colNames, std::forward<F>(expression), inputColumns, variationTags, variationName);
741 template <
typename F>
744 const std::vector<std::string> &variationTags, std::string_view variationName)
746 return Vary(std::vector<std::string>(colNames), std::forward<F>(expression), inputColumns, variationTags, variationName);
753 template <
typename F>
756 std::size_t nVariations, std::string_view variationName)
758 R__ASSERT(nVariations > 0 &&
"Must have at least one variation.");
760 std::vector<std::string> variationTags;
761 variationTags.reserve(nVariations);
762 for (std::size_t i = 0u; i < nVariations; ++i)
763 variationTags.emplace_back(std::to_string(i));
765 return Vary(colNames, std::forward<F>(expression), inputColumns, std::move(variationTags), variationName);
769 template <
typename F>
772 std::size_t nVariations, std::string_view variationName)
774 return Vary(std::vector<std::string>(colNames), std::forward<F>(expression), inputColumns, nVariations, variationName);
797 const std::vector<std::string> &variationTags, std::string_view variationName =
"")
799 std::vector<std::string> colNames{{std::string(colName)}};
800 const std::string theVariationName{variationName.empty() ? colName : variationName};
802 return JittedVaryImpl(colNames, expression, variationTags, theVariationName,
true);
815 std::string_view variationName =
"")
817 std::vector<std::string> variationTags;
818 variationTags.reserve(nVariations);
819 for (std::size_t i = 0u; i < nVariations; ++i)
820 variationTags.emplace_back(std::to_string(i));
822 return Vary(colName, expression, std::move(variationTags), variationName);
843 std::size_t nVariations, std::string_view variationName)
845 std::vector<std::string> variationTags;
846 variationTags.reserve(nVariations);
847 for (std::size_t i = 0u; i < nVariations; ++i)
848 variationTags.emplace_back(std::to_string(i));
850 return Vary(colNames, expression, std::move(variationTags), variationName);
855 std::size_t nVariations, std::string_view variationName)
857 return Vary(std::vector<std::string>(colNames), expression, nVariations, variationName);
878 const std::vector<std::string> &variationTags, std::string_view variationName)
880 return JittedVaryImpl(colNames, expression, variationTags, variationName,
false);
904 constexpr auto where =
"Alias";
912 newCols.AddAlias(alias, validColumnName);
978 template <
typename... ColumnTypes>
1008 const auto pairOfColumnLists =
1010 std::move(colListNoAliases), std::move(colListNoPoundSizes));
1011 const auto &colListNoAliasesWithSizeBranches = pairOfColumnLists.first;
1012 const auto &colListWithAliasesAndSizeBranches = pairOfColumnLists.second;
1015 const auto fullTreeName = treename;
1017 treename = parsedTreePath.fTreeName;
1018 const auto &dirname = parsedTreePath.fDirName;
1020 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(
1021 RDFInternal::SnapshotHelperArgs{std::string(
filename), std::string(dirname), std::string(treename),
1022 colListWithAliasesAndSizeBranches, options});
1025 auto newRDF = std::make_shared<ROOT::RDataFrame>(fullTreeName,
filename, colListNoAliasesWithSizeBranches);
1027 auto resPtr = CreateAction<RDFInternal::ActionTags::Snapshot, RDFDetail::RInferredType>(
1028 colListNoAliasesWithSizeBranches, newRDF, snapHelperArgs,
fProxiedPtr,
1029 colListNoAliasesWithSizeBranches.size());
1050 std::string_view columnNameRegexp =
"",
1059 std::copy_if(dsColumns.begin(), dsColumns.end(), std::back_inserter(dsColumnsWithoutSizeColumns),
1060 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
1062 columnNames.reserve(definedColumns.size() + treeBranchNames.size() + dsColumnsWithoutSizeColumns.size());
1063 columnNames.insert(columnNames.end(), definedColumns.begin(), definedColumns.end());
1064 columnNames.insert(columnNames.end(), treeBranchNames.begin(), treeBranchNames.end());
1065 columnNames.insert(columnNames.end(), dsColumnsWithoutSizeColumns.begin(), dsColumnsWithoutSizeColumns.end());
1090 std::initializer_list<std::string> columnList,
1132 template <
typename... ColumnTypes>
1135 auto staticSeq = std::make_index_sequence<
sizeof...(ColumnTypes)>();
1136 return CacheImpl<ColumnTypes...>(columnList, staticSeq);
1149 if (columnList.empty()) {
1150 auto nEntries = *this->
Count();
1155 std::stringstream cacheCall;
1162 cacheCall <<
"*reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>*>("
1164 <<
") = reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RNodeBase>*>("
1169 const auto validColumnNames =
1173 for (
const auto &colType : colTypes)
1174 cacheCall << colType <<
", ";
1175 if (!columnListWithoutSizeColumns.empty())
1176 cacheCall.seekp(-2, cacheCall.cur);
1177 cacheCall <<
">(*reinterpret_cast<std::vector<std::string>*>("
1198 const auto treeBranchNames =
1203 std::copy_if(dsColumns.begin(), dsColumns.end(), std::back_inserter(dsColumnsWithoutSizeColumns),
1204 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
1206 columnNames.reserve(definedColumns.size() + treeBranchNames.size() + dsColumns.size());
1207 columnNames.insert(columnNames.end(), definedColumns.begin(), definedColumns.end());
1208 columnNames.insert(columnNames.end(), treeBranchNames.begin(), treeBranchNames.end());
1209 columnNames.insert(columnNames.end(), dsColumns.begin(), dsColumns.end());
1211 return Cache(selectedColumns);
1223 return Cache(selectedColumns);
1247 if (stride == 0 || (end != 0 && end < begin))
1248 throw std::runtime_error(
"Range: stride must be strictly greater than 0 and end must be greater than begin.");
1252 auto rangePtr = std::make_shared<Range_t>(begin, end, stride,
fProxiedPtr);
1254 return newInterface;
1284 template <
typename F>
1287 using arg_types =
typename TTraits::CallableTraits<
decltype(
f)>::arg_types_nodecay;
1288 using ret_type =
typename TTraits::CallableTraits<
decltype(
f)>::ret_type;
1289 ForeachSlot(RDFInternal::AddSlotParameter<ret_type>(
f, arg_types()), columns);
1314 template <
typename F>
1318 constexpr auto nColumns = ColTypes_t::list_size;
1323 using Helper_t = RDFInternal::ForeachSlotHelper<F>;
1361 template <typename F, typename T = typename TTraits::CallableTraits<F>::ret_type>
1365 std::is_default_constructible<T>::value,
1366 "reduce object cannot be default-constructed. Please provide an initialisation value (redIdentity)");
1367 return Reduce(std::move(
f), columnName, T());
1384 template <typename F, typename T = typename TTraits::CallableTraits<F>::ret_type>
1406 auto cSPtr = std::make_shared<ULong64_t>(0);
1407 using Helper_t = RDFInternal::CountHelper;
1411 return MakeResultPtr(cSPtr, *
fLoopManager, std::move(action));
1434 template <
typename T,
typename COLL = std::vector<T>>
1442 using Helper_t = RDFInternal::TakeHelper<T, T, COLL>;
1444 auto valuesPtr = std::make_shared<COLL>();
1449 return MakeResultPtr(valuesPtr, *
fLoopManager, std::move(action));
1477 template <
typename V = RDFDetail::RInferredType>
1484 std::shared_ptr<::TH1D>
h(
nullptr);
1486 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1487 h = model.GetHistogram();
1488 h->SetDirectory(
nullptr);
1491 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
1492 RDFInternal::HistoUtils<::TH1D>::SetCanExtendAllAxes(*
h);
1493 return CreateAction<RDFInternal::ActionTags::Histo1D, V>(validatedColumns,
h,
h,
fProxiedPtr);
1513 template <
typename V = RDFDetail::RInferredType>
1516 const auto h_name = std::string(vName);
1517 const auto h_title = h_name +
";" + h_name +
";count";
1518 return Histo1D<V>({h_name.c_str(), h_title.c_str(), 128u, 0., 0.}, vName);
1539 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
1542 const std::vector<std::string_view> columnViews = {vName, wName};
1546 std::shared_ptr<::TH1D>
h(
nullptr);
1548 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1549 h = model.GetHistogram();
1551 return CreateAction<RDFInternal::ActionTags::Histo1D, V, W>(userColumns,
h,
h,
fProxiedPtr);
1573 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
1577 std::string str_vName{vName};
1578 std::string str_wName{wName};
1579 const auto h_name = str_vName +
"_weighted_" + str_wName;
1580 const auto h_title = str_vName +
", weights: " + str_wName +
";" + str_vName +
";count * " + str_wName;
1581 return Histo1D<V, W>({h_name.c_str(), h_title.c_str(), 128u, 0., 0.}, vName, wName);
1593 template <
typename V,
typename W>
1596 return Histo1D<V, W>(model,
"",
"");
1627 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
1630 std::shared_ptr<::TH2D>
h(
nullptr);
1632 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1633 h = model.GetHistogram();
1635 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
1636 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
1638 const std::vector<std::string_view> columnViews = {v1Name, v2Name};
1642 return CreateAction<RDFInternal::ActionTags::Histo2D, V1, V2>(userColumns,
h,
h,
fProxiedPtr);
1671 Histo2D(
const TH2DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view wName)
1673 std::shared_ptr<::TH2D>
h(
nullptr);
1675 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1676 h = model.GetHistogram();
1678 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
1679 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
1681 const std::vector<std::string_view> columnViews = {v1Name, v2Name, wName};
1685 return CreateAction<RDFInternal::ActionTags::Histo2D, V1, V2, W>(userColumns,
h,
h,
fProxiedPtr);
1688 template <
typename V1,
typename V2,
typename W>
1691 return Histo2D<V1, V2, W>(model,
"",
"",
"");
1724 std::string_view v3Name =
"")
1726 std::shared_ptr<::TH3D>
h(
nullptr);
1728 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1729 h = model.GetHistogram();
1731 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
1732 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
1734 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name};
1738 return CreateAction<RDFInternal::ActionTags::Histo3D, V1, V2, V3>(userColumns,
h,
h,
fProxiedPtr);
1773 std::string_view v3Name, std::string_view wName)
1775 std::shared_ptr<::TH3D>
h(
nullptr);
1777 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1778 h = model.GetHistogram();
1780 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
1781 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
1783 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name, wName};
1787 return CreateAction<RDFInternal::ActionTags::Histo3D, V1, V2, V3, W>(userColumns,
h,
h,
fProxiedPtr);
1790 template <
typename V1,
typename V2,
typename V3,
typename W>
1793 return Histo3D<V1, V2, V3, W>(model,
"",
"",
"",
"");
1818 template <
typename FirstColumn,
typename... OtherColumns>
1821 std::shared_ptr<::THnD>
h(
nullptr);
1823 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1824 h = model.GetHistogram();
1826 if (
int(columnList.size()) == (
h->GetNdimensions() + 1)) {
1828 }
else if (
int(columnList.size()) !=
h->GetNdimensions()) {
1829 throw std::runtime_error(
"Wrong number of columns for the specified number of histogram axes.");
1832 return CreateAction<RDFInternal::ActionTags::HistoND, FirstColumn, OtherColumns...>(columnList,
h,
h,
1855 std::shared_ptr<::THnD>
h(
nullptr);
1857 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1858 h = model.GetHistogram();
1860 if (
int(columnList.size()) == (
h->GetNdimensions() + 1)) {
1862 }
else if (
int(columnList.size()) !=
h->GetNdimensions()) {
1863 throw std::runtime_error(
"Wrong number of columns for the specified number of histogram axes.");
1866 return CreateAction<RDFInternal::ActionTags::HistoND, RDFDetail::RInferredType>(columnList,
h,
h,
fProxiedPtr,
1898 template <
typename X = RDFDetail::RInferredType,
typename Y = RDFDetail::RInferredType>
1901 auto graph = std::make_shared<::TGraph>();
1902 const std::vector<std::string_view> columnViews = {
x,
y};
1910 const auto g_name = validatedColumns[1] +
"_vs_" + validatedColumns[0];
1911 const auto g_title = validatedColumns[1] +
" vs " + validatedColumns[0];
1912 graph->SetNameTitle(g_name.c_str(), g_title.c_str());
1913 graph->GetXaxis()->SetTitle(validatedColumns[0].c_str());
1914 graph->GetYaxis()->SetTitle(validatedColumns[1].c_str());
1916 return CreateAction<RDFInternal::ActionTags::Graph, X, Y>(validatedColumns,
graph,
graph,
fProxiedPtr);
1953 std::string_view exh =
"", std::string_view eyl =
"", std::string_view eyh =
"")
1955 auto graph = std::make_shared<::TGraphAsymmErrors>();
1956 const std::vector<std::string_view> columnViews = {
x,
y, exl, exh, eyl, eyh};
1964 const auto g_name = validatedColumns[1] +
"_vs_" + validatedColumns[0];
1965 const auto g_title = validatedColumns[1] +
" vs " + validatedColumns[0];
1966 graph->SetNameTitle(g_name.c_str(), g_title.c_str());
1967 graph->GetXaxis()->SetTitle(validatedColumns[0].c_str());
1968 graph->GetYaxis()->SetTitle(validatedColumns[1].c_str());
1970 return CreateAction<RDFInternal::ActionTags::GraphAsymmErrors, X, Y, EXL, EXH, EYL, EYH>(validatedColumns,
graph,
1997 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
2001 std::shared_ptr<::TProfile>
h(
nullptr);
2003 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2004 h = model.GetProfile();
2007 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2008 throw std::runtime_error(
"Profiles with no axes limits are not supported yet.");
2010 const std::vector<std::string_view> columnViews = {v1Name, v2Name};
2014 return CreateAction<RDFInternal::ActionTags::Profile1D, V1, V2>(userColumns,
h,
h,
fProxiedPtr);
2046 std::shared_ptr<::TProfile>
h(
nullptr);
2048 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2049 h = model.GetProfile();
2052 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2053 throw std::runtime_error(
"Profile histograms with no axes limits are not supported yet.");
2055 const std::vector<std::string_view> columnViews = {v1Name, v2Name, wName};
2059 return CreateAction<RDFInternal::ActionTags::Profile1D, V1, V2, W>(userColumns,
h,
h,
fProxiedPtr);
2065 template <
typename V1,
typename V2,
typename W>
2068 return Profile1D<V1, V2, W>(model,
"",
"",
"");
2101 std::string_view v2Name =
"", std::string_view v3Name =
"")
2103 std::shared_ptr<::TProfile2D>
h(
nullptr);
2105 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2106 h = model.GetProfile();
2109 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
2110 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
2112 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name};
2116 return CreateAction<RDFInternal::ActionTags::Profile2D, V1, V2, V3>(userColumns,
h,
h,
fProxiedPtr);
2149 std::string_view v3Name, std::string_view wName)
2151 std::shared_ptr<::TProfile2D>
h(
nullptr);
2153 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2154 h = model.GetProfile();
2157 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
2158 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
2160 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name, wName};
2164 return CreateAction<RDFInternal::ActionTags::Profile2D, V1, V2, V3, W>(userColumns,
h,
h,
fProxiedPtr);
2169 template <
typename V1,
typename V2,
typename V3,
typename W>
2172 return Profile2D<V1, V2, V3, W>(model,
"",
"",
"",
"");
2212 auto h = std::make_shared<std::decay_t<T>>(std::forward<T>(model));
2213 if (!RDFInternal::HistoUtils<T>::HasAxisLimits(*
h)) {
2214 throw std::runtime_error(
"The absence of axes limits is not supported yet.");
2235 template <
typename V = RDFDetail::RInferredType>
2239 if (!
value.empty()) {
2240 columns.emplace_back(std::string(
value));
2243 if (std::is_same<V, RDFDetail::RInferredType>::value) {
2246 return Fill<V>(
TStatistic(), validColumnNames);
2267 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
2271 constexpr auto vIsInferred = std::is_same<V, RDFDetail::RInferredType>::value;
2272 constexpr auto wIsInferred = std::is_same<W, RDFDetail::RInferredType>::value;
2278 if (vIsInferred && wIsInferred) {
2280 }
else if (vIsInferred != wIsInferred) {
2281 std::string error(
"The ");
2282 error += vIsInferred ?
"value " :
"weight ";
2283 error +=
"column type is explicit, while the ";
2284 error += vIsInferred ?
"weight " :
"value ";
2285 error +=
" is specified to be inferred. This case is not supported: please specify both types or none.";
2286 throw std::runtime_error(error);
2288 return Fill<V, W>(
TStatistic(), validColumnNames);
2313 template <
typename T = RDFDetail::RInferredType>
2317 using RetType_t = RDFDetail::MinReturnType_t<T>;
2318 auto minV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::max());
2319 return CreateAction<RDFInternal::ActionTags::Min, T>(userColumns, minV, minV,
fProxiedPtr);
2343 template <
typename T = RDFDetail::RInferredType>
2347 using RetType_t = RDFDetail::MaxReturnType_t<T>;
2348 auto maxV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::lowest());
2349 return CreateAction<RDFInternal::ActionTags::Max, T>(userColumns, maxV, maxV,
fProxiedPtr);
2372 template <
typename T = RDFDetail::RInferredType>
2376 auto meanV = std::make_shared<double>(0);
2377 return CreateAction<RDFInternal::ActionTags::Mean, T>(userColumns, meanV, meanV,
fProxiedPtr);
2400 template <
typename T = RDFDetail::RInferredType>
2404 auto stdDeviationV = std::make_shared<double>(0);
2405 return CreateAction<RDFInternal::ActionTags::StdDev, T>(userColumns, stdDeviationV, stdDeviationV,
fProxiedPtr);
2431 template <
typename T = RDFDetail::RInferredType>
2433 Sum(std::string_view columnName =
"",
2434 const RDFDetail::SumReturnType_t<T> &initValue = RDFDetail::SumReturnType_t<T>{})
2437 auto sumV = std::make_shared<RDFDetail::SumReturnType_t<T>>(initValue);
2438 return CreateAction<RDFInternal::ActionTags::Sum, T>(userColumns, sumV, sumV,
fProxiedPtr);
2468 bool returnEmptyReport =
false;
2475 returnEmptyReport =
true;
2477 auto rep = std::make_shared<RCutFlowReport>();
2478 using Helper_t = RDFInternal::ReportHelper<Proxied>;
2484 return MakeResultPtr(rep, *
fLoopManager, std::move(action));
2548 template <typename AccFun, typename MergeFun, typename R = typename TTraits::CallableTraits<AccFun>::ret_type,
2549 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
2550 typename ArgTypesNoDecay =
typename TTraits::CallableTraits<AccFun>::arg_types_nodecay,
2551 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
2552 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
2555 RDFInternal::CheckAggregate<R, MergeFun>(ArgTypesNoDecay());
2561 auto accObjPtr = std::make_shared<U>(aggIdentity);
2562 using Helper_t = RDFInternal::AggregateHelper<AccFun, MergeFun, R, T, U>;
2564 auto action = std::make_unique<Action_t>(
2565 Helper_t(std::move(aggregator), std::move(merger), accObjPtr,
fLoopManager->
GetNSlots()), validColumnNames,
2567 return MakeResultPtr(accObjPtr, *
fLoopManager, std::move(action));
2583 template <typename AccFun, typename MergeFun, typename R = typename TTraits::CallableTraits<AccFun>::ret_type,
2584 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
2585 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
2586 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
2590 std::is_default_constructible<U>::value,
2591 "aggregated object cannot be default-constructed. Please provide an initialisation value (aggIdentity)");
2592 return Aggregate(std::move(aggregator), std::move(merger), columnName, U());
2660 using HelperT = std::decay_t<Helper>;
2663 static_assert(std::is_base_of<AH, HelperT>::value && std::is_convertible<HelperT *, AH *>::value,
2664 "Action helper of type T must publicly inherit from ROOT::Detail::RDF::RActionImpl<T>");
2666 auto hPtr = std::make_shared<HelperT>(std::forward<Helper>(helper));
2667 auto resPtr = hPtr->GetResultPtr();
2669 if (std::is_same<FirstColumn, RDFDetail::RInferredType>::value && columns.empty()) {
2672 return CreateAction<RDFInternal::ActionTags::Book, FirstColumn, OtherColumns...>(columns, resPtr, hPtr,
2702 template <
typename... ColumnTypes>
2706 auto newCols = columnList;
2707 newCols.insert(newCols.begin(),
"rdfentry_");
2708 auto displayer = std::make_shared<RDisplay>(newCols,
GetColumnTypeNamesList(newCols), nMaxCollectionElements);
2709 using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<RDisplay>>;
2712 std::move(newCols), displayer, std::make_shared<displayHelperArgs_t>(nRows, displayer),
fProxiedPtr);
2729 auto newCols = columnList;
2730 newCols.insert(newCols.begin(),
"rdfentry_");
2731 auto displayer = std::make_shared<RDisplay>(newCols,
GetColumnTypeNamesList(newCols), nMaxCollectionElements);
2732 using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<RDisplay>>;
2733 return CreateAction<RDFInternal::ActionTags::Display, RDFDetail::RInferredType>(
2734 std::move(newCols), displayer, std::make_shared<displayHelperArgs_t>(nRows, displayer),
fProxiedPtr,
2735 columnList.size() + 1);
2749 Display(std::string_view columnNameRegexp =
"",
size_t nRows = 5,
size_t nMaxCollectionElements = 10)
2753 return Display(selectedColumns, nRows, nMaxCollectionElements);
2765 Display(std::initializer_list<std::string> columnList,
size_t nRows = 5,
size_t nMaxCollectionElements = 10)
2768 return Display(selectedColumns, nRows, nMaxCollectionElements);
2772 template <typename F, typename DefineType, typename RetType = typename TTraits::CallableTraits<F>::ret_type>
2776 if (where.compare(0, 8,
"Redefine") != 0) {
2786 using ArgTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
2788 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::Slot>::value, ArgTypes_t>
::type;
2790 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::SlotAndEntry>::value, ColTypesTmp_t>
::type;
2792 constexpr auto nColumns = ColTypes_t::list_size;
2799 if (retTypeName.empty()) {
2803 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
2807 auto newColumn = std::make_shared<NewCol_t>(
name, retTypeName, std::forward<F>(expression), validColumnNames,
2811 newCols.
AddDefine(std::move(newColumn));
2815 return newInterface;
2821 template <typename F, typename DefineType, typename RetType = typename TTraits::CallableTraits<F>::ret_type,
2822 bool IsFStringConv = std::is_convertible<F, std::string>::value,
2823 bool IsRetTypeDefConstr = std::is_default_constructible<RetType>::value>
2824 std::enable_if_t<!IsFStringConv && !IsRetTypeDefConstr, RInterface<Proxied, DS_t>>
2827 static_assert(std::is_default_constructible<typename TTraits::CallableTraits<F>::ret_type>
::value,
2828 "Error in `Define`: type returned by expression is not default-constructible");
2832 template <
typename... ColumnTypes>
2840 const auto validCols =
GetValidatedColumnNames(columnListWithoutSizeColumns.size(), columnListWithoutSizeColumns);
2845 const auto &treename = parsedTreePath.fTreeName;
2846 const auto &dirname = parsedTreePath.fDirName;
2848 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
2849 std::string(
filename), std::string(dirname), std::string(treename), columnListWithoutSizeColumns, options});
2853 std::make_shared<ROOT::RDataFrame>(fullTreeName,
filename, columnListWithoutSizeColumns);
2857 auto resPtr =
CreateAction<RDFInternal::ActionTags::Snapshot, ColumnTypes...>(validCols, newRDF, snapHelperArgs,
2867 template <
typename... ColTypes, std::size_t... S>
2873 constexpr bool areCopyConstructible =
2874 RDFInternal::TEvalAnd<std::is_copy_constructible<ColTypes>::value...>
::value;
2875 static_assert(areCopyConstructible,
"Columns of a type which is not copy constructible cannot be cached yet.");
2879 auto colHolders = std::make_tuple(Take<ColTypes>(columnListWithoutSizeColumns[S])...);
2880 auto ds = std::make_unique<
RLazyDS<ColTypes...>>(
2881 std::make_pair(columnListWithoutSizeColumns[S], std::get<S>(colHolders))...);
2888 template <
bool IsSingleColumn,
typename F>
2891 const std::vector<std::string> &variationTags, std::string_view variationName)
2893 using F_t = std::decay_t<F>;
2894 using ColTypes_t =
typename TTraits::CallableTraits<F_t>::arg_types;
2895 using RetType =
typename TTraits::CallableTraits<F_t>::ret_type;
2896 constexpr auto nColumns = ColTypes_t::list_size;
2898 SanityChecksForVary<RetType>(colNames, variationTags, variationName);
2904 if (retTypeName.empty()) {
2908 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
2911 auto variation = std::make_shared<RDFInternal::RVariation<F_t, IsSingleColumn>>(
2916 newCols.AddVariation(std::move(variation));
2920 return newInterface;
2924 const std::vector<std::string> &variationTags,
2925 std::string_view variationName,
bool isSingleColumn)
2927 R__ASSERT(variationTags.size() > 0 &&
"Must have at least one variation.");
2928 R__ASSERT(colNames.size() > 0 &&
"Must have at least one varied column.");
2929 R__ASSERT(!variationName.empty() &&
"Must provide a variation name.");
2931 for (
auto &colName : colNames) {
2939 if (colNames.size() > 1) {
2940 std::set<std::string> uniqueCols(colNames.begin(), colNames.end());
2941 if (uniqueCols.size() != colNames.size())
2942 throw std::logic_error(
"A column name was passed to the same Vary invocation multiple times.");
2946 auto jittedVariation =
2951 newColRegister.
AddVariation(std::move(jittedVariation));
2955 return newInterface;
2958 template <
typename Helper,
typename ActionResultType>
2960 const std::shared_ptr<Helper> &hPtr,
2964 return CreateAction<RDFInternal::ActionTags::Book>({}, resPtr, hPtr,
fProxiedPtr, 0u);
2967 template <
typename Helper,
typename ActionResultType,
typename... Others>
2968 RResultPtr<ActionResultType>
2970 const std::shared_ptr<Helper>& ,
2973 throw std::logic_error(std::string(
"An action was booked with no input columns, but the action requires "
2974 "columns! The action helper type was ") +
2975 typeid(Helper).
name());
unsigned long long ULong64_t
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
Base class for action helpers, see RInterface::Book() for more information.
The head node of a RDF computation graph.
const ColumnNames_t & GetBranchNames()
Return all valid TTree::Branch names (caching results for subsequent calls).
void ToJitExec(const std::string &) const
void Run(bool jit=true)
Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source.
unsigned int GetNSlots() const
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
Helper class that provides the operation graph nodes.
A RDataFrame node that produces a result.
A binder for user-defined columns, variations and aliases.
void AddVariation(std::shared_ptr< RVariationBase > variation)
Register a new systematic variation.
void AddDefine(std::shared_ptr< RDFDetail::RDefineBase > column)
Add a new defined column.
ColumnNames_t GetNames() const
Return the list of the names of the defined columns (Defines + Aliases).
A dataset specification for RDataFrame.
virtual const std::vector< std::string > & GetColumnNames() const =0
Returns a reference to the collection of the dataset's column names.
ColumnNames_t GetValidatedColumnNames(const unsigned int nColumns, const ColumnNames_t &columns)
ColumnNames_t GetColumnTypeNamesList(const ColumnNames_t &columnList)
RDFDetail::RLoopManager * fLoopManager
< The RLoopManager at the root of this computation graph. Never null.
RResultPtr< ActionResultType > CreateAction(const ColumnNames_t &columns, const std::shared_ptr< ActionResultType > &r, const std::shared_ptr< HelperArgType > &helperArg, const std::shared_ptr< RDFNode > &proxiedPtr, const int=-1)
Create RAction object, return RResultPtr for the action Overload for the case in which all column typ...
RDataSource * fDataSource
Non-owning pointer to a data-source object. Null if no data-source. RLoopManager has ownership of the...
void CheckAndFillDSColumns(ColumnNames_t validCols, TTraits::TypeList< ColumnTypes... > typeList)
void CheckIMTDisabled(std::string_view callerName)
ColumnNames_t GetColumnNames()
Returns the names of the available columns.
RDFInternal::RColumnRegister fColRegister
Contains the columns defined up to this node.
The public interface to the RDataFrame federation of classes.
RResultPtr<::THnD > HistoND(const THnDModel &model, const ColumnNames_t &columnList)
Fill and return an N-dimensional histogram (lazy action).
RInterface(const RInterface &)=default
Copy-ctor for RInterface.
RResultPtr<::TH1D > Histo1D(std::string_view vName, std::string_view wName)
Fill and return a one-dimensional histogram with the weighted values of a column (lazy action).
RInterface(const std::shared_ptr< Proxied > &proxied, RLoopManager &lm, const RDFInternal::RColumnRegister &colRegister)
RResultPtr<::TH1D > Histo1D(const TH1DModel &model={"", "", 128u, 0., 0.})
Fill and return a one-dimensional histogram with the weighted values of a column (lazy action).
RResultPtr<::TH2D > Histo2D(const TH2DModel &model)
RResultPtr<::TProfile > Profile1D(const TProfile1DModel &model, std::string_view v1Name="", std::string_view v2Name="")
Fill and return a one-dimensional profile (lazy action).
RResultPtr<::THnD > HistoND(const THnDModel &model, const ColumnNames_t &columnList)
Fill and return an N-dimensional histogram (lazy action).
std::enable_if_t<!IsFStringConv &&!IsRetTypeDefConstr, RInterface< Proxied, DS_t > > DefineImpl(std::string_view, F, const ColumnNames_t &, const std::string &)
RResultPtr< RInterface< RLoopManager > > Snapshot(std::string_view treename, std::string_view filename, std::string_view columnNameRegexp="", const RSnapshotOptions &options=RSnapshotOptions())
Save selected columns to disk, in a new TTree treename in file filename.
RResultPtr< TStatistic > Stats(std::string_view value="")
Return a TStatistic object, filled once per event (lazy action).
RInterface< Proxied, DS_t > Vary(std::string_view colName, F &&expression, const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName="")
Register systematic variations for an existing columns using auto-generated variation tags.
RInterface< Proxied, DS_t > Vary(std::string_view colName, std::string_view expression, std::size_t nVariations, std::string_view variationName="")
Register systematic variations for an existing column.
RResultPtr<::TGraph > Graph(std::string_view x="", std::string_view y="")
Fill and return a TGraph object (lazy action).
RResultPtr< ActionResultType > CallCreateActionWithoutColsIfPossible(const std::shared_ptr< ActionResultType > &, const std::shared_ptr< Helper > &, Others...)
RInterface< Proxied, DS_t > DefineSlot(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column with a value dependent on the processing slot.
RResultPtr< double > StdDev(std::string_view columnName="")
Return the unbiased standard deviation of processed column values (lazy action).
std::enable_if_t< std::is_default_constructible< RetType >::value, RInterface< Proxied, DS_t > > DefineImpl(std::string_view name, F &&expression, const ColumnNames_t &columns, const std::string &where)
RInterface< Proxied, DS_t > DefinePerSample(std::string_view name, F expression)
Define a new column that is updated when the input sample changes.
RInterface & operator=(RInterface &&)=default
Move-assignment operator for RInterface.
RInterface< Proxied, DS_t > Vary(const std::vector< std::string > &colNames, F &&expression, const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName)
Register systematic variations for one or more existing columns using auto-generated tags.
void ForeachSlot(F f, const ColumnNames_t &columns={})
Execute a user-defined function requiring a processing slot index on each entry (instant action).
RInterface< Proxied, DS_t > Vary(std::string_view colName, std::string_view expression, const std::vector< std::string > &variationTags, std::string_view variationName="")
Register systematic variations for an existing column.
RResultPtr< RDisplay > Display(const ColumnNames_t &columnList, size_t nRows=5, size_t nMaxCollectionElements=10)
Provides a representation of the columns in the dataset.
RInterface< RLoopManager > Cache(const ColumnNames_t &columnList)
Save selected columns in memory.
RInterface< Proxied, DS_t > Define(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column.
RResultPtr< TStatistic > Stats(std::string_view value, std::string_view weight)
Return a TStatistic object, filled once per event (lazy action).
RInterface< Proxied, DS_t > Redefine(std::string_view name, std::string_view expression)
Overwrite the value and/or type of an existing column.
auto CallCreateActionWithoutColsIfPossible(const std::shared_ptr< ActionResultType > &resPtr, const std::shared_ptr< Helper > &hPtr, TTraits::TypeList< RDFDetail::RInferredType >) -> decltype(hPtr->Exec(0u), RResultPtr< ActionResultType >{})
RInterface< Proxied, DS_t > Vary(const std::vector< std::string > &colNames, std::string_view expression, std::size_t nVariations, std::string_view variationName)
Register systematic variations for one or more existing columns.
RResultPtr<::TH2D > Histo2D(const TH2DModel &model, std::string_view v1Name="", std::string_view v2Name="")
Fill and return a two-dimensional histogram (lazy action).
RResultPtr< RInterface< RLoopManager > > SnapshotImpl(std::string_view fullTreeName, std::string_view filename, const ColumnNames_t &columnList, const RSnapshotOptions &options)
RInterface< Proxied, DS_t > Vary(std::initializer_list< std::string > colNames, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName)
Overload to avoid ambiguity between C++20 string, vector<string> construction from init list.
RResultPtr<::TProfile > Profile1D(const TProfile1DModel &model)
Fill and return a one-dimensional profile (lazy action).
RInterface(const std::shared_ptr< RLoopManager > &proxied)
Build a RInterface from a RLoopManager.
RInterface< RDFDetail::RFilter< F, Proxied >, DS_t > Filter(F f, const std::initializer_list< std::string > &columns)
Append a filter to the call graph.
RInterface< Proxied, DS_t > DefinePerSample(std::string_view name, std::string_view expression)
Define a new column that is updated when the input sample changes.
RResultPtr< double > Mean(std::string_view columnName="")
Return the mean of processed column values (lazy action).
RResultPtr< RInterface< RLoopManager > > Snapshot(std::string_view treename, std::string_view filename, std::initializer_list< std::string > columnList, const RSnapshotOptions &options=RSnapshotOptions())
Save selected columns to disk, in a new TTree treename in file filename.
RResultPtr< RDisplay > Display(std::initializer_list< std::string > columnList, size_t nRows=5, size_t nMaxCollectionElements=10)
Provides a representation of the columns in the dataset.
RInterface< Proxied, DS_t > Alias(std::string_view alias, std::string_view columnName)
Allow to refer to a column with a different name.
RInterface< RLoopManager > Cache(const ColumnNames_t &columnList)
Save selected columns in memory.
RInterface< Proxied, DS_t > Redefine(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
RInterface< RLoopManager > Cache(std::string_view columnNameRegexp="")
Save selected columns in memory.
RInterface< Proxied, DS_t > VaryImpl(const std::vector< std::string > &colNames, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName)
RResultPtr< typename std::decay_t< Helper >::Result_t > Book(Helper &&helper, const ColumnNames_t &columns={})
Book execution of a custom action using a user-defined helper object.
RResultPtr< RDisplay > Display(std::string_view columnNameRegexp="", size_t nRows=5, size_t nMaxCollectionElements=10)
Provides a representation of the columns in the dataset.
friend class RDFInternal::GraphDrawing::GraphCreatorHelper
RResultPtr<::TH2D > Histo2D(const TH2DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view wName)
Fill and return a weighted two-dimensional histogram (lazy action).
RInterface & operator=(const RInterface &)=default
Copy-assignment operator for RInterface.
RResultPtr< RDFDetail::SumReturnType_t< T > > Sum(std::string_view columnName="", const RDFDetail::SumReturnType_t< T > &initValue=RDFDetail::SumReturnType_t< T >{})
Return the sum of processed column values (lazy action).
RInterface< Proxied, DS_t > Vary(std::string_view colName, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName="")
Register systematic variations for an existing column.
RResultPtr< ULong64_t > Count()
Return the number of entries processed (lazy action).
RInterface< Proxied, DS_t > Vary(const std::vector< std::string > &colNames, std::string_view expression, const std::vector< std::string > &variationTags, std::string_view variationName)
Register systematic variations for one or more existing columns.
RInterface< Proxied, DS_t > Define(std::string_view name, std::string_view expression)
Define a new column.
std::shared_ptr< Proxied > fProxiedPtr
Smart pointer to the graph node encapsulated by this RInterface.
RResultPtr<::TH1D > Histo1D(std::string_view vName)
Fill and return a one-dimensional histogram with the values of a column (lazy action).
RInterface< Proxied, DS_t > Vary(const std::vector< std::string > &colNames, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName)
Register a systematic variation that affects multiple columns simultaneously.
RInterface< Proxied, DS_t > RedefineSlotEntry(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
RResultPtr<::TH1D > Histo1D(const TH1DModel &model, std::string_view vName, std::string_view wName)
Fill and return a one-dimensional histogram with the weighted values of a column (lazy action).
RInterface< RLoopManager > CacheImpl(const ColumnNames_t &columnList, std::index_sequence< S... >)
Implementation of cache.
RInterface< RDFDetail::RRange< Proxied >, DS_t > Range(unsigned int end)
Creates a node that filters entries based on range.
RResultPtr< COLL > Take(std::string_view column="")
Return a collection of values of a column (lazy action, returns a std::vector by default).
RInterface< RLoopManager > Cache(std::initializer_list< std::string > columnList)
Save selected columns in memory.
RResultPtr<::TProfile2D > Profile2D(const TProfile2DModel &model, std::string_view v1Name="", std::string_view v2Name="", std::string_view v3Name="")
Fill and return a two-dimensional profile (lazy action).
const std::shared_ptr< Proxied > & GetProxiedPtr() const
RInterface< Proxied, DS_t > JittedVaryImpl(const std::vector< std::string > &colNames, std::string_view expression, const std::vector< std::string > &variationTags, std::string_view variationName, bool isSingleColumn)
RResultPtr<::TH3D > Histo3D(const TH3DModel &model, std::string_view v1Name="", std::string_view v2Name="", std::string_view v3Name="")
Fill and return a three-dimensional histogram (lazy action).
RInterface< Proxied, DS_t > Vary(std::initializer_list< std::string > colNames, F &&expression, const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName)
Overload to avoid ambiguity between C++20 string, vector<string> construction from init list.
RResultPtr< std::decay_t< T > > Fill(T &&model, const ColumnNames_t &columnList)
Return an object of type T on which T::Fill will be called once per event (lazy action).
RResultPtr< RInterface< RLoopManager > > Snapshot(std::string_view treename, std::string_view filename, const ColumnNames_t &columnList, const RSnapshotOptions &options=RSnapshotOptions())
Save selected columns to disk, in a new TTree treename in file filename.
RResultPtr< RDisplay > Display(const ColumnNames_t &columnList, size_t nRows=5, size_t nMaxCollectionElements=10)
Provides a representation of the columns in the dataset.
RResultPtr< RCutFlowReport > Report()
Gather filtering statistics.
RInterface< Proxied, DS_t > RedefineSlot(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
RResultPtr<::TProfile2D > Profile2D(const TProfile2DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view v3Name, std::string_view wName)
Fill and return a two-dimensional profile (lazy action).
RResultPtr<::TGraphAsymmErrors > GraphAsymmErrors(std::string_view x="", std::string_view y="", std::string_view exl="", std::string_view exh="", std::string_view eyl="", std::string_view eyh="")
Fill and return a TGraphAsymmErrors object (lazy action).
RResultPtr< RInterface< RLoopManager > > Snapshot(std::string_view treename, std::string_view filename, const ColumnNames_t &columnList, const RSnapshotOptions &options=RSnapshotOptions())
Save selected columns to disk, in a new TTree treename in file filename.
RResultPtr< U > Aggregate(AccFun aggregator, MergeFun merger, std::string_view columnName="")
Execute a user-defined accumulation operation on the processed column values in each processing slot.
RInterface< Proxied, DS_t > DefineSlotEntry(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column with a value dependent on the processing slot and the current entry.
RResultPtr< RDFDetail::MinReturnType_t< T > > Min(std::string_view columnName="")
Return the minimum of processed column values (lazy action).
RResultPtr< T > Reduce(F f, std::string_view columnName="")
Execute a user-defined reduce operation on the values of a column.
void Foreach(F f, const ColumnNames_t &columns={})
Execute a user-defined function on each entry (instant action).
RInterface< RDFDetail::RJittedFilter, DS_t > Filter(std::string_view expression, std::string_view name="")
Append a filter to the call graph.
RResultPtr<::TProfile2D > Profile2D(const TProfile2DModel &model)
Fill and return a two-dimensional profile (lazy action).
RInterface< RDFDetail::RFilter< F, Proxied >, DS_t > Filter(F f, const ColumnNames_t &columns={}, std::string_view name="")
Append a filter to the call graph.
RResultPtr< U > Aggregate(AccFun aggregator, MergeFun merger, std::string_view columnName, const U &aggIdentity)
Execute a user-defined accumulation operation on the processed column values in each processing slot.
RInterface(RInterface &&)=default
Move-ctor for RInterface.
RResultPtr< T > Reduce(F f, std::string_view columnName, const T &redIdentity)
Execute a user-defined reduce operation on the values of a column.
RResultPtr<::TH3D > Histo3D(const TH3DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view v3Name, std::string_view wName)
Fill and return a three-dimensional histogram (lazy action).
RInterface< RDFDetail::RFilter< F, Proxied >, DS_t > Filter(F f, std::string_view name)
Append a filter to the call graph.
RInterface< RDFDetail::RRange< Proxied >, DS_t > Range(unsigned int begin, unsigned int end, unsigned int stride=1)
Creates a node that filters entries based on range: [begin, end).
std::vector< std::string > GetFilterNames()
Returns the names of the filters created.
RResultPtr<::TH1D > Histo1D(const TH1DModel &model={"", "", 128u, 0., 0.}, std::string_view vName="")
Fill and return a one-dimensional histogram with the values of a column (lazy action).
RResultPtr<::TProfile > Profile1D(const TProfile1DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view wName)
Fill and return a one-dimensional profile (lazy action).
RResultPtr<::TH3D > Histo3D(const TH3DModel &model)
RResultPtr< RDFDetail::MaxReturnType_t< T > > Max(std::string_view columnName="")
Return the maximum of processed column values (lazy action).
RInterface< Proxied, DS_t > Vary(std::initializer_list< std::string > colNames, std::string_view expression, std::size_t nVariations, std::string_view variationName)
Overload to avoid ambiguity between C++20 string, vector<string> construction from init list.
A RDataSource implementation which is built on top of result proxies.
Smart pointer for the return type of actions.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
typename RemoveFirstParameter< T >::type RemoveFirstParameter_t
TDirectory::TContext keeps track and restore the current directory.
A TGraph is an object made of two arrays X and Y with npoints each.
Statistical variable, defined by its mean and variance (RMS).
void CheckForNoVariations(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister)
Throw if the column has systematic variations attached.
ParsedTreePath ParseTreePath(std::string_view fullTreeName)
void CheckForRedefinition(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister, const ColumnNames_t &treeColumns, const ColumnNames_t &dataSourceColumns)
Throw if column definedColView is already there.
void CheckForDefinition(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister, const ColumnNames_t &treeColumns, const ColumnNames_t &dataSourceColumns)
Throw if column definedColView is not already there.
void ChangeEmptyEntryRange(const ROOT::RDF::RNode &node, std::pair< ULong64_t, ULong64_t > &&newRange)
std::shared_ptr< RJittedDefine > BookDefineJit(std::string_view name, std::string_view expression, RLoopManager &lm, RDataSource *ds, const RColumnRegister &colRegister, const ColumnNames_t &branches, std::shared_ptr< RNodeBase > *upcastNodeOnHeap)
Book the jitting of a Define call.
void CheckValidCppVarName(std::string_view var, const std::string &where)
void ChangeSpec(const ROOT::RDF::RNode &node, ROOT::RDF::Experimental::RDatasetSpec &&spec)
Changes the input dataset specification of an RDataFrame.
void RemoveDuplicates(ColumnNames_t &columnNames)
std::shared_ptr< RNodeBase > UpcastNode(std::shared_ptr< RNodeBase > ptr)
std::string TypeID2TypeName(const std::type_info &id)
Returns the name of a type starting from its type_info An empty string is returned in case of failure...
std::vector< std::string > GetFilterNames(const std::shared_ptr< RLoopManager > &loopManager)
std::string PrettyPrintAddr(const void *const addr)
void TriggerRun(ROOT::RDF::RNode node)
Trigger the execution of an RDataFrame computation graph.
void CheckTypesAndPars(unsigned int nTemplateParams, unsigned int nColumnNames)
std::string DemangleTypeIdName(const std::type_info &typeInfo)
bool AtLeastOneEmptyString(const std::vector< std::string_view > strings)
std::shared_ptr< RDFDetail::RJittedFilter > BookFilterJit(std::shared_ptr< RDFDetail::RNodeBase > *prevNodeOnHeap, std::string_view name, std::string_view expression, const ColumnNames_t &branches, const RColumnRegister &colRegister, TTree *tree, RDataSource *ds)
Book the jitting of a Filter call.
ColumnNames_t FilterArraySizeColNames(const ColumnNames_t &columnNames, const std::string &action)
Take a list of column names, return that list with entries starting by '#' filtered out.
std::shared_ptr< RJittedVariation > BookVariationJit(const std::vector< std::string > &colNames, std::string_view variationName, const std::vector< std::string > &variationTags, std::string_view expression, RLoopManager &lm, RDataSource *ds, const RColumnRegister &colRegister, const ColumnNames_t &branches, std::shared_ptr< RNodeBase > *upcastNodeOnHeap, bool isSingleColumn)
Book the jitting of a Vary call.
void CheckForDuplicateSnapshotColumns(const ColumnNames_t &cols)
ColumnNames_t ConvertRegexToColumns(const ColumnNames_t &colNames, std::string_view columnNameRegexp, std::string_view callerName)
std::pair< std::vector< std::string >, std::vector< std::string > > AddSizeBranches(const std::vector< std::string > &branches, TTree *tree, std::vector< std::string > &&colsWithoutAliases, std::vector< std::string > &&colsWithAliases)
Return copies of colsWithoutAliases and colsWithAliases with size branches for variable-sized array b...
std::shared_ptr< RJittedDefine > BookDefinePerSampleJit(std::string_view name, std::string_view expression, RLoopManager &lm, const RColumnRegister &colRegister, std::shared_ptr< RNodeBase > *upcastNodeOnHeap)
Book the jitting of a DefinePerSample call.
std::vector< std::string > GetTopLevelBranchNames(TTree &t)
Get all the top-level branches names, including the ones of the friend trees.
RInterface<::ROOT::Detail::RDF::RNodeBase, void > RNode
std::vector< std::string > ColumnNames_t
ROOT type_traits extensions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
void DisableImplicitMT()
Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
type is TypeList if MustRemove is false, otherwise it is a TypeList with the first type removed
A collection of options to steer the creation of the dataset on file.
bool fLazy
Do not start the event loop when Snapshot is called.
A struct which stores the parameters of a TH1D.
A struct which stores the parameters of a TH2D.
A struct which stores the parameters of a TH3D.
A struct which stores the parameters of a THnD.
A struct which stores the parameters of a TProfile.
A struct which stores the parameters of a TProfile2D.
Lightweight storage for a collection of types.