From 1690cd510e94bb59e58ec731a7f89a02ed3e1b8f Mon Sep 17 00:00:00 2001 From: Fabrice Couderc Date: Mon, 22 May 2017 12:00:16 +0200 Subject: [PATCH 1/2] add the possibility to add new regression and calibration --- python/TnPTreeProducer_cfg.py | 6 ++-- python/egmElectronIDModules_cff.py | 1 + python/egmGoodParticlesDef_cff.py | 56 ++++++++++++++++++------------ python/egmPhotonIDModules_cff.py | 2 +- python/egmTreesSetup_cff.py | 11 +++--- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/python/TnPTreeProducer_cfg.py b/python/TnPTreeProducer_cfg.py index 1fcab588cf9..03841243250 100644 --- a/python/TnPTreeProducer_cfg.py +++ b/python/TnPTreeProducer_cfg.py @@ -44,7 +44,7 @@ ) varOptions.register( - "useCalibEn", False, + "calibEn", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool, @@ -110,7 +110,7 @@ options['OUTPUTEDMFILENAME'] = 'edmFile.root' options['DEBUG'] = cms.bool(False) options['isMC'] = cms.bool(False) -options['UseCalibEn'] = varOptions.useCalibEn +options['UseCalibEn'] = varOptions.calibEn if (varOptions.isMC): options['isMC'] = cms.bool(True) @@ -296,7 +296,7 @@ process.p = cms.Path( process.hltFilter + - process.cand_sequence + + process.cand_sequence + process.tnpPairs_sequence + process.mc_sequence + process.eleVarHelper + diff --git a/python/egmElectronIDModules_cff.py b/python/egmElectronIDModules_cff.py index 1cc6ca198da..38dcd23836b 100644 --- a/python/egmElectronIDModules_cff.py +++ b/python/egmElectronIDModules_cff.py @@ -34,6 +34,7 @@ def setIDs(process, options): process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag(options['ELECTRON_COLL']) process.electronMVAValueMapProducer.srcMiniAOD = cms.InputTag(options['ELECTRON_COLL']) + process.electronRegressionValueMapProducer.srcMiniAOD = cms.InputTag(options['ELECTRON_COLL']) process.probeEleCutBasedVeto = cms.EDProducer(eleProducer, input = cms.InputTag("goodElectrons"), diff --git a/python/egmGoodParticlesDef_cff.py b/python/egmGoodParticlesDef_cff.py index c56ce8e5662..b79f9cbc8b6 100644 --- a/python/egmGoodParticlesDef_cff.py +++ b/python/egmGoodParticlesDef_cff.py @@ -3,18 +3,10 @@ def calibrateEGM(process, options ): - process.selectElectronsBase = cms.EDFilter("PATElectronSelector", - src = cms.InputTag( options['ELECTRON_COLL'] ), - cut = cms.string(options['ELECTRON_CUTS']), - filter = cms.bool(True), - ) - - process.selectPhotonsBase = cms.EDFilter("PATPhotonSelector", - src = cms.InputTag( options['PHOTON_COLL'] ), - cut = cms.string(options['PHOTON_CUTS']), - filter = cms.bool(True), - ) - + + ### apply 80X regression + from EgammaAnalysis.ElectronTools.regressionWeights_cfi import regressionWeights + process = regressionWeights(process) process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", calibratedPatElectrons = cms.PSet( initialSeed = cms.untracked.uint32(81), @@ -24,25 +16,46 @@ def calibrateEGM(process, options ): engineName = cms.untracked.string('TRandom3'), ), ) - process.load('EgammaAnalysis.ElectronTools.calibratedElectronsRun2_cfi') - process.load('EgammaAnalysis.ElectronTools.calibratedPhotonsRun2_cfi') + process.load('EgammaAnalysis.ElectronTools.regressionApplication_cff') + process.load('EgammaAnalysis.ElectronTools.calibratedPatElectronsRun2_cfi') + process.load('EgammaAnalysis.ElectronTools.calibratedPatPhotonsRun2_cfi') - process.calibratedPatElectrons.electrons = cms.InputTag('selectElectronsBase') - process.calibratedPatPhotons.photons = cms.InputTag('selectPhotonsBase') + process.calibratedPatElectrons.electrons = cms.InputTag(options['ELECTRON_COLL']) + process.calibratedPatPhotons.photons = cms.InputTag(options['PHOTON_COLL'] ) if options['isMC']: process.calibratedPatElectrons.isMC = cms.bool(True) process.calibratedPatPhotons.isMC = cms.bool(True) + else : + process.calibratedPatElectrons.isMC = cms.bool(False) + process.calibratedPatPhotons.isMC = cms.bool(False) + + + + process.selectElectronsBase = cms.EDFilter("PATElectronSelector", + src = cms.InputTag('calibratedPatElectrons'), + cut = cms.string( options['ELECTRON_CUTS']), + ) + + process.selectPhotonsBase = cms.EDFilter("PATPhotonSelector", + src = cms.InputTag('calibratedPatPhotons' ), + cut = cms.string(options['PHOTON_CUTS']), + ) ### change the input collection to be the calibrated energy one for all other modules from now on - options['ELECTRON_COLL'] = 'calibratedPatElectrons' - options['PHOTON_COLL'] = 'calibratedPatPhotons' + options['ELECTRON_COLL'] = 'selectElectronsBase' + options['PHOTON_COLL'] = 'selectPhotonsBase' + + + ################################################################################### ################ --- GOOD particles MiniAOD ################################################################################### def setGoodParticlesMiniAOD(process, options): + if options['UseCalibEn']: calibrateEGM( process, options ) + process.eleVarHelper = cms.EDProducer("PatElectronVariableHelper", probes = cms.InputTag(options['ELECTRON_COLL']), @@ -52,14 +65,11 @@ def setGoodParticlesMiniAOD(process, options): ) - - - if options['UseCalibEn']: calibrateEGM( process, options ) - + #################### Electron collection process.goodElectrons = cms.EDFilter("PATElectronRefSelector", src = cms.InputTag( options['ELECTRON_COLL'] ), - cut = cms.string( options['ELECTRON_CUTS'] ) + cut = cms.string( options['ELECTRON_CUTS'] ), ) #################### Photon collection diff --git a/python/egmPhotonIDModules_cff.py b/python/egmPhotonIDModules_cff.py index 2d9da81f783..cf449964671 100644 --- a/python/egmPhotonIDModules_cff.py +++ b/python/egmPhotonIDModules_cff.py @@ -29,7 +29,7 @@ def setIDs(process, options): process.egmPhotonIDs.physicsObjectSrc = cms.InputTag(options['PHOTON_COLL']) process.photonIDValueMapProducer.srcMiniAOD = cms.InputTag(options['PHOTON_COLL']) process.photonMVAValueMapProducer.srcMiniAOD = cms.InputTag(options['PHOTON_COLL']) - process.photonMVAValueMapProducer.src = cms.InputTag(options['PHOTON_COLL']) +# process.photonMVAValueMapProducer.src = cms.InputTag(options['PHOTON_COLL']) process.probePhoCutBasedLoose = cms.EDProducer( phoProducer, diff --git a/python/egmTreesSetup_cff.py b/python/egmTreesSetup_cff.py index b5f2105f91b..35942539158 100644 --- a/python/egmTreesSetup_cff.py +++ b/python/egmTreesSetup_cff.py @@ -134,12 +134,13 @@ def setTagsProbes(process, options): def setSequences(process, options): process.init_sequence = cms.Sequence() - if options['UseCalibEn'] and options['useAOD']: + if options['UseCalibEn']: process.enCalib_sequence = cms.Sequence( - process.selectElectronsBase + - process.selectPhotonsBase + - process.calibratedPatElectrons + - process.calibratedPatPhotons + process.regressionApplication * + process.calibratedPatElectrons * + process.calibratedPatPhotons * + process.selectElectronsBase * + process.selectPhotonsBase ) process.init_sequence += process.enCalib_sequence From 45f1501207db540d1d52488f1b8dd6292f5971f4 Mon Sep 17 00:00:00 2001 From: Fabrice Couderc Date: Mon, 22 May 2017 12:11:58 +0200 Subject: [PATCH 2/2] update readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 577c141ed7a..a83c3aa43d6 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ For developpers 1. On github fork the package https://github.com/cms-analysis/EgammaAnalysis-TnPTreeProducer 2. Add the remote -git remote add username git@github.com:/EgammaAnalysis-TnPTreeProducer.git +git remote add username-push git@github.com:username/EgammaAnalysis-TnPTreeProducer.git -3. push commits to fork and then standard pull request process \ No newline at end of file +3. push commits to fork and then standard pull request process +git push username-push branchname \ No newline at end of file