CMS 3D CMS Logo

EtaMultiRangeCut.cc
Go to the documentation of this file.
2 
4 public:
5  EtaMultiRangeCut(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 min = range.getParameter<double>("minEta");
9  const double max = range.getParameter<double>("maxEta");
10  _ranges.emplace_back(min, max);
11  }
12  }
13 
14  double value(const reco::CandidatePtr& cand) const final { return (_absEta ? std::abs(cand->eta()) : cand->eta()); }
15 
16  result_type asCandidate(const argument_type&) const final;
17 
18 private:
19  const bool _absEta;
20  std::vector<std::pair<double, double> > _ranges;
21 };
22 
24 
26  const double the_eta = (_absEta ? std::abs(cand->eta()) : cand->eta());
27  bool result = false;
28  for (const auto& range : _ranges) {
29  if (the_eta >= range.first && the_eta < range.second) {
30  result = true;
31  break;
32  }
33  }
34  return result;
35 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
string ranges
Definition: diffTwoXMLs.py:79
EtaMultiRangeCut(const edm::ParameterSet &c)
std::vector< std::pair< double, double > > _ranges
reco::CandidatePtr argument_type
Definition: CandidateCut.h:10
double value(const reco::CandidatePtr &cand) const final
#define DEFINE_EDM_PLUGIN(factory, type, name)
result_type asCandidate(const argument_type &) const final