Go to the documentation of this file.00001 #include "DataFormats/PatCandidates/interface/MET.h"
00002 #include "DataFormats/PatCandidates/interface/Muon.h"
00003 #include "PhysicsTools/SelectorUtils/interface/EventSelector.h"
00004
00015 class WSelector : public EventSelector {
00016
00017 public:
00019 WSelector(edm::ParameterSet const& params) :
00020 muonSrc_(params.getParameter<edm::InputTag>("muonSrc")),
00021 metSrc_ (params.getParameter<edm::InputTag>("metSrc"))
00022 {
00023 double muonPtMin = params.getParameter<double>("muonPtMin");
00024 double metMin = params.getParameter<double>("metMin");
00025 push_back("Muon Pt", muonPtMin );
00026 push_back("MET" , metMin );
00027 set("Muon Pt"); set("MET");
00028 wMuon_ = 0; met_ = 0;
00029 if ( params.exists("cutsToIgnore") ){
00030 setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
00031 }
00032 retInternal_ = getBitTemplate();
00033 }
00035 virtual ~WSelector() {}
00037 pat::Muon const& wMuon() const { return *wMuon_;}
00039 pat::MET const& met() const { return *met_; }
00040
00042 virtual bool operator()( edm::EventBase const & event, pat::strbitset & ret){
00043 ret.set(false);
00044
00045 edm::Handle<std::vector<pat::Muon> > muons;
00046
00047 edm::Handle<std::vector<pat::MET> > met;
00048
00049 bool gotMuons = event.getByLabel(muonSrc_, muons);
00050 bool gotMET = event.getByLabel(metSrc_, met );
00051
00052 if( gotMET ){
00053 met_ = &met->at(0);
00054 if( met_->pt() > cut(metIndex_, double()) || ignoreCut(metIndex_) )
00055 passCut(ret, metIndex_);
00056 }
00057
00058 if( gotMuons ){
00059 if( !ignoreCut(muonPtIndex_) ){
00060 if( muons->size() > 0 ){
00061 wMuon_ = &muons->at(0);
00062 if ( wMuon_->pt() > cut(muonPtIndex_, double()) || ignoreCut(muonPtIndex_) )
00063 passCut(ret, muonPtIndex_);
00064 }
00065 }
00066 else{
00067 passCut( ret, muonPtIndex_);
00068 }
00069 }
00070 setIgnored(ret);
00071 return (bool)ret;
00072 }
00073
00074 protected:
00076 edm::InputTag muonSrc_;
00078 edm::InputTag metSrc_;
00080 pat::Muon const* wMuon_;
00082 pat::MET const* met_;
00084 index_type muonPtIndex_;
00086 index_type metIndex_;
00087 };