11#ifndef ROOT_RDF_TINTERFACE
12#define ROOT_RDF_TINTERFACE
48#include "RConfigure.h"
58#include <initializer_list>
68#include <unordered_set>
92template <
typename Proxied>
95using RNode = RInterface<::ROOT::Detail::RDF::RNodeBase>;
109 const std::vector<std::size_t> &vecSizes,
float vecPadding,
ROOT::RVecF &
dest);
126template <
typename Proxied>
134 template <
typename T>
141 friend std::vector<std::pair<std::uint64_t, std::uint64_t>>
146 const std::vector<std::size_t> &vecSizes,
float vecPadding,
156 auto nColumns = columnList.size();
157 std::vector<const std::type_info *> colTypeIDs;
158 colTypeIDs.reserve(nColumns);
159 for (
decltype(nColumns) i{}; i < nColumns; i++) {
160 const auto &colName = validColumnNames[i];
164 colTypeIDs.push_back(colTypeID);
171 auto location = std::shared_ptr<ROOT::RVecF>(&
dest, [](
ROOT::RVecF *) {});
172 auto action = RDFInternal::BuildAction(validColumnNames, colTypeIDs, location, vecSizes, vecPadding,
fProxiedPtr,
174 auto resPtr = MakeResultPtr(location, *
GetLoopManager(), std::move(action));
199 template <typename T = Proxied, typename = std::enable_if_t<std::is_same<T, RLoopManager>::value,
int>>
274 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
277 RDFInternal::CheckFilter(
f);
278 using ColTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
279 constexpr auto nColumns = ColTypes_t::list_size;
297 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
313 template <
typename F>
346 const auto jittedFilter = RDFInternal::BookFilterJit(RDFInternal::UpcastNode(
fProxiedPtr),
name, expression,
394 throw std::runtime_error(
"Unknown column: \"" + std::string(column) +
"\"");
445 throw std::runtime_error(
"Unknown column: \"" + std::string(column) +
"\"");
492 template <typename F, typename std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
495 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::None>(
name, std::move(expression), columns,
"Define");
522 template <
typename F>
525 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::Slot>(
name, std::move(expression), columns,
"DefineSlot");
553 template <
typename F>
556 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::SlotAndEntry>(
name, std::move(expression), columns,
584 constexpr auto where =
"Define";
585 RDFInternal::CheckValidCppVarName(
name, where);
593 newCols.
AddDefine(std::move(jittedDefine));
611 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
614 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::None>(
name, std::move(expression), columns,
"Redefine");
630 template <
typename F>
633 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::Slot>(
name, std::move(expression), columns,
"RedefineSlot");
649 template <
typename F>
652 return DefineImpl<F, RDFDetail::ExtraArgsForDefine::SlotAndEntry>(
name, std::move(expression), columns,
653 "RedefineSlotEntry");
672 constexpr auto where =
"Redefine";
673 RDFInternal::CheckValidCppVarName(
name, where);
681 newCols.
AddDefine(std::move(jittedDefine));
721 template <
typename T>
724 constexpr auto where{
"DefaultValueFor"};
725 RDFInternal::CheckForNoVariations(where, column,
fColRegister);
729 RDFInternal::CheckForDefinition(where, column,
fColRegister,
734 if (retTypeName.empty()) {
737 const auto demangledType = RDFInternal::DemangleTypeIdName(
typeid(T));
738 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
742 auto newColumn = std::make_shared<ROOT::Internal::RDF::RDefaultValueFor<T>>(
747 newCols.AddDefine(std::move(newColumn));
784 template <typename F, typename RetType_t = typename TTraits::CallableTraits<F>::ret_type>
787 return DefinePerSampleImpl<F, RetType_t>(
name, std::move(expression),
false);
793 template <typename F, typename RetType_t = typename TTraits::CallableTraits<F>::ret_type>
796 return DefinePerSampleImpl<F, RetType_t>(
name, std::move(expression),
true);
896 template <
typename F>
898 const std::vector<std::string> &variationTags, std::string_view variationName =
"")
900 std::vector<std::string> colNames{{std::string(colName)}};
901 const std::string theVariationName{variationName.empty() ? colName : variationName};
903 return VaryImpl<true>(std::move(colNames), std::forward<F>(expression), inputColumns, variationTags,
935 template <
typename F>
937 std::size_t nVariations, std::string_view variationName =
"")
939 R__ASSERT(nVariations > 0 &&
"Must have at least one variation.");
941 std::vector<std::string> variationTags;
942 variationTags.reserve(nVariations);
943 for (std::size_t i = 0u; i < nVariations; ++i)
944 variationTags.emplace_back(std::to_string(i));
946 const std::string theVariationName{variationName.empty() ? colName : variationName};
948 return Vary(colName, std::forward<F>(expression), inputColumns, std::move(variationTags), theVariationName);
983 template <
typename F>
985 const std::vector<std::string> &variationTags, std::string_view variationName)
987 return VaryImpl<false>(colNames, std::forward<F>(expression), inputColumns, variationTags, variationName);
1004 template <
typename F>
1006 Vary(std::initializer_list<std::string> colNames, F &&expression,
const ColumnNames_t &inputColumns,
1007 const std::vector<std::string> &variationTags, std::string_view variationName)
1009 return Vary(std::vector<std::string>(colNames), std::forward<F>(expression), inputColumns, variationTags, variationName);
1044 template <
typename F>
1046 std::size_t nVariations, std::string_view variationName)
1048 R__ASSERT(nVariations > 0 &&
"Must have at least one variation.");
1050 std::vector<std::string> variationTags;
1051 variationTags.reserve(nVariations);
1052 for (std::size_t i = 0u; i < nVariations; ++i)
1053 variationTags.emplace_back(std::to_string(i));
1055 return Vary(colNames, std::forward<F>(expression), inputColumns, std::move(variationTags), variationName);
1074 template <
typename F>
1076 const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName)
1078 return Vary(std::vector<std::string>(colNames), std::forward<F>(expression), inputColumns, nVariations, variationName);
1119 const std::vector<std::string> &variationTags, std::string_view variationName =
"")
1121 std::vector<std::string> colNames{{std::string(colName)}};
1122 const std::string theVariationName{variationName.empty() ? colName : variationName};
1124 return JittedVaryImpl(colNames, expression, variationTags, theVariationName,
true);
1164 std::string_view variationName =
"")
1166 std::vector<std::string> variationTags;
1167 variationTags.reserve(nVariations);
1168 for (std::size_t i = 0u; i < nVariations; ++i)
1169 variationTags.emplace_back(std::to_string(i));
1171 return Vary(colName, expression, std::move(variationTags), variationName);
1226 std::size_t nVariations, std::string_view variationName)
1228 std::vector<std::string> variationTags;
1229 variationTags.reserve(nVariations);
1230 for (std::size_t i = 0u; i < nVariations; ++i)
1231 variationTags.emplace_back(std::to_string(i));
1233 return Vary(colNames, expression, std::move(variationTags), variationName);
1250 std::size_t nVariations, std::string_view variationName)
1252 return Vary(std::vector<std::string>(colNames), expression, nVariations, variationName);
1303 const std::vector<std::string> &variationTags, std::string_view variationName)
1305 return JittedVaryImpl(colNames, expression, variationTags, variationName,
false);
1329 constexpr auto where =
"Alias";
1330 RDFInternal::CheckValidCppVarName(alias, where);
1332 RDFInternal::CheckForRedefinition(where, alias,
fColRegister, dsColumnNames);
1337 newCols.AddAlias(alias, validColumnName);
1341 return newInterface;
1365 if (stride == 0 || (end != 0 && end < begin))
1366 throw std::runtime_error(
"Range: stride must be strictly greater than 0 and end must be greater than begin.");
1370 auto rangePtr = std::make_shared<Range_t>(begin, end, stride,
fProxiedPtr);
1372 return newInterface;
1410 auto cSPtr = std::make_shared<ULong64_t>(0);
1411 using Helper_t = RDFInternal::CountHelper;
1415 return MakeResultPtr(cSPtr, *
fLoopManager, std::move(action));
1438 template <
typename T,
typename COLL = std::vector<T>>
1446 using Helper_t = RDFInternal::TakeHelper<T, T, COLL>;
1448 auto valuesPtr = std::make_shared<COLL>();
1453 return MakeResultPtr(valuesPtr, *
fLoopManager, std::move(action));
1481 template <
typename V = RDFDetail::RInferredType>
1488 std::shared_ptr<::TH1D>
h(
nullptr);
1490 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1491 h = model.GetHistogram();
1494 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
1496 return CreateAction<RDFInternal::ActionTags::Histo1D, V>(validatedColumns,
h,
h,
fProxiedPtr);
1516 template <
typename V = RDFDetail::RInferredType>
1519 const auto h_name = std::string(vName);
1520 const auto h_title = h_name +
";" + h_name +
";count";
1521 return Histo1D<V>({h_name.c_str(), h_title.c_str(), 128u, 0., 0.}, vName);
1542 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
1545 const std::vector<std::string_view> columnViews = {vName, wName};
1546 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
1549 std::shared_ptr<::TH1D>
h(
nullptr);
1551 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1552 h = model.GetHistogram();
1555 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
1557 return CreateAction<RDFInternal::ActionTags::Histo1D, V, W>(userColumns,
h,
h,
fProxiedPtr);
1579 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
1583 std::string str_vName{vName};
1584 std::string str_wName{wName};
1585 const auto h_name = str_vName +
"_weighted_" + str_wName;
1586 const auto h_title = str_vName +
", weights: " + str_wName +
";" + str_vName +
";count * " + str_wName;
1587 return Histo1D<V, W>({h_name.c_str(), h_title.c_str(), 128u, 0., 0.}, vName, wName);
1599 template <
typename V,
typename W>
1602 return Histo1D<V, W>(model,
"",
"");
1633 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
1636 std::shared_ptr<::TH2D>
h(
nullptr);
1638 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1639 h = model.GetHistogram();
1641 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
1642 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
1644 const std::vector<std::string_view> columnViews = {v1Name, v2Name};
1645 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
1648 return CreateAction<RDFInternal::ActionTags::Histo2D, V1, V2>(userColumns,
h,
h,
fProxiedPtr);
1677 Histo2D(
const TH2DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view wName)
1679 std::shared_ptr<::TH2D>
h(
nullptr);
1681 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1682 h = model.GetHistogram();
1684 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
1685 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
1687 const std::vector<std::string_view> columnViews = {v1Name, v2Name, wName};
1688 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
1691 return CreateAction<RDFInternal::ActionTags::Histo2D, V1, V2, W>(userColumns,
h,
h,
fProxiedPtr);
1694 template <
typename V1,
typename V2,
typename W>
1697 return Histo2D<V1, V2, W>(model,
"",
"",
"");
1732 std::string_view v3Name =
"")
1734 std::shared_ptr<::TH3D>
h(
nullptr);
1736 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1737 h = model.GetHistogram();
1739 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
1740 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
1742 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name};
1743 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
1746 return CreateAction<RDFInternal::ActionTags::Histo3D, V1, V2, V3>(userColumns,
h,
h,
fProxiedPtr);
1781 std::string_view v3Name, std::string_view wName)
1783 std::shared_ptr<::TH3D>
h(
nullptr);
1785 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1786 h = model.GetHistogram();
1788 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
1789 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
1791 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name, wName};
1792 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
1795 return CreateAction<RDFInternal::ActionTags::Histo3D, V1, V2, V3, W>(userColumns,
h,
h,
fProxiedPtr);
1798 template <
typename V1,
typename V2,
typename V3,
typename W>
1801 return Histo3D<V1, V2, V3, W>(model,
"",
"",
"",
"");
1829 template <
typename FirstColumn,
typename... OtherColumns>
1832 std::shared_ptr<::THnD>
h(
nullptr);
1834 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1835 h = model.GetHistogram();
1836 const auto hDims =
h->GetNdimensions();
1837 decltype(hDims) nCols = columnList.size();
1839 if (!wName.empty() && nCols == hDims + 1)
1840 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
1841 "input columns contains one column more than the number of dimensions of the "
1842 "histogram. Call as 'HistoND(model, cols, weightCol)'.");
1844 if (nCols == hDims + 1)
1845 Warning(
"HistoND",
"Passing the column with the weights as the last column in the list is deprecated. "
1846 "Instead, pass it as a separate argument, e.g. 'HistoND(model, cols, weightCol)'.");
1848 if (!wName.empty() || nCols == hDims + 1)
1851 if (nCols != hDims + 1 && nCols != hDims)
1852 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
1855 if (!wName.empty()) {
1859 userColumns.push_back(std::string{wName});
1860 return CreateAction<RDFInternal::ActionTags::HistoND, FirstColumn, OtherColumns...>(userColumns,
h,
h,
1863 return CreateAction<RDFInternal::ActionTags::HistoND, FirstColumn, OtherColumns...>(columnList,
h,
h,
1889 std::shared_ptr<::THnD>
h(
nullptr);
1891 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1892 h = model.GetHistogram();
1893 const auto hDims =
h->GetNdimensions();
1894 decltype(hDims) nCols = columnList.size();
1896 if (!wName.empty() && nCols == hDims + 1)
1897 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
1898 "input columns contains one column more than the number of dimensions of the "
1899 "histogram. Call as 'HistoND(model, cols, weightCol)'.");
1901 if (nCols == hDims + 1)
1902 Warning(
"HistoND",
"Passing the column with the weights as the last column in the list is deprecated. "
1903 "Instead, pass it as a separate argument, e.g. 'HistoND(model, cols, weightCol)'.");
1905 if (!wName.empty() || nCols == hDims + 1)
1908 if (nCols != hDims + 1 && nCols != hDims)
1909 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
1912 if (!wName.empty()) {
1916 userColumns.push_back(std::string{wName});
1917 return CreateAction<RDFInternal::ActionTags::HistoND, RDFDetail::RInferredType>(userColumns,
h,
h,
fProxiedPtr,
1918 userColumns.size());
1920 return CreateAction<RDFInternal::ActionTags::HistoND, RDFDetail::RInferredType>(columnList,
h,
h,
fProxiedPtr,
1949 template <
typename FirstColumn,
typename... OtherColumns>
1953 std::shared_ptr<::THnSparseD>
h(
nullptr);
1955 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1956 h = model.GetHistogram();
1957 const auto hDims =
h->GetNdimensions();
1958 decltype(hDims) nCols = columnList.size();
1960 if (!wName.empty() && nCols == hDims + 1)
1961 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
1962 "input columns contains one column more than the number of dimensions of the "
1963 "histogram. Call as 'HistoNSparseD(model, cols, weightCol)'.");
1965 if (nCols == hDims + 1)
1967 "Passing the column with the weights as the last column in the list is deprecated. "
1968 "Instead, pass it as a separate argument, e.g. 'HistoNSparseD(model, cols, weightCol)'.");
1970 if (!wName.empty() || nCols == hDims + 1)
1973 if (nCols != hDims + 1 && nCols != hDims)
1974 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
1977 if (!wName.empty()) {
1981 userColumns.push_back(std::string{wName});
1982 return CreateAction<RDFInternal::ActionTags::HistoNSparseD, FirstColumn, OtherColumns...>(userColumns,
h,
h,
1985 return CreateAction<RDFInternal::ActionTags::HistoNSparseD, FirstColumn, OtherColumns...>(columnList,
h,
h,
2012 std::shared_ptr<::THnSparseD>
h(
nullptr);
2014 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2015 h = model.GetHistogram();
2016 const auto hDims =
h->GetNdimensions();
2017 decltype(hDims) nCols = columnList.size();
2019 if (!wName.empty() && nCols == hDims + 1)
2020 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2021 "input columns contains one column more than the number of dimensions of the "
2022 "histogram. Call as 'HistoNSparseD(model, cols, weightCol)'.");
2024 if (nCols == hDims + 1)
2026 "Passing the column with the weights as the last column in the list is deprecated. "
2027 "Instead, pass it as a separate argument, e.g. 'HistoNSparseD(model, cols, weightCol)'.");
2029 if (!wName.empty() || nCols == hDims + 1)
2032 if (nCols != hDims + 1 && nCols != hDims)
2033 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2036 if (!wName.empty()) {
2040 userColumns.push_back(std::string{wName});
2041 return CreateAction<RDFInternal::ActionTags::HistoNSparseD, RDFDetail::RInferredType>(
2044 return CreateAction<RDFInternal::ActionTags::HistoNSparseD, RDFDetail::RInferredType>(
2067 template <
typename BinContentType =
double,
typename V = RDFDetail::RInferredType>
2069 Hist(std::uint64_t nNormalBins, std::pair<double, double> interval, std::string_view vName)
2071 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(nNormalBins, interval);
2075 return Hist<V>(
h, columnList);
2102 if (axes.size() != columnList.size()) {
2103 std::string msg =
"Wrong number of columns for the specified number of histogram axes: ";
2104 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(columnList.size());
2105 throw std::invalid_argument(msg);
2108 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
2110 return Hist<ColumnType, ColumnTypes...>(
h, columnList);
2141 if (
h->GetNDimensions() != columnList.size()) {
2142 std::string msg =
"Wrong number of columns for the passed histogram: ";
2143 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2144 throw std::invalid_argument(msg);
2175 Hist(std::uint64_t nNormalBins, std::pair<double, double> interval, std::string_view vName, std::string_view wName)
2177 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(nNormalBins, interval);
2181 return Hist<V, W>(
h, columnList, wName);
2210 Hist(std::vector<ROOT::Experimental::RAxisVariant> axes,
const ColumnNames_t &columnList, std::string_view wName)
2213 "weighted filling is not supported for integral bin content types");
2215 if (axes.size() != columnList.size()) {
2216 std::string msg =
"Wrong number of columns for the specified number of histogram axes: ";
2217 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(columnList.size());
2218 throw std::invalid_argument(msg);
2221 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
2223 return Hist<ColumnType, ColumnTypes...>(
h, columnList, wName);
2254 std::string_view wName)
2257 "weighted filling is not supported for integral bin content types");
2261 if (
h->GetNDimensions() != columnList.size()) {
2262 std::string msg =
"Wrong number of columns for the passed histogram: ";
2263 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2264 throw std::invalid_argument(msg);
2269 columnListWithWeights.push_back(std::string(wName));
2271 return CreateAction<RDFInternal::ActionTags::HistWithWeight, ColumnType, ColumnTypes...>(
2272 columnListWithWeights,
h,
h,
fProxiedPtr, columnListWithWeights.size());
2303 if (
h->GetNDimensions() != columnList.size()) {
2304 std::string msg =
"Wrong number of columns for the passed histogram: ";
2305 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2306 throw std::invalid_argument(msg);
2341 std::string_view wName)
2344 "weighted filling is not supported for integral bin content types");
2348 if (
h->GetNDimensions() != columnList.size()) {
2349 std::string msg =
"Wrong number of columns for the passed histogram: ";
2350 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2351 throw std::invalid_argument(msg);
2356 columnListWithWeights.push_back(std::string(wName));
2358 return CreateAction<RDFInternal::ActionTags::HistWithWeight, ColumnType, ColumnTypes...>(
2359 columnListWithWeights,
h,
h,
fProxiedPtr, columnListWithWeights.size());
2383 template <
typename X = RDFDetail::RInferredType,
typename V = RDFDetail::RInferredType>
2385 std::string_view xName, std::string_view vName)
2387 std::shared_ptr
p = std::make_shared<ROOT::Experimental::RProfile>(nNormalBins, interval);
2391 return Profile<X, V>(
p, columnList, vName);
2416 Profile(std::vector<ROOT::Experimental::RAxisVariant> axes,
const ColumnNames_t &columnList, std::string_view vName)
2418 if (axes.size() != columnList.size()) {
2419 std::string msg =
"Wrong number of columns for the specified number of histogram axes: ";
2420 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(columnList.size());
2421 throw std::invalid_argument(msg);
2424 std::shared_ptr
p = std::make_shared<ROOT::Experimental::RProfile>(std::move(axes));
2426 return Profile<ColumnType, ColumnTypes...>(
p, columnList, vName);
2458 if (
p->GetNDimensions() != columnList.size()) {
2459 std::string msg =
"Wrong number of columns for the passed profile histogram: ";
2460 msg +=
"expected " + std::to_string(
p->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2461 throw std::invalid_argument(msg);
2466 columnListWithValues.push_back(std::string(vName));
2468 return CreateAction<RDFInternal::ActionTags::Profile, ColumnType, ColumnTypes...>(
2469 columnListWithValues,
p,
p,
fProxiedPtr, columnListWithValues.size());
2497 Profile(std::uint64_t nNormalBins, std::pair<double, double> interval, std::string_view xName,
2498 std::string_view vName, std::string_view wName)
2500 std::shared_ptr
p = std::make_shared<ROOT::Experimental::RProfile>(nNormalBins, interval);
2504 return Profile<X, V, W>(
p, columnList, vName, wName);
2530 Profile(std::vector<ROOT::Experimental::RAxisVariant> axes,
const ColumnNames_t &columnList, std::string_view vName,
2531 std::string_view wName)
2533 if (axes.size() != columnList.size()) {
2534 std::string msg =
"Wrong number of columns for the specified number of histogram axes: ";
2535 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(columnList.size());
2536 throw std::invalid_argument(msg);
2539 std::shared_ptr
p = std::make_shared<ROOT::Experimental::RProfile>(std::move(axes));
2541 return Profile<ColumnType, ColumnTypes...>(
p, columnList, vName, wName);
2571 std::string_view wName)
2575 if (
p->GetNDimensions() != columnList.size()) {
2576 std::string msg =
"Wrong number of columns for the passed profile histogram: ";
2577 msg +=
"expected " + std::to_string(
p->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2578 throw std::invalid_argument(msg);
2583 columnListWithValuesAndWeights.push_back(std::string(vName));
2584 columnListWithValuesAndWeights.push_back(std::string(wName));
2586 return CreateAction<RDFInternal::ActionTags::ProfileWithWeight, ColumnType, ColumnTypes...>(
2587 columnListWithValuesAndWeights,
p,
p,
fProxiedPtr, columnListWithValuesAndWeights.size());
2619 template <
typename X = RDFDetail::RInferredType,
typename Y = RDFDetail::RInferredType>
2622 auto graph = std::make_shared<::TGraph>();
2623 const std::vector<std::string_view> columnViews = {
x,
y};
2624 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
2631 const auto g_name = validatedColumns[1] +
"_vs_" + validatedColumns[0];
2632 const auto g_title = validatedColumns[1] +
" vs " + validatedColumns[0];
2633 graph->SetNameTitle(g_name.c_str(), g_title.c_str());
2634 graph->GetXaxis()->SetTitle(validatedColumns[0].c_str());
2635 graph->GetYaxis()->SetTitle(validatedColumns[1].c_str());
2637 return CreateAction<RDFInternal::ActionTags::Graph, X, Y>(validatedColumns, graph, graph,
fProxiedPtr);
2686 std::string_view exh =
"", std::string_view eyl =
"", std::string_view eyh =
"")
2688 auto graph = std::make_shared<::TGraphAsymmErrors>();
2689 const std::vector<std::string_view> columnViews = {
x,
y, exl, exh, eyl, eyh};
2690 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
2697 const auto g_name = validatedColumns[1] +
"_vs_" + validatedColumns[0];
2698 const auto g_title = validatedColumns[1] +
" vs " + validatedColumns[0];
2699 graph->SetNameTitle(g_name.c_str(), g_title.c_str());
2700 graph->GetXaxis()->SetTitle(validatedColumns[0].c_str());
2701 graph->GetYaxis()->SetTitle(validatedColumns[1].c_str());
2703 return CreateAction<RDFInternal::ActionTags::GraphAsymmErrors, X, Y, EXL, EXH, EYL, EYH>(validatedColumns, graph,
2730 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
2734 std::shared_ptr<::TProfile>
h(
nullptr);
2736 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2737 h = model.GetProfile();
2740 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2741 throw std::runtime_error(
"Profiles with no axes limits are not supported yet.");
2743 const std::vector<std::string_view> columnViews = {v1Name, v2Name};
2744 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
2747 return CreateAction<RDFInternal::ActionTags::Profile1D, V1, V2>(userColumns,
h,
h,
fProxiedPtr);
2779 std::shared_ptr<::TProfile>
h(
nullptr);
2781 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2782 h = model.GetProfile();
2785 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2786 throw std::runtime_error(
"Profile histograms with no axes limits are not supported yet.");
2788 const std::vector<std::string_view> columnViews = {v1Name, v2Name, wName};
2789 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
2792 return CreateAction<RDFInternal::ActionTags::Profile1D, V1, V2, W>(userColumns,
h,
h,
fProxiedPtr);
2798 template <
typename V1,
typename V2,
typename W>
2801 return Profile1D<V1, V2, W>(model,
"",
"",
"");
2834 std::string_view v2Name =
"", std::string_view v3Name =
"")
2836 std::shared_ptr<::TProfile2D>
h(
nullptr);
2838 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2839 h = model.GetProfile();
2842 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
2843 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
2845 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name};
2846 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
2849 return CreateAction<RDFInternal::ActionTags::Profile2D, V1, V2, V3>(userColumns,
h,
h,
fProxiedPtr);
2882 std::string_view v3Name, std::string_view wName)
2884 std::shared_ptr<::TProfile2D>
h(
nullptr);
2886 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2887 h = model.GetProfile();
2890 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
2891 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
2893 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name, wName};
2894 const auto userColumns = RDFInternal::AtLeastOneEmptyString(columnViews)
2897 return CreateAction<RDFInternal::ActionTags::Profile2D, V1, V2, V3, W>(userColumns,
h,
h,
fProxiedPtr);
2902 template <
typename V1,
typename V2,
typename V3,
typename W>
2905 return Profile2D<V1, V2, V3, W>(model,
"",
"",
"",
"");
2945 auto h = std::make_shared<std::decay_t<T>>(std::forward<T>(model));
2946 if (!RDFInternal::HistoUtils<T>::HasAxisLimits(*
h)) {
2947 throw std::runtime_error(
"The absence of axes limits is not supported yet.");
2968 template <
typename V = RDFDetail::RInferredType>
2972 if (!
value.empty()) {
2973 columns.emplace_back(std::string(
value));
2976 if (std::is_same<V, RDFDetail::RInferredType>::value) {
2979 return Fill<V>(
TStatistic(), validColumnNames);
3000 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
3004 constexpr auto vIsInferred = std::is_same<V, RDFDetail::RInferredType>::value;
3005 constexpr auto wIsInferred = std::is_same<W, RDFDetail::RInferredType>::value;
3011 if (vIsInferred && wIsInferred) {
3013 }
else if (vIsInferred != wIsInferred) {
3014 std::string error(
"The ");
3015 error += vIsInferred ?
"value " :
"weight ";
3016 error +=
"column type is explicit, while the ";
3017 error += vIsInferred ?
"weight " :
"value ";
3018 error +=
" is specified to be inferred. This case is not supported: please specify both types or none.";
3019 throw std::runtime_error(error);
3021 return Fill<V, W>(
TStatistic(), validColumnNames);
3046 template <
typename T = RDFDetail::RInferredType>
3050 using RetType_t = RDFDetail::MinReturnType_t<T>;
3051 auto minV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::max());
3052 return CreateAction<RDFInternal::ActionTags::Min, T>(userColumns, minV, minV,
fProxiedPtr);
3076 template <
typename T = RDFDetail::RInferredType>
3080 using RetType_t = RDFDetail::MaxReturnType_t<T>;
3081 auto maxV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::lowest());
3082 return CreateAction<RDFInternal::ActionTags::Max, T>(userColumns, maxV, maxV,
fProxiedPtr);
3107 template <
typename T = RDFDetail::RInferredType>
3111 auto meanV = std::make_shared<double>(0);
3112 return CreateAction<RDFInternal::ActionTags::Mean, T>(userColumns, meanV, meanV,
fProxiedPtr);
3135 template <
typename T = RDFDetail::RInferredType>
3139 auto stdDeviationV = std::make_shared<double>(0);
3140 return CreateAction<RDFInternal::ActionTags::StdDev, T>(userColumns, stdDeviationV, stdDeviationV,
fProxiedPtr);
3171 template <
typename T = RDFDetail::RInferredType>
3175 auto medianV = std::make_shared<double>(0);
3176 return CreateAction<RDFInternal::ActionTags::Median, T>(userColumns, medianV, medianV,
fProxiedPtr);
3202 template <
typename T = RDFDetail::RInferredType>
3204 Sum(std::string_view columnName =
"",
3205 const RDFDetail::SumReturnType_t<T> &initValue = RDFDetail::SumReturnType_t<T>{})
3208 auto sumV = std::make_shared<RDFDetail::SumReturnType_t<T>>(initValue);
3209 return CreateAction<RDFInternal::ActionTags::Sum, T>(userColumns, sumV, sumV,
fProxiedPtr);
3239 bool returnEmptyReport =
false;
3246 returnEmptyReport =
true;
3248 auto rep = std::make_shared<RCutFlowReport>();
3255 return MakeResultPtr(rep, *
fLoopManager, std::move(action));
3284 template <
typename... ColumnTypes>
3288 auto newCols = columnList;
3289 newCols.insert(newCols.begin(),
"rdfentry_");
3290 auto displayer = std::make_shared<RDisplay>(newCols,
GetColumnTypeNamesList(newCols), nMaxCollectionElements);
3291 using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<RDisplay>>;
3294 std::move(newCols), displayer, std::make_shared<displayHelperArgs_t>(nRows, displayer),
fProxiedPtr);
3311 auto newCols = columnList;
3312 newCols.insert(newCols.begin(),
"rdfentry_");
3313 auto displayer = std::make_shared<RDisplay>(newCols,
GetColumnTypeNamesList(newCols), nMaxCollectionElements);
3314 using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<RDisplay>>;
3315 return CreateAction<RDFInternal::ActionTags::Display, RDFDetail::RInferredType>(
3316 std::move(newCols), displayer, std::make_shared<displayHelperArgs_t>(nRows, displayer),
fProxiedPtr,
3317 columnList.size() + 1);
3331 Display(std::string_view columnNameRegexp =
"",
size_t nRows = 5,
size_t nMaxCollectionElements = 10)
3334 const auto selectedColumns = RDFInternal::ConvertRegexToColumns(columnNames, columnNameRegexp,
"Display");
3335 return Display(selectedColumns, nRows, nMaxCollectionElements);
3347 Display(std::initializer_list<std::string> columnList,
size_t nRows = 5,
size_t nMaxCollectionElements = 10)
3350 return Display(selectedColumns, nRows, nMaxCollectionElements);
3361 template <
typename... ColumnTypes>
3362 [[deprecated(
"Snapshot is not any more a template. You can safely remove the template parameters.")]]
3450 auto colListNoPoundSizes = RDFInternal::FilterArraySizeColNames(columnList,
"Snapshot");
3453 RDFInternal::CheckForDuplicateSnapshotColumns(colListNoAliases);
3455 const auto pairOfColumnLists =
3456 RDFInternal::AddSizeBranches(
GetDataSource(), std::move(colListNoAliases), std::move(colListNoPoundSizes));
3457 const auto &colListNoAliasesWithSizeBranches = pairOfColumnLists.first;
3458 const auto &colListWithAliasesAndSizeBranches = pairOfColumnLists.second;
3460 const auto fullTreeName = treename;
3461 const auto parsedTreePath = RDFInternal::ParseTreePath(fullTreeName);
3462 treename = parsedTreePath.fTreeName;
3463 const auto &dirname = parsedTreePath.fDirName;
3469 auto retrieveTypeID = [](
const std::string &colName,
const std::string &colTypeName,
3470 bool isRNTuple =
false) ->
const std::type_info * {
3473 }
catch (
const std::runtime_error &err) {
3477 if (std::string(err.what()).find(
"Cannot extract type_info of type") != std::string::npos) {
3479 std::string trueTypeName{colTypeName};
3480 if (colTypeName.rfind(
"CLING_UNKNOWN_TYPE", 0) == 0)
3481 trueTypeName = colTypeName.substr(19);
3482 std::string msg{
"No runtime type information is available for column \"" + colName +
3483 "\" with type name \"" + trueTypeName +
3484 "\". Thus, it cannot be written to disk with Snapshot. Make sure to generate and load "
3485 "ROOT dictionaries for the type of this column."};
3487 throw std::runtime_error(msg);
3494 RDFInternal::CheckSnapshotOptionsFormatCompatibility(options);
3500 auto newRDF = std::make_shared<RInterface<RLoopManager>>(std::make_shared<RLoopManager>(colListNoPoundSizes));
3502 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
3503 std::string(
filename), std::string(dirname), std::string(treename), colListWithAliasesAndSizeBranches,
3504 options, newRDF->GetLoopManager(),
GetLoopManager(),
true ,
false});
3506 auto &&nColumns = colListNoAliasesWithSizeBranches.size();
3510 std::vector<const std::type_info *> colTypeIDs;
3511 colTypeIDs.reserve(nColumns);
3512 for (
decltype(nColumns) i{}; i < nColumns; i++) {
3513 const auto &colName = validColumnNames[i];
3516 const std::type_info *colTypeID = retrieveTypeID(colName, colTypeName,
true);
3517 colTypeIDs.push_back(colTypeID);
3525 resPtr = MakeResultPtr(newRDF, *
GetLoopManager(), std::move(action));
3530 "The default Snapshot output data format is TTree, but the input data format is RNTuple. If you "
3531 "want to Snapshot to RNTuple or suppress this warning, set the appropriate fOutputFormat option in "
3532 "RSnapshotOptions. Note that this current default behaviour might change in the future.");
3537 auto newRDF = std::make_shared<RInterface<RLoopManager>>(
3538 std::make_shared<RLoopManager>(colListNoAliasesWithSizeBranches));
3540 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
3541 std::string(
filename), std::string(dirname), std::string(treename), colListWithAliasesAndSizeBranches,
3542 options, newRDF->GetLoopManager(),
GetLoopManager(),
false , options.fIncludeVariations});
3544 auto &&nColumns = colListNoAliasesWithSizeBranches.size();
3548 std::vector<const std::type_info *> colTypeIDs;
3549 colTypeIDs.reserve(nColumns);
3550 for (
decltype(nColumns) i{}; i < nColumns; i++) {
3551 const auto &colName = validColumnNames[i];
3554 const std::type_info *colTypeID = retrieveTypeID(colName, colTypeName);
3555 colTypeIDs.push_back(colTypeID);
3563 resPtr = MakeResultPtr(newRDF, *
GetLoopManager(), std::move(action));
3585 std::string_view columnNameRegexp =
"",
3593 std::copy_if(dsColumns.begin(), dsColumns.end(), std::back_inserter(dsColumnsWithoutSizeColumns),
3594 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
3596 columnNames.reserve(definedColumns.size() + dsColumnsWithoutSizeColumns.size());
3597 columnNames.insert(columnNames.end(), definedColumns.begin(), definedColumns.end());
3598 columnNames.insert(columnNames.end(), dsColumnsWithoutSizeColumns.begin(), dsColumnsWithoutSizeColumns.end());
3602 RDFInternal::RemoveDuplicates(columnNames);
3604 std::vector<std::string> selectedColumns;
3606 selectedColumns = RDFInternal::ConvertRegexToColumns(columnNames, columnNameRegexp,
"Snapshot");
3608 catch (
const std::runtime_error &
e){
3611 selectedColumns = RDFInternal::ConvertRegexToColumns(ds->GetColumnNames(), columnNameRegexp,
"Snapshot");
3617 RDFInternal::RemoveRNTupleSubfields(selectedColumns);
3638 std::initializer_list<std::string> columnList,
3680 template <
typename... ColumnTypes>
3683 auto staticSeq = std::make_index_sequence<
sizeof...(ColumnTypes)>();
3684 return CacheImpl<ColumnTypes...>(columnList, staticSeq);
3697 if (columnList.empty()) {
3698 auto nEntries = *this->
Count();
3703 std::stringstream cacheCall;
3704 auto upcastNode = RDFInternal::UpcastNode(
fProxiedPtr);
3710 cacheCall <<
"*reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>*>("
3712 <<
") = reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RNodeBase>*>("
3715 const auto columnListWithoutSizeColumns = RDFInternal::FilterArraySizeColNames(columnList,
"Cache");
3717 const auto validColumnNames =
3719 const auto colTypes =
3721 for (
const auto &colType : colTypes)
3722 cacheCall << colType <<
", ";
3723 if (!columnListWithoutSizeColumns.empty())
3724 cacheCall.seekp(-2, cacheCall.cur);
3725 cacheCall <<
">(*reinterpret_cast<std::vector<std::string>*>("
3748 std::copy_if(dsColumns.begin(), dsColumns.end(), std::back_inserter(dsColumnsWithoutSizeColumns),
3749 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
3751 columnNames.reserve(definedColumns.size() + dsColumns.size());
3752 columnNames.insert(columnNames.end(), definedColumns.begin(), definedColumns.end());
3753 columnNames.insert(columnNames.end(), dsColumns.begin(), dsColumns.end());
3754 const auto selectedColumns = RDFInternal::ConvertRegexToColumns(columnNames, columnNameRegexp,
"Cache");
3755 return Cache(selectedColumns);
3767 return Cache(selectedColumns);
3788 template <
typename F>
3791 using arg_types =
typename TTraits::CallableTraits<
decltype(
f)>::arg_types_nodecay;
3792 using ret_type =
typename TTraits::CallableTraits<
decltype(
f)>::ret_type;
3793 ForeachSlot(RDFInternal::AddSlotParameter<ret_type>(
f, arg_types()), columns);
3818 template <
typename F>
3822 constexpr auto nColumns = ColTypes_t::list_size;
3827 using Helper_t = RDFInternal::ForeachSlotHelper<F>;
3905 template <typename AccFun, typename MergeFun, typename R = typename TTraits::CallableTraits<AccFun>::ret_type,
3906 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
3907 typename ArgTypesNoDecay =
typename TTraits::CallableTraits<AccFun>::arg_types_nodecay,
3908 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
3909 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
3912 RDFInternal::CheckAggregate<R, MergeFun>(ArgTypesNoDecay());
3918 auto accObjPtr = std::make_shared<U>(aggIdentity);
3919 using Helper_t = RDFInternal::AggregateHelper<AccFun, MergeFun, R, T, U>;
3921 auto action = std::make_unique<Action_t>(
3922 Helper_t(std::move(aggregator), std::move(merger), accObjPtr,
fLoopManager->GetNSlots()), validColumnNames,
3924 return MakeResultPtr(accObjPtr, *
fLoopManager, std::move(action));
3940 template <typename AccFun, typename MergeFun, typename R = typename TTraits::CallableTraits<AccFun>::ret_type,
3941 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
3942 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
3943 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
3947 std::is_default_constructible<U>::value,
3948 "aggregated object cannot be default-constructed. Please provide an initialisation value (aggIdentity)");
3949 return Aggregate(std::move(aggregator), std::move(merger), columnName, U());
4018 using HelperT = std::decay_t<Helper>;
4021 static_assert(std::is_base_of<AH, HelperT>::value && std::is_convertible<HelperT *, AH *>::value,
4022 "Action helper of type T must publicly inherit from ROOT::Detail::RDF::RActionImpl<T>");
4024 auto hPtr = std::make_shared<HelperT>(std::forward<Helper>(helper));
4025 auto resPtr = hPtr->GetResultPtr();
4027 if (std::is_same<FirstColumn, RDFDetail::RInferredType>::value && columns.empty()) {
4030 return CreateAction<RDFInternal::ActionTags::Book, FirstColumn, OtherColumns...>(columns, resPtr, hPtr,
4066 template <typename F, typename T = typename TTraits::CallableTraits<F>::ret_type>
4070 std::is_default_constructible<T>::value,
4071 "reduce object cannot be default-constructed. Please provide an initialisation value (redIdentity)");
4072 return Reduce(std::move(
f), columnName, T());
4089 template <typename F, typename T = typename TTraits::CallableTraits<F>::ret_type>
4099 template <typename F, typename DefineType, typename RetType = typename TTraits::CallableTraits<F>::ret_type>
4103 if (where.compare(0, 8,
"Redefine") != 0) {
4104 RDFInternal::CheckValidCppVarName(
name, where);
4113 using ArgTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
4115 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::Slot>::value, ArgTypes_t>
::type;
4117 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::SlotAndEntry>::value, ColTypesTmp_t>
::type;
4119 constexpr auto nColumns = ColTypes_t::list_size;
4126 if (retTypeName.empty()) {
4129 const auto demangledType = RDFInternal::DemangleTypeIdName(
typeid(RetType));
4130 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
4134 auto newColumn = std::make_shared<NewCol_t>(
name, retTypeName, std::forward<F>(expression), validColumnNames,
4138 newCols.
AddDefine(std::move(newColumn));
4142 return newInterface;
4148 template <typename F, typename DefineType, typename RetType = typename TTraits::CallableTraits<F>::ret_type,
4149 bool IsFStringConv = std::is_convertible<F, std::string>::value,
4150 bool IsRetTypeDefConstr = std::is_default_constructible<RetType>::value>
4151 std::enable_if_t<!IsFStringConv && !IsRetTypeDefConstr, RInterface<Proxied>>
4154 static_assert(std::is_default_constructible<typename TTraits::CallableTraits<F>::ret_type>
::value,
4155 "Error in `Define`: type returned by expression is not default-constructible");
4161 template <typename F, typename RetType_t = typename TTraits::CallableTraits<F>::ret_type>
4165 RDFInternal::CheckValidCppVarName(
name,
"DefinePerSample");
4171 RDFInternal::CheckForNoVariations(
"RedefinePerSample",
name,
fColRegister);
4175 if (retTypeName.empty()) {
4178 const auto demangledType = RDFInternal::DemangleTypeIdName(
typeid(RetType_t));
4179 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
4183 std::make_shared<RDFDetail::RDefinePerSample<F>>(
name, retTypeName, std::move(expression), *
fLoopManager);
4186 newCols.AddDefine(std::move(newColumn));
4188 return newInterface;
4197 RDFInternal::CheckValidCppVarName(
name, redefine ?
"RedefinePerSample" :
"DefinePerSample");
4203 RDFInternal::CheckForNoVariations(
"RedefinePerSample",
name,
fColRegister);
4209 newCols.
AddDefine(std::move(jittedDefine));
4213 return newInterface;
4218 template <
typename... ColTypes, std::size_t... S>
4221 const auto columnListWithoutSizeColumns = RDFInternal::FilterArraySizeColNames(columnList,
"Snapshot");
4224 constexpr bool areCopyConstructible =
4225 RDFInternal::TEvalAnd<std::is_copy_constructible<ColTypes>::value...>
::value;
4226 static_assert(areCopyConstructible,
"Columns of a type which is not copy constructible cannot be cached yet.");
4228 RDFInternal::CheckTypesAndPars(
sizeof...(ColTypes), columnListWithoutSizeColumns.size());
4230 auto colHolders = std::make_tuple(Take<ColTypes>(columnListWithoutSizeColumns[S])...);
4231 auto ds = std::make_unique<
RLazyDS<ColTypes...>>(
4232 std::make_pair(columnListWithoutSizeColumns[S], std::get<S>(colHolders))...);
4239 template <
bool IsSingleColumn,
typename F>
4242 const std::vector<std::string> &variationTags, std::string_view variationName)
4244 using F_t = std::decay_t<F>;
4245 using ColTypes_t =
typename TTraits::CallableTraits<F_t>::arg_types;
4246 using RetType =
typename TTraits::CallableTraits<F_t>::ret_type;
4247 constexpr auto nColumns = ColTypes_t::list_size;
4249 SanityChecksForVary<RetType>(colNames, variationTags, variationName);
4255 if (retTypeName.empty()) {
4258 const auto demangledType = RDFInternal::DemangleTypeIdName(
typeid(RetType));
4259 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
4262 auto variation = std::make_shared<RDFInternal::RVariation<F_t, IsSingleColumn>>(
4267 newCols.AddVariation(std::move(variation));
4271 return newInterface;
4275 const std::vector<std::string> &variationTags, std::string_view variationName,
4276 bool isSingleColumn)
4278 R__ASSERT(!variationTags.empty() &&
"Must have at least one variation.");
4279 R__ASSERT(!colNames.empty() &&
"Must have at least one varied column.");
4280 R__ASSERT(!variationName.empty() &&
"Must provide a variation name.");
4282 for (
auto &colName : colNames) {
4283 RDFInternal::CheckValidCppVarName(colName,
"Vary");
4284 RDFInternal::CheckForDefinition(
"Vary", colName,
fColRegister,
4287 RDFInternal::CheckValidCppVarName(variationName,
"Vary");
4290 if (colNames.size() > 1) {
4291 std::set<std::string> uniqueCols(colNames.begin(), colNames.end());
4292 if (uniqueCols.size() != colNames.size())
4293 throw std::logic_error(
"A column name was passed to the same Vary invocation multiple times.");
4298 auto jittedVariation =
4299 RDFInternal::BookVariationJit(colNames, variationName, variationTags, expression, *
fLoopManager,
4303 newColRegister.
AddVariation(std::move(jittedVariation));
4307 return newInterface;
4310 template <
typename Helper,
typename ActionResultType>
4312 const std::shared_ptr<Helper> &hPtr,
4316 return CreateAction<RDFInternal::ActionTags::Book>({}, resPtr, hPtr,
fProxiedPtr, 0u);
4319 template <
typename Helper,
typename ActionResultType,
typename... Others>
4320 RResultPtr<ActionResultType>
4322 const std::shared_ptr<Helper>& ,
4325 throw std::logic_error(std::string(
"An action was booked with no input columns, but the action requires "
4326 "columns! The action helper type was ") +
4327 typeid(Helper).
name());
Basic types used by ROOT and required by TInterpreter.
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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 dest
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.
implementation of FilterAvailable and FilterMissing operations
The head node of a RDF computation graph.
A histogram data structure to bin data along multiple dimensions.
A histogram for aggregation of data along multiple dimensions.
Helper class that provides the operation graph nodes.
A RDataFrame node that produces a result.
A binder for user-defined columns, variations and aliases.
std::vector< std::string_view > GenerateColumnNames() const
Return the list of the names of the defined columns (Defines + 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.
RDFDetail::RDefineBase * GetDefine(std::string_view colName) const
Return the RDefine for the requested column name, or nullptr.
The 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.
The base public interface to the RDataFrame federation of classes.
std::string GetColumnType(std::string_view column)
Return the type of a given column as a string.
ColumnNames_t GetValidatedColumnNames(const unsigned int nColumns, const ColumnNames_t &columns)
ColumnNames_t GetColumnTypeNamesList(const ColumnNames_t &columnList)
std::shared_ptr< ROOT::Detail::RDF::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 * GetDataSource() const
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.
RDFDetail::RLoopManager * GetLoopManager() const
RDFInternal::RColumnRegister fColRegister
Contains the columns defined up to this node.
The public interface to the RDataFrame federation of classes.
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<::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<::THnD > HistoND(const THnDModel &model, const ColumnNames_t &columnList, std::string_view wName="")
Fill and return an N-dimensional histogram (lazy action).
RResultPtr<::TGraph > Graph(std::string_view x="", std::string_view y="")
Fill and return a TGraph object (lazy action).
RInterface< Proxied > 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 a single existing column using custom variation tags.
RInterface< Proxied > Vary(const std::vector< std::string > &colNames, std::string_view expression, std::size_t nVariations, std::string_view variationName)
Register systematic variations for multiple existing columns using auto-generated variation tags.
RResultPtr< ROOT::Experimental::RHist< BinContentType > > Hist(std::uint64_t nNormalBins, std::pair< double, double > interval, std::string_view vName, std::string_view wName)
Fill and return a one-dimensional RHist with weights (lazy action).
RInterface(const RInterface &)=default
Copy-ctor for RInterface.
RResultPtr< RDFDetail::MaxReturnType_t< T > > Max(std::string_view columnName="")
Return the maximum of processed column values (lazy action).
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(RInterface &&)=default
Move-ctor for RInterface.
RInterface< Proxied > Vary(std::string_view colName, std::string_view expression, const std::vector< std::string > &variationTags, std::string_view variationName="")
Register systematic variations for a single existing column using custom variation tags.
RInterface< RDFDetail::RFilter< F, Proxied > > Filter(F f, const std::initializer_list< std::string > &columns)
Append a filter to the call graph.
RInterface< RLoopManager > Cache(std::initializer_list< std::string > columnList)
Save selected columns in memory.
RInterface< Proxied > Vary(std::string_view colName, F &&expression, const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName="")
Register systematic variations for a single existing column using auto-generated variation tags.
RInterface< Proxied > Vary(std::initializer_list< std::string > colNames, std::string_view expression, std::size_t nVariations, std::string_view variationName)
Register systematic variations for multiple existing columns using auto-generated variation tags.
RResultPtr< RInterface< RLoopManager > > Snapshot(std::string_view treename, std::string_view filename, const ColumnNames_t &columnList, const RSnapshotOptions &options=RSnapshotOptions())
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< 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 or RNTuple 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< 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(const std::shared_ptr< RLoopManager > &proxied)
Build a RInterface from a RLoopManager.
RResultPtr< ROOT::Experimental::RProfile > Profile(std::shared_ptr< ROOT::Experimental::RProfile > p, const ColumnNames_t &columnList, std::string_view vName)
Fill the provided RProfile (lazy action).
RResultPtr<::THnSparseD > HistoNSparseD(const THnSparseDModel &model, const ColumnNames_t &columnList, std::string_view wName="")
Fill and return a sparse N-dimensional histogram (lazy action).
RInterface< Proxied > Redefine(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
std::shared_ptr< Proxied > fProxiedPtr
Smart pointer to the graph node encapsulated by this RInterface.
RInterface< Proxied > 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 multiple existing columns using custom variation tags.
RInterface< Proxied > Vary(std::string_view colName, std::string_view expression, std::size_t nVariations, std::string_view variationName="")
Register systematic variations for a single existing column using auto-generated variation tags.
RResultPtr<::TH1D > Histo1D(std::string_view vName)
Fill and return a one-dimensional histogram with the values of a column (lazy action).
RInterface< RDFDetail::RRange< Proxied > > Range(unsigned int begin, unsigned int end, unsigned int stride=1)
Creates a node that filters entries based on range: [begin, end).
RInterface< Proxied > DefinePerSampleImpl(std::string_view name, F expression, bool redefine)
Implementation of DefinePerSample and RedefinePerSample (non-jitted).
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< ROOT::Experimental::RHist< BinContentType > > Hist(std::vector< ROOT::Experimental::RAxisVariant > axes, const ColumnNames_t &columnList)
Fill and return an RHist (lazy action).
RResultPtr<::TProfile > Profile1D(const TProfile1DModel &model, std::string_view v1Name="", std::string_view v2Name="")
Fill and return a one-dimensional profile (lazy action).
const std::shared_ptr< Proxied > & GetProxiedPtr() const
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< T > Reduce(F f, std::string_view columnName="")
Execute a user-defined reduce operation on the values of a column.
RResultPtr< double > Median(std::string_view columnName="")
Return the median value of the input column (lazy action).
RResultPtr< T > Reduce(F f, std::string_view columnName, const T &redIdentity)
Execute a user-defined reduce operation on the values of a column.
RInterface< Proxied > Vary(const std::vector< std::string > &colNames, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName)
Register systematic variations for multiple existing columns using custom variation tags.
RInterface< RLoopManager > Cache(const ColumnNames_t &columnList)
Save selected columns in memory.
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).
RResultPtr< RDisplay > Display(std::string_view columnNameRegexp="", size_t nRows=5, size_t nMaxCollectionElements=10)
Provides a representation of the columns in the dataset.
RInterface & operator=(const RInterface &)=default
Copy-assignment operator for RInterface.
RInterface< Proxied > VaryImpl(const std::vector< std::string > &colNames, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName)
RResultPtr<::THnSparseD > HistoNSparseD(const THnSparseDModel &model, const ColumnNames_t &columnList, std::string_view wName="")
Fill and return a sparse N-dimensional histogram (lazy action).
RInterface< Proxied > Define(std::string_view name, std::string_view expression)
Define a new column.
RInterface< RDFDetail::RFilterWithMissingValues< Proxied > > FilterAvailable(std::string_view column)
Discard entries with missing values.
std::enable_if_t<!IsFStringConv &&!IsRetTypeDefConstr, RInterface< Proxied > > DefineImpl(std::string_view, F, const ColumnNames_t &, const std::string &)
RInterface< Proxied > Redefine(std::string_view name, std::string_view expression)
Overwrite the value and/or type of an existing column.
std::vector< std::string > GetFilterNames()
Returns the names of the filters created.
RInterface< RLoopManager > Cache(std::string_view columnNameRegexp="")
Save selected columns in memory.
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).
RInterface< Proxied > Vary(std::initializer_list< std::string > colNames, F &&expression, const ColumnNames_t &inputColumns, const std::vector< std::string > &variationTags, std::string_view variationName)
Register systematic variations for multiple existing columns using custom variation tags.
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< Proxied > DefinePerSampleJitImpl(std::string_view name, std::string_view expression, bool redefine)
Implementation of DefinePerSample and RedefinePerSample (jitted).
void LoadValuesCustom(const ColumnNames_t &columnList, const std::vector< std::size_t > &vecSizes, float vecPadding, ROOT::RVecF &dest)
RResultPtr< ROOT::Experimental::RProfile > Profile(std::uint64_t nNormalBins, std::pair< double, double > interval, std::string_view xName, std::string_view vName)
Fill and return a one-dimensional RProfile (lazy action).
friend class RDFInternal::GraphDrawing::GraphCreatorHelper
RResultPtr< ROOT::Experimental::RHistEngine< BinContentType > > Hist(std::shared_ptr< ROOT::Experimental::RHistEngine< BinContentType > > h, const ColumnNames_t &columnList)
Fill the provided RHistEngine (lazy action).
RInterface< RLoopManager > CacheImpl(const ColumnNames_t &columnList, std::index_sequence< S... >)
Implementation of cache.
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).
RInterface< RDFDetail::RFilter< F, Proxied > > Filter(F f, std::string_view name)
Append a filter to the call graph.
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 > RedefinePerSample(std::string_view name, std::string_view expression)
Redefine an existing column that is updated when the input sample changes.
std::enable_if_t< std::is_default_constructible< RetType >::value, RInterface< Proxied > > DefineImpl(std::string_view name, F &&expression, const ColumnNames_t &columns, const std::string &where)
RResultPtr< ROOT::Experimental::RHist< BinContentType > > Hist(std::shared_ptr< ROOT::Experimental::RHist< BinContentType > > h, const ColumnNames_t &columnList)
Fill the provided RHist (lazy action).
RInterface(const std::shared_ptr< Proxied > &proxied, RLoopManager &lm, const RDFInternal::RColumnRegister &colRegister)
RResultPtr< COLL > Take(std::string_view column="")
Return a collection of values of a column (lazy action, returns a std::vector by default).
RInterface< Proxied > Alias(std::string_view alias, std::string_view columnName)
Allow to refer to a column with a different name.
RResultPtr< ROOT::Experimental::RProfile > Profile(std::vector< ROOT::Experimental::RAxisVariant > axes, const ColumnNames_t &columnList, std::string_view vName, std::string_view wName)
Fill and return an RProfile with weights (lazy action).
RResultPtr< RDFDetail::MinReturnType_t< T > > Min(std::string_view columnName="")
Return the minimum of processed column values (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 or RNTuple treename in file filename.
RResultPtr< ROOT::Experimental::RHistEngine< BinContentType > > Hist(std::shared_ptr< ROOT::Experimental::RHistEngine< BinContentType > > h, const ColumnNames_t &columnList, std::string_view wName)
Fill the provided RHistEngine with weights (lazy action).
RResultPtr< RCutFlowReport > Report()
Gather filtering statistics.
RResultPtr<::TH3D > Histo3D(const TH3DModel &model)
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).
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< Proxied > DefinePerSample(std::string_view name, std::string_view expression)
Define a new column that is updated when the input sample changes.
RInterface< Proxied > 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< 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).
RInterface< Proxied > DefineSlot(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column with a value dependent on the processing slot.
RInterface< RDFDetail::RFilterWithMissingValues< Proxied > > FilterMissing(std::string_view column)
Keep only the entries that have missing values.
RResultPtr< TStatistic > Stats(std::string_view value="")
Return a TStatistic object, filled once per event (lazy action).
RInterface< Proxied > JittedVaryImpl(const std::vector< std::string > &colNames, std::string_view expression, const std::vector< std::string > &variationTags, std::string_view variationName, bool isSingleColumn)
RResultPtr< ROOT::Experimental::RProfile > Profile(std::shared_ptr< ROOT::Experimental::RProfile > p, const ColumnNames_t &columnList, std::string_view vName, std::string_view wName)
Fill the provided RProfile with weights (lazy action).
RInterface< Proxied > DefaultValueFor(std::string_view column, const T &defaultValue)
In case the value in the given column is missing, provide a default value.
RResultPtr< TStatistic > Stats(std::string_view value, std::string_view weight)
Return a TStatistic object, filled once per event (lazy action).
RResultPtr<::TProfile2D > Profile2D(const TProfile2DModel &model)
Fill and return a two-dimensional profile (lazy action).
RInterface< Proxied > RedefineSlot(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
void Foreach(F f, const ColumnNames_t &columns={})
Execute a user-defined function on each entry (instant action).
RResultPtr<::TH2D > Histo2D(const TH2DModel &model, std::string_view v1Name="", std::string_view v2Name="")
Fill and return a two-dimensional histogram (lazy action).
RResultPtr< ActionResultType > CallCreateActionWithoutColsIfPossible(const std::shared_ptr< ActionResultType > &, const std::shared_ptr< Helper > &, Others...)
RInterface< Proxied > Define(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column.
void ForeachSlot(F f, const ColumnNames_t &columns={})
Execute a user-defined function requiring a processing slot index on each entry (instant 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< 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.
RResultPtr< ROOT::Experimental::RProfile > Profile(std::vector< ROOT::Experimental::RAxisVariant > axes, const ColumnNames_t &columnList, std::string_view vName)
Fill and return an RProfile (lazy action).
RResultPtr< ROOT::Experimental::RHist< BinContentType > > Hist(std::shared_ptr< ROOT::Experimental::RHist< BinContentType > > h, const ColumnNames_t &columnList, std::string_view wName)
Fill the provided RHist with weights (lazy action).
RResultPtr<::TProfile > Profile1D(const TProfile1DModel &model)
Fill and return a one-dimensional profile (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 or RNTuple treename in file filename.
RInterface & operator=(RInterface &&)=default
Move-assignment operator for RInterface.
RResultPtr<::TH2D > Histo2D(const TH2DModel &model)
RResultPtr< double > Mean(std::string_view columnName="")
Return the mean of processed column values (lazy action).
RInterface< RDFDetail::RFilter< F, Proxied > > Filter(F f, const ColumnNames_t &columns={}, std::string_view name="")
Append a filter to the call graph.
RInterface< RLoopManager > Cache(const ColumnNames_t &columnList)
Save selected columns in memory.
RInterface< Proxied > DefinePerSample(std::string_view name, F expression)
Define a new column that is updated when the input sample changes.
RInterface< Proxied > Vary(std::initializer_list< std::string > colNames, F &&expression, const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName)
Register systematic variations for for multiple existing columns using custom variation tags.
RInterface< RDFDetail::RRange< Proxied > > Range(unsigned int end)
Creates a node that filters entries based on range.
RResultPtr< ROOT::Experimental::RProfile > Profile(std::uint64_t nNormalBins, std::pair< double, double > interval, std::string_view xName, std::string_view vName, std::string_view wName)
Fill and return a one-dimensional RProfile with weights (lazy action).
RInterface< Proxied > RedefineSlotEntry(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
RInterface< RDFDetail::RJittedFilter > Filter(std::string_view expression, std::string_view name="")
Append a filter to the call graph.
RResultPtr< ROOT::Experimental::RHist< BinContentType > > Hist(std::uint64_t nNormalBins, std::pair< double, double > interval, std::string_view vName)
Fill and return a one-dimensional RHist (lazy action).
RResultPtr< ROOT::Experimental::RHist< BinContentType > > Hist(std::vector< ROOT::Experimental::RAxisVariant > axes, const ColumnNames_t &columnList, std::string_view wName)
Fill and return an RHist with weights (lazy action).
RResultPtr< ULong64_t > Count()
Return the number of entries processed (lazy action).
RInterface< Proxied > RedefinePerSample(std::string_view name, F expression)
Redefine an existing column that is updated when the input sample changes.
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< Proxied > 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 multiple existing columns using auto-generated tags.
RResultPtr<::THnD > HistoND(const THnDModel &model, const ColumnNames_t &columnList, std::string_view wName="")
Fill and return an N-dimensional histogram (lazy action).
RResultPtr< double > StdDev(std::string_view columnName="")
Return the unbiased standard deviation of processed column values (lazy action).
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).
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).
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
void ChangeEmptyEntryRange(const ROOT::RDF::RNode &node, std::pair< ULong64_t, ULong64_t > &&newRange)
void ChangeSpec(const ROOT::RDF::RNode &node, ROOT::RDF::Experimental::RDatasetSpec &&spec)
Changes the input dataset specification of an RDataFrame.
const std::vector< std::string > & GetTopLevelFieldNames(const ROOT::RDF::RDataSource &ds)
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::string GetDataSourceLabel(const ROOT::RDF::RNode &node)
std::string PrettyPrintAddr(const void *const addr)
void TriggerRun(ROOT::RDF::RNode node)
Trigger the execution of an RDataFrame computation graph.
void LoadCustomValues(ROOT::RDF::RNode &node, const std::vector< std::string > &cols, const std::vector< std::size_t > &vecSizes, float vecPadding, ROOT::RVecF &dest)
std::string ColumnName2ColumnTypeName(const std::string &colName, TTree *, RDataSource *, RDefineBase *, bool vector2RVec=true)
Return a string containing the type of the given branch.
void WarnProfile()
Warn once about experimental filling of RProfile.
void SetTTreeLifeline(ROOT::RDF::RNode &node, std::any lifeline)
std::vector< std::pair< std::uint64_t, std::uint64_t > > GetDatasetGlobalClusterBoundaries(const RNode &node)
Retrieve the cluster boundaries for each cluster in the dataset, across files, with a global offset.
void WarnHist()
Warn once about experimental filling of RHist.
void ChangeBeginAndEndEntries(const RNode &node, Long64_t begin, Long64_t end)
RInterface<::ROOT::Detail::RDF::RNodeBase > RNode
std::vector< std::string > ColumnNames_t
ROOT type_traits extensions.
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).
A special bin content type to compute the bin error in weighted filling.
type is TypeList if MustRemove is false, otherwise it is a TypeList with the first type removed
Tag to let data sources use the native data type when creating a column reader.
A collection of options to steer the creation of the dataset on disk through Snapshot().
A struct which stores some basic parameters of a TH1D.
A struct which stores some basic parameters of a TH2D.
A struct which stores some basic parameters of a TH3D.
A struct which stores some basic parameters of a THnD.
A struct which stores some basic parameters of a THnSparseD.
A struct which stores some basic parameters of a TProfile.
A struct which stores some basic parameters of a TProfile2D.
Lightweight storage for a collection of types.