Logo ROOT  
Reference Guide
ROOT::Detail::RDF::RLoopManager Class Reference

The head node of a RDF computation graph.

This class is responsible of running the event loop.

Definition at line 56 of file RLoopManager.hxx.

Classes

class  TCallback
 
class  TOneTimeCallback
 

Public Member Functions

 RLoopManager (const RLoopManager &)=delete
 
 RLoopManager (std::unique_ptr< RDataSource > ds, const ColumnNames_t &defaultBranches)
 
 RLoopManager (TTree *tree, const ColumnNames_t &defaultBranches)
 
 RLoopManager (ULong64_t nEmptyEntries)
 
void AddColumnAlias (const std::string &alias, const std::string &colName)
 
void AddFilterName (std::vector< std::string > &)
 End of recursive chain of calls, does nothing. More...
 
void Book (RDFInternal::RActionBase *actionPtr)
 
void Book (RFilterBase *filterPtr)
 
void Book (RRangeBase *rangePtr)
 
bool CheckFilters (unsigned int, Long64_t) final
 
void Deregister (RDFInternal::RActionBase *actionPtr)
 
void Deregister (RFilterBase *filterPtr)
 
void Deregister (RRangeBase *rangePtr)
 
const std::map< std::string, std::string > & GetAliasMap () const
 
std::vector< RDFInternal::RActionBase * > GetAllActions ()
 For all the actions, either booked or run. More...
 
std::vector< RDFInternal::RActionBase * > GetBookedActions ()
 
const ColumnNames_tGetBranchNames ()
 Return all valid TTree::Branch names (caching results for subsequent calls). More...
 
RDataSourceGetDataSource () const
 
const ColumnNames_tGetDefaultColumnNames () const
 Return the list of default columns – empty if none was provided when constructing the RDataFrame. More...
 
::TDirectoryGetDirectory () const
 
std::vector< std::string > GetFiltersNames ()
 For each booked filter, returns either the name or "Unnamed Filter". More...
 
std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNodeGetGraph ()
 
unsigned int GetID () const
 
RLoopManagerGetLoopManagerUnchecked () final
 
ULong64_t GetNEmptyEntries () const
 
unsigned int GetNSlots () const
 
TTreeGetTree () const
 
void IncrChildrenCount () final
 
void Jit ()
 Add RDF nodes that require just-in-time compilation to the computation graph. More...
 
void JitDeclarations ()
 Declare to the interpreter type aliases and other entities required by RDF jitted nodes. More...
 
RLoopManageroperator= (const RLoopManager &)=delete
 
void PartialReport (ROOT::RDF::RCutFlowReport &) const final
 End of recursive chain of calls, does nothing. More...
 
void RegisterCallback (ULong64_t everyNEvents, std::function< void(unsigned int)> &&f)
 
void Report (ROOT::RDF::RCutFlowReport &rep) const final
 Call FillReport on all booked filters. More...
 
void Run ()
 Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source. More...
 
void SetTree (const std::shared_ptr< TTree > &tree)
 
void StopProcessing () final
 
void ToJitDeclare (const std::string &s)
 
void ToJitExec (const std::string &s)
 
- Public Member Functions inherited from ROOT::Detail::RDF::RNodeBase
 RNodeBase (RLoopManager *lm=nullptr)
 
virtual ~RNodeBase ()
 
virtual void AddFilterName (std::vector< std::string > &filters)=0
 
virtual bool CheckFilters (unsigned int, Long64_t)=0
 
virtual std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNodeGetGraph ()=0
 
virtual RLoopManagerGetLoopManagerUnchecked ()
 
virtual void IncrChildrenCount ()=0
 
virtual void PartialReport (ROOT::RDF::RCutFlowReport &) const =0
 
virtual void Report (ROOT::RDF::RCutFlowReport &) const =0
 
virtual void ResetChildrenCount ()
 
virtual void StopProcessing ()=0
 

Private Types

using Callback_t = std::function< void(unsigned int)>
 
enum class  ELoopType {
  kROOTFiles , kROOTFilesMT , kNoFiles , kNoFilesMT ,
  kDataSource , kDataSourceMT
}
 
