Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::RDF::RResultHandle Class Reference

A type-erased version of RResultPtr and RResultMap.

RResultHandles are used to invoke ROOT::RDF::RunGraphs() and can also be useful to store result pointers of different types in the same collection. Knowledge about the actual result type will still be needed to access it.

Note
Varied results are stripped away when a RResultMap is converted to a RResultHandle: Only the nominal result will be accessible from the RResultHandle.

Definition at line 33 of file RResultHandle.hxx.

Public Member Functions

 RResultHandle ()=default
 
template<class T >
 RResultHandle (const Experimental::RResultMap< T > &resultMap)
 
 RResultHandle (const RResultHandle &)=default
 
template<class T >
 RResultHandle (const RResultPtr< T > &resultPtr)
 
 RResultHandle (RResultHandle &&)=default
 
template<class T >
T * GetPtr ()
 Get the pointer to the encapsulated object.
 
template<class T >
const T & GetValue ()
 Get a const reference to the encapsulated object.
 
bool IsReady () const
 Check whether the result has already been computed.
 
bool operator!= (const RResultHandle &rhs) const
 
bool operator== (const RResultHandle &rhs) const
 

Private Member Functions

void CheckType (const std::type_info &type)
 Compare given type to the type of the wrapped result and throw if the types don't match.
 
void * Get ()
 Get the pointer to the encapsulated result.
 
void ThrowIfNull ()
 

Private Attributes

std::shared_ptr< ROOT::Internal::RDF::RActionBasefActionPtr
 Owning pointer to the action that will produce this result.
 
ROOT::Detail::RDF::RLoopManagerfLoopManager = nullptr
 
std::shared_ptr< void > fObjPtr
 Type erased shared pointer encapsulating the wrapped result.
 
const std::type_info * fType = nullptr
 Type of the wrapped result.
 
std::shared_ptr< ROOT::Internal::RDF::RActionBasefVariedActionPtr
 Owning pointer to the varied action that will produce these results if any.
 

Friends

unsigned int RunGraphs (std::vector< RResultHandle >)
 Trigger the event loop of multiple RDataFrames concurrently.
 

#include <ROOT/RResultHandle.hxx>

Constructor & Destructor Documentation

◆ RResultHandle() [1/5]

template<class T >
ROOT::RDF::RResultHandle::RResultHandle ( const RResultPtr< T > &  resultPtr)
inline

Definition at line 77 of file RResultHandle.hxx.

◆ RResultHandle() [2/5]

template<class T >
ROOT::RDF::RResultHandle::RResultHandle ( const Experimental::RResultMap< T > &  resultMap)
inline

Definition at line 79 of file RResultHandle.hxx.

◆ RResultHandle() [3/5]

ROOT::RDF::RResultHandle::RResultHandle ( const RResultHandle )
default

◆ RResultHandle() [4/5]

ROOT::RDF::RResultHandle::RResultHandle ( RResultHandle &&  )
default

◆ RResultHandle() [5/5]

ROOT::RDF::RResultHandle::RResultHandle ( )
default

Member Function Documentation

◆ CheckType()

void ROOT::RDF::RResultHandle::CheckType ( const std::type_info &  type)
inlineprivate

Compare given type to the type of the wrapped result and throw if the types don't match.

Definition at line 58 of file RResultHandle.hxx.

◆ Get()

void * ROOT::RDF::RResultHandle::Get ( )
inlineprivate

Get the pointer to the encapsulated result.

Ownership is not transferred to the caller. Triggers event loop and execution of all actions booked in the associated RLoopManager.

Definition at line 50 of file RResultHandle.hxx.

◆ GetPtr()

template<class T >
T * ROOT::RDF::RResultHandle::GetPtr ( )
inline

Get the pointer to the encapsulated object.

Triggers event loop and execution of all actions booked in the associated RLoopManager. If the RResultHandle was created from a RResultMap, this returns a pointer to the nominal value.

Template Parameters
TType of the action result

