13 using FourVector = ROOT::Math::XYZTVector;
14 using FourVectors = std::vector<FourVector>;
15 using CylFourVector = ROOT::Math::RhoEtaPhiVector;
19 void fill_tree(
const char *treeName,
const char *fileName)
21 ROOT::RDataFrame d(50);
23 d.Define(
"b1", [&i]() {
return (
double)i; })
30 .Snapshot(treeName, fileName);
33 void df004_cutFlowReport()
37 auto fileName =
"df004_cutFlowReport.root";
38 auto treeName =
"myTree";
39 fill_tree(treeName, fileName);
42 ROOT::RDataFrame d(treeName, fileName, {
"b1",
"b2"});
46 auto cut1 = [](
double b1) {
return b1 > 25.; };
47 auto cut2 = [](
int b2) {
return 0 == b2 % 2; };
51 auto filtered1 = d.Filter(cut1, {
"b1"},
"Cut1");
52 auto filtered2 = d.Filter(cut2, {
"b2"},
"Cut2");
54 auto augmented1 = filtered2.Define(
"b3", [](
double b1,
int b2) {
return b1 / b2; });
55 auto cut3 = [](
double x) {
return x < .5; };
56 auto filtered3 = augmented1.Filter(cut3, {
"b3"},
"Cut3");
67 std::cout <<
"Cut3 stats:" << std::endl;
68 filtered3.Report()->Print();
72 std::cout <<
"All stats:" << std::endl;
73 auto allCutsReport = d.Report();
74 allCutsReport->Print();
77 std::cout <<
"Name\tAll\tPass\tEfficiency" << std::endl;
78 for (
auto &&cutInfo : allCutsReport) {
79 std::cout << cutInfo.GetName() <<
"\t" << cutInfo.GetAll() <<
"\t" << cutInfo.GetPass() <<
"\t"
80 << cutInfo.GetEff() <<
" %" << std::endl;
84 auto cutName =
"Cut1";
85 auto cut = allCutsReport->At(
"Cut1");
86 std::cout << cutName <<
" efficiency is " << cut.GetEff() <<
" %" << std::endl;