11#ifndef ROOT_RDF_TINTERFACE
12#define ROOT_RDF_TINTERFACE
48#include "RConfigure.h"
57#include <initializer_list>
67#include <unordered_set>
82std::string printValue(ROOT::RDataFrame *tdf);
89namespace TTraits = ROOT::TypeTraits;
91template <
typename Proxied>
99class GraphCreatorHelper;
123template <
typename Proxied>
131 template <
typename T>
138 friend std::vector<std::pair<std::uint64_t, std::uint64_t>>
164 template <typename T = Proxied, typename = std::enable_if_t<std::is_same<T, RLoopManager>::value,
int>>
231 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
234 RDFInternal::CheckFilter(
f);
235 using ColTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
236 constexpr auto nColumns = ColTypes_t::list_size;
240 using F_t = RDFDetail::RFilter<F, Proxied>;
254 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
270 template <
typename F>
351 throw std::runtime_error(
"Unknown column: \"" + std::string(column) +
"\"");
352 using F_t = RDFDetail::RFilterWithMissingValues<Proxied>;
402 throw std::runtime_error(
"Unknown column: \"" + std::string(column) +
"\"");
403 using F_t = RDFDetail::RFilterWithMissingValues<Proxied>;
449 template <typename F, typename std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
479 template <
typename F>
510 template <
typename F>
541 constexpr auto where =
"Define";
550 newCols.
AddDefine(std::move(jittedDefine));
568 template <typename F, std::enable_if_t<!std::is_convertible<F, std::string>::value,
int> = 0>
587 template <
typename F>
606 template <
typename F>
610 "RedefineSlotEntry");
629 constexpr auto where =
"Redefine";
638 newCols.
AddDefine(std::move(jittedDefine));
678 template <
typename T>
681 constexpr auto where{
"DefaultValueFor"};
691 if (retTypeName.empty()) {
695 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
699 auto newColumn = std::make_shared<ROOT::Internal::RDF::RDefaultValueFor<T>>(
704 newCols.AddDefine(std::move(newColumn));
741 template <typename F, typename RetType_t = typename TTraits::CallableTraits<F>::ret_type>
749 if (retTypeName.empty()) {
753 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
757 std::make_shared<RDFDetail::RDefinePerSample<F>>(
name, retTypeName, std::move(expression), *
fLoopManager);
760 newCols.AddDefine(std::move(newColumn));
813 newCols.
AddDefine(std::move(jittedDefine));
866 template <
typename F>
868 const std::vector<std::string> &variationTags, std::string_view variationName =
"")
870 std::vector<std::string> colNames{{std::string(colName)}};
871 const std::string theVariationName{variationName.empty() ? colName : variationName};
873 return VaryImpl<true>(std::move(colNames), std::forward<F>(expression), inputColumns, variationTags,
905 template <
typename F>
907 std::size_t nVariations, std::string_view variationName =
"")
909 R__ASSERT(nVariations > 0 &&
"Must have at least one variation.");
911 std::vector<std::string> variationTags;
912 variationTags.reserve(nVariations);
913 for (std::size_t i = 0u; i < nVariations; ++i)
914 variationTags.emplace_back(std::to_string(i));
916 const std::string theVariationName{variationName.empty() ? colName : variationName};
918 return Vary(colName, std::forward<F>(expression), inputColumns, std::move(variationTags), theVariationName);
953 template <
typename F>
955 const std::vector<std::string> &variationTags, std::string_view variationName)
957 return VaryImpl<false>(colNames, std::forward<F>(expression), inputColumns, variationTags, variationName);
974 template <
typename F>
977 const std::vector<std::string> &variationTags, std::string_view variationName)
979 return Vary(std::vector<std::string>(colNames), std::forward<F>(expression), inputColumns, variationTags, variationName);
1014 template <
typename F>
1016 std::size_t nVariations, std::string_view variationName)
1018 R__ASSERT(nVariations > 0 &&
"Must have at least one variation.");
1020 std::vector<std::string> variationTags;
1021 variationTags.reserve(nVariations);
1022 for (std::size_t i = 0u; i < nVariations; ++i)
1023 variationTags.emplace_back(std::to_string(i));
1025 return Vary(colNames, std::forward<F>(expression), inputColumns, std::move(variationTags), variationName);
1044 template <
typename F>
1046 const ColumnNames_t &inputColumns, std::size_t nVariations, std::string_view variationName)
1048 return Vary(std::vector<std::string>(colNames), std::forward<F>(expression), inputColumns, nVariations, variationName);
1089 const std::vector<std::string> &variationTags, std::string_view variationName =
"")
1091 std::vector<std::string> colNames{{std::string(colName)}};
1092 const std::string theVariationName{variationName.empty() ? colName : variationName};
1134 std::string_view variationName =
"")
1136 std::vector<std::string> variationTags;
1137 variationTags.reserve(nVariations);
1138 for (std::size_t i = 0u; i < nVariations; ++i)
1139 variationTags.emplace_back(std::to_string(i));
1141 return Vary(colName, expression, std::move(variationTags), variationName);
1196 std::size_t nVariations, std::string_view variationName)
1198 std::vector<std::string> variationTags;
1199 variationTags.reserve(nVariations);
1200 for (std::size_t i = 0u; i < nVariations; ++i)
1201 variationTags.emplace_back(std::to_string(i));
1203 return Vary(colNames, expression, std::move(variationTags), variationName);
1220 std::size_t nVariations, std::string_view variationName)
1222 return Vary(std::vector<std::string>(colNames), expression, nVariations, variationName);
1273 const std::vector<std::string> &variationTags, std::string_view variationName)
1275 return JittedVaryImpl(colNames, expression, variationTags, variationName,
false);
1299 constexpr auto where =
"Alias";
1307 newCols.AddAlias(alias, validColumnName);
1311 return newInterface;
1314 template <
typename... ColumnTypes>
1315 [[deprecated(
"Snapshot is not any more a template. You can safely remove the template parameters.")]]
1316 RResultPtr<RInterface<RLoopManager>>
1408 const auto pairOfColumnLists =
1410 const auto &colListNoAliasesWithSizeBranches = pairOfColumnLists.first;
1411 const auto &colListWithAliasesAndSizeBranches = pairOfColumnLists.second;
1413 const auto fullTreeName = treename;
1415 treename = parsedTreePath.fTreeName;
1416 const auto &dirname = parsedTreePath.fDirName;
1420 RResultPtr<RInterface<RLoopManager>> resPtr;
1422 auto retrieveTypeID = [](
const std::string &colName,
const std::string &colTypeName,
1423 bool isRNTuple =
false) ->
const std::type_info * {
1426 }
catch (
const std::runtime_error &err) {
1428 return &
typeid(ROOT::Internal::RDF::UseNativeDataType);
1430 if (std::string(err.what()).find(
"Cannot extract type_info of type") != std::string::npos) {
1432 std::string trueTypeName{colTypeName};
1433 if (colTypeName.rfind(
"CLING_UNKNOWN_TYPE", 0) == 0)
1434 trueTypeName = colTypeName.substr(19);
1435 std::string msg{
"No runtime type information is available for column \"" + colName +
1436 "\" with type name \"" + trueTypeName +
1437 "\". Thus, it cannot be written to disk with Snapshot. Make sure to generate and load "
1438 "ROOT dictionaries for the type of this column."};
1440 throw std::runtime_error(msg);
1453 auto newRDF = std::make_shared<RInterface<RLoopManager>>(std::make_shared<RLoopManager>(colListNoPoundSizes));
1455 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
1456 std::string(
filename), std::string(dirname), std::string(treename), colListWithAliasesAndSizeBranches,
1457 options, newRDF->GetLoopManager(),
GetLoopManager(),
true ,
false});
1459 auto &&nColumns = colListNoAliasesWithSizeBranches.size();
1463 std::vector<const std::type_info *> colTypeIDs;
1464 colTypeIDs.reserve(nColumns);
1465 for (
decltype(nColumns) i{}; i < nColumns; i++) {
1466 const auto &colName = validColumnNames[i];
1469 const std::type_info *colTypeID = retrieveTypeID(colName, colTypeName,
true);
1470 colTypeIDs.push_back(colTypeID);
1483 "The default Snapshot output data format is TTree, but the input data format is RNTuple. If you "
1484 "want to Snapshot to RNTuple or suppress this warning, set the appropriate fOutputFormat option in "
1485 "RSnapshotOptions. Note that this current default behaviour might change in the future.");
1490 auto newRDF = std::make_shared<RInterface<RLoopManager>>(
1491 std::make_shared<RLoopManager>(colListNoAliasesWithSizeBranches));
1493 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
1494 std::string(
filename), std::string(dirname), std::string(treename), colListWithAliasesAndSizeBranches,
1495 options, newRDF->GetLoopManager(),
GetLoopManager(),
false , options.fIncludeVariations});
1497 auto &&nColumns = colListNoAliasesWithSizeBranches.size();
1501 std::vector<const std::type_info *> colTypeIDs;
1502 colTypeIDs.reserve(nColumns);
1503 for (
decltype(nColumns) i{}; i < nColumns; i++) {
1504 const auto &colName = validColumnNames[i];
1507 const std::type_info *colTypeID = retrieveTypeID(colName, colTypeName);
1508 colTypeIDs.push_back(colTypeID);
1538 std::string_view columnNameRegexp =
"",
1546 std::copy_if(dsColumns.begin(), dsColumns.end(), std::back_inserter(dsColumnsWithoutSizeColumns),
1547 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
1549 columnNames.reserve(definedColumns.size() + dsColumnsWithoutSizeColumns.size());
1550 columnNames.insert(columnNames.end(), definedColumns.begin(), definedColumns.end());
1551 columnNames.insert(columnNames.end(), dsColumnsWithoutSizeColumns.begin(), dsColumnsWithoutSizeColumns.end());
1557 std::vector<std::string> selectedColumns;
1561 catch (
const std::runtime_error &
e){
1591 std::initializer_list<std::string> columnList,
1633 template <
typename... ColumnTypes>
1636 auto staticSeq = std::make_index_sequence<
sizeof...(ColumnTypes)>();
1637 return CacheImpl<ColumnTypes...>(columnList, staticSeq);
1650 if (columnList.empty()) {
1651 auto nEntries = *this->
Count();
1656 std::stringstream cacheCall;
1663 cacheCall <<
"*reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>*>("
1665 <<
") = reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RNodeBase>*>("
1670 const auto validColumnNames =
1672 const auto colTypes =
1674 for (
const auto &colType : colTypes)
1675 cacheCall << colType <<
", ";
1676 if (!columnListWithoutSizeColumns.empty())
1677 cacheCall.seekp(-2, cacheCall.cur);
1678 cacheCall <<
">(*reinterpret_cast<std::vector<std::string>*>("
1701 std::copy_if(dsColumns.begin(), dsColumns.end(), std::back_inserter(dsColumnsWithoutSizeColumns),
1702 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
1704 columnNames.reserve(definedColumns.size() + dsColumns.size());
1705 columnNames.insert(columnNames.end(), definedColumns.begin(), definedColumns.end());
1706 columnNames.insert(columnNames.end(), dsColumns.begin(), dsColumns.end());
1708 return Cache(selectedColumns);
1720 return Cache(selectedColumns);
1744 if (stride == 0 || (end != 0 && end < begin))
1745 throw std::runtime_error(
"Range: stride must be strictly greater than 0 and end must be greater than begin.");
1748 using Range_t = RDFDetail::RRange<Proxied>;
1749 auto rangePtr = std::make_shared<Range_t>(begin, end, stride,
fProxiedPtr);
1751 return newInterface;
1781 template <
typename F>
1784 using arg_types =
typename TTraits::CallableTraits<
decltype(
f)>::arg_types_nodecay;
1785 using ret_type =
typename TTraits::CallableTraits<
decltype(
f)>::ret_type;
1786 ForeachSlot(RDFInternal::AddSlotParameter<ret_type>(
f, arg_types()), columns);
1811 template <
typename F>
1814 using ColTypes_t = TypeTraits::RemoveFirstParameter_t<typename TTraits::CallableTraits<F>::arg_types>;
1815 constexpr auto nColumns = ColTypes_t::list_size;
1820 using Helper_t = RDFInternal::ForeachSlotHelper<F>;
1821 using Action_t = RDFInternal::RAction<Helper_t, Proxied>;
1858 template <typename F, typename T = typename TTraits::CallableTraits<F>::ret_type>
1862 std::is_default_constructible<T>::value,
1863 "reduce object cannot be default-constructed. Please provide an initialisation value (redIdentity)");
1864 return Reduce(std::move(
f), columnName, T());
1881 template <typename F, typename T = typename TTraits::CallableTraits<F>::ret_type>
1903 auto cSPtr = std::make_shared<ULong64_t>(0);
1904 using Helper_t = RDFInternal::CountHelper;
1908 return MakeResultPtr(cSPtr, *
fLoopManager, std::move(action));
1931 template <
typename T,
typename COLL = std::vector<T>>
1939 using Helper_t = RDFInternal::TakeHelper<T, T, COLL>;
1941 auto valuesPtr = std::make_shared<COLL>();
1946 return MakeResultPtr(valuesPtr, *
fLoopManager, std::move(action));
1974 template <
typename V = RDFDetail::RInferredType>
1981 std::shared_ptr<::TH1D>
h(
nullptr);
1983 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
1984 h = model.GetHistogram();
1987 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
2009 template <
typename V = RDFDetail::RInferredType>
2012 const auto h_name = std::string(vName);
2013 const auto h_title = h_name +
";" + h_name +
";count";
2014 return Histo1D<V>({h_name.c_str(), h_title.c_str(), 128u, 0., 0.}, vName);
2035 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
2038 const std::vector<std::string_view> columnViews = {vName, wName};
2042 std::shared_ptr<::TH1D>
h(
nullptr);
2044 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2048 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
2072 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
2076 std::string str_vName{vName};
2077 std::string str_wName{wName};
2078 const auto h_name = str_vName +
"_weighted_" + str_wName;
2079 const auto h_title = str_vName +
", weights: " + str_wName +
";" + str_vName +
";count * " + str_wName;
2080 return Histo1D<V, W>({h_name.c_str(), h_title.c_str(), 128u, 0., 0.}, vName, wName);
2092 template <
typename V,
typename W>
2126 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
2129 std::shared_ptr<::TH2D>
h(
nullptr);
2131 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2134 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
2135 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
2137 const std::vector<std::string_view> columnViews = {v1Name, v2Name};
2167 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType,
2168 typename W = RDFDetail::RInferredType>
2170 Histo2D(
const TH2DModel &model, std::string_view v1Name, std::string_view v2Name, std::string_view wName)
2172 std::shared_ptr<::TH2D>
h(
nullptr);
2174 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2177 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
2178 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
2180 const std::vector<std::string_view> columnViews = {v1Name, v2Name, wName};
2187 template <
typename V1,
typename V2,
typename W>
2222 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType,
2223 typename V3 = RDFDetail::RInferredType>
2225 std::string_view v3Name =
"")
2227 std::shared_ptr<::TH3D>
h(
nullptr);
2229 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2232 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
2233 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
2235 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name};
2271 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType,
2272 typename V3 = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
2274 std::string_view v3Name, std::string_view wName)
2276 std::shared_ptr<::TH3D>
h(
nullptr);
2278 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2281 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
2282 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
2284 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name, wName};
2291 template <
typename V1,
typename V2,
typename V3,
typename W>
2322 template <
typename FirstColumn,
typename... OtherColumns>
2325 std::shared_ptr<::THnD>
h(
nullptr);
2327 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2329 const auto hDims =
h->GetNdimensions();
2330 decltype(hDims) nCols = columnList.size();
2332 if (!wName.empty() && nCols == hDims + 1)
2333 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2334 "input columns contains one column more than the number of dimensions of the "
2335 "histogram. Call as 'HistoND(model, cols, weightCol)'.");
2337 if (nCols == hDims + 1)
2338 Warning(
"HistoND",
"Passing the column with the weights as the last column in the list is deprecated. "
2339 "Instead, pass it as a separate argument, e.g. 'HistoND(model, cols, weightCol)'.");
2341 if (!wName.empty() || nCols == hDims + 1)
2344 if (nCols != hDims + 1 && nCols != hDims)
2345 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2348 if (!wName.empty()) {
2352 userColumns.push_back(std::string{wName});
2353 return CreateAction<RDFInternal::ActionTags::HistoND, FirstColumn, OtherColumns...>(userColumns,
h,
h,
2356 return CreateAction<RDFInternal::ActionTags::HistoND, FirstColumn, OtherColumns...>(columnList,
h,
h,
2382 std::shared_ptr<::THnD>
h(
nullptr);
2384 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2386 const auto hDims =
h->GetNdimensions();
2387 decltype(hDims) nCols = columnList.size();
2389 if (!wName.empty() && nCols == hDims + 1)
2390 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2391 "input columns contains one column more than the number of dimensions of the "
2392 "histogram. Call as 'HistoND(model, cols, weightCol)'.");
2394 if (nCols == hDims + 1)
2395 Warning(
"HistoND",
"Passing the column with the weights as the last column in the list is deprecated. "
2396 "Instead, pass it as a separate argument, e.g. 'HistoND(model, cols, weightCol)'.");
2398 if (!wName.empty() || nCols == hDims + 1)
2401 if (nCols != hDims + 1 && nCols != hDims)
2402 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2405 if (!wName.empty()) {
2409 userColumns.push_back(std::string{wName});
2411 userColumns.size());
2442 template <
typename FirstColumn,
typename... OtherColumns>
2443 RResultPtr<::THnSparseD>
2446 std::shared_ptr<::THnSparseD>
h(
nullptr);
2448 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2450 const auto hDims =
h->GetNdimensions();
2451 decltype(hDims) nCols = columnList.size();
2453 if (!wName.empty() && nCols == hDims + 1)
2454 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2455 "input columns contains one column more than the number of dimensions of the "
2456 "histogram. Call as 'HistoNSparseD(model, cols, weightCol)'.");
2458 if (nCols == hDims + 1)
2460 "Passing the column with the weights as the last column in the list is deprecated. "
2461 "Instead, pass it as a separate argument, e.g. 'HistoNSparseD(model, cols, weightCol)'.");
2463 if (!wName.empty() || nCols == hDims + 1)
2466 if (nCols != hDims + 1 && nCols != hDims)
2467 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2470 if (!wName.empty()) {
2474 userColumns.push_back(std::string{wName});
2475 return CreateAction<RDFInternal::ActionTags::HistoNSparseD, FirstColumn, OtherColumns...>(userColumns,
h,
h,
2478 return CreateAction<RDFInternal::ActionTags::HistoNSparseD, FirstColumn, OtherColumns...>(columnList,
h,
h,
2502 RResultPtr<::THnSparseD>
2505 std::shared_ptr<::THnSparseD>
h(
nullptr);
2507 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2509 const auto hDims =
h->GetNdimensions();
2510 decltype(hDims) nCols = columnList.size();
2512 if (!wName.empty() && nCols == hDims + 1)
2513 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2514 "input columns contains one column more than the number of dimensions of the "
2515 "histogram. Call as 'HistoNSparseD(model, cols, weightCol)'.");
2517 if (nCols == hDims + 1)
2519 "Passing the column with the weights as the last column in the list is deprecated. "
2520 "Instead, pass it as a separate argument, e.g. 'HistoNSparseD(model, cols, weightCol)'.");
2522 if (!wName.empty() || nCols == hDims + 1)
2525 if (nCols != hDims + 1 && nCols != hDims)
2526 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2529 if (!wName.empty()) {
2533 userColumns.push_back(std::string{wName});
2557 template <
typename BinContentType =
double,
typename V = RDFDetail::RInferredType>
2558 RResultPtr<ROOT::Experimental::RHist<BinContentType>>
2559 Hist(std::uint64_t nNormalBins, std::pair<double, double> interval, std::string_view vName)
2561 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(nNormalBins, interval);
2583 template <
typename BinContentType =
double,
typename ColumnType = RDFDetail::RInferredType,
typename... ColumnTypes>
2584 RResultPtr<ROOT::Experimental::RHist<BinContentType>>
2587 if (axes.size() != columnList.size()) {
2588 std::string msg =
"Wrong number of columns for the specified number of histogram axes: ";
2589 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(columnList.size());
2590 throw std::invalid_argument(msg);
2593 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
2595 return Hist<ColumnType, ColumnTypes...>(
h, columnList);
2615 template <
typename ColumnType = RDFDetail::RInferredType,
typename... ColumnTypes,
typename BinContentType>
2616 RResultPtr<ROOT::Experimental::RHist<BinContentType>>
2621 if (
h->GetNDimensions() != columnList.size()) {
2622 std::string msg =
"Wrong number of columns for the passed histogram: ";
2623 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2624 throw std::invalid_argument(msg);
2648 typename W = RDFDetail::RInferredType>
2649 RResultPtr<ROOT::Experimental::RHist<BinContentType>>
2650 Hist(std::uint64_t nNormalBins, std::pair<double, double> interval, std::string_view vName, std::string_view wName)
2652 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(nNormalBins, interval);
2678 typename ColumnType = RDFDetail::RInferredType,
typename... ColumnTypes>
2679 RResultPtr<ROOT::Experimental::RHist<BinContentType>>
2680 Hist(std::vector<ROOT::Experimental::RAxisVariant> axes,
const ColumnNames_t &columnList, std::string_view wName)
2683 "weighted filling is not supported for integral bin content types");
2685 if (axes.size() != columnList.size()) {
2686 std::string msg =
"Wrong number of columns for the specified number of histogram axes: ";
2687 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(columnList.size());
2688 throw std::invalid_argument(msg);
2691 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
2693 return Hist<ColumnType, ColumnTypes...>(
h, columnList, wName);
2716 template <
typename ColumnType = RDFDetail::RInferredType,
typename... ColumnTypes,
typename BinContentType>
2717 RResultPtr<ROOT::Experimental::RHist<BinContentType>>
2719 std::string_view wName)
2722 "weighted filling is not supported for integral bin content types");
2726 if (
h->GetNDimensions() != columnList.size()) {
2727 std::string msg =
"Wrong number of columns for the passed histogram: ";
2728 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2729 throw std::invalid_argument(msg);
2734 columnListWithWeights.push_back(std::string(wName));
2736 return CreateAction<RDFInternal::ActionTags::HistWithWeight, ColumnType, ColumnTypes...>(
2737 columnListWithWeights,
h,
h,
fProxiedPtr, columnListWithWeights.size());
2757 template <
typename ColumnType = RDFDetail::RInferredType,
typename... ColumnTypes,
typename BinContentType>
2758 RResultPtr<ROOT::Experimental::RHistEngine<BinContentType>>
2763 if (
h->GetNDimensions() != columnList.size()) {
2764 std::string msg =
"Wrong number of columns for the passed histogram: ";
2765 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2766 throw std::invalid_argument(msg);
2793 template <
typename ColumnType = RDFDetail::RInferredType,
typename... ColumnTypes,
typename BinContentType>
2794 RResultPtr<ROOT::Experimental::RHistEngine<BinContentType>>
2796 std::string_view wName)
2799 "weighted filling is not supported for integral bin content types");
2803 if (
h->GetNDimensions() != columnList.size()) {
2804 std::string msg =
"Wrong number of columns for the passed histogram: ";
2805 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(columnList.size());
2806 throw std::invalid_argument(msg);
2811 columnListWithWeights.push_back(std::string(wName));
2813 return CreateAction<RDFInternal::ActionTags::HistWithWeight, ColumnType, ColumnTypes...>(
2814 columnListWithWeights,
h,
h,
fProxiedPtr, columnListWithWeights.size());
2846 template <
typename X = RDFDetail::RInferredType,
typename Y = RDFDetail::RInferredType>
2849 auto graph = std::make_shared<::TGraph>();
2850 const std::vector<std::string_view> columnViews = {
x,
y};
2858 const auto g_name = validatedColumns[1] +
"_vs_" + validatedColumns[0];
2859 const auto g_title = validatedColumns[1] +
" vs " + validatedColumns[0];
2860 graph->SetNameTitle(g_name.c_str(), g_title.c_str());
2861 graph->GetXaxis()->SetTitle(validatedColumns[0].c_str());
2862 graph->GetYaxis()->SetTitle(validatedColumns[1].c_str());
2908 template <
typename X = RDFDetail::RInferredType,
typename Y = RDFDetail::RInferredType,
2909 typename EXL = RDFDetail::RInferredType,
typename EXH = RDFDetail::RInferredType,
2910 typename EYL = RDFDetail::RInferredType,
typename EYH = RDFDetail::RInferredType>
2911 RResultPtr<::TGraphAsymmErrors>
2913 std::string_view exh =
"", std::string_view eyl =
"", std::string_view eyh =
"")
2915 auto graph = std::make_shared<::TGraphAsymmErrors>();
2916 const std::vector<std::string_view> columnViews = {
x,
y, exl, exh, eyl, eyh};
2924 const auto g_name = validatedColumns[1] +
"_vs_" + validatedColumns[0];
2925 const auto g_title = validatedColumns[1] +
" vs " + validatedColumns[0];
2926 graph->SetNameTitle(g_name.c_str(), g_title.c_str());
2927 graph->GetXaxis()->SetTitle(validatedColumns[0].c_str());
2928 graph->GetYaxis()->SetTitle(validatedColumns[1].c_str());
2957 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
2958 RResultPtr<::TProfile>
2961 std::shared_ptr<::TProfile>
h(
nullptr);
2963 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
2967 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2968 throw std::runtime_error(
"Profiles with no axes limits are not supported yet.");
2970 const std::vector<std::string_view> columnViews = {v1Name, v2Name};
3001 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType,
3002 typename W = RDFDetail::RInferredType>
3003 RResultPtr<::TProfile>
3006 std::shared_ptr<::TProfile>
h(
nullptr);
3008 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
3012 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
3013 throw std::runtime_error(
"Profile histograms with no axes limits are not supported yet.");
3015 const std::vector<std::string_view> columnViews = {v1Name, v2Name, wName};
3025 template <
typename V1,
typename V2,
typename W>
3058 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType,
3059 typename V3 = RDFDetail::RInferredType>
3061 std::string_view v2Name =
"", std::string_view v3Name =
"")
3063 std::shared_ptr<::TProfile2D>
h(
nullptr);
3065 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
3069 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
3070 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
3072 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name};
3106 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType,
3107 typename V3 = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
3109 std::string_view v3Name, std::string_view wName)
3111 std::shared_ptr<::TProfile2D>
h(
nullptr);
3113 ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(
kError);
3117 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
3118 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
3120 const std::vector<std::string_view> columnViews = {v1Name, v2Name, v3Name, wName};
3129 template <
typename V1,
typename V2,
typename V3,
typename W>
3169 template <
typename FirstColumn = RDFDetail::RInferredType,
typename... OtherColumns,
typename T>
3172 auto h = std::make_shared<std::decay_t<T>>(std::forward<T>(model));
3173 if (!RDFInternal::HistoUtils<T>::HasAxisLimits(*
h)) {
3174 throw std::runtime_error(
"The absence of axes limits is not supported yet.");
3195 template <
typename V = RDFDetail::RInferredType>
3199 if (!
value.empty()) {
3200 columns.emplace_back(std::string(
value));
3203 if (std::is_same<V, RDFDetail::RInferredType>::value) {
3227 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
3231 constexpr auto vIsInferred = std::is_same<V, RDFDetail::RInferredType>::value;
3232 constexpr auto wIsInferred = std::is_same<W, RDFDetail::RInferredType>::value;
3238 if (vIsInferred && wIsInferred) {
3240 }
else if (vIsInferred != wIsInferred) {
3241 std::string error(
"The ");
3242 error += vIsInferred ?
"value " :
"weight ";
3243 error +=
"column type is explicit, while the ";
3244 error += vIsInferred ?
"weight " :
"value ";
3245 error +=
" is specified to be inferred. This case is not supported: please specify both types or none.";
3246 throw std::runtime_error(error);
3273 template <
typename T = RDFDetail::RInferredType>
3277 using RetType_t = RDFDetail::MinReturnType_t<T>;
3278 auto minV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::max());
3303 template <
typename T = RDFDetail::RInferredType>
3307 using RetType_t = RDFDetail::MaxReturnType_t<T>;
3308 auto maxV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::lowest());
3334 template <
typename T = RDFDetail::RInferredType>
3338 auto meanV = std::make_shared<double>(0);
3362 template <
typename T = RDFDetail::RInferredType>
3366 auto stdDeviationV = std::make_shared<double>(0);
3393 template <
typename T = RDFDetail::RInferredType>
3394 RResultPtr<RDFDetail::SumReturnType_t<T>>
3395 Sum(std::string_view columnName =
"",
3396 const RDFDetail::SumReturnType_t<T> &initValue = RDFDetail::SumReturnType_t<T>{})
3399 auto sumV = std::make_shared<RDFDetail::SumReturnType_t<T>>(initValue);
3430 bool returnEmptyReport =
false;
3437 returnEmptyReport =
true;
3439 auto rep = std::make_shared<RCutFlowReport>();
3446 return MakeResultPtr(rep, *
fLoopManager, std::move(action));
3510 template <typename AccFun, typename MergeFun, typename R = typename TTraits::CallableTraits<AccFun>::ret_type,
3511 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
3512 typename ArgTypesNoDecay =
typename TTraits::CallableTraits<AccFun>::arg_types_nodecay,
3513 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
3514 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
3517 RDFInternal::CheckAggregate<R, MergeFun>(ArgTypesNoDecay());
3523 auto accObjPtr = std::make_shared<U>(aggIdentity);
3524 using Helper_t = RDFInternal::AggregateHelper<AccFun, MergeFun, R, T, U>;
3526 auto action = std::make_unique<Action_t>(
3527 Helper_t(std::move(aggregator), std::move(merger), accObjPtr,
fLoopManager->GetNSlots()), validColumnNames,
3529 return MakeResultPtr(accObjPtr, *
fLoopManager, std::move(action));
3545 template <typename AccFun, typename MergeFun, typename R = typename TTraits::CallableTraits<AccFun>::ret_type,
3546 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
3547 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
3548 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
3552 std::is_default_constructible<U>::value,
3553 "aggregated object cannot be default-constructed. Please provide an initialisation value (aggIdentity)");
3554 return Aggregate(std::move(aggregator), std::move(merger), columnName, U());
3620 template <
typename FirstColumn = RDFDetail::RInferredType,
typename... OtherColumns,
typename Helper>
3623 using HelperT = std::decay_t<Helper>;
3625 using AH = RDFDetail::RActionImpl<HelperT>;
3626 static_assert(std::is_base_of<AH, HelperT>::value && std::is_convertible<HelperT *, AH *>::value,
3627 "Action helper of type T must publicly inherit from ROOT::Detail::RDF::RActionImpl<T>");
3629 auto hPtr = std::make_shared<HelperT>(std::forward<Helper>(helper));
3630 auto resPtr = hPtr->GetResultPtr();
3632 if (std::is_same<FirstColumn, RDFDetail::RInferredType>::value && columns.empty()) {
3635 return CreateAction<RDFInternal::ActionTags::Book, FirstColumn, OtherColumns...>(columns, resPtr, hPtr,
3665 template <
typename... ColumnTypes>
3669 auto newCols = columnList;
3670 newCols.insert(newCols.begin(),
"rdfentry_");
3671 auto displayer = std::make_shared<RDisplay>(newCols,
GetColumnTypeNamesList(newCols), nMaxCollectionElements);
3672 using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<RDisplay>>;
3675 std::move(newCols), displayer, std::make_shared<displayHelperArgs_t>(nRows, displayer),
fProxiedPtr);
3692 auto newCols = columnList;
3693 newCols.insert(newCols.begin(),
"rdfentry_");
3694 auto displayer = std::make_shared<RDisplay>(newCols,
GetColumnTypeNamesList(newCols), nMaxCollectionElements);
3695 using displayHelperArgs_t = std::pair<size_t, std::shared_ptr<RDisplay>>;
3697 std::move(newCols), displayer, std::make_shared<displayHelperArgs_t>(nRows, displayer),
fProxiedPtr,
3698 columnList.size() + 1);
3711 RResultPtr<RDisplay>
3712 Display(std::string_view columnNameRegexp =
"",
size_t nRows = 5,
size_t nMaxCollectionElements = 10)
3716 return Display(selectedColumns, nRows, nMaxCollectionElements);
3727 RResultPtr<RDisplay>
3728 Display(std::initializer_list<std::string> columnList,
size_t nRows = 5,
size_t nMaxCollectionElements = 10)
3731 return Display(selectedColumns, nRows, nMaxCollectionElements);
3735 template <typename F, typename DefineType, typename RetType = typename TTraits::CallableTraits<F>::ret_type>
3739 if (where.compare(0, 8,
"Redefine") != 0) {
3749 using ArgTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
3751 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::Slot>::value, ArgTypes_t>
::type;
3753 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::SlotAndEntry>::value, ColTypesTmp_t>
::type;
3755 constexpr auto nColumns = ColTypes_t::list_size;
3762 if (retTypeName.empty()) {
3766 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
3769 using NewCol_t = RDFDetail::RDefine<F, DefineType>;
3770 auto newColumn = std::make_shared<NewCol_t>(
name, retTypeName, std::forward<F>(expression), validColumnNames,
3774 newCols.
AddDefine(std::move(newColumn));
3778 return newInterface;
3784 template <typename F, typename DefineType, typename RetType = typename TTraits::CallableTraits<F>::ret_type,
3785 bool IsFStringConv = std::is_convertible<F, std::string>::value,
3786 bool IsRetTypeDefConstr = std::is_default_constructible<RetType>::value>
3787 std::enable_if_t<!IsFStringConv && !IsRetTypeDefConstr, RInterface<Proxied>>
3790 static_assert(std::is_default_constructible<typename TTraits::CallableTraits<F>::ret_type>
::value,
3791 "Error in `Define`: type returned by expression is not default-constructible");
3797 template <
typename... ColTypes, std::size_t... S>
3803 constexpr bool areCopyConstructible =
3804 RDFInternal::TEvalAnd<std::is_copy_constructible<ColTypes>::value...>
::value;
3805 static_assert(areCopyConstructible,
"Columns of a type which is not copy constructible cannot be cached yet.");
3809 auto colHolders = std::make_tuple(
Take<ColTypes>(columnListWithoutSizeColumns[S])...);
3810 auto ds = std::make_unique<
RLazyDS<ColTypes...>>(
3811 std::make_pair(columnListWithoutSizeColumns[S], std::get<S>(colHolders))...);
3818 template <
bool IsSingleColumn,
typename F>
3821 const std::vector<std::string> &variationTags, std::string_view variationName)
3823 using F_t = std::decay_t<F>;
3824 using ColTypes_t =
typename TTraits::CallableTraits<F_t>::arg_types;
3825 using RetType =
typename TTraits::CallableTraits<F_t>::ret_type;
3826 constexpr auto nColumns = ColTypes_t::list_size;
3834 if (retTypeName.empty()) {
3838 retTypeName =
"CLING_UNKNOWN_TYPE_" + demangledType;
3841 auto variation = std::make_shared<RDFInternal::RVariation<F_t, IsSingleColumn>>(
3846 newCols.AddVariation(std::move(variation));
3850 return newInterface;
3854 const std::vector<std::string> &variationTags, std::string_view variationName,
3855 bool isSingleColumn)
3857 R__ASSERT(!variationTags.empty() &&
"Must have at least one variation.");
3858 R__ASSERT(!colNames.empty() &&
"Must have at least one varied column.");
3859 R__ASSERT(!variationName.empty() &&
"Must provide a variation name.");
3861 for (
auto &colName : colNames) {
3869 if (colNames.size() > 1) {
3870 std::set<std::string> uniqueCols(colNames.begin(), colNames.end());
3871 if (uniqueCols.size() != colNames.size())
3872 throw std::logic_error(
"A column name was passed to the same Vary invocation multiple times.");
3877 auto jittedVariation =
3882 newColRegister.
AddVariation(std::move(jittedVariation));
3886 return newInterface;
3889 template <
typename Helper,
typename ActionResultType>
3891 const std::shared_ptr<Helper> &hPtr,
3892 TTraits::TypeList<RDFDetail::RInferredType>)
3898 template <
typename Helper,
typename ActionResultType,
typename... Others>
3899 RResultPtr<ActionResultType>
3901 const std::shared_ptr<Helper>& ,
3904 throw std::logic_error(std::string(
"An action was booked with no input columns, but the action requires "
3905 "columns! The action helper type was ") +
3906 typeid(Helper).
name());
std::shared_ptr< Proxied > fProxiedPtr
Smart pointer to the graph node encapsulated by this RInterface.
RDFDetail::RLoopManager RLoopManager
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.
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
A histogram data structure to bin data along multiple dimensions.
static constexpr bool SupportsWeightedFilling
Whether this histogram engine type supports weighted filling.
A histogram for aggregation of data along multiple dimensions.
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.
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...
void SanityChecksForVary(const std::vector< std::string > &colNames, const std::vector< std::string > &variationTags, std::string_view variationName)
RDataSource * GetDataSource() const
void CheckAndFillDSColumns(ColumnNames_t validCols, TTraits::TypeList< ColumnTypes... > typeList)
void CheckIMTDisabled(std::string_view callerName)
RInterfaceBase(std::shared_ptr< RDFDetail::RLoopManager > lm)
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.
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.
RDFDetail::RFilterBase RFilterBase
RInterface(const RInterface &)=default
Copy-ctor for RInterface.
RInterface(RInterface &&)=default
Move-ctor for RInterface.
RInterface< RDFDetail::RFilter< F, Proxied > > Filter(F f, const std::initializer_list< std::string > &columns)
Append a filter to the call graph.
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(const std::shared_ptr< RLoopManager > &proxied)
Build a RInterface from a RLoopManager.
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< ::ROOT::Detail::RDF::RNodeBase > fProxiedPtr
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.
RDFDetail::RRangeBase RRangeBase
RInterface & operator=(const RInterface &)=default
Copy-assignment operator for RInterface.
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.
RInterface< Proxied > Redefine(std::string_view name, std::string_view expression)
Overwrite the value and/or type of an existing column.
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.
RInterface< RDFDetail::RFilter< F, Proxied > > Filter(F f, std::string_view name)
Append a filter to the call graph.
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.
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.
RInterface< Proxied > DefaultValueFor(std::string_view column, const T &defaultValue)
In case the value in the given column is missing, provide a default value.
RInterface< Proxied > RedefineSlot(std::string_view name, F expression, const ColumnNames_t &columns={})
Overwrite the value and/or type of an existing column.
RInterface< Proxied > Define(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column.
RInterface & operator=(RInterface &&)=default
Move-assignment operator for RInterface.
RDFDetail::RLoopManager RLoopManager
RInterface< RDFDetail::RFilter< F, Proxied > > Filter(F f, const ColumnNames_t &columns={}, std::string_view name="")
Append a filter to the call graph.
RInterface< Proxied > DefinePerSample(std::string_view name, F expression)
Define a new column that is updated when the input sample changes.
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.
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 ,...
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).
RResultPtr< T > MakeResultPtr(const std::shared_ptr< T > &r, RLoopManager &df, std::shared_ptr< ROOT::Internal::RDF::RActionBase > actionPtr)
Create a RResultPtr and set its pointer to the corresponding RAction This overload is invoked by non-...
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)
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)
std::shared_ptr< RJittedDefine > BookDefinePerSampleJit(std::string_view name, std::string_view expression, RLoopManager &lm, const RColumnRegister &colRegister)
Book the jitting of a DefinePerSample 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.
const std::vector< std::string > & GetTopLevelFieldNames(const ROOT::RDF::RDataSource &ds)
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...
void CheckSnapshotOptionsFormatCompatibility(const ROOT::RDF::RSnapshotOptions &opts)
void CheckForDefinition(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister, const ColumnNames_t &dataSourceColumns)
Throw if column definedColView is not already there.
std::string GetDataSourceLabel(const ROOT::RDF::RNode &node)
std::string PrettyPrintAddr(const void *const addr)
std::shared_ptr< RDFDetail::RJittedFilter > BookFilterJit(std::shared_ptr< RDFDetail::RNodeBase > prevNode, std::string_view name, std::string_view expression, const RColumnRegister &colRegister, TTree *tree, RDataSource *ds)
Book the jitting of a Filter call.
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::pair< std::vector< std::string >, std::vector< std::string > > AddSizeBranches(ROOT::RDF::RDataSource *ds, 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::string ColumnName2ColumnTypeName(const std::string &colName, TTree *, RDataSource *, RDefineBase *, bool vector2RVec=true)
Return a string containing the type of the given branch.
void SetTTreeLifeline(ROOT::RDF::RNode &node, std::any lifeline)
void RemoveRNTupleSubfields(ColumnNames_t &columnNames)
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.
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.
void WarnHist()
Warn once about experimental filling of RHist.
void CheckForDuplicateSnapshotColumns(const ColumnNames_t &cols)
ColumnNames_t ConvertRegexToColumns(const ColumnNames_t &colNames, std::string_view columnNameRegexp, std::string_view callerName)
void CheckForRedefinition(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister, const ColumnNames_t &dataSourceColumns)
Throw if column definedColView is already there.
std::shared_ptr< RJittedDefine > BookDefineJit(std::string_view name, std::string_view expression, RLoopManager &lm, RDataSource *ds, const RColumnRegister &colRegister)
Book the jitting of a Define call.
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, bool isSingleColumn, const std::string &varyColType)
Book the jitting of a Vary call.
void ChangeBeginAndEndEntries(const RNode &node, Long64_t begin, Long64_t end)
RResultPtr< COLL > Take(std::string_view column="")
Return a collection of values of a column (lazy action, returns a std::vector by default).
RResultPtr<::TGraph > Graph(std::string_view x="", std::string_view y="")
Fill and return a TGraph object (lazy action).
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<::TH2D > Histo2D(const TH2DModel &model, std::string_view v1Name="", std::string_view v2Name="")
Fill and return a two-dimensional histogram (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< RDisplay > Display(const ColumnNames_t &columnList, size_t nRows=5, size_t nMaxCollectionElements=10)
Provides a representation of the columns in the dataset.
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< 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).
RResultPtr<::TProfile > Profile1D(const TProfile1DModel &model, std::string_view v1Name="", std::string_view v2Name="")
Fill and return a one-dimensional profile (lazy action).
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< ULong64_t > Count()
Return the number of entries processed (lazy action).
std::vector< std::string > GetFilterNames()
Returns the names of the filters created.
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< T > Reduce(F f, std::string_view columnName="")
Execute a user-defined reduce operation on the values of a column.
RResultPtr< RInterface< RLoopManager > > Snapshot(std::string_view treename, std::string_view filename, const ColumnNames_t &columnList, const RSnapshotOptions &options=RSnapshotOptions())
RInterface< Proxied > Alias(std::string_view alias, std::string_view columnName)
Allow to refer to a column with a different name.
void Foreach(F f, const ColumnNames_t &columns={})
Execute a user-defined function on each entry (instant 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< 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.
void ForeachSlot(F f, const ColumnNames_t &columns={})
Execute a user-defined function requiring a processing slot index on each entry (instant action).
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 >{})
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< double > StdDev(std::string_view columnName="")
Return the unbiased standard deviation of processed column values (lazy action).
RInterface<::ROOT::Detail::RDF::RNodeBase > RNode
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).
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<::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< RLoopManager > CacheImpl(const ColumnNames_t &columnList, std::index_sequence< S... >)
Implementation of cache.
std::vector< std::string > ColumnNames_t
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).
RResultPtr< RDFDetail::MinReturnType_t< T > > Min(std::string_view columnName="")
Return the minimum of processed column values (lazy action).
const std::shared_ptr< Proxied > & GetProxiedPtr() const
RInterface< RLoopManager > Cache(const ColumnNames_t &columnList)
Save selected columns in memory.
RResultPtr< TStatistic > Stats(std::string_view value="")
Return a TStatistic object, filled once per event (lazy action).
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< RCutFlowReport > Report()
Gather filtering statistics.
RResultPtr< double > Mean(std::string_view columnName="")
Return the mean of processed column values (lazy action).
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.
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
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.
std::shared_ptr<::TH1D > GetHistogram() const
A struct which stores some basic parameters of a TH2D.
std::shared_ptr<::TH2D > GetHistogram() const
A struct which stores some basic parameters of a TH3D.
std::shared_ptr<::TH3D > GetHistogram() const
A struct which stores some basic parameters of a THnD.
std::shared_ptr<::THnD > GetHistogram() const
A struct which stores some basic parameters of a THnSparseD.
std::shared_ptr<::THnSparseD > GetHistogram() const
A struct which stores some basic parameters of a TProfile.
std::shared_ptr<::TProfile > GetProfile() const
A struct which stores some basic parameters of a TProfile2D.
std::shared_ptr<::TProfile2D > GetProfile() const