CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EGammaCutBasedEleIdAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EGammaCutBasedEleIdAnalyzer
4 // Class: EGammaCutBasedEleIdAnalyzer
5 //
13 //
14 // Original Author: Dave Evans,510 1-015,+41227679496,
15 // Created: Tue Apr 10 11:17:29 CEST 2012
16 // $Id: EGammaCutBasedEleIdAnalyzer.cc,v 1.1 2012/12/03 20:51:02 tjkim Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
40 
41 #include <TFile.h>
42 #include <TH1F.h>
43 
44 //
45 // class declaration
46 //
47 
49  public:
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 
56  private:
57  virtual void beginJob() ;
58  virtual void analyze(const edm::Event&, const edm::EventSetup&);
59  virtual void endJob() ;
60 
61  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
62  virtual void endRun(edm::Run const&, edm::EventSetup const&);
63  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
64  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
65 
66  // ----------member data ---------------------------
67 
68  // input tags
74  std::vector<edm::InputTag> isoValInputTags_;
75 
76  // debug
78 
79  // histograms
80  TH1F *h1_pt_;
81  TH1F *h1_pt_veto_;
82  TH1F *h1_pt_loose_;
84  TH1F *h1_pt_tight_;
85  TH1F *h1_pt_trig_;
87 
88 };
89 
90 //
91 // constants, enums and typedefs
92 //
93 
94 typedef std::vector< edm::Handle< edm::ValueMap<reco::IsoDeposit> > > IsoDepositMaps;
95 typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsoDepositVals;
96 
97 //
98 // static data member definitions
99 //
100 
101 //
102 // constructors and destructor
103 //
105 {
106 
107  // get input parameters
108  electronsInputTag_ = iConfig.getParameter<edm::InputTag>("electronsInputTag");
109  conversionsInputTag_ = iConfig.getParameter<edm::InputTag>("conversionsInputTag");
110  beamSpotInputTag_ = iConfig.getParameter<edm::InputTag>("beamSpotInputTag");
111  rhoIsoInputTag = iConfig.getParameter<edm::InputTag>("rhoIsoInputTag");
112  primaryVertexInputTag_ = iConfig.getParameter<edm::InputTag>("primaryVertexInputTag");
113  isoValInputTags_ = iConfig.getParameter<std::vector<edm::InputTag> >("isoValInputTags");
114 
115  // debug
116  printDebug_ = iConfig.getParameter<bool>("printDebug");
117 
118  // output histograms
120 
121  h1_pt_ = fs->make<TH1F>("h1_pt", "pt", 100, 0.0, 100.0);
122  h1_pt_veto_ = fs->make<TH1F>("h1_pt_veto", "pt (veto)", 100, 0.0, 100.0);
123  h1_pt_loose_ = fs->make<TH1F>("h1_pt_loose", "pt (loose)", 100, 0.0, 100.0);
124  h1_pt_medium_ = fs->make<TH1F>("h1_pt_medium", "pt (medium)", 100, 0.0, 100.0);
125  h1_pt_tight_ = fs->make<TH1F>("h1_pt_tight", "pt (tight)", 100, 0.0, 100.0);
126  h1_pt_trig_ = fs->make<TH1F>("h1_pt_trig", "pt (trig)", 100, 0.0, 100.0);
127  h1_pt_fbremeopin_ = fs->make<TH1F>("h1_pt_fbremeopin", "pt (fbremeopin)", 100, 0.0, 100.0);
128 
129 }
130 
131 
133 {
134 
135  // do anything here that needs to be done at desctruction time
136  // (e.g. close files, deallocate resources etc.)
137 
138 }
139 
140 
141 //
142 // member functions
143 //
144 
145 // ------------ method called for each event ------------
146  void
148 {
149  // electrons
151  iEvent.getByLabel(electronsInputTag_, els_h);
152 
153  // conversions
155  iEvent.getByLabel(conversionsInputTag_, conversions_h);
156 
157  // iso deposits
158  IsoDepositVals isoVals(isoValInputTags_.size());
159  for (size_t j = 0; j < isoValInputTags_.size(); ++j) {
160  iEvent.getByLabel(isoValInputTags_[j], isoVals[j]);
161  }
162 
163  // beam spot
164  edm::Handle<reco::BeamSpot> beamspot_h;
165  iEvent.getByLabel(beamSpotInputTag_, beamspot_h);
166  const reco::BeamSpot &beamSpot = *(beamspot_h.product());
167 
168  // vertices
170  iEvent.getByLabel(primaryVertexInputTag_, vtx_h);
171 
172  // rho for isolation
173  edm::Handle<double> rhoIso_h;
174  iEvent.getByLabel(rhoIsoInputTag, rhoIso_h);
175  double rhoIso = *(rhoIso_h.product());
176 
177  // loop on electrons
178  unsigned int n = els_h->size();
179  for(unsigned int i = 0; i < n; ++i) {
180 
181  // get reference to electron
182  reco::GsfElectronRef ele(els_h, i);
183 
184  //
185  // get particle flow isolation
186  //
187 
188  double iso_ch = (*(isoVals)[0])[ele];
189  double iso_em = (*(isoVals)[1])[ele];
190  double iso_nh = (*(isoVals)[2])[ele];
191 
192  //
193  // test ID
194  //
195 
196  // working points
197  bool veto = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::VETO, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
198  bool loose = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::LOOSE, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
199  bool medium = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::MEDIUM, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
200  bool tight = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::TIGHT, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
201 
202  // eop/fbrem cuts for extra tight ID
203  bool fbremeopin = EgammaCutBasedEleId::PassEoverPCuts(ele);
204 
205  // cuts to match tight trigger requirements
207 
208  // for 2011 WP70 trigger
210 
211  //
212  // fill histograms
213  //
214 
215  h1_pt_->Fill(ele->pt());
216  if (veto) h1_pt_veto_ ->Fill(ele->pt());
217  if (loose) h1_pt_loose_ ->Fill(ele->pt());
218  if (medium) h1_pt_medium_ ->Fill(ele->pt());
219  if (tight) h1_pt_tight_ ->Fill(ele->pt());
220  if (trigtight) h1_pt_trig_ ->Fill(ele->pt());
221  if (fbremeopin) h1_pt_fbremeopin_ ->Fill(ele->pt());
222 
223  //
224  // print decisions
225  //
226 
227  if (printDebug_) {
228  printf("%u %u %u : ", iEvent.id().run(), iEvent.luminosityBlock(), iEvent.id().event());
229  printf("veto(%i), ", veto);
230  printf("loose(%i), ", loose);
231  printf("medium(%i), ", medium);
232  printf("tight(%i), ", tight);
233  printf("trigtight(%i), ", trigtight);
234  printf("trigwp70(%i), ", trigwp70);
235  printf("fbremeopin(%i)\n", fbremeopin);
236  }
237 
238  }
239 
240 }
241 
242 
243 // ------------ method called once each job just before starting event loop ------------
244  void
246 {
247 }
248 
249 // ------------ method called once each job just after ending the event loop ------------
250  void
252 {
253 }
254 
255 // ------------ method called when starting to processes a run ------------
256  void
258 {
259 }
260 
261 // ------------ method called when ending the processing of a run ------------
262  void
264 {
265 }
266 
267 // ------------ method called when starting to processes a luminosity block ------------
268  void
270 {
271 }
272 
273 // ------------ method called when ending the processing of a luminosity block ------------
274  void
276 {
277 }
278 
279 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
280 void
282  //The following says we do not know what parameters are allowed so do no validation
283  // Please change this to state exactly what you do use, even if it is no parameters
285  desc.setUnknown();
286  descriptions.addDefault(desc);
287 }
288 
289 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
std::vector< edm::Handle< edm::ValueMap< reco::IsoDeposit > > > IsoDepositMaps
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< edm::InputTag > isoValInputTags_
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
EGammaCutBasedEleIdAnalyzer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< edm::Handle< edm::ValueMap< double > > > IsoDepositVals
bool PassWP(const WorkingPoint workingPoint, const reco::GsfElectronRef &ele, const edm::Handle< reco::ConversionCollection > &conversions, const reco::BeamSpot &beamspot, const edm::Handle< reco::VertexCollection > &vtxs, const double &iso_ch, const double &iso_em, const double &iso_nh, const double &rho)
bool PassTriggerCuts(const TriggerWorkingPoint triggerWorkingPoint, const reco::GsfElectronRef &ele)
bool PassEoverPCuts(const reco::GsfElectronRef &ele)
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: Handle.h:74
edm::EventID id() const
Definition: EventBase.h:56
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: Run.h:33
virtual void beginRun(edm::Run const &, edm::EventSetup const &)