19namespace GraphDrawing {
24 std::stringstream dotStringLabels;
26 std::stringstream dotStringGraph;
30 dotStringLabels <<
"\t" << leaf->fCounter <<
" [label=\"" << leaf->fName <<
"\", style=\"filled\", fillcolor=\""
31 << leaf->fColor <<
"\", shape=\"" << leaf->fShape <<
"\"];\n";
32 if (leaf->fPrevNode) {
33 dotStringGraph <<
"\t" << leaf->fPrevNode->fCounter <<
" -> " << leaf->fCounter <<
";\n";
35 leaf = leaf->fPrevNode;
38 return "digraph {\n" + dotStringLabels.str() + dotStringGraph.str() +
"}";
44 std::stringstream dotStringLabels;
46 std::stringstream dotStringGraph;
48 for (
auto leaf : leaves) {
49 while (leaf && !leaf->fIsExplored) {
50 dotStringLabels <<
"\t" << leaf->fCounter <<
" [label=\"" << leaf->fName
51 <<
"\", style=\"filled\", fillcolor=\"" << leaf->fColor <<
"\", shape=\"" << leaf->fShape
53 if (leaf->fPrevNode) {
54 dotStringGraph <<
"\t" << leaf->fPrevNode->fCounter <<
" -> " << leaf->fCounter <<
";\n";
57 leaf->fIsExplored =
true;
58 leaf = leaf->fPrevNode;
61 return "digraph {\n" + dotStringLabels.str() + dotStringGraph.str() +
"}";
78 std::vector<std::shared_ptr<GraphNode>> nodes;
79 nodes.reserve(actions.size() + edges.size());
81 for (
auto *action : actions)
82 nodes.emplace_back(action->GetGraph());
83 for (
auto *edge : edges)
84 nodes.emplace_back(edge->GetGraph());
89std::shared_ptr<GraphNode>
95 auto duplicateDefineIt = sColumnsMap.find(columnPtr);
96 if (duplicateDefineIt != sColumnsMap.end()) {
97 auto duplicateDefine = duplicateDefineIt->second.lock();
98 return duplicateDefine;
101 auto node = std::make_shared<GraphNode>(
"Define\n" + columnName);
104 sColumnsMap[columnPtr] = node;
112 auto duplicateFilterIt = sFiltersMap.find(filterPtr);
113 if (duplicateFilterIt != sFiltersMap.end()) {
114 auto duplicateFilter = duplicateFilterIt->second.lock();
115 duplicateFilter->SetIsNew(
false);
116 return duplicateFilter;
118 auto filterName = (filterPtr->
HasName() ? filterPtr->
GetName() :
"Filter");
119 auto node = std::make_shared<GraphNode>(filterName);
121 sFiltersMap[filterPtr] = node;
130 auto duplicateRangeIt = sRangesMap.find(rangePtr);
131 if (duplicateRangeIt != sRangesMap.end()) {
132 auto duplicateRange = duplicateRangeIt->second.lock();
133 duplicateRange->SetIsNew(
false);
134 return duplicateRange;
136 auto node = std::make_shared<GraphNode>(
"Range");
139 sRangesMap[rangePtr] = node;
145 const std::vector<std::string> &prevNodeDefines)
147 auto upmostNode = node;
148 const auto &defineNames = defines.
GetNames();
150 for (
auto i =
int(defineNames.size()) - 1; i >= 0; --i) {
151 const auto colName = defineNames[i];
152 const bool isAlias = defineMap.find(colName) == defineMap.end();
155 const bool isANewDefine =
156 std::find(prevNodeDefines.begin(), prevNodeDefines.end(), colName) == prevNodeDefines.end();
162 upmostNode->SetPrevNode(defineNode);
163 upmostNode = defineNode;
std::string GetName() const
The head node of a RDF computation graph.
std::vector< RDFInternal::RActionBase * > GetAllActions() const
Return all actions, either booked or already run.
std::vector< RNodeBase * > GetGraphEdges() const
Return all graph edges known to RLoopManager This includes Filters and Ranges but not Defines.
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
static FiltersNodesMap_t & GetStaticFiltersMap()
Stores the filters defined and which node in the graph defined them.
static DefinesNodesMap_t & GetStaticColumnsMap()
Stores the columns defined and which node in the graph defined them.
std::string FromGraphLeafToDot(std::shared_ptr< GraphNode > leaf)
Starting from any leaf (Action, Filter, Range) it draws the dot representation of the branch.
std::string FromGraphActionsToDot(std::vector< std::shared_ptr< GraphNode > > leaves)
Starting by an array of leaves, it draws the entire graph.
std::string RepresentGraph(ROOT::RDataFrame &rDataFrame)
Starting from the root node, prints the entire graph.
static RangesNodesMap_t & GetStaticRangesMap()
Stores the ranges defined and which node in the graph defined them.
Encapsulates the columns defined by the user.
const RDefineBasePtrMap_t & GetColumns() const
Returns the list of the pointers to the defined columns.
ColumnNames_t GetNames() const
Returns the list of the names of the defined columns.
RLoopManager * GetLoopManager() const
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
std::shared_ptr< GraphNode > CreateDefineNode(const std::string &columnName, const ROOT::Detail::RDF::RDefineBase *columnPtr)
std::shared_ptr< GraphNode > CreateRangeNode(const ROOT::Detail::RDF::RRangeBase *rangePtr)
std::shared_ptr< GraphNode > AddDefinesToGraph(std::shared_ptr< GraphNode > node, const RDFInternal::RBookedDefines &defines, const std::vector< std::string > &prevNodeDefines)
Add the Defines that have been added between this node and the previous to the graph.
std::shared_ptr< GraphNode > CreateFilterNode(const ROOT::Detail::RDF::RFilterBase *filterPtr)
bool IsInternalColumn(std::string_view colName)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...