File indexing completed on 2023-10-25 09:41:35
0001
0002
0003
0004
0005
0006
0007
0008 #include <memory>
0009 #include <iostream>
0010 #include <fstream>
0011 #include <sstream>
0012 #include <string>
0013 #include <cstdio>
0014 #include <cstdlib>
0015
0016 #include "FWCore/Framework/interface/Frameworkfwd.h"
0017 #include "FWCore/Framework/interface/one/EDFilter.h"
0018
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022
0023 #include "FWCore/Utilities/interface/InputTag.h"
0024
0025 #include "FWCore/Framework/interface/LuminosityBlock.h"
0026 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0027 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0028 #include "DataFormats/METReco/interface/CaloMETFwd.h"
0029 #include "DataFormats/METReco/interface/CaloMET.h"
0030 #include "DataFormats/METReco/interface/CaloMETCollection.h"
0031 #include "DataFormats/METReco/interface/PFMETFwd.h"
0032 #include "DataFormats/METReco/interface/PFMET.h"
0033 #include "DataFormats/METReco/interface/PFMETCollection.h"
0034 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0035 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0036
0037 #include "TLorentzVector.h"
0038
0039
0040
0041
0042 using namespace reco;
0043
0044 class WZInterestingEventSelector : public edm::one::EDFilter<> {
0045 public:
0046 struct event {
0047 long run;
0048 long event;
0049 long ls;
0050 int nEle;
0051 float maxPt;
0052 float maxPtEleEta;
0053 float maxPtElePhi;
0054 float invMass;
0055 float met;
0056 float metPhi;
0057 };
0058
0059 explicit WZInterestingEventSelector(const edm::ParameterSet&);
0060 ~WZInterestingEventSelector() override;
0061
0062 private:
0063 bool filter(edm::Event&, const edm::EventSetup&) override;
0064 void endJob() override;
0065 bool electronSelection(const GsfElectron* eleRef, const math::XYZPoint& bspotPosition);
0066
0067
0068
0069
0070
0071 float ptCut_;
0072 int missHitCut_;
0073
0074
0075 float eb_trIsoCut_;
0076 float eb_ecalIsoCut_;
0077 float eb_hcalIsoCut_;
0078 float eb_hoeCut_;
0079 float eb_seeCut_;
0080
0081
0082 float ee_trIsoCut_;
0083 float ee_ecalIsoCut_;
0084 float ee_hcalIsoCut_;
0085 float ee_hoeCut_;
0086 float ee_seeCut_;
0087
0088
0089 float metCut_;
0090
0091
0092 float invMassCut_;
0093
0094 edm::InputTag electronCollection_;
0095 edm::InputTag pfMetCollection_;
0096 edm::InputTag offlineBSCollection_;
0097 };
0098
0099
0100
0101
0102 WZInterestingEventSelector::WZInterestingEventSelector(const edm::ParameterSet& iConfig) {
0103 ptCut_ = iConfig.getParameter<double>("ptCut");
0104 missHitCut_ = iConfig.getParameter<int>("missHitsCut");
0105
0106 eb_trIsoCut_ = iConfig.getParameter<double>("eb_trIsoCut");
0107 eb_ecalIsoCut_ = iConfig.getParameter<double>("eb_ecalIsoCut");
0108 eb_hcalIsoCut_ = iConfig.getParameter<double>("eb_hcalIsoCut");
0109 eb_hoeCut_ = iConfig.getParameter<double>("eb_hoeCut");
0110 eb_seeCut_ = iConfig.getParameter<double>("eb_seeCut");
0111
0112 ee_trIsoCut_ = iConfig.getParameter<double>("ee_trIsoCut");
0113 ee_ecalIsoCut_ = iConfig.getParameter<double>("ee_ecalIsoCut");
0114 ee_hcalIsoCut_ = iConfig.getParameter<double>("ee_hcalIsoCut");
0115 ee_hoeCut_ = iConfig.getParameter<double>("ee_hoeCut");
0116 ee_seeCut_ = iConfig.getParameter<double>("ee_seeCut");
0117
0118 metCut_ = iConfig.getParameter<double>("metCut");
0119 invMassCut_ = iConfig.getParameter<double>("invMassCut");
0120
0121 electronCollection_ =
0122 iConfig.getUntrackedParameter<edm::InputTag>("electronCollection", edm::InputTag("gsfElectrons"));
0123 pfMetCollection_ = iConfig.getUntrackedParameter<edm::InputTag>("pfMetCollection", edm::InputTag("pfMet"));
0124 offlineBSCollection_ =
0125 iConfig.getUntrackedParameter<edm::InputTag>("offlineBSCollection", edm::InputTag("offlineBeamSpot"));
0126 }
0127
0128 WZInterestingEventSelector::~WZInterestingEventSelector() {
0129
0130
0131 }
0132
0133
0134
0135
0136
0137
0138
0139 void WZInterestingEventSelector::endJob() {
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170 }
0171
0172 bool WZInterestingEventSelector::electronSelection(const GsfElectron* eleRef, const math::XYZPoint& bspotPosition) {
0173
0174
0175
0176
0177
0178
0179 if (eleRef->pt() < ptCut_)
0180 return false;
0181
0182 if (eleRef->isEB()) {
0183 if (eleRef->dr03TkSumPt() / eleRef->pt() > eb_trIsoCut_)
0184 return false;
0185 if (eleRef->dr03EcalRecHitSumEt() / eleRef->pt() > eb_ecalIsoCut_)
0186 return false;
0187 if (eleRef->dr03HcalTowerSumEt() / eleRef->pt() > eb_hcalIsoCut_)
0188 return false;
0189 if (eleRef->sigmaIetaIeta() > eb_seeCut_)
0190 return false;
0191 if (eleRef->hcalOverEcal() > eb_hoeCut_)
0192 return false;
0193 } else if (eleRef->isEE()) {
0194 if (eleRef->dr03TkSumPt() / eleRef->pt() > ee_trIsoCut_)
0195 return false;
0196 if (eleRef->dr03EcalRecHitSumEt() / eleRef->pt() > ee_ecalIsoCut_)
0197 return false;
0198 if (eleRef->dr03HcalTowerSumEt() / eleRef->pt() > ee_hcalIsoCut_)
0199 return false;
0200 if (eleRef->sigmaIetaIeta() > ee_seeCut_)
0201 return false;
0202 if (eleRef->hcalOverEcal() > ee_hoeCut_)
0203 return false;
0204 }
0205
0206 if (eleRef->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) > missHitCut_)
0207 return false;
0208
0209 return true;
0210 }
0211
0212 bool WZInterestingEventSelector::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0213
0214 edm::Handle<reco::GsfElectronCollection> gsfElectrons;
0215 iEvent.getByLabel(electronCollection_, gsfElectrons);
0216
0217
0218
0219
0220 edm::Handle<reco::PFMETCollection> pfMET;
0221 iEvent.getByLabel(pfMetCollection_, pfMET);
0222
0223 edm::Handle<reco::BeamSpot> pBeamSpot;
0224 iEvent.getByLabel(offlineBSCollection_, pBeamSpot);
0225
0226 const reco::BeamSpot* bspot = pBeamSpot.product();
0227 const math::XYZPoint& bspotPosition = bspot->position();
0228
0229 std::vector<const GsfElectron*> goodElectrons;
0230 float ptMax = -999.;
0231 const GsfElectron* ptMaxEle = nullptr;
0232 for (reco::GsfElectronCollection::const_iterator myEle = gsfElectrons->begin(); myEle != gsfElectrons->end();
0233 ++myEle) {
0234
0235 if (!electronSelection(&(*myEle), bspotPosition))
0236 continue;
0237 goodElectrons.push_back(&(*myEle));
0238 if (myEle->pt() > ptMax) {
0239 ptMax = myEle->pt();
0240 ptMaxEle = &(*myEle);
0241 }
0242 }
0243
0244 float maxInv = -999.;
0245 TLorentzVector v1;
0246 if (ptMaxEle)
0247 v1.SetPtEtaPhiM(ptMaxEle->pt(), ptMaxEle->eta(), ptMaxEle->phi(), 0);
0248 if (goodElectrons.size() > 1) {
0249 for (unsigned int iEle = 0; iEle < goodElectrons.size(); ++iEle)
0250 if (goodElectrons[iEle] != ptMaxEle && (goodElectrons[iEle]->charge() * ptMaxEle->charge() == -1)) {
0251 TLorentzVector v2;
0252 v2.SetPtEtaPhiM(goodElectrons[iEle]->pt(), goodElectrons[iEle]->eta(), goodElectrons[iEle]->phi(), 0.);
0253 if ((v1 + v2).M() > maxInv)
0254 maxInv = (v1 + v2).M();
0255 }
0256 }
0257
0258
0259 if (goodElectrons.size() > 1 && maxInv > invMassCut_) {
0260
0261 return true;
0262 }
0263
0264
0265 if (!goodElectrons.empty() && (pfMET->begin()->et() > metCut_)) {
0266
0267 return true;
0268 }
0269
0270 return false;
0271 }
0272
0273
0274 DEFINE_FWK_MODULE(WZInterestingEventSelector);