24 size_t npoints = 10000000;
35 auto pidf = df.Define(
"x",
"gRandom->Uniform(-1.0, 1.0)")
36 .Define(
"y",
"gRandom->Uniform(-1.0, 1.0)")
37 .Define(
"p",
"std::array<double, 2> v{x, y}; return v;")
38 .Define(
"r",
"double r2 = 0.0; for (auto&& x : p) r2 += x*x; return sqrt(r2);");
50 auto incircle = *(pidf.Filter(
"r <= 1.0").Count());
52 double pi_approx = 4.0 * incircle / npoints;
54 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 ,...