-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30306 from kdlong/NanoGen_master
GEN-only NanoAOD configs (NanoGEN) and cmsDriver support
- Loading branch information
Showing
5 changed files
with
187 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
genWeightsTable = cms.EDProducer("GenWeightsTableProducer", | ||
genEvent = cms.InputTag("generator"), | ||
genLumiInfoHeader = cms.InputTag("generator"), | ||
lheInfo = cms.VInputTag(cms.InputTag("externalLHEProducer"), cms.InputTag("source")), | ||
preferredPDFs = cms.VPSet( # see https://lhapdf.hepforge.org/pdfsets.html | ||
cms.PSet( name = cms.string("PDF4LHC15_nnlo_30_pdfas"), lhaid = cms.uint32(91400) ), | ||
cms.PSet( name = cms.string("NNPDF31_nnlo_hessian_pdfas"), lhaid = cms.uint32(306000) ), | ||
cms.PSet( name = cms.string("NNPDF30_nlo_as_0118"), lhaid = cms.uint32(260000) ), # for some 92X samples. Note that the nominal weight, 260000, is not included in the LHE ... | ||
cms.PSet( name = cms.string("NNPDF30_lo_as_0130"), lhaid = cms.uint32(262000) ), # some MLM 80X samples have only this (e.g. /store/mc/RunIISummer16MiniAODv2/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/MINIAODSIM/PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6_ext1-v2/120000/02A210D6-F5C3-E611-B570-008CFA197BD4.root ) | ||
cms.PSet( name = cms.string("NNPDF30_nlo_nf_4_pdfas"), lhaid = cms.uint32(292000) ), # some FXFX 80X samples have only this (e.g. WWTo1L1Nu2Q, WWTo4Q) | ||
cms.PSet( name = cms.string("NNPDF30_nlo_nf_5_pdfas"), lhaid = cms.uint32(292200) ), # some FXFX 80X samples have only this (e.g. DYJetsToLL_Pt, WJetsToLNu_Pt, DYJetsToNuNu_Pt) | ||
), | ||
namedWeightIDs = cms.vstring(), | ||
namedWeightLabels = cms.vstring(), | ||
lheWeightPrecision = cms.int32(14), | ||
maxPdfWeights = cms.uint32(150), | ||
debug = cms.untracked.bool(False), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
from PhysicsTools.NanoAOD.taus_cff import * | ||
from PhysicsTools.NanoAOD.jets_cff import * | ||
from PhysicsTools.NanoAOD.globals_cff import * | ||
from PhysicsTools.NanoAOD.genparticles_cff import * | ||
from PhysicsTools.NanoAOD.particlelevel_cff import * | ||
from PhysicsTools.NanoAOD.lheInfoTable_cfi import * | ||
from PhysicsTools.NanoAOD.genWeightsTable_cfi import * | ||
|
||
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+ | ||
genJetTable+ | ||
patJetPartons+ | ||
genJetFlavourAssociation+ | ||
genJetFlavourTable+ | ||
genJetAK8Table+ | ||
genJetAK8FlavourAssociation+ | ||
genJetAK8FlavourTable+ | ||
tauGenJets+ | ||
tauGenJetsSelectorAllHadrons+ | ||
genVisTaus+ | ||
genVisTauTable+ | ||
genTable+ | ||
genParticleTables+ | ||
tautagger+ | ||
rivetProducerHTXS+ | ||
particleLevelTables+ | ||
metGenTable+ | ||
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.lheInfoTable.storeLHEParticles = True | ||
process.lheInfoTable.precision = 14 | ||
process.genJetFlavourAssociation.jets = process.genJetTable.src | ||
process.genJetFlavourTable.src = process.genJetTable.src | ||
process.genJetAK8FlavourAssociation.jets = process.genJetAK8Table.src | ||
process.genJetAK8FlavourTable.src = process.genJetAK8Table.src | ||
process.particleLevel.particleMaxEta = 999. | ||
process.particleLevel.lepMinPt = 0. | ||
process.particleLevel.lepMaxEta = 999. | ||
process.genJetFlavourTable.jetFlavourInfos = "genJetFlavourAssociation" | ||
|
||
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.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared" | ||
process.genParticleTable.src = "prunedGenParticles" | ||
process.patJetPartons.particles = "prunedGenParticles" | ||
process.particleLevel.src = "genParticles2HepMC:unsmeared" | ||
|
||
process.genJetTable.src = "slimmedGenJets" | ||
process.genJetAK8Table.src = "slimmedGenJetsAK8" | ||
process.tauGenJets.GenParticles = "prunedGenParticles" | ||
process.genVisTaus.srcGenParticles = "prunedGenParticles" | ||
nanoGenCommonCustomize(process) | ||
|
||
return process | ||
|
||
def customizeNanoGEN(process): | ||
process.rivetProducerHTXS.HepMCCollection = "generatorSmeared" | ||
process.genParticleTable.src = "genParticles" | ||
process.patJetPartons.particles = "genParticles" | ||
process.particleLevel.src = "generatorSmeared" | ||
|
||
process.genJetTable.src = "ak4GenJets" | ||
process.genJetAK8Table.src = "ak8GenJets" | ||
process.tauGenJets.GenParticles = "genParticles" | ||
process.genVisTaus.srcGenParticles = "genParticles" | ||
nanoGenCommonCustomize(process) | ||
return process | ||
|
||
# Prune gen particles with tight conditions applied in usual NanoAOD | ||
def pruneGenParticlesNano(process): | ||
process.finalGenParticles = finalGenParticles.clone() | ||
process.genParticleTable.src = "prunedGenParticles" | ||
process.patJetPartons.particles = "prunedGenParticles" | ||
process.nanoAOD_step.insert(0, process.finalGenParticles) | ||
return process | ||
|
||
# Prune gen particles with conditions applied in usual MiniAOD | ||
def pruneGenParticlesMini(process): | ||
from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles | ||
process.prunedGenParticles = prunedGenParticles.clone() | ||
if process.nanoAOD_step.contains(process.nanogenMiniSequence): | ||
raise ValueError("Applying the MiniAOD genParticle pruner to MiniAOD is redunant. " \ | ||
"Use a different customization.") | ||
process.genParticleTable.src = "prunedGenParticles" | ||
process.patJetPartons.particles = "prunedGenParticles" | ||
process.nanoAOD_step.insert(0, process.prunedGenParticles) | ||
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 | ||
return process | ||
|
||
def setLHEFullPrecision(process): | ||
process.lheInfoTable.precision = 23 | ||
return process | ||
|
||
def setGenWeightsFullPrecision(process): | ||
process.genWeightsTable.lheWeightPrecision = 23 | ||
return process |