11#ifndef ROOT_RDF_TINTERFACE
12#define ROOT_RDF_TINTERFACE
48#include "RConfigure.h"
57#include <initializer_list>
67#include <unordered_set>
91template <
typename Proxied>
123template <
typename Proxied>
131 template <
typename T>
138 friend std::vector<std::pair<std::uint64_t, std::uint64_t>>
234 RDFInternal::CheckFilter(
f);
235 using ColTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
236 constexpr auto nColumns = ColTypes_t::list_size;
270 template <
typename F>
351 throw std::runtime_error(
"Unknown column: \"" + std::string(column) +
"\"");
402 throw std::runtime_error(
"Unknown column: \"" + std::string(column) +
"\"");
479 template <
typename F>
510 template <
typename F>
541 constexpr auto where =
"Define";
587 template <
typename F>
606 template <
typename F>
610 "RedefineSlotEntry");
629 constexpr auto where =
"Redefine";
678 template <
typename T>
681 constexpr auto where{
"DefaultValueFor"};
699 auto newColumn = std::make_shared<ROOT::Internal::RDF::RDefaultValueFor<T>>(
866 template <
typename F>
905 template <
typename F>
953 template <
typename F>
974 template <
typename F>
1014 template <
typename F>
1044 template <
typename F>
1225 constexpr auto where =
"Alias";
1241 [[deprecated(
"Snapshot is not any more a template. You can safely remove the template parameters.")]]
1349 bool isRNTuple =
false) ->
const std::type_info * {
1352 }
catch (
const std::runtime_error &err) {
1356 if (std::string(err.what()).find(
"Cannot extract type_info of type") != std::string::npos) {
1359 if (
colTypeName.rfind(
"CLING_UNKNOWN_TYPE", 0) == 0)
1361 std::string
msg{
"No runtime type information is available for column \"" +
colName +
1363 "\". Thus, it cannot be written to disk with Snapshot. Make sure to generate and load "
1364 "ROOT dictionaries for the type of this column."};
1366 throw std::runtime_error(
msg);
1381 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
1389 std::vector<const std::type_info *>
colTypeIDs;
1409 "The default Snapshot output data format is TTree, but the input data format is RNTuple. If you "
1410 "want to Snapshot to RNTuple or suppress this warning, set the appropriate fOutputFormat option in "
1411 "RSnapshotOptions. Note that this current default behaviour might change in the future.");
1416 auto newRDF = std::make_shared<RInterface<RLoopManager>>(
1419 auto snapHelperArgs = std::make_shared<RDFInternal::SnapshotHelperArgs>(RDFInternal::SnapshotHelperArgs{
1427 std::vector<const std::type_info *>
colTypeIDs;
1473 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
1487 catch (
const std::runtime_error &
e){
1517 std::initializer_list<std::string>
columnList,
1562 auto staticSeq = std::make_index_sequence<
sizeof...(ColumnTypes)>();
1589 cacheCall <<
"*reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>*>("
1591 <<
") = reinterpret_cast<ROOT::RDF::RInterface<ROOT::Detail::RDF::RNodeBase>*>("
1604 cacheCall <<
">(*reinterpret_cast<std::vector<std::string>*>("
1628 [](
const std::string &
name) { return name.size() < 13 || name.substr(0, 13) !=
"R_rdf_sizeof_"; });
1670 if (
stride == 0 || (end != 0 && end < begin))
1671 throw std::runtime_error(
"Range: stride must be strictly greater than 0 and end must be greater than begin.");
1707 template <
typename F>
1710 using arg_types =
typename TTraits::CallableTraits<
decltype(
f)>::arg_types_nodecay;
1711 using ret_type =
typename TTraits::CallableTraits<
decltype(
f)>::ret_type;
1737 template <
typename F>
1741 constexpr auto nColumns = ColTypes_t::list_size;
1746 using Helper_t = RDFInternal::ForeachSlotHelper<F>;
1788 std::is_default_constructible<T>::value,
1789 "reduce object cannot be default-constructed. Please provide an initialisation value (redIdentity)");
1829 auto cSPtr = std::make_shared<ULong64_t>(0);
1830 using Helper_t = RDFInternal::CountHelper;
1857 template <
typename T,
typename COLL = std::vector<T>>
1865 using Helper_t = RDFInternal::TakeHelper<T, T, COLL>;
1867 auto valuesPtr = std::make_shared<COLL>();
1900 template <
typename V = RDFDetail::RInferredType>
1907 std::shared_ptr<::TH1D>
h(
nullptr);
1909 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
1910 h = model.GetHistogram();
1913 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
1935 template <
typename V = RDFDetail::RInferredType>
1961 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
1968 std::shared_ptr<::TH1D>
h(
nullptr);
1970 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
1974 if (
h->GetXaxis()->GetXmax() ==
h->GetXaxis()->GetXmin())
1998 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
2018 template <
typename V,
typename W>
2052 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
2055 std::shared_ptr<::TH2D>
h(
nullptr);
2057 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2060 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
2061 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
2098 std::shared_ptr<::TH2D>
h(
nullptr);
2100 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2103 if (!RDFInternal::HistoUtils<::TH2D>::HasAxisLimits(*
h)) {
2104 throw std::runtime_error(
"2D histograms with no axes limits are not supported yet.");
2113 template <
typename V1,
typename V2,
typename W>
2151 std::string_view
v3Name =
"")
2153 std::shared_ptr<::TH3D>
h(
nullptr);
2155 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2158 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
2159 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
2202 std::shared_ptr<::TH3D>
h(
nullptr);
2204 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2207 if (!RDFInternal::HistoUtils<::TH3D>::HasAxisLimits(*
h)) {
2208 throw std::runtime_error(
"3D histograms with no axes limits are not supported yet.");
2217 template <
typename V1,
typename V2,
typename V3,
typename W>
2251 std::shared_ptr<::THnD>
h(
nullptr);
2253 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2255 const auto hDims =
h->GetNdimensions();
2259 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2260 "input columns contains one column more than the number of dimensions of the "
2261 "histogram. Call as 'HistoND(model, cols, weightCol)'.");
2264 Warning(
"HistoND",
"Passing the column with the weights as the last column in the list is deprecated. "
2265 "Instead, pass it as a separate argument, e.g. 'HistoND(model, cols, weightCol)'.");
2271 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2274 if (!
wName.empty()) {
2308 std::shared_ptr<::THnD>
h(
nullptr);
2310 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2312 const auto hDims =
h->GetNdimensions();
2316 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2317 "input columns contains one column more than the number of dimensions of the "
2318 "histogram. Call as 'HistoND(model, cols, weightCol)'.");
2321 Warning(
"HistoND",
"Passing the column with the weights as the last column in the list is deprecated. "
2322 "Instead, pass it as a separate argument, e.g. 'HistoND(model, cols, weightCol)'.");
2328 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2331 if (!
wName.empty()) {
2372 std::shared_ptr<::THnSparseD>
h(
nullptr);
2374 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2376 const auto hDims =
h->GetNdimensions();
2380 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2381 "input columns contains one column more than the number of dimensions of the "
2382 "histogram. Call as 'HistoNSparseD(model, cols, weightCol)'.");
2386 "Passing the column with the weights as the last column in the list is deprecated. "
2387 "Instead, pass it as a separate argument, e.g. 'HistoNSparseD(model, cols, weightCol)'.");
2393 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2396 if (!
wName.empty()) {
2431 std::shared_ptr<::THnSparseD>
h(
nullptr);
2433 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2435 const auto hDims =
h->GetNdimensions();
2439 throw std::invalid_argument(
"The weight column was passed as an argument and at the same time the list of "
2440 "input columns contains one column more than the number of dimensions of the "
2441 "histogram. Call as 'HistoNSparseD(model, cols, weightCol)'.");
2445 "Passing the column with the weights as the last column in the list is deprecated. "
2446 "Instead, pass it as a separate argument, e.g. 'HistoNSparseD(model, cols, weightCol)'.");
2452 throw std::invalid_argument(
"Wrong number of columns for the specified number of histogram axes.");
2455 if (!
wName.empty()) {
2483 template <
typename BinContentType =
double,
typename V = RDFDetail::RInferredType>
2487 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(
nNormalBins,
interval);
2514 std::string
msg =
"Wrong number of columns for the specified number of histogram axes: ";
2515 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(
columnList.size());
2516 throw std::invalid_argument(
msg);
2519 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
2548 std::string
msg =
"Wrong number of columns for the passed histogram: ";
2549 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(
columnList.size());
2550 throw std::invalid_argument(
msg);
2578 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(
nNormalBins,
interval);
2609 "weighted filling is not supported for integral bin content types");
2612 std::string
msg =
"Wrong number of columns for the specified number of histogram axes: ";
2613 msg +=
"expected " + std::to_string(axes.size()) +
", got " + std::to_string(
columnList.size());
2614 throw std::invalid_argument(
msg);
2617 std::shared_ptr
h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes));
2645 std::string_view
wName)
2648 "weighted filling is not supported for integral bin content types");
2653 std::string
msg =
"Wrong number of columns for the passed histogram: ";
2654 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(
columnList.size());
2655 throw std::invalid_argument(
msg);
2690 std::string
msg =
"Wrong number of columns for the passed histogram: ";
2691 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(
columnList.size());
2692 throw std::invalid_argument(
msg);
2722 std::string_view
wName)
2725 "weighted filling is not supported for integral bin content types");
2730 std::string
msg =
"Wrong number of columns for the passed histogram: ";
2731 msg +=
"expected " + std::to_string(
h->GetNDimensions()) +
", got " + std::to_string(
columnList.size());
2732 throw std::invalid_argument(
msg);
2772 template <
typename X = RDFDetail::RInferredType,
typename Y = RDFDetail::RInferredType>
2775 auto graph = std::make_shared<::TGraph>();
2839 std::string_view
exh =
"", std::string_view
eyl =
"", std::string_view
eyh =
"")
2841 auto graph = std::make_shared<::TGraphAsymmErrors>();
2883 template <
typename V1 = RDFDetail::RInferredType,
typename V2 = RDFDetail::RInferredType>
2887 std::shared_ptr<::TProfile>
h(
nullptr);
2889 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2893 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2894 throw std::runtime_error(
"Profiles with no axes limits are not supported yet.");
2932 std::shared_ptr<::TProfile>
h(
nullptr);
2934 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2938 if (!RDFInternal::HistoUtils<::TProfile>::HasAxisLimits(*
h)) {
2939 throw std::runtime_error(
"Profile histograms with no axes limits are not supported yet.");
2951 template <
typename V1,
typename V2,
typename W>
2987 std::string_view
v2Name =
"", std::string_view
v3Name =
"")
2989 std::shared_ptr<::TProfile2D>
h(
nullptr);
2991 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
2995 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
2996 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
3037 std::shared_ptr<::TProfile2D>
h(
nullptr);
3039 ROOT::Internal::RDF::RIgnoreErrorLevelRAII
iel(
kError);
3043 if (!RDFInternal::HistoUtils<::TProfile2D>::HasAxisLimits(*
h)) {
3044 throw std::runtime_error(
"2D profiles with no axes limits are not supported yet.");
3055 template <
typename V1,
typename V2,
typename V3,
typename W>
3098 auto h = std::make_shared<std::decay_t<T>>(std::forward<T>(model));
3099 if (!RDFInternal::HistoUtils<T>::HasAxisLimits(*
h)) {
3100 throw std::runtime_error(
"The absence of axes limits is not supported yet.");
3121 template <
typename V = RDFDetail::RInferredType>
3125 if (!
value.empty()) {
3129 if (std::is_same<V, RDFDetail::RInferredType>::value) {
3153 template <
typename V = RDFDetail::RInferredType,
typename W = RDFDetail::RInferredType>
3157 constexpr auto vIsInferred = std::is_same<V, RDFDetail::RInferredType>::value;
3158 constexpr auto wIsInferred = std::is_same<W, RDFDetail::RInferredType>::value;
3167 std::string error(
"The ");
3169 error +=
"column type is explicit, while the ";
3171 error +=
" is specified to be inferred. This case is not supported: please specify both types or none.";
3172 throw std::runtime_error(error);
3199 template <
typename T = RDFDetail::RInferredType>
3203 using RetType_t = RDFDetail::MinReturnType_t<T>;
3204 auto minV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::max());
3229 template <
typename T = RDFDetail::RInferredType>
3233 using RetType_t = RDFDetail::MaxReturnType_t<T>;
3234 auto maxV = std::make_shared<RetType_t>(std::numeric_limits<RetType_t>::lowest());
3260 template <
typename T = RDFDetail::RInferredType>
3264 auto meanV = std::make_shared<double>(0);
3288 template <
typename T = RDFDetail::RInferredType>
3319 template <
typename T = RDFDetail::RInferredType>
3322 const RDFDetail::SumReturnType_t<T> &
initValue = RDFDetail::SumReturnType_t<T>{})
3325 auto sumV = std::make_shared<RDFDetail::SumReturnType_t<T>>(
initValue);
3365 auto rep = std::make_shared<RCutFlowReport>();
3437 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
3438 typename ArgTypesNoDecay =
typename TTraits::CallableTraits<AccFun>::arg_types_nodecay,
3439 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
3440 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
3450 using Helper_t = RDFInternal::AggregateHelper<AccFun, MergeFun, R, T, U>;
3452 auto action = std::make_unique<Action_t>(
3472 typename ArgTypes =
typename TTraits::CallableTraits<AccFun>::arg_types,
3473 typename U = TTraits::TakeFirstParameter_t<ArgTypes>,
3474 typename T = TTraits::TakeFirstParameter_t<TTraits::RemoveFirstParameter_t<ArgTypes>>>
3478 std::is_default_constructible<U>::value,
3479 "aggregated object cannot be default-constructed. Please provide an initialisation value (aggIdentity)");
3549 using HelperT = std::decay_t<Helper>;
3552 static_assert(std::is_base_of<AH, HelperT>::value && std::is_convertible<HelperT *, AH *>::value,
3553 "Action helper of type T must publicly inherit from ROOT::Detail::RDF::RActionImpl<T>");
3555 auto hPtr = std::make_shared<HelperT>(std::forward<Helper>(
helper));
3558 if (std::is_same<FirstColumn, RDFDetail::RInferredType>::value &&
columns.empty()) {
3665 if (
where.compare(0, 8,
"Redefine") != 0) {
3675 using ArgTypes_t =
typename TTraits::CallableTraits<F>::arg_types;
3677 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::Slot>::value,
ArgTypes_t>
::type;
3679 std::is_same<DefineType, RDFDetail::ExtraArgsForDefine::SlotAndEntry>::value,
ColTypesTmp_t>
::type;
3681 constexpr auto nColumns = ColTypes_t::list_size;
3711 bool IsFStringConv = std::is_convertible<F, std::string>::value,
3713 std::enable_if_t<!IsFStringConv && !IsRetTypeDefConstr, RInterface<Proxied>>
3716 static_assert(std::is_default_constructible<typename TTraits::CallableTraits<F>::ret_type>
::value,
3717 "Error in `Define`: type returned by expression is not default-constructible");
3723 template <
typename...
ColTypes, std::size_t... S>
3730 RDFInternal::TEvalAnd<std::is_copy_constructible<ColTypes>::value...>
::value;
3731 static_assert(
areCopyConstructible,
"Columns of a type which is not copy constructible cannot be cached yet.");
3744 template <
bool IsSingleColumn,
typename F>
3749 using F_t = std::decay_t<F>;
3750 using ColTypes_t =
typename TTraits::CallableTraits<F_t>::arg_types;
3751 using RetType =
typename TTraits::CallableTraits<F_t>::ret_type;
3752 constexpr auto nColumns = ColTypes_t::list_size;
3767 auto variation = std::make_shared<RDFInternal::RVariation<F_t, IsSingleColumn>>(
3798 throw std::logic_error(
"A column name was passed to the same Vary invocation multiple times.");
3813 template <
typename Helper,
typename ActionResultType>
3815 const std::shared_ptr<Helper> &
hPtr,
3825 const std::shared_ptr<Helper>& ,
3828 throw std::logic_error(std::string(
"An action was booked with no input columns, but the action requires "
3829 "columns! The action helper type was ") +
3830 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.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#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
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).
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.
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<::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).
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< 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).
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.
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< 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)
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::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.
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).
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.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
const_iterator begin() const
const_iterator end() const
typename RemoveFirstParameter< T >::type RemoveFirstParameter_t
TDirectory::TContext keeps track and restore the current directory.
A TGraph is an object made of two arrays X and Y with npoints each.
Statistical variable, defined by its mean and variance (RMS).
void CheckForNoVariations(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister)
Throw if the column has systematic variations attached.
ParsedTreePath ParseTreePath(std::string_view fullTreeName)
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::vector< std::string > GetFilterNames(const std::shared_ptr< RLoopManager > &loopManager)
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.
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)
Book the jitting of a Vary call.
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.
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.
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
Lightweight storage for a collection of types.