From f6749a3ab8952b4c37215babefb83f4809c71f04 Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Mon, 30 Jan 2017 14:02:07 +0000 Subject: [PATCH 1/4] fixing up comments --- .../src/EGRefinedSCFixer.cc | 68 +++++-------------- 1 file changed, 18 insertions(+), 50 deletions(-) diff --git a/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc b/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc index ed789676c2711..26645c1dbe9e4 100644 --- a/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc +++ b/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc @@ -19,13 +19,11 @@ #include #include -//work in progress (emergancy fix!) -//issue: we need to re-make the refined superclusters -//we only really need to do this for barrel super with a gain switch -//but usual to remake without gain switch for debugging -//however it is barrel only -//everything else is copied or relinked to produce the same set of outputs -//as particleFlowEGamma + +//issue: we need to re-make the refined superclusters in the AOD +//problem: to do this properly, we need the outer position of the track, not stored in AOD +// so we cant re-run PFEGammaProducer which would normally do this +//solution: we fudge it in the following way //how it works: // a refined supercluster will have subclusters added or removed w.r.t to its parent SC @@ -35,6 +33,11 @@ // we id clusters via seed crystal, this shouldnt change for any cluster without a gain switch, // its still a local maximum // +// it is important to know that for the digis to be saved in miniAOD, it must be within the 3x3 +// of a hybrid (or multi 5x5 in endcap) supercluster seed crystal. The hybrid supercluster seed +// crystals should map well to the PF supercluster seed crystal, particularly for isolated high +// energy e/gamma objects +// // for matching the new fixed superclusters vs old superclusters, the seed crystal may gain // as the gain switched crystal will now have a larger energy // but it really should be in the 3x3 of the orginal SC (the gain switch crysal has to be here to be redone) @@ -42,7 +45,6 @@ // but take the smallest dIR // issues: sub cluster ordering may not be correct (its sorted by decreasing energy) -// issues: when it assigns a sub cluster to a refined SC, it doesnt remove it from others class EGRefinedSCFixer : public edm::stream::EDProducer<> { public: @@ -145,38 +147,6 @@ namespace { } } -namespace{ - class SCPrinter { - const reco::SuperCluster& sc_; - public: - SCPrinter(const reco::SuperCluster& sc):sc_(sc){} - std::ostream& operator()(std::ostream& out)const{ - out <<"E "<seed().rawId()<<" nrclus "<seed().rawId()<<" nrclus "<energy()<<" Ecorr "<correctedEnergy()<<" seed "<seed().rawId()<<" nrHits "<hitsAndFractions().size()<(); // direct translation of the original ES collection - there is nothing "fixed" about this + // however they may be slightly different as we are reclustering from reduced rec-hit collections + // this will mainly effect non-photon or non-electron superclusters as those superclusters + // save less rec-hits surrounding them auto fixedESs = std::make_unique(); auto fixedConvs = std::make_unique(); @@ -224,20 +197,13 @@ void EGRefinedSCFixer::produce(edm::Event & iEvent, const edm::EventSetup & iSet // particleFlowEGamma can create superclusters directly out of PFClusters too // -> there is not always a matching EB SC if (orgEBSC.isNonnull()) { - //changing the matching to be in 3x3 now (had issues with suprious matches) auto fixedEBSC(GainSwitchTools::matchSCBySeedCrys(*orgEBSC, fixedEBSCs, 1, 1)); - - // here we may genuinely miss a mapping, if the seed position moves too much by re-reconstruction - // Sam: its very unlikely, if not impossible. To be replaced the gain switched crystal must be within +/-1 crystal a hybrid supercluster - // seed crystal because of ecalSelectedDigis. - // You could only get a shift larger than 1 if you had two supercluster seed crystals very close together and even then I'm not sure its possible. if (fixedEBSC.isNonnull()) { mappedSCsEB[fixedEBSC.key()] = orgEBSC; auto fixedRefinedSC(makeFixedRefinedBarrelSC(orgRefinedSC, *orgEBSC, *fixedEBSC, fixedPFClusters,clusterAddedToAnyEBSC)); fixedRefinedSCs->push_back(fixedRefinedSC); - continue; } } @@ -245,10 +211,12 @@ void EGRefinedSCFixer::produce(edm::Event & iEvent, const edm::EventSetup & iSet else { auto orgEESC(GainSwitchTools::matchSCBySeedCrys(orgRefinedSC, orgEESCs)); if (orgEESC.isNonnull()) { - // there is nothing "fixed" here - two clusters are identical + //there is nothing "fixed" here - two clusters are in theory identical but + //there could be mild differences given we are clustering from the + //reduced rec-hit collecitons + //for example this can lead to small energy changes leading a cluster to be + //now below the 4 GeV Et threshold to make a supercluster and therefore disappear auto fixedEESC(GainSwitchTools::matchSCBySeedCrys(*orgEESC, fixedEESCs)); - - // fixedEESC has to be nonnull if(fixedEESC.isNonnull()) mappedSCsEE[fixedEESC.key()] = orgEESC; } } From 1b910022dbcb5594e74685ccbbef4a0f10582c76 Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Mon, 30 Jan 2017 14:52:18 +0000 Subject: [PATCH 2/4] throwing on duplicate clusters now optional & tagged --- .../python/gsFixedRefinedSuperClusters_cfi.py | 3 ++ .../src/EGRefinedSCFixer.cc | 44 ++++++++++++++----- .../egammaGainSwitchFixToolsForPAT_cff.py | 3 ++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py b/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py index 24442b84e872c..536806421e97a 100644 --- a/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py +++ b/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py @@ -5,4 +5,7 @@ orgSC = cms.InputTag("particleFlowSuperClusterECAL", '', cms.InputTag.skipCurrentProcess()), fixedSC = cms.InputTag("particleFlowSuperClusterECALGSFixed"), fixedPFClusters = cms.InputTag("particleFlowClusterECALGSFixed"), + throwOnDupECALClustersInEvent = cms.bool(False), + throwOnDupESClustersInEvent = cms.bool(True) + ) diff --git a/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc b/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc index 26645c1dbe9e4..b76a575bef09d 100644 --- a/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc +++ b/RecoEcal/EgammaClusterProducers/src/EGRefinedSCFixer.cc @@ -106,14 +106,23 @@ class EGRefinedSCFixer : public edm::stream::EDProducer<> { edm::EDGetTokenT fixedPFClustersToken_; // output instance name of EB/EE BC collection - std::string ebeeClustersCollection_; + const std::string ebeeClustersCollection_; // output instance name of ES BC collection - std::string esClustersCollection_; + const std::string esClustersCollection_; + + //if this is true, throw on duplicate clusters entering the event + //if false, we flags the event and move on + const bool throwOnDupECALClustersInEvent_; + const bool throwOnDupESClustersInEvent_; + }; EGRefinedSCFixer::EGRefinedSCFixer(const edm::ParameterSet& iConfig) : ebeeClustersCollection_("EBEEClusters"), - esClustersCollection_("ESClusters") + esClustersCollection_("ESClusters"), + throwOnDupECALClustersInEvent_(iConfig.getParameter("throwOnDupECALClustersInEvent")), + throwOnDupESClustersInEvent_(iConfig.getParameter("throwOnDupESClustersInEvent")) + { getToken(orgRefinedSCToken_, iConfig, "orgRefinedSC"); getToken(orgBCToken_, iConfig, "orgRefinedSC", "EBEEClusters"); @@ -134,6 +143,9 @@ EGRefinedSCFixer::EGRefinedSCFixer(const edm::ParameterSet& iConfig) : produces(); produces("parentSCsEB"); produces("parentSCsEE"); + //flags to tell us if we have duplicate clusters + produces("dupECALClusters"); + produces("dupESClusters"); } namespace { @@ -243,6 +255,8 @@ void EGRefinedSCFixer::produce(edm::Event & iEvent, const edm::EventSetup & iSet std::map pfClusterMapEBEE; //maps of pfclusters to caloclusters std::map pfClusterMapES; + bool duplicateECALClusters=false; + bool duplicateESClusters=false; for (auto& sc : *fixedRefinedSCs) { // The cluster ref in fixed EB and the other superclusters point to different collections (former to gs-fixed, latter to original) // but we are copying the basic clusters by value and remaking yet another collection here -> no need to distinguish @@ -252,9 +266,13 @@ void EGRefinedSCFixer::produce(edm::Event & iEvent, const edm::EventSetup & iSet pfClusterMapEBEE[ptr] = fixedBCs->size(); fixedBCs->emplace_back(*ptr); } - else - throw cms::Exception("EGRefinedSCFixer::produce") - << "Found an EB/EE pfcluster matched to more than one supercluster!"; + else{ + duplicateECALClusters=true; + if(throwOnDupECALClustersInEvent_){ + throw cms::Exception("EGRefinedSCFixer::produce") + << "Found an EB/EE pfcluster matched to more than one supercluster!"; + } + } } for (auto&& cItr = sc.preshowerClustersBegin(); cItr!=sc.preshowerClustersEnd(); ++cItr) { @@ -263,12 +281,18 @@ void EGRefinedSCFixer::produce(edm::Event & iEvent, const edm::EventSetup & iSet pfClusterMapES[ptr] = fixedESs->size(); fixedESs->emplace_back(*ptr); } - else - throw cms::Exception("PFEgammaProducer::produce") - << "Found an ES pfcluster matched to more than one supercluster!"; + else{ + duplicateESClusters=true; + if(throwOnDupESClustersInEvent_){ + throw cms::Exception("PFEgammaProducer::produce") + << "Found an ES pfcluster matched to more than one supercluster!"; + } + } } } - + iEvent.put(std::make_unique(duplicateECALClusters),"dupECALClusters"); + iEvent.put(std::make_unique(duplicateESClusters),"dupESClusters"); + //put calocluster output collections in event and get orphan handles to create ptrs auto caloClusHandleEBEE(iEvent.put(std::move(fixedBCs), ebeeClustersCollection_)); auto caloClusHandleES(iEvent.put(std::move(fixedESs), esClustersCollection_)); diff --git a/RecoEgamma/EgammaTools/python/egammaGainSwitchFixToolsForPAT_cff.py b/RecoEgamma/EgammaTools/python/egammaGainSwitchFixToolsForPAT_cff.py index 33757036cbaf2..e73cfab3eb439 100644 --- a/RecoEgamma/EgammaTools/python/egammaGainSwitchFixToolsForPAT_cff.py +++ b/RecoEgamma/EgammaTools/python/egammaGainSwitchFixToolsForPAT_cff.py @@ -100,6 +100,9 @@ def customizeGSFixForPAT(process): 'keep EEDigiCollection_selectDigi_*_*', 'drop *_reducedEgammaBeforeGSFix_reducedGedGsfElectrons_*', 'drop *_reducedEgammaBeforeGSFix_reducedGedPhotons_*', + 'keep *_ecalMultiAndGSGlobalRecHitEB_hitsNotReplaced_*', + 'keep *_particleFlowEGammaGSFixed_dupECALClusters_*', + 'keep *_particleFlowEGammaGSFixed_dupESClusters_*', ]) process.reducedEgamma.gsfElectrons = cms.InputTag("gedGsfElectronsGSFixed") process.reducedEgamma.gsfElectronsPFValMap = cms.InputTag("particleBasedIsolationGSFixed","gedGsfElectrons") From ceaccb94bd7947c5025c5a4df6c6372fb165dfe4 Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Mon, 30 Jan 2017 15:26:25 +0000 Subject: [PATCH 3/4] modules renamed so they start with their final name --- .../gsFixedRefinedBarrelSuperClusters_cfi.py | 8 ---- ...fi.py => particleFlowEGammaGSFixed_cfi.py} | 2 +- ...i.py => gedGsfElectronCoresGSFixed_cfi.py} | 4 +- ...s_cfi.py => gedGsfElectronsGSFixed_cfi.py} | 4 +- .../python/gedPhotonCoreGSFixed_cfi.py | 9 +++++ ...hotons_cfi.py => gedPhotonsGSFixed_cfi.py} | 4 +- .../python/gsFixedGEDPhotonCores_cfi.py | 9 ----- .../python/egammaGainSwitchFixForPAT_cff.py | 40 ------------------- .../python/egammaGainSwitchFix_cff.py | 20 +++++----- 9 files changed, 26 insertions(+), 74 deletions(-) delete mode 100644 RecoEcal/EgammaClusterProducers/python/gsFixedRefinedBarrelSuperClusters_cfi.py rename RecoEcal/EgammaClusterProducers/python/{gsFixedRefinedSuperClusters_cfi.py => particleFlowEGammaGSFixed_cfi.py} (88%) rename RecoEgamma/EgammaElectronProducers/python/{gsFixedGsfElectronCores_cfi.py => gedGsfElectronCoresGSFixed_cfi.py} (59%) rename RecoEgamma/EgammaElectronProducers/python/{gsFixedGsfElectrons_cfi.py => gedGsfElectronsGSFixed_cfi.py} (75%) create mode 100644 RecoEgamma/EgammaPhotonProducers/python/gedPhotonCoreGSFixed_cfi.py rename RecoEgamma/EgammaPhotonProducers/python/{gsFixedGEDPhotons_cfi.py => gedPhotonsGSFixed_cfi.py} (90%) delete mode 100644 RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotonCores_cfi.py diff --git a/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedBarrelSuperClusters_cfi.py b/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedBarrelSuperClusters_cfi.py deleted file mode 100644 index da39124acebdf..0000000000000 --- a/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedBarrelSuperClusters_cfi.py +++ /dev/null @@ -1,8 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -gsFixedRefinedBarrelSuperClusters = cms.EDProducer("EGRefinedSCFixer", - fixedSC=cms.InputTag("particleFlowSuperClusterECALGSFixed","particleFlowSuperClusterECALBarrel"), - orgSC=cms.InputTag("particleFlowSuperClusterECAL","particleFlowSuperClusterECALBarrel",processName=cms.InputTag.skipCurrentProcess()), - orgRefinedSC=cms.InputTag("particleFlowEGamma",processName=cms.InputTag.skipCurrentProcess()), - fixedPFClusters=cms.InputTag("particleFlowClusterECALGSFixed"), - ) diff --git a/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py b/RecoEcal/EgammaClusterProducers/python/particleFlowEGammaGSFixed_cfi.py similarity index 88% rename from RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py rename to RecoEcal/EgammaClusterProducers/python/particleFlowEGammaGSFixed_cfi.py index 536806421e97a..1ee78699b1476 100644 --- a/RecoEcal/EgammaClusterProducers/python/gsFixedRefinedSuperClusters_cfi.py +++ b/RecoEcal/EgammaClusterProducers/python/particleFlowEGammaGSFixed_cfi.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms -gsFixedRefinedSuperClusters = cms.EDProducer("EGRefinedSCFixer", +particleFlowEGammaGSFixed = cms.EDProducer("EGRefinedSCFixer", orgRefinedSC = cms.InputTag("particleFlowEGamma", '', cms.InputTag.skipCurrentProcess()), orgSC = cms.InputTag("particleFlowSuperClusterECAL", '', cms.InputTag.skipCurrentProcess()), fixedSC = cms.InputTag("particleFlowSuperClusterECALGSFixed"), diff --git a/RecoEgamma/EgammaElectronProducers/python/gsFixedGsfElectronCores_cfi.py b/RecoEgamma/EgammaElectronProducers/python/gedGsfElectronCoresGSFixed_cfi.py similarity index 59% rename from RecoEgamma/EgammaElectronProducers/python/gsFixedGsfElectronCores_cfi.py rename to RecoEgamma/EgammaElectronProducers/python/gedGsfElectronCoresGSFixed_cfi.py index 0bf8548605056..74c277f78b1c6 100644 --- a/RecoEgamma/EgammaElectronProducers/python/gsFixedGsfElectronCores_cfi.py +++ b/RecoEgamma/EgammaElectronProducers/python/gedGsfElectronCoresGSFixed_cfi.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms -gsFixedGsfElectronCores = cms.EDProducer("GsfElectronCoreGSCrysFixer", +gedGsfElectronCoresGSFixed = cms.EDProducer("GsfElectronCoreGSCrysFixer", orgCores=cms.InputTag("gedGsfElectronCores", '', cms.InputTag.skipCurrentProcess()), - refinedSCs = cms.InputTag('gsFixedRefinedSuperClusters'), + refinedSCs = cms.InputTag('particleFlowEGammaGSFixed'), scs = cms.InputTag('particleFlowSuperClusterECALGSFixed'), ) diff --git a/RecoEgamma/EgammaElectronProducers/python/gsFixedGsfElectrons_cfi.py b/RecoEgamma/EgammaElectronProducers/python/gedGsfElectronsGSFixed_cfi.py similarity index 75% rename from RecoEgamma/EgammaElectronProducers/python/gsFixedGsfElectrons_cfi.py rename to RecoEgamma/EgammaElectronProducers/python/gedGsfElectronsGSFixed_cfi.py index 92105041be951..351b9c3d2c8a3 100644 --- a/RecoEgamma/EgammaElectronProducers/python/gsFixedGsfElectrons_cfi.py +++ b/RecoEgamma/EgammaElectronProducers/python/gedGsfElectronsGSFixed_cfi.py @@ -1,8 +1,8 @@ import FWCore.ParameterSet.Config as cms from RecoEgamma.EgammaTools.regressionModifier_cfi import regressionModifier -gsFixedGsfElectrons = cms.EDProducer("GsfElectronGSCrysFixer", - newCores=cms.InputTag("gsFixedGsfElectronCores"), +gedGsfElectronsGSFixed = cms.EDProducer("GsfElectronGSCrysFixer", + newCores=cms.InputTag("gedGsfElectronCoresGSFixed"), oldEles=cms.InputTag("gedGsfElectrons", '', cms.InputTag.skipCurrentProcess()), ebRecHits=cms.InputTag("ecalMultiAndGSGlobalRecHitEB"), regressionConfig = regressionModifier.clone(rhoCollection=cms.InputTag("fixedGridRhoFastjetAllTmp")), diff --git a/RecoEgamma/EgammaPhotonProducers/python/gedPhotonCoreGSFixed_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/gedPhotonCoreGSFixed_cfi.py new file mode 100644 index 0000000000000..15cf14c7ceeee --- /dev/null +++ b/RecoEgamma/EgammaPhotonProducers/python/gedPhotonCoreGSFixed_cfi.py @@ -0,0 +1,9 @@ +import FWCore.ParameterSet.Config as cms + +gedPhotonCoreGSFixed = cms.EDProducer("GEDPhotonCoreGSCrysFixer", + photonCores = cms.InputTag("gedPhotonCore", '', cms.InputTag.skipCurrentProcess()), + refinedSCs = cms.InputTag('particleFlowEGammaGSFixed'), + scs = cms.InputTag('particleFlowSuperClusterECALGSFixed'), + conversions = cms.InputTag('allConversions'), + singleconversions = cms.InputTag('particleFlowEGamma') +) diff --git a/RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotons_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/gedPhotonsGSFixed_cfi.py similarity index 90% rename from RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotons_cfi.py rename to RecoEgamma/EgammaPhotonProducers/python/gedPhotonsGSFixed_cfi.py index 5336b4a03b057..3dc521e1b5ce9 100644 --- a/RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotons_cfi.py +++ b/RecoEgamma/EgammaPhotonProducers/python/gedPhotonsGSFixed_cfi.py @@ -2,9 +2,9 @@ from RecoEgamma.EgammaTools.regressionModifier_cfi import * -gsFixedGEDPhotons = cms.EDProducer('GEDPhotonGSCrysFixer', +gedPhotonsGSFixed = cms.EDProducer('GEDPhotonGSCrysFixer', photons = cms.InputTag('gedPhotons', '', cms.InputTag.skipCurrentProcess()), - newCores = cms.InputTag('gsFixedGEDPhotonCores'), + newCores = cms.InputTag('gedPhotonCoreGSFixed'), barrelEcalHits=cms.InputTag("ecalMultiAndGSGlobalRecHitEB"), primaryVertexProducer = cms.InputTag('offlinePrimaryVerticesWithBS'), # rest for regression diff --git a/RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotonCores_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotonCores_cfi.py deleted file mode 100644 index 3257b46513ab0..0000000000000 --- a/RecoEgamma/EgammaPhotonProducers/python/gsFixedGEDPhotonCores_cfi.py +++ /dev/null @@ -1,9 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -gsFixedGEDPhotonCores = cms.EDProducer("GEDPhotonCoreGSCrysFixer", - photonCores = cms.InputTag("gedPhotonCore", '', cms.InputTag.skipCurrentProcess()), - refinedSCs = cms.InputTag('gsFixedRefinedSuperClusters'), - scs = cms.InputTag('particleFlowSuperClusterECALGSFixed'), - conversions = cms.InputTag('gsFixedConversions'), - singleconversions = cms.InputTag('gsFixedRefinedSuperClusters') -) diff --git a/RecoEgamma/EgammaTools/python/egammaGainSwitchFixForPAT_cff.py b/RecoEgamma/EgammaTools/python/egammaGainSwitchFixForPAT_cff.py index 44816b956017f..09b1418a8df00 100644 --- a/RecoEgamma/EgammaTools/python/egammaGainSwitchFixForPAT_cff.py +++ b/RecoEgamma/EgammaTools/python/egammaGainSwitchFixForPAT_cff.py @@ -2,43 +2,3 @@ from RecoEgamma.EgammaTools.egammaGainSwitchFix_cff import * -# rename the products that stay in AOD event content -particleFlowEGammaGSFixed = gsFixedRefinedSuperClusters.clone( - fixedSC = 'particleFlowSuperClusterECALGSFixed', - fixedPFClusters = 'particleFlowClusterECALGSFixed' -) -gedGsfElectronCoresGSFixed = gsFixedGsfElectronCores.clone( - refinedSCs = 'particleFlowEGammaGSFixed', - scs = 'particleFlowSuperClusterECALGSFixed' -) -gedGsfElectronsGSFixed = gsFixedGsfElectrons.clone( - newCores = 'gedGsfElectronCoresGSFixed' -) -gedPhotonCoreGSFixed = gsFixedGEDPhotonCores.clone( - refinedSCs = 'particleFlowEGammaGSFixed', - scs = 'particleFlowSuperClusterECALGSFixed', - conversions = 'allConversions', - singleconversions = 'particleFlowEGamma' -) -gedPhotonsGSFixed = gsFixedGEDPhotons.clone( - newCores = 'gedPhotonCoreGSFixed' -) - -gsFixedParticleFlowSuperClustering = cms.Sequence( - particleFlowRecHitECALGSFixed* - particleFlowRecHitPSGSFixed* - particleFlowClusterPSGSFixed* - particleFlowClusterECALUncorrectedGSFixed* - particleFlowClusterECALGSFixed* - particleFlowSuperClusterECALGSFixed -) - -egammaGainSwitchFixSequence = cms.Sequence( - egammaGainSwitchLocalFixSequence* - gsFixedParticleFlowSuperClustering* - particleFlowEGammaGSFixed* - gedGsfElectronCoresGSFixed* - gedGsfElectronsGSFixed* - gedPhotonCoreGSFixed* - gedPhotonsGSFixed -) diff --git a/RecoEgamma/EgammaTools/python/egammaGainSwitchFix_cff.py b/RecoEgamma/EgammaTools/python/egammaGainSwitchFix_cff.py index 945f428e89a1c..07a127b585e82 100644 --- a/RecoEgamma/EgammaTools/python/egammaGainSwitchFix_cff.py +++ b/RecoEgamma/EgammaTools/python/egammaGainSwitchFix_cff.py @@ -9,15 +9,15 @@ from RecoEcal.EgammaClusterProducers.gsFixedSuperClustering_cff import * #this module remakes the refined EGamma superclusters although it has to approximate them as there is not #enough info in AOD to properly remake them -from RecoEcal.EgammaClusterProducers.gsFixedRefinedSuperClusters_cfi import * +from RecoEcal.EgammaClusterProducers.particleFlowEGammaGSFixed_cfi import particleFlowEGammaGSFixed #this makes makes a new colleciton of gsfelectron cores, modifying only those that have a gs eb crystal -from RecoEgamma.EgammaElectronProducers.gsFixedGsfElectronCores_cfi import * +from RecoEgamma.EgammaElectronProducers.gedGsfElectronCoresGSFixed_cfi import gedGsfElectronCoresGSFixed #turns the cores into gsf electrons, again only modifying those which have a gs eb crystal -from RecoEgamma.EgammaElectronProducers.gsFixedGsfElectrons_cfi import * +from RecoEgamma.EgammaElectronProducers.gedGsfElectronsGSFixed_cfi import gedGsfElectronsGSFixed #this makes makes a new colleciton of photon cores, modifying only those that have a gs eb crystal -from RecoEgamma.EgammaPhotonProducers.gsFixedGEDPhotonCores_cfi import * +from RecoEgamma.EgammaPhotonProducers.gedPhotonCoreGSFixed_cfi import gedPhotonCoreGSFixed #turns the cores into photons, again only modifying those which have a gs eb crystal -from RecoEgamma.EgammaPhotonProducers.gsFixedGEDPhotons_cfi import * +from RecoEgamma.EgammaPhotonProducers.gedPhotonsGSFixed_cfi import gedPhotonsGSFixed egammaGainSwitchLocalFixSequence = cms.Sequence( ecalGlobalLocalRecoFromSelectedDigis* @@ -27,9 +27,9 @@ egammaGainSwitchFixSequence = cms.Sequence( egammaGainSwitchLocalFixSequence* gsFixedParticleFlowSuperClustering* - gsFixedRefinedSuperClusters* - gsFixedGsfElectronCores* - gsFixedGsfElectrons* - gsFixedGEDPhotonCores* - gsFixedGEDPhotons + particleFlowEGammaGSFixed* + gedGsfElectronCoresGSFixed* + gedGsfElectronsGSFixed* + gedPhotonCoreGSFixed* + gedPhotonsGSFixed ) From fca2430ff6846777a5ea3d13edcf918ad427d9e3 Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Mon, 30 Jan 2017 16:34:13 +0000 Subject: [PATCH 4/4] clean up --- .../gsBrokenToGSFixedSuperClustersMap_cfi.py | 8 -- .../src/MapNewToOldSCs.cc | 96 ------------------- .../python/gsSimpleFixedPhotons_cfi.py | 0 .../src}/PhotonGSCrysSimpleFixer.cc | 0 .../EgammaTools/test/gsSimpleFixTest_cfg.py | 64 ------------- 5 files changed, 168 deletions(-) delete mode 100644 RecoEcal/EgammaClusterProducers/python/gsBrokenToGSFixedSuperClustersMap_cfi.py delete mode 100644 RecoEcal/EgammaClusterProducers/src/MapNewToOldSCs.cc rename RecoEgamma/{EgammaElectronProducers => EgammaPhotonProducers}/python/gsSimpleFixedPhotons_cfi.py (100%) rename RecoEgamma/{EgammaElectronProducers/plugins => EgammaPhotonProducers/src}/PhotonGSCrysSimpleFixer.cc (100%) delete mode 100644 RecoEgamma/EgammaTools/test/gsSimpleFixTest_cfg.py diff --git a/RecoEcal/EgammaClusterProducers/python/gsBrokenToGSFixedSuperClustersMap_cfi.py b/RecoEcal/EgammaClusterProducers/python/gsBrokenToGSFixedSuperClustersMap_cfi.py deleted file mode 100644 index 717a14a4f6f20..0000000000000 --- a/RecoEcal/EgammaClusterProducers/python/gsBrokenToGSFixedSuperClustersMap_cfi.py +++ /dev/null @@ -1,8 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -gsBrokenToGSFixedSuperClustersMap = cms.EDProducer("MapNewToOldSCs", - oldSC=cms.InputTag("particleFlowSuperClusterECAL","particleFlowSuperClusterECALBarrel",processName=cms.InputTag.skipCurrentProcess()), - newSC=cms.InputTag("particleFlowSuperClusterECALGSFixed","particleFlowSuperClusterECALBarrel"), - oldRefinedSC=cms.InputTag("particleFlowEGamma",processName=cms.InputTag.skipCurrentProcess()), - newRefinedSC=cms.InputTag("gsFixedRefinedBarrelSuperClusters") - ) diff --git a/RecoEcal/EgammaClusterProducers/src/MapNewToOldSCs.cc b/RecoEcal/EgammaClusterProducers/src/MapNewToOldSCs.cc deleted file mode 100644 index a098ea2fa732b..0000000000000 --- a/RecoEcal/EgammaClusterProducers/src/MapNewToOldSCs.cc +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef RecoEcal_EgammaClusterProducers_MapNewToOldSCs_h -#define RecoEcal_EgammaClusterProducers_MapNewToOldSCs_h - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" -#include "DataFormats/EgammaReco/interface/SuperCluster.h" -#include "DataFormats/Common/interface/ValueMap.h" -#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" -#include "DataFormats/EcalDetId/interface/EBDetId.h" -#include "RecoEgamma/EgammaTools/interface/GainSwitchTools.h" - -//this allows us to make the old superclusters to the new superclusters -//via a valuemap -class MapNewToOldSCs : public edm::stream::EDProducer<> { -public: - explicit MapNewToOldSCs(const edm::ParameterSet& ); - virtual ~MapNewToOldSCs(){} - virtual void produce(edm::Event &, const edm::EventSetup &); - - static void writeSCRefValueMap(edm::Event &iEvent, - const edm::Handle & handle, - const std::vector & values, - const std::string& label); -private: - edm::EDGetTokenT oldRefinedSCToken_; - edm::EDGetTokenT oldSCToken_; - edm::EDGetTokenT newSCToken_; - edm::EDGetTokenT newRefinedSCToken_; - - - - -}; - -MapNewToOldSCs::MapNewToOldSCs(const edm::ParameterSet& iConfig ) -{ - oldRefinedSCToken_ = consumes(iConfig.getParameter("oldRefinedSC")); - oldSCToken_ = consumes(iConfig.getParameter("oldSC")); - newSCToken_ = consumes(iConfig.getParameter("newSC")); - newRefinedSCToken_ = consumes(iConfig.getParameter("newRefinedSC")); - - produces >("parentSCs"); - produces >("refinedSCs"); - -} - -namespace { - template edm::Handle getHandle(const edm::Event& iEvent,const edm::EDGetTokenT& token){ - edm::Handle handle; - iEvent.getByToken(token,handle); - return handle; - } -} - -void MapNewToOldSCs::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) -{ - auto newRefinedSCs = getHandle(iEvent,newRefinedSCToken_); - auto newSCs = getHandle(iEvent,newSCToken_); - - auto oldRefinedSCs = getHandle(iEvent,oldRefinedSCToken_); - auto oldSCs = getHandle(iEvent,oldSCToken_); - - std::vector matchedNewSCs; - for(auto oldSC : *oldSCs){ - matchedNewSCs.push_back(GainSwitchTools::matchSCBySeedCrys(oldSC,newSCs,2,2)); - } - std::vector matchedNewRefinedSCs; - for(auto oldSC : *oldRefinedSCs){ - matchedNewRefinedSCs.push_back(GainSwitchTools::matchSCBySeedCrys(oldSC,newRefinedSCs,2,2)); - } - - writeSCRefValueMap(iEvent,oldSCs,matchedNewSCs,"parentSCs"); - writeSCRefValueMap(iEvent,oldRefinedSCs,matchedNewRefinedSCs,"refinedSCs"); - -} - -void MapNewToOldSCs::writeSCRefValueMap(edm::Event &iEvent, - const edm::Handle & handle, - const std::vector & values, - const std::string& label) -{ - std::unique_ptr > valMap(new edm::ValueMap()); - typename edm::ValueMap::Filler filler(*valMap); - filler.insert(handle, values.begin(), values.end()); - filler.fill(); - iEvent.put(std::move(valMap),label); -} - -DEFINE_FWK_MODULE(MapNewToOldSCs); - -#endif diff --git a/RecoEgamma/EgammaElectronProducers/python/gsSimpleFixedPhotons_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/gsSimpleFixedPhotons_cfi.py similarity index 100% rename from RecoEgamma/EgammaElectronProducers/python/gsSimpleFixedPhotons_cfi.py rename to RecoEgamma/EgammaPhotonProducers/python/gsSimpleFixedPhotons_cfi.py diff --git a/RecoEgamma/EgammaElectronProducers/plugins/PhotonGSCrysSimpleFixer.cc b/RecoEgamma/EgammaPhotonProducers/src/PhotonGSCrysSimpleFixer.cc similarity index 100% rename from RecoEgamma/EgammaElectronProducers/plugins/PhotonGSCrysSimpleFixer.cc rename to RecoEgamma/EgammaPhotonProducers/src/PhotonGSCrysSimpleFixer.cc diff --git a/RecoEgamma/EgammaTools/test/gsSimpleFixTest_cfg.py b/RecoEgamma/EgammaTools/test/gsSimpleFixTest_cfg.py deleted file mode 100644 index ddfcb7b77a8d1..0000000000000 --- a/RecoEgamma/EgammaTools/test/gsSimpleFixTest_cfg.py +++ /dev/null @@ -1,64 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -# set up process -process = cms.Process("GSFIX") -process.load("FWCore.MessageService.MessageLogger_cfi") -process.MessageLogger.cerr.FwkReport = cms.untracked.PSet( - reportEvery = cms.untracked.int32(1000), - limit = cms.untracked.int32(10000000) -) -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') - -#setup global tag -from Configuration.AlCa.GlobalTag import GlobalTag -from Configuration.AlCa.autoCond import autoCond -process.GlobalTag = GlobalTag(process.GlobalTag, '80X_dataRun2_2016SeptRepro_v3', '') # - - -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) -process.source = cms.Source ("PoolSource",fileNames = cms.untracked.vstring( - #"file:/opt/ppd/scratch/harper/dataFiles/DoubleEG_Run2016G-23Sep2016-v1_DiHEEPWOSS_GainSwitch_1.root", - "/store/user/sharper/EventSkim/DiHEEPWOSS_GainSwitch/AOD/DoubleEG/Run2016G-23Sep2016-v1_AOD_DiHEEPWOSS_GainSwitch/170112_185336/0000/DoubleEG_Run2016G-23Sep2016-v1_DiHEEPWOSS_GainSwitch_1.root", - ) -) - - -#defines our sequences to remake the electrons and photons -#there are currently two sequences, egammaGainSwitchFixSequence and -#egammaGainSwitchSimpleFixSequence -# -#egammaGainSwitchFixSequence: remakes the superclusters and then can correctly -# redo the electrons and photons (photons not implimented) -# -#egammaGainSwitchSimpleFixSequence: just corrects electorns and photons energy and showershape -# correction is ( supercluster raw energy - E(gain switched multi fit hits) + E(gain switched weights hits) ) / supercluster raw energy -# does not correct photon H/E or R9 - -process.load("RecoEgamma.EgammaTools.egammaGainSwitchFix_cff") -process.p = cms.Path(process.egammaGainSwitchSimpleFixSequence) - - - -#dumps the products made for easier debugging, you wouldnt normally need to do this -#edmDumpEventContent outputTest.root shows you all the products produced -#will be very slow when this is happening -process.load('Configuration.EventContent.EventContent_cff') -process.output = cms.OutputModule("PoolOutputModule", - compressionAlgorithm = cms.untracked.string('LZMA'), - compressionLevel = cms.untracked.int32(4), - dataset = cms.untracked.PSet( - dataTier = cms.untracked.string('MINIAODSIM'), - filterName = cms.untracked.string('') - ), - dropMetaData = cms.untracked.string('ALL'), - eventAutoFlushCompressedSize = cms.untracked.int32(15728640), - fastCloning = cms.untracked.bool(False), - fileName = cms.untracked.string('outputTest.root'), - outputCommands = process.MINIAODSIMEventContent.outputCommands, - overrideInputFileSplitLevels = cms.untracked.bool(True) -) -process.output.outputCommands = cms.untracked.vstring('keep *_*_*_*', - ) -process.outPath = cms.EndPath(process.output)