using RDataSource = ROOT::RDF::RDataSource
 

Private Member Functions

void CheckIndexedFriends ()
 
void CleanUpNodes ()
 Perform clean-up operations. To be called at the end of each event loop. More...
 
void CleanUpTask (unsigned int slot)
 Perform clean-up operations. To be called at the end of each task execution. More...
 
void EvalChildrenCounts ()
 Trigger counting of number of children nodes for each node of the functional graph. More...
 
void InitNodes ()
 Initialize all nodes of the functional graph before running the event loop. More...
 
void InitNodeSlots (TTreeReader *r, unsigned int slot)
 Build TTreeReaderValues for all nodes This method loops over all filters, actions and other booked objects and calls their InitRDFValues methods. More...
 
void RunAndCheckFilters (unsigned int slot, Long64_t entry)
 Execute actions and make sure named filters are called for each event. More...
 
void RunDataSource ()
 Run event loop over data accessed through a DataSource, in sequence. More...
 
void RunDataSourceMT ()
 Run event loop over data accessed through a DataSource, in parallel. More...
 
void RunEmptySource ()
 Run event loop with no source files, in sequence. More...
 
void RunEmptySourceMT ()
 Run event loop with no source files, in parallel. More...
 
void RunTreeProcessorMT ()
 Run event loop over one or multiple ROOT files, in parallel. More...
 
void RunTreeReader ()
 Run event loop over one or multiple ROOT files, in sequence. More...
 

Static Private Member Functions

static unsigned int GetNextID ()
 

Private Attributes

std::map< std::string, std::string > fAliasColumnNameMap
 ColumnNameAlias-columnName pairs. More...
 
std::vector< RDFInternal::RActionBase * > fBookedActions
 Non-owning pointers to actions to be run. More...
 
std::vector< RFilterBase * > fBookedFilters
 
std::vector< RFilterBase * > fBookedNamedFilters
 Contains a subset of fBookedFilters, i.e. only the named filters. More...
 
std::vector< RRangeBase * > fBookedRanges
 
std::vector< TCallbackfCallbacks
 Registered callbacks. More...
 
std::vector< TOneTimeCallbackfCallbacksOnce
 Registered callbacks to invoke just once before running the loop. More...
 
std::vector< RCustomColumnBase * > fCustomColumns
 Non-owning container of all custom columns created so far. More...
 
const std::unique_ptr< RDataSourcefDataSource
 Owning pointer to a data-source object. Null if no data-source. More...
 
const ColumnNames_t fDefaultColumns
 
const unsigned int fID = GetNextID()
 A unique ID that identifies the computation graph that starts with this RLoopManager. More...
 
const ELoopType fLoopType
 The kind of event loop that is going to be run (e.g. on ROOT files, on no files) More...
 
bool fMustRunNamedFilters {true}
 
const ULong64_t fNEmptyEntries {0}
 
const unsigned int fNSlots {1}
 
std::vector< RDFInternal::RActionBase * > fRunActions
 Non-owning pointers to actions already run. More...
 
std::string fToJitDeclare
 Code that should be just-in-time declared right before the event loop. More...
 
std::string fToJitExec
 Code that should be just-in-time executed right before the event loop. More...
 
std::shared_ptr< TTreefTree {nullptr}
 Shared pointer to the input TTree. More...
 
ColumnNames_t fValidBranchNames
 Cache of the tree/chain branch names. Never access directy, always use GetBranchNames(). More...
 

Additional Inherited Members

- Protected Attributes inherited from ROOT::Detail::RDF::RNodeBase
RLoopManagerfLoopManager
 
unsigned int fNChildren {0}
 Number of nodes of the functional graph hanging from this object. More...
 
unsigned int fNStopsReceived {0}
 Number of times that a children node signaled to stop processing entries. More...
 

#include <ROOT/RDF/RLoopManager.hxx>

Inheritance diagram for ROOT::Detail::RDF::RLoopManager:
[legend]

Member Typedef Documentation

◆ Callback_t

using ROOT::Detail::RDF::RLoopManager::Callback_t = std::function<void(unsigned int)>
private

