14 void df012_DefinesAndFiltersAsStrings()
23 size_t npoints = 10000000;
24 ROOT::RDataFrame tdf(npoints);
34 auto pidf = tdf.Define(
"x",
"gRandom->Uniform(-1.0, 1.0)")
35 .Define(
"y",
"gRandom->Uniform(-1.0, 1.0)")
36 .Define(
"p",
"std::array<double, 2> v{x, y}; return v;")
37 .Define(
"r",
"double r2 = 0.0; for (auto&& x : p) r2 += x*x; return sqrt(r2);");
49 auto incircle = *(pidf.Filter(
"r <= 1.0").Count());
51 double pi_approx = 4.0 * incircle / npoints;
53 std::cout <<
"pi is approximately equal to " << pi_approx << std::endl;