CMS 3D CMS Logo

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 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
40 
41 #include <TFile.h>
42 #include <TH1F.h>
43 
44 //
45 // class declaration
46 //
47 
49 public:
50  typedef std::vector<edm::Handle<edm::ValueMap<reco::IsoDeposit> > > IsoDepositMaps;
51  typedef std::vector<edm::Handle<edm::ValueMap<double> > > IsoDepositVals;
52 
55 
56  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
58 
59 private:
60  void beginJob() override;
61  void analyze(const edm::Event &, const edm::EventSetup &) override;
62  void endJob() override;
63 
64  void beginRun(edm::Run const &, edm::EventSetup const &) override;
65  void endRun(edm::Run const &, edm::EventSetup const &) override;
66  void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override;
67  void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override;
68 
69  // ----------member data ---------------------------
70 
71  // input tags
77  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isoValTokens_;
79 
80  // debug
82 
83  // histograms
84  TH1F *h1_pt_;
85  TH1F *h1_pt_veto_;
86  TH1F *h1_pt_loose_;
88  TH1F *h1_pt_tight_;
89  TH1F *h1_pt_trig_;
91 };
92 
93 //
94 // static data member definitions
95 //
96 
97 //
98 // constructors and destructor
99 //
101  // get input parameters
102  electronsToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronsInputTag"));
103  conversionsToken_ = consumes<reco::ConversionCollection>(iConfig.getParameter<edm::InputTag>("conversionsInputTag"));
104  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
105  rhoIsoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("rhoIsoInputTag"));
106  primaryVertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertexInputTag"));
107  isoValTokens_ =
108  edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >("isoValInputTags"),
109  [this](edm::InputTag const &tag) { return consumes<edm::ValueMap<double> >(tag); });
111  "EAtarget"); //EleEANoCorr, EleEAData2011, EleEASummer11MC,EleEAFall11MC, EleEAData2012/
112 
113  // debug
114  printDebug_ = iConfig.getParameter<bool>("printDebug");
115 
116  // output histograms
118 
119  h1_pt_ = fs->make<TH1F>("h1_pt", "pt", 100, 0.0, 100.0);
120  h1_pt_veto_ = fs->make<TH1F>("h1_pt_veto", "pt (veto)", 100, 0.0, 100.0);
121  h1_pt_loose_ = fs->make<TH1F>("h1_pt_loose", "pt (loose)", 100, 0.0, 100.0);
122  h1_pt_medium_ = fs->make<TH1F>("h1_pt_medium", "pt (medium)", 100, 0.0, 100.0);
123  h1_pt_tight_ = fs->make<TH1F>("h1_pt_tight", "pt (tight)", 100, 0.0, 100.0);
124  h1_pt_trig_ = fs->make<TH1F>("h1_pt_trig", "pt (trig)", 100, 0.0, 100.0);
125  h1_pt_fbremeopin_ = fs->make<TH1F>("h1_pt_fbremeopin", "pt (fbremeopin)", 100, 0.0, 100.0);
126 }
127 
129  // do anything here that needs to be done at desctruction time
130  // (e.g. close files, deallocate resources etc.)
131 }
132 
133 //
134 // member functions
135 //
136 
137 // ------------ method called for each event ------------
139  // electrons
141  iEvent.getByToken(electronsToken_, els_h);
142 
143  // conversions
145  iEvent.getByToken(conversionsToken_, conversions_h);
146 
147  // iso deposits
148  IsoDepositVals isoVals(isoValTokens_.size());
149  for (size_t j = 0; j < isoValTokens_.size(); ++j) {
150  iEvent.getByToken(isoValTokens_[j], isoVals[j]);
151  }
152 
153  // beam spot
154  edm::Handle<reco::BeamSpot> beamspot_h;
155  iEvent.getByToken(beamSpotToken_, beamspot_h);
156  const reco::BeamSpot &beamSpot = *(beamspot_h.product());
157 
158  // vertices
160  iEvent.getByToken(primaryVertexToken_, vtx_h);
161 
162  // rho for isolation
163  edm::Handle<double> rhoIso_h;
164  iEvent.getByToken(rhoIsoToken_, rhoIso_h);
165  double rhoIso = *(rhoIso_h.product());
166 
167  // loop on electrons
168  unsigned int n = els_h->size();
169  for (unsigned int i = 0; i < n; ++i) {
170  // get reference to electron
171  reco::GsfElectronRef ele(els_h, i);
172 
173  //
174  // get particle flow isolation
175  //
176 
177  double iso_ch = (*(isoVals)[0])[ele];
178  double iso_em = (*(isoVals)[1])[ele];
179  double iso_nh = (*(isoVals)[2])[ele];
180 
181  //
182  // test ID
183  //
184 
185  // working points
187  EgammaCutBasedEleId::VETO, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
188  bool loose = EgammaCutBasedEleId::PassWP(
189  EgammaCutBasedEleId::LOOSE, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
190  bool medium = EgammaCutBasedEleId::PassWP(
191  EgammaCutBasedEleId::MEDIUM, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
192  bool tight = EgammaCutBasedEleId::PassWP(
193  EgammaCutBasedEleId::TIGHT, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso, EAtarget);
194 
195  // eop/fbrem cuts for extra tight ID
196  bool fbremeopin = EgammaCutBasedEleId::PassEoverPCuts(ele);
197 
198  // cuts to match tight trigger requirements
200 
201  // for 2011 WP70 trigger
203 
204  //
205  // fill histograms
206  //
207 
208  h1_pt_->Fill(ele->pt());
209  if (veto)
210  h1_pt_veto_->Fill(ele->pt());
211  if (loose)
212  h1_pt_loose_->Fill(ele->pt());
213  if (medium)
214  h1_pt_medium_->Fill(ele->pt());
215  if (tight)
216  h1_pt_tight_->Fill(ele->pt());
217  if (trigtight)
218  h1_pt_trig_->Fill(ele->pt());
219  if (fbremeopin)
220  h1_pt_fbremeopin_->Fill(ele->pt());
221 
222  //
223  // print decisions
224  //
225 
226  if (printDebug_) {
227  printf("%u %u %llu : ", iEvent.id().run(), iEvent.luminosityBlock(), iEvent.id().event());
228  printf("veto(%i), ", veto);
229  printf("loose(%i), ", loose);
230  printf("medium(%i), ", medium);
231  printf("tight(%i), ", tight);
232  printf("trigtight(%i), ", trigtight);
233  printf("trigwp70(%i), ", trigwp70);
234  printf("fbremeopin(%i)\n", fbremeopin);
235  }
236  }
237 }
238 
239 // ------------ method called once each job just before starting event loop ------------
241  if (EAtargetToken_ == "EleEANoCorr")
243  else if (EAtargetToken_ == "EleEAData2011")
245  else if (EAtargetToken_ == "EleEASummer11MC")
247  else if (EAtargetToken_ == "EleEAFall11MC")
249  else if (EAtargetToken_ == "EleEAData2012")
251  else
253 }
254 
255 // ------------ method called once each job just after ending the event loop ------------
257 
258 // ------------ method called when starting to processes a run ------------
260 
261 // ------------ method called when ending the processing of a run ------------
263 
264 // ------------ method called when starting to processes a luminosity block ------------
266 
267 // ------------ method called when ending the processing of a luminosity block ------------
269 
270 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
272  //The following says we do not know what parameters are allowed so do no validation
273  // Please change this to state exactly what you do use, even if it is no parameters
275  desc.setUnknown();
276  descriptions.addDefault(desc);
277 }
278 
279 //define this as a plug-in
EGammaCutBasedEleIdAnalyzer::EAtargetToken_
std::string EAtargetToken_
Definition: EGammaCutBasedEleIdAnalyzer.cc:78
EGammaCutBasedEleIdAnalyzer::h1_pt_trig_
TH1F * h1_pt_trig_
Definition: EGammaCutBasedEleIdAnalyzer.cc:89
EGammaCutBasedEleIdAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EGammaCutBasedEleIdAnalyzer.cc:271
mps_fire.i
i
Definition: mps_fire.py:428
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EgammaCutBasedEleId::TIGHT
Definition: EGammaCutBasedEleId.h:34
EGammaCutBasedEleIdAnalyzer::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: EGammaCutBasedEleIdAnalyzer.cc:262
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
EGammaCutBasedEleIdAnalyzer::printDebug_
bool printDebug_
Definition: EGammaCutBasedEleIdAnalyzer.cc:81
edm::EDGetTokenT< reco::GsfElectronCollection >
EGammaCutBasedEleIdAnalyzer::h1_pt_veto_
TH1F * h1_pt_veto_
Definition: EGammaCutBasedEleIdAnalyzer.cc:85
EGammaCutBasedEleIdAnalyzer::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EGammaCutBasedEleIdAnalyzer.cc:268
EGammaCutBasedEleIdAnalyzer::primaryVertexToken_
edm::EDGetTokenT< reco::VertexCollection > primaryVertexToken_
Definition: EGammaCutBasedEleIdAnalyzer.cc:76
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EGammaCutBasedEleIdAnalyzer::h1_pt_fbremeopin_
TH1F * h1_pt_fbremeopin_
Definition: EGammaCutBasedEleIdAnalyzer.cc:90
EDAnalyzer.h
edm::Handle< reco::GsfElectronCollection >
EgammaCutBasedEleId::VETO
Definition: EGammaCutBasedEleId.h:34
ElectronEffectiveArea::ElectronEffectiveAreaTarget
ElectronEffectiveAreaTarget
Definition: ElectronEffectiveArea.h:57
edm::Ref
Definition: AssociativeIterator.h:58
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
EGammaCutBasedEleIdAnalyzer::EAtarget
ElectronEffectiveArea::ElectronEffectiveAreaTarget EAtarget
Definition: EGammaCutBasedEleIdAnalyzer.cc:57
EgammaCutBasedEleId::TRIGGERTIGHT
Definition: EGammaCutBasedEleId.h:36
EGammaCutBasedEleIdAnalyzer::h1_pt_
TH1F * h1_pt_
Definition: EGammaCutBasedEleIdAnalyzer.cc:84
Service.h
EGammaCutBasedEleIdAnalyzer::endJob
void endJob() override
Definition: EGammaCutBasedEleIdAnalyzer.cc:256
reco::BeamSpot
Definition: BeamSpot.h:21
ElectronEffectiveArea::kEleEANoCorr
Definition: ElectronEffectiveArea.h:57
GsfElectron.h
EgammaCutBasedEleId::TRIGGERWP70
Definition: EGammaCutBasedEleId.h:36
EGammaCutBasedEleIdAnalyzer::IsoDepositMaps
std::vector< edm::Handle< edm::ValueMap< reco::IsoDeposit > > > IsoDepositMaps
Definition: EGammaCutBasedEleIdAnalyzer.cc:50
IsoDeposit.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
Vertex.h
TFileService.h
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
EGammaCutBasedEleIdAnalyzer::conversionsToken_
edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
Definition: EGammaCutBasedEleIdAnalyzer.cc:73
Event.h
EGammaCutBasedEleIdAnalyzer::h1_pt_tight_
TH1F * h1_pt_tight_
Definition: EGammaCutBasedEleIdAnalyzer.cc:88
ElectronEffectiveArea::kEleEAFall11MC
Definition: ElectronEffectiveArea.h:57
EGammaCutBasedEleIdAnalyzer::beamSpotToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: EGammaCutBasedEleIdAnalyzer.cc:74
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
EgammaCutBasedEleId::PassTriggerCuts
bool PassTriggerCuts(const TriggerWorkingPoint triggerWorkingPoint, const reco::GsfElectronRef &ele)
Definition: EGammaCutBasedEleId.cc:59
EGammaCutBasedEleIdAnalyzer::isoValTokens_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isoValTokens_
Definition: EGammaCutBasedEleIdAnalyzer.cc:77
edm::EventSetup
Definition: EventSetup.h:57
EgammaCutBasedEleId::PassEoverPCuts
bool PassEoverPCuts(const reco::GsfElectronRef &ele)
Definition: EGammaCutBasedEleId.cc:73
ElectronEffectiveArea::kEleEASummer11MC
Definition: ElectronEffectiveArea.h:57
EGammaCutBasedEleIdAnalyzer::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EGammaCutBasedEleIdAnalyzer.cc:265
EGammaCutBasedEleId.h
ValueMap.h
VertexFwd.h
ElectronEffectiveArea.h
EGammaCutBasedEleIdAnalyzer::rhoIsoToken_
edm::EDGetTokenT< double > rhoIsoToken_
Definition: EGammaCutBasedEleIdAnalyzer.cc:75
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
EGammaCutBasedEleIdAnalyzer::electronsToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronsToken_
Definition: EGammaCutBasedEleIdAnalyzer.cc:72
EGammaCutBasedEleIdAnalyzer::h1_pt_loose_
TH1F * h1_pt_loose_
Definition: EGammaCutBasedEleIdAnalyzer.cc:86
EGammaCutBasedEleIdAnalyzer::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EGammaCutBasedEleIdAnalyzer.cc:259
EGammaCutBasedEleIdAnalyzer::EGammaCutBasedEleIdAnalyzer
EGammaCutBasedEleIdAnalyzer(const edm::ParameterSet &)
Definition: EGammaCutBasedEleIdAnalyzer.cc:100
Frameworkfwd.h
transform.h
EGammaCutBasedEleIdAnalyzer::~EGammaCutBasedEleIdAnalyzer
~EGammaCutBasedEleIdAnalyzer() override
Definition: EGammaCutBasedEleIdAnalyzer.cc:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EgammaCutBasedEleId::MEDIUM
Definition: EGammaCutBasedEleId.h:34
EGammaCutBasedEleIdAnalyzer::beginJob
void beginJob() override
Definition: EGammaCutBasedEleIdAnalyzer.cc:240
EGammaCutBasedEleIdAnalyzer::h1_pt_medium_
TH1F * h1_pt_medium_
Definition: EGammaCutBasedEleIdAnalyzer.cc:87
ParameterSet.h
electronIsolatorFromEffectiveArea_cfi.rhoIso
rhoIso
Definition: electronIsolatorFromEffectiveArea_cfi.py:6
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ElectronEffectiveArea::kEleEAData2011
Definition: ElectronEffectiveArea.h:57
edm::Event
Definition: Event.h:73
PbPb_ZMuSkimMuonDPG_cff.veto
veto
Definition: PbPb_ZMuSkimMuonDPG_cff.py:61
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
EgammaCutBasedEleId::LOOSE
Definition: EGammaCutBasedEleId.h:34
EGammaCutBasedEleIdAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EGammaCutBasedEleIdAnalyzer.cc:138
edm::InputTag
Definition: InputTag.h:15
EGammaCutBasedEleIdAnalyzer
Definition: EGammaCutBasedEleIdAnalyzer.cc:48
EGammaCutBasedEleIdAnalyzer::IsoDepositVals
std::vector< edm::Handle< edm::ValueMap< double > > > IsoDepositVals
Definition: EGammaCutBasedEleIdAnalyzer.cc:51
ElectronEffectiveArea::kEleEAData2012
Definition: ElectronEffectiveArea.h:57
EgammaCutBasedEleId::PassWP
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)
Definition: EGammaCutBasedEleId.cc:29
Conversion.h