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 = tdf.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 high level interface for analyses of data stored in TTrees,...
REAL incircle(struct mesh *m, struct behavior *b, vertex pa, vertex pb, vertex pc, vertex pd)
pi is approximately equal to 3.14146
- Date
- October 2017
- Author
- Guilherme Amadio
Definition in file df012_DefinesAndFiltersAsStrings.C.