File indexing completed on 2025-02-20 03:45:25
0001 #include "DQMOffline/RecoB/interface/EtaPtBin.h"
0002
0003 #include <algorithm>
0004 #include <sstream>
0005
0006 EtaPtBin::EtaPtBin(const bool& etaActive_,
0007 const double& etaMin_,
0008 const double& etaMax_,
0009 const bool& ptActive_,
0010 const double& ptMin_,
0011 const double& ptMax_)
0012 : etaActive(etaActive_), etaMin(etaMin_), etaMax(etaMax_), ptActive(ptActive_), ptMin(ptMin_), ptMax(ptMax_) {
0013 descriptionString = buildDescriptionString(etaActive, etaMin, etaMax, ptActive, ptMin, ptMax);
0014 }
0015
0016 std::string EtaPtBin::buildDescriptionString(const bool& etaActive_,
0017 const double& etaMin_,
0018 const double& etaMax_,
0019 const bool& ptActive_,
0020 const double& ptMin_,
0021 const double& ptMax_) {
0022
0023 std::stringstream stream("");
0024
0025 if (etaActive_) {
0026 stream << "_ETA_" << etaMin_ << "-" << etaMax_;
0027 }
0028
0029 if (ptActive_) {
0030 stream << "_PT_" << ptMin_ << "-" << ptMax_;
0031 }
0032 if (!(etaActive_ || ptActive_))
0033 stream << "_GLOBAL";
0034
0035 std::string descr(stream.str());
0036
0037 auto last = std::remove(descr.begin(), descr.end(), ' ');
0038 descr.erase(last, descr.end());
0039 std::replace(descr.begin(), descr.end(), '.', 'v');
0040
0041 return descr;
0042 }
0043
0044 bool EtaPtBin::inBin(const reco::Jet& jet, const double jec) const { return inBin(jet.eta(), jet.pt() * jec); }
0045
0046
0047
0048
0049
0050
0051
0052 bool EtaPtBin::inBin(const double& eta, const double& pt) const {
0053 if (etaActive) {
0054 if (fabs(eta) < etaMin)
0055 return false;
0056 if (fabs(eta) > etaMax)
0057 return false;
0058 }
0059
0060 if (ptActive) {
0061 if (pt < ptMin)
0062 return false;
0063 if (pt > ptMax)
0064 return false;
0065 }
0066
0067 return true;
0068 }