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 > .4 && r < .8 && x*y < 0")\
.Define("yFig", "y[rInFig]")\
.Define("xFig", "x[rInFig]")\
.Histo2D(("fig", "Two quarters of a ring", 64, -1, 1, 64, -1, 1), "xFig", "yFig")
cring = ROOT.TCanvas()
ring_h.Draw("Colz")
cring.SaveAs("df016_ring.png")
print("Saved figure to df016_ring.png")
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
- Date
- February 2018
- Author
- Danilo Piparo (CERN)
Definition in file df016_vecOps.py.