RDataFrame SaveGraph root node

Hi,

I am very happy about the new RDataFrame and am using it frequently.

I am using RDataFrame with PyROOT in version 6.16.00.

I want to apply some Filters to the RDataFrame and then visualize all filter nodes with the ROOT.RDF.SaveGraph() function.

From the documentation I get, that for this I have to call the function on the head node. But by doing this I get only an empty .dot file. Calling the function on a daughter node on the other hand produces the expected (sub)graph.

I am using the following code to get this result:

import ROOT
import numpy as np

def fill_tree(treeName, fileName):
    ROOT.gRandom.SetSeed(1)
    tdf = ROOT.ROOT.RDataFrame(100)
    tdf.Define("b1", "gRandom->Gaus()")\
       .Define("b2", "gRandom->Gaus()")\
       .Define("b3", "gRandom->Gaus()")\
       .Define("b4", "gRandom->Gaus()")\
       .Snapshot(treeName, fileName)

def fslice(frame, binedges, varname):
    if binedges == ():
        return ()

    left, right = np.array_split(binedges, 2)

    if len(left) == 0:
        return ()

    splitval = left[-1]
    
    if len(left) == 1:
        return (
            frame.Filter(
                "{1} < {0}".format(splitval, varname), 
                "{1} < {0}".format(splitval, varname)), 
            frame.Filter(
                "{1} > {0}".format(splitval, varname), 
                "{1} > {0}".format(splitval, varname))
            )
    else:
        return fslice(
            frame.Filter(
                "{1} < {0}".format(splitval, varname), 
                "{1} < {0}".format(splitval, varname)),
            left[:-1],
            varname
            ) + fslice(
            frame.Filter(
                "{1} > {0}".format(splitval, varname), 
                "{1} > {0}".format(splitval, varname)),
            right,
            varname)

treeName = 'tree'
fileName = treeName+".root"
fill_tree(treeName, treeName+".root")

f = ROOT.ROOT.RDataFrame(treeName, fileName)
ROOT.RDF.SaveGraph(f, "graph.dot")

frames = fslice(f, np.linspace(-1,1,6), "b1")

ROOT.RDF.SaveGraph(frames[-1], "graph1.dot")
ROOT.RDF.SaveGraph(f, "graph2.dot")

Even with a very simple

f = ROOT.ROOT.RDataFrame(treeName, fileName)
f2 = f.Filter("b2 > 2.")
ROOT.RDF.SaveGraph(f, "graph.dot")

I get only a empty graph.dot file with:

digraph {
}

Can somebody help me getting the complete graphs?

Cheers,
Christian

Hi Christian,
this is a bug! I filed a ticket at https://sft.its.cern.ch/jira/browse/ROOT-9977 , please follow the development there. And please feel free to ping us there if you don’t see any movement in a few weeks.

Cheers,
Enrico