13#ifndef ROOT_RDF_HELPERS
14#define ROOT_RDF_HELPERS
35template <
typename... ArgTypes,
typename F>
38 return std::function<
bool(ArgTypes...)>([=](ArgTypes... args)
mutable {
return !
f(args...); });
41template <
typename... ArgTypes,
typename Ret,
typename... Args>
44 return std::function<
bool(ArgTypes...)>([=](ArgTypes... args)
mutable {
return !
f(args...); });
47template <
typename I,
typename T,
typename F>
50template <std::size_t...
N,
typename T,
typename F>
52 template <std::
size_t Idx>
54 std::decay_t<F> fFunc;
58 auto operator()(AlwaysT<N>... args) ->
decltype(fFunc({args...})) {
return fFunc({args...}); }
61template <std::
size_t N,
typename T,
typename F>
81 typename Args =
typename ROOT::TypeTraits::CallableTraits<std::decay_t<F>>::arg_types_nodecay,
82 typename Ret =
typename ROOT::TypeTraits::CallableTraits<std::decay_t<F>>::ret_type>
85 static_assert(std::is_same<Ret, bool>::value,
"RDF::Not requires a callable that returns a bool.");
102template <std::
size_t N,
typename T,
typename F>
119template <
typename NodeType>
138template <
typename NodeType>
139void SaveGraph(NodeType node,
const std::string &outputFile)
142 std::string dotGraph = helper(node);
144 std::ofstream out(outputFile);
145 if (!out.is_open()) {
146 throw std::runtime_error(
"Could not open output file \"" + outputFile +
"\"for reading");
157template <
typename NodeType>
184void RunGraphs(std::vector<RResultHandle> handles);
186namespace Experimental {
220 R__ASSERT(resPtr !=
nullptr &&
"Calling VariationsFor on an empty RResultPtr");
226 std::unique_ptr<RDFInternal::RActionBase> variedAction;
227 std::vector<std::shared_ptr<T>> variedResults;
229 std::shared_ptr<RDFInternal::RActionBase> nominalAction = resPtr.
fActionPtr;
230 std::vector<std::string> variations = nominalAction->GetVariations();
231 const auto nVariations = variations.size();
233 if (nVariations > 0) {
235 variedResults.reserve(nVariations);
236 for (
auto i = 0u; i < nVariations; ++i)
239 variedResults.emplace_back(
new T{*resPtr.fObjPtr});
241 std::vector<void *> typeErasedResults;
242 typeErasedResults.reserve(variedResults.size());
243 for (
auto &res : variedResults)
244 typeErasedResults.emplace_back(&res);
248 variedAction = nominalAction->MakeVariedAction(std::move(typeErasedResults));
251 return RDFInternal::MakeResultMap<T>(resPtr.
fObjPtr, std::move(variedResults), std::move(variations),
252 *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.
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Lightweight storage for a collection of types.