From 5cbed8df507df664a4d6e3827f97a0350ccd1ff4 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 3 Jul 2023 10:12:58 +0200 Subject: [PATCH 1/2] IsoPhotonEB skim (13_1_X) --- .../Skims/python/IsoPhotonEBSkim_cff.py | 51 +++++++ DPGAnalysis/Skims/python/Skims_DPG_cff.py | 14 ++ DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc | 141 ++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py create mode 100644 DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc diff --git a/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py b/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py new file mode 100644 index 0000000000000..6846ada22d0b4 --- /dev/null +++ b/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py @@ -0,0 +1,51 @@ +import FWCore.ParameterSet.Config as cms +import copy +from HLTrigger.HLTfilters.hltHighLevel_cfi import * +IsoPhotonEBHLTFilter = copy.deepcopy(hltHighLevel) +IsoPhotonEBHLTFilter.throw = cms.bool(False) +IsoPhotonEBHLTFilter.HLTPaths = ["HLT_Photon110EB_TightID_TightIso_v*"] + +# run on MIONAOD +RUN_ON_MINIAOD = False + + +# cuts +PHOTON_CUT=("pt > 110 && abs(eta)<1.4442") + +# single lepton selectors +if RUN_ON_MINIAOD: + goodPhotons = cms.EDFilter("PATElectronRefSelector", + src = cms.InputTag("slimmedPhotons"), + cut = cms.string(PHOTON_CUT) + ) +else: + goodPhotons = cms.EDFilter("PhotonRefSelector", + src = cms.InputTag("gedPhotons"), + cut = cms.string(PHOTON_CUT) + ) + +photonIDWP = cms.PSet( #first for barrel, second for endcap. + full5x5_sigmaIEtaIEtaCut = cms.vdouble(0.011 ,-1. ) , # full5x5_sigmaIEtaIEtaCut + hOverECut = cms.vdouble(0.1 ,-1. ) , # hOverECut + relCombIsolationWithEACut = cms.vdouble(0.05 ,-1. ) # relCombIsolationWithEALowPtCut +) + + +identifiedPhotons = cms.EDFilter("IsoPhotonEBSelectorAndSkim", + src = cms.InputTag("goodPhotons"), + phID = photonIDWP, + absEtaMin=cms.vdouble( 0.0000, 1.0000, 1.4790, 2.0000, 2.2000, 2.3000, 2.4000), + absEtaMax=cms.vdouble( 1.0000, 1.4790, 2.0000, 2.2000, 2.3000, 2.4000, 5.0000), + effectiveAreaValues=cms.vdouble( 0.1703, 0.1715, 0.1213, 0.1230, 0.1635, 0.1937, 0.2393), + rho = cms.InputTag("fixedGridRhoFastjetCentralCalo") + ) + +identifiedPhotonsCountFilter = cms.EDFilter("CandViewCountFilter", + src = cms.InputTag("identifiedPhotons"), + minNumber = cms.uint32(1) + ) + + + +#sequences +isoPhotonEBSequence = cms.Sequence(IsoPhotonEBHLTFilter*goodPhotons*identifiedPhotons*identifiedPhotonsCountFilter ) diff --git a/DPGAnalysis/Skims/python/Skims_DPG_cff.py b/DPGAnalysis/Skims/python/Skims_DPG_cff.py index 56dfbfe8a81f8..222bca5ee7fe4 100644 --- a/DPGAnalysis/Skims/python/Skims_DPG_cff.py +++ b/DPGAnalysis/Skims/python/Skims_DPG_cff.py @@ -402,6 +402,20 @@ ##################### +from DPGAnalysis.Skims.IsoPhotonEBSkim_cff import * +isoPhotonEBPath = cms.Path( isoPhotonEBSequence ) + +SKIMStreamIsoPhotonEB = cms.FilteredStream( + responsible = 'L1 DPG', + name = 'IsoPhotonEB', + paths = ( isoPhotonEBPath ), + content = skimContent.outputCommands, + selectEvents = cms.untracked.PSet(), + dataTier = cms.untracked.string('RAW-RECO') + ) + +##################### + from DPGAnalysis.Skims.HighMETSkim_cff import * condPath = cms.Path(CondMETSelSeq) #pfPath = cms.Path(pfMETSelSeq) diff --git a/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc b/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc new file mode 100644 index 0000000000000..d871888bf8453 --- /dev/null +++ b/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc @@ -0,0 +1,141 @@ +// -*- C++ -*- +// Class: ZElectronsSelector +// +// Original Author: Silvia Taroni +// Created: Wed, 29 Nov 2017 18:23:54 GMT +// +// + +#include "FWCore/PluginManager/interface/ModuleDef.h" + +// system include files + +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDFilter.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/EgammaCandidates/interface/Photon.h" +#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" +#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "CommonTools/UtilAlgos/interface/SingleObjectSelector.h" +// +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "CommonTools/UtilAlgos/interface/SingleObjectSelector.h" +#include "DataFormats/Common/interface/View.h" + +using namespace std; +using namespace reco; +namespace edm { + class EventSetup; +} + +class IsoPhotonEBSelector { +public: + IsoPhotonEBSelector(const edm::ParameterSet&, edm::ConsumesCollector& iC); + bool operator()(const reco::Photon&) const; + void newEvent(const edm::Event&, const edm::EventSetup&); + const float getEffectiveArea(float eta) const; + void printEffectiveAreas() const; + + edm::EDGetTokenT theRhoToken; + edm::EDGetTokenT thePhotonToken; + edm::Handle _rhoHandle; + + std::vector absEtaMin_; // low limit of the eta range + std::vector absEtaMax_; // upper limit of the eta range + std::vector effectiveAreaValues_; // effective area for this eta range + + edm::ParameterSet phIDWP; + + vector sigmaIEtaIEtaCut; + vector hOverECut; + vector relCombIso; +}; + +void IsoPhotonEBSelector::printEffectiveAreas() const { + printf(" eta_min eta_max effective area\n"); + uint nEtaBins = absEtaMin_.size(); + for (uint iEta = 0; iEta < nEtaBins; iEta++) { + printf(" %8.4f %8.4f %8.5f\n", absEtaMin_[iEta], absEtaMax_[iEta], effectiveAreaValues_[iEta]); + } +} +const float IsoPhotonEBSelector::getEffectiveArea(float eta) const { + float effArea = 0; + uint nEtaBins = absEtaMin_.size(); + for (uint iEta = 0; iEta < nEtaBins; iEta++) { + if (std::abs(eta) >= absEtaMin_[iEta] && std::abs(eta) < absEtaMax_[iEta]) { + effArea = effectiveAreaValues_[iEta]; + break; + } + } + + return effArea; +} + +IsoPhotonEBSelector::IsoPhotonEBSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) + : theRhoToken(iC.consumes(cfg.getParameter("rho"))) { + absEtaMin_ = cfg.getParameter >("absEtaMin"); + absEtaMax_ = cfg.getParameter >("absEtaMax"); + effectiveAreaValues_ = cfg.getParameter >("effectiveAreaValues"); + //printEffectiveAreas(); + phIDWP = cfg.getParameter("phID"); + + sigmaIEtaIEtaCut = phIDWP.getParameter >("full5x5_sigmaIEtaIEtaCut"); + hOverECut = phIDWP.getParameter >("hOverECut"); + relCombIso = phIDWP.getParameter >("relCombIsolationWithEACut"); +} + +void IsoPhotonEBSelector::newEvent(const edm::Event& ev, const edm::EventSetup&) { + ev.getByToken(theRhoToken, _rhoHandle); +} + +bool IsoPhotonEBSelector::operator()(const reco::Photon& ph) const { + float pt_e = ph.pt(); + unsigned int ind = 0; + float abseta = fabs((ph.superCluster().get())->position().eta()); + + if (ph.isEB()) { + if (abseta > 1.479) + return false; // check if it is really needed + } + if (ph.isEE()) { + ind = 1; + if (abseta < 1.479) + return false; // check if it is really needed + if (abseta >= 2.5) + return false; // check if it is really needed + } + + if (ph.full5x5_sigmaIetaIeta() > sigmaIEtaIEtaCut[ind]) + return false; + if (ph.hadronicOverEm() > hOverECut[ind]) + return false; + const float eA = getEffectiveArea(abseta); + const float rho = _rhoHandle.isValid() ? (float)(*_rhoHandle.product()) : 0; + if ((ph.getPflowIsolationVariables().chargedHadronIso + + std::max(float(0.0), + ph.getPflowIsolationVariables().neutralHadronIso + ph.getPflowIsolationVariables().photonIso - + eA * rho)) > relCombIso[ind] * pt_e) + return false; + + return true; +} + +EVENTSETUP_STD_INIT(IsoPhotonEBSelector); + +typedef SingleObjectSelector, IsoPhotonEBSelector> IsoPhotonEBSelectorAndSkim; + +DEFINE_FWK_MODULE(IsoPhotonEBSelectorAndSkim); From cf85b32129919eacdda6753eebc3e8ad57b86eb5 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 8 Jul 2023 09:32:44 +0200 Subject: [PATCH 2/2] Complying with class member syntax, dropping unused includes ... --- .../Skims/python/IsoPhotonEBSkim_cff.py | 10 ++-- DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc | 53 ++++++++----------- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py b/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py index 6846ada22d0b4..b0e8ec8f110b5 100644 --- a/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py +++ b/DPGAnalysis/Skims/python/IsoPhotonEBSkim_cff.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms -import copy -from HLTrigger.HLTfilters.hltHighLevel_cfi import * -IsoPhotonEBHLTFilter = copy.deepcopy(hltHighLevel) -IsoPhotonEBHLTFilter.throw = cms.bool(False) -IsoPhotonEBHLTFilter.HLTPaths = ["HLT_Photon110EB_TightID_TightIso_v*"] +from HLTrigger.HLTfilters.hltHighLevel_cfi import hltHighLevel +IsoPhotonEBHLTFilter = hltHighLevel.clone( + throw = False, + HLTPaths = ["HLT_Photon110EB_TightID_TightIso_v*"] +) # run on MIONAOD RUN_ON_MINIAOD = False diff --git a/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc b/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc index d871888bf8453..001f9be48265f 100644 --- a/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc +++ b/DPGAnalysis/Skims/src/IsoPhotonEBSelector.cc @@ -27,9 +27,6 @@ #include "DataFormats/EgammaCandidates/interface/Photon.h" #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" -#include "CommonTools/UtilAlgos/interface/SingleObjectSelector.h" // #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/ConsumesCollector.h" @@ -50,19 +47,18 @@ class IsoPhotonEBSelector { const float getEffectiveArea(float eta) const; void printEffectiveAreas() const; - edm::EDGetTokenT theRhoToken; - edm::EDGetTokenT thePhotonToken; - edm::Handle _rhoHandle; + const edm::EDGetTokenT theRhoToken_; + edm::Handle rhoHandle_; - std::vector absEtaMin_; // low limit of the eta range - std::vector absEtaMax_; // upper limit of the eta range - std::vector effectiveAreaValues_; // effective area for this eta range + const std::vector absEtaMin_; // low limit of the eta range + const std::vector absEtaMax_; // upper limit of the eta range + const std::vector effectiveAreaValues_; // effective area for this eta range - edm::ParameterSet phIDWP; + const edm::ParameterSet phIDWP_; - vector sigmaIEtaIEtaCut; - vector hOverECut; - vector relCombIso; + const vector sigmaIEtaIEtaCut_; + const vector hOverECut_; + const vector relCombIso_; }; void IsoPhotonEBSelector::printEffectiveAreas() const { @@ -86,20 +82,19 @@ const float IsoPhotonEBSelector::getEffectiveArea(float eta) const { } IsoPhotonEBSelector::IsoPhotonEBSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) - : theRhoToken(iC.consumes(cfg.getParameter("rho"))) { - absEtaMin_ = cfg.getParameter >("absEtaMin"); - absEtaMax_ = cfg.getParameter >("absEtaMax"); - effectiveAreaValues_ = cfg.getParameter >("effectiveAreaValues"); + : theRhoToken_(iC.consumes(cfg.getParameter("rho"))), + absEtaMin_(cfg.getParameter >("absEtaMin")), + absEtaMax_(cfg.getParameter >("absEtaMax")), + effectiveAreaValues_(cfg.getParameter >("effectiveAreaValues")), + phIDWP_(cfg.getParameter("phID")), + sigmaIEtaIEtaCut_(phIDWP_.getParameter >("full5x5_sigmaIEtaIEtaCut")), + hOverECut_(phIDWP_.getParameter >("hOverECut")), + relCombIso_(phIDWP_.getParameter >("relCombIsolationWithEACut")) { //printEffectiveAreas(); - phIDWP = cfg.getParameter("phID"); - - sigmaIEtaIEtaCut = phIDWP.getParameter >("full5x5_sigmaIEtaIEtaCut"); - hOverECut = phIDWP.getParameter >("hOverECut"); - relCombIso = phIDWP.getParameter >("relCombIsolationWithEACut"); } void IsoPhotonEBSelector::newEvent(const edm::Event& ev, const edm::EventSetup&) { - ev.getByToken(theRhoToken, _rhoHandle); + ev.getByToken(theRhoToken_, rhoHandle_); } bool IsoPhotonEBSelector::operator()(const reco::Photon& ph) const { @@ -113,22 +108,20 @@ bool IsoPhotonEBSelector::operator()(const reco::Photon& ph) const { } if (ph.isEE()) { ind = 1; - if (abseta < 1.479) - return false; // check if it is really needed - if (abseta >= 2.5) + if (abseta <= 1.479 || abseta >= 2.5) return false; // check if it is really needed } - if (ph.full5x5_sigmaIetaIeta() > sigmaIEtaIEtaCut[ind]) + if (ph.full5x5_sigmaIetaIeta() > sigmaIEtaIEtaCut_[ind]) return false; - if (ph.hadronicOverEm() > hOverECut[ind]) + if (ph.hadronicOverEm() > hOverECut_[ind]) return false; const float eA = getEffectiveArea(abseta); - const float rho = _rhoHandle.isValid() ? (float)(*_rhoHandle.product()) : 0; + const float rho = rhoHandle_.isValid() ? (float)(*rhoHandle_.product()) : 0; if ((ph.getPflowIsolationVariables().chargedHadronIso + std::max(float(0.0), ph.getPflowIsolationVariables().neutralHadronIso + ph.getPflowIsolationVariables().photonIso - - eA * rho)) > relCombIso[ind] * pt_e) + eA * rho)) > relCombIso_[ind] * pt_e) return false; return true;