CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/HiggsAnalysis/Skimming/src/HiggsToZZ4LeptonsSkim.cc

Go to the documentation of this file.
00001 
00002 /* \class HiggsTo4LeptonsSkim 
00003  *
00004  * Consult header file for description
00005  *
00006  * author:  Dominique Fortin - UC Riverside
00007  *
00008  */
00009 
00010 
00011 // system include files
00012 #include <HiggsAnalysis/Skimming/interface/HiggsToZZ4LeptonsSkim.h>
00013 
00014 // User include files
00015 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00016 
00017 // Muons:
00018 #include <DataFormats/TrackReco/interface/Track.h>
00019 
00020 // Electrons
00021 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00022 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00023 
00024 // C++
00025 #include <iostream>
00026 #include <vector>
00027 
00028 using namespace std;
00029 using namespace edm;
00030 using namespace reco;
00031 
00032 
00033 // Constructor
00034 HiggsToZZ4LeptonsSkim::HiggsToZZ4LeptonsSkim(const edm::ParameterSet& pset) {
00035 
00036   // Local Debug flag
00037   debug              = pset.getParameter<bool>("DebugHiggsToZZ4LeptonsSkim");
00038 
00039   // Reconstructed objects
00040   recTrackLabel      = pset.getParameter<edm::InputTag>("RecoTrackLabel");
00041   theGLBMuonLabel    = pset.getParameter<edm::InputTag>("GlobalMuonCollectionLabel");
00042   theGsfELabel       = pset.getParameter<edm::InputTag>("ElectronCollectionLabel");
00043 
00044   // Minimum Pt for leptons for skimming
00045   stiffMinPt         = pset.getParameter<double>("stiffMinimumPt");
00046   softMinPt          = pset.getParameter<double>("softMinimumPt");
00047   nStiffLeptonMin    = pset.getParameter<int>("nStiffLeptonMinimum");
00048   nLeptonMin         = pset.getParameter<int>("nLeptonMinimum");
00049 
00050   nEvents         = 0;
00051   nSelectedEvents = 0;
00052 
00053 }
00054 
00055 
00056 // Destructor
00057 HiggsToZZ4LeptonsSkim::~HiggsToZZ4LeptonsSkim() {
00058 
00059   edm::LogVerbatim("HiggsToZZ4LeptonsSkim") 
00060   << " Number_events_read " << nEvents          
00061   << " Number_events_kept " << nSelectedEvents 
00062   << " Efficiency         " << ((double)nSelectedEvents)/((double) nEvents + 0.01) << std::endl;
00063 }
00064 
00065 
00066 
00067 // Filter event
00068 bool HiggsToZZ4LeptonsSkim::filter(edm::Event& event, const edm::EventSetup& setup ) {
00069 
00070   nEvents++;
00071 
00072   using reco::TrackCollection;
00073 
00074   bool keepEvent   = false;
00075   int  nStiffLeptons    = 0;
00076   int  nLeptons    = 0;
00077   
00078 
00079   // First look at muons:
00080 
00081   // Get the muon track collection from the event
00082   edm::Handle<reco::TrackCollection> muTracks;
00083   event.getByLabel(theGLBMuonLabel.label(), muTracks);
00084 
00085   if ( muTracks.isValid() ) {  
00086   
00087     reco::TrackCollection::const_iterator muons;
00088         
00089     // Loop over muon collections and count how many muons there are, 
00090     // and how many are above threshold
00091     for ( muons = muTracks->begin(); muons != muTracks->end(); ++muons ) {
00092       if ( muons->pt() > stiffMinPt) nStiffLeptons++; 
00093       if ( muons->pt() > softMinPt) nLeptons++; 
00094     }  
00095   } 
00096   
00097   // Now look at electrons:
00098 
00099   // Get the electron track collection from the event
00100   edm::Handle<reco::GsfElectronCollection> pTracks;
00101 
00102   event.getByLabel(theGsfELabel.label(),pTracks);
00103 
00104   if ( pTracks.isValid() ) {  
00105 
00106     const reco::GsfElectronCollection* eTracks = pTracks.product();
00107 
00108     reco::GsfElectronCollection::const_iterator electrons;
00109 
00110     // Loop over electron collections and count how many muons there are, 
00111     // and how many are above threshold
00112     for ( electrons = eTracks->begin(); electrons != eTracks->end(); ++electrons ) {
00113       float pt_e = electrons->pt(); 
00114       if ( pt_e > stiffMinPt) nStiffLeptons++; 
00115       if ( pt_e > softMinPt) nLeptons++; 
00116     }
00117   }
00118 
00119   // Make decision:
00120   if ( nStiffLeptons >= nStiffLeptonMin && nLeptons >= nLeptonMin) keepEvent = true;
00121 
00122   if (keepEvent) nSelectedEvents++;
00123 
00124   return keepEvent;
00125 }
00126 
00127