Process collections in RDataFrame with the help of RVec.
This tutorial shows the potential of the VecOps approach for treating collections stored in datasets, a situation very common in HEP data analysis.
import ROOT
coordDefineCode = '''ROOT::RVecD {0}(len);
std::transform({0}.begin(), {0}.end(), {0}.begin(), [](double){{return gRandom->Uniform(-1.0, 1.0);}});
return {0};'''
d = df.Define("len", "gRandom->Uniform(0, 16)")\
.
Define(
"x", coordDefineCode.format(
"x"))\
.
Define(
"y", coordDefineCode.format(
"y"))
d1 = d.Define("r", "sqrt(x*x + y*y)")
ring_h = d1.Define("rInFig", "r > .5 && r < 1 && x*y < 0")\
.Histo2D(("fig", "Two quarters of a ring", 64, -1.1, 1.1, 64, -1.1, 1.1), "xFig", "yFig")
cring = ROOT.TCanvas()
ring_h.Draw("Colz")
cring.SaveAs("df016_ring.png")
print("Saved figure to df016_ring.png")
RInterface< Proxied, DS_t > Define(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
- Date
- February 2018
- Author
- Danilo Piparo (CERN)
Definition in file df016_vecOps.py.