Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:25

0001 #include "PhysicsTools/SelectorUtils/interface/CutApplicatorBase.h"
0002 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0003 
0004 class GsfEleSCEtaMultiRangeCut : public CutApplicatorBase {
0005 public:
0006   GsfEleSCEtaMultiRangeCut(const edm::ParameterSet& c)
0007       : CutApplicatorBase(c), _absEta(c.getParameter<bool>("useAbsEta")) {
0008     const std::vector<edm::ParameterSet>& ranges = c.getParameterSetVector("allowedEtaRanges");
0009     for (const auto& range : ranges) {
0010       const double min = range.getParameter<double>("minEta");
0011       const double max = range.getParameter<double>("maxEta");
0012       _ranges.emplace_back(min, max);
0013     }
0014   }
0015 
0016   result_type operator()(const reco::GsfElectronPtr&) const final;
0017 
0018   double value(const reco::CandidatePtr& cand) const final;
0019 
0020   CandidateType candidateType() const final { return ELECTRON; }
0021 
0022 private:
0023   const bool _absEta;
0024   std::vector<std::pair<double, double> > _ranges;
0025 };
0026 
0027 DEFINE_EDM_PLUGIN(CutApplicatorFactory, GsfEleSCEtaMultiRangeCut, "GsfEleSCEtaMultiRangeCut");
0028 
0029 CutApplicatorBase::result_type GsfEleSCEtaMultiRangeCut::operator()(const reco::GsfElectronPtr& cand) const {
0030   const reco::SuperClusterRef& scref = cand->superCluster();
0031   const double the_eta = (_absEta ? std::abs(scref->eta()) : scref->eta());
0032   bool result = false;
0033   for (const auto& range : _ranges) {
0034     if (the_eta >= range.first && the_eta < range.second) {
0035       result = true;
0036       break;
0037     }
0038   }
0039   return result;
0040 }
0041 
0042 double GsfEleSCEtaMultiRangeCut::value(const reco::CandidatePtr& cand) const {
0043   reco::GsfElectronPtr ele(cand);
0044   const reco::SuperClusterRef& scref = ele->superCluster();
0045   return (_absEta ? std::abs(scref->eta()) : scref->eta());
0046 }