Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RCutFlowReport.cxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 02/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
12#include "TString.h" // Printf
13
14#include <algorithm>
15#include <stdexcept>
16
17namespace ROOT {
18
19namespace RDF {
20
22{
23 const auto allEntries = fCutInfos.empty() ? 0ULL : fCutInfos.begin()->GetAll();
24 for (auto &&ci : fCutInfos) {
25 const auto &name = ci.GetName();
26 const auto pass = ci.GetPass();
27 const auto all = ci.GetAll();
28 const auto eff = ci.GetEff();
29 const auto cumulativeEff = 100.f * float(pass) / float(allEntries);
30 Printf("%-10s: pass=%-10lld all=%-10lld -- eff=%3.2f %% cumulative eff=%3.2f %%", name.c_str(), pass, all, eff, cumulativeEff);
31 }
32}
33const TCutInfo &RCutFlowReport::operator[](std::string_view cutName)
34{
35 if (cutName.empty()) {
36 throw std::runtime_error("Cannot look for an unnamed cut.");
37 }
38 auto pred = [&cutName](const TCutInfo &ci) { return ci.GetName() == cutName; };
39 const auto ciItEnd = fCutInfos.end();
40 const auto it = std::find_if(fCutInfos.begin(), ciItEnd, pred);
41 if (ciItEnd == it) {
42 std::string err = "Cannot find a cut called \"";
43 err += cutName;
44 err += "\". Available named cuts are: \n";
45 for (auto &&ci : fCutInfos) {
46 err += " - " + ci.GetName() + "\n";
47 }
48 throw std::runtime_error(err);
49 }
50 return *it;
51}
52
53} // End NS RDF
54
55} // End NS ROOT
char name[80]
Definition TGX11.cxx:110
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
std::vector< TCutInfo > fCutInfos
const TCutInfo & operator[](std::string_view cutName)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...