Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:53:06

0001 // Author: Enrico Guiraud, Danilo Piparo CERN  02/2018
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_RCUTFLOWREPORT
0012 #define ROOT_RCUTFLOWREPORT
0013 
0014 #include <string_view>
0015 #include "RtypesCore.h"
0016 
0017 #include <string>
0018 #include <vector>
0019 
0020 namespace ROOT {
0021 
0022 namespace Detail {
0023 namespace RDF {
0024 class RFilterBase;
0025 } // End NS RDF
0026 } // End NS Detail
0027 
0028 namespace RDF {
0029 
0030 class TCutInfo {
0031    friend class RCutFlowReport;
0032    friend class ROOT::Detail::RDF::RFilterBase;
0033 
0034 private:
0035    std::string fName;
0036    ULong64_t fPass;
0037    ULong64_t fAll;
0038    TCutInfo(const std::string &name, ULong64_t pass, ULong64_t all) : fName(name), fPass(pass), fAll(all) {}
0039 
0040 public:
0041    // Default constructor for the I/O
0042    TCutInfo() = default;
0043    const std::string &GetName() const { return fName; }
0044    ULong64_t GetAll() const { return fAll; }
0045    ULong64_t GetPass() const { return fPass; }
0046    float GetEff() const { return 100.f * (fPass / float(fAll)); }
0047 };
0048 
0049 class RCutFlowReport {
0050    friend class ROOT::Detail::RDF::RFilterBase;
0051 
0052 private:
0053    std::vector<TCutInfo> fCutInfos;
0054    void AddCut(TCutInfo &&ci) { fCutInfos.emplace_back(std::move(ci)); };
0055 
0056 public:
0057    using const_iterator = typename std::vector<TCutInfo>::const_iterator;
0058    void Print();
0059    const TCutInfo &operator[](std::string_view cutName);
0060    const TCutInfo &At(std::string_view cutName) { return operator[](cutName); }
0061    const_iterator begin() const { return fCutInfos.begin(); }
0062    const_iterator end() const { return fCutInfos.end(); }
0063 };
0064 
0065 } // End NS RDF
0066 } // End NS ROOT
0067 
0068 #endif