File indexing completed on 2024-04-06 12:09:48
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 std::remove(descr.begin(), descr.end(), ' ');
0038 std::replace(descr.begin(), descr.end(), '.', 'v');
0039
0040 return descr;
0041 }
0042
0043 bool EtaPtBin::inBin(const reco::Jet& jet, const double jec) const { return inBin(jet.eta(), jet.pt() * jec); }
0044
0045
0046
0047
0048
0049
0050
0051 bool EtaPtBin::inBin(const double& eta, const double& pt) const {
0052 if (etaActive) {
0053 if (fabs(eta) < etaMin)
0054 return false;
0055 if (fabs(eta) > etaMax)
0056 return false;
0057 }
0058
0059 if (ptActive) {
0060 if (pt < ptMin)
0061 return false;
0062 if (pt > ptMax)
0063 return false;
0064 }
0065
0066 return true;
0067 }