The head node of a RDF computation graph.
This class is responsible of running the event loop.
Definition at line 108 of file RLoopManager.hxx.
Public Member Functions | |
RLoopManager (const RLoopManager &)=delete | |
RLoopManager (ROOT::RDF::Experimental::RDatasetSpec &&spec) | |
RLoopManager (std::unique_ptr< RDataSource > ds, const ColumnNames_t &defaultBranches) | |
RLoopManager (TTree *tree, const ColumnNames_t &defaultBranches) | |
RLoopManager (ULong64_t nEmptyEntries) | |
void | AddDataSourceColumnReaders (const std::string &col, std::vector< std::unique_ptr< RColumnReaderBase > > &&readers, const std::type_info &ti) |
void | AddFilterName (std::vector< std::string > &) final |
End of recursive chain of calls, does nothing. More... | |
void | AddSampleCallback (void *nodePtr, ROOT::RDF::SampleCallback_t &&callback) |
RColumnReaderBase * | AddTreeColumnReader (unsigned int slot, const std::string &col, std::unique_ptr< RColumnReaderBase > &&reader, const std::type_info &ti) |
Register a new RTreeColumnReader with this RLoopManager. More... | |
bool | CheckFilters (unsigned int, Long64_t) final |
void | Deregister (RDefineBase *definePtr) |
void | Deregister (RDFInternal::RActionBase *actionPtr) |
void | Deregister (RDFInternal::RVariationBase *varPtr) |
void | Deregister (RFilterBase *filterPtr) |
void | Deregister (RRangeBase *rangePtr) |
std::vector< RDFInternal::RActionBase * > | GetAllActions () const |
Return all actions, either booked or already run. More... | |
const ColumnNames_t & | GetBranchNames () |
Return all valid TTree::Branch names (caching results for subsequent calls). More... | |
RColumnReaderBase * | GetDatasetColumnReader (unsigned int slot, const std::string &col, const std::type_info &ti) const |
RDataSource * | GetDataSource () const |
const ColumnNames_t & | GetDefaultColumnNames () const |
Return the list of default columns – empty if none was provided when constructing the RDataFrame. More... | |
::TDirectory * | GetDirectory () 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::GraphNode > | GetGraph (std::unordered_map< void *, std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > > &visitedMap) final |
std::vector< RNodeBase * > | GetGraphEdges () const |
Return all graph edges known to RLoopManager This includes Filters and Ranges but not Defines. More... | |
RLoopManager * | GetLoopManagerUnchecked () final |
ULong64_t | GetNEmptyEntries () const |
unsigned int | GetNRuns () const |
unsigned int | GetNSlots () const |
TTree * | GetTree () const |
bool | HasDataSourceColumnReaders (const std::string &col, const std::type_info &ti) const |
Return true if AddDataSourceColumnReaders was called for column name col. More... | |
void | IncrChildrenCount () final |
void | Jit () |
Add RDF nodes that require just-in-time compilation to the computation graph. More... | |
void | JitDeclarations () |
RLoopManager & | operator= (const RLoopManager &)=delete |
void | PartialReport (ROOT::RDF::RCutFlowReport &) const final |
End of recursive chain of calls, does nothing. More... | |
void | Register (RDefineBase *definePtr) |
void | Register (RDFInternal::RActionBase *actionPtr) |
void | Register (RDFInternal::RVariationBase *varPtr) |
void | Register (RFilterBase *filterPtr) |
void | Register (RRangeBase *rangePtr) |
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 (bool jit=true) |
Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source. More... | |
void | SetTree (std::shared_ptr< TTree > tree) |
void | StopProcessing () final |
void | ToJitExec (const std::string &) const |
![]() | |
RNodeBase (const std::vector< std::string > &variations={}, 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::GraphNode > | GetGraph (std::unordered_map< void *, std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > > &visitedMap)=0 |
virtual RLoopManager * | GetLoopManagerUnchecked () |
const std::vector< std::string > & | GetVariations () const |
virtual std::shared_ptr< RNodeBase > | GetVariedFilter (const std::string &) |
Return a clone of this node that acts as a Filter working with values in the variationName "universe". More... | |
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 | ColumnNames_t = std::vector< std::string > |
enum class | ELoopType { kROOTFiles , kROOTFilesMT , kNoFiles , kNoFilesMT , kDataSource , kDataSourceMT } |
Private Member Functions | |
void | CleanUpNodes () |
Perform clean-up operations. To be called at the end of each event loop. More... | |
void | CleanUpTask (TTreeReader *r, 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 InitSlot method, to get them ready for running a task. 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... | |
void | SetupSampleCallbacks (TTreeReader *r, unsigned int slot) |
void | UpdateSampleInfo (unsigned int slot, const std::pair< ULong64_t, ULong64_t > &range) |
void | UpdateSampleInfo (unsigned int slot, TTreeReader &r) |
Private Attributes | |
Long64_t | fBeginEntry {0} |
std::vector< RDFInternal::RActionBase * > | fBookedActions |
Non-owning pointers to actions to be run. More... | |
std::vector< RDefineBase * > | fBookedDefines |
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< RDFInternal::RVariationBase * > | fBookedVariations |
std::vector< RDFInternal::RCallback > | fCallbacks |
Registered callbacks. More... | |
std::vector< RDFInternal::ROneTimeCallback > | fCallbacksOnce |
Registered callbacks to invoke just once before running the loop. More... | |
std::vector< std::unordered_map< std::string, std::unique_ptr< RColumnReaderBase > > > | fDatasetColumnReaders |
Readers for TTree/RDataSource columns (one per slot), shared by all nodes in the computation graph. More... | |
std::unordered_map< std::string, ROOT::RDF::Experimental::RDatasetGroup * > | fDatasetGroupMap |
Keys are fname + "/" + treename as RSampleInfo::fID; Values are pointers to the corresponding group. More... | |
std::vector< ROOT::RDF::Experimental::RDatasetGroup > | fDatasetGroups |
Groups need to survive throughout the whole event loop, hence stored as an attribute. More... | |
const std::unique_ptr< RDataSource > | fDataSource |
Owning pointer to a data-source object. Null if no data-source. More... | |
const ColumnNames_t | fDefaultColumns |
Long64_t | fEndEntry {std::numeric_limits<Long64_t>::max()} |
std::vector< std::unique_ptr< TTree > > | fFriends |
Friends of the fTree. Only used if we constructed fTree ourselves. 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} |
RDFInternal::RNewSampleNotifier | fNewSampleNotifier |
ROOT::Internal::TreeUtils::RNoCleanupNotifier | fNoCleanupNotifier |
unsigned int | fNRuns {0} |
Number of event loops run. More... | |
const unsigned int | fNSlots {1} |
std::vector< RDFInternal::RActionBase * > | fRunActions |
Non-owning pointers to actions already run. More... | |
std::unordered_map< void *, ROOT::RDF::SampleCallback_t > | fSampleCallbacks |
Registered callbacks to call at the beginning of each "data block". More... | |
std::vector< ROOT::RDF::RSampleInfo > | fSampleInfos |
std::shared_ptr< TTree > | fTree {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... | |
Friends | |
struct | RCallCleanUpTask |
Additional Inherited Members | |
![]() | |
RLoopManager * | fLoopManager |
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... | |
std::vector< std::string > | fVariations |
List of systematic variations that affect this node. More... | |
#include <ROOT/RDF/RLoopManager.hxx>
|
private |
Definition at line 109 of file RLoopManager.hxx.
|
strongprivate |
Enumerator | |
---|---|
kROOTFiles | |
kROOTFilesMT | |
kNoFiles | |
kNoFilesMT | |
kDataSource | |
kDataSourceMT |
Definition at line 110 of file RLoopManager.hxx.
RLoopManager::RLoopManager | ( | TTree * | tree, |
const ColumnNames_t & | defaultBranches | ||
) |
Definition at line 345 of file RLoopManager.cxx.
RLoopManager::RLoopManager | ( | ULong64_t | nEmptyEntries | ) |
Definition at line 353 of file RLoopManager.cxx.
RLoopManager::RLoopManager | ( | std::unique_ptr< RDataSource > | ds, |
const ColumnNames_t & | defaultBranches | ||
) |
Definition at line 360 of file RLoopManager.cxx.
RLoopManager::RLoopManager | ( | ROOT::RDF::Experimental::RDatasetSpec && | spec | ) |
Definition at line 368 of file RLoopManager.cxx.
|
delete |
void RLoopManager::AddDataSourceColumnReaders | ( | const std::string & | col, |
std::vector< std::unique_ptr< RColumnReaderBase > > && | readers, | ||
const std::type_info & | ti | ||
) |
Definition at line 1025 of file RLoopManager.cxx.
|
inlinefinalvirtual |
End of recursive chain of calls, does nothing.
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 220 of file RLoopManager.hxx.
void RLoopManager::AddSampleCallback | ( | void * | nodePtr, |
ROOT::RDF::SampleCallback_t && | callback | ||
) |
Definition at line 1065 of file RLoopManager.cxx.
RColumnReaderBase * RLoopManager::AddTreeColumnReader | ( | unsigned int | slot, |
const std::string & | col, | ||
std::unique_ptr< RColumnReaderBase > && | reader, | ||
const std::type_info & | ti | ||
) |
Register a new RTreeColumnReader with this RLoopManager.
Definition at line 1041 of file RLoopManager.cxx.
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 921 of file RLoopManager.cxx.
|
private |
Perform clean-up operations. To be called at the end of each event loop.
Definition at line 733 of file RLoopManager.cxx.
|
private |
Perform clean-up operations. To be called at the end of each task execution.
Definition at line 758 of file RLoopManager.cxx.
void RLoopManager::Deregister | ( | RDefineBase * | definePtr | ) |
Definition at line 904 of file RLoopManager.cxx.
void RLoopManager::Deregister | ( | RDFInternal::RActionBase * | actionPtr | ) |
Definition at line 867 of file RLoopManager.cxx.
void RLoopManager::Deregister | ( | RDFInternal::RVariationBase * | varPtr | ) |
Definition at line 915 of file RLoopManager.cxx.
void RLoopManager::Deregister | ( | RFilterBase * | filterPtr | ) |
Definition at line 883 of file RLoopManager.cxx.
void RLoopManager::Deregister | ( | RRangeBase * | rangePtr | ) |
Definition at line 894 of file RLoopManager.cxx.
|
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 805 of file RLoopManager.cxx.
std::vector< RDFInternal::RActionBase * > RLoopManager::GetAllActions | ( | ) | const |
Return all actions, either booked or already run.
Definition at line 974 of file RLoopManager.cxx.
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 1007 of file RLoopManager.cxx.
RColumnReaderBase * RLoopManager::GetDatasetColumnReader | ( | unsigned int | slot, |
const std::string & | col, | ||
const std::type_info & | ti | ||
) | const |
Definition at line 1055 of file RLoopManager.cxx.
|
inline |
Definition at line 190 of file RLoopManager.hxx.
const ColumnNames_t & RLoopManager::GetDefaultColumnNames | ( | ) | const |
Return the list of default columns – empty if none was provided when constructing the RDataFrame.
Definition at line 851 of file RLoopManager.cxx.
::TDirectory * ROOT::Detail::RDF::RLoopManager::GetDirectory | ( | ) | const |
std::vector< std::string > RLoopManager::GetFiltersNames | ( | ) |
For each booked filter, returns either the name or "Unnamed Filter".
Definition at line 956 of file RLoopManager.cxx.
|
finalvirtual |
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 982 of file RLoopManager.cxx.
std::vector< RNodeBase * > RLoopManager::GetGraphEdges | ( | ) | const |
Return all graph edges known to RLoopManager This includes Filters and Ranges but not Defines.
Definition at line 966 of file RLoopManager.cxx.
|
inlinefinalvirtual |
Reimplemented from ROOT::Detail::RDF::RNodeBase.
Definition at line 184 of file RLoopManager.hxx.
|
inline |
Definition at line 189 of file RLoopManager.hxx.
|
inline |
Definition at line 211 of file RLoopManager.hxx.
|
inline |
Definition at line 202 of file RLoopManager.hxx.
TTree * RLoopManager::GetTree | ( | ) | const |
Definition at line 856 of file RLoopManager.cxx.
bool RLoopManager::HasDataSourceColumnReaders | ( | const std::string & | col, |
const std::type_info & | ti | ||
) | const |
Return true if AddDataSourceColumnReaders was called for column name col.
Definition at line 1016 of file RLoopManager.cxx.
|
inlinefinalvirtual |
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 207 of file RLoopManager.hxx.
|
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 721 of file RLoopManager.cxx.
|
private |
Build TTreeReaderValues for all nodes This method loops over all filters, actions and other booked objects and calls their InitSlot
method, to get them ready for running a task.
Definition at line 664 of file RLoopManager.cxx.
void RLoopManager::Jit | ( | ) |
Add RDF nodes that require just-in-time compilation to the computation graph.
This method also clears the contents of GetCodeToJit().
Definition at line 779 of file RLoopManager.cxx.
void ROOT::Detail::RDF::RLoopManager::JitDeclarations | ( | ) |
|
delete |
|
inlinefinalvirtual |
End of recursive chain of calls, does nothing.
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 205 of file RLoopManager.hxx.
void RLoopManager::Register | ( | RDefineBase * | definePtr | ) |
Definition at line 899 of file RLoopManager.cxx.
void RLoopManager::Register | ( | RDFInternal::RActionBase * | actionPtr | ) |
Definition at line 861 of file RLoopManager.cxx.
void RLoopManager::Register | ( | RDFInternal::RVariationBase * | varPtr | ) |
Definition at line 910 of file RLoopManager.cxx.
void RLoopManager::Register | ( | RFilterBase * | filterPtr | ) |
Definition at line 874 of file RLoopManager.cxx.
void RLoopManager::Register | ( | RRangeBase * | rangePtr | ) |
Definition at line 889 of file RLoopManager.cxx.
void RLoopManager::RegisterCallback | ( | ULong64_t | everyNEvents, |
std::function< void(unsigned int)> && | f | ||
) |
Definition at line 948 of file RLoopManager.cxx.
|
finalvirtual |
Call FillReport
on all booked filters.
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 927 of file RLoopManager.cxx.
void RLoopManager::Run | ( | bool | jit = true | ) |
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...). The jitting phase is skipped if the jit
parameter is false
(unsafe, use with care).
Definition at line 816 of file RLoopManager.cxx.
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 644 of file RLoopManager.cxx.
|
private |
Run event loop over data accessed through a DataSource, in sequence.
Definition at line 571 of file RLoopManager.cxx.
|
private |
Run event loop over data accessed through a DataSource, in parallel.
Definition at line 602 of file RLoopManager.cxx.
|
private |
Run event loop with no source files, in sequence.
Definition at line 471 of file RLoopManager.cxx.
|
private |
Run event loop with no source files, in parallel.
Definition at line 425 of file RLoopManager.cxx.
|
private |
Run event loop over one or multiple ROOT files, in parallel.
Definition at line 488 of file RLoopManager.cxx.
|
private |
Run event loop over one or multiple ROOT files, in sequence.
Definition at line 534 of file RLoopManager.cxx.
void RLoopManager::SetTree | ( | std::shared_ptr< TTree > | tree | ) |
Definition at line 933 of file RLoopManager.cxx.
|
private |
Definition at line 680 of file RLoopManager.cxx.
|
inlinefinalvirtual |
Implements ROOT::Detail::RDF::RNodeBase.
Definition at line 208 of file RLoopManager.hxx.
void RLoopManager::ToJitExec | ( | const std::string & | code | ) | const |
Definition at line 942 of file RLoopManager.cxx.
|
private |
Definition at line 694 of file RLoopManager.cxx.
|
private |
Definition at line 699 of file RLoopManager.cxx.
|
friend |
Definition at line 112 of file RLoopManager.hxx.
|
private |
Definition at line 125 of file RLoopManager.hxx.
|
private |
Non-owning pointers to actions to be run.
Definition at line 114 of file RLoopManager.hxx.
|
private |
Definition at line 119 of file RLoopManager.hxx.
|
private |
Definition at line 116 of file RLoopManager.hxx.
|
private |
Contains a subset of fBookedFilters, i.e. only the named filters.
Definition at line 117 of file RLoopManager.hxx.
|
private |
Definition at line 118 of file RLoopManager.hxx.
|
private |
Definition at line 120 of file RLoopManager.hxx.
|
private |
Registered callbacks.
Definition at line 140 of file RLoopManager.hxx.
|
private |
Registered callbacks to invoke just once before running the loop.
Definition at line 142 of file RLoopManager.hxx.
|
private |
Readers for TTree/RDataSource columns (one per slot), shared by all nodes in the computation graph.
Definition at line 151 of file RLoopManager.hxx.
|
private |
Keys are fname + "/" + treename
as RSampleInfo::fID; Values are pointers to the corresponding group.
Definition at line 129 of file RLoopManager.hxx.
|
private |
Groups need to survive throughout the whole event loop, hence stored as an attribute.
Definition at line 131 of file RLoopManager.hxx.
|
private |
Owning pointer to a data-source object. Null if no data-source.
Definition at line 139 of file RLoopManager.hxx.
|
private |
Definition at line 134 of file RLoopManager.hxx.
Definition at line 126 of file RLoopManager.hxx.
|
private |
Friends of the fTree. Only used if we constructed fTree ourselves.
Definition at line 133 of file RLoopManager.hxx.
|
private |
The kind of event loop that is going to be run (e.g. on ROOT files, on no files)
Definition at line 138 of file RLoopManager.hxx.
|
private |
Definition at line 137 of file RLoopManager.hxx.
|
private |
Definition at line 135 of file RLoopManager.hxx.
|
private |
Definition at line 146 of file RLoopManager.hxx.
|
private |
Definition at line 156 of file RLoopManager.hxx.
|
private |
Number of event loops run.
Definition at line 148 of file RLoopManager.hxx.
|
private |
Definition at line 136 of file RLoopManager.hxx.
|
private |
Non-owning pointers to actions already run.
Definition at line 115 of file RLoopManager.hxx.
|
private |
Registered callbacks to call at the beginning of each "data block".
The key is the pointer of the corresponding node in the computation graph (a RDefinePerSample or a RAction).
Definition at line 145 of file RLoopManager.hxx.
|
private |
Definition at line 147 of file RLoopManager.hxx.
|
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 124 of file RLoopManager.hxx.
|
private |
Cache of the tree/chain branch names. Never access directy, always use GetBranchNames().
Definition at line 154 of file RLoopManager.hxx.