13#ifndef ROOT_RDF_HELPERS
14#define ROOT_RDF_HELPERS
32template <
typename... ArgTypes,
typename F>
35 return std::function<
bool(ArgTypes...)>([=](ArgTypes... args)
mutable {
return !
f(args...); });
38template <
typename... ArgTypes,
typename Ret,
typename... Args>
41 return std::function<
bool(ArgTypes...)>([=](ArgTypes... args)
mutable {
return !
f(args...); });
44template <
typename I,
typename T,
typename F>
47template <std::size_t...
N,
typename T,
typename F>
49 template <std::
size_t Idx>
51 std::decay_t<F> fFunc;
55 auto operator()(AlwaysT<N>... args) ->
decltype(fFunc({args...})) {
return fFunc({args...}); }
58template <std::
size_t N,
typename T,
typename F>
77 typename Args =
typename ROOT::TypeTraits::CallableTraits<std::decay_t<F>>::arg_types_nodecay,
78 typename Ret =
typename ROOT::TypeTraits::CallableTraits<std::decay_t<F>>::ret_type>
81 static_assert(std::is_same<Ret, bool>::value,
"RDF::Not requires a callable that returns a bool.");
98template <std::
size_t N,
typename T,
typename F>
115template <
typename NodeType>
134template <
typename NodeType>
135void SaveGraph(NodeType node,
const std::string &outputFile)
140 std::ofstream out(outputFile);
141 if (!out.is_open()) {
142 throw std::runtime_error(
"Could not open output file \"" + outputFile +
"\"for reading");
153template <
typename NodeType>
180void RunGraphs(std::vector<RResultHandle> handles);
182namespace Experimental {
216 R__ASSERT(resPtr !=
nullptr &&
"Calling VariationsFor on an empty RResultPtr");
222 std::unique_ptr<RDFInternal::RActionBase> variedAction;
223 std::vector<std::shared_ptr<T>> variedResults;
225 std::shared_ptr<RDFInternal::RActionBase> nominalAction = resPtr.
fActionPtr;
226 std::vector<std::string> variations = nominalAction->GetVariations();
227 const auto nVariations = variations.size();
229 if (nVariations > 0) {
231 variedResults.reserve(nVariations);
232 for (
auto i = 0u; i < nVariations; ++i)
235 variedResults.emplace_back(
new T{*resPtr.fObjPtr});
237 std::vector<void *> typeErasedResults;
238 typeErasedResults.reserve(variedResults.size());
239 for (
auto &res : variedResults)
240 typeErasedResults.emplace_back(&res);
244 variedAction = nominalAction->MakeVariedAction(std::move(typeErasedResults));
247 return RDFInternal::MakeResultMap<T>(resPtr.
fObjPtr, std::move(variedResults), std::move(variations),
248 *resPtr.
fLoopManager, std::move(nominalAction), std::move(variedAction));
TRObject operator()(const T1 &t1) const
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
std::string RepresentGraph(ROOT::RDataFrame &rDataFrame)
Starting from the root node, prints the entire graph.
The public interface to the RDataFrame federation of classes.
Smart pointer for the return type of actions.
RDFDetail::RLoopManager * fLoopManager
Non-owning pointer to the RLoopManager at the root of this computation graph.
std::shared_ptr< RDFInternal::RActionBase > fActionPtr
Owning pointer to the action that will produce this result.
SPT_t fObjPtr
Shared pointer encapsulating the wrapped result.
std::function< bool(ArgTypes...)> NotHelper(ROOT::TypeTraits::TypeList< ArgTypes... >, F &&f)
auto PassAsVec(F &&f) -> PassAsVecHelper< std::make_index_sequence< N >, T, F >
RResultMap< T > VariationsFor(RResultPtr< T > resPtr)
Produce all required systematic variations for the given result.
void RunGraphs(std::vector< RResultHandle > handles)
Trigger the event loop of multiple RDataFrames concurrently.
auto Not(F &&f) -> decltype(RDFInternal::NotHelper(Args(), std::forward< F >(f)))
Given a callable with signature bool(T1, T2, ...) return a callable with same signature that returns ...
std::string SaveGraph(NodeType node)
Create a graphviz representation of the dataframe computation graph, return it as a string.
RNode AsRNode(NodeType node)
Cast a RDataFrame node to the common type ROOT::RDF::RNode.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Lightweight storage for a collection of types.