CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/HiggsAnalysis/Skimming/src/HiggsTo2GammaSkim.cc

Go to the documentation of this file.
00001 
00002 /* \class HiggsTo2GammaSkim 
00003  *
00004  * Consult header file for description
00005  *
00006  * author:  Kati Lassila-Perini Helsinki Institute of Physics
00007  *
00008  */
00009 
00010 
00011 // system include files
00012 #include <HiggsAnalysis/Skimming/interface/HiggsTo2GammaSkim.h>
00013 
00014 // User include files
00015 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00016 
00017 // Message logger
00018 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00019 
00020 // Photons:
00021 #include <DataFormats/EgammaCandidates/interface/Photon.h>
00022 #include <DataFormats/EgammaCandidates/interface/PhotonFwd.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 HiggsTo2GammaSkim::HiggsTo2GammaSkim(const edm::ParameterSet& pset) {
00035 
00036   // Local Debug flag
00037   debug              = pset.getParameter<bool>("DebugHiggsTo2GammaSkim");
00038 
00039   // Reconstructed objects
00040   thePhotonLabel     = pset.getParameter<edm::InputTag>("PhotonCollectionLabel");
00041 
00042   // Minimum Pt for photons for skimming
00043   photon1MinPt       = pset.getParameter<double>("photon1MinimumPt");
00044   nPhotonMin         = pset.getParameter<int>("nPhotonMinimum");
00045 
00046 
00047   nEvents         = 0;
00048   nSelectedEvents = 0;
00049 
00050 }
00051 
00052 
00053 // Destructor
00054 HiggsTo2GammaSkim::~HiggsTo2GammaSkim() {
00055 
00056   edm::LogVerbatim("HiggsTo2GammaSkim") 
00057   << " Number_events_read " << nEvents          
00058   << " Number_events_kept " << nSelectedEvents 
00059   << " Efficiency         " << ((double)nSelectedEvents)/((double) nEvents + 0.01) << std::endl;
00060 }
00061 
00062 
00063 
00064 // Filter event
00065 bool HiggsTo2GammaSkim::filter(edm::Event& event, const edm::EventSetup& setup ) {
00066 
00067   nEvents++;
00068 
00069   using reco::PhotonCollection;
00070 
00071   bool keepEvent    = false;
00072   int  nPhotons     = 0;
00073 
00074   // Look at photons:
00075 
00076   // Get the photon collection from the event
00077   edm::Handle<reco::PhotonCollection> photonHandle;
00078 
00079   event.getByLabel(thePhotonLabel.label(),photonHandle);
00080 
00081   if ( photonHandle.isValid() ) {
00082   
00083   const reco::PhotonCollection* phoCollection = photonHandle.product();
00084 
00085     reco::PhotonCollection::const_iterator photons;
00086 
00087     // Loop over photon collections and count how many photons there are, 
00088     // and how many are above the thresholds
00089 
00090     // Question: do we need to take the reconstructed primary vertex at this point?
00091     // Here, I assume that the et is taken with respect to the nominal vertex (0,0,0).
00092     for ( photons = phoCollection->begin(); photons != phoCollection->end(); ++photons ) {
00093       float et_p = photons->et(); 
00094       if ( et_p > photon1MinPt) nPhotons++;
00095     }
00096   }
00097   
00098   // Make decision:
00099   if ( nPhotons >= nPhotonMin ) keepEvent = true;
00100 
00101   if (keepEvent) nSelectedEvents++;
00102 
00103   return keepEvent;
00104 }
00105 
00106