diff --git a/DataFormats/EgammaCandidates/interface/GsfElectron.h b/DataFormats/EgammaCandidates/interface/GsfElectron.h index af5f4ac1f8dd2..2929ed412d206 100644 --- a/DataFormats/EgammaCandidates/interface/GsfElectron.h +++ b/DataFormats/EgammaCandidates/interface/GsfElectron.h @@ -163,6 +163,7 @@ class GsfElectron : public RecoCandidate // accessors virtual GsfElectronCoreRef core() const ; + void setCore(const reco::GsfElectronCoreRef &core) { core_ = core; } // forward core methods virtual SuperClusterRef superCluster() const { return core()->superCluster() ; } diff --git a/DataFormats/EgammaCandidates/interface/Photon.h b/DataFormats/EgammaCandidates/interface/Photon.h index c4047f3b8b599..b788662dc1d37 100644 --- a/DataFormats/EgammaCandidates/interface/Photon.h +++ b/DataFormats/EgammaCandidates/interface/Photon.h @@ -47,6 +47,8 @@ namespace reco { /// returns a reference to the core photon object reco::PhotonCoreRef photonCore() const { return photonCore_;} + void setPhotonCore(const reco::PhotonCoreRef &photonCore) { photonCore_ = photonCore; } + // /// Retrieve photonCore attributes // diff --git a/DataFormats/EgammaCandidates/interface/PhotonCore.h b/DataFormats/EgammaCandidates/interface/PhotonCore.h index 4cf3fbd139317..afe8be91460b1 100644 --- a/DataFormats/EgammaCandidates/interface/PhotonCore.h +++ b/DataFormats/EgammaCandidates/interface/PhotonCore.h @@ -76,6 +76,9 @@ namespace reco { /// get vector of references to one leg Conversion's reco::ConversionRefVector conversionsOneLeg() const {return conversionsOneLeg_;} + void setConversions(const reco::ConversionRefVector &conversions) { conversions_ = conversions; } + void setConversionsOneLeg(const reco::ConversionRefVector &conversions) { conversionsOneLeg_ = conversions; } + /// get reference to electron seed if existing reco::ElectronSeedRefVector electronPixelSeeds() const {return electronSeed_;} bool isPFlowPhoton() const {return isPFlowPhoton_;} diff --git a/DataFormats/EgammaReco/interface/SuperCluster.h b/DataFormats/EgammaReco/interface/SuperCluster.h index fd54c9ba34a87..2e5311fa29fba 100644 --- a/DataFormats/EgammaReco/interface/SuperCluster.h +++ b/DataFormats/EgammaReco/interface/SuperCluster.h @@ -104,6 +104,9 @@ namespace reco { //(re)-set preshower clusters void setPreshowerClusters(const CaloClusterPtrVector &clusters) { preshowerClusters_ = clusters; } + //clear hits and fractions vector (for slimming) + void clearHitsAndFractions() { hitsAndFractions_.clear(); } + /// add reference to constituent BasicCluster void addCluster( const CaloClusterPtr & r ) { clusters_.push_back( r ); diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index e6cb5e03ba791..bb46a78141192 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -14,15 +14,56 @@ def miniAOD_customizeCommon(process): process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track # - process.patElectrons.embedPflowSuperCluster = False - process.patElectrons.embedPflowBasicClusters = False - process.patElectrons.embedPflowPreshowerClusters = False + # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer + process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core + process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster + process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster + process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster + process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters + process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters + process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters + process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters + process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer + process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") + process.patElectrons.electronIDSources = cms.PSet( + # configure many IDs as InputTag = you + # can comment out those you don't want to save some disk space + eidRobustLoose = cms.InputTag("reducedEgamma","eidRobustLoose"), + eidRobustTight = cms.InputTag("reducedEgamma","eidRobustTight"), + eidLoose = cms.InputTag("reducedEgamma","eidLoose"), + eidTight = cms.InputTag("reducedEgamma","eidTight"), + eidRobustHighEnergy = cms.InputTag("reducedEgamma","eidRobustHighEnergy"), + ) + process.elPFIsoDepositCharged.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") + process.elPFIsoDepositChargedAll.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") + process.elPFIsoDepositNeutral.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") + process.elPFIsoDepositGamma.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") + process.elPFIsoDepositPU.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") + # + process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster + process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster + process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters + process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters + process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer + process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons") + process.patPhotons.photonIDSources = cms.PSet( + PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma', + 'PhotonCutBasedIDLoose'), + PhotonCutBasedIDTight = cms.InputTag('reducedEgamma', + 'PhotonCutBasedIDTight') + ) + + process.phPFIsoDepositCharged.src = cms.InputTag("reducedEgamma","reducedGedPhotons") + process.phPFIsoDepositChargedAll.src = cms.InputTag("reducedEgamma","reducedGedPhotons") + process.phPFIsoDepositNeutral.src = cms.InputTag("reducedEgamma","reducedGedPhotons") + process.phPFIsoDepositGamma.src = cms.InputTag("reducedEgamma","reducedGedPhotons") + process.phPFIsoDepositPU.src = cms.InputTag("reducedEgamma","reducedGedPhotons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))") process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string("pt > 20 && tauID('decayModeFinding')> 0.5") - process.selectedPatPhotons.cut = cms.string("pt > 15 && hadTowOverEm()<0.15 ") + process.selectedPatPhotons.cut = cms.string("") # from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection # @@ -59,7 +100,9 @@ def miniAOD_customizeCommon(process): def miniAOD_customizeMC(process): process.muonMatch.matched = "prunedGenParticles" process.electronMatch.matched = "prunedGenParticles" + process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.photonMatch.matched = "prunedGenParticles" + process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.tauMatch.matched = "prunedGenParticles" process.patJetPartonMatch.matched = "prunedGenParticles" process.patJetGenJetMatch.matched = "slimmedGenJets" diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedElectrons_cfi.py b/PhysicsTools/PatAlgos/python/slimming/slimmedElectrons_cfi.py index 687f6640b3c20..7cc235f706286 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedElectrons_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedElectrons_cfi.py @@ -3,18 +3,18 @@ slimmedElectrons = cms.EDProducer("PATElectronSlimmer", src = cms.InputTag("selectedPatElectrons"), dropSuperCluster = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 - dropBasicClusters = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 - dropPFlowClusters = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 - dropPreshowerClusters = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 - dropSeedCluster = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 - dropRecHits = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 + dropBasicClusters = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 + dropPFlowClusters = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 + dropPreshowerClusters = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 + dropSeedCluster = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 + dropRecHits = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 dropCorrections = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 dropIsolations = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 dropShapes = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 dropExtrapolations = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 dropClassifications = cms.string("pt < 5"), # you can put a cut to slim selectively, e.g. pt < 10 linkToPackedPFCandidates = cms.bool(True), - recoToPFMap = cms.InputTag("particleBasedIsolation","gedGsfElectrons"), + recoToPFMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap"), packedPFCandidates = cms.InputTag("packedPFCandidates"), saveNonZSClusterShapes = cms.string("pt > 5"), # save additional user floats: (sigmaIetaIeta,sigmaIphiIphi,sigmaIetaIphi,r9,e1x5_over_e5x5)_NoZS ) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedPhotons_cfi.py b/PhysicsTools/PatAlgos/python/slimming/slimmedPhotons_cfi.py index 895fcb647b882..78503ee6f1dd8 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedPhotons_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedPhotons_cfi.py @@ -3,12 +3,12 @@ slimmedPhotons = cms.EDProducer("PATPhotonSlimmer", src = cms.InputTag("selectedPatPhotons"), dropSuperCluster = cms.string("0"), # always keep SC? # ! (r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), # you can put a cut to slim selectively, e.g. pt < 10 - dropBasicClusters = cms.string("! (r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), # you can put a cut to slim selectively, e.g. pt < 10 - dropPreshowerClusters = cms.string("! (r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), # you can put a cut to slim selectively, e.g. pt < 10 + dropBasicClusters = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 + dropPreshowerClusters = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 dropSeedCluster = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 - dropRecHits = cms.string("! (r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), # you can put a cut to slim selectively, e.g. pt < 10 + dropRecHits = cms.string("0"), # you can put a cut to slim selectively, e.g. pt < 10 linkToPackedPFCandidates = cms.bool(True), - recoToPFMap = cms.InputTag("particleBasedIsolation","gedPhotons"), + recoToPFMap = cms.InputTag("reducedEgamma","reducedPhotonPfCandMap"), packedPFCandidates = cms.InputTag("packedPFCandidates"), saveNonZSClusterShapes = cms.string("(r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), # save additional user floats: (sigmaIetaIeta,sigmaIphiIphi,sigmaIetaIphi,r9,e1x5_over_e5x5)_NoZS ) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py index 2571b3694abc0..b51f315dae5ad 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py @@ -27,6 +27,14 @@ 'keep *_slimmedSecondaryVertices*_*_*', ## add extra METs + 'keep recoPhotonCores_reducedEgamma_*_*', + 'keep recoGsfElectronCores_reducedEgamma_*_*', + 'keep recoConversions_reducedEgamma_*_*', + 'keep recoSuperClusters_reducedEgamma_*_*', + 'keep recoCaloClusters_reducedEgamma_*_*', + 'keep EcalRecHitsSorted_reducedEgamma_*_*', + + 'drop *_*_caloTowers_*', 'drop *_*_pfCandidates_*', 'drop *_*_genJets_*', diff --git a/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini.py b/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini.py index 37e0259853f80..30ea329083cac 100644 --- a/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini.py +++ b/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini.py @@ -4,6 +4,7 @@ process.options.allowUnscheduled = cms.untracked.bool(True) #process.Tracer = cms.Service("Tracer") +process.load("RecoEgamma.EgammaPhotonProducers.reducedEgamma_cfi") process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff") process.load("PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff") diff --git a/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini_data.py b/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini_data.py index 67070eacf71c7..85e67c7dc1c30 100644 --- a/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini_data.py +++ b/PhysicsTools/PatAlgos/test/miniAOD/patTuple_mini_data.py @@ -4,6 +4,7 @@ process.options.allowUnscheduled = cms.untracked.bool(True) #process.Tracer = cms.Service("Tracer") +process.load("RecoEgamma.EgammaPhotonProducers.reducedEgamma_cfi") process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff") process.load("PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff") diff --git a/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h b/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h new file mode 100644 index 0000000000000..6a83eb6ad0352 --- /dev/null +++ b/RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h @@ -0,0 +1,106 @@ +#ifndef RecoEgamma_EgammaPhotonProducers_ReducedEGProducer_h +#define RecoEgamma_EgammaPhotonProducers_ReducedEGProducer_h +/** \class ReducedEGProducer + ** + ** Select subset of electrons and photons from input collections and + ** produced consistently relinked output collections including + ** associated SuperClusters, CaloClusters and ecal RecHits + ** + ** \author J.Bendavid (CERN) + ** + ***/ + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloTopology/interface/CaloTopology.h" +#include "DataFormats/EgammaCandidates/interface/Conversion.h" +#include "DataFormats/EgammaReco/interface/BasicCluster.h" +#include "DataFormats/EgammaReco/interface/SuperCluster.h" +#include "DataFormats/EgammaCandidates/interface/Photon.h" +#include "DataFormats/EgammaCandidates/interface/PhotonCore.h" +#include "DataFormats/EgammaReco/interface/BasicClusterShapeAssociation.h" +#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h" +#include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h" +#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" +#include "RecoEgamma/EgammaIsolationAlgos/interface/PfBlockBasedIsolation.h" +#include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollections.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h" +#include "RecoEgamma/PhotonIdentification/interface/PFPhotonIsolationCalculator.h" +#include "RecoEgamma/PhotonIdentification/interface/PhotonIsolationCalculator.h" +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" +#include "RecoEgamma/PhotonIdentification/interface/PhotonMIPHaloTagger.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionBaseClass.h" +#include "CondFormats/EcalObjects/interface/EcalFunctionParameters.h" +#include "RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h" + +#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" + +#include "CommonTools/UtilAlgos/interface/StringCutObjectSelector.h" + + +// ReducedEGProducer inherits from EDProducer, so it can be a module: +class ReducedEGProducer : public edm::EDProducer { + + public: + + ReducedEGProducer (const edm::ParameterSet& ps); + ~ReducedEGProducer(); + + virtual void produce(edm::Event& evt, const edm::EventSetup& es); + + private: + + //tokens for input collections + edm::EDGetTokenT photonT_; + edm::EDGetTokenT gsfElectronT_; + edm::EDGetTokenT conversionT_; + edm::EDGetTokenT singleConversionT_; + + edm::EDGetTokenT barrelEcalHits_; + edm::EDGetTokenT endcapEcalHits_; + edm::EDGetTokenT preshowerEcalHits_; + + edm::EDGetTokenT > > photonPfCandMapT_; + edm::EDGetTokenT > > gsfElectronPfCandMapT_; + + std::vector > > photonIdTs_; + std::vector > > gsfElectronIdTs_; + + //names for output collections + std::string outPhotons_; + std::string outPhotonCores_; + std::string outGsfElectrons_; + std::string outGsfElectronCores_; + std::string outConversions_; + std::string outSingleConversions_; + std::string outSuperClusters_; + std::string outEBEEClusters_; + std::string outESClusters_; + std::string outEBRecHits_; + std::string outEERecHits_; + std::string outESRecHits_; + std::string outPhotonPfCandMap_; + std::string outGsfElectronPfCandMap_; + std::vector outPhotonIds_; + std::vector outGsfElectronIds_; + + StringCutObjectSelector keepPhotonSel_; + StringCutObjectSelector slimRelinkPhotonSel_; + StringCutObjectSelector relinkPhotonSel_; + StringCutObjectSelector keepGsfElectronSel_; + StringCutObjectSelector slimRelinkGsfElectronSel_; + StringCutObjectSelector relinkGsfElectronSel_; + + + +}; +#endif + + diff --git a/RecoEgamma/EgammaPhotonProducers/python/reducedEgamma_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/reducedEgamma_cfi.py new file mode 100644 index 0000000000000..24af36d7d1b87 --- /dev/null +++ b/RecoEgamma/EgammaPhotonProducers/python/reducedEgamma_cfi.py @@ -0,0 +1,45 @@ +import FWCore.ParameterSet.Config as cms + +reducedEgamma = cms.EDProducer("ReducedEGProducer", + keepPhotons = cms.string("pt > 14 && hadTowOverEm()<0.15"), #keep in output + slimRelinkPhotons = cms.string("pt > 14 && hadTowOverEm()<0.15"), #keep only slimmed SuperCluster plus seed cluster + relinkPhotons = cms.string("(r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), #keep all associated clusters/rechits/conversions + keepGsfElectrons = cms.string(""), #keep in output + slimRelinkGsfElectrons = cms.string(""), #keep only slimmed SuperCluster plus seed cluster + relinkGsfElectrons = cms.string("pt>5"), #keep all associated clusters/rechits/conversions + photons = cms.InputTag("gedPhotons"), + gsfElectrons = cms.InputTag("gedGsfElectrons"), + conversions = cms.InputTag("allConversions"), + singleConversions = cms.InputTag("gedPhotonCore"), + barrelEcalHits = cms.InputTag("reducedEcalRecHitsEB"), + endcapEcalHits = cms.InputTag("reducedEcalRecHitsEE"), + preshowerEcalHits = cms.InputTag("reducedEcalRecHitsES"), + photonsPFValMap = cms.InputTag("particleBasedIsolation","gedPhotons"), + gsfElectronsPFValMap = cms.InputTag("particleBasedIsolation","gedGsfElectrons"), + photonIDSources = cms.VInputTag( + cms.InputTag("PhotonIDProdGED","PhotonCutBasedIDLoose"), + cms.InputTag("PhotonIDProdGED","PhotonCutBasedIDLooseEM"), + cms.InputTag("PhotonIDProdGED","PhotonCutBasedIDTight") + ), + photonIDOutput = cms.vstring( + "PhotonCutBasedIDLoose", + "PhotonCutBasedIDLooseEM", + "PhotonCutBasedIDTight", + ), + gsfElectronIDSources = cms.VInputTag( + cms.InputTag("eidLoose"), + cms.InputTag("eidRobustHighEnergy"), + cms.InputTag("eidRobustLoose"), + cms.InputTag("eidRobustTight"), + cms.InputTag("eidTight"), + ), + gsfElectronIDOutput = cms.vstring( + "eidLoose", + "eidRobustHighEnergy", + "eidRobustLoose", + "eidRobustTight", + "eidTight", + ), +) + + diff --git a/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc new file mode 100644 index 0000000000000..594329dbaec38 --- /dev/null +++ b/RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc @@ -0,0 +1,656 @@ +#include +#include +#include + +// Framework +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "CommonTools/Utils/interface/StringToEnumValue.h" + +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/CaloTopology/interface/CaloTopology.h" +#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" + + +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/EgammaReco/interface/ClusterShape.h" +#include "DataFormats/EgammaCandidates/interface/PhotonCore.h" +#include "DataFormats/EgammaCandidates/interface/Photon.h" +#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" +#include "DataFormats/EgammaCandidates/interface/Conversion.h" +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtraFwd.h" + + +#include "DataFormats/EgammaReco/interface/ElectronSeed.h" +#include "RecoCaloTools/Selectors/interface/CaloConeSelector.h" + +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" + +#include "RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h" +#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h" + +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionBaseClass.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h" +#include "RecoEcal/EgammaCoreTools/plugins/EcalClusterCrackCorrection.h" +#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaHadTower.h" + +#include "RecoEgamma/EgammaTools/interface/ConversionTools.h" + +ReducedEGProducer::ReducedEGProducer(const edm::ParameterSet& config) : + keepPhotonSel_(config.getParameter("keepPhotons")), + slimRelinkPhotonSel_(config.getParameter("slimRelinkPhotons")), + relinkPhotonSel_(config.getParameter("relinkPhotons")), + keepGsfElectronSel_(config.getParameter("keepGsfElectrons")), + slimRelinkGsfElectronSel_(config.getParameter("slimRelinkGsfElectrons")), + relinkGsfElectronSel_(config.getParameter("relinkGsfElectrons")) +{ + + + photonT_ = consumes(config.getParameter("photons")); + gsfElectronT_ = consumes(config.getParameter("gsfElectrons")); + conversionT_ = consumes(config.getParameter("conversions")); + singleConversionT_ = consumes(config.getParameter("singleConversions")); + + barrelEcalHits_ = + consumes(config.getParameter("barrelEcalHits")); + endcapEcalHits_ = + consumes(config.getParameter("endcapEcalHits")); + preshowerEcalHits_ = + consumes(config.getParameter("preshowerEcalHits")); + + photonPfCandMapT_ = consumes > >(config.getParameter("photonsPFValMap")); + gsfElectronPfCandMapT_ = consumes > >(config.getParameter("gsfElectronsPFValMap")); + + std::vector photonidinputs(config.getParameter >("photonIDSources")); + for (edm::InputTag &tag : photonidinputs) { + photonIdTs_.emplace_back(consumes >(tag)); + } + + std::vector gsfelectronidinputs(config.getParameter >("gsfElectronIDSources")); + for (edm::InputTag &tag : gsfelectronidinputs) { + gsfElectronIdTs_.emplace_back(consumes >(tag)); + } + + //output collections + outPhotons_ = "reducedGedPhotons"; + outPhotonCores_ = "reducedGedPhotonCores"; + outGsfElectrons_ = "reducedGedGsfElectrons"; + outGsfElectronCores_ = "reducedGedGsfElectronCores"; + outConversions_ = "reducedConversions"; + outSingleConversions_ = "reducedSingleLegConversions"; + outSuperClusters_ = "reducedSuperClusters"; + outEBEEClusters_ = "reducedEBEEClusters"; + outESClusters_ = "reducedESClusters"; + outEBRecHits_ = "reducedEBRecHits"; + outEERecHits_ = "reducedEERecHits"; + outESRecHits_ = "reducedESRecHits"; + outPhotonPfCandMap_ = "reducedPhotonPfCandMap"; + outGsfElectronPfCandMap_ = "reducedGsfElectronPfCandMap"; + outPhotonIds_ = config.getParameter >("photonIDOutput"); + outGsfElectronIds_ = config.getParameter >("gsfElectronIDOutput"); + + + produces< reco::PhotonCollection >(outPhotons_); + produces< reco::PhotonCoreCollection >(outPhotonCores_); + produces< reco::GsfElectronCollection >(outGsfElectrons_); + produces< reco::GsfElectronCoreCollection >(outGsfElectronCores_); + produces< reco::ConversionCollection >(outConversions_); + produces< reco::ConversionCollection >(outSingleConversions_); + produces< reco::SuperClusterCollection >(outSuperClusters_); + produces< reco::CaloClusterCollection >(outEBEEClusters_); + produces< reco::CaloClusterCollection >(outESClusters_); + produces< EcalRecHitCollection >(outEBRecHits_); + produces< EcalRecHitCollection >(outEERecHits_); + produces< EcalRecHitCollection >(outESRecHits_); + produces< edm::ValueMap > >(outPhotonPfCandMap_); + produces< edm::ValueMap > >(outGsfElectronPfCandMap_); + for (const std::string &outid : outPhotonIds_) { + produces< edm::ValueMap >(outid); + } + for (const std::string &outid : outGsfElectronIds_) { + produces< edm::ValueMap >(outid); + } + +} + +ReducedEGProducer::~ReducedEGProducer() +{ +} + + + + +void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& theEventSetup) { + + //get input collections + + + edm::Handle photonHandle; + theEvent.getByToken(photonT_, photonHandle); + + edm::Handle gsfElectronHandle; + theEvent.getByToken(gsfElectronT_, gsfElectronHandle); + + edm::Handle conversionHandle; + theEvent.getByToken(conversionT_, conversionHandle); + + edm::Handle singleConversionHandle; + theEvent.getByToken(singleConversionT_, singleConversionHandle); + + edm::Handle barrelHitHandle; + theEvent.getByToken(barrelEcalHits_, barrelHitHandle); + + edm::Handle endcapHitHandle; + theEvent.getByToken(endcapEcalHits_, endcapHitHandle); + + edm::Handle preshowerHitHandle; + theEvent.getByToken(preshowerEcalHits_, preshowerHitHandle); + + edm::Handle > > photonPfCandMapHandle; + theEvent.getByToken(photonPfCandMapT_, photonPfCandMapHandle); + + edm::Handle > > gsfElectronPfCandMapHandle; + theEvent.getByToken(gsfElectronPfCandMapT_, gsfElectronPfCandMapHandle); + + std::vector > > photonIdHandles(photonIdTs_.size()); + for (unsigned int itok=0; itok > > gsfElectronIdHandles(gsfElectronIdTs_.size()); + for (unsigned int itok=0; itok theCaloTopology; + theEventSetup.get().get(theCaloTopology); + const CaloTopology *caloTopology = & (*theCaloTopology); + + //initialize output collections + std::auto_ptr photons(new reco::PhotonCollection); + std::auto_ptr photonCores(new reco::PhotonCoreCollection); + std::auto_ptr gsfElectrons(new reco::GsfElectronCollection); + std::auto_ptr gsfElectronCores(new reco::GsfElectronCoreCollection); + std::auto_ptr conversions(new reco::ConversionCollection); + std::auto_ptr singleConversions(new reco::ConversionCollection); + std::auto_ptr superClusters(new reco::SuperClusterCollection); + std::auto_ptr ebeeClusters(new reco::CaloClusterCollection); + std::auto_ptr esClusters(new reco::CaloClusterCollection); + std::auto_ptr ebRecHits(new EcalRecHitCollection); + std::auto_ptr eeRecHits(new EcalRecHitCollection); + std::auto_ptr esRecHits(new EcalRecHitCollection); + std::auto_ptr > > photonPfCandMap(new edm::ValueMap >); + std::auto_ptr > > gsfElectronPfCandMap(new edm::ValueMap >); + + std::vector > > photonIds; + for (unsigned int iid=0; iid); + } + + std::vector > > gsfElectronIds; + for (unsigned int iid=0; iid); + } + + //maps to collection indices of output objects + std::map photonCoreMap; + std::map gsfElectronCoreMap; + std::map conversionMap; + std::map singleConversionMap; + std::map superClusterMap; + std::map ebeeClusterMap; + std::map esClusterMap; + std::set rechitMap; + + std::set superClusterFullRelinkMap; + + //vectors for pfcandidate valuemaps + std::vector> pfCandIsoPairVecPho; + std::vector> pfCandIsoPairVecEle; + + //vectors for id valuemaps + std::vector > photonIdVals(photonIds.size()); + std::vector > gsfElectronIdVals(gsfElectronIds.size()); + + //loop over photons and fill maps + for (unsigned int ipho=0; iphosize(); ++ipho) { + const reco::Photon &photon = (*photonHandle)[ipho]; + + bool keep = keepPhotonSel_(photon); + if (!keep) continue; + + reco::PhotonRef photonref(photonHandle,ipho); + + photons->push_back(photon); + + //fill pf candidate value map vector + pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]); + + //fill photon id valuemap vectors + for (unsigned int iid=0; iidpush_back(*photonCore); + photonCoreMap[photonCore] = photonCores->size() - 1; + } + + bool slimRelink = slimRelinkPhotonSel_(photon); + //no supercluster relinking unless slimRelink selection is satisfied + if (!slimRelink) continue; + + bool relink = relinkPhotonSel_(photon); + + const reco::SuperClusterRef &superCluster = photon.superCluster(); + const auto &mappedsc = superClusterMap.find(superCluster); + //get index in output collection in order to keep track whether superCluster + //will be subject to full relinking + unsigned int mappedscidx = 0; + if (mappedsc==superClusterMap.end()) { + superClusters->push_back(*superCluster); + mappedscidx = superClusters->size() - 1; + superClusterMap[superCluster] = mappedscidx; + } + else { + mappedscidx = mappedsc->second; + } + + //additionally mark supercluster for full relinking + if (relink) superClusterFullRelinkMap.insert(mappedscidx); + + //conversions only for full relinking + if (!relink) continue; + + const reco::ConversionRefVector &convrefs = photon.conversions(); + for (const reco::ConversionRef &convref : convrefs) { + if (!conversionMap.count(convref)) { + conversions->push_back(*convref); + conversionMap[convref] = conversions->size() - 1; + } + } + + //explicitly references conversions + const reco::ConversionRefVector &singleconvrefs = photon.conversionsOneLeg(); + for (const reco::ConversionRef &convref : singleconvrefs) { + if (!singleConversionMap.count(convref)) { + singleConversions->push_back(*convref); + singleConversionMap[convref] = singleConversions->size() - 1; + } + } + + } + + //loop over electrons and fill maps + for (unsigned int iele = 0; ielesize(); ++iele) { + const reco::GsfElectron &gsfElectron = (*gsfElectronHandle)[iele]; + + bool keep = keepGsfElectronSel_(gsfElectron); + if (!keep) continue; + + reco::GsfElectronRef gsfElectronref(gsfElectronHandle,iele); + + gsfElectrons->push_back(gsfElectron); + pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]); + + //fill electron id valuemap vectors + for (unsigned int iid=0; iidpush_back(*gsfElectronCore); + gsfElectronCoreMap[gsfElectronCore] = gsfElectronCores->size() - 1; + } + + bool slimRelink = slimRelinkGsfElectronSel_(gsfElectron); + //no supercluster relinking unless slimRelink selection is satisfied + if (!slimRelink) continue; + + bool relink = relinkGsfElectronSel_(gsfElectron); + + const reco::SuperClusterRef &superCluster = gsfElectron.superCluster(); + const auto &mappedsc = superClusterMap.find(superCluster); + //get index in output collection in order to keep track whether superCluster + //will be subject to full relinking + unsigned int mappedscidx = 0; + if (mappedsc==superClusterMap.end()) { + superClusters->push_back(*superCluster); + mappedscidx = superClusters->size() - 1; + superClusterMap[superCluster] = mappedscidx; + } + else { + mappedscidx = mappedsc->second; + } + + //additionally mark supercluster for full relinking + if (relink) superClusterFullRelinkMap.insert(mappedscidx); + + //conversions only for full relinking + if (!relink) continue; + + //conversions matched by trackrefs + for (unsigned int iconv = 0; iconvsize(); ++iconv) { + const reco::Conversion &conversion = (*conversionHandle)[iconv]; + reco::ConversionRef convref(conversionHandle,iconv); + + bool matched = ConversionTools::matchesConversion(gsfElectron,conversion,true,true); + if (!matched) continue; + + if (!conversionMap.count(convref)) { + conversions->push_back(conversion); + conversionMap[convref] = conversions->size() - 1; + } + + } + + //single leg conversions matched by trackrefs + for (unsigned int iconv = 0; iconvsize(); ++iconv) { + const reco::Conversion &conversion = (*singleConversionHandle)[iconv]; + reco::ConversionRef convref(singleConversionHandle,iconv); + + bool matched = ConversionTools::matchesConversion(gsfElectron,conversion,true,true); + if (!matched) continue; + + if (!singleConversionMap.count(convref)) { + singleConversions->push_back(conversion); + singleConversionMap[convref] = singleConversions->size() - 1; + } + + } + + } + + //loop over output SuperClusters and fill maps + for (unsigned int isc = 0; iscsize(); ++isc) { + reco::SuperCluster &superCluster = (*superClusters)[isc]; + + //link seed cluster no matter what + if (!ebeeClusterMap.count(superCluster.seed())) { + ebeeClusters->push_back(*superCluster.seed()); + ebeeClusterMap[superCluster.seed()] = ebeeClusters->size() - 1; + } + + //only proceed if superCluster is marked for full relinking + bool fullrelink = superClusterFullRelinkMap.count(isc); + if (!fullrelink) { + //zero detid vector which is anyways not useful without stored rechits + superCluster.clearHitsAndFractions(); + continue; + } + + for (const reco::CaloClusterPtr &cluster : superCluster.clusters()) { + if (!ebeeClusterMap.count(cluster)) { + ebeeClusters->push_back(*cluster); + ebeeClusterMap[cluster] = ebeeClusters->size() - 1; + } + for (std::pair hitfrac : cluster->hitsAndFractions()) { + rechitMap.insert(hitfrac.first); + } + //make sure to also take all hits in the 5x5 around the max energy xtal + bool barrel = cluster->hitsAndFractions().front().first.subdetId()==EcalBarrel; + const EcalRecHitCollection *rhcol = barrel ? barrelHitHandle.product() : endcapHitHandle.product(); + DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first; + + std::vector dets5x5 = (barrel) ? caloTopology->getSubdetectorTopology(DetId::Ecal,EcalBarrel)->getWindow(seed,5,5) : caloTopology->getSubdetectorTopology(DetId::Ecal,EcalEndcap)->getWindow(seed,5,5); + for (const DetId &detid : dets5x5) { + rechitMap.insert(detid); + } + } + for (const reco::CaloClusterPtr &cluster : superCluster.preshowerClusters()) { + if (!esClusterMap.count(cluster)) { + esClusters->push_back(*cluster); + esClusterMap[cluster] = esClusters->size() - 1; + } + for (std::pair hitfrac : cluster->hitsAndFractions()) { + rechitMap.insert(hitfrac.first); + } + } + + //conversions matched geometrically + for (unsigned int iconv = 0; iconvsize(); ++iconv) { + const reco::Conversion &conversion = (*conversionHandle)[iconv]; + reco::ConversionRef convref(conversionHandle,iconv); + + bool matched = ConversionTools::matchesConversion(superCluster,conversion,0.2); + if (!matched) continue; + + if (!conversionMap.count(convref)) { + conversions->push_back(conversion); + conversionMap[convref] = conversions->size() - 1; + } + + } + + //single leg conversions matched by trackrefs + for (unsigned int iconv = 0; iconvsize(); ++iconv) { + const reco::Conversion &conversion = (*singleConversionHandle)[iconv]; + reco::ConversionRef convref(singleConversionHandle,iconv); + + bool matched = ConversionTools::matchesConversion(superCluster,conversion,0.2); + if (!matched) continue; + + if (!singleConversionMap.count(convref)) { + singleConversions->push_back(conversion); + singleConversionMap[convref] = singleConversions->size() - 1; + } + + } + + } + + //now finalize and add to the event collections in "reverse" order + + //rechits (fill output collections of rechits to be stored) + for (const EcalRecHit &rechit : *barrelHitHandle) { + if (rechitMap.count(rechit.detid())) { + ebRecHits->push_back(rechit); + } + } + + for (const EcalRecHit &rechit : *endcapHitHandle) { + if (rechitMap.count(rechit.detid())) { + eeRecHits->push_back(rechit); + } + } + + for (const EcalRecHit &rechit : *preshowerHitHandle) { + if (rechitMap.count(rechit.detid())) { + esRecHits->push_back(rechit); + } + } + + theEvent.put(ebRecHits,outEBRecHits_); + theEvent.put(eeRecHits,outEERecHits_); + theEvent.put(esRecHits,outESRecHits_); + + + //CaloClusters + //put calocluster output collections in event and get orphan handles to create ptrs + const edm::OrphanHandle &outEBEEClusterHandle = theEvent.put(ebeeClusters,outEBEEClusters_); + const edm::OrphanHandle &outESClusterHandle = theEvent.put(esClusters,outESClusters_);; + + //loop over output superclusters and relink to output caloclusters + for (reco::SuperCluster &superCluster : *superClusters) { + //remap seed cluster + const auto &seedmapped = ebeeClusterMap.find(superCluster.seed()); + if (seedmapped != ebeeClusterMap.end()) { + //make new ptr + reco::CaloClusterPtr clusptr(outEBEEClusterHandle,seedmapped->second); + superCluster.setSeed(clusptr); + } + + //remap all clusters + reco::CaloClusterPtrVector clusters; + for (const reco::CaloClusterPtr &cluster : superCluster.clusters()) { + const auto &clustermapped = ebeeClusterMap.find(cluster); + if (clustermapped != ebeeClusterMap.end()) { + //make new ptr + reco::CaloClusterPtr clusptr(outEBEEClusterHandle,clustermapped->second); + clusters.push_back(clusptr); + } + else { + //can only relink if all clusters are being relinked, so if one is missing, then skip the relinking completely + clusters.clear(); + break; + } + } + if (clusters.size()) { + superCluster.setClusters(clusters); + } + + //remap preshower clusters + reco::CaloClusterPtrVector esclusters; + for (const reco::CaloClusterPtr &cluster : superCluster.preshowerClusters()) { + const auto &clustermapped = esClusterMap.find(cluster); + if (clustermapped != esClusterMap.end()) { + //make new ptr + reco::CaloClusterPtr clusptr(outESClusterHandle,clustermapped->second); + esclusters.push_back(clusptr); + } + else { + //can only relink if all clusters are being relinked, so if one is missing, then skip the relinking completely + esclusters.clear(); + break; + } + } + if (esclusters.size()) { + superCluster.setPreshowerClusters(esclusters); + } + + } + + //put superclusters and conversions in the event + const edm::OrphanHandle &outSuperClusterHandle = theEvent.put(superClusters,outSuperClusters_); + const edm::OrphanHandle &outConversionHandle = theEvent.put(conversions,outConversions_); + const edm::OrphanHandle &outSingleConversionHandle = theEvent.put(singleConversions,outSingleConversions_); + + //loop over photoncores and relink superclusters (and conversions) + for (reco::PhotonCore &photonCore : *photonCores) { + const auto &scmapped = superClusterMap.find(photonCore.superCluster()); + if (scmapped != superClusterMap.end()) { + //make new ref + reco::SuperClusterRef scref(outSuperClusterHandle,scmapped->second); + photonCore.setSuperCluster(scref); + } + + //conversions + const reco::ConversionRefVector &convrefs = photonCore.conversions(); + reco::ConversionRefVector outconvrefs; + for (const reco::ConversionRef &convref : convrefs) { + const auto &convmapped = conversionMap.find(convref); + if (convmapped != conversionMap.end()) { + //make new ref + reco::ConversionRef outref(outConversionHandle,convmapped->second); + } + else { + //can only relink if all conversions are being relinked, so if one is missing, then skip the relinking completely + outconvrefs.clear(); + break; + } + } + if (outconvrefs.size()) { + photonCore.setConversions(outconvrefs); + } + + //single leg conversions + const reco::ConversionRefVector &singleconvrefs = photonCore.conversionsOneLeg(); + reco::ConversionRefVector outsingleconvrefs; + for (const reco::ConversionRef &convref : singleconvrefs) { + const auto &convmapped = singleConversionMap.find(convref); + if (convmapped != singleConversionMap.end()) { + //make new ref + reco::ConversionRef outref(outSingleConversionHandle,convmapped->second); + } + else { + //can only relink if all conversions are being relinked, so if one is missing, then skip the relinking completely + outsingleconvrefs.clear(); + break; + } + } + if (outsingleconvrefs.size()) { + photonCore.setConversionsOneLeg(outsingleconvrefs); + } + + } + + //loop over gsfelectroncores and relink superclusters + for (reco::GsfElectronCore &gsfElectronCore : *gsfElectronCores) { + const auto &scmapped = superClusterMap.find(gsfElectronCore.superCluster()); + if (scmapped != superClusterMap.end()) { + //make new ref + reco::SuperClusterRef scref(outSuperClusterHandle,scmapped->second); + gsfElectronCore.setSuperCluster(scref); + } + } + + //put photon and gsfelectroncores into the event + const edm::OrphanHandle &outPhotonCoreHandle = theEvent.put(photonCores,outPhotonCores_); + const edm::OrphanHandle &outgsfElectronCoreHandle = theEvent.put(gsfElectronCores,outGsfElectronCores_); + + //loop over photons and electrons and relink the cores + for (reco::Photon &photon : *photons) { + const auto &coremapped = photonCoreMap.find(photon.photonCore()); + if (coremapped != photonCoreMap.end()) { + //make new ref + reco::PhotonCoreRef coreref(outPhotonCoreHandle,coremapped->second); + photon.setPhotonCore(coreref); + } + } + + for (reco::GsfElectron &gsfElectron : *gsfElectrons) { + const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core()); + if (coremapped != gsfElectronCoreMap.end()) { + //make new ref + reco::GsfElectronCoreRef coreref(outgsfElectronCoreHandle,coremapped->second); + gsfElectron.setCore(coreref); + } + } + + //(finally) store the output photon and electron collections + const edm::OrphanHandle &outPhotonHandle = theEvent.put(photons,outPhotons_); + const edm::OrphanHandle &outGsfElectronHandle = theEvent.put(gsfElectrons,outGsfElectrons_); + + //still need to output relinked valuemaps + + //photon pfcand isolation valuemap + edm::ValueMap>::Filler fillerPhotons(*photonPfCandMap); + fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end()); + fillerPhotons.fill(); + + //electron pfcand isolation valuemap + edm::ValueMap>::Filler fillerGsfElectrons(*gsfElectronPfCandMap); + fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end()); + fillerGsfElectrons.fill(); + + theEvent.put(photonPfCandMap,outPhotonPfCandMap_); + theEvent.put(gsfElectronPfCandMap,outGsfElectronPfCandMap_); + + //photon id value maps + for (unsigned int iid=0; iid::Filler fillerPhotonId(*photonIds[iid]); + fillerPhotonId.insert(outPhotonHandle,photonIdVals[iid].begin(),photonIdVals[iid].end()); + fillerPhotonId.fill(); + theEvent.put(photonIds[iid],outPhotonIds_[iid]); + } + + //electron id value maps + for (unsigned int iid=0; iid::Filler fillerGsfElectronId(*gsfElectronIds[iid]); + fillerGsfElectronId.insert(outGsfElectronHandle,gsfElectronIdVals[iid].begin(),gsfElectronIdVals[iid].end()); + fillerGsfElectronId.fill(); + theEvent.put(gsfElectronIds[iid],outGsfElectronIds_[iid]); + } + +} + + diff --git a/RecoEgamma/EgammaPhotonProducers/src/SealModule.cc b/RecoEgamma/EgammaPhotonProducers/src/SealModule.cc index 32a124a1eff02..9c4ad9f1d2b76 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/SealModule.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/SealModule.cc @@ -11,6 +11,7 @@ #include "RecoEgamma/EgammaPhotonProducers/interface/ConversionTrackMerger.h" #include "RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonCoreProducer.h" #include "RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonProducer.h" +#include "RecoEgamma/EgammaPhotonProducers/interface/ReducedEGProducer.h" DEFINE_FWK_MODULE(PhotonCoreProducer); DEFINE_FWK_MODULE(PhotonProducer); @@ -22,3 +23,4 @@ DEFINE_FWK_MODULE(ConversionTrackProducer); DEFINE_FWK_MODULE(ConversionTrackMerger); DEFINE_FWK_MODULE(GEDPhotonCoreProducer); DEFINE_FWK_MODULE(GEDPhotonProducer); +DEFINE_FWK_MODULE(ReducedEGProducer); diff --git a/RecoEgamma/EgammaTools/interface/ConversionTools.h b/RecoEgamma/EgammaTools/interface/ConversionTools.h index 4b0f27ada226e..360257463a86e 100644 --- a/RecoEgamma/EgammaTools/interface/ConversionTools.h +++ b/RecoEgamma/EgammaTools/interface/ConversionTools.h @@ -41,7 +41,7 @@ class ConversionTools static bool isGoodConversion(const reco::Conversion &conv, const math::XYZPoint &beamspot, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=1); - static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true); + static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false); static bool matchesConversion(const reco::SuperCluster &sc, const reco::Conversion &conv, float dRMax = 0.1, float dEtaMax = 999., float dPhiMax = 999.); static bool matchesConversion(const edm::RefToBase &trk, const reco::Conversion &conv); static bool matchesConversion(const reco::TrackRef &trk, const reco::Conversion &conv); diff --git a/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h b/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h index a550f05a6105f..1c28caf87d3d3 100644 --- a/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h +++ b/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h @@ -15,9 +15,9 @@ #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" class GBRForest; -class EcalClusterLazyTools; class EGEnergyCorrector { public: diff --git a/RecoEgamma/EgammaTools/src/ConversionTools.cc b/RecoEgamma/EgammaTools/src/ConversionTools.cc index d32142da5eb37..59d260ba50f34 100644 --- a/RecoEgamma/EgammaTools/src/ConversionTools.cc +++ b/RecoEgamma/EgammaTools/src/ConversionTools.cc @@ -47,7 +47,7 @@ bool ConversionTools::isGoodConversion(const Conversion &conv, const math::XYZPo } //-------------------------------------------------------------------------------------------------- -bool ConversionTools::matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch) +bool ConversionTools::matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch, bool allowAmbiguousGsfMatch) { //check if a given GsfElectron matches a given conversion (no quality cuts applied) @@ -56,8 +56,13 @@ bool ConversionTools::matchesConversion(const reco::GsfElectron &ele, const reco const std::vector > &convTracks = conv.tracks(); for (std::vector >::const_iterator it=convTracks.begin(); it!=convTracks.end(); ++it) { - if ( ele.gsfTrack().isNonnull() && ele.gsfTrack().id()==it->id() && ele.gsfTrack().key()==it->key()) return true; - else if ( allowCkfMatch && ele.closestCtfTrackRef().isNonnull() && ele.closestCtfTrackRef().id()==it->id() && ele.closestCtfTrackRef().key()==it->key() ) return true; + if ( ele.reco::GsfElectron::gsfTrack().isNonnull() && ele.reco::GsfElectron::gsfTrack().id()==it->id() && ele.reco::GsfElectron::gsfTrack().key()==it->key()) return true; + else if ( allowCkfMatch && ele.reco::GsfElectron::closestCtfTrackRef().isNonnull() && ele.reco::GsfElectron::closestCtfTrackRef().id()==it->id() && ele.reco::GsfElectron::closestCtfTrackRef().key()==it->key() ) return true; + if (allowAmbiguousGsfMatch) { + for (reco::GsfTrackRefVector::const_iterator tk = ele.ambiguousGsfTracksBegin(); tk!=ele.ambiguousGsfTracksEnd(); ++tk) { + if (tk->isNonnull() && tk->id()==it->id() && tk->key()==it->key()) return true; + } + } } return false; @@ -299,7 +304,7 @@ bool ConversionTools::hasMatchedPromptElectron(const reco::SuperClusterRef &sc, for (GsfElectronCollection::const_iterator it = eleCol->begin(); it!=eleCol->end(); ++it) { //match electron to supercluster - if (it->superCluster()!=sc) continue; + if (it->reco::GsfElectron::superCluster()!=sc) continue; //check expected inner hits if (it->gsfTrack()->trackerExpectedHitsInner().numberOfHits()>0) continue; @@ -331,7 +336,7 @@ reco::GsfElectronRef ConversionTools::matchedPromptElectron(const reco::SuperClu for (GsfElectronCollection::const_iterator it = eleCol->begin(); it!=eleCol->end(); ++it) { //match electron to supercluster - if (it->superCluster()!=sc) continue; + if (it->reco::GsfElectron::superCluster()!=sc) continue; //check expected inner hits if (it->gsfTrack()->trackerExpectedHitsInner().numberOfHits()>0) continue; diff --git a/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc b/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc index 624d10c1562ac..06a19a784e8f6 100644 --- a/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc +++ b/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc @@ -7,7 +7,6 @@ #include "DataFormats/EgammaCandidates/interface/Photon.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/Math/interface/deltaPhi.h" -#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" #include "DataFormats/VertexReco/interface/Vertex.h"