CMS 3D CMS Logo

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