CMS 3D CMS Logo

MinPtCutInEtaRanges.cc
Go to the documentation of this file.
2 
4 public:
5  MinPtCutInEtaRanges(const edm::ParameterSet& c) : CutApplicatorBase(c), _absEta(c.getParameter<bool>("useAbsEta")) {
6  const std::vector<edm::ParameterSet>& ranges = c.getParameterSetVector("allowedEtaRanges");
7  for (const auto& range : ranges) {
8  const double minEta = range.getParameter<double>("minEta");
9  const double maxEta = range.getParameter<double>("maxEta");
10  const double minPt = range.getParameter<double>("minPt");
11  _ranges.emplace_back(minEta, maxEta);
12  _minPt.push_back(minPt);
13  }
14  }
15 
16  double value(const reco::CandidatePtr& cand) const final { return cand->pt(); }
17 
18  result_type asCandidate(const argument_type&) const final;
19 
20 private:
21  const bool _absEta;
22  std::vector<std::pair<double, double> > _ranges;
23  std::vector<double> _minPt; // indexed as above
24 };
25 
27 
29  const double the_eta = (_absEta ? std::abs(cand->eta()) : cand->eta());
30  bool result = false;
31  for (unsigned i = 0; i < _ranges.size(); ++i) {
32  const auto& range = _ranges[i];
33  if (the_eta >= range.first && the_eta < range.second && cand->pt() > _minPt[i]) {
34  result = true;
35  break;
36  }
37  }
38  return result;
39 }
MinPtCutInEtaRanges(const edm::ParameterSet &c)
std::vector< double > _minPt
minPt
Definition: PV_cfg.py:223
std::vector< std::pair< double, double > > _ranges
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
string ranges
Definition: diffTwoXMLs.py:79
reco::CandidatePtr argument_type
Definition: CandidateCut.h:10
result_type asCandidate(const argument_type &) const final
#define DEFINE_EDM_PLUGIN(factory, type, name)
double value(const reco::CandidatePtr &cand) const final