Definition at line 59 of file RLoopManager.hxx.

◆ RDataSource

Member Enumeration Documentation

◆ ELoopType

Enumerator
kROOTFiles 
kROOTFilesMT 
kNoFiles 
kNoFilesMT 
kDataSource 
kDataSourceMT 

Definition at line 58 of file RLoopManager.hxx.

Constructor & Destructor Documentation

◆ RLoopManager() [1/4]

RLoopManager::RLoopManager ( TTree tree,
const ColumnNames_t defaultBranches 
)

Definition at line 188 of file RLoopManager.cxx.

◆ RLoopManager() [2/4]

RLoopManager::RLoopManager ( ULong64_t  nEmptyEntries)

Definition at line 195 of file RLoopManager.cxx.

◆ RLoopManager() [3/4]

RLoopManager::RLoopManager ( std::unique_ptr< RDataSource ds,
const ColumnNames_t defaultBranches 
)

Definition at line 201 of file RLoopManager.cxx.

◆ RLoopManager() [4/4]

ROOT::Detail::RDF::RLoopManager::RLoopManager ( const RLoopManager )
delete

Member Function Documentation

◆ AddColumnAlias()

void ROOT::Detail::RDF::RLoopManager::AddColumnAlias ( const std::string &  alias,
const std::string &  colName 
)
inline

Definition at line 173 of file RLoopManager.hxx.

◆ AddFilterName()

void ROOT::Detail::RDF::RLoopManager::AddFilterName ( std::vector< std::string > &  )
inlinevirtual

End of recursive chain of calls, does nothing.

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 179 of file RLoopManager.hxx.

◆ Book() [1/3]

void RLoopManager::Book ( RDFInternal::RActionBase actionPtr)

Definition at line 530 of file RLoopManager.cxx.

◆ Book() [2/3]

void RLoopManager::Book ( RFilterBase filterPtr)

Definition at line 541 of file RLoopManager.cxx.

◆ Book() [3/3]

void RLoopManager::Book ( RRangeBase rangePtr)

Definition at line 556 of file RLoopManager.cxx.

◆ CheckFilters()

bool RLoopManager::CheckFilters ( unsigned int  ,
Long64_t   
)
finalvirtual

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 567 of file RLoopManager.cxx.

◆ CheckIndexedFriends()

void RLoopManager::CheckIndexedFriends ( )
private

Definition at line 210 of file RLoopManager.cxx.

◆ CleanUpNodes()

void RLoopManager::CleanUpNodes ( )
private

Perform clean-up operations. To be called at the end of each event loop.

Definition at line 423 of file RLoopManager.cxx.

◆ CleanUpTask()

void RLoopManager::CleanUpTask ( unsigned int  slot)
private

Perform clean-up operations. To be called at the end of each task execution.

Definition at line 447 of file RLoopManager.cxx.

◆ Deregister() [1/3]

void RLoopManager::Deregister ( RDFInternal::RActionBase actionPtr)

Definition at line 535 of file RLoopManager.cxx.

◆ Deregister() [2/3]

void RLoopManager::Deregister ( RFilterBase filterPtr)

Definition at line 550 of file RLoopManager.cxx.

◆ Deregister() [3/3]

void RLoopManager::Deregister ( RRangeBase rangePtr)

Definition at line 561 of file RLoopManager.cxx.

◆ EvalChildrenCounts()

void RLoopManager::EvalChildrenCounts ( )
private

Trigger counting of number of children nodes for each node of the functional graph.

This is done once before starting the event loop. Each action sends an increase children count signal upstream, which is propagated until RLoopManager. Each time a node receives the signal, in increments its children counter. Each node only propagates the signal once, even if it receives it multiple times. Named filters also send an increase children count signal, just like actions, as they always execute during the event loop so the graph branch they belong to must count as active even if it does not end in an action.

Definition at line 484 of file RLoopManager.cxx.

◆ GetAliasMap()

const std::map< std::string, std::string > & ROOT::Detail::RDF::RLoopManager::GetAliasMap ( ) const
inline

Definition at line 174 of file RLoopManager.hxx.

