13def fill_tree(treeName, fileName):
14 tdf = ROOT.ROOT.RDataFrame(10000)
15 tdf.Define(
"b1",
"(int) tdfentry_")\
16 .Define(
"b2",
"(float) tdfentry_ * tdfentry_").Snapshot(treeName, fileName)
19fileName =
"df007_snapshot_py.root"
20outFileName =
"df007_snapshot_output_py.root"
21outFileNameAllColumns =
"df007_snapshot_output_allColumns_py.root"
23fill_tree(treeName, fileName)
26RDF = ROOT.ROOT.RDataFrame
27d = RDF(treeName, fileName)
31d_cut = d.Filter(
"b1 % 2 == 0")
36std::vector<float> getVector (float b2)
39 for (int i = 0; i < 3; i++) v.push_back(b2*i);
43ROOT.gInterpreter.Declare(getVector_code)
45d2 = d_cut.Define("b1_square", "b1 * b1") \
46 .Define("b2_vector",
"getVector( b2 )")
54branchList = ROOT.vector(
'string')()
55for branchName
in [
"b1",
"b1_square",
"b2_vector"]:
56 branchList.push_back(branchName)
57d2.Snapshot(treeName, outFileName, branchList)
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 tdf:")
77for branch
in t.GetListOfBranches():
78 print(
"Branch: %s" %branch.GetName())
86branchList.push_back(
"b1_square")
87snapshot_tdf = d2.Snapshot(treeName, outFileName, branchList);
88h = snapshot_tdf.Histo1D(
"b1_square")