13def fill_tree(treeName, fileName):
14 df.Define(
"b1",
"(int) rdfentry_")\
15 .Define(
"b2",
"(float) rdfentry_ * rdfentry_").Snapshot(treeName, fileName)
18fileName =
"df007_snapshot_py.root"
19outFileName =
"df007_snapshot_output_py.root"
20outFileNameAllColumns =
"df007_snapshot_output_allColumns_py.root"
22fill_tree(treeName, fileName)
29d_cut = d.Filter(
"b1 % 2 == 0")
34std::vector<float> getVector (float b2)
37 for (int i = 0; i < 3; i++) v.push_back(b2*i);
41ROOT.gInterpreter.Declare(getVector_code)
43d2 = d_cut.Define("b1_square", "b1 * b1") \
44 .Define("b2_vector",
"getVector( b2 )")
52branchList = ROOT.vector(
'string')()
53for branchName
in [
"b1",
"b1_square",
"b2_vector"]:
54 branchList.push_back(branchName)
55d2.Snapshot(treeName, outFileName, branchList)
58f1 = ROOT.TFile(outFileName)
60print(
"These are the columns b1, b1_square and b2_vector:")
61for branch
in t.GetListOfBranches():
62 print(
"Branch: %s" %branch.GetName())
69d2.Snapshot(treeName, outFileNameAllColumns)
72f2 = ROOT.TFile(outFileNameAllColumns)
74print(
"These are all the columns available to this dataframe:")
75for branch
in t.GetListOfBranches():
76 print(
"Branch: %s" %branch.GetName())
84branchList.push_back(
"b1_square")
85snapshot_df = d2.Snapshot(treeName, outFileName, branchList);
86h = snapshot_df.Histo1D(
"b1_square")
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...