00001 /* \class HadSUSYSMBackgrSkim 00002 * 00003 * all hadronic SUSY Skim 00004 * >= 2 jets, 1st jet 110 GeV + MET 100 GeV 00005 * Total SM background (JetMet trigger path) 00006 * 00007 * $Date: 2007/09/25 17:54:51 $ 00008 * $Revision: 1.4 $ 00009 * 00010 * \author Michael Tytgat, Maria Spiropulu - CERN 00011 * 00012 */ 00013 00014 #include <iostream> 00015 #include <string> 00016 #include <list> 00017 #include <cmath> 00018 #include <cstdio> 00019 #include <vector> 00020 #include <memory> 00021 00022 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00023 #include "DataFormats/Common/interface/Handle.h" 00024 #include "DataFormats/METReco/interface/CaloMET.h" 00025 00026 #include "DataFormats/JetReco/interface/CaloJet.h" 00027 #include "DataFormats/METReco/interface/CaloMETCollection.h" 00028 00029 #include "SUSYBSMAnalysis/CSA07Skims/interface/HadSUSYSMBackgrSkim.h" 00030 00031 using namespace edm; 00032 using namespace std; 00033 using namespace reco; 00034 00035 class PtSorter { 00036 public: 00037 template <class T> bool operator() ( const T& a, const T& b ) { 00038 return ( a.pt() > b.pt() ); 00039 } 00040 }; 00041 00042 HadSUSYSMBackgrSkim::HadSUSYSMBackgrSkim( const edm::ParameterSet& iConfig ) : 00043 nEvents_(0), nAccepted_(0) 00044 { 00045 CaloJetsrc_ = iConfig.getParameter<InputTag>( "CaloJetsrc" ); 00046 NminCaloJet_ = iConfig.getParameter<int>( "NminCaloJet"); 00047 CaloJetPtmin_ = 00048 iConfig.getParameter<double>( "CaloJetPtmin"); 00049 CaloJet1Ptmin_ = 00050 iConfig.getParameter<double>( "CaloJet1Ptmin"); 00051 CaloMETsrc_ = iConfig.getParameter<InputTag>( "CaloMETsrc" ); 00052 CaloMETmin_ = iConfig.getParameter<double>( "CaloMETmin"); 00053 } 00054 00055 /*------------------------------------------------------------------------*/ 00056 00057 HadSUSYSMBackgrSkim::~HadSUSYSMBackgrSkim() 00058 {} 00059 00060 /*------------------------------------------------------------------------*/ 00061 00062 bool HadSUSYSMBackgrSkim::filter( edm::Event& iEvent, 00063 const edm::EventSetup& iSetup ) 00064 { 00065 nEvents_++; 00066 00067 Handle<CaloJetCollection> CaloJetsHandle; 00068 00069 // try { 00070 iEvent.getByLabel( CaloJetsrc_, CaloJetsHandle ); 00071 // } 00072 // catch ( cms::Exception& ex ) { 00073 // edm::LogError( "HadSUSYSMBackgrSkim" ) 00074 // << "Unable to get CaloJet collection " 00075 // << CaloJetsrc_.label(); 00076 // return false; 00077 // } 00078 00079 if ( CaloJetsHandle->empty() ) return false; 00080 00081 Handle<CaloMETCollection> CaloMETHandle; 00082 00083 // try { 00084 iEvent.getByLabel( CaloMETsrc_, CaloMETHandle ); 00085 // } 00086 // catch ( cms::Exception& ex ) { 00087 // edm::LogError( "HadSUSYSMBackgrSkim" ) 00088 // << "Unable to get CaloMET collection " 00089 // << CaloMETsrc_.label(); 00090 // return false; 00091 // } 00092 00093 // MET cut 00094 if ( (CaloMETHandle->begin())->et() < CaloMETmin_ ) return false; 00095 00096 // jet cuts 00097 reco::CaloJetCollection TheJets = *CaloJetsHandle; 00098 std::stable_sort( TheJets.begin(), TheJets.end(), PtSorter() ); 00099 00100 if ( (TheJets.begin())->pt() < CaloJet1Ptmin_ ) return false; // 1st jet 00101 00102 int nJet = 0; 00103 for ( CaloJetCollection::const_iterator it = TheJets.begin(); 00104 it != TheJets.end(); it++ ) { 00105 if ( it->pt() > CaloJetPtmin_ ) nJet++; 00106 } 00107 if ( nJet < NminCaloJet_ ) return false; 00108 00109 nAccepted_++; 00110 00111 return true; 00112 } 00113 00114 /*------------------------------------------------------------------------*/ 00115 00116 void HadSUSYSMBackgrSkim::endJob() 00117 { 00118 edm::LogVerbatim( "HadSUSYSMBackgrSkim" ) 00119 << "Events read " << nEvents_ 00120 << " Events accepted " << nAccepted_ 00121 << "\nEfficiency " << (double)(nAccepted_)/(double)(nEvents_) 00122 << endl; 00123 }