17def fill_tree(treeName, fileName):
19 df.Define(
"b1",
"(int) rdfentry_")\
20 .Define(
"b2",
"(float) rdfentry_ * rdfentry_").Snapshot(treeName, fileName)
23fileName =
"df007_snapshot_py.root"
24outFileName =
"df007_snapshot_output_py.root"
25outFileNameAllColumns =
"df007_snapshot_output_allColumns_py.root"
27fill_tree(treeName, fileName)
34d_cut = d.Filter(
"b1 % 2 == 0")
39std::vector<float> getVector (float b2)
42 for (int i = 0; i < 3; i++) v.push_back(b2*i);
46ROOT.gInterpreter.Declare(getVector_code)
48d2 = d_cut.Define(
"b1_square",
"b1 * b1") \
49 .Define(
"b2_vector",
"getVector( b2 )")
57d2.Snapshot(treeName, outFileName, \
58 [
"b1",
"b1_square",
"b2_vector"])
60f1 = ROOT.TFile(outFileName)
62print(
"These are the columns b1, b1_square and b2_vector:")
63for branch
in t.GetListOfBranches():
64 print(
"Branch: %s" %branch.GetName())
71d2.Snapshot(treeName, outFileNameAllColumns)
74f2 = ROOT.TFile(outFileNameAllColumns)
76print(
"These are all the columns available to this dataframe:")
77for branch
in t.GetListOfBranches():
78 print(
"Branch: %s" %branch.GetName())
85snapshot_df = d2.Snapshot(treeName, outFileName, [
"b1_square"]);
86h = snapshot_df.Histo1D(
"b1_square")
90c.SaveAs(
"df007_snapshot.png")
92print(
"Saved figure to df007_snapshot.png")
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...