CMS 3D CMS Logo

HiggsTo2GammaSkim.cc
Go to the documentation of this file.
1 
2 /* \class HiggsTo2GammaSkim
3  *
4  * Consult header file for description
5  *
6  * author: Kati Lassila-Perini Helsinki Institute of Physics
7  *
8  */
9 
10 
11 // system include files
13 
14 // User include files
16 
17 // Message logger
19 
20 // Photons:
22 
23 // C++
24 #include <iostream>
25 #include <vector>
26 
27 using namespace std;
28 using namespace edm;
29 using namespace reco;
30 
31 
32 // Constructor
34 
35  // Local Debug flag
36  debug = pset.getParameter<bool>("DebugHiggsTo2GammaSkim");
37 
38  // Reconstructed objects
39  thePhotonToken = consumes<reco::PhotonCollection>(pset.getParameter<edm::InputTag>("PhotonCollectionLabel"));
40 
41  // Minimum Pt for photons for skimming
42  photon1MinPt = pset.getParameter<double>("photon1MinimumPt");
43  nPhotonMin = pset.getParameter<int>("nPhotonMinimum");
44 
45 
46  nEvents = 0;
47  nSelectedEvents = 0;
48 
49 }
50 
51 
52 // Destructor
54 
55  edm::LogVerbatim("HiggsTo2GammaSkim")
56  << " Number_events_read " << nEvents
57  << " Number_events_kept " << nSelectedEvents
58  << " Efficiency " << ((double)nSelectedEvents)/((double) nEvents + 0.01) << std::endl;
59 }
60 
61 
62 
63 // Filter event
65 
66  nEvents++;
67 
69 
70  bool keepEvent = false;
71  int nPhotons = 0;
72 
73  // Look at photons:
74 
75  // Get the photon collection from the event
77 
78  event.getByToken(thePhotonToken,photonHandle);
79 
80  if ( photonHandle.isValid() ) {
81 
82  const reco::PhotonCollection* phoCollection = photonHandle.product();
83 
84  reco::PhotonCollection::const_iterator photons;
85 
86  // Loop over photon collections and count how many photons there are,
87  // and how many are above the thresholds
88 
89  // Question: do we need to take the reconstructed primary vertex at this point?
90  // Here, I assume that the et is taken with respect to the nominal vertex (0,0,0).
91  for ( photons = phoCollection->begin(); photons != phoCollection->end(); ++photons ) {
92  float et_p = photons->et();
93  if ( et_p > photon1MinPt) nPhotons++;
94  }
95  }
96 
97  // Make decision:
98  if ( nPhotons >= nPhotonMin ) keepEvent = true;
99 
100  if (keepEvent) nSelectedEvents++;
101 
102  return keepEvent;
103 }
104 
105 
T getParameter(std::string const &) const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
~HiggsTo2GammaSkim() override
bool isValid() const
Definition: HandleBase.h:74
#define debug
Definition: HDRShower.cc:19
T const * product() const
Definition: Handle.h:81
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
HiggsTo2GammaSkim(const edm::ParameterSet &)
fixed size matrix
bool filter(edm::Event &, const edm::EventSetup &) override
Get event properties to send to builder to fill seed collection.
HLT enums.
UInt_t nEvents
Definition: hcalCalib.cc:42
Definition: event.py:1