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
41 
42 #include <TFile.h>
43 #include <TH1F.h>
44 
45 //
46 // class declaration
47 //
48 
50  public:
53 
54  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
55 
57 
58  private:
59  virtual void beginJob() ;
60  virtual void analyze(const edm::Event&, const edm::EventSetup&);
61  virtual void endJob() ;
62 
63  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
64  virtual void endRun(edm::Run const&, edm::EventSetup const&);
65  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
66  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
67 
68  // ----------member data ---------------------------
69 
70  // input tags
76  std::vector<edm::InputTag> isoValInputTags_;
77 
78  std::string EAtargetToken_;
79  // debug
81 
82  // histograms
83  TH1F *h1_pt_;
84  TH1F *h1_pt_veto_;
85  TH1F *h1_pt_loose_;
87  TH1F *h1_pt_tight_;
88  TH1F *h1_pt_trig_;
90 
91 };
92 
93 //
94 // constants, enums and typedefs
95 //
96 
97 typedef std::vector< edm::Handle< edm::ValueMap<reco::IsoDeposit> > > IsoDepositMaps;
98 typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsoDepositVals;
99 
100 //
101 // static data member definitions
102 //
103 
104 //
105 // constructors and destructor
106 //
108 {
109 
110  // get input parameters
111  electronsInputTag_ = iConfig.getParameter<edm::InputTag>("electronsInputTag");
112  conversionsInputTag_ = iConfig.getParameter<edm::InputTag>("conversionsInputTag");
113  beamSpotInputTag_ = iConfig.getParameter<edm::InputTag>("beamSpotInputTag");
114  rhoIsoInputTag = iConfig.getParameter<edm::InputTag>("rhoIsoInputTag");
115  primaryVertexInputTag_ = iConfig.getParameter<edm::InputTag>("primaryVertexInputTag");
116  isoValInputTags_ = iConfig.getParameter<std::vector<edm::InputTag> >("isoValInputTags");
117 
118  EAtargetToken_ = iConfig.getParameter<std::string>("EAtarget");//EleEANoCorr, EleEAData2011, EleEASummer11MC,EleEAFall11MC, EleEAData2012/
119  // debug
120  printDebug_ = iConfig.getParameter<bool>("printDebug");
121 
122  // output histograms
124 
125  h1_pt_ = fs->make<TH1F>("h1_pt", "pt", 100, 0.0, 100.0);
126  h1_pt_veto_ = fs->make<TH1F>("h1_pt_veto", "pt (veto)", 100, 0.0, 100.0);
127  h1_pt_loose_ = fs->make<TH1F>("h1_pt_loose", "pt (loose)", 100, 0.0, 100.0);
128  h1_pt_medium_ = fs->make<TH1F>("h1_pt_medium", "pt (medium)", 100, 0.0, 100.0);
129  h1_pt_tight_ = fs->make<TH1F>("h1_pt_tight", "pt (tight)", 100, 0.0, 100.0);
130  h1_pt_trig_ = fs->make<TH1F>("h1_pt_trig", "pt (trig)", 100, 0.0, 100.0);
131  h1_pt_fbremeopin_ = fs->make<TH1F>("h1_pt_fbremeopin", "pt (fbremeopin)", 100, 0.0, 100.0);
132 
133 }
134 
135 
137 {
138 
139  // do anything here that needs to be done at desctruction time
140  // (e.g. close files, deallocate resources etc.)
141 
142 }
143 
144 
145 //
146 // member functions
147 //
148 
149 // ------------ method called for each event ------------
150  void
152 {
153  // electrons
155  iEvent.getByLabel(electronsInputTag_, els_h);
156 
157  // conversions
159  iEvent.getByLabel(conversionsInputTag_, conversions_h);
160 
161  // iso deposits
162  IsoDepositVals isoVals(isoValInputTags_.size());
163  for (size_t j = 0; j < isoValInputTags_.size(); ++j) {
164  iEvent.getByLabel(isoValInputTags_[j], isoVals[j]);
165  }
166 
167  // beam spot
168  edm::Handle<reco::BeamSpot> beamspot_h;
169  iEvent.getByLabel(beamSpotInputTag_, beamspot_h);
170  const reco::BeamSpot &beamSpot = *(beamspot_h.product());
171 
172  // vertices
174  iEvent.getByLabel(primaryVertexInputTag_, vtx_h);
175 
176  // rho for isolation
177  edm::Handle<double> rhoIso_h;
178  iEvent.getByLabel(rhoIsoInputTag, rhoIso_h);
179  double rhoIso = *(rhoIso_h.product());
180 
181  // loop on electrons
182  unsigned int n = els_h->size();
183  for(unsigned int i = 0; i < n; ++i) {
184 
185  // get reference to electron
186  reco::GsfElectronRef ele(els_h, i);
187 
188  //
189  // get particle flow isolation
190  //
191 
192  double iso_ch = (*(isoVals)[0])[ele];
193  double iso_em = (*(isoVals)[1])[ele];
194  double iso_nh = (*(isoVals)[2])[ele];
195 
196  //
197  // test ID
198  //
199 
200  // working points
201  bool veto = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::VETO, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
202  bool loose = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::LOOSE, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
203  bool medium = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::MEDIUM, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
204  bool tight = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::TIGHT, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
205 
206  // eop/fbrem cuts for extra tight ID
207  bool fbremeopin = EgammaCutBasedEleId::PassEoverPCuts(ele);
208 
209  // cuts to match tight trigger requirements
211 
212  // for 2011 WP70 trigger
214 
215  //
216  // fill histograms
217  //
218 
219  h1_pt_->Fill(ele->pt());
220  if (veto) h1_pt_veto_ ->Fill(ele->pt());
221  if (loose) h1_pt_loose_ ->Fill(ele->pt());
222  if (medium) h1_pt_medium_ ->Fill(ele->pt());
223  if (tight) h1_pt_tight_ ->Fill(ele->pt());
224  if (trigtight) h1_pt_trig_ ->Fill(ele->pt());
225  if (fbremeopin) h1_pt_fbremeopin_ ->Fill(ele->pt());
226 
227  //
228  // print decisions
229  //
230 
231  if (printDebug_) {
232  printf("%u %u %u : ", iEvent.id().run(), iEvent.luminosityBlock(), iEvent.id().event());
233  printf("veto(%i), ", veto);
234  printf("loose(%i), ", loose);
235  printf("medium(%i), ", medium);
236  printf("tight(%i), ", tight);
237  printf("trigtight(%i), ", trigtight);
238  printf("trigwp70(%i), ", trigwp70);
239  printf("fbremeopin(%i)\n", fbremeopin);
240  }
241 
242  }
243 
244 }
245 
246 
247 // ------------ method called once each job just before starting event loop ------------
248  void
250 {
251  if( EAtargetToken_ == "EleEANoCorr")
253  else if( EAtargetToken_ == "EleEAData2011")
255  else if( EAtargetToken_ == "EleEASummer11MC")
257  else if( EAtargetToken_ == "EleEAFall11MC")
259  else if( EAtargetToken_ == "EleEAData2012")
261  else
263 }
264 
265 // ------------ method called once each job just after ending the event loop ------------
266  void
268 {
269 }
270 
271 // ------------ method called when starting to processes a run ------------
272  void
274 {
275 }
276 
277 // ------------ method called when ending the processing of a run ------------
278  void
280 {
281 }
282 
283 // ------------ method called when starting to processes a luminosity block ------------
284  void
286 {
287 }
288 
289 // ------------ method called when ending the processing of a luminosity block ------------
290  void
292 {
293 }
294 
295 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
296 void
298  //The following says we do not know what parameters are allowed so do no validation
299  // Please change this to state exactly what you do use, even if it is no parameters
301  desc.setUnknown();
302  descriptions.addDefault(desc);
303 }
304 
305 //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
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, ElectronEffectiveArea::ElectronEffectiveAreaTarget EAtarget)
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 PassTriggerCuts(const TriggerWorkingPoint triggerWorkingPoint, const reco::GsfElectronRef &ele)
bool PassEoverPCuts(const reco::GsfElectronRef &ele)
int j
Definition: DBlmapReader.cc:9
ElectronEffectiveArea::ElectronEffectiveAreaTarget EAtarget
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 &)