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 }
VParameterSet const & getParameterSetVector(std::string const &name) const
result_type asCandidate(const argument_type &) const final
double value(const reco::CandidatePtr &cand) const final
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
string ranges
Definition: diffTwoXMLs.py:79
EtaMultiRangeCut(const edm::ParameterSet &c)
std::vector< std::pair< double, double > > _ranges
#define DEFINE_EDM_PLUGIN(factory, type, name)