Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:10

0001 #include "PhysicsTools/SelectorUtils/interface/CutApplicatorBase.h"
0002 
0003 class EtaMultiRangeCut : public CutApplicatorBase {
0004 public:
0005   EtaMultiRangeCut(const edm::ParameterSet& c) : CutApplicatorBase(c), _absEta(c.getParameter<bool>("useAbsEta")) {
0006     const std::vector<edm::ParameterSet>& ranges = c.getParameterSetVector("allowedEtaRanges");
0007     for (const auto& range : ranges) {
0008       const double min = range.getParameter<double>("minEta");
0009       const double max = range.getParameter<double>("maxEta");
0010       _ranges.emplace_back(min, max);
0011     }
0012   }
0013 
0014   double value(const reco::CandidatePtr& cand) const final { return (_absEta ? std::abs(cand->eta()) : cand->eta()); }
0015 
0016   result_type asCandidate(const argument_type&) const final;
0017 
0018 private:
0019   const bool _absEta;
0020   std::vector<std::pair<double, double> > _ranges;
0021 };
0022 
0023 DEFINE_EDM_PLUGIN(CutApplicatorFactory, EtaMultiRangeCut, "EtaMultiRangeCut");
0024 
0025 CutApplicatorBase::result_type EtaMultiRangeCut::asCandidate(const argument_type& cand) const {
0026   const double the_eta = (_absEta ? std::abs(cand->eta()) : cand->eta());
0027   bool result = false;
0028   for (const auto& range : _ranges) {
0029     if (the_eta >= range.first && the_eta < range.second) {
0030       result = true;
0031       break;
0032     }
0033   }
0034   return result;
0035 }