Use just-in-time-compiled Filters and Defines for quick prototyping.
This tutorial illustrates how to save some typing when using RDataFrame by invoking functions that perform jit-compiling at runtime.
{
size_t npoints = 10000000;
auto 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&& x : p) r2 += x*x; return sqrt(r2);");
auto incircle = *(pidf.Filter("r <= 1.0").Count());
double pi_approx = 4.0 * incircle / npoints;
std::cout << "pi is approximately equal to " << pi_approx << std::endl;
}
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
pi is approximately equal to 3.14146
- Date
- October 2017
- Author
- Guilherme Amadio (CERN)
Definition in file df012_DefinesAndFiltersAsStrings.C.