CMS 3D CMS Logo

nanogen_cff.py
Go to the documentation of this file.
3 from PhysicsTools.NanoAOD.globals_cff import genTable
4 from PhysicsTools.NanoAOD.met_cff import metMCTable
10 from PhysicsTools.NanoAOD.common_cff import Var,CandVars
12 
13 nanoMetadata = cms.EDProducer("UniqueStringProducer",
14  strings = cms.PSet(
15  tag = cms.string("untagged"),
16  )
17 )
18 
19 nanogenSequence = cms.Sequence(
20  nanoMetadata+
21  particleLevel+
22  genJetTable+
23  patJetPartons+
24  genJetFlavourAssociation+
25  genJetFlavourTable+
26  genJetAK8Table+
27  genJetAK8FlavourAssociation+
28  genJetAK8FlavourTable+
29  tauGenJets+
30  tauGenJetsSelectorAllHadrons+
31  genVisTaus+
32  genVisTauTable+
33  genTable+
34  genParticleTables+
35  genVertexTables+
36  tautagger+
37  rivetProducerHTXS+
38  particleLevelTables+
39  metMCTable+
40  genWeightsTable+
41  lheInfoTable
42 )
43 
45  process.rivetMetTable.extension = False
46  process.lheInfoTable.storeLHEParticles = True
47  process.lheInfoTable.precision = 14
48  process.genWeightsTable.keepAllPSWeights = True
49  process.genJetFlavourAssociation.jets = process.genJetTable.src
50  process.genJetFlavourTable.src = process.genJetTable.src
51  process.genJetAK8FlavourAssociation.jets = process.genJetAK8Table.src
52  process.genJetAK8FlavourTable.src = process.genJetAK8Table.src
53  process.particleLevel.particleMaxEta = 999.
54  process.particleLevel.lepMinPt = 0.
55  process.particleLevel.lepMaxEta = 999.
56  process.genJetFlavourTable.jetFlavourInfos = "genJetFlavourAssociation"
57  # Same as default RECO
58  setGenPtPrecision(process, CandVars.pt.precision)
59  setGenEtaPrecision(process, CandVars.eta.precision)
60  setGenPhiPrecision(process, CandVars.phi.precision)
61 
63  process.nanogenSequence.insert(0, process.genParticles2HepMCHiggsVtx)
64  process.nanogenSequence.insert(0, process.genParticles2HepMC)
65  process.nanogenSequence.insert(0, process.mergedGenParticles)
66 
67  (run2_nanoAOD_92X | run2_miniAOD_80XLegacy | run2_nanoAOD_94X2016 | run2_nanoAOD_94X2016 | \
68  run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94XMiniAODv2 | \
69  run2_nanoAOD_102Xv1).toReplaceWith(nanogenSequence, nanogenSequence.copyAndExclude([genVertexTable, genVertexT0Table]))
70 
71  process.metMCTable.src = "slimmedMETs"
72  process.metMCTable.variables.pt = Var("genMET.pt", float, doc="pt")
73  process.metMCTable.variables.phi = Var("genMET.phi", float, doc="phi")
74  process.metMCTable.variables.phi.precision = CandVars.phi.precision
75 
76  process.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared"
77  process.genParticleTable.src = "prunedGenParticles"
78  process.patJetPartons.particles = "prunedGenParticles"
79  process.particleLevel.src = "genParticles2HepMC:unsmeared"
80 
81  process.genJetTable.src = "slimmedGenJets"
82  process.genJetAK8Table.src = "slimmedGenJetsAK8"
83  process.tauGenJets.GenParticles = "prunedGenParticles"
84  process.genVisTaus.srcGenParticles = "prunedGenParticles"
85 
86  nanoGenCommonCustomize(process)
87 
88  return process
89 
90 def customizeNanoGEN(process):
91  process.metMCTable.src = "genMetTrue"
92  process.metMCTable.variables = cms.PSet(PTVars)
93 
94  process.rivetProducerHTXS.HepMCCollection = "generatorSmeared"
95  process.genParticleTable.src = "genParticles"
96  process.patJetPartons.particles = "genParticles"
97  process.particleLevel.src = "generatorSmeared"
98 
99  process.genJetTable.src = "ak4GenJets"
100  process.genJetAK8Table.src = "ak8GenJets"
101  process.tauGenJets.GenParticles = "genParticles"
102  process.genVisTaus.srcGenParticles = "genParticles"
103 
104  # In case customizeNanoGENFromMini has already been called
105  process.nanogenSequence.remove(process.genParticles2HepMCHiggsVtx)
106  process.nanogenSequence.remove(process.genParticles2HepMC)
107  process.nanogenSequence.remove(process.mergedGenParticles)
108  nanoGenCommonCustomize(process)
109  return process
110 
111 # Prune gen particles with tight conditions applied in usual NanoAOD
113  process.finalGenParticles.src = process.genParticleTable.src.getModuleLabel()
114  process.genParticleTable.src = "finalGenParticles"
115  process.nanogenSequence.insert(0, process.finalGenParticles)
116  return process
117 
118 # Prune gen particles with conditions applied in usual MiniAOD
120  if process.nanogenSequence.contains(process.mergedGenParticles):
121  raise ValueError("Applying the MiniAOD genParticle pruner to MiniAOD is redunant. " \
122  "Use a different customization.")
123  from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles
124  process.prunedGenParticles = prunedGenParticles.clone()
125  process.prunedGenParticles.src = "genParticles"
126  process.genParticleTable.src = "prunedGenParticles"
127 
128  process.nanogenSequence.insert(0, process.prunedGenParticles)
129  return process
130 
131 def setGenFullPrecision(process):
132  setGenPtPrecision(process, 23)
133  setGenEtaPrecision(process, 23)
134  setGenPhiPrecision(process, 23)
135 
136 def setGenPtPrecision(process, precision):
137  process.genParticleTable.variables.pt.precision = precision
138  process.genJetTable.variables.pt.precision = precision
139  process.metMCTable.variables.pt.precision = precision
140  return process
141 
142 def setGenEtaPrecision(process, precision):
143  process.genParticleTable.variables.eta.precision = precision
144  process.genJetTable.variables.eta.precision = precision
145  return process
146 
147 def setGenPhiPrecision(process, precision):
148  process.genParticleTable.variables.phi.precision = precision
149  process.genJetTable.variables.phi.precision = precision
150  process.metMCTable.variables.phi.precision = precision
151  return process
152 
153 def setLHEFullPrecision(process):
154  process.lheInfoTable.precision = 23
155  return process
156 
158  process.genWeightsTable.lheWeightPrecision = 23
159  return process
nanogen_cff.nanoGenCommonCustomize
def nanoGenCommonCustomize(process)
Definition: nanogen_cff.py:44
nanogen_cff.setLHEFullPrecision
def setLHEFullPrecision(process)
Definition: nanogen_cff.py:153
nanogen_cff.pruneGenParticlesMini
def pruneGenParticlesMini(process)
Definition: nanogen_cff.py:119
taus_cff
genparticles_cff
genVertex_cff
particlelevel_cff
globals_cff
common_cff
common_cff.Var
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
nanogen_cff.pruneGenParticlesNano
def pruneGenParticlesNano(process)
Definition: nanogen_cff.py:112
nanogen_cff.setGenFullPrecision
def setGenFullPrecision(process)
Definition: nanogen_cff.py:131
genWeightsTable_cfi
nanogen_cff.setGenPhiPrecision
def setGenPhiPrecision(process, precision)
Definition: nanogen_cff.py:147
prunedGenParticles_cfi
nanogen_cff.setGenWeightsFullPrecision
def setGenWeightsFullPrecision(process)
Definition: nanogen_cff.py:157
jets_cff
nanogen_cff.setGenPtPrecision
def setGenPtPrecision(process, precision)
Definition: nanogen_cff.py:136
nano_eras_cff
nanogen_cff.customizeNanoGEN
def customizeNanoGEN(process)
Definition: nanogen_cff.py:90
nanogen_cff.customizeNanoGENFromMini
def customizeNanoGENFromMini(process)
Definition: nanogen_cff.py:62
lheInfoTable_cfi
nanogen_cff.setGenEtaPrecision
def setGenEtaPrecision(process, precision)
Definition: nanogen_cff.py:142
met_cff