30pidf = df.Define(
"x",
"gRandom->Uniform(-1.0, 1.0)") \
31 .Define(
"y",
"gRandom->Uniform(-1.0, 1.0)") \
32 .Define(
"p",
"std::array<double, 2> v{x, y}; return v;") \
33 .Define(
"r",
"double r2 = 0.0; for (auto&& w : p) r2 += w*w; return sqrt(r2);")
45incircle = pidf.Filter(
"r <= 1.0").Count().GetValue()
47pi_approx = 4.0 * incircle / npoints
49print(
"pi is approximately equal to %g" % (pi_approx))
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...