Skip to content

Commit

Permalink
Merge pull request #5 from fcouderc/master
Browse files Browse the repository at this point in the history
Add energy regression + calibration
  • Loading branch information
fcouderc authored May 23, 2017
2 parents 3cee3a8 + 45f1501 commit c7ff536
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 34 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]:<username>/EgammaAnalysis-TnPTreeProducer.git
git remote add username-push [email protected]:username/EgammaAnalysis-TnPTreeProducer.git

3. push commits to fork and then standard pull request process
3. push commits to fork and then standard pull request process
git push username-push branchname
6 changes: 3 additions & 3 deletions python/TnPTreeProducer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)

varOptions.register(
"useCalibEn", False,
"calibEn", False,
VarParsing.multiplicity.singleton,
VarParsing.varType.bool,

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -296,7 +296,7 @@

process.p = cms.Path(
process.hltFilter +
process.cand_sequence +
process.cand_sequence +
process.tnpPairs_sequence +
process.mc_sequence +
process.eleVarHelper +
Expand Down
1 change: 1 addition & 0 deletions python/egmElectronIDModules_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
56 changes: 33 additions & 23 deletions python/egmGoodParticlesDef_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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']),
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/egmPhotonIDModules_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 6 additions & 5 deletions python/egmTreesSetup_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c7ff536

Please sign in to comment.