Skip to content

Commit

Permalink
Merge pull request #2 from rafaellopesdesa/Sam-Harper/GSIssueFix
Browse files Browse the repository at this point in the history
thanks for getting this sorted
  • Loading branch information
Sam-Harper authored Jan 23, 2017
2 parents 7c74f0d + afcfe6f commit c69575c
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ namespace {
}
}




typedef edm::ValueMap<reco::GsfElectronRef> ElectronRefMap;

GsfElectronGSCrysFixer::GsfElectronGSCrysFixer( const edm::ParameterSet & pset )
{
Expand All @@ -98,6 +96,8 @@ GsfElectronGSCrysFixer::GsfElectronGSCrysFixer( const edm::ParameterSet & pset )
}

produces<reco::GsfElectronCollection >();
produces<ElectronRefMap>();

}

namespace {
Expand Down Expand Up @@ -131,10 +131,13 @@ void GsfElectronGSCrysFixer::produce( edm::Event & iEvent, const edm::EventSetup
auto& ebRecHits = *getHandle(iEvent,ebRecHitsToken_);
auto& newCoresToOldCoresMap = *getHandle(iEvent,newCoresToOldCoresMapToken_);
auto newCoresHandle = getHandle(iEvent,newCoresToken_);

std::vector<reco::GsfElectronRef> oldElectrons;

for(size_t eleNr=0;eleNr<elesHandle->size();eleNr++){
reco::GsfElectronRef eleRef(elesHandle,eleNr);

oldElectrons.emplace_back(eleRef);

reco::GsfElectronCoreRef newCoreRef = getNewCore(eleRef,newCoresHandle,newCoresToOldCoresMap);

if(newCoreRef.isNonnull()){ //okay we have to remake the electron
Expand Down Expand Up @@ -162,7 +165,12 @@ void GsfElectronGSCrysFixer::produce( edm::Event & iEvent, const edm::EventSetup
}
}

iEvent.put(std::move(outEles));
auto&& newElectronsHandle(iEvent.put(std::move(outEles)));
std::unique_ptr<ElectronRefMap> pRefMap(new ElectronRefMap);
ElectronRefMap::Filler refMapFiller(*pRefMap);
refMapFiller.insert(newElectronsHandle, oldElectrons.begin(), oldElectrons.end());
refMapFiller.fill();
iEvent.put(std::move(pRefMap));
}

void GsfElectronGSCrysFixer::beginLuminosityBlock(edm::LuminosityBlock const& lb,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class ReducedEGProducer : public edm::stream::EDProducer<> {

//tokens for input collections
const edm::EDGetTokenT<reco::PhotonCollection> photonT_;
const edm::EDGetTokenT<edm::ValueMap<reco::PhotonRef> > gsFixedPhotonMapT_;
const edm::EDGetTokenT<reco::GsfElectronCollection> gsfElectronT_;
const edm::EDGetTokenT<edm::ValueMap<reco::GsfElectronRef> > gsFixedElectronMapT_;
const edm::EDGetTokenT<reco::ConversionCollection> conversionT_;
const edm::EDGetTokenT<reco::ConversionCollection> singleConversionT_;

Expand Down
6 changes: 4 additions & 2 deletions RecoEgamma/EgammaPhotonProducers/python/reducedEgamma_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
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"),
photons = cms.InputTag("gsFixedGedPhotons"),
gsFixedPhotonMap = cms.InputTag("gsFixedGedPhotons"),
gsfElectrons = cms.InputTag("gsFixedGsfElectrons"),
gsFixedElectronMap = cms.InputTag("gsFixedGsfElectrons"),
conversions = cms.InputTag("allConversions"),
singleConversions = cms.InputTag("particleFlowEGamma"),
barrelEcalHits = cms.InputTag("reducedEcalRecHitsEB"),
Expand Down
16 changes: 13 additions & 3 deletions RecoEgamma/EgammaPhotonProducers/src/GEDPhotonGSCrysFixer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace {
}
}

typedef edm::ValueMap<reco::PhotonRef> PhotonRefMap;

GEDPhotonGSCrysFixer::GEDPhotonGSCrysFixer( const edm::ParameterSet & pset )
{
Expand All @@ -30,6 +31,7 @@ GEDPhotonGSCrysFixer::GEDPhotonGSCrysFixer( const edm::ParameterSet & pset )
}

produces<reco::PhotonCollection >();
produces<PhotonRefMap>();
}

namespace {
Expand Down Expand Up @@ -63,10 +65,13 @@ void GEDPhotonGSCrysFixer::produce( edm::Event & iEvent, const edm::EventSetup &
auto& ebRecHits = *getHandle(iEvent,ebRecHitsToken_);
auto& newCoresToOldCoresMap = *getHandle(iEvent,newCoresToOldCoresMapToken_);
auto newCoresHandle = getHandle(iEvent,newCoresToken_);


std::vector<reco::PhotonRef> oldPhotons;

for(size_t phoNr=0;phoNr<phosHandle->size();phoNr++){
reco::PhotonRef phoRef(phosHandle,phoNr);

oldPhotons.emplace_back(phoRef);

reco::PhotonCoreRef newCoreRef = getNewCore(phoRef,newCoresHandle,newCoresToOldCoresMap);

if(newCoreRef.isNonnull()){ //okay we have to remake the photon
Expand Down Expand Up @@ -95,7 +100,12 @@ void GEDPhotonGSCrysFixer::produce( edm::Event & iEvent, const edm::EventSetup &
}
}

iEvent.put(std::move(outPhos));
auto&& newPhotonsHandle(iEvent.put(std::move(outPhos)));
std::unique_ptr<PhotonRefMap> pRefMap(new PhotonRefMap);
PhotonRefMap::Filler refMapFiller(*pRefMap);
refMapFiller.insert(newPhotonsHandle, oldPhotons.begin(), oldPhotons.end());
refMapFiller.fill();
iEvent.put(std::move(pRefMap));
}

void GEDPhotonGSCrysFixer::beginLuminosityBlock(edm::LuminosityBlock const& lb,
Expand Down
26 changes: 20 additions & 6 deletions RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ namespace std {

ReducedEGProducer::ReducedEGProducer(const edm::ParameterSet& config) :
photonT_(consumes<reco::PhotonCollection>(config.getParameter<edm::InputTag>("photons"))),
gsFixedPhotonMapT_(consumes<edm::ValueMap<reco::PhotonRef> >(config.getParameter<edm::InputTag>("gsFixedPhotonMap"))),
gsfElectronT_(consumes<reco::GsfElectronCollection>(config.getParameter<edm::InputTag>("gsfElectrons"))),
gsFixedElectronMapT_(consumes<edm::ValueMap<reco::GsfElectronRef> >(config.getParameter<edm::InputTag>("gsFixedElectronMap"))),
conversionT_(consumes<reco::ConversionCollection>(config.getParameter<edm::InputTag>("conversions"))),
singleConversionT_(consumes<reco::ConversionCollection>(config.getParameter<edm::InputTag>("singleConversions"))),
barrelEcalHits_(consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("barrelEcalHits"))),
Expand Down Expand Up @@ -156,8 +158,14 @@ void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& the
edm::Handle<reco::PhotonCollection> photonHandle;
theEvent.getByToken(photonT_, photonHandle);

edm::Handle<edm::ValueMap<reco::PhotonRef > > gsFixedPhotonMapHandle;
theEvent.getByToken(gsFixedPhotonMapT_, gsFixedPhotonMapHandle);

edm::Handle<reco::GsfElectronCollection> gsfElectronHandle;
theEvent.getByToken(gsfElectronT_, gsfElectronHandle);

edm::Handle<edm::ValueMap<reco::GsfElectronRef > > gsFixedElectronMapHandle;
theEvent.getByToken(gsFixedElectronMapT_, gsFixedElectronMapHandle);

edm::Handle<reco::ConversionCollection> conversionHandle;
theEvent.getByToken(conversionT_, conversionHandle);
Expand Down Expand Up @@ -264,15 +272,20 @@ void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& the

//loop over photons and fill maps
for (unsigned int ipho=0; ipho<photonHandle->size(); ++ipho) {

const reco::Photon &photon = (*photonHandle)[ipho];

bool keep = keepPhotonSel_(photon);
if (!keep) continue;

reco::PhotonRef photonref(photonHandle,ipho);

photons->push_back(photon);

reco::PhotonRef gsFixedPhotonRef(photonHandle,ipho);

// // check if it was fixed
// std::cout << gsFixedPhotonMapHandle->contains(gsFixedPhotonRef.id()) << std::endl;
// std::cout << (*gsFixedPhotonMapHandle)[gsFixedPhotonRef].isNull() << std::endl;
reco::PhotonRef photonref = (*gsFixedPhotonMapHandle)[gsFixedPhotonRef];

//fill pf candidate value map vector
pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);

Expand Down Expand Up @@ -342,10 +355,11 @@ void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& the

bool keep = keepGsfElectronSel_(gsfElectron);
if (!keep) continue;

reco::GsfElectronRef gsfElectronref(gsfElectronHandle,iele);

gsfElectrons->push_back(gsfElectron);

reco::GsfElectronRef gsFixedGsfElectronref(gsfElectronHandle,iele);
reco::GsfElectronRef gsfElectronref = (*gsFixedElectronMapHandle)[gsFixedGsfElectronref];

pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);

//fill electron id valuemap vectors
Expand Down
6 changes: 3 additions & 3 deletions RecoEgamma/EgammaTools/python/egammaGainSwitchFix_cff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms

bunchSpacingProducer = cms.EDProducer("BunchSpacingProducer")
bunchSpacingProducerGSFix = cms.EDProducer("BunchSpacingProducer")

#this module re-makes the rec-hits using the weights reco for hits saved in ecal selected digis
from RecoEgamma.EgammaTools.ecalWeightRecHitFromSelectedDigis_cff import *
Expand All @@ -24,7 +24,7 @@
from RecoEgamma.EgammaPhotonProducers.gsFixedGedPhotons_cfi import *

egammaGainSwitchFixSequence = cms.Sequence(
bunchSpacingProducer*
bunchSpacingProducerGSFix*
ecalWeightLocalRecoFromSelectedDigis*
ecalMultiAndGSWeightRecHitEB*
gsFixedParticleFlowSuperClustering*
Expand All @@ -39,7 +39,7 @@
from RecoEgamma.EgammaElectronProducers.gsSimpleFixedPhotons_cfi import gsSimpleFixedPhotons

egammaGainSwitchSimpleFixSequence = cms.Sequence(
bunchSpacingProducer*
bunchSpacingProducerGSFix*
ecalWeightLocalRecoFromSelectedDigis*
ecalMultiAndGSWeightRecHitEB*
gsSimpleFixedGsfElectrons*
Expand Down
114 changes: 114 additions & 0 deletions RecoEgamma/EgammaTools/test/miniaod_PAT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Auto generated configuration file
# using:
# Revision: 1.19
# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v
# with command line options: miniaod --no_exec --data --eventcontent MINIAOD --runUnscheduled --datatier MINIAOD --conditions 80X_dataRun2_2016SeptRepro_v3 --step PAT --era Run2_2016 --filein /store/user/sharper/EventSkim/DiHEEPWOSS_GainSwitch/AOD/DoubleEG/Run2016G-23Sep2016-v1_AOD_DiHEEPWOSS_GainSwitch/170112_185336/0000/DoubleEG_Run2016G-23Sep2016-v1_DiHEE --fileout file:miniaod.root --geometry DB:Extended
import FWCore.ParameterSet.Config as cms

from Configuration.StandardSequences.Eras import eras

process = cms.Process('PAT',eras.Run2_2016)

# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
process.load('PhysicsTools.PatAlgos.slimming.metFilterPaths_cff')
process.load('Configuration.StandardSequences.EndOfProcess_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(-1)
)

# Input source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring('/store/user/sharper/EventSkim/DiHEEPWOSS_GainSwitch/AOD/DoubleEG/Run2016G-23Sep2016-v1_AOD_DiHEEPWOSS_GainSwitch/170112_185336/0000/DoubleEG_Run2016G-23Sep2016-v1_DiHEEPWOSS_GainSwitch_10.root'),
secondaryFileNames = cms.untracked.vstring()
)

process.options = cms.untracked.PSet(
allowUnscheduled = cms.untracked.bool(True)
)

# Production Info
process.configurationMetadata = cms.untracked.PSet(
annotation = cms.untracked.string('miniaod nevts:1'),
name = cms.untracked.string('Applications'),
version = cms.untracked.string('$Revision: 1.19 $')
)

# Output definition

process.MINIAODoutput = cms.OutputModule("PoolOutputModule",
compressionAlgorithm = cms.untracked.string('LZMA'),
compressionLevel = cms.untracked.int32(4),
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('MINIAOD'),
filterName = cms.untracked.string('')
),
dropMetaData = cms.untracked.string('ALL'),
eventAutoFlushCompressedSize = cms.untracked.int32(15728640),
fastCloning = cms.untracked.bool(False),
fileName = cms.untracked.string('file:miniaod.root'),
outputCommands = process.MINIAODEventContent.outputCommands,
overrideInputFileSplitLevels = cms.untracked.bool(True)
)

# Additional output definition

# Other statements
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, '80X_dataRun2_2016SeptRepro_v3', '')

# Path and EndPath definitions
process.Flag_trackingFailureFilter = cms.Path(process.goodVertices+process.trackingFailureFilter)
process.Flag_goodVertices = cms.Path(process.primaryVertexFilter)
process.Flag_CSCTightHaloFilter = cms.Path(process.CSCTightHaloFilter)
process.Flag_trkPOGFilters = cms.Path(process.trkPOGFilters)
process.Flag_trkPOG_logErrorTooManyClusters = cms.Path(~process.logErrorTooManyClusters)
process.Flag_EcalDeadCellTriggerPrimitiveFilter = cms.Path(process.EcalDeadCellTriggerPrimitiveFilter)
process.Flag_ecalLaserCorrFilter = cms.Path(process.ecalLaserCorrFilter)
process.Flag_globalSuperTightHalo2016Filter = cms.Path(process.globalSuperTightHalo2016Filter)
process.Flag_eeBadScFilter = cms.Path(process.eeBadScFilter)
process.Flag_METFilters = cms.Path(process.metFilters)
process.Flag_chargedHadronTrackResolutionFilter = cms.Path(process.chargedHadronTrackResolutionFilter)
process.Flag_globalTightHalo2016Filter = cms.Path(process.globalTightHalo2016Filter)
process.Flag_CSCTightHaloTrkMuUnvetoFilter = cms.Path(process.CSCTightHaloTrkMuUnvetoFilter)
process.Flag_HBHENoiseIsoFilter = cms.Path(process.HBHENoiseFilterResultProducer+process.HBHENoiseIsoFilter)
process.Flag_hcalLaserEventFilter = cms.Path(process.hcalLaserEventFilter)
process.Flag_HBHENoiseFilter = cms.Path(process.HBHENoiseFilterResultProducer+process.HBHENoiseFilter)
process.Flag_trkPOG_toomanystripclus53X = cms.Path(~process.toomanystripclus53X)
process.Flag_EcalDeadCellBoundaryEnergyFilter = cms.Path(process.EcalDeadCellBoundaryEnergyFilter)
process.Flag_trkPOG_manystripclus53X = cms.Path(~process.manystripclus53X)
process.Flag_HcalStripHaloFilter = cms.Path(process.HcalStripHaloFilter)
process.Flag_muonBadTrackFilter = cms.Path(process.muonBadTrackFilter)
process.Flag_CSCTightHalo2015Filter = cms.Path(process.CSCTightHalo2015Filter)
process.endjob_step = cms.EndPath(process.endOfProcess)
process.MINIAODoutput_step = cms.EndPath(process.MINIAODoutput)

process.load("RecoEgamma.EgammaTools.egammaGainSwitchFix_cff")
process.applyGSfix = cms.Path(process.egammaGainSwitchFixSequence)

# Schedule definition
process.schedule = cms.Schedule(process.applyGSfix,process.Flag_HBHENoiseFilter,process.Flag_HBHENoiseIsoFilter,process.Flag_CSCTightHaloFilter,process.Flag_CSCTightHaloTrkMuUnvetoFilter,process.Flag_CSCTightHalo2015Filter,process.Flag_globalTightHalo2016Filter,process.Flag_globalSuperTightHalo2016Filter,process.Flag_HcalStripHaloFilter,process.Flag_hcalLaserEventFilter,process.Flag_EcalDeadCellTriggerPrimitiveFilter,process.Flag_EcalDeadCellBoundaryEnergyFilter,process.Flag_goodVertices,process.Flag_eeBadScFilter,process.Flag_ecalLaserCorrFilter,process.Flag_trkPOGFilters,process.Flag_chargedHadronTrackResolutionFilter,process.Flag_muonBadTrackFilter,process.Flag_trkPOG_manystripclus53X,process.Flag_trkPOG_toomanystripclus53X,process.Flag_trkPOG_logErrorTooManyClusters,process.Flag_METFilters,process.endjob_step,process.MINIAODoutput_step)

#do not add changes to your config after this point (unless you know what you are doing)
from FWCore.ParameterSet.Utilities import convertToUnscheduled
process=convertToUnscheduled(process)
process.load('Configuration.StandardSequences.PAT_cff')
from FWCore.ParameterSet.Utilities import cleanUnscheduled
process=cleanUnscheduled(process)

# customisation of the process.

# Automatic addition of the customisation function from PhysicsTools.PatAlgos.slimming.miniAOD_tools
from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeAllData

#call to customisation function miniAOD_customizeAllData imported from PhysicsTools.PatAlgos.slimming.miniAOD_tools
process = miniAOD_customizeAllData(process)

# End of customisation functions

0 comments on commit c69575c

Please sign in to comment.