Skip to content

Commit

Permalink
Merge pull request #31591 from kdlong/NanoGen_dqm
Browse files Browse the repository at this point in the history
Nano gen dqm
  • Loading branch information
cmsbuild authored Oct 20, 2020
2 parents e2b2ead + fa3e79a commit bd56616
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from Configuration.Generator.Pythia8CommonSettings_cfi import *
from Configuration.Generator.MCTunes2017.PythiaCP5Settings_cfi import *
from Configuration.Generator.PSweightsPythia.PythiaPSweightsSettings_cfi import *

generator = cms.EDFilter("Pythia8ConcurrentHadronizerFilter",
maxEventsToPrint = cms.untracked.int32(1),
Expand All @@ -13,6 +14,7 @@
PythiaParameters = cms.PSet(
pythia8CommonSettingsBlock,
pythia8CP5SettingsBlock,
pythia8PSweightsSettingsBlock,
JetMatchingParameters = cms.vstring(
'JetMatching:setMad = off',
'JetMatching:scheme = 1',
Expand All @@ -28,6 +30,7 @@
),
parameterSets = cms.vstring('pythia8CommonSettings',
'pythia8CP5Settings',
'pythia8PSweightsSettings',
'JetMatchingParameters'
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from Configuration.Generator.Pythia8CommonSettings_cfi import *
from Configuration.Generator.MCTunes2017.PythiaCP5Settings_cfi import *
from Configuration.Generator.Pythia8PowhegEmissionVetoSettings_cfi import *
from Configuration.Generator.PSweightsPythia.PythiaPSweightsSettings_cfi import *

generator = cms.EDFilter("Pythia8ConcurrentHadronizerFilter",
maxEventsToPrint = cms.untracked.int32(1),
Expand All @@ -12,6 +13,7 @@
PythiaParameters = cms.PSet(
pythia8CommonSettingsBlock,
pythia8CP5SettingsBlock,
pythia8PSweightsSettingsBlock,
pythia8PowhegEmissionVetoSettingsBlock,
processParameters = cms.vstring(
'POWHEG:nFinal = 2', ## Number of final state particles
Expand All @@ -21,6 +23,7 @@
),
parameterSets = cms.vstring('pythia8CommonSettings',
'pythia8CP5Settings',
'pythia8PSweightsSettings',
'pythia8PowhegEmissionVetoSettings',
'processParameters'
)
Expand Down
3 changes: 3 additions & 0 deletions Configuration/PyReleaseValidation/python/relval_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
workflows[545]=['',['BsToMuMu_forSTEAM_13TeV','HARVESTGEN']]

# Miscellaneous
workflows[546]=['',['DYToLL_M-50_13TeV_pythia8','NANOGENFromGen']]
workflows[547]=['',['DYToll01234Jets_5f_LO_MLM_Madgraph_LHE_13TeV','Hadronizer_TuneCP5_13TeV_MLM_5f_max4j_LHE_pythia8','NANOGENFromGen']]
workflows[548]=['',['TTbar_Pow_LHE_13TeV','Hadronizer_TuneCP5_13TeV_powhegEmissionVeto2p_pythia8','NANOGENFromGen']]
5 changes: 5 additions & 0 deletions Configuration/PyReleaseValidation/python/relval_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3119,11 +3119,16 @@ def gen2021HiMix(fragment,howMuch):
steps['MINIAODMCUP18ml'] =merge([concurrentLumis,steps['MINIAODMCUP18']])

stepNanoAODDefaults = { '-s': 'NANO,DQM:@nanoAODDQM', '-n': 1000 }
stepNanoGenDefaults = { '-s': 'NANOGEN,DQM:@nanogenDQM', '-n': 1000 }
stepNanoAODData = merge([{ '--data':'', '--eventcontent' : 'NANOAOD,DQM' ,'--datatier': 'NANOAOD,DQMIO' }, stepNanoAODDefaults ])
stepNanoAODMC = merge([{ '--mc':'' , '--eventcontent' : 'NANOAODSIM,DQM','--datatier': 'NANOAODSIM,DQMIO' }, stepNanoAODDefaults ])
stepNanoEDMData = merge([{ '--data':'', '--eventcontent' : 'NANOEDMAOD,DQM' ,'--datatier': 'NANOAOD,DQMIO' }, stepNanoAODDefaults ])
stepNanoEDMMC = merge([{ '--mc':'' , '--eventcontent' : 'NANOEDMAODSIM,DQM','--datatier': 'NANOAODSIM,DQMIO' }, stepNanoAODDefaults ])
stepNanoEDMMCProd = merge([{ '--mc':'', '-s': 'NANO', '--eventcontent' : 'NANOEDMAODSIM','--datatier': 'NANOAODSIM' }, stepNanoAODDefaults ])
stepNanoGen = merge([{ '--mc':'' , '--eventcontent' : 'NANOAODGEN,DQM','--datatier': 'NANOAODSIM,DQMIO' }, stepNanoGenDefaults ])

steps['NANOGENFromGen'] = merge([{'--conditions': 'auto:run2_mc', '--customise' : 'PhysicsTools/NanoAOD/nanogen_cff.customizeNanoGEN'}, stepNanoGen ])
steps['NANOGENFromMini'] = merge([{'--conditions': 'auto:run2_mc'}, stepNanoGen ])

steps['NANOAOD2016'] = merge([{'--conditions': 'auto:run2_data_relval', '--era': 'Run2_2016'}, stepNanoAODData ])
steps['NANOAOD2017'] = merge([{'--conditions': 'auto:run2_data_relval', '--era': 'Run2_2017'}, stepNanoAODData ])
Expand Down
2 changes: 2 additions & 0 deletions DQMOffline/Configuration/python/DQMOffline_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,5 @@
from PhysicsTools.NanoAOD.nanoDQM_cff import nanoDQM
DQMOfflineNanoAOD = cms.Sequence(nanoDQM)
#PostDQMOfflineNanoAOD = cms.Sequence(nanoDQM)
from PhysicsTools.NanoAOD.nanogenDQM_cff import nanogenDQM
DQMOfflineNanoGen = cms.Sequence(nanogenDQM)
4 changes: 4 additions & 0 deletions DQMOffline/Configuration/python/autoDQM.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@
'PostDQMOffline',
'DQMHarvestNanoAOD'],

'nanogenDQM': ['DQMOfflineNanoGen',
'PostDQMOffline',
'DQMHarvestNanoAOD'],

'pfDQM': ['DQMOfflinePF+DQMOfflinePFExtended',
'PostDQMOffline',
'DQMHarvestPF'],
Expand Down
7 changes: 6 additions & 1 deletion PhysicsTools/NanoAOD/python/NanoAODEDMEventContent_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
compressionLevel = cms.untracked.int32(9),
compressionAlgorithm = cms.untracked.string("LZMA"),
)
NANOAODGENEventContent = NanoAODEDMEventContent.clone(

NanoGenOutput = NanoAODEDMEventContent.outputCommands[:]
NanoGenOutput.remove("keep edmTriggerResults_*_*_*")

NANOAODGENEventContent = cms.PSet(
compressionLevel = cms.untracked.int32(9),
compressionAlgorithm = cms.untracked.string("LZMA"),
outputCommands = cms.untracked.vstring(NanoGenOutput)
)
25 changes: 25 additions & 0 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,31 @@
Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'),
)
),
LHEPart = cms.PSet(
sels = cms.PSet(),
plots = cms.VPSet(
Count1D('_size', 20, 0, 20, 'LHE particles'),
Plot1D('eta', 'eta', 20, -30000, 30000, 'eta'),
Plot1D('pdgId', 'pdgId', 20, -6000, 6000, 'PDG id'),
Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
Plot1D('pt', 'pt', 20, 0, 200, 'pt'),
)
),
LHEPdfWeight = cms.PSet(
sels = cms.PSet(),
plots = cms.VPSet(
Count1D('_size', 1000, 0, 2000, 'LHE PDF weights'),
Plot1D('', '', 100, 0, 2, 'all weights'),
)
),
LHEScaleWeight = cms.PSet(
sels = cms.PSet(),
plots = cms.VPSet(
Count1D('_size', 20, 0, 20, 'LHE scale weights'),
Plot1D('', '', 100, 0, 2, 'all weights'),
)
),

MET = cms.PSet(
sels = cms.PSet(),
plots = cms.VPSet(
Expand Down
32 changes: 32 additions & 0 deletions PhysicsTools/NanoAOD/python/nanogenDQM_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import FWCore.ParameterSet.Config as cms
import copy

from PhysicsTools.NanoAOD.nanoDQM_cfi import nanoDQM
from PhysicsTools.NanoAOD.nanoDQM_tools_cff import *
from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer

nanogenDQM = DQMEDAnalyzer("NanoAODDQM",
vplots = cms.PSet(GenDressedLepton = nanoDQM.vplots.GenDressedLepton,
GenIsolatedPhoton = nanoDQM.vplots.GenIsolatedPhoton,
GenJet = nanoDQM.vplots.GenJet,
GenJetAK8 = nanoDQM.vplots.GenJetAK8,
GenMET = nanoDQM.vplots.GenMET,
GenPart = nanoDQM.vplots.GenPart,
GenVisTau = nanoDQM.vplots.GenVisTau,
LHEPart = nanoDQM.vplots.LHEPart,
LHEScaleWeight = nanoDQM.vplots.LHEScaleWeight,
LHEPdfWeight = nanoDQM.vplots.LHEPdfWeight,
PSWeight = nanoDQM.vplots.PSWeight,
)
)

from DQMServices.Core.DQMQualityTester import DQMQualityTester
nanoDQMQTester = DQMQualityTester(
qtList = cms.untracked.FileInPath('PhysicsTools/NanoAOD/test/dqmQualityTests.xml'),
prescaleFactor = cms.untracked.int32(1),
testInEventloop = cms.untracked.bool(False),
qtestOnEndLumi = cms.untracked.bool(False),
verboseQT = cms.untracked.bool(True)
)

nanogenHarvest = cms.Sequence( nanoDQMQTester )
81 changes: 42 additions & 39 deletions PhysicsTools/NanoAOD/python/nanogen_cff.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
from PhysicsTools.NanoAOD.taus_cff import *
from PhysicsTools.NanoAOD.jets_cff import *
from PhysicsTools.NanoAOD.globals_cff import *
from PhysicsTools.NanoAOD.globals_cff import genTable
from PhysicsTools.NanoAOD.met_cff import metMCTable
from PhysicsTools.NanoAOD.genparticles_cff import *
from PhysicsTools.NanoAOD.particlelevel_cff import *
from PhysicsTools.NanoAOD.lheInfoTable_cfi import *
from PhysicsTools.NanoAOD.genWeightsTable_cfi import *
from PhysicsTools.NanoAOD.common_cff import CandVars

nanoMetadata = cms.EDProducer("UniqueStringProducer",
strings = cms.PSet(
tag = cms.string("untagged"),
)
)

metGenTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("genMetTrue"),
name = cms.string("GenMET"),
doc = cms.string("Gen MET"),
singleton = cms.bool(True),
extension = cms.bool(False),
variables = cms.PSet(
pt = Var("pt", float, doc="pt", precision=10),
phi = Var("phi", float, doc="phi", precision=10),
),
)

nanogenSequence = cms.Sequence(
nanoMetadata+
particleLevel+
Expand All @@ -43,29 +33,13 @@
tautagger+
rivetProducerHTXS+
particleLevelTables+
metGenTable+
metMCTable+
genWeightsTable+
lheInfoTable
)

NANOAODGENoutput = cms.OutputModule("NanoAODOutputModule",
compressionAlgorithm = cms.untracked.string('LZMA'),
compressionLevel = cms.untracked.int32(9),
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('NANOAODSIM'),
filterName = cms.untracked.string('')
),
fileName = cms.untracked.string('nanogen.root'),
outputCommands = cms.untracked.vstring(
'drop *',
"keep nanoaodFlatTable_*Table_*_*", # event data
"keep String_*_genModel_*", # generator model data
"keep nanoaodMergeableCounterTable_*Table_*_*", # accumulated per/run or per/lumi data
"keep nanoaodUniqueString_nanoMetadata_*_*", # basic metadata
)
)

def nanoGenCommonCustomize(process):
process.rivetMetTable.extension = False
process.lheInfoTable.storeLHEParticles = True
process.lheInfoTable.precision = 14
process.genWeightsTable.keepAllPSWeights = True
Expand All @@ -77,12 +51,20 @@ def nanoGenCommonCustomize(process):
process.particleLevel.lepMinPt = 0.
process.particleLevel.lepMaxEta = 999.
process.genJetFlavourTable.jetFlavourInfos = "genJetFlavourAssociation"
# Same as default RECO
setGenPhiPrecision(process, CandVars.pt.precision)
setGenPtPrecision(process, CandVars.eta.precision)
setGenPhiPrecision(process, CandVars.phi.precision)

def customizeNanoGENFromMini(process):
process.nanoAOD_step.insert(0, process.genParticles2HepMCHiggsVtx)
process.nanoAOD_step.insert(0, process.genParticles2HepMC)
process.nanoAOD_step.insert(0, process.mergedGenParticles)

process.metMCTable.src = "slimmedMETs"
process.metMCTable.variables.pt = Var("genMET.pt", float, doc="pt", precision=10)
process.metMCTable.variables.phi = Var("genMET.phi", float, doc="phi", precision=10)

process.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared"
process.genParticleTable.src = "prunedGenParticles"
process.patJetPartons.particles = "prunedGenParticles"
Expand All @@ -97,6 +79,10 @@ def customizeNanoGENFromMini(process):
return process

def customizeNanoGEN(process):
process.metMCTable.src = "genMetTrue"
process.metMCTable.variables.pt = Var("pt", float, doc="pt", precision=10)
process.metMCTable.variables.phi = Var("phi", float, doc="phi", precision=10)

process.rivetProducerHTXS.HepMCCollection = "generatorSmeared"
process.genParticleTable.src = "genParticles"
process.patJetPartons.particles = "genParticles"
Expand All @@ -106,6 +92,11 @@ def customizeNanoGEN(process):
process.genJetAK8Table.src = "ak8GenJets"
process.tauGenJets.GenParticles = "genParticles"
process.genVisTaus.srcGenParticles = "genParticles"

# In case customizeNanoGENFromMini has already been called
process.nanoAOD_step.remove(process.genParticles2HepMCHiggsVtx)
process.nanoAOD_step.remove(process.genParticles2HepMC)
process.nanoAOD_step.remove(process.mergedGenParticles)
nanoGenCommonCustomize(process)
return process

Expand All @@ -130,14 +121,26 @@ def pruneGenParticlesMini(process):
return process

def setGenFullPrecision(process):
process.genParticleTable.variables.pt.precision = 23
process.genParticleTable.variables.eta.precision = 23
process.genParticleTable.variables.phi.precision = 23
process.genJetTable.variables.pt.precision = 23
process.genJetTable.variables.eta.precision = 23
process.genJetTable.variables.phi.precision = 23
process.metGenTable.variables.pt.precision = 23
process.metGenTable.variables.phi.precision = 23
setGenPtPrecision(process, 23)
setGenEtaPrecision(process, 23)
setGenPhiPrecision(process, 23)

def setGenPtPrecision(process, precision):
process.genParticleTable.variables.pt.precision = precision
process.genJetTable.variables.pt.precision = precision
process.metMCTable.variables.pt.precision = precision
return process

def setGenEtaPrecision(process, precision):
process.genParticleTable.variables.eta.precision = precision
process.genJetTable.variables.eta.precision = precision
process.metMCTable.variables.eta.precision = precision
return process

def setGenPhiPrecision(process, precision):
process.genParticleTable.variables.phi.precision = precision
process.genJetTable.variables.phi.precision = precision
process.metMCTable.variables.phi.precision = precision
return process

def setLHEFullPrecision(process):
Expand Down

0 comments on commit bd56616

Please sign in to comment.