Definition at line 97 of file RResultHandle.hxx.

◆ GetValue()

template<class T >
const T & ROOT::RDF::RResultHandle::GetValue ( )
inline

Get a const reference to the encapsulated object.

Triggers event loop and execution of all actions booked in the associated RLoopManager. If the RResultHandle was created from a RResultMap, this returns a pointer to the nominal value.

Template Parameters
TType of the action result

Definition at line 109 of file RResultHandle.hxx.

◆ IsReady()

bool ROOT::RDF::RResultHandle::IsReady ( ) const
inline

Check whether the result has already been computed.

std::vector<RResultHandle> results;
results.emplace_back(df.Mean<double>("var"));
res.IsReady(); // false, access will trigger event loop
std::cout << res.GetValue<double>() << std::endl; // triggers event loop
res.IsReady(); // true

Definition at line 125 of file RResultHandle.hxx.

◆ operator!=()

bool ROOT::RDF::RResultHandle::operator!= ( const RResultHandle rhs) const
inline

Definition at line 136 of file RResultHandle.hxx.

◆ operator==()

bool ROOT::RDF::RResultHandle::operator== ( const RResultHandle rhs) const
inline

Definition at line 131 of file RResultHandle.hxx.

◆ ThrowIfNull()

void ROOT::RDF::RResultHandle::ThrowIfNull ( )
inlineprivate

Definition at line 69 of file RResultHandle.hxx.

Friends And Related Symbol Documentation

◆ RunGraphs

unsigned int RunGraphs ( std::vector< RResultHandle )
friend

Trigger the event loop of multiple RDataFrames concurrently.

Parameters
[in]handlesA vector of RResultHandles
Returns
The number of distinct computation graphs that have been processed

This function triggers the event loop of all computation graphs which relate to the given RResultHandles. The advantage compared to running the event loop implicitly by accessing the RResultPtr is that the event loops will run concurrently. Therefore, the overall computation of all results is generally more efficient. It should be noted that user-defined operations (e.g., Filters and Defines) of the different RDataFrame graphs are assumed to be safe to call concurrently.

ROOT::RDataFrame df1("tree1", "file1.root");
auto r1 = df1.Histo1D("var1");
ROOT::RDataFrame df2("tree2", "file2.root");
auto r2 = df2.Sum("var2");
// RResultPtr -> RResultHandle conversion is automatic
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
unsigned int RunGraphs(std::vector< RResultHandle > handles)
Trigger the event loop of multiple RDataFrames concurrently.

Member Data Documentation

◆ fActionPtr

std::shared_ptr<ROOT::Internal::RDF::RActionBase> ROOT::RDF::RResultHandle::fActionPtr
private

Owning pointer to the action that will produce this result.

Ownership is shared with RResultPtrs and RResultHandles that refer to the same result.

Definition at line 37 of file RResultHandle.hxx.

◆ fLoopManager

ROOT::Detail::RDF::RLoopManager* ROOT::RDF::RResultHandle::fLoopManager = nullptr
private

Definition at line 34 of file RResultHandle.hxx.

◆ fObjPtr

std::shared_ptr<void> ROOT::RDF::RResultHandle::fObjPtr
private

Type erased shared pointer encapsulating the wrapped result.

Definition at line 38 of file RResultHandle.hxx.

◆ fType

const std::type_info* ROOT::RDF::RResultHandle::fType = nullptr
private

Type of the wrapped result.

Definition at line 42 of file RResultHandle.hxx.

◆ fVariedActionPtr

std::shared_ptr<ROOT::Internal::RDF::RActionBase> ROOT::RDF::RResultHandle::fVariedActionPtr
private

Owning pointer to the varied action that will produce these results if any.

Null if the RResultHandle was created from a RResultPtr, so no variations were present.

Definition at line 41 of file RResultHandle.hxx.

Libraries for ROOT::RDF::RResultHandle:

The documentation for this class was generated from the following file: