From 79c92f1016637de0d794dbe1c52a412b5dad8b7d Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Fri, 3 Apr 2020 13:34:39 +0200 Subject: [PATCH 1/6] Add NanoGen configs Fix NanoGEN weights tables, work from MinAOD No cuts on dressed leptons for nanogen Add customize functions Simplify NanoGEN from Mini workflow Run NanoGen from runTheMatrix.py Add DQM support, improve nanogen configs Clean up output, remove trigger branches Revert accidental change Add nanogenDQM file A few more NanoGen DQM plots, update default precision Add lhe and weights plots to main nano dqm Update generator configs Minimize changes to nanoDQM fix duplicates --- ...eCP5_13TeV_MLM_5f_max4j_LHE_pythia8_cff.py | 3 + ..._13TeV_powhegEmissionVeto2p_pythia8_cff.py | 3 + .../python/relval_generator.py | 3 + .../python/relval_steps.py | 5 + .../Configuration/python/DQMOffline_cff.py | 3 + DQMOffline/Configuration/python/autoDQM.py | 9 ++ .../python/NanoAODEDMEventContent_cff.py | 9 ++ PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 25 +++ PhysicsTools/NanoAOD/python/nanogenDQM_cff.py | 32 ++++ PhysicsTools/NanoAOD/python/nanogen_cff.py | 151 ++++++++++++++++++ 10 files changed, 243 insertions(+) create mode 100644 PhysicsTools/NanoAOD/python/nanogenDQM_cff.py create mode 100644 PhysicsTools/NanoAOD/python/nanogen_cff.py diff --git a/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_MLM_5f_max4j_LHE_pythia8_cff.py b/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_MLM_5f_max4j_LHE_pythia8_cff.py index 916596eb0c51e..c3d00695e9ef6 100644 --- a/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_MLM_5f_max4j_LHE_pythia8_cff.py +++ b/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_MLM_5f_max4j_LHE_pythia8_cff.py @@ -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("Pythia8HadronizerFilter", maxEventsToPrint = cms.untracked.int32(1), @@ -13,6 +14,7 @@ PythiaParameters = cms.PSet( pythia8CommonSettingsBlock, pythia8CP5SettingsBlock, + pythia8PSweightsSettingsBlock, JetMatchingParameters = cms.vstring( 'JetMatching:setMad = off', 'JetMatching:scheme = 1', @@ -28,6 +30,7 @@ ), parameterSets = cms.vstring('pythia8CommonSettings', 'pythia8CP5Settings', + 'pythia8PSweightsSettings', 'JetMatchingParameters' ) diff --git a/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_powhegEmissionVeto2p_pythia8_cff.py b/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_powhegEmissionVeto2p_pythia8_cff.py index 51e4881fe3edf..ee27799008edd 100644 --- a/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_powhegEmissionVeto2p_pythia8_cff.py +++ b/Configuration/Generator/python/Hadronizer_TuneCP5_13TeV_powhegEmissionVeto2p_pythia8_cff.py @@ -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("Pythia8HadronizerFilter", maxEventsToPrint = cms.untracked.int32(1), @@ -12,6 +13,7 @@ PythiaParameters = cms.PSet( pythia8CommonSettingsBlock, pythia8CP5SettingsBlock, + pythia8PSweightsSettingsBlock, pythia8PowhegEmissionVetoSettingsBlock, processParameters = cms.vstring( 'POWHEG:nFinal = 2', ## Number of final state particles @@ -21,6 +23,7 @@ ), parameterSets = cms.vstring('pythia8CommonSettings', 'pythia8CP5Settings', + 'pythia8PSweightsSettings', 'pythia8PowhegEmissionVetoSettings', 'processParameters' ) diff --git a/Configuration/PyReleaseValidation/python/relval_generator.py b/Configuration/PyReleaseValidation/python/relval_generator.py index 984d6b48f6e93..18d6844f45b6b 100644 --- a/Configuration/PyReleaseValidation/python/relval_generator.py +++ b/Configuration/PyReleaseValidation/python/relval_generator.py @@ -40,3 +40,6 @@ workflows[545]=['',['BsToMuMu_forSTEAM_13TeV_TuneCUETP8M1','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']] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index b314420b01ec8..594926f98e770 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2905,11 +2905,16 @@ def gen2018HiMix(fragment,howMuch): steps['MINIAODMCUP18FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018_FastSim'},stepMiniAODMC]) 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 ]) diff --git a/DQMOffline/Configuration/python/DQMOffline_cff.py b/DQMOffline/Configuration/python/DQMOffline_cff.py index f3ebc32d5ef66..39c3be48d7f51 100644 --- a/DQMOffline/Configuration/python/DQMOffline_cff.py +++ b/DQMOffline/Configuration/python/DQMOffline_cff.py @@ -191,6 +191,9 @@ DQMOfflineNanoAOD = cms.Sequence(nanoDQM) #PostDQMOfflineNanoAOD = cms.Sequence(nanoDQM) +from PhysicsTools.NanoAOD.nanogenDQM_cff import nanogenDQM +DQMOfflineNanoGen = cms.Sequence(nanogenDQM) + # L1 trigger sequences DQMOfflineL1TMonitoring = cms.Sequence( l1TriggerDqmOffline ) # L1 emulator is run within this sequence for real data diff --git a/DQMOffline/Configuration/python/autoDQM.py b/DQMOffline/Configuration/python/autoDQM.py index 920b7a543bc2e..914bcd12eb787 100644 --- a/DQMOffline/Configuration/python/autoDQM.py +++ b/DQMOffline/Configuration/python/autoDQM.py @@ -100,6 +100,15 @@ 'PostDQMOffline', 'DQMHarvestNanoAOD'], + 'nanogenDQM': ['DQMOfflineNanoGen', + 'PostDQMOffline', + 'DQMHarvestNanoAOD'], + + 'pfDQM': ['DQMOfflinePF+DQMOfflinePFExtended', + 'PostDQMOffline', + 'DQMHarvestPF'], + +# 'standardDQM': ['@dcs+@DQMMessageLogger+@ecal+@hcal+@hcal2+@strip+@pixel+@castor+@ctpps+@muon+@tracking+@jetmet+@egamma+@L1TMon+@hlt+@btag+@beam+@physics+@HLTMon', 'standardDQM': ['DQMOffline', 'PostDQMOffline', 'dqmHarvesting'], diff --git a/PhysicsTools/NanoAOD/python/NanoAODEDMEventContent_cff.py b/PhysicsTools/NanoAOD/python/NanoAODEDMEventContent_cff.py index d9722f0e5be98..d2e1f939d795e 100644 --- a/PhysicsTools/NanoAOD/python/NanoAODEDMEventContent_cff.py +++ b/PhysicsTools/NanoAOD/python/NanoAODEDMEventContent_cff.py @@ -19,3 +19,12 @@ compressionLevel = cms.untracked.int32(9), compressionAlgorithm = cms.untracked.string("LZMA"), ) + +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) +) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index eeeba95010197..5ce6f81f8e03f 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -382,6 +382,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( diff --git a/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py b/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py new file mode 100644 index 0000000000000..b7f8b408df4c2 --- /dev/null +++ b/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py @@ -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 ) diff --git a/PhysicsTools/NanoAOD/python/nanogen_cff.py b/PhysicsTools/NanoAOD/python/nanogen_cff.py new file mode 100644 index 0000000000000..201d6eb95eff7 --- /dev/null +++ b/PhysicsTools/NanoAOD/python/nanogen_cff.py @@ -0,0 +1,151 @@ +from PhysicsTools.NanoAOD.taus_cff import * +from PhysicsTools.NanoAOD.jets_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"), + ) +) + +nanogenSequence = cms.Sequence( + nanoMetadata+ + particleLevel+ + genJetTable+ + patJetPartons+ + genJetFlavourAssociation+ + genJetFlavourTable+ + genJetAK8Table+ + genJetAK8FlavourAssociation+ + genJetAK8FlavourTable+ + tauGenJets+ + tauGenJetsSelectorAllHadrons+ + genVisTaus+ + genVisTauTable+ + genTable+ + genParticleTables+ + tautagger+ + rivetProducerHTXS+ + particleLevelTables+ + metMCTable+ + genWeightsTable+ + lheInfoTable +) + +def nanoGenCommonCustomize(process): + process.rivetMetTable.extension = False + 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" + # 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" + 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.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" + process.particleLevel.src = "generatorSmeared" + + process.genJetTable.src = "ak4GenJets" + 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 + +# 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): + 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): + process.lheInfoTable.precision = 23 + return process + +def setGenWeightsFullPrecision(process): + process.genWeightsTable.lheWeightPrecision = 23 + return process From 6a9fd087a5bd94892b54456a21e902e90d597684 Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Fri, 3 Apr 2020 13:34:39 +0200 Subject: [PATCH 2/6] Fix issue with cmsDriver from cherry-pick --- Configuration/Applications/python/ConfigBuilder.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Configuration/Applications/python/ConfigBuilder.py b/Configuration/Applications/python/ConfigBuilder.py index 7c87182d6df10..ee710cbcf04cb 100644 --- a/Configuration/Applications/python/ConfigBuilder.py +++ b/Configuration/Applications/python/ConfigBuilder.py @@ -937,6 +937,7 @@ def define_Configs(self): self.RECOSIMDefaultCFF="Configuration/StandardSequences/RecoSim_cff" self.PATDefaultCFF="Configuration/StandardSequences/PAT_cff" self.NANODefaultCFF="PhysicsTools/NanoAOD/nano_cff" + self.NANOGENDefaultCFF="PhysicsTools/NanoAOD/nanogen_cff" self.EIDefaultCFF=None self.SKIMDefaultCFF="Configuration/StandardSequences/Skims_cff" self.POSTRECODefaultCFF="Configuration/StandardSequences/PostRecoGenerator_cff" @@ -986,6 +987,8 @@ def define_Configs(self): self.REPACKDefaultSeq='DigiToRawRepack' self.PATDefaultSeq='miniAOD' self.PATGENDefaultSeq='miniGEN' + #TODO: Check based of file input + self.NANOGENDefaultSeq='nanogenSequence' self.NANODefaultSeq='nanoSequence' self.EVTCONTDefaultCFF="Configuration/EventContent/EventContent_cff" @@ -1689,6 +1692,17 @@ def prepare_NANO(self, sequence = "nanoAOD"): self._options.customise_commands = self._options.customise_commands + " \n" self._options.customise_commands = self._options.customise_commands + "process.unpackedPatTrigger.triggerResults= cms.InputTag( 'TriggerResults::"+self._options.hltProcess+"' )\n" + def prepare_NANOGEN(self, sequence = "nanoAOD"): + ''' Enrich the schedule with NANOGEN ''' + # TODO: Need to modify this based on the input file type + fromGen = any([x in self.stepMap for x in ['LHE', 'GEN', 'AOD']]) + self.loadDefaultOrSpecifiedCFF(sequence,self.NANOGENDefaultCFF) + self.scheduleSequence(sequence.split('.')[-1],'nanoAOD_step') + custom = "customizeNanoGEN" if fromGen else "customizeNanoGENFromMini" + if self._options.runUnscheduled: + self._options.customisation_file_unsch.insert(0, '.'.join([self.NANOGENDefaultCFF, custom])) + else: + self._options.customisation_file.insert(0, '.'.join([self.NANOGENDefaultCFF, custom])) def prepare_EI(self, sequence = None): ''' Enrich the schedule with event interpretation ''' From b11d49612d8ed8faac2ec3b0b7069bccf5552398 Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Thu, 22 Oct 2020 19:02:17 +0200 Subject: [PATCH 3/6] Add genWeights table, fix dqm --- .../NanoAOD/python/genWeightsTable_cfi.py | 21 +++++++++++++++++++ PhysicsTools/NanoAOD/python/nanogenDQM_cff.py | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 PhysicsTools/NanoAOD/python/genWeightsTable_cfi.py diff --git a/PhysicsTools/NanoAOD/python/genWeightsTable_cfi.py b/PhysicsTools/NanoAOD/python/genWeightsTable_cfi.py new file mode 100644 index 0000000000000..1ca662a85b90e --- /dev/null +++ b/PhysicsTools/NanoAOD/python/genWeightsTable_cfi.py @@ -0,0 +1,21 @@ +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), + keepAllPSWeights = cms.bool(False), + debug = cms.untracked.bool(False), +) diff --git a/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py b/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py index b7f8b408df4c2..47ddec519bb25 100644 --- a/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py +++ b/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py @@ -20,8 +20,7 @@ ) ) -from DQMServices.Core.DQMQualityTester import DQMQualityTester -nanoDQMQTester = DQMQualityTester( +nanoDQMQTester = cms.EDAnalyzer("QualityTester", qtList = cms.untracked.FileInPath('PhysicsTools/NanoAOD/test/dqmQualityTests.xml'), prescaleFactor = cms.untracked.int32(1), testInEventloop = cms.untracked.bool(False), From bfbc678ecc3fa26c122845188a66eca0e60f750f Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Wed, 28 Oct 2020 15:17:31 +0100 Subject: [PATCH 4/6] Fixes to make backport fully consistent with master --- DQMOffline/Configuration/python/autoDQM.py | 5 ----- PhysicsTools/NanoAOD/python/nano_cff.py | 21 +-------------------- PhysicsTools/NanoAOD/python/nanogen_cff.py | 1 + 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/DQMOffline/Configuration/python/autoDQM.py b/DQMOffline/Configuration/python/autoDQM.py index 914bcd12eb787..c9d0795ec1e99 100644 --- a/DQMOffline/Configuration/python/autoDQM.py +++ b/DQMOffline/Configuration/python/autoDQM.py @@ -104,11 +104,6 @@ 'PostDQMOffline', 'DQMHarvestNanoAOD'], - 'pfDQM': ['DQMOfflinePF+DQMOfflinePFExtended', - 'PostDQMOffline', - 'DQMHarvestPF'], - -# 'standardDQM': ['@dcs+@DQMMessageLogger+@ecal+@hcal+@hcal2+@strip+@pixel+@castor+@ctpps+@muon+@tracking+@jetmet+@egamma+@L1TMon+@hlt+@btag+@beam+@physics+@HLTMon', 'standardDQM': ['DQMOffline', 'PostDQMOffline', 'dqmHarvesting'], diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 0613329795ab0..0ea4db29ad9df 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -11,6 +11,7 @@ from PhysicsTools.NanoAOD.ttbarCategorization_cff import * from PhysicsTools.NanoAOD.genparticles_cff import * from PhysicsTools.NanoAOD.particlelevel_cff import * +from PhysicsTools.NanoAOD.genWeightsTable_cfi import * from PhysicsTools.NanoAOD.vertices_cff import * from PhysicsTools.NanoAOD.met_cff import * from PhysicsTools.NanoAOD.triggerObjects_cff import * @@ -96,26 +97,6 @@ ) -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) - cms.PSet( name = cms.string("NNPDF31_lo_as_0130"), lhaid = cms.uint32(315200) ), # SUSY signal samples use this - ), - namedWeightIDs = cms.vstring(), - namedWeightLabels = cms.vstring(), - lheWeightPrecision = cms.int32(14), - keepAllPSWeights = cms.bool(False), - maxPdfWeights = cms.uint32(150), - debug = cms.untracked.bool(False), -) lheInfoTable = cms.EDProducer("LHETablesProducer", lheInfo = cms.VInputTag(cms.InputTag("externalLHEProducer"), cms.InputTag("source")), precision = cms.int32(14), diff --git a/PhysicsTools/NanoAOD/python/nanogen_cff.py b/PhysicsTools/NanoAOD/python/nanogen_cff.py index 201d6eb95eff7..25c3efcb0b332 100644 --- a/PhysicsTools/NanoAOD/python/nanogen_cff.py +++ b/PhysicsTools/NanoAOD/python/nanogen_cff.py @@ -42,6 +42,7 @@ def nanoGenCommonCustomize(process): process.rivetMetTable.extension = False process.lheInfoTable.storeLHEParticles = True process.lheInfoTable.precision = 14 + process.genWeightsTable.keepAllPSWeights = True process.genJetFlavourAssociation.jets = process.genJetTable.src process.genJetFlavourTable.src = process.genJetTable.src process.genJetAK8FlavourAssociation.jets = process.genJetAK8Table.src From 5627eb69a3dcd4e73c91ac6baab7e57b757fe66b Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Wed, 28 Oct 2020 15:21:50 +0100 Subject: [PATCH 5/6] Fix bug in NanoGEN precision setting --- PhysicsTools/NanoAOD/python/nanogen_cff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanogen_cff.py b/PhysicsTools/NanoAOD/python/nanogen_cff.py index 25c3efcb0b332..1716ed6a042ce 100644 --- a/PhysicsTools/NanoAOD/python/nanogen_cff.py +++ b/PhysicsTools/NanoAOD/python/nanogen_cff.py @@ -52,8 +52,8 @@ def nanoGenCommonCustomize(process): process.particleLevel.lepMaxEta = 999. process.genJetFlavourTable.jetFlavourInfos = "genJetFlavourAssociation" # Same as default RECO - setGenPhiPrecision(process, CandVars.pt.precision) - setGenPtPrecision(process, CandVars.eta.precision) + setGenPtPrecision(process, CandVars.pt.precision) + setGenEtaPrecision(process, CandVars.eta.precision) setGenPhiPrecision(process, CandVars.phi.precision) def customizeNanoGENFromMini(process): From ee389cce0ddb2c861be670fc7330d7e00f815a3f Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Wed, 28 Oct 2020 15:21:50 +0100 Subject: [PATCH 6/6] Fix bug in NanoGEN precision setting Better code reuse --- PhysicsTools/NanoAOD/python/nanogen_cff.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanogen_cff.py b/PhysicsTools/NanoAOD/python/nanogen_cff.py index 1716ed6a042ce..88878addd4506 100644 --- a/PhysicsTools/NanoAOD/python/nanogen_cff.py +++ b/PhysicsTools/NanoAOD/python/nanogen_cff.py @@ -6,7 +6,7 @@ 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 +from PhysicsTools.NanoAOD.common_cff import Var,CandVars nanoMetadata = cms.EDProducer("UniqueStringProducer", strings = cms.PSet( @@ -62,8 +62,9 @@ def customizeNanoGENFromMini(process): 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.metMCTable.variables.pt = Var("genMET.pt", float, doc="pt") + process.metMCTable.variables.phi = Var("genMET.phi", float, doc="phi") + process.metMCTable.variables.phi.precision = CandVars.phi.precision process.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared" process.genParticleTable.src = "prunedGenParticles" @@ -80,8 +81,7 @@ def customizeNanoGENFromMini(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.metMCTable.variables = cms.PSet(PTVars) process.rivetProducerHTXS.HepMCCollection = "generatorSmeared" process.genParticleTable.src = "genParticles" @@ -134,7 +134,6 @@ def setGenPtPrecision(process, precision): 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):