Use just-in-time-compiled Filters and Defines for quick prototyping.
This tutorial illustrates how to use jit-compiling features of RDataFrame to define data using C++ code in a Python script
import ROOT
npoints = 10000000
pidf = df.Define("x", "gRandom->Uniform(-1.0, 1.0)") \
.Define("y", "gRandom->Uniform(-1.0, 1.0)") \
.Define("p", "std::array<double, 2> v{x, y}; return v;") \
.Define("r", "double r2 = 0.0; for (auto&& w : p) r2 += w*w; return sqrt(r2);")
incircle = pidf.Filter("r <= 1.0").Count().GetValue()
pi_approx = 4.0 * incircle / npoints
print("pi is approximately equal to %g" % (pi_approx))
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
pi is approximately equal to 3.14146
- Date
- October 2017
- Author
- Guilherme Amadio (CERN)
Definition in file df012_DefinesAndFiltersAsStrings.py.