This tutorial shows how to get information about the efficiency of the filters applied
using FourVectors = std::vector<FourVector>;
void fill_tree(const char *treeName, const char *fileName)
{
int i(0);
d.Define(
"b1", [&i]() {
return (
double)i; })
.Define("b2",
[&i]() {
auto j = i * i;
++i;
return j;
})
.Snapshot(treeName, fileName);
}
{
auto fileName = "df004_cutFlowReport.root";
auto treeName = "myTree";
fill_tree(treeName, fileName);
auto cut1 = [](double b1) { return b1 > 25.; };
auto cut2 = [](int b2) { return 0 == b2 % 2; };
auto filtered1 =
d.
Filter(cut1, {
"b1"},
"Cut1");
auto filtered2 =
d.Filter(cut2, {
"b2"},
"Cut2");
auto augmented1 = filtered2.Define("b3", [](double b1, int b2) { return b1 / b2; });
auto cut3 = [](
double x) {
return x < .5; };
auto filtered3 = augmented1.Filter(cut3, {"b3"}, "Cut3");
std::cout << "Cut3 stats:" << std::endl;
filtered3.Report()->Print();
std::cout << "All stats:" << std::endl;
auto allCutsReport =
d.Report();
allCutsReport->Print();
std::cout << "Name\tAll\tPass\tEfficiency" << std::endl;
for (auto &&cutInfo : allCutsReport) {
std::cout << cutInfo.GetName() << "\t" << cutInfo.GetAll() << "\t" << cutInfo.GetPass() << "\t"
<< cutInfo.GetEff() << " %" << std::endl;
}
auto cutName = "Cut1";
auto cut = allCutsReport->At("Cut1");
std::cout << cutName << " efficiency is " << cut.GetEff() << " %" << std::endl;
}
RInterface< RDFDetail::RFilter< F, Proxied >, DS_t > Filter(F f, const ColumnNames_t &columns={}, std::string_view name="")
Append a filter to the call graph.
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
DisplacementVector3D< CylindricalEta3D< double >, DefaultCoordinateSystemTag > RhoEtaPhiVector
3D Vector based on the eta based cylindrical coordinates rho, eta, phi in double precision.
LorentzVector< PxPyPzE4D< double > > XYZTVector
LorentzVector based on x,y,x,t (or px,py,pz,E) coordinates in double precision with metric (-,...
Cut3 stats:
Cut2 : pass=25 all=50 -- eff=50.00 % cumulative eff=50.00 %
Cut3 : pass=23 all=25 -- eff=92.00 % cumulative eff=46.00 %
All stats:
Cut1 : pass=24 all=50 -- eff=48.00 % cumulative eff=48.00 %
Cut2 : pass=25 all=50 -- eff=50.00 % cumulative eff=50.00 %
Cut3 : pass=23 all=25 -- eff=92.00 % cumulative eff=46.00 %
Name All Pass Efficiency
Cut1 50 24 48 %
Cut2 50 25 50 %
Cut3 25 23 92 %
Cut1 efficiency is 48 %