Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-14 23:39:44

0001 from PhysicsTools.NanoAOD.taus_cff import *
0002 from PhysicsTools.NanoAOD.jetMC_cff import *
0003 from PhysicsTools.NanoAOD.globals_cff import genTable,genFilterTable
0004 from PhysicsTools.NanoAOD.met_cff import metMCTable
0005 from PhysicsTools.NanoAOD.genparticles_cff import *
0006 from PhysicsTools.NanoAOD.particlelevel_cff import *
0007 from PhysicsTools.NanoAOD.genWeightsTable_cfi import *
0008 from PhysicsTools.NanoAOD.genVertex_cff import *
0009 from PhysicsTools.NanoAOD.common_cff import Var,CandVars
0010 
0011 nanoMetadata = cms.EDProducer("UniqueStringProducer",
0012     strings = cms.PSet(
0013         tag = cms.string("untagged"),
0014     )
0015 )
0016 
0017 nanogenSequence = cms.Sequence(
0018     nanoMetadata+
0019     cms.Sequence(particleLevelTask)+
0020     genJetTable+
0021     patJetPartonsNano+
0022     genJetFlavourAssociation+
0023     genJetFlavourTable+
0024     genJetAK8Table+
0025     genJetAK8FlavourAssociation+
0026     genJetAK8FlavourTable+
0027     cms.Sequence(genTauTask)+
0028     genTable+
0029     genFilterTable+
0030     cms.Sequence(genParticleTablesTask)+
0031     cms.Sequence(genVertexTablesTask)+
0032     tautagger+
0033     rivetProducerHTXS+
0034     cms.Sequence(particleLevelTablesTask)+
0035     metMCTable+
0036     genWeightsTable
0037 )
0038 
0039 def nanoGenCommonCustomize(process):
0040     process.rivetMetTable.extension = False
0041     process.lheInfoTable.storeLHEParticles = True
0042     process.lheInfoTable.precision = 14
0043     process.genWeightsTable.keepAllPSWeights = True
0044     process.genJetFlavourAssociation.jets = process.genJetTable.src
0045     process.genJetFlavourTable.src = process.genJetTable.src
0046     process.genJetAK8FlavourAssociation.jets = process.genJetAK8Table.src
0047     process.genJetAK8FlavourTable.src = process.genJetAK8Table.src
0048     process.particleLevel.particleMaxEta = 999.
0049     process.particleLevel.lepMinPt = 0.
0050     process.particleLevel.lepMaxEta = 999.
0051     process.genJetFlavourTable.jetFlavourInfos = "genJetFlavourAssociation"
0052     # Same as default RECO
0053     setGenPtPrecision(process, CandVars.pt.precision)
0054     setGenEtaPrecision(process, CandVars.eta.precision)
0055     setGenPhiPrecision(process, CandVars.phi.precision)
0056     setGenMassPrecision(process, CandVars.mass.precision)
0057 
0058 def customizeNanoGENFromMini(process):
0059     process.nanogenSequence.insert(0, process.genParticles2HepMCHiggsVtx)
0060     process.nanogenSequence.insert(0, process.genParticles2HepMC)
0061     process.nanogenSequence.insert(0, process.mergedGenParticles)
0062 
0063     process.metMCTable.src = "slimmedMETs"
0064     process.metMCTable.variables.pt = Var("genMET.pt", float, doc="pt")
0065     process.metMCTable.variables.phi = Var("genMET.phi", float, doc="phi")
0066     process.metMCTable.variables.phi.precision = CandVars.phi.precision
0067 
0068     process.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared"
0069     process.genParticleTable.src = "prunedGenParticles"
0070     process.patJetPartonsNano.particles = "prunedGenParticles"
0071     process.particleLevel.src = "genParticles2HepMC:unsmeared"
0072 
0073     process.genJetTable.src = "slimmedGenJets"
0074     process.genJetAK8Table.src = "slimmedGenJetsAK8"
0075     process.tauGenJetsForNano.GenParticles = "prunedGenParticles"
0076     process.genVisTaus.srcGenParticles = "prunedGenParticles"
0077 
0078     nanoGenCommonCustomize(process)
0079 
0080     return process
0081 
0082 def customizeNanoGEN(process):
0083     process.metMCTable.src = "genMetTrue"
0084     process.metMCTable.variables = cms.PSet(PTVars)
0085 
0086     process.rivetProducerHTXS.HepMCCollection = "generatorSmeared"
0087     process.genParticleTable.src = "genParticles"
0088     process.patJetPartonsNano.particles = "genParticles"
0089     process.particleLevel.src = "generatorSmeared"
0090 
0091     process.genJetTable.src = "ak4GenJets"
0092     process.genJetAK8Table.src = "ak8GenJets"
0093     process.tauGenJetsForNano.GenParticles = "genParticles"
0094     process.genVisTaus.srcGenParticles = "genParticles"
0095 
0096     # In case customizeNanoGENFromMini has already been called
0097     process.nanogenSequence.remove(process.genParticles2HepMCHiggsVtx)
0098     process.nanogenSequence.remove(process.genParticles2HepMC)
0099     process.nanogenSequence.remove(process.mergedGenParticles)
0100     nanoGenCommonCustomize(process)
0101     return process
0102 
0103 # Prune gen particles with tight conditions applied in usual NanoAOD
0104 def pruneGenParticlesNano(process):
0105     process.finalGenParticles.src = process.genParticleTable.src.getModuleLabel()
0106     process.genParticleTable.src = "finalGenParticles"
0107     process.nanogenSequence.insert(0, process.finalGenParticles)
0108     return process
0109 
0110 # Prune gen particles with conditions applied in usual MiniAOD
0111 def pruneGenParticlesMini(process):
0112     if process.nanogenSequence.contains(process.mergedGenParticles):
0113         raise ValueError("Applying the MiniAOD genParticle pruner to MiniAOD is redunant. " \
0114             "Use a different customization.")
0115     from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles
0116     process.prunedGenParticles = prunedGenParticles.clone()
0117     process.prunedGenParticles.src = "genParticles"
0118     process.genParticleTable.src = "prunedGenParticles"
0119 
0120     process.nanogenSequence.insert(0, process.prunedGenParticles)
0121     return process
0122 
0123 def setGenFullPrecision(process):
0124     process = setGenPtPrecision(process, 23)
0125     process = setGenEtaPrecision(process, 23)
0126     process = setGenPhiPrecision(process, 23)
0127     process = setGenMassPrecision(process, 23)
0128     return process
0129 
0130 def setGenPtPrecision(process, precision):
0131     process.genParticleTable.variables.pt.precision = precision
0132     process.genJetTable.variables.pt.precision = precision
0133     process.metMCTable.variables.pt.precision = precision
0134     return process
0135 
0136 def setGenEtaPrecision(process, precision):
0137     process.genParticleTable.variables.eta.precision = precision
0138     process.genJetTable.variables.eta.precision = precision
0139     return process
0140 
0141 def setGenPhiPrecision(process, precision):
0142     process.genParticleTable.variables.phi.precision = precision
0143     process.genJetTable.variables.phi.precision = precision
0144     process.metMCTable.variables.phi.precision = precision
0145     return process
0146 
0147 def setGenMassPrecision(process, precision):
0148     process.genParticleTable.variables.mass.precision = precision
0149     process.genJetTable.variables.mass.precision = precision
0150     return process
0151 
0152 def setLHEFullPrecision(process):
0153     process.lheInfoTable.precision = 23
0154     return process
0155 
0156 def setGenWeightsFullPrecision(process):
0157     process.genWeightsTable.lheWeightPrecision = 23
0158     return process