CMS 3D CMS Logo

EtaPtBin.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 #include <sstream>
5 
6 EtaPtBin::EtaPtBin(const bool& etaActive_,
7  const double& etaMin_,
8  const double& etaMax_,
9  const bool& ptActive_,
10  const double& ptMin_,
11  const double& ptMax_)
12  : etaActive(etaActive_), etaMin(etaMin_), etaMax(etaMax_), ptActive(ptActive_), ptMin(ptMin_), ptMax(ptMax_) {
14 }
15 
17  const double& etaMin_,
18  const double& etaMax_,
19  const bool& ptActive_,
20  const double& ptMin_,
21  const double& ptMax_) {
22  // create string only from the active parts
23  std::stringstream stream("");
24 
25  if (etaActive_) {
26  stream << "_ETA_" << etaMin_ << "-" << etaMax_;
27  }
28 
29  if (ptActive_) {
30  stream << "_PT_" << ptMin_ << "-" << ptMax_;
31  }
32  if (!(etaActive_ || ptActive_))
33  stream << "_GLOBAL";
34 
35  std::string descr(stream.str());
36  // remove blanks which are introduced when adding doubles
37  std::remove(descr.begin(), descr.end(), ' ');
38  std::replace(descr.begin(), descr.end(), '.', 'v');
39 
40  return descr;
41 }
42 
43 bool EtaPtBin::inBin(const reco::Jet& jet, const double jec) const { return inBin(jet.eta(), jet.pt() * jec); }
44 
45 // bool EtaPtBin::inBin(const BTagMCTools::JetFlavour & jetFlavour) const
46 // {
47 // return inBin(jetFlavour.underlyingParton4Vec().Eta(),
48 // jetFlavour.underlyingParton4Vec().Pt());
49 // }
50 
51 bool EtaPtBin::inBin(const double& eta, const double& pt) const {
52  if (etaActive) {
53  if (fabs(eta) < etaMin)
54  return false;
55  if (fabs(eta) > etaMax)
56  return false;
57  }
58 
59  if (ptActive) {
60  if (pt < ptMin)
61  return false;
62  if (pt > ptMax)
63  return false;
64  }
65 
66  return true;
67 }
Base class for all types of Jets.
Definition: Jet.h:20
double ptMin
Definition: EtaPtBin.h:60
std::string descriptionString
Definition: EtaPtBin.h:64
constexpr float ptMin
def replace(string, replacements)
static std::string buildDescriptionString(const bool &etaActive_, const double &etaMin_, const double &etaMax_, const bool &ptActive_, const double &ptMin_, const double &ptMax_)
Definition: EtaPtBin.cc:16
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
double etaMax
Definition: EtaPtBin.h:57
double etaMin
Definition: EtaPtBin.h:56
EtaPtBin(const bool &etaActive_, const double &etaMin_, const double &etaMax_, const bool &ptActive_, const double &ptMin_, const double &ptMax_)
Definition: EtaPtBin.cc:6
bool ptActive
Definition: EtaPtBin.h:59
bool etaActive
Definition: EtaPtBin.h:55
double ptMax
Definition: EtaPtBin.h:61
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:234
bool inBin(const double &eta, const double &pt) const
Check if jet/parton are within rapidity/pt cuts.
Definition: EtaPtBin.cc:51