19def fill_tree(treeName, fileName):
21 df.Define(
"b1",
"(double) rdfentry_")\
22 .Define(
"b2",
"(int) rdfentry_ * rdfentry_").Snapshot(treeName, fileName)
25fileName =
"df001_introduction_py.root"
27fill_tree(treeName, fileName)
46cutb1b2 =
'b2 % 2 && b1 < 4.'
52entries1 = d.Filter(cutb1) \
56print(
'{} entries passed all filters'.
format(entries1.GetValue()))
58entries2 = d.Filter(
"b1 < 5.").Count();
59print(
'{} entries passed all filters'.
format(entries2.GetValue()))
64b1b2_cut = d.Filter(cutb1b2)
65minVal = b1b2_cut.Min(
'b1')
66maxVal = b1b2_cut.Max(
'b1')
67meanVal = b1b2_cut.Mean(
'b1')
68nonDefmeanVal = b1b2_cut.Mean(
"b2")
69print(
'The mean is always included between the min and the max: {0} <= {1} <= {2}'.
format(minVal.GetValue(), meanVal.GetValue(), maxVal.GetValue()))
76hist = d.Filter(cutb1).Histo1D(
'b1')
77print(
'Filled h {0} times, mean: {1}'.
format(hist.GetEntries(), hist.GetMean()))
86cutb1_result = d.Filter(cutb1);
87cutb1b2_result = d.Filter(cutb1b2);
88cutb1_cutb1b2_result = cutb1_result.Filter(cutb1b2)
91evts_cutb1_result = cutb1_result.Count()
92evts_cutb1b2_result = cutb1b2_result.Count()
93evts_cutb1_cutb1b2_result = cutb1_cutb1b2_result.Count()
95print(
'Events passing cutb1: {}'.
format(evts_cutb1_result.GetValue()))
96print(
'Events passing cutb1b2: {}'.
format(evts_cutb1b2_result.GetValue()))
97print(
'Events passing both: {}'.
format(evts_cutb1_cutb1b2_result.GetValue()))
112entries_sum = d.Define(
'sum',
'b2 + b1') \
113 .Filter(
'sum > 4.2') \
115print(entries_sum.GetValue())
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...