ROOT
master
Reference Guide
Loading...
Searching...
No Matches
df034_SaveGraph.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_dataframe
3
## \notebook -nodraw
4
## Basic SaveGraph usage.
5
##
6
## This tutorial shows how to use the SaveGraph action.
7
## SaveGraph inspects the sequence of RDataFrame actions.
8
##
9
## \macro_code
10
## \macro_output
11
##
12
## \date January 2022
13
## \author Ivan Kabadzhov (CERN)
14
15
# First, an RDataFrame computation graph is created with Defines, Filters and methods such as Mean, Count, etc.
16
# After that, SaveGraph can be called either on the root RDataFrame object or on a specific node of the computation
17
# graph: in the first case, the graph returned will span the full computation graph, in the second case it will show
18
# only the branch of the computation graph that the node belongs to.
19
# If a filename is passed as second argument, the graph is saved to that file, otherwise it is returned as a string.
20
21
import
ROOT
22
23
rd1 =
ROOT.RDataFrame
(2)
24
25
rd2 =
rd1.Define
(
"Root_def1"
,
"1"
) \
26
.Filter(
"Root_def1 < 2"
,
"Main_Filter"
) \
27
.Define(
"Root_def2"
,
"1"
)
28
29
branch1 =
rd2.Define
(
"Branch_1_def"
,
"1"
)
30
branch2 =
rd2.Define
(
"Branch_2_def"
,
"1"
)
31
32
branch1_1 =
branch1.Filter
(
"Branch_1_def < 2"
,
"Filter_1"
) \
33
.Define(
"Branch_1_1_def"
,
"1"
) \
34
.Filter(
"1 == Branch_1_1_def % 2"
,
"Filter_1_1"
) \
35
.Mean(
"Branch_1_1_def"
);
36
37
branch1_2 =
branch1.Define
(
"Branch_1_2_def"
,
"1"
) \
38
.Filter(
"Branch_1_2_def < 2"
,
"Filter_1_2"
) \
39
.Count()
40
41
branch2_1 =
branch2.Filter
(
"Branch_2_def < 2"
,
"Filter_2"
) \
42
.Define(
"Branch_2_1_def"
,
"1"
) \
43
.Define(
"Branch_2_2_def"
,
"1"
) \
44
.Filter(
"1 == Branch_2_1_def % 2"
,
"Filter_2_1"
) \
45
.Max(
"Branch_2_1_def"
)
46
47
branch2_2 =
branch2.Count
()
48
49
print(
ROOT.RDF.SaveGraph
(branch1_1))
50
ROOT.RDF.SaveGraph
(rd1,
"exampleGraph.dot"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::RDataFrame
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
Definition
RDataFrame.hxx:41
tutorials
analysis
dataframe
df034_SaveGraph.py
ROOT master - Reference Guide Generated on Sat Feb 1 2025 14:28:54 (GVA Time) using Doxygen 1.10.0