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 MuonTypeByOrCut : public CutApplicatorBase {
0006 public:
0007   MuonTypeByOrCut(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   unsigned int type_;
0015 };
0016 DEFINE_EDM_PLUGIN(CutApplicatorFactory, MuonTypeByOrCut, "MuonTypeByOrCut");
0017 
0018 // Define constructors and initialization routines
0019 MuonTypeByOrCut::MuonTypeByOrCut(const edm::ParameterSet& c) : CutApplicatorBase(c), type_(0) {
0020   const auto muonTypes = c.getParameter<std::vector<std::string> >("types");
0021   for (auto x : muonTypes) {
0022     std::transform(x.begin(), x.end(), x.begin(), ::tolower);
0023     if (x == "globalmuon")
0024       type_ |= reco::Muon::GlobalMuon;
0025     else if (x == "trackermuon")
0026       type_ |= reco::Muon::TrackerMuon;
0027     else if (x == "standalonemuon")
0028       type_ |= reco::Muon::StandAloneMuon;
0029     else if (x == "calomuon")
0030       type_ |= reco::Muon::CaloMuon;
0031     else if (x == "pfmuon")
0032       type_ |= reco::Muon::PFMuon;
0033     else if (x == "rpcmuon")
0034       type_ |= reco::Muon::RPCMuon;
0035   }
0036 }
0037 
0038 // Functors for evaluation
0039 CutApplicatorBase::result_type MuonTypeByOrCut::operator()(const reco::MuonPtr& muon) const {
0040   return (muon->type() & type_) != 0;
0041 }
0042 
0043 double MuonTypeByOrCut::value(const reco::CandidatePtr& cand) const {
0044   const reco::MuonPtr muon(cand);
0045   return muon->type() & type_;
0046 }