CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/GeneratorInterface/GenFilters/src/RecoDiMuon.cc

Go to the documentation of this file.
00001 
00013 //-ap #include "Configuration/CSA06Skimming/interface/RecoDiMuon.h"
00014 #include "GeneratorInterface/GenFilters/interface/RecoDiMuon.h"
00015 
00016 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00017 #include "DataFormats/TrackReco/interface/Track.h"
00018 
00019 #include <iostream>
00020 
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 
00023 using namespace edm;
00024 using namespace std;
00025 
00026 
00027 RecoDiMuon::RecoDiMuon(const edm::ParameterSet& iConfig) :
00028   nEvents_(0), nAccepted_(0)
00029 {
00030   muonLabel_ = iConfig.getParameter<InputTag>("MuonLabel");
00031   singleMuonPtMin_ = iConfig.getUntrackedParameter<double>("SingleMuonPtMin",20.);
00032   diMuonPtMin_ = iConfig.getUntrackedParameter<double>("DiMuonPtMin",5.);
00033 }
00034 
00035 
00036 RecoDiMuon::~RecoDiMuon()
00037 {
00038 }
00039 
00040 void RecoDiMuon::endJob() 
00041 {
00042   edm::LogVerbatim("RecoDiMuon") 
00043             << "Events read " << nEvents_ 
00044             << " Events accepted " << nAccepted_ 
00045             << "\nEfficiency " << ((double)nAccepted_)/((double)nEvents_) 
00046             << std::endl;
00047 }
00048 
00049 // ------------ method called to skim the data  ------------
00050 bool RecoDiMuon::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00051 {
00052 
00053   nEvents_++;
00054   bool accepted = false;
00055   using namespace edm;
00056 
00057   Handle<reco::TrackCollection> muons;
00058 
00059   iEvent.getByLabel(muonLabel_, muons);
00060   if (!muons.isValid()) {
00061     edm::LogError("RecoDiMuon") << "FAILED to get Muon Track Collection. ";
00062     return false;
00063   }
00064 
00065   if ( muons->empty() ) {
00066     return false;
00067   }
00068 
00069   // at least one muons above a pt threshold singleMuonPtMin 
00070   // or at least 2 muons above a pt threshold diMuonPtMin
00071   int nMuonOver2ndCut = 0;
00072   for(reco::TrackCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++ muon ) {
00073 
00074     if ( muon->pt() > singleMuonPtMin_ ) accepted = true;
00075     if ( muon->pt() > diMuonPtMin_ )  nMuonOver2ndCut++;
00076   }
00077   if ( nMuonOver2ndCut >= 2 ) accepted = true;
00078 
00079   if ( accepted ) nAccepted_++;
00080 
00081   return accepted;
00082 
00083 }