◆ GetAllActions()

std::vector< RDFInternal::RActionBase * > RLoopManager::GetAllActions ( )

For all the actions, either booked or run.

Definition at line 597 of file RLoopManager.cxx.

◆ GetBookedActions()

std::vector< RDFInternal::RActionBase * > ROOT::Detail::RDF::RLoopManager::GetBookedActions ( )
inline

Definition at line 186 of file RLoopManager.hxx.

◆ GetBranchNames()

const ColumnNames_t & RLoopManager::GetBranchNames ( )

Return all valid TTree::Branch names (caching results for subsequent calls).

Never use fBranchNames directy, always request it through this method.

Definition at line 625 of file RLoopManager.cxx.

◆ GetDataSource()

RDataSource * ROOT::Detail::RDF::RLoopManager::GetDataSource ( ) const
inline

Definition at line 156 of file RLoopManager.hxx.

◆ GetDefaultColumnNames()

const ColumnNames_t & RLoopManager::GetDefaultColumnNames ( ) const

Return the list of default columns – empty if none was provided when constructing the RDataFrame.

Definition at line 520 of file RLoopManager.cxx.

◆ GetDirectory()

::TDirectory * ROOT::Detail::RDF::RLoopManager::GetDirectory ( ) const

◆ GetFiltersNames()

std::vector< std::string > RLoopManager::GetFiltersNames ( )

For each booked filter, returns either the name or "Unnamed Filter".

Definition at line 587 of file RLoopManager.cxx.

◆ GetGraph()

std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > RLoopManager::GetGraph ( )
virtual

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 605 of file RLoopManager.cxx.

◆ GetID()

unsigned int ROOT::Detail::RDF::RLoopManager::GetID ( ) const
inline

Definition at line 176 of file RLoopManager.hxx.

◆ GetLoopManagerUnchecked()

RLoopManager * ROOT::Detail::RDF::RLoopManager::GetLoopManagerUnchecked ( )
inlinefinalvirtual

Reimplemented from ROOT::Detail::RDF::RNodeBase.

Definition at line 150 of file RLoopManager.hxx.

◆ GetNEmptyEntries()

ULong64_t ROOT::Detail::RDF::RLoopManager::GetNEmptyEntries ( ) const
inline

Definition at line 155 of file RLoopManager.hxx.

◆ GetNextID()

unsigned int RLoopManager::GetNextID ( )
staticprivate

Definition at line 492 of file RLoopManager.cxx.

◆ GetNSlots()

unsigned int ROOT::Detail::RDF::RLoopManager::GetNSlots ( ) const
inline

Definition at line 164 of file RLoopManager.hxx.

◆ GetTree()

TTree * RLoopManager::GetTree ( ) const

Definition at line 525 of file RLoopManager.cxx.

◆ IncrChildrenCount()

void ROOT::Detail::RDF::RLoopManager::IncrChildrenCount ( )
inlinefinalvirtual

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 169 of file RLoopManager.hxx.

◆ InitNodes()

void RLoopManager::InitNodes ( )
private

Initialize all nodes of the functional graph before running the event loop.

This method is called once per event-loop and performs generic initialization operations that do not depend on the specific processing slot (i.e. operations that are common for all threads).

Definition at line 409 of file RLoopManager.cxx.

◆ InitNodeSlots()

void RLoopManager::InitNodeSlots ( TTreeReader r,
unsigned int  slot 
)
private

Build TTreeReaderValues for all nodes This method loops over all filters, actions and other booked objects and calls their InitRDFValues methods.

It is called once per node per slot, before running the event loop. It also informs each node of the TTreeReader that a particular slot will be using.

Definition at line 395 of file RLoopManager.cxx.

◆ Jit()

void RLoopManager::Jit ( )

Add RDF nodes that require just-in-time compilation to the computation graph.

This method also invokes JitDeclarations() if needed, and clears the fToJitExec member variable.

Definition at line 468 of file RLoopManager.cxx.

◆ JitDeclarations()

void RLoopManager::JitDeclarations ( )

Declare to the interpreter type aliases and other entities required by RDF jitted nodes.

This method clears the fToJitDeclare member variable.

Definition at line 457 of file RLoopManager.cxx.

◆ operator=()

RLoopManager & ROOT::Detail::RDF::RLoopManager::operator= ( const RLoopManager )
delete

◆ PartialReport()

void ROOT::Detail::RDF::RLoopManager::PartialReport ( ROOT::RDF::RCutFlowReport ) const
inlinefinalvirtual

End of recursive chain of calls, does nothing.

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 167 of file RLoopManager.hxx.

◆ RegisterCallback()

void RLoopManager::RegisterCallback ( ULong64_t  everyNEvents,
std::function< void(unsigned int)> &&  f 
)

Definition at line 579 of file RLoopManager.cxx.

◆ Report()

void RLoopManager::Report ( ROOT::RDF::RCutFlowReport rep) const
finalvirtual

Call FillReport on all booked filters.

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 573 of file RLoopManager.cxx.

◆ Run()

void RLoopManager::Run ( )

Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source.

Also perform a few setup and clean-up operations (jit actions if necessary, clear booked actions after the loop...).

Definition at line 501 of file RLoopManager.cxx.

◆ RunAndCheckFilters()

void RLoopManager::RunAndCheckFilters ( unsigned int  slot,
Long64_t  entry 
)
private

Execute actions and make sure named filters are called for each event.

Named filters must be called even if the analysis logic would not require it, lest they report confusing results.

Definition at line 380 of file RLoopManager.cxx.

◆ RunDataSource()

void RLoopManager::RunDataSource ( )
private

Run event loop over data accessed through a DataSource, in sequence.

Definition at line 321 of file RLoopManager.cxx.

◆ RunDataSourceMT()

void RLoopManager::RunDataSourceMT ( )
private

Run event loop over data accessed through a DataSource, in parallel.

Definition at line 345 of file RLoopManager.cxx.

◆ RunEmptySource()

void RLoopManager::RunEmptySource ( )
private

Run event loop with no source files, in sequence.

Definition at line 267 of file RLoopManager.cxx.

◆ RunEmptySourceMT()

void RLoopManager::RunEmptySourceMT ( )
private

Run event loop with no source files, in parallel.

Definition at line 229 of file RLoopManager.cxx.

◆ RunTreeProcessorMT()

void RLoopManager::RunTreeProcessorMT ( )
private

Run event loop over one or multiple ROOT files, in parallel.

Definition at line 277 of file RLoopManager.cxx.

◆ RunTreeReader()

void RLoopManager::RunTreeReader ( )
private

Run event loop over one or multiple ROOT files, in sequence.

Definition at line 304 of file RLoopManager.cxx.

◆ SetTree()

void ROOT::Detail::RDF::RLoopManager::SetTree ( const std::shared_ptr< TTree > &  tree)
inline

Definition at line 168 of file RLoopManager.hxx.

◆ StopProcessing()

void ROOT::Detail::RDF::RLoopManager::StopProcessing ( )
inlinefinalvirtual

Implements ROOT::Detail::RDF::RNodeBase.

Definition at line 170 of file RLoopManager.hxx.

◆ ToJitDeclare()

void ROOT::Detail::RDF::RLoopManager::ToJitDeclare ( const std::string &  s)
inline

Definition at line 171 of file RLoopManager.hxx.

◆ ToJitExec()

void ROOT::Detail::RDF::RLoopManager::ToJitExec ( const std::string &  s)
inline

Definition at line 172 of file RLoopManager.hxx.

Member Data Documentation

◆ fAliasColumnNameMap

std::map<std::string, std::string> ROOT::Detail::RDF::RLoopManager::fAliasColumnNameMap
private

ColumnNameAlias-columnName pairs.

Definition at line 115 of file RLoopManager.hxx.

◆ fBookedActions

std::vector<RDFInternal::RActionBase *> ROOT::Detail::RDF::RLoopManager::fBookedActions
private

Non-owning pointers to actions to be run.

Definition at line 98 of file RLoopManager.hxx.

◆ fBookedFilters

std::vector<RFilterBase *> ROOT::Detail::RDF::RLoopManager::fBookedFilters
private

Definition at line 100 of file RLoopManager.hxx.

◆ fBookedNamedFilters

std::vector<RFilterBase *> ROOT::Detail::RDF::RLoopManager::fBookedNamedFilters
private

Contains a subset of fBookedFilters, i.e. only the named filters.

Definition at line 101 of file RLoopManager.hxx.

◆ fBookedRanges

std::vector<RRangeBase *> ROOT::Detail::RDF::RLoopManager::fBookedRanges
private

Definition at line 102 of file RLoopManager.hxx.

◆ fCallbacks

std::vector<TCallback> ROOT::Detail::RDF::RLoopManager::fCallbacks
private

Registered callbacks.

Definition at line 116 of file RLoopManager.hxx.

◆ fCallbacksOnce

std::vector<TOneTimeCallback> ROOT::Detail::RDF::RLoopManager::fCallbacksOnce
private

Registered callbacks to invoke just once before running the loop.

Definition at line 117 of file RLoopManager.hxx.

◆ fCustomColumns

std::vector<RCustomColumnBase *> ROOT::Detail::RDF::RLoopManager::fCustomColumns
private

Non-owning container of all custom columns created so far.

Definition at line 122 of file RLoopManager.hxx.

◆ fDataSource

const std::unique_ptr<RDataSource> ROOT::Detail::RDF::RLoopManager::fDataSource
private

Owning pointer to a data-source object. Null if no data-source.

Definition at line 114 of file RLoopManager.hxx.

◆ fDefaultColumns

const ColumnNames_t ROOT::Detail::RDF::RLoopManager::fDefaultColumns
private

Definition at line 107 of file RLoopManager.hxx.

◆ fID

const unsigned int ROOT::Detail::RDF::RLoopManager::fID = GetNextID()
private

A unique ID that identifies the computation graph that starts with this RLoopManager.

Used, for example, to jit objects in a namespace reserved for this computation graph

Definition at line 120 of file RLoopManager.hxx.

◆ fLoopType

const ELoopType ROOT::Detail::RDF::RLoopManager::fLoopType
private

The kind of event loop that is going to be run (e.g. on ROOT files, on no files)

Definition at line 111 of file RLoopManager.hxx.

◆ fMustRunNamedFilters

bool ROOT::Detail::RDF::RLoopManager::fMustRunNamedFilters {true}
private

Definition at line 110 of file RLoopManager.hxx.

◆ fNEmptyEntries

const ULong64_t ROOT::Detail::RDF::RLoopManager::fNEmptyEntries {0}
private

Definition at line 108 of file RLoopManager.hxx.

◆ fNSlots

const unsigned int ROOT::Detail::RDF::RLoopManager::fNSlots {1}
private

Definition at line 109 of file RLoopManager.hxx.

◆ fRunActions

std::vector<RDFInternal::RActionBase *> ROOT::Detail::RDF::RLoopManager::fRunActions
private

Non-owning pointers to actions already run.

Definition at line 99 of file RLoopManager.hxx.

◆ fToJitDeclare

std::string ROOT::Detail::RDF::RLoopManager::fToJitDeclare
private

Code that should be just-in-time declared right before the event loop.

Definition at line 112 of file RLoopManager.hxx.

◆ fToJitExec

std::string ROOT::Detail::RDF::RLoopManager::fToJitExec
private

Code that should be just-in-time executed right before the event loop.

Definition at line 113 of file RLoopManager.hxx.

◆ fTree

std::shared_ptr<TTree> ROOT::Detail::RDF::RLoopManager::fTree {nullptr}
private

Shared pointer to the input TTree.

It does not delete the pointee if the TTree/TChain was passed directly as an argument to RDataFrame's ctor (in which case we let users retain ownership).

Definition at line 106 of file RLoopManager.hxx.

◆ fValidBranchNames

ColumnNames_t ROOT::Detail::RDF::RLoopManager::fValidBranchNames
private

Cache of the tree/chain branch names. Never access directy, always use GetBranchNames().

Definition at line 124 of file RLoopManager.hxx.

Libraries for ROOT::Detail::RDF::RLoopManager:
[legend]

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