CMS 3D CMS Logo

TeVdiMuonSkim.cc

Go to the documentation of this file.
00001 
00013 #include <iostream>
00014 #include <string>
00015 #include <list>
00016 #include <cmath>
00017 #include <cstdio>
00018 #include <vector>
00019 #include <memory>
00020 
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "DataFormats/Common/interface/Handle.h"    
00023 
00024 #include "SUSYBSMAnalysis/CSA07Skims/interface/TeVdiMuonSkim.h"
00025 #include "DataFormats/MuonReco/interface/Muon.h"
00026 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00027 
00028 using namespace edm;
00029 using namespace std;
00030 using namespace reco;
00031 
00032 TeVdiMuonSkim::TeVdiMuonSkim( const edm::ParameterSet& iConfig ) :
00033   nEvents_(0), nAccepted_(0)
00034 {
00035   Muonsrc_ = iConfig.getParameter<InputTag>( "Muonsrc" );
00036   MuonPtmin_ = iConfig.getParameter<double>( "MuonPtmin");
00037 }
00038 
00039 /*------------------------------------------------------------------------*/
00040 
00041 TeVdiMuonSkim::~TeVdiMuonSkim() 
00042 {}
00043 
00044 /*------------------------------------------------------------------------*/
00045 
00046 bool TeVdiMuonSkim::filter( edm::Event& iEvent, 
00047                                 const edm::EventSetup& iSetup )
00048 {
00049   nEvents_++;
00050 
00051   Handle<MuonCollection> MuonHandle;
00052   iEvent.getByLabel(Muonsrc_, MuonHandle);
00053 
00054   if (MuonHandle->empty()) return false;
00055   
00056   MuonCollection theMuonC = *MuonHandle;
00057   
00058   int nMuons=0;
00059   for ( MuonCollection::const_iterator it=theMuonC.begin(); it!=theMuonC.end(); it++ )
00060     if (it->pt()>MuonPtmin_) nMuons++;
00061   
00062   if (nMuons<2) return false;
00063 
00064   nAccepted_++;
00065 
00066   return true;
00067 }
00068 
00069 /*------------------------------------------------------------------------*/
00070 
00071 void TeVdiMuonSkim::endJob()
00072 {
00073   edm::LogVerbatim("TeVdiMuonSkim") 
00074     << "Events read " << nEvents_
00075     << " Events accepted " << nAccepted_
00076     << "\nEfficiency " << (double)(nAccepted_)/(double)(nEvents_) 
00077     << endl;
00078 }

Generated on Tue Jun 9 17:48:04 2009 for CMSSW by  doxygen 1.5.4