CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/PhysicsTools/FWLite/interface/WSelector.h

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     // Handle to the muon collection
00045     edm::Handle<std::vector<pat::Muon> > muons;    
00046     // Handle to the MET collection
00047     edm::Handle<std::vector<pat::MET> > met;
00048     // get the objects from the event
00049     bool gotMuons = event.getByLabel(muonSrc_, muons);
00050     bool gotMET   = event.getByLabel(metSrc_, met   );
00051     // get the MET, require to be > minimum
00052     if( gotMET ){
00053       met_ = &met->at(0);
00054       if( met_->pt() > cut("MET", double()) || ignoreCut("MET") ) 
00055         passCut(ret, "MET");
00056     }
00057     // get the highest pt muon, require to have pt > minimum
00058     if( gotMuons ){
00059       if( !ignoreCut("Muon Pt") ){
00060         if( muons->size() > 0 ){
00061           wMuon_ = &muons->at(0);
00062           if( wMuon_->pt() > cut("Muon Pt", double()) || ignoreCut("Muon Pt") ) 
00063             passCut(ret, "Muon Pt");
00064         }
00065       } 
00066       else{
00067         passCut( ret, "Muon Pt");
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_;
00083 };