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