11#ifndef ROOT_RDF_RRESULTMAP
12#define ROOT_RDF_RRESULTMAP
22#include <unordered_map>
29namespace Experimental {
49 std::shared_ptr<ROOT::Internal::RDF::RActionBase>
nominalAction,
50 std::shared_ptr<ROOT::Internal::RDF::RActionBase>
variedAction)
95namespace Experimental {
101 std::unordered_map<std::string, std::shared_ptr<T>>
fMap;
107 ROOT::Internal::RDF::MakeResultMap<T>(std::shared_ptr<T>
nominalResult,
110 std::shared_ptr<ROOT::Internal::RDF::RActionBase>
nominalAction,
111 std::shared_ptr<ROOT::Internal::RDF::RActionBase>
variedAction);
114 friend std::unique_ptr<ROOT::Detail::RDF::RMergeableVariations<T>>
116 friend class ::ROOT::RDF::RResultHandle;
121 std::shared_ptr<ROOT::Internal::RDF::RActionBase>
nominalAction,
122 std::shared_ptr<ROOT::Internal::RDF::RActionBase>
variedAction)
123 :
fKeys{
ROOT::Internal::RDF::Union({std::string(
"nominal")}, keys)}, fLoopManager(&
lm),
129 for (
const auto &k : keys) {
132 "Failed to insert an element in RResultMap, maybe a duplicated key? This should never happen.");
138 if ((fVariedAction !=
nullptr && !fVariedAction->HasRun()) || !fNominalAction->HasRun())
143 using iterator =
typename decltype(fMap)::iterator;
149 auto it = fMap.find(key);
150 if (it == fMap.end())
151 throw std::runtime_error(
"RResultMap: no result with key \"" + key +
"\".");
153 RunEventLoopIfNeeded();
161 RunEventLoopIfNeeded();
167 RunEventLoopIfNeeded();
168 return fMap.cbegin();
173 RunEventLoopIfNeeded();
179 RunEventLoopIfNeeded();
183 const std::vector<std::string> &
GetKeys()
const {
return fKeys; }
213 rmap.RunEventLoopIfNeeded();
214 if (
rmap.fVariedAction !=
nullptr) {
218 return std::make_unique<RMergeableVariations<T>>(std::move(*
mVariationsBase));
220 auto ret = std::make_unique<RMergeableVariations<T>>();
221 ret->AddNominal(
rmap.fNominalAction->GetMergeableValue());
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.
The head node of a RDF computation graph.
A container for variation names and variation results.
T & operator[](const std::string &key)
ROOT::Detail::RDF::RLoopManager * fLoopManager
RResultMap(std::shared_ptr< T > &&nominalResult, std::vector< std::shared_ptr< T > > &&variedResults, std::vector< std::string > &&keys, ROOT::Detail::RDF::RLoopManager &lm, std::shared_ptr< ROOT::Internal::RDF::RActionBase > nominalAction, std::shared_ptr< ROOT::Internal::RDF::RActionBase > variedAction)
const std::vector< std::string > & GetKeys() const
void RunEventLoopIfNeeded()
const_iterator cend() const
std::shared_ptr< ROOT::Internal::RDF::RActionBase > fNominalAction
std::unordered_map< std::string, std::shared_ptr< T > > fMap
iterator begin()
Iterator to walk through key-value pairs of all variations for a given object.
std::vector< std::string > fKeys
std::shared_ptr< ROOT::Internal::RDF::RActionBase > fVariedAction
std::unique_ptr< RMergeableVariations< T > > GetMergeableValue(ROOT::RDF::Experimental::RResultMap< T > &rmap)
Retrieve mergeable values after calling ROOT::RDF::VariationsFor .
ROOT::RDF::Experimental::RResultMap< T > MakeResultMap(std::shared_ptr< T > nominalResult, std::vector< std::shared_ptr< T > > &&variedResults, std::vector< std::string > &&keys, RLoopManager &lm, std::shared_ptr< ROOT::Internal::RDF::RActionBase > nominalAction, std::shared_ptr< ROOT::Internal::RDF::RActionBase > variedAction)
ROOT::RDF::Experimental::RResultMap< T > CloneResultAndAction(const ROOT::RDF::Experimental::RResultMap< T > &inmap)
Clones an RResultMap and its corresponding RVariedAction.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...