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 ''' 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..c9d0795ec1e99 100644 --- a/DQMOffline/Configuration/python/autoDQM.py +++ b/DQMOffline/Configuration/python/autoDQM.py @@ -100,6 +100,10 @@ 'PostDQMOffline', 'DQMHarvestNanoAOD'], + 'nanogenDQM': ['DQMOfflineNanoGen', + 'PostDQMOffline', + 'DQMHarvestNanoAOD'], + '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/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/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 3a1b537810e82..3610c063e9035 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -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( diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 7c81f6112bb33..c752f16ec18b4 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/nanogenDQM_cff.py b/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py new file mode 100644 index 0000000000000..47ddec519bb25 --- /dev/null +++ b/PhysicsTools/NanoAOD/python/nanogenDQM_cff.py @@ -0,0 +1,31 @@ +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, + ) +) + +nanoDQMQTester = cms.EDAnalyzer("QualityTester", + 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..88878addd4506 --- /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 Var,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.genWeightsTable.keepAllPSWeights = True + 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 + setGenPtPrecision(process, CandVars.pt.precision) + setGenEtaPrecision(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") + 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" + 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 = cms.PSet(PTVars) + + 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 + 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