CMS 3D CMS Logo

custom_jme_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016
4 from Configuration.Eras.Modifier_run2_jme_2017_cff import run2_jme_2017
5 
6 from CommonTools.PileupAlgos.Puppi_cff import puppi
7 
8 from RecoJets.JetProducers.PileupJetID_cfi import pileupJetIdCalculator, pileupJetId
9 from RecoJets.JetProducers.PileupJetID_cfi import _chsalgos_81x, _chsalgos_94x, _chsalgos_102x
10 
11 from PhysicsTools.NanoAOD.common_cff import Var, P4Vars
12 from PhysicsTools.NanoAOD.jets_cff import jetTable, jetCorrFactorsNano, updatedJets, finalJets, qgtagger, hfJetShowerShapeforNanoAOD
13 from PhysicsTools.NanoAOD.jets_cff import genJetTable, genJetFlavourAssociation, genJetFlavourTable
14 
15 from PhysicsTools.PatAlgos.tools.jetCollectionTools import GenJetAdder, RecoJetAdder
16 from PhysicsTools.PatAlgos.tools.jetTools import supportedJetAlgos
17 from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
18 
19 import copy
20 
21 bTagCSVV2 = ['pfDeepCSVJetTags:probb','pfDeepCSVJetTags:probbb','pfDeepCSVJetTags:probc']
22 bTagDeepCSV = ['pfCombinedInclusiveSecondaryVertexV2BJetTags']
23 bTagDeepJet = [
24  'pfDeepFlavourJetTags:probb','pfDeepFlavourJetTags:probbb','pfDeepFlavourJetTags:problepb',
25  'pfDeepFlavourJetTags:probc','pfDeepFlavourJetTags:probuds','pfDeepFlavourJetTags:probg'
26 ]
27 
28 from RecoBTag.ONNXRuntime.pfParticleNetAK4_cff import _pfParticleNetAK4JetTagsAll
29 bTagDiscriminatorsForAK4 = bTagCSVV2+bTagDeepCSV+bTagDeepJet+_pfParticleNetAK4JetTagsAll
30 
31 #
32 # By default, these collections are saved in NanoAODs:
33 # - ak4gen (GenJet in NanoAOD), slimmedGenJets in MiniAOD
34 # - ak8gen (GenJetAK8 in NanoAOD), slimmedGenJetsAK8 in MiniAOD
35 # Below is a list of genjets that we can save in NanoAOD. Set
36 # "enabled" to true if you want to store the jet collection
37 config_genjets = [
38  {
39  "jet" : "ak8gen",
40  "enabled" : False,
41  },
42 ]
43 config_genjets = list(filter(lambda k: k['enabled'], config_genjets))
44 #
45 # GenJets info in NanoAOD
46 #
47 nanoInfo_genjets = {
48  "ak8gen" : {
49  "name" : "GenJetAK8",
50  "doc" : "AK8 Gen jets",
51  },
52 }
53 #
54 # By default, these collections are saved in the main NanoAODs:
55 # - ak4pfchs (Jet in NanoAOD), slimmedJets in MiniAOD
56 # - ak8pfpuppi (FatJet in NanoAOD), slimmedJetsAK8 in MiniAOD
57 # Below is a list of recojets that we can save in NanoAOD. Set
58 # "enabled" to true if you want to store the recojet collection.
59 #
60 config_recojets = [
61  {
62  "jet" : "ak4calo",
63  "enabled" : True,
64  "inputCollection" : "slimmedCaloJets", #Exist in MiniAOD
65  "genJetsCollection": "AK4GenJetsNoNu",
66  },
67  {
68  "jet" : "ak4pf",
69  "enabled" : True,
70  "inputCollection" : "",
71  "genJetsCollection": "AK4GenJetsNoNu",
72  },
73  {
74  "jet" : "ak4pfpuppi",
75  "enabled" : True,
76  "inputCollection" : "",
77  "genJetsCollection": "AK4GenJetsNoNu",
78  "bTagDiscriminators": bTagDiscriminatorsForAK4
79  },
80  {
81  "jet" : "ak8pf",
82  "enabled" : True,
83  "inputCollection" : "",
84  "genJetsCollection": "slimmedGenJetsAK8",
85  },
86  {
87  "jet" : "ak8pfchs",
88  "enabled" : True,
89  "inputCollection" : "",
90  "genJetsCollection": "slimmedGenJetsAK8",
91  },
92 ]
93 config_recojets = list(filter(lambda k: k['enabled'], config_recojets))
94 #
95 # RecoJets info in NanoAOD
96 #
97 nanoInfo_recojets = {
98  "ak4pfpuppi" : {
99  "name" : "JetPuppi",
100  "doc" : "AK4 PF Puppi jets with JECs applied, after basic selection (pt > 2)",
101  "ptcut" : "pt > 2",
102  "doQGL" : True,
103  "doPUIDVar": True,
104  "doBTag": True,
105  },
106  "ak4pf" : {
107  "name" : "JetPF",
108  "doc" : "AK4 PF jets with JECs applied, after basic selection (pt > 2)",
109  "ptcut" : "pt > 2",
110  },
111  "ak4calo" : {
112  "name": "JetCalo",
113  "doc" : "AK4 Calo jets with JECs applied",
114  },
115  "ak8pfchs" : {
116  "name" : "FatJetCHS",
117  "doc" : "AK8 PF CHS jets with JECs applied, after basic selection (pt > 100)",
118  "ptcut" : "pt > 100"
119  },
120  "ak8pf" : {
121  "name" : "FatJetPF",
122  "doc" : "AK8 PF jets with JECs applied, after basic selection (pt > 100)",
123  "ptcut" : "pt > 100",
124  },
125 }
126 
127 
128 
129 GENJETVARS = cms.PSet(P4Vars,
130  nConstituents = jetTable.variables.nConstituents,
131 )
132 PFJETVARS = cms.PSet(P4Vars,
133  rawFactor = jetTable.variables.rawFactor,
134  area = jetTable.variables.area,
135  chHEF = jetTable.variables.chHEF,
136  neHEF = jetTable.variables.neHEF,
137  chEmEF = jetTable.variables.chEmEF,
138  neEmEF = jetTable.variables.neEmEF,
139  muEF = jetTable.variables.muEF,
140  hfHEF = Var("HFHadronEnergyFraction()",float,doc = "hadronic energy fraction in HF",precision = 6),
141  hfEmEF = Var("HFEMEnergyFraction()",float,doc = "electromagnetic energy fraction in HF",precision = 6),
142  nMuons = jetTable.variables.nMuons,
143  nElectrons = jetTable.variables.nElectrons,
144  nConstituents = jetTable.variables.nConstituents,
145  nConstChHads = Var("chargedHadronMultiplicity()",int,doc="number of charged hadrons in the jet"),
146  nConstNeuHads = Var("neutralHadronMultiplicity()",int,doc="number of neutral hadrons in the jet"),
147  nConstHFHads = Var("HFHadronMultiplicity()", int,doc="number of HF hadrons in the jet"),
148  nConstHFEMs = Var("HFEMMultiplicity()",int,doc="number of HF EMs in the jet"),
149  nConstMuons = Var("muonMultiplicity()",int,doc="number of muons in the jet"),
150  nConstElecs = Var("electronMultiplicity()",int,doc="number of electrons in the jet"),
151  nConstPhotons = Var("photonMultiplicity()",int,doc="number of photons in the jet"),
152 )
153 PUIDVARS = cms.PSet(
154  puId_dR2Mean = Var("userFloat('puId_dR2Mean')",float,doc="pT^2-weighted average square distance of jet constituents from the jet axis (PileUp ID BDT input variable)", precision= 6),
155  puId_majW = Var("userFloat('puId_majW')",float,doc="major axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision= 6) ,
156  puId_minW = Var("userFloat('puId_minW')",float,doc="minor axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision= 6) ,
157  puId_frac01 = Var("userFloat('puId_frac01')",float,doc="fraction of constituents' pT contained within dR <0.1 (PileUp ID BDT input variable)", precision= 6) ,
158  puId_frac02 = Var("userFloat('puId_frac02')",float,doc="fraction of constituents' pT contained within 0.1< dR <0.2 (PileUp ID BDT input variable)", precision= 6) ,
159  puId_frac03 = Var("userFloat('puId_frac03')",float,doc="fraction of constituents' pT contained within 0.2< dR <0.3 (PileUp ID BDT input variable)", precision= 6) ,
160  puId_frac04 = Var("userFloat('puId_frac04')",float,doc="fraction of constituents' pT contained within 0.3< dR <0.4 (PileUp ID BDT input variable)", precision= 6) ,
161  puId_ptD = Var("userFloat('puId_ptD')",float,doc="pT-weighted average pT of constituents (PileUp ID BDT input variable)", precision= 6) ,
162  puId_beta = Var("userFloat('puId_beta')",float,doc="fraction of pT of charged constituents associated to PV (PileUp ID BDT input variable)", precision= 6) ,
163  puId_pull = Var("userFloat('puId_pull')",float,doc="magnitude of pull vector (PileUp ID BDT input variable)", precision= 6) ,
164  puId_jetR = Var("userFloat('puId_jetR')",float,doc="fraction of jet pT carried by the leading constituent (PileUp ID BDT input variable)", precision= 6) ,
165  puId_jetRchg = Var("userFloat('puId_jetRchg')",float,doc="fraction of jet pT carried by the leading charged constituent (PileUp ID BDT input variable)", precision= 6) ,
166  puId_nCharged = Var("userInt('puId_nCharged')",int,doc="number of charged constituents (PileUp ID BDT input variable)"),
167 )
168 QGLVARS = cms.PSet(
169  qgl_axis2 = Var("userFloat('qgl_axis2')",float,doc="ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision= 6),
170  qgl_ptD = Var("userFloat('qgl_ptD')",float,doc="pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)", precision= 6),
171  qgl_mult = Var("userInt('qgl_mult')", int,doc="PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
172 )
173 BTAGVARS = cms.PSet(
174  btagDeepB = jetTable.variables.btagDeepB,
175  btagCSVV2 = jetTable.variables.btagCSVV2,
176  btagDeepCvL = jetTable.variables.btagDeepCvL,
177 )
178 DEEPJETVARS = cms.PSet(
179  btagDeepFlavB = jetTable.variables.btagDeepFlavB,
180  btagDeepFlavC = Var("bDiscriminator('pfDeepFlavourJetTags:probc')",float,doc="DeepFlavour charm tag raw score",precision=10),
181  btagDeepFlavG = Var("bDiscriminator('pfDeepFlavourJetTags:probg')",float,doc="DeepFlavour gluon tag raw score",precision=10),
182  btagDeepFlavUDS = Var("bDiscriminator('pfDeepFlavourJetTags:probuds')",float,doc="DeepFlavour uds tag raw score",precision=10)
183 )
184 PARTICLENETAK4VARS = cms.PSet(
185  particleNetAK4_B = Var("bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:BvsAll')",float,doc="ParticleNetAK4 tagger b vs all (udsg, c) discriminator",precision=10),
186  particleNetAK4_CvsL = Var("bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsL')",float,doc="ParticleNetAK4 tagger c vs udsg discriminator",precision=10),
187  particleNetAK4_CvsB = Var("bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsB')",float,doc="ParticleNetAK4 tagger c vs b discriminator",precision=10),
188  particleNetAK4_QvsG = Var("bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:QvsG')",float,doc="ParticleNetAK4 tagger uds vs g discriminator",precision=10),
189  particleNetAK4_puIdDisc = Var("1-bDiscriminator('pfParticleNetAK4JetTags:probpu')",float,doc="ParticleNetAK4 tagger pileup jet discriminator",precision=10),
190 )
191 
192 CALOJETVARS = cms.PSet(P4Vars,
193  area = jetTable.variables.area,
194  rawFactor = jetTable.variables.rawFactor,
195  emf = Var("emEnergyFraction()", float, doc = "electromagnetic energy fraction", precision = 10),
196 )
197 
198 
199 #******************************************
200 #
201 #
202 # Reco Jets related functions
203 #
204 #
205 #******************************************
206 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName=""):
207  """
208  Setup modules to calculate PF jet ID
209  """
210 
211  isPUPPIJet = True if "Puppi" in jetName else False
212 
213  looseJetId = "looseJetId{}".format(jetName)
214  setattr(proc, looseJetId, proc.looseJetId.clone(
215  src = jetSrc,
216  filterParams=proc.looseJetId.filterParams.clone(
217  version ="WINTER16"
218  ),
219  )
220  )
221 
222  tightJetId = "tightJetId{}".format(jetName)
223  setattr(proc, tightJetId, proc.tightJetId.clone(
224  src = jetSrc,
225  filterParams=proc.tightJetId.filterParams.clone(
226  version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "")
227  ),
228  )
229  )
230 
231  tightJetIdLepVeto = "tightJetIdLepVeto{}".format(jetName)
232  setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
233  src = jetSrc,
234  filterParams=proc.tightJetIdLepVeto.filterParams.clone(
235  version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "")
236  ),
237  )
238  )
239  run2_jme_2016.toModify(getattr(proc, tightJetId) .filterParams, version = "WINTER16" )
240  run2_jme_2016.toModify(getattr(proc, tightJetIdLepVeto) .filterParams, version = "WINTER16" )
241  run2_jme_2017.toModify(getattr(proc, tightJetId) .filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
242  run2_jme_2017.toModify(getattr(proc, tightJetIdLepVeto) .filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
243 
244  #
245  # Save variables as userInts in each jet
246  #
247  patJetWithUserData = "{}WithUserData".format(jetSrc)
248  getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
249  getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
250  run2_jme_2016.toModify(getattr(proc, patJetWithUserData).userInts, looseId = cms.InputTag(looseJetId))
251 
252  #
253  # Specfiy variables in the jetTable to save in NanoAOD
254  #
255  getattr(proc, jetTableName).variables.jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc="Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto")
256  run2_jme_2016.toModify(getattr(proc, jetTableName).variables, jetId = Var("userInt('tightIdLepVeto')*4+userInt('tightId')*2+userInt('looseId')",int, doc="Jet ID flags bit1 is loose, bit2 is tight, bit3 is tightLepVeto"))
257 
258  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, jetSrc))+1, getattr(proc, tightJetId))
259  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, tightJetId))+1, getattr(proc, tightJetIdLepVeto))
260 
261  setattr(proc,"_"+jetSequenceName+"_2016", getattr(proc,jetSequenceName).copy())
262  getattr(proc,"_"+jetSequenceName+"_2016").insert(getattr(proc, "_"+jetSequenceName+"_2016").index(getattr(proc, tightJetId)), getattr(proc, looseJetId))
263  run2_jme_2016.toReplaceWith(getattr(proc,jetSequenceName), getattr(proc, "_"+jetSequenceName+"_2016"))
264 
265  return proc
266 
267 def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName=""):
268  """
269  Setup modules to calculate pileup jet ID input variables for PF jet
270  """
271 
272  #
273  # Calculate pileup jet ID variables
274  #
275  puJetIdVarsCalculator = "puJetIdCalculator{}".format(jetName)
276  setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
277  jets = jetSrc,
278  vertexes = "offlineSlimmedPrimaryVertices",
279  inputIsCorrected = True,
280  applyJec = False,
281  usePuppi = True if "Puppi" in jetName else False
282  )
283  )
284  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, jetSrc))+1, getattr(proc, puJetIdVarsCalculator))
285 
286  #
287  # Get the variables
288  #
289  puJetIDVar = "puJetIDVar{}".format(jetName)
290  setattr(proc, puJetIDVar, cms.EDProducer("PileupJetIDVarProducer",
291  srcJet = cms.InputTag(jetSrc),
292  srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
293  )
294  )
295  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, puJetIdVarsCalculator))+1, getattr(proc, puJetIDVar))
296 
297  #
298  # Save variables as userFloats and userInts for each jet
299  #
300  patJetWithUserData = "{}WithUserData".format(jetSrc)
301  getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag("{}:dR2Mean".format(puJetIDVar))
302  getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag("{}:majW".format(puJetIDVar))
303  getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag("{}:minW".format(puJetIDVar))
304  getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag("{}:frac01".format(puJetIDVar))
305  getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag("{}:frac02".format(puJetIDVar))
306  getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag("{}:frac03".format(puJetIDVar))
307  getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag("{}:frac04".format(puJetIDVar))
308  getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag("{}:ptD".format(puJetIDVar))
309  getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag("{}:beta".format(puJetIDVar))
310  getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag("{}:pull".format(puJetIDVar))
311  getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag("{}:jetR".format(puJetIDVar))
312  getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag("{}:jetRchg".format(puJetIDVar))
313  getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag("{}:nCharged".format(puJetIDVar))
314 
315  #
316  # Specfiy variables in the jet table to save in NanoAOD
317  #
318  getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
319  getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
320  getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
321  getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
322  getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
323  getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
324  getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
325  getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
326  getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
327  getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
328  getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
329  getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
330  getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
331 
332  return proc
333 
334 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", calculateQGLVars=False):
335  """
336  Schedule the QGTagger module to calculate input variables to the QG likelihood
337  """
338 
339  QGLTagger="qgtagger{}".format(jetName)
340  patJetWithUserData="{}WithUserData".format(jetSrc)
341 
342  if calculateQGLVars:
343  setattr(proc, QGLTagger, qgtagger.clone(
344  srcJets=jetSrc
345  )
346  )
347 
348  #
349  # Save variables as userFloats and userInts for each jet
350  #
351  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
352  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
353  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
354 
355  #
356  # Specfiy variables in the jet table to save in NanoAOD
357  #
358  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
359  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
360  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
361 
362  if calculateQGLVars:
363  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, jetSrc))+1, getattr(proc, QGLTagger))
364 
365  return proc
366 
367 def AddBTaggingScores(proc, jetTableName=""):
368  """
369  Store b-tagging scores from various algortihm
370  """
371 
372  getattr(proc, jetTableName).variables.btagDeepB = jetTable.variables.btagDeepB
373  getattr(proc, jetTableName).variables.btagCSVV2 = jetTable.variables.btagCSVV2
374  getattr(proc, jetTableName).variables.btagDeepCvL = jetTable.variables.btagDeepCvL
375  getattr(proc, jetTableName).variables.btagDeepFlavB = jetTable.variables.btagDeepFlavB
376  getattr(proc, jetTableName).variables.btagDeepFlavCvL = jetTable.variables.btagDeepFlavCvL
377 
378  return proc
379 
380 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
381  """
382  Store DeepJet raw score in jetTable for gluon and light quark
383  """
384 
385  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
386  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
387 
388  return proc
389 
390 def AddParticleNetAK4Scores(proc, jetTableName=""):
391  """
392  Store ParticleNetAK4 scores in jetTable
393  """
394 
395  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
396  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
397  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
398  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
399  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
400 
401  return proc
402 
403 def AddNewPatJets(proc, recoJetInfo, runOnMC):
404  """
405  Add patJet into custom nanoAOD
406  """
407 
408  jetName = recoJetInfo.jetUpper
409  payload = recoJetInfo.jetCorrPayload
410  doPF = recoJetInfo.doPF
411  doCalo = recoJetInfo.doCalo
412 
413  if recoJetInfo.inputCollection != "":
414  patJetFinalColl = recoJetInfo.inputCollection
415  else:
416  patJetFinalColl = "selectedUpdatedPatJets{}Final".format(jetName)
417 
418  if doCalo:
419  patJetFinalColl = "selectedPatJets{}".format(jetName)
420 
421  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
422  jetTablePrefix = nanoInfoForJet["name"]
423  jetTableDoc = nanoInfoForJet["doc"]
424  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else ""
425  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
426  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
427  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
428 
429  SavePatJets(proc,
430  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
431  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
432  )
433 
434  return proc
435 
436 def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc,
437  doPF, doCalo, ptcut="", doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
438  """
439  Schedule modules for a given patJet collection and save its variables into custom NanoAOD
440  """
441 
442  #
443  # Setup jet correction factors
444  #
445  jetCorrFactors = "jetCorrFactorsNano{}".format(jetName)
446  setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
447  src = patJetFinalColl,
448  payload = payload,
449  )
450  )
451 
452  #
453  # Update jets
454  #
455  srcJets = "updatedJets{}".format(jetName)
456  setattr(proc, srcJets, updatedJets.clone(
457  jetSource = patJetFinalColl,
458  jetCorrFactorsSource=[jetCorrFactors],
459  )
460  )
461 
462  #
463  # Setup UserDataEmbedder
464  #
465  srcJetsWithUserData = "updatedJets{}WithUserData".format(jetName)
466  setattr(proc, srcJetsWithUserData, cms.EDProducer("PATJetUserDataEmbedder",
467  src = cms.InputTag(srcJets),
468  userFloats = cms.PSet(),
469  userInts = cms.PSet(),
470  )
471  )
472 
473  #
474  # Filter jets with pt cut
475  #
476  finalJetsForTable = "finalJets{}".format(jetName)
477  setattr(proc, finalJetsForTable, finalJets.clone(
478  src = srcJetsWithUserData,
479  cut = ptcut
480  )
481  )
482 
483  #
484  # Save jets in table
485  #
486  tableContent = PFJETVARS
487  if doCalo:
488  tableContent = CALOJETVARS
489 
490  jetTable = "jet{}Table".format(jetName)
491  setattr(proc,jetTable, cms.EDProducer("SimpleCandidateFlatTableProducer",
492  src = cms.InputTag(finalJetsForTable),
493  cut = cms.string(""), # Don't specify cuts here
494  name = cms.string(jetTablePrefix),
495  doc = cms.string(jetTableDoc),
496  singleton = cms.bool(False), # the number of entries is variable
497  extension = cms.bool(False), # this is the main table for the jets
498  variables = cms.PSet(tableContent)
499  )
500  )
501  getattr(proc,jetTable).variables.pt.precision=10
502 
503  #
504  # Save MC-only jet variables in table
505  #
506  jetMCTable = "jet{}MCTable".format(jetName)
507  setattr(proc, jetMCTable, cms.EDProducer("SimpleCandidateFlatTableProducer",
508  src = cms.InputTag(finalJetsForTable),
509  cut = getattr(proc,jetTable).cut,
510  name = cms.string(jetTablePrefix),
511  singleton = cms.bool(False),
512  extension = cms.bool(True), # this is an extension table
513  variables = cms.PSet(
514  partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
515  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
516  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
517  )
518  )
519  )
520 
521  #
522  # Define the jet modules sequence first
523  #
524  jetSequenceName = "jet{}Sequence".format(jetName)
525  setattr(proc, jetSequenceName, cms.Sequence(
526  getattr(proc,jetCorrFactors)+
527  getattr(proc,srcJets)+
528  getattr(proc,srcJetsWithUserData)+
529  getattr(proc,finalJetsForTable)
530  )
531  )
532 
533  #
534  # Define the jet table sequences
535  #
536  jetTableSequenceName = "jet{}TablesSequence".format(jetName)
537  setattr(proc, jetTableSequenceName, cms.Sequence(getattr(proc,jetTable)))
538 
539  jetTableSequenceMCName = "jet{}MCTablesSequence".format(jetName)
540  setattr(proc, jetTableSequenceMCName, cms.Sequence(getattr(proc,jetMCTable)))
541 
542  if runOnMC:
543  proc.nanoSequenceMC += getattr(proc,jetSequenceName)
544  proc.nanoSequenceMC += getattr(proc,jetTableSequenceName)
545  proc.nanoSequenceMC += getattr(proc,jetTableSequenceMCName)
546  else:
547  proc.nanoSequence += getattr(proc,jetSequenceName)
548  proc.nanoSequence += getattr(proc,jetTableSequenceName)
549 
550  #
551  # Schedule plugins to calculate Jet ID, PileUp Jet ID input variables, and Quark-Gluon Likehood input variables.
552  #
553  if doPF:
554  proc = AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName)
555  if doPUIDVar:
556  proc = AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName)
557  if doQGL:
558  proc = AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName, calculateQGLVars=True)
559 
560  #
561  # Save b-tagging algorithm scores. Should only be done for jet collection with b-tagging
562  # calculated when reclustered or collection saved with b-tagging info in MiniAOD
563  #
564  if doBTag:
565  AddBTaggingScores(proc,jetTableName=jetTable)
566  AddDeepJetGluonLQuarkScores(proc,jetTableName=jetTable)
567  AddParticleNetAK4Scores(proc,jetTableName=jetTable)
568 
569  return proc
570 
571 def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
572  """
573  Recluster AK4 CHS jets and replace slimmedJets
574  that is used as default to save AK4 CHS jets
575  in NanoAODs.
576  """
577  print("custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
578 
579  #
580  # Recluster AK4 CHS jets
581  #
582  cfg = {
583  "jet" : "ak4pfchs",
584  "inputCollection" : "",
585  "genJetsCollection": "AK4GenJetsNoNu",
586  "bTagDiscriminators": bTagDiscriminatorsForAK4
587  }
588  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
589 
590  jetName = recoJetInfo.jetUpper
591  patJetFinalColl = "selectedUpdatedPatJets{}Final".format(jetName)
592 
593  #
594  # Change the input jet source for jetCorrFactorsNano
595  # and updatedJets
596  #
597  proc.jetCorrFactorsNano.src=patJetFinalColl
598  proc.updatedJets.jetSource=patJetFinalColl
599 
600  #
601  # Change pt cut
602  #
603  proc.finalJets.cut = "pt > 2"
604  proc.simpleCleanerTable.jetSel = "pt > 10" # Change this from 15 -> 10
605 
606  #
607  # Add variables
608  #
609  proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
610  proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
611  proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
612  proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
613  proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
614  proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
615  proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
616  proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
617  proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
618 
619  proc.jetTable.doc = cms.string("AK4 PF CHS Jets with JECs applied, after basic selection (pt > 2)")
620 
621  #
622  # Setup pileup jet ID with 80X training.
623  #
624  pileupJetId80X = "pileupJetId80X"
625  setattr(proc, pileupJetId80X, pileupJetId.clone(
626  jets="updatedJets",
627  algos=cms.VPSet(_chsalgos_81x),
628  inputIsCorrected=True,
629  applyJec=False,
630  vertexes="offlineSlimmedPrimaryVertices"
631  )
632  )
633  proc.jetSequence.insert(proc.jetSequence.index(proc.pileupJetId94X), getattr(proc, pileupJetId80X))
634 
635  proc.updatedJetsWithUserData.userInts.puId80XfullId = cms.InputTag('pileupJetId80X:fullId')
636  run2_jme_2016.toModify(proc.updatedJetsWithUserData.userFloats, puId80XDisc = cms.InputTag("pileupJetId80X:fullDiscriminant"))
637 
638  proc.jetTable.variables.puId = Var("userInt('puId80XfullId')", int, doc="Pilup ID flags with 80X (2016) training")
639  run2_jme_2016.toModify(proc.jetTable.variables, puIdDisc = Var("userFloat('puId80XDisc')",float,doc="Pilup ID discriminant with 80X (2016) training",precision=10))
640 
641  #
642  # Add variables for pileup jet ID studies.
643  #
644  proc = AddPileUpJetIDVars(proc,
645  jetName="",
646  jetSrc="updatedJets",
647  jetTableName="jetTable",
648  jetSequenceName="jetSequence"
649  )
650  #
651  # Add variables for quark guon likelihood tagger studies.
652  # Save variables as userFloats and userInts in each jet
653  #
654  proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag("qgtagger:axis2")
655  proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag("qgtagger:ptD")
656  proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag("qgtagger:mult")
657  #
658  # Specfiy variables in the jetTable to save in NanoAOD
659  #
660  proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
661  proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
662  proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
663  #
664  # Save DeepJet raw score for gluon and light quarks
665  #
666  proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
667  proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
668  #
669  # Add ParticleNetAK4 scores
670  #
671  proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
672  proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
673  proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
674  proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
675  proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
676 
677  #Adding hf shower shape producer to the jet sequence. By default this producer is not automatically rerun at the NANOAOD step
678  #The following lines make sure it is.
679  hfJetShowerShapeforCustomNanoAOD = "hfJetShowerShapeforCustomNanoAOD"
680  setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShapeforNanoAOD.clone(jets="updatedJets",vertices="offlineSlimmedPrimaryVertices") )
681  proc.jetSequence.insert(proc.jetSequence.index(proc.updatedJetsWithUserData), getattr(proc, hfJetShowerShapeforCustomNanoAOD))
682  proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
683  proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
684  proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
685  proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
686  proc.jetTable.variables.hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
687  proc.jetTable.variables.hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
688  proc.jetTable.variables.hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) ")
689  proc.jetTable.variables.hfadjacentEtaStripsSize = Var("userInt('hfadjacentEtaStripsSize')", int, doc="eta size of the strips next to the central tower strip in HF (noise discriminating variable) ")
690 
691  return proc
692 
694  """
695  Add more variables for AK8 PFPUPPI jets
696  """
697 
698  #
699  # These variables are not stored for AK8PFCHS (slimmedJetsAK8)
700  # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
701  #
702  proc.fatJetTable.variables.chHEF = Var("?isPFJet()?chargedHadronEnergyFraction():-1", float, doc="charged Hadron Energy Fraction", precision = 6)
703  proc.fatJetTable.variables.neHEF = Var("?isPFJet()?neutralHadronEnergyFraction():-1", float, doc="neutral Hadron Energy Fraction", precision = 6)
704  proc.fatJetTable.variables.chEmEF = Var("?isPFJet()?chargedEmEnergyFraction():-1", float, doc="charged Electromagnetic Energy Fraction", precision = 6)
705  proc.fatJetTable.variables.neEmEF = Var("?isPFJet()?neutralEmEnergyFraction():-1", float, doc="neutral Electromagnetic Energy Fraction", precision = 6)
706  proc.fatJetTable.variables.muEF = Var("?isPFJet()?muonEnergyFraction():-1", float, doc="muon Energy Fraction", precision = 6)
707  proc.fatJetTable.variables.hfHEF = Var("?isPFJet()?HFHadronEnergyFraction():-1", float, doc="energy fraction in forward hadronic calorimeter", precision = 6)
708  proc.fatJetTable.variables.hfEmEF = Var("?isPFJet()?HFEMEnergyFraction():-1", float, doc="energy fraction in forward EM calorimeter", precision = 6)
709  proc.fatJetTable.variables.nConstChHads = Var("?isPFJet()?chargedHadronMultiplicity():-1",int, doc="number of charged hadrons in the jet")
710  proc.fatJetTable.variables.nConstNeuHads = Var("?isPFJet()?neutralHadronMultiplicity():-1",int, doc="number of neutral hadrons in the jet")
711  proc.fatJetTable.variables.nConstHFHads = Var("?isPFJet()?HFHadronMultiplicity():-1", int, doc="number of HF Hadrons in the jet")
712  proc.fatJetTable.variables.nConstHFEMs = Var("?isPFJet()?HFEMMultiplicity():-1", int, doc="number of HF EMs in the jet")
713  proc.fatJetTable.variables.nConstMuons = Var("?isPFJet()?muonMultiplicity():-1", int, doc="number of muons in the jet")
714  proc.fatJetTable.variables.nConstElecs = Var("?isPFJet()?electronMultiplicity():-1", int, doc="number of electrons in the jet")
715  proc.fatJetTable.variables.nConstPhotons = Var("?isPFJet()?photonMultiplicity():-1", int, doc="number of photons in the jet")
716 
717  return proc
718 #******************************************
719 #
720 #
721 # Gen Jets related functions
722 #
723 #
724 #******************************************
725 def AddNewGenJets(proc, genJetInfo):
726  """
727  Add genJet into custom nanoAOD
728  """
729 
730  genJetName = genJetInfo.jetUpper
731  genJetAlgo = genJetInfo.jetAlgo
732  genJetSize = genJetInfo.jetSize
733  genJetSizeNr = genJetInfo.jetSizeNr
734  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
735  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
736  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
737 
738  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
739 
740  return proc
741 
742 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
743  """
744  Schedule modules for a given genJet collection and save its variables into custom NanoAOD
745  """
746 
747  genJetTableThisJet = "jet{}Table".format(genJetName)
748  setattr(proc, genJetTableThisJet, genJetTable.clone(
749  src = genJetFinalColl,
750  cut = "pt > 1",
751  name = genJetTablePrefix,
752  doc = genJetTableDoc,
753  variables = GENJETVARS
754  )
755  )
756 
757  genJetFlavourAssociationThisJet = "genJet{}FlavourAssociation".format(genJetName)
758  setattr(proc, genJetFlavourAssociationThisJet, genJetFlavourAssociation.clone(
759  jets = getattr(proc,genJetTableThisJet).src,
760  jetAlgorithm = supportedJetAlgos[genJetAlgo],
761  rParam = genJetSizeNr,
762  )
763  )
764 
765  genJetFlavourTableThisJet = "genJet{}FlavourTable".format(genJetName)
766  setattr(proc, genJetFlavourTableThisJet, genJetFlavourTable.clone(
767  name = getattr(proc,genJetTableThisJet).name,
768  src = getattr(proc,genJetTableThisJet).src,
769  cut = getattr(proc,genJetTableThisJet).cut,
770  jetFlavourInfos = genJetFlavourAssociationThisJet,
771  )
772  )
773 
774  genJetSequenceName = "genJet{}Sequence".format(genJetName)
775  setattr(proc, genJetSequenceName, cms.Sequence(
776  getattr(proc,genJetTableThisJet)+
777  getattr(proc,genJetFlavourAssociationThisJet)+
778  getattr(proc,genJetFlavourTableThisJet)
779  )
780  )
781  proc.nanoSequenceMC.insert(proc.nanoSequenceMC.index(proc.jetMC)+1, getattr(proc,genJetSequenceName))
782 
783  return proc
784 
785 def ReclusterAK4GenJets(proc, genJA):
786  """
787  Recluster AK4 Gen jets and replace
788  slimmedGenJets that is used as default
789  to save AK4 Gen jets in NanoAODs.
790  """
791  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
792 
793  #
794  # Recluster AK4 Gen jet
795  #
796  cfg = {
797  "jet" : "ak4gen",
798  }
799  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
800 
801  genJetName = genJetInfo.jetUpper
802  genJetAlgo = genJetInfo.jetAlgo
803  genJetSize = genJetInfo.jetSize
804  genJetSizeNr = genJetInfo.jetSizeNr
805  selectedPatGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
806 
807  #
808  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
809  # to be stored in the GenJet Table
810  #
811  proc.genJetTable.src = selectedPatGenJets
812  proc.genJetTable.cut = "pt > 1"
813  proc.genJetTable.doc ="AK4 Gen jets (made with visible genparticles)"
814 
815  genJetFlavourAssociationThisJet = "genJet{}FlavourAssociation".format(genJetName)
816  setattr(proc, genJetFlavourAssociationThisJet, genJetFlavourAssociation.clone(
817  jets = proc.genJetTable.src,
818  jetAlgorithm = supportedJetAlgos[genJetAlgo],
819  rParam = genJetSizeNr,
820  )
821  )
822  proc.jetMC.insert(proc.jetMC.index(proc.genJetFlavourTable), getattr(proc, genJetFlavourAssociationThisJet))
823  return proc
824 
826  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
827  return proc
828 
830  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
831  return proc
832 
833 #===========================================================================
834 #
835 # Misc. functions
836 #
837 #===========================================================================
839  """
840  Remove default pt cuts for all jets set in jets_cff.py
841  """
842 
843  proc.finalJets.cut = "" # 15 -> 10
844  proc.finalJetsAK8.cut = "" # 170 -> 170
845  proc.genJetTable.cut = "" # 10 -> 8
846  proc.genJetFlavourTable.cut = "" # 10 -> 8
847  proc.genJetAK8Table.cut = "" # 100 -> 80
848  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
849 
850  return proc
851 
852 #===========================================================================
853 #
854 # CUSTOMIZATION function
855 #
856 #===========================================================================
857 def PrepJMECustomNanoAOD(process,runOnMC):
858 
859  ############################################################################
860  # Remove all default jet pt cuts from jets_cff.py
861  ############################################################################
862  process = RemoveAllJetPtCuts(process)
863 
864  ###########################################################################
865  #
866  # Gen-level jets related functions. Only for MC.
867  #
868  ###########################################################################
869  genJA = GenJetAdder()
870  if runOnMC:
871  ############################################################################
872  # Save additional variables for AK8 GEN jets
873  ############################################################################
874  process = AddVariablesForAK8GenJets(process)
875  ###########################################################################
876  # Recluster AK4 GEN jets
877  ###########################################################################
878  process = ReclusterAK4GenJets(process, genJA)
879  process = AddVariablesForAK4GenJets(process)
880  ###########################################################################
881  # Add additional GEN jets to NanoAOD
882  ###########################################################################
883  for jetConfig in config_genjets:
884  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
885  genJetInfo = genJA.addGenJetCollection(process, **cfg)
886  AddNewGenJets(process, genJetInfo)
887 
888  ###########################################################################
889  #
890  # Reco-level jets related functions. For both MC and data.
891  #
892  ###########################################################################
893  recoJA = RecoJetAdder(runOnMC=runOnMC)
894  ###########################################################################
895  # Save additional variables for AK8Puppi jets
896  ###########################################################################
897  process = AddVariablesForAK8PuppiJets(process)
898  ###########################################################################
899  # Recluster AK4 CHS jets and replace "slimmedJets"
900  ###########################################################################
901  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
902  ###########################################################################
903  # Add additional Reco jets to NanoAOD
904  ###########################################################################
905  for jetConfig in config_recojets:
906  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
907  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
908  AddNewPatJets(process, recoJetInfo, runOnMC)
909 
910  ###########################################################################
911  # Save Maximum of Pt Hat Max
912  ###########################################################################
913  if runOnMC:
914  process.puTable.savePtHatMax = True
915 
916  return process
917 
919  PrepJMECustomNanoAOD(process,runOnMC=True)
920  return process
921 
923  PrepJMECustomNanoAOD(process,runOnMC=False)
924  return process
def AddBTaggingScores(proc, jetTableName="")
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def copy(args, dbName)
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="")
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", calculateQGLVars=False)
def RemoveAllJetPtCuts(proc)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
def ReclusterAK4GenJets(proc, genJA)
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut="", doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="")
def AddNewGenJets(proc, genJetInfo)
def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
def AddVariablesForAK4GenJets(proc)
def AddVariablesForAK8PuppiJets(proc)
def AddParticleNetAK4Scores(proc, jetTableName="")
def AddVariablesForAK8GenJets(proc)
def PrepJMECustomNanoAOD_MC(process)
def PrepJMECustomNanoAOD_Data(process)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run