diff --git a/CatProducer/plugins/BadECALSlewRateMitigationFilter2016.cc b/CatProducer/plugins/BadECALSlewRateMitigationFilter2016.cc new file mode 100644 index 00000000000..51bb1fe3716 --- /dev/null +++ b/CatProducer/plugins/BadECALSlewRateMitigationFilter2016.cc @@ -0,0 +1,77 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/Common/interface/EDCollection.h" +#include "DataFormats/DetId/interface/DetId.h" + +#include +#include +#include + +using namespace std; + +class BadECALSlewRateMitigationFilter2016 : public edm::stream::EDFilter<> +{ +public: + BadECALSlewRateMitigationFilter2016(const edm::ParameterSet& pset); + ~BadECALSlewRateMitigationFilter2016() {}; + + bool filter(edm::Event& event, const edm::EventSetup& eventSetup) override; + +private: + edm::EDGetTokenT dupECALClusterToken_; + edm::EDGetTokenT> hitsNotReplacedToken_; + + const bool doFilter_; +}; + +BadECALSlewRateMitigationFilter2016::BadECALSlewRateMitigationFilter2016(const edm::ParameterSet& pset): + doFilter_(pset.getUntrackedParameter("doFilter", false)) +{ + dupECALClusterToken_ = consumes(edm::InputTag("particleFlowEGammaGSFixed:dupECALClusters")); + hitsNotReplacedToken_ = consumes>(edm::InputTag("ecalMultiAndGSGlobalRecHitEB:hitsNotReplaced")); + + produces(); +} + +bool BadECALSlewRateMitigationFilter2016::filter(edm::Event& event, const edm::EventSetup& eventSetup) +{ + bool isAccepted = true; + + do { + if ( !event.isRealData() ) break; // always accept MC + + edm::Handle dupECALClusterHandle; + event.getByToken(dupECALClusterToken_, dupECALClusterHandle); + + edm::Handle> hitsNotReplacedHandle; + event.getByToken(hitsNotReplacedToken_, hitsNotReplacedHandle); + + if ( dupECALClusterHandle.isValid() and *dupECALClusterHandle == true ) { + // Duplicated ECAL clusters must be false + isAccepted = false; + break; + } + + if ( hitsNotReplacedHandle.isValid() and !hitsNotReplacedHandle->empty() ) { + // There should no "hits not replaced" + isAccepted = false; + break; + } + + } while (false); + + event.put(std::move(std::make_unique(isAccepted))); + + if ( !doFilter_ ) return true; + return isAccepted; +} + +DEFINE_FWK_MODULE(BadECALSlewRateMitigationFilter2016); diff --git a/CatProducer/plugins/CATElectronProducer.cc b/CatProducer/plugins/CATElectronProducer.cc index 92773c31273..88865c70b19 100644 --- a/CatProducer/plugins/CATElectronProducer.cc +++ b/CatProducer/plugins/CATElectronProducer.cc @@ -59,7 +59,6 @@ namespace cat { edm::EDGetTokenT pfSrc_; edm::EDGetTokenT beamLineSrc_; edm::EDGetTokenT rhoLabel_; - edm::EDGetTokenT>> ebRecHitsToken_; bool runOnMC_; @@ -142,7 +141,6 @@ cat::CATElectronProducer::CATElectronProducer(const edm::ParameterSet & iConfig) pfSrc_(consumes(iConfig.getParameter("pfSrc"))), beamLineSrc_(consumes(iConfig.getParameter("beamLineSrc"))), rhoLabel_(consumes(iConfig.getParameter("rhoLabel"))), - ebRecHitsToken_(consumes>>(iConfig.getParameter("ebRecHits"))), electronIDs_(iConfig.getParameter >("electronIDs")) { @@ -183,16 +181,11 @@ cat::CATElectronProducer::produce(edm::Event & iEvent, const edm::EventSetup & i iEvent.getByToken(rhoLabel_, rhoHandle); double rhoIso = std::max(*(rhoHandle.product()), 0.0); - edm::Handle>> ebRecHitsHandle; - GlobalPoint pVertex(pv.position().x(),pv.position().y(),pv.position().z()); if (runOnMC_){ iEvent.getByToken(mcLabel_,genParticles); } - else { - iEvent.getByToken(ebRecHitsToken_, ebRecHitsHandle); - } ESHandle trackBuilder; iSetup.get().get("TransientTrackBuilder",trackBuilder); @@ -216,26 +209,6 @@ cat::CATElectronProducer::produce(edm::Event & iEvent, const edm::EventSetup & i // nan protection - smearing fails for soft electrons if ( std::isnan(std::abs(aElectron.p())) ) aElectron = *unsmearedElecRef; - // Redisual scale correction is needed for Moriond17 analysis. see https://twiki.cern.ch/twiki/bin/view/CMS/EGMSmearer - // this residual correction have to be applied ONLY FOR DATA with BARREL RecHits - if ( !runOnMC_ ) { - // FIXME: maybe it should be removed in the future - DetId detid = aPatElectron.superCluster()->seed()->seed(); - const EcalRecHit * rh = 0; - if (detid.subdetId() == EcalBarrel) { - auto rh_i = ebRecHitsHandle->find(detid); - if( rh_i != ebRecHitsHandle->end()) rh = &(*rh_i); - else rh = NULL; - } - if ( rh ) { - double Ecorr=1; - if(rh->energy() > 200 && rh->energy()<300) Ecorr=1.0199; - else if(rh->energy()>300 && rh->energy()<400) Ecorr= 1.052; - else if(rh->energy()>400 && rh->energy()<500) Ecorr = 1.015; - aElectron.setP4(Ecorr*aElectron.p4()); - } - } - if (runOnMC_){ aElectron.setGenParticleRef(aPatElectron.genParticleRef()); aElectron.setMCMatched( mcMatch( aElectron.p4(), genParticles ) ); diff --git a/CatProducer/plugins/CATPhotonProducer.cc b/CatProducer/plugins/CATPhotonProducer.cc index 34477db96b4..7b43d170fc9 100644 --- a/CatProducer/plugins/CATPhotonProducer.cc +++ b/CatProducer/plugins/CATPhotonProducer.cc @@ -58,7 +58,6 @@ namespace cat { edm::EDGetTokenT mcLabel_; edm::EDGetTokenT rhoLabel_; - edm::EDGetTokenT>> ebRecHitsToken_; bool runOnMC_; @@ -78,7 +77,6 @@ cat::CATPhotonProducer::CATPhotonProducer(const edm::ParameterSet & iConfig) : vertexLabel_(consumes(iConfig.getParameter("vertexLabel"))), mcLabel_(consumes(iConfig.getParameter("mcLabel"))), rhoLabel_(consumes(iConfig.getParameter("rhoLabel"))), - ebRecHitsToken_(consumes>>(iConfig.getParameter("ebRecHits"))), photonIDs_(iConfig.getParameter >("photonIDs")) { produces >(); @@ -111,15 +109,10 @@ cat::CATPhotonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSe iEvent.getByToken(rhoLabel_, rhoHandle); double rhoIso = std::max(*(rhoHandle.product()), 0.0); - edm::Handle>> ebRecHitsHandle; - Handle genParticles; if (runOnMC_){ iEvent.getByToken(mcLabel_,genParticles); } - else { - iEvent.getByToken(ebRecHitsToken_, ebRecHitsHandle); - } std::vector > > idhandles; std::vector ids; @@ -139,26 +132,6 @@ cat::CATPhotonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSe auto phosRef = src->refAt(j); auto unsmearedPhotRef = unsmearedPhotHandle->refAt(j); - // Redisual scale correction is needed for Moriond17 analysis. see https://twiki.cern.ch/twiki/bin/view/CMS/EGMSmearer - // this residual correction have to be applied ONLY FOR DATA with BARREL RecHits - if ( !runOnMC_ ) { - // FIXME: maybe it should be removed in the future - DetId detid = aPatPhoton.superCluster()->seed()->seed(); - const EcalRecHit * rh = 0; - if (detid.subdetId() == EcalBarrel) { - auto rh_i = ebRecHitsHandle->find(detid); - if( rh_i != ebRecHitsHandle->end()) rh = &(*rh_i); - else rh = NULL; - } - if ( rh ) { - double Ecorr=1; - if(rh->energy() > 200 && rh->energy()<300) Ecorr=1.0199; - else if(rh->energy()>300 && rh->energy()<400) Ecorr= 1.052; - else if(rh->energy()>400 && rh->energy()<500) Ecorr = 1.015; - aPhoton.setP4(Ecorr*aPhoton.p4()); - } - } - if (runOnMC_){ aPhoton.setGenParticleRef(aPatPhoton.genParticleRef()); if(mcMatch(aPatPhoton.p4(), genParticles ) == 1) aPhoton.setMCMatched( true); diff --git a/CatProducer/python/catTools_cff.py b/CatProducer/python/catTools_cff.py index a0a713aaa6f..afa49240291 100644 --- a/CatProducer/python/catTools_cff.py +++ b/CatProducer/python/catTools_cff.py @@ -14,6 +14,8 @@ def catTool(process, runOnMC=True, useMiniAOD=True): from FWCore.PythonUtilities.LumiList import LumiList process.lumiMask = cms.EDFilter("LumiMaskFilter", LumiSections = LumiList('%s/src/CATTools/CatProducer/data/LumiMask/%s.txt'%(os.environ['CMSSW_BASE'], cat.lumiJSON)).getVLuminosityBlockRange()) + + process.load("CATTools.CatProducer.eventCleaning.badECALSlewRateMitigationFilter2016_cfi") useJECfile = True jecFiles = cat.JetEnergyCorrection diff --git a/CatProducer/python/eventCleaning/badECALSlewRateMitigationFilter2016_cfi.py b/CatProducer/python/eventCleaning/badECALSlewRateMitigationFilter2016_cfi.py new file mode 100644 index 00000000000..e62e4a45a11 --- /dev/null +++ b/CatProducer/python/eventCleaning/badECALSlewRateMitigationFilter2016_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +badECALSlewRateMitigationFilter2016 = cms.EDFilter("BadECALSlewRateMitigationFilter2016", +) diff --git a/CatProducer/python/producers/electronProducer_cfi.py b/CatProducer/python/producers/electronProducer_cfi.py index 97469a764ad..53804eb402a 100644 --- a/CatProducer/python/producers/electronProducer_cfi.py +++ b/CatProducer/python/producers/electronProducer_cfi.py @@ -9,7 +9,6 @@ pfSrc = cms.InputTag("packedPFCandidates"), beamLineSrc = cms.InputTag("offlineBeamSpot"), rhoLabel = cms.InputTag("fixedGridRhoAll"), - ebRecHits = cms.InputTag("reducedEgamma","reducedEBRecHits"), electronIDSources = cms.PSet(), electronIDs = cms.vstring(), ## Defined in CatProducer/python/patTools/egmVersionedID_cff.py ) diff --git a/CatProducer/python/producers/photonProducer_cfi.py b/CatProducer/python/producers/photonProducer_cfi.py index 3663c0cb46e..f0487749704 100644 --- a/CatProducer/python/producers/photonProducer_cfi.py +++ b/CatProducer/python/producers/photonProducer_cfi.py @@ -4,7 +4,6 @@ src = cms.InputTag("slimmedPhotons"), unsmearedPhotons = cms.InputTag("slimmedPhotons"), rhoLabel = cms.InputTag("fixedGridRhoFastjetAll"), - ebRecHits = cms.InputTag("reducedEgamma","reducedEBRecHits"), mcLabel = cms.InputTag("prunedGenParticles"), vertexLabel = cms.InputTag('catVertex'), beamLineSrc = cms.InputTag("offlineBeamSpot"), diff --git a/CatProducer/python/producers/triggerProducer_cfi.py b/CatProducer/python/producers/triggerProducer_cfi.py index b0010cf8e5b..31f129b7c12 100644 --- a/CatProducer/python/producers/triggerProducer_cfi.py +++ b/CatProducer/python/producers/triggerProducer_cfi.py @@ -30,10 +30,12 @@ "Flag_HBHENoiseIsoFilter", "Flag_EcalDeadCellTriggerPrimitiveFilter", "Flag_eeBadScFilter", + "Flag_badMuons", "Flag_duplicateMuons", "Flag_noBadMuons", ), bools = cms.VInputTag( cms.InputTag("BadChargedCandidateFilter"), cms.InputTag("BadPFMuonFilter"), + cms.InputTag("badECALSlewRateMitigationFilter2016"), ), ), ) diff --git a/Validation/python/commonTestInput_cff.py b/Validation/python/commonTestInput_cff.py index 3865750803c..f6412254dfc 100644 --- a/Validation/python/commonTestInput_cff.py +++ b/Validation/python/commonTestInput_cff.py @@ -10,5 +10,5 @@ commonTestMiniAODs = { "sig":cms.untracked.vstring("root://cmsxrootd.fnal.gov//store/mc/RunIISummer16MiniAODv2/TT_TuneCUETP8M2T4_13TeV-powheg-pythia8/MINIAODSIM/PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1/50000/0693E0E7-97BE-E611-B32F-0CC47A78A3D8.root",), "bkg":cms.untracked.vstring("root://cmsxrootd.fnal.gov//store/mc/RunIISummer16MiniAODv2/WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1/120000/0AF0207B-EFBE-E611-B4BE-0CC47A7FC858.root",), - "data":cms.untracked.vstring("root://cmsxrootd.fnal.gov///store/data/Run2016C/SingleMuon/MINIAOD/23Sep2016-v1/80000/82AF08FC-3B87-E611-A209-FA163E3F4268.root",), + "data":cms.untracked.vstring("root://cmsxrootd.fnal.gov///store/data/Run2016H/MuonEG/MINIAOD/03Feb2017_ver2-v1/100000/044366C7-4AEE-E611-8CF7-0025905B856E.root",), }