CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MonoPhotonSkimmer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MonoPhotonSkimmer
4 // Class: MonoPhotonSkimmer
5 //
13 //
14 // Original Author: Jie Chen
15 // Created: Wed Nov 17 14:33:08 CST 2010
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
36 #include <string>
37 
38 //
39 // class declaration
40 //
41 
43  public:
44  explicit MonoPhotonSkimmer(const edm::ParameterSet&);
46 
47  private:
48  virtual void beginJob() override ;
49  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
50  virtual void endJob() override ;
51 
52  // ----------member data ---------------------------
54  bool _selectEE; //Do you want to select EE photons?
55  //True enables this.
56 
57  double _ecalisoOffsetEB; //Photon Preselection has linearized cuts.
58  double _ecalisoSlopeEB; //slope * photonpt + offset is the isolation
59  //threshold. This is ECAL EB.
60 
61  double _hcalisoOffsetEB; //Linearized cut on HCAL towers, EB.
63 
64  double _hadoveremEB; //Flat selection cut on HadOverEM.
65 
66  double _minPhoEtEB; //Minimum Photon ET threshold, EB.
67 
68  double _trackisoOffsetEB;//Linearized cut on track isolation EB
70 
71  double _etawidthEB; //eta width for EB
72 
73  double _ecalisoOffsetEE; //As above, but separately set for EE.
77  double _hadoveremEE;
78  double _minPhoEtEE;
81  double _etawidthEE;
82 };
83 
84 //
85 // constants, enums and typedefs
86 //
87 
88 //
89 // static data member definitions
90 //
91 
92 //
93 // constructors and destructor
94 //
96 {
97  //now do what ever initialization is needed
98  _phoToken = consumes<reco::PhotonCollection>(iConfig.getParameter<edm::InputTag>("phoTag"));
99  _selectEE = iConfig.getParameter<bool>("selectEE");
100 
101  _ecalisoOffsetEB = iConfig.getParameter<double>("ecalisoOffsetEB");
102  _ecalisoSlopeEB = iConfig.getParameter<double>("ecalisoSlopeEB");
103 
104  _hcalisoOffsetEB = iConfig.getParameter<double>("hcalisoOffsetEB");
105  _hcalisoSlopeEB = iConfig.getParameter<double>("hcalisoSlopeEB");
106 
107  _hadoveremEB = iConfig.getParameter<double>("hadoveremEB");
108  _minPhoEtEB = iConfig.getParameter<double>("minPhoEtEB");
109 
110 
111  _trackisoOffsetEB= iConfig.getParameter<double>("trackIsoOffsetEB");
112  _trackisoSlopeEB= iConfig.getParameter<double>("trackIsoSlopeEB");
113  _etawidthEB=iConfig.getParameter<double>("etaWidthEB");
114 
115  _ecalisoOffsetEE = iConfig.getParameter<double>("ecalisoOffsetEE");
116  _ecalisoSlopeEE = iConfig.getParameter<double>("ecalisoSlopeEE");
117 
118  _hcalisoOffsetEE = iConfig.getParameter<double>("hcalisoOffsetEE");
119  _hcalisoSlopeEE = iConfig.getParameter<double>("hcalisoSlopeEE");
120 
121  _hadoveremEE = iConfig.getParameter<double>("hadoveremEE");
122  _minPhoEtEE = iConfig.getParameter<double>("minPhoEtEE");
123 
124 
125  _trackisoOffsetEE= iConfig.getParameter<double>("trackIsoOffsetEE");
126  _trackisoSlopeEE= iConfig.getParameter<double>("trackIsoSlopeEE");
127 
128  _etawidthEE= iConfig.getParameter<double>("etaWidthEE");
129 
130 }
131 
132 
134 {
135 
136  // do anything here that needs to be done at desctruction time
137  // (e.g. close files, deallocate resources etc.)
138 
139 }
140 
141 
142 //
143 // member functions
144 //
145 
146 // ------------ method called on each new Event ------------
147 bool
149 {
150  using namespace edm;
152  iEvent.getByToken(_phoToken, photonColl);
153  const reco::PhotonCollection *photons = photonColl.product();
154  //Iterate over photon collection.
155 // std::vector<reco::Photon> PreselPhotons;
156  int PreselPhotons=0;
157  reco::PhotonCollection::const_iterator pho;
158  for (pho = (*photons).begin(); pho!= (*photons).end(); pho++){
159  if (!pho->isEB() && !_selectEE) continue;
160 
161  double ecalisocut = 0;
162  double hcalisocut = 0;
163  double hadoverem = 0;
164  double minphoet = 0;
165  double trackiso = 0;
166  double etawidth = 0;
167  if (pho->isEB()){
168  ecalisocut = _ecalisoOffsetEB + _ecalisoSlopeEB * pho->pt();
169  hcalisocut = _hcalisoOffsetEB + _hcalisoSlopeEB * pho->pt();
170  hadoverem = _hadoveremEB;
171  minphoet = _minPhoEtEB;
172  trackiso = _trackisoOffsetEB + _trackisoSlopeEB * pho->pt();
173  etawidth = _etawidthEB;
174  }
175  else{
176  ecalisocut = _ecalisoOffsetEE + _ecalisoSlopeEE * pho->pt();
177  hcalisocut = _hcalisoOffsetEE + _hcalisoSlopeEE * pho->pt();
178  hadoverem = _hadoveremEE;
179  minphoet = _minPhoEtEE;
180  trackiso = _trackisoOffsetEE + _trackisoSlopeEE * pho->pt();
181  etawidth = _etawidthEE;
182  }
183 
184  if (pho->ecalRecHitSumEtConeDR04() < ecalisocut
185  && pho->hcalTowerSumEtConeDR04() < hcalisocut
186  && pho->hadronicOverEm() < hadoverem
187  && pho->pt() > minphoet
188  && pho->trkSumPtHollowConeDR04()<trackiso
189  && pho->sigmaIetaIeta() <etawidth
190  ) PreselPhotons++;
191 
192  }//Loop over Photons
193  if (PreselPhotons > 0 ) return true;
194  return false;
195 }
196 
197 // ------------ method called once each job just before starting event loop ------------
198 void
200 {
201 }
202 
203 // ------------ method called once each job just after ending the event loop ------------
204 void
206 }
207 
208 //define this as a plug-in
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endJob() override
MonoPhotonSkimmer(const edm::ParameterSet &)
edm::EDGetTokenT< reco::PhotonCollection > _phoToken
int iEvent
Definition: GenABIO.cc:230
virtual void beginJob() override
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
virtual bool filter(edm::Event &, const edm::EventSetup &) override