Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RCutFlowReport.hxx
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 
11 #ifndef ROOT_RCUTFLOWREPORT
12 #define ROOT_RCUTFLOWREPORT
13 
14 #include "RtypesCore.h"
15 #include "TString.h"
16 
17 #include <string>
18 #include <vector>
19 
20 namespace ROOT {
21 
22 namespace Detail {
23 namespace RDF {
24 class RFilterBase;
25 } // End NS RDF
26 } // End NS Detail
27 
28 namespace RDF {
29 
30 class TCutInfo {
31  friend class RCutFlowReport;
32  friend class ROOT::Detail::RDF::RFilterBase;
33 
34 private:
35  const std::string fName;
36  const ULong64_t fPass;
37  const ULong64_t fAll;
38  TCutInfo(const std::string &name, ULong64_t pass, ULong64_t all) : fName(name), fPass(pass), fAll(all) {}
39 
40 public:
41  const std::string &GetName() const { return fName; }
42  ULong64_t GetAll() const { return fAll; }
43  ULong64_t GetPass() const { return fPass; }
44  float GetEff() const { return 100.f * (fPass / float(fAll)); }
45 };
46 
47 class RCutFlowReport {
48  friend class ROOT::Detail::RDF::RFilterBase;
49 
50 private:
51  std::vector<TCutInfo> fCutInfos;
52  void AddCut(TCutInfo &&ci) { fCutInfos.emplace_back(std::move(ci)); };
53 
54 public:
55  using const_iterator = typename std::vector<TCutInfo>::const_iterator;
56  void Print();
57  const TCutInfo &operator[](std::string_view cutName);
58  const TCutInfo &At(std::string_view cutName) { return operator[](cutName); }
59  const_iterator begin() const { return fCutInfos.begin(); }
60  const_iterator end() const { return fCutInfos.end(); }
61 };
62 
63 } // End NS RDF
64 } // End NS ROOT
65 
66 #endif