CMS 3D CMS Logo

nanogen_cff.py
Go to the documentation of this file.
3 from PhysicsTools.NanoAOD.globals_cff import genTable,genFilterTable
4 from PhysicsTools.NanoAOD.met_cff import metMCTable
9 from PhysicsTools.NanoAOD.common_cff import Var,CandVars
10 from PhysicsTools.NanoAOD.simpleSingletonCandidateFlatTableProducer_cfi import simpleSingletonCandidateFlatTableProducer
11 
12 nanoMetadata = cms.EDProducer("UniqueStringProducer",
13  strings = cms.PSet(
14  tag = cms.string("untagged"),
15  )
16 )
17 
18 nanogenSequence = cms.Sequence(
19  nanoMetadata+
20  cms.Sequence(particleLevelTask)+
21  genJetTable+
22  patJetPartonsNano+
23  genJetFlavourAssociation+
24  genJetFlavourTable+
25  genJetAK8Table+
26  genJetAK8FlavourAssociation+
27  genJetAK8FlavourTable+
28  cms.Sequence(genTauTask)+
29  genTable+
30  genIso+
31  genFilterTable+
32  cms.Sequence(genParticleTablesTask)+
33  cms.Sequence(genVertexTablesTask)+
34  tautagger+
35  rivetProducerHTXS+
36  cms.Sequence(particleLevelTablesTask)+
37  metMCTable+
38  genWeightsTable
39 )
40 
42  process.rivetMetTable.extension = False
43  process.lheInfoTable.storeLHEParticles = True
44  process.lheInfoTable.precision = 14
45  process.genWeightsTable.keepAllPSWeights = True
46  process.genJetFlavourAssociation.jets = process.genJetTable.src
47  process.genJetFlavourTable.src = process.genJetTable.src
48  process.genJetAK8FlavourAssociation.jets = process.genJetAK8Table.src
49  process.genJetAK8FlavourTable.src = process.genJetAK8Table.src
50  process.particleLevel.particleMaxEta = 999.
51  process.particleLevel.lepMinPt = 0.
52  process.particleLevel.lepMaxEta = 999.
53  process.genJetFlavourTable.jetFlavourInfos = "genJetFlavourAssociation"
54  # Same as default RECO
55  setGenPtPrecision(process, CandVars.pt.precision)
56  setGenEtaPrecision(process, CandVars.eta.precision)
57  setGenPhiPrecision(process, CandVars.phi.precision)
58  setGenMassPrecision(process, CandVars.mass.precision)
59 
60  for output in ("NANOEDMAODSIMoutput", "NANOAODSIMoutput"):
61  if hasattr(process, output):
62  getattr(process, output).outputCommands.append("drop edmTriggerResults_*_*_*")
63 
65  process.nanogenSequence.insert(0, process.genParticles2HepMCHiggsVtx)
66  process.nanogenSequence.insert(0, process.genParticles2HepMC)
67  process.nanogenSequence.insert(0, process.mergedGenParticles)
68 
69  process.metMCTable.src = "slimmedMETs"
70  process.metMCTable.variables.pt = Var("genMET.pt", float, doc="pt")
71  process.metMCTable.variables.phi = Var("genMET.phi", float, doc="phi")
72  process.metMCTable.variables.phi.precision = CandVars.phi.precision
73 
74  process.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared"
75  process.genParticleTable.src = "prunedGenParticles"
76  process.patJetPartonsNano.particles = "prunedGenParticles"
77  process.particleLevel.src = "genParticles2HepMC:unsmeared"
78  process.genIso.genPart = "prunedGenParticles"
79 
80  process.genJetTable.src = "slimmedGenJets"
81  process.genJetAK8Table.src = "slimmedGenJetsAK8"
82  process.tauGenJetsForNano.GenParticles = "prunedGenParticles"
83  process.genVisTaus.srcGenParticles = "prunedGenParticles"
84 
85  nanoGenCommonCustomize(process)
86 
87  return process
88 
89 def customizeNanoGEN(process):
90  process.metMCTable = simpleSingletonCandidateFlatTableProducer.clone(
91  src = "genMetTrue",
92  name = process.metMCTable.name,
93  doc = process.metMCTable.doc,
94  variables = cms.PSet(PTVars)
95  )
96 
97  process.nanogenSequence.insert(0, process.genParticles2HepMCHiggsVtx)
98  process.nanogenSequence.insert(0, process.genParticles2HepMC)
99  process.genParticles2HepMCHiggsVtx.genParticles = "genParticles"
100  process.genParticles2HepMC.genParticles = "genParticles"
101 
102  process.rivetProducerHTXS.HepMCCollection = "genParticles2HepMCHiggsVtx:unsmeared"
103  process.genParticleTable.src = "genParticles"
104  process.patJetPartonsNano.particles = "genParticles"
105  process.particleLevel.src = "genParticles2HepMC:unsmeared"
106 
107  process.genJetTable.src = "ak4GenJetsNoNu"
108  process.genJetAK8Table.src = "ak8GenJetsNoNu"
109  process.tauGenJetsForNano.GenParticles = "genParticles"
110  process.genVisTaus.srcGenParticles = "genParticles"
111 
112  # In case customizeNanoGENFromMini has already been called
113  process.nanogenSequence.remove(process.mergedGenParticles)
114  process.nanogenSequence.remove(process.genIso)
115  delattr(process.genParticleTable.externalVariables,"iso")
116  nanoGenCommonCustomize(process)
117  return process
118 
119 # Prune gen particles with tight conditions applied in usual NanoAOD
121  process.finalGenParticles.src = process.genParticleTable.src.getModuleLabel()
122  process.genParticleTable.src = "finalGenParticles"
123  process.nanogenSequence.insert(0, process.finalGenParticles)
124  return process
125 
126 # Prune gen particles with conditions applied in usual MiniAOD
128  if process.nanogenSequence.contains(process.mergedGenParticles):
129  raise ValueError("Applying the MiniAOD genParticle pruner to MiniAOD is redunant. " \
130  "Use a different customization.")
131  from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles
132  process.prunedGenParticles = prunedGenParticles.clone()
133  process.prunedGenParticles.src = "genParticles"
134  process.genParticleTable.src = "prunedGenParticles"
135 
136  process.nanogenSequence.insert(0, process.prunedGenParticles)
137  return process
138 
139 def setGenFullPrecision(process):
140  process = setGenPtPrecision(process, 23)
141  process = setGenEtaPrecision(process, 23)
142  process = setGenPhiPrecision(process, 23)
143  process = setGenMassPrecision(process, 23)
144  return process
145 
146 def setGenPtPrecision(process, precision):
147  process.genParticleTable.variables.pt.precision = precision
148  process.genJetTable.variables.pt.precision = precision
149  process.metMCTable.variables.pt.precision = precision
150  return process
151 
152 def setGenEtaPrecision(process, precision):
153  process.genParticleTable.variables.eta.precision = precision
154  process.genJetTable.variables.eta.precision = precision
155  return process
156 
157 def setGenPhiPrecision(process, precision):
158  process.genParticleTable.variables.phi.precision = precision
159  process.genJetTable.variables.phi.precision = precision
160  process.metMCTable.variables.phi.precision = precision
161  return process
162 
163 def setGenMassPrecision(process, precision):
164  process.genParticleTable.variables.mass.precision = precision
165  process.genJetTable.variables.mass.precision = precision
166  return process
167 
168 def setLHEFullPrecision(process):
169  process.lheInfoTable.precision = 23
170  return process
171 
173  process.genWeightsTable.lheWeightPrecision = 23
174  return process
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
def pruneGenParticlesMini(process)
Definition: nanogen_cff.py:127
def setGenMassPrecision(process, precision)
Definition: nanogen_cff.py:163
def customizeNanoGEN(process)
Definition: nanogen_cff.py:89
def setLHEFullPrecision(process)
Definition: nanogen_cff.py:168
def setGenPhiPrecision(process, precision)
Definition: nanogen_cff.py:157
def setGenPtPrecision(process, precision)
Definition: nanogen_cff.py:146
def nanoGenCommonCustomize(process)
Definition: nanogen_cff.py:41
def pruneGenParticlesNano(process)
Definition: nanogen_cff.py:120
def setGenFullPrecision(process)
Definition: nanogen_cff.py:139
def setGenWeightsFullPrecision(process)
Definition: nanogen_cff.py:172
def customizeNanoGENFromMini(process)
Definition: nanogen_cff.py:64
def setGenEtaPrecision(process, precision)
Definition: nanogen_cff.py:152