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 MinPtCutInEtaRanges : public CutApplicatorBase {
0004 public:
0005   MinPtCutInEtaRanges(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 minEta = range.getParameter<double>("minEta");
0009       const double maxEta = range.getParameter<double>("maxEta");
0010       const double minPt = range.getParameter<double>("minPt");
0011       _ranges.emplace_back(minEta, maxEta);
0012       _minPt.push_back(minPt);
0013     }
0014   }
0015 
0016   double value(const reco::CandidatePtr& cand) const final { return cand->pt(); }
0017 
0018   result_type asCandidate(const argument_type&) const final;
0019 
0020 private:
0021   const bool _absEta;
0022   std::vector<std::pair<double, double> > _ranges;
0023   std::vector<double> _minPt;  // indexed as above
0024 };
0025 
0026 DEFINE_EDM_PLUGIN(CutApplicatorFactory, MinPtCutInEtaRanges, "MinPtCutInEtaRanges");
0027 
0028 CutApplicatorBase::result_type MinPtCutInEtaRanges::asCandidate(const argument_type& cand) const {
0029   const double the_eta = (_absEta ? std::abs(cand->eta()) : cand->eta());
0030   bool result = false;
0031   for (unsigned i = 0; i < _ranges.size(); ++i) {
0032     const auto& range = _ranges[i];
0033     if (the_eta >= range.first && the_eta < range.second && cand->pt() > _minPt[i]) {
0034       result = true;
0035       break;
0036     }
0037   }
0038   return result;
0039 }