Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNodeBase.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 09/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RDFNODEBASE
12#define ROOT_RDFNODEBASE
13
14#include "RtypesCore.h"
15#include "TError.h" // R__ASSERT
16
17#include <memory>
18#include <string>
19#include <vector>
20#include <unordered_map>
21
22namespace ROOT {
23namespace RDF {
24class RCutFlowReport;
25}
26
27namespace Internal {
28namespace RDF {
29namespace GraphDrawing {
30class GraphNode;
31}
32}
33}
34
35namespace Detail {
36namespace RDF {
37
38class RLoopManager;
39
40/// Base class for non-leaf nodes of the computational graph.
41/// It only exposes the bare minimum interface required to work as a generic part of the computation graph.
42/// RDataFrames and results of transformations can be cast to this type via ROOT::RDF::RNode (or ROOT.RDF.AsRNode in PyROOT).
43class RNodeBase {
44protected:
46 unsigned int fNChildren{0}; ///< Number of nodes of the functional graph hanging from this object
47 unsigned int fNStopsReceived{0}; ///< Number of times that a children node signaled to stop processing entries.
48 std::vector<std::string> fVariations; ///< List of systematic variations that affect this node.
49
50public:
51 RNodeBase(const std::vector<std::string> &variations = {}, RLoopManager *lm = nullptr)
52 : fLoopManager(lm), fVariations(variations)
53 {
54 }
55 virtual ~RNodeBase() {}
56 virtual bool CheckFilters(unsigned int, Long64_t) = 0;
57 virtual void Report(ROOT::RDF::RCutFlowReport &) const = 0;
58 virtual void PartialReport(ROOT::RDF::RCutFlowReport &) const = 0;
59 virtual void IncrChildrenCount() = 0;
60 virtual void StopProcessing() = 0;
61 virtual void AddFilterName(std::vector<std::string> &filters) = 0;
62 // Helper function for SaveGraph
63 virtual std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>
64 GetGraph(std::unordered_map<void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap) = 0;
65
66 virtual void ResetChildrenCount()
67 {
68 fNChildren = 0;
70 }
71
73
74 const std::vector<std::string> &GetVariations() const { return fVariations; }
75
76 /// Return a clone of this node that acts as a Filter working with values in the variationName "universe".
77 virtual std::shared_ptr<RNodeBase> GetVariedFilter(const std::string & /*variationName*/)
78 {
79 R__ASSERT(false &&
80 "GetVariedFilter was called on a node type that does not implement it. This should never happen.");
81 return nullptr;
82 }
83};
84} // ns RDF
85} // ns Detail
86} // ns ROOT
87
88#endif
long long Long64_t
Definition RtypesCore.h:80
#define R__ASSERT(e)
Definition TError.h:118
const char * filters[]
The head node of a RDF computation graph.
Base class for non-leaf nodes of the computational graph.
Definition RNodeBase.hxx:43
const std::vector< std::string > & GetVariations() const
Definition RNodeBase.hxx:74
virtual void AddFilterName(std::vector< std::string > &filters)=0
virtual void StopProcessing()=0
virtual RLoopManager * GetLoopManagerUnchecked()
Definition RNodeBase.hxx:72
virtual bool CheckFilters(unsigned int, Long64_t)=0
virtual void IncrChildrenCount()=0
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"...
Definition RNodeBase.hxx:77
unsigned int fNStopsReceived
Number of times that a children node signaled to stop processing entries.
Definition RNodeBase.hxx:47
virtual void Report(ROOT::RDF::RCutFlowReport &) const =0
unsigned int fNChildren
Number of nodes of the functional graph hanging from this object.
Definition RNodeBase.hxx:46
virtual void PartialReport(ROOT::RDF::RCutFlowReport &) const =0
RNodeBase(const std::vector< std::string > &variations={}, RLoopManager *lm=nullptr)
Definition RNodeBase.hxx:51
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 void ResetChildrenCount()
Definition RNodeBase.hxx:66
std::vector< std::string > fVariations
List of systematic variations that affect this node.
Definition RNodeBase.hxx:48
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...