00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/Framework/interface/MakerMacros.h"
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00030 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00031 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00032 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00033 #include "DataFormats/VertexReco/interface/Vertex.h"
00034 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00035 #include "DataFormats/Common/interface/ValueMap.h"
00036 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00037 #include "EgammaAnalysis/ElectronTools/interface/EGammaCutBasedEleId.h"
00038 #include "FWCore/ServiceRegistry/interface/Service.h"
00039 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00040
00041 #include <TFile.h>
00042 #include <TH1F.h>
00043
00044
00045
00046
00047
00048 class EGammaCutBasedEleIdAnalyzer : public edm::EDAnalyzer {
00049 public:
00050 explicit EGammaCutBasedEleIdAnalyzer(const edm::ParameterSet&);
00051 ~EGammaCutBasedEleIdAnalyzer();
00052
00053 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
00054
00055
00056 private:
00057 virtual void beginJob() ;
00058 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00059 virtual void endJob() ;
00060
00061 virtual void beginRun(edm::Run const&, edm::EventSetup const&);
00062 virtual void endRun(edm::Run const&, edm::EventSetup const&);
00063 virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
00064 virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
00065
00066
00067
00068
00069 edm::InputTag electronsInputTag_;
00070 edm::InputTag conversionsInputTag_;
00071 edm::InputTag beamSpotInputTag_;
00072 edm::InputTag rhoIsoInputTag;
00073 edm::InputTag primaryVertexInputTag_;
00074 std::vector<edm::InputTag> isoValInputTags_;
00075
00076
00077 bool printDebug_;
00078
00079
00080 TH1F *h1_pt_;
00081 TH1F *h1_pt_veto_;
00082 TH1F *h1_pt_loose_;
00083 TH1F *h1_pt_medium_;
00084 TH1F *h1_pt_tight_;
00085 TH1F *h1_pt_trig_;
00086 TH1F *h1_pt_fbremeopin_;
00087
00088 };
00089
00090
00091
00092
00093
00094 typedef std::vector< edm::Handle< edm::ValueMap<reco::IsoDeposit> > > IsoDepositMaps;
00095 typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsoDepositVals;
00096
00097
00098
00099
00100
00101
00102
00103
00104 EGammaCutBasedEleIdAnalyzer::EGammaCutBasedEleIdAnalyzer(const edm::ParameterSet& iConfig)
00105 {
00106
00107
00108 electronsInputTag_ = iConfig.getParameter<edm::InputTag>("electronsInputTag");
00109 conversionsInputTag_ = iConfig.getParameter<edm::InputTag>("conversionsInputTag");
00110 beamSpotInputTag_ = iConfig.getParameter<edm::InputTag>("beamSpotInputTag");
00111 rhoIsoInputTag = iConfig.getParameter<edm::InputTag>("rhoIsoInputTag");
00112 primaryVertexInputTag_ = iConfig.getParameter<edm::InputTag>("primaryVertexInputTag");
00113 isoValInputTags_ = iConfig.getParameter<std::vector<edm::InputTag> >("isoValInputTags");
00114
00115
00116 printDebug_ = iConfig.getParameter<bool>("printDebug");
00117
00118
00119 edm::Service<TFileService> fs;
00120
00121 h1_pt_ = fs->make<TH1F>("h1_pt", "pt", 100, 0.0, 100.0);
00122 h1_pt_veto_ = fs->make<TH1F>("h1_pt_veto", "pt (veto)", 100, 0.0, 100.0);
00123 h1_pt_loose_ = fs->make<TH1F>("h1_pt_loose", "pt (loose)", 100, 0.0, 100.0);
00124 h1_pt_medium_ = fs->make<TH1F>("h1_pt_medium", "pt (medium)", 100, 0.0, 100.0);
00125 h1_pt_tight_ = fs->make<TH1F>("h1_pt_tight", "pt (tight)", 100, 0.0, 100.0);
00126 h1_pt_trig_ = fs->make<TH1F>("h1_pt_trig", "pt (trig)", 100, 0.0, 100.0);
00127 h1_pt_fbremeopin_ = fs->make<TH1F>("h1_pt_fbremeopin", "pt (fbremeopin)", 100, 0.0, 100.0);
00128
00129 }
00130
00131
00132 EGammaCutBasedEleIdAnalyzer::~EGammaCutBasedEleIdAnalyzer()
00133 {
00134
00135
00136
00137
00138 }
00139
00140
00141
00142
00143
00144
00145
00146 void
00147 EGammaCutBasedEleIdAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00148 {
00149
00150 edm::Handle<reco::GsfElectronCollection> els_h;
00151 iEvent.getByLabel(electronsInputTag_, els_h);
00152
00153
00154 edm::Handle<reco::ConversionCollection> conversions_h;
00155 iEvent.getByLabel(conversionsInputTag_, conversions_h);
00156
00157
00158 IsoDepositVals isoVals(isoValInputTags_.size());
00159 for (size_t j = 0; j < isoValInputTags_.size(); ++j) {
00160 iEvent.getByLabel(isoValInputTags_[j], isoVals[j]);
00161 }
00162
00163
00164 edm::Handle<reco::BeamSpot> beamspot_h;
00165 iEvent.getByLabel(beamSpotInputTag_, beamspot_h);
00166 const reco::BeamSpot &beamSpot = *(beamspot_h.product());
00167
00168
00169 edm::Handle<reco::VertexCollection> vtx_h;
00170 iEvent.getByLabel(primaryVertexInputTag_, vtx_h);
00171
00172
00173 edm::Handle<double> rhoIso_h;
00174 iEvent.getByLabel(rhoIsoInputTag, rhoIso_h);
00175 double rhoIso = *(rhoIso_h.product());
00176
00177
00178 unsigned int n = els_h->size();
00179 for(unsigned int i = 0; i < n; ++i) {
00180
00181
00182 reco::GsfElectronRef ele(els_h, i);
00183
00184
00185
00186
00187
00188 double iso_ch = (*(isoVals)[0])[ele];
00189 double iso_em = (*(isoVals)[1])[ele];
00190 double iso_nh = (*(isoVals)[2])[ele];
00191
00192
00193
00194
00195
00196
00197 bool veto = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::VETO, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
00198 bool loose = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::LOOSE, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
00199 bool medium = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::MEDIUM, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
00200 bool tight = EgammaCutBasedEleId::PassWP(EgammaCutBasedEleId::TIGHT, ele, conversions_h, beamSpot, vtx_h, iso_ch, iso_em, iso_nh, rhoIso);
00201
00202
00203 bool fbremeopin = EgammaCutBasedEleId::PassEoverPCuts(ele);
00204
00205
00206 bool trigtight = EgammaCutBasedEleId::PassTriggerCuts(EgammaCutBasedEleId::TRIGGERTIGHT, ele);
00207
00208
00209 bool trigwp70 = EgammaCutBasedEleId::PassTriggerCuts(EgammaCutBasedEleId::TRIGGERWP70, ele);
00210
00211
00212
00213
00214
00215 h1_pt_->Fill(ele->pt());
00216 if (veto) h1_pt_veto_ ->Fill(ele->pt());
00217 if (loose) h1_pt_loose_ ->Fill(ele->pt());
00218 if (medium) h1_pt_medium_ ->Fill(ele->pt());
00219 if (tight) h1_pt_tight_ ->Fill(ele->pt());
00220 if (trigtight) h1_pt_trig_ ->Fill(ele->pt());
00221 if (fbremeopin) h1_pt_fbremeopin_ ->Fill(ele->pt());
00222
00223
00224
00225
00226
00227 if (printDebug_) {
00228 printf("%u %u %u : ", iEvent.id().run(), iEvent.luminosityBlock(), iEvent.id().event());
00229 printf("veto(%i), ", veto);
00230 printf("loose(%i), ", loose);
00231 printf("medium(%i), ", medium);
00232 printf("tight(%i), ", tight);
00233 printf("trigtight(%i), ", trigtight);
00234 printf("trigwp70(%i), ", trigwp70);
00235 printf("fbremeopin(%i)\n", fbremeopin);
00236 }
00237
00238 }
00239
00240 }
00241
00242
00243
00244 void
00245 EGammaCutBasedEleIdAnalyzer::beginJob()
00246 {
00247 }
00248
00249
00250 void
00251 EGammaCutBasedEleIdAnalyzer::endJob()
00252 {
00253 }
00254
00255
00256 void
00257 EGammaCutBasedEleIdAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
00258 {
00259 }
00260
00261
00262 void
00263 EGammaCutBasedEleIdAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
00264 {
00265 }
00266
00267
00268 void
00269 EGammaCutBasedEleIdAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
00270 {
00271 }
00272
00273
00274 void
00275 EGammaCutBasedEleIdAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
00276 {
00277 }
00278
00279
00280 void
00281 EGammaCutBasedEleIdAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00282
00283
00284 edm::ParameterSetDescription desc;
00285 desc.setUnknown();
00286 descriptions.addDefault(desc);
00287 }
00288
00289
00290 DEFINE_FWK_MODULE(EGammaCutBasedEleIdAnalyzer);