Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:53

0001 #include "PhysicsTools/SelectorUtils/interface/CutApplicatorBase.h"
0002 #include "DataFormats/MuonReco/interface/Muon.h"
0003 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
0004 
0005 class MuonMomQualityCut : public CutApplicatorBase {
0006 public:
0007   MuonMomQualityCut(const edm::ParameterSet& c);
0008 
0009   result_type operator()(const reco::MuonPtr&) const final;
0010   CandidateType candidateType() const final { return MUON; }
0011   double value(const reco::CandidatePtr&) const final;
0012 
0013 private:
0014   const double maxRelPtErr_;
0015 };
0016 DEFINE_EDM_PLUGIN(CutApplicatorFactory, MuonMomQualityCut, "MuonMomQualityCut");
0017 
0018 // Define constructors and initialization routines
0019 MuonMomQualityCut::MuonMomQualityCut(const edm::ParameterSet& c)
0020     : CutApplicatorBase(c), maxRelPtErr_(c.getParameter<double>("maxRelPtErr")) {}
0021 
0022 // Functors for evaluation
0023 CutApplicatorBase::result_type MuonMomQualityCut::operator()(const reco::MuonPtr& cand) const {
0024   const auto trackRef = cand->muonBestTrack();
0025   return trackRef.isNonnull() and trackRef->ptError() <= maxRelPtErr_ * trackRef->pt();
0026 
0027   return true;
0028 }
0029 
0030 double MuonMomQualityCut::value(const reco::CandidatePtr& cand) const {
0031   const reco::MuonPtr muon(cand);
0032   const auto trackRef = muon->muonBestTrack();
0033   if (trackRef.isNull() or trackRef->pt() <= 0)
0034     return -1;
0035 
0036   return trackRef->ptError() / trackRef->pt();
0037 }