CMS 3D CMS Logo

custom_jme_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
5 
6 from CommonTools.PileupAlgos.Puppi_cff import puppi
7 
8 from RecoJets.JetProducers.hfJetShowerShape_cfi import hfJetShowerShape
9 from RecoJets.JetProducers.PileupJetID_cfi import pileupJetIdCalculator, pileupJetId
10 from RecoJets.JetProducers.PileupJetID_cfi import _chsalgos_81x, _chsalgos_94x, _chsalgos_102x
11 
12 from PhysicsTools.NanoAOD.common_cff import Var, P4Vars
13 from PhysicsTools.NanoAOD.jetsAK4_CHS_cff import jetTable, jetCorrFactorsNano, updatedJets, finalJets, qgtagger
14 from PhysicsTools.NanoAOD.jetsAK4_Puppi_cff import jetPuppiTable, jetPuppiCorrFactorsNano, updatedJetsPuppi, updatedJetsPuppiWithUserData
15 from PhysicsTools.NanoAOD.jetMC_cff import genJetTable, genJetFlavourAssociation, genJetFlavourTable
16 
17 from PhysicsTools.PatAlgos.tools.jetCollectionTools import GenJetAdder, RecoJetAdder
18 from PhysicsTools.PatAlgos.tools.jetTools import supportedJetAlgos
19 from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
20 
21 import copy
22 
23 bTagCSVV2 = ['pfCombinedInclusiveSecondaryVertexV2BJetTags']
24 bTagDeepCSV = ['pfDeepCSVJetTags:probb','pfDeepCSVJetTags:probbb','pfDeepCSVJetTags:probc','pfDeepCSVJetTags:probudsg']
25 bTagDeepJet = [
26  'pfDeepFlavourJetTags:probb','pfDeepFlavourJetTags:probbb','pfDeepFlavourJetTags:problepb',
27  'pfDeepFlavourJetTags:probc','pfDeepFlavourJetTags:probuds','pfDeepFlavourJetTags:probg'
28 ]
29 from RecoBTag.ONNXRuntime.pfParticleNetAK4_cff import _pfParticleNetAK4JetTagsAll
30 bTagDiscriminatorsForAK4 = bTagCSVV2+bTagDeepCSV+bTagDeepJet+_pfParticleNetAK4JetTagsAll
31 
32 from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsAll
33 from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetJetTagsAll
34 
35 btagHbb = ['pfBoostedDoubleSecondaryVertexAK8BJetTags']
36 btagDDX = [
37  'pfDeepDoubleBvLJetTags:probHbb',
38  'pfDeepDoubleCvLJetTags:probHcc',
39  'pfDeepDoubleCvBJetTags:probHcc',
40  'pfMassIndependentDeepDoubleBvLJetTags:probHbb',
41  'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
42  'pfMassIndependentDeepDoubleCvBJetTags:probHcc'
43 ]
44 btagDDXV2 = [
45  'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
46  'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
47  'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc'
48 ]
49 
50 #
51 # By default, these collections are saved in NanoAODs:
52 # - ak4gen (GenJet in NanoAOD), slimmedGenJets in MiniAOD
53 # - ak8gen (GenJetAK8 in NanoAOD), slimmedGenJetsAK8 in MiniAOD
54 # Below is a list of genjets that we can save in NanoAOD. Set
55 # "enabled" to true if you want to store the jet collection
56 config_genjets = [
57  {
58  "jet" : "ak6gen",
59  "enabled" : False,
60  },
61 ]
62 config_genjets = list(filter(lambda k: k['enabled'], config_genjets))
63 #
64 # GenJets info in NanoAOD
65 #
66 nanoInfo_genjets = {
67  "ak6gen" : {
68  "name" : "GenJetAK6",
69  "doc" : "AK6 Gen jets (made with visible genparticles) with pt > 3 GeV", # default genjets pt cut after clustering is 3 GeV
70  },
71 }
72 #
73 # By default, these collections are saved in the main NanoAODs:
74 # - ak4pfpuppi (Jet in NanoAOD), slimmedJetsPuppi in MiniAOD
75 # - ak8pfpuppi (FatJet in NanoAOD), slimmedJetsAK8 in MiniAOD
76 # Below is a list of recojets that we can save in NanoAOD. Set
77 # "enabled" to true if you want to store the recojet collection.
78 #
79 config_recojets = [
80  {
81  "jet" : "ak4calo",
82  "enabled" : True,
83  "inputCollection" : "slimmedCaloJets", #Exist in MiniAOD
84  "genJetsCollection": "AK4GenJetsNoNu",
85  },
86  {
87  "jet" : "ak4pf",
88  "enabled" : False,
89  "inputCollection" : "",
90  "genJetsCollection": "AK4GenJetsNoNu",
91  "minPtFastjet" : 0.,
92  },
93  {
94  "jet" : "ak8pf",
95  "enabled" : False,
96  "inputCollection" : "",
97  "genJetsCollection": "AK8GenJetsNoNu",
98  "minPtFastjet" : 0.,
99  },
100 ]
101 config_recojets = list(filter(lambda k: k['enabled'], config_recojets))
102 #
103 # RecoJets info in NanoAOD
104 #
105 nanoInfo_recojets = {
106  "ak4calo" : {
107  "name": "JetCalo",
108  "doc" : "AK4 Calo jets (slimmedCaloJets)",
109  },
110  "ak4pf" : {
111  "name" : "JetPF",
112  "doc" : "AK4 PF jets",
113  "ptcut" : "",
114  },
115  "ak8pf" : {
116  "name" : "FatJetPF",
117  "doc" : "AK8 PF jets",
118  "ptcut" : "",
119  },
120 }
121 
122 GENJETVARS = cms.PSet(P4Vars,
123  nConstituents = jetTable.variables.nConstituents,
124 )
125 PFJETVARS = cms.PSet(P4Vars,
126  rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
127  area = jetTable.variables.area,
128  chHEF = jetTable.variables.chHEF,
129  neHEF = jetTable.variables.neHEF,
130  chEmEF = jetTable.variables.chEmEF,
131  neEmEF = jetTable.variables.neEmEF,
132  muEF = jetTable.variables.muEF,
133  hfHEF = Var("HFHadronEnergyFraction()",float,doc = "hadronic energy fraction in HF",precision = 6),
134  hfEmEF = Var("HFEMEnergyFraction()",float,doc = "electromagnetic energy fraction in HF",precision = 6),
135  nMuons = jetTable.variables.nMuons,
136  nElectrons = jetTable.variables.nElectrons,
137  nConstituents = jetTable.variables.nConstituents,
138  nConstChHads = Var("chargedHadronMultiplicity()",int,doc="number of charged hadrons in the jet"),
139  nConstNeuHads = Var("neutralHadronMultiplicity()",int,doc="number of neutral hadrons in the jet"),
140  nConstHFHads = Var("HFHadronMultiplicity()", int,doc="number of HF hadrons in the jet"),
141  nConstHFEMs = Var("HFEMMultiplicity()",int,doc="number of HF EMs in the jet"),
142  nConstMuons = Var("muonMultiplicity()",int,doc="number of muons in the jet"),
143  nConstElecs = Var("electronMultiplicity()",int,doc="number of electrons in the jet"),
144  nConstPhotons = Var("photonMultiplicity()",int,doc="number of photons in the jet"),
145 )
146 PUIDVARS = cms.PSet(
147  puId_dR2Mean = Var("?(pt>=10)?userFloat('puId_dR2Mean'):-1",float,doc="pT^2-weighted average square distance of jet constituents from the jet axis (PileUp ID BDT input variable)", precision=14),
148  puId_majW = Var("?(pt>=10)?userFloat('puId_majW'):-1",float,doc="major axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision=14),
149  puId_minW = Var("?(pt>=10)?userFloat('puId_minW'):-1",float,doc="minor axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision=14),
150  puId_frac01 = Var("?(pt>=10)?userFloat('puId_frac01'):-1",float,doc="fraction of constituents' pT contained within dR <0.1 (PileUp ID BDT input variable)", precision=14),
151  puId_frac02 = Var("?(pt>=10)?userFloat('puId_frac02'):-1",float,doc="fraction of constituents' pT contained within 0.1< dR <0.2 (PileUp ID BDT input variable)", precision=14),
152  puId_frac03 = Var("?(pt>=10)?userFloat('puId_frac03'):-1",float,doc="fraction of constituents' pT contained within 0.2< dR <0.3 (PileUp ID BDT input variable)", precision=14),
153  puId_frac04 = Var("?(pt>=10)?userFloat('puId_frac04'):-1",float,doc="fraction of constituents' pT contained within 0.3< dR <0.4 (PileUp ID BDT input variable)", precision=14),
154  puId_ptD = Var("?(pt>=10)?userFloat('puId_ptD'):-1",float,doc="pT-weighted average pT of constituents (PileUp ID BDT input variable)", precision=14),
155  puId_beta = Var("?(pt>=10)?userFloat('puId_beta'):-1",float,doc="fraction of pT of charged constituents associated to PV (PileUp ID BDT input variable)", precision=14),
156  puId_pull = Var("?(pt>=10)?userFloat('puId_pull'):-1",float,doc="magnitude of pull vector (PileUp ID BDT input variable)", precision=14),
157  puId_jetR = Var("?(pt>=10)?userFloat('puId_jetR'):-1",float,doc="fraction of jet pT carried by the leading constituent (PileUp ID BDT input variable)", precision=14),
158  puId_jetRchg = Var("?(pt>=10)?userFloat('puId_jetRchg'):-1",float,doc="fraction of jet pT carried by the leading charged constituent (PileUp ID BDT input variable)", precision=14),
159  puId_nCharged = Var("?(pt>=10)?userInt('puId_nCharged'):-1",int,doc="number of charged constituents (PileUp ID BDT input variable)"),
160 )
161 QGLVARS = cms.PSet(
162  qgl_axis2 = Var("?(pt>=10)?userFloat('qgl_axis2'):-1",float,doc="ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision=14),
163  qgl_ptD = Var("?(pt>=10)?userFloat('qgl_ptD'):-1",float,doc="pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)", precision=14),
164  qgl_mult = Var("?(pt>=10)?userInt('qgl_mult'):-1", int,doc="PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
165 )
166 BTAGVARS = cms.PSet(
167  btagDeepB = Var("?(pt>=15)&&((bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0)?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc="DeepCSV b+bb tag discriminator",precision=10),
168  btagCSVV2 = Var("?(pt>=15)?bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags'):-1",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
169  btagDeepCvL = Var("?(pt>=15)&&(bDiscriminator('pfDeepCSVJetTags:probc')>=0)?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc="DeepCSV c vs udsg discriminator",precision=10),
170  btagDeepCvB = Var("?(pt>=15)&&bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1",float,doc="DeepCSV c vs b+bb discriminator",precision=10),
171 )
172 DEEPJETVARS = cms.PSet(
173  btagDeepFlavB = Var("?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'):-1",float,doc="DeepJet b+bb+lepb tag discriminator",precision=10),
174  btagDeepFlavC = Var("?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probc'):-1",float,doc="DeepFlavour charm tag raw score",precision=10),
175  btagDeepFlavG = Var("?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probg'):-1",float,doc="DeepFlavour gluon tag raw score",precision=10),
176  btagDeepFlavUDS = Var("?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probuds'):-1",float,doc="DeepFlavour uds tag raw score",precision=10),
177  btagDeepFlavCvL = Var("?(pt>=15)&&(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1",float,doc="DeepJet c vs uds+g discriminator",precision=10),
178  btagDeepFlavCvB = Var("?(pt>=15)&&(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1",float,doc="DeepJet c vs b+bb+lepb discriminator",precision=10),
179  btagDeepFlavQG = Var("?(pt>=15)&&(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1",float,doc="DeepJet g vs uds discriminator",precision=10),
180 )
181 PARTICLENETAK4VARS = cms.PSet(
182  particleNetAK4_B = Var("?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:BvsAll'):-1",float,doc="ParticleNetAK4 tagger b vs all (udsg, c) discriminator",precision=10),
183  particleNetAK4_CvsL = Var("?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsL'):-1",float,doc="ParticleNetAK4 tagger c vs udsg discriminator",precision=10),
184  particleNetAK4_CvsB = Var("?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsB'):-1",float,doc="ParticleNetAK4 tagger c vs b discriminator",precision=10),
185  particleNetAK4_QvsG = Var("?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:QvsG'):-1",float,doc="ParticleNetAK4 tagger uds vs g discriminator",precision=10),
186  particleNetAK4_G = Var("?(pt>=15)?bDiscriminator('pfParticleNetAK4JetTags:probg'):-1",float,doc="ParticleNetAK4 tagger g raw score",precision=10),
187  particleNetAK4_puIdDisc = Var("?(pt>=15)?1-bDiscriminator('pfParticleNetAK4JetTags:probpu'):-1",float,doc="ParticleNetAK4 tagger pileup jet discriminator",precision=10),
188 )
189 
190 CALOJETVARS = cms.PSet(P4Vars,
191  area = jetTable.variables.area,
192  rawFactor = jetTable.variables.rawFactor,
193  emf = Var("emEnergyFraction()", float, doc = "electromagnetic energy fraction", precision = 10),
194 )
195 
196 
197 #******************************************
198 #
199 #
200 # Reco Jets related functions
201 #
202 #
203 #******************************************
204 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
205  """
206  Setup modules to calculate PF jet ID
207  """
208 
209  isPUPPIJet = True if "PUPPI" in jetName.upper() else False
210 
211  looseJetId = "looseJetId{}".format(jetName)
212  setattr(proc, looseJetId, proc.looseJetId.clone(
213  src = jetSrc,
214  filterParams = proc.looseJetId.filterParams.clone(
215  version = "WINTER16"
216  ),
217  )
218  )
219 
220  tightJetId = "tightJetId{}".format(jetName)
221  setattr(proc, tightJetId, proc.tightJetId.clone(
222  src = jetSrc,
223  filterParams = proc.tightJetId.filterParams.clone(
224  version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
225  ),
226  )
227  )
228 
229  tightJetIdLepVeto = "tightJetIdLepVeto{}".format(jetName)
230  setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
231  src = jetSrc,
232  filterParams = proc.tightJetIdLepVeto.filterParams.clone(
233  version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
234  ),
235  )
236  )
237 
238  run2_jme_2016.toModify(
239  getattr(proc, tightJetId).filterParams, version = "RUN2UL16{}".format("PUPPI" if isPUPPIJet else "CHS")
240  ).toModify(
241  getattr(proc, tightJetIdLepVeto).filterParams, version = "RUN2UL16{}".format("PUPPI" if isPUPPIJet else "CHS")
242  )
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 
251  #
252  # Specfiy variables in the jetTable to save in NanoAOD
253  #
254  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")
255 
256  getattr(proc,jetTaskName).add(getattr(proc, tightJetId))
257  getattr(proc,jetTaskName).add(getattr(proc, tightJetIdLepVeto))
258 
259  return proc
260 
261 def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
262  """
263  Setup modules to calculate pileup jet ID input variables for PF jet
264  """
265 
266  #
267  # Calculate pileup jet ID variables
268  #
269  puJetIdVarsCalculator = "puJetIdCalculator{}".format(jetName)
270  setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
271  jets = jetSrc,
272  vertexes = "offlineSlimmedPrimaryVertices",
273  inputIsCorrected = True,
274  applyJec = False,
275  usePuppi = True if "PUPPI" in jetName.upper() else False,
276  srcConstituentWeights = "packedPFCandidatespuppi" if "PUPPI" in jetName.upper() else "",
277  useBugFix = True
278  )
279  )
280  getattr(proc,jetTaskName).add(getattr(proc, puJetIdVarsCalculator))
281 
282  #
283  # Get the variables
284  #
285  puJetIDVar = "puJetIDVar{}".format(jetName)
286  setattr(proc, puJetIDVar, cms.EDProducer("PileupJetIDVarProducer",
287  srcJet = cms.InputTag(jetSrc),
288  srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
289  )
290  )
291  getattr(proc,jetTaskName).add(getattr(proc, puJetIDVar))
292 
293  #
294  # Save variables as userFloats and userInts for each jet
295  #
296  patJetWithUserData = "{}WithUserData".format(jetSrc)
297  getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag("{}:dR2Mean".format(puJetIDVar))
298  getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag("{}:majW".format(puJetIDVar))
299  getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag("{}:minW".format(puJetIDVar))
300  getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag("{}:frac01".format(puJetIDVar))
301  getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag("{}:frac02".format(puJetIDVar))
302  getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag("{}:frac03".format(puJetIDVar))
303  getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag("{}:frac04".format(puJetIDVar))
304  getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag("{}:ptD".format(puJetIDVar))
305  getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag("{}:beta".format(puJetIDVar))
306  getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag("{}:pull".format(puJetIDVar))
307  getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag("{}:jetR".format(puJetIDVar))
308  getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag("{}:jetRchg".format(puJetIDVar))
309  getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag("{}:nCharged".format(puJetIDVar))
310 
311  #
312  # Specfiy variables in the jet table to save in NanoAOD
313  #
314  getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
315  getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
316  getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
317  getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
318  getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
319  getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
320  getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
321  getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
322  getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
323  getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
324  getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
325  getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
326  getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
327 
328  return proc
329 
330 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
331  """
332  Schedule the QGTagger module to calculate input variables to the QG likelihood
333  """
334 
335  isPUPPIJet = True if "PUPPI" in jetName.upper() else False
336 
337  QGLTagger="qgtagger{}".format(jetName)
338  patJetWithUserData="{}WithUserData".format(jetSrc)
339 
340  if calculateQGLVars:
341  setattr(proc, QGLTagger, qgtagger.clone(
342  srcJets = jetSrc,
343  computeLikelihood = False,
344  )
345  )
346  if isPUPPIJet:
347  getattr(proc,QGLTagger).srcConstituentWeights = cms.InputTag("packedPFCandidatespuppi")
348 
349  #
350  # Save variables as userFloats and userInts for each jet
351  #
352  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
353  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
354  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
355 
356  #
357  # Specfiy variables in the jet table to save in NanoAOD
358  #
359  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
360  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
361  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
362 
363  if calculateQGLVars:
364  getattr(proc,jetTaskName).add(getattr(proc, QGLTagger))
365 
366  return proc
367 
368 def AddBTaggingScores(proc, jetTableName=""):
369  """
370  Store b-tagging scores from various algortihm
371  """
372 
373  getattr(proc, jetTableName).variables.btagDeepB = BTAGVARS.btagDeepB
374  getattr(proc, jetTableName).variables.btagCSVV2 = BTAGVARS.btagCSVV2
375  getattr(proc, jetTableName).variables.btagDeepCvL = BTAGVARS.btagDeepCvL
376  getattr(proc, jetTableName).variables.btagDeepCvB = BTAGVARS.btagDeepCvB
377  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
378  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
379  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
380 
381  return proc
382 
383 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
384  """
385  Store DeepJet raw score in jetTable for gluon and light quark
386  """
387 
388  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
389  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
390  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
391 
392  return proc
393 
394 def AddParticleNetAK4Scores(proc, jetTableName=""):
395  """
396  Store ParticleNetAK4 scores in jetTable
397  """
398 
399  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
400  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
401  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
402  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
403  getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
404  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
405 
406  return proc
407 
408 def AddNewPatJets(proc, recoJetInfo, runOnMC):
409  """
410  Add patJet into custom nanoAOD
411  """
412 
413  jetName = recoJetInfo.jetUpper
414  payload = recoJetInfo.jetCorrPayload
415  doPF = recoJetInfo.doPF
416  doCalo = recoJetInfo.doCalo
417  patJetFinalColl = recoJetInfo.patJetFinalCollection
418 
419  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
420  jetTablePrefix = nanoInfoForJet["name"]
421  jetTableDoc = nanoInfoForJet["doc"]
422  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else 8
423  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
424  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
425  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
426 
427  SavePatJets(proc,
428  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
429  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
430  )
431 
432  return proc
433 
434 def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc,
435  doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
436  """
437  Schedule modules for a given patJet collection and save its variables into custom NanoAOD
438  """
439 
440  #
441  # Setup jet correction factors
442  #
443  jetCorrFactors = "jetCorrFactorsNano{}".format(jetName)
444  setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
445  src = patJetFinalColl,
446  payload = payload,
447  )
448  )
449 
450  #
451  # Update jets
452  #
453  srcJets = "updatedJets{}".format(jetName)
454  setattr(proc, srcJets, updatedJets.clone(
455  jetSource = patJetFinalColl,
456  jetCorrFactorsSource = [jetCorrFactors],
457  )
458  )
459 
460  #
461  # Setup UserDataEmbedder
462  #
463  srcJetsWithUserData = "updatedJets{}WithUserData".format(jetName)
464  setattr(proc, srcJetsWithUserData, cms.EDProducer("PATJetUserDataEmbedder",
465  src = cms.InputTag(srcJets),
466  userFloats = cms.PSet(),
467  userInts = cms.PSet(),
468  )
469  )
470 
471  #
472  # Filter jets with pt cut
473  #
474  finalJetsCut = "(pt >= {ptcut:.0f})".format(ptcut=ptcut)
475  if runOnMC:
476  finalJetsCut = "(pt >= {ptcut:.0f}) || ((pt < {ptcut:.0f}) && (genJetFwdRef().backRef().isNonnull()))".format(ptcut=ptcut)
477 
478  finalJetsForTable = "finalJets{}".format(jetName)
479  setattr(proc, finalJetsForTable, finalJets.clone(
480  src = srcJetsWithUserData,
481  cut = finalJetsCut
482  )
483  )
484 
485  #
486  # Save jets in table
487  #
488  tableContent = PFJETVARS
489  if doCalo:
490  tableContent = CALOJETVARS
491 
492  jetTableCutDefault = "" #Don't apply any cuts for the table.
493 
494  jetTableDocDefault = jetTableDoc + " with JECs applied. Jets with pt >= {ptcut:.0f} GeV are stored.".format(ptcut=ptcut)
495  if runOnMC:
496  jetTableDocDefault += "For jets with pt < {ptcut:.0f} GeV, only those matched to gen jets are stored.".format(ptcut=ptcut)
497 
498  if doCalo:
499  jetTableDocDefault = jetTableDoc
500 
501  jetTableName = "jet{}Table".format(jetName)
502  setattr(proc,jetTableName, simpleCandidateFlatTableProducer.clone(
503  src = cms.InputTag(finalJetsForTable),
504  cut = cms.string(jetTableCutDefault),
505  name = cms.string(jetTablePrefix),
506  doc = cms.string(jetTableDocDefault),
507  variables = cms.PSet(tableContent)
508  )
509  )
510  getattr(proc,jetTableName).variables.pt.precision=10
511  getattr(proc,jetTableName).variables.rawFactor.precision=10
512 
513  #
514  # Save MC-only jet variables in table
515  #
516  jetMCTableName = "jet{}MCTable".format(jetName)
517  setattr(proc, jetMCTableName, simpleCandidateFlatTableProducer.clone(
518  src = cms.InputTag(finalJetsForTable),
519  cut = getattr(proc,jetTableName).cut,
520  name = cms.string(jetTablePrefix),
521  extension = cms.bool(True), # this is an extension table
522  variables = cms.PSet(
523  partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
524  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
525  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
526  )
527  )
528  )
529 
530  #
531  # Define the jet modules Task first
532  #
533  jetTaskName = "jet{}Task".format(jetName)
534  setattr(proc, jetTaskName, cms.Task(
535  getattr(proc,jetCorrFactors),
536  getattr(proc,srcJets),
537  getattr(proc,srcJetsWithUserData),
538  getattr(proc,finalJetsForTable)
539  )
540  )
541  proc.nanoTableTaskCommon.add(getattr(proc,jetTaskName))
542 
543  #
544  # Define the jet tables Task
545  #
546  jetTableTaskName = "jet{}TablesTask".format(jetName)
547  setattr(proc, jetTableTaskName, cms.Task(getattr(proc,jetTableName)))
548  proc.nanoTableTaskCommon.add(getattr(proc,jetTableTaskName))
549 
550  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
551  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
552  if runOnMC:
553  proc.nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
554 
555  #
556  # Schedule plugins to calculate Jet ID, PileUp Jet ID input variables, and Quark-Gluon Likehood input variables.
557  #
558  if doPF:
559  proc = AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
560  if doPUIDVar:
561  proc = AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
562  if doQGL:
563  proc = AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName, calculateQGLVars=True)
564 
565  #
566  # Save b-tagging algorithm scores. Should only be done for jet collection with b-tagging
567  # calculated when reclustered or collection saved with b-tagging info in MiniAOD
568  #
569  if doBTag:
570  AddBTaggingScores(proc,jetTableName=jetTableName)
571  AddDeepJetGluonLQuarkScores(proc,jetTableName=jetTableName)
572  AddParticleNetAK4Scores(proc,jetTableName=jetTableName)
573 
574  return proc
575 
576 
577 def ReclusterAK4PuppiJets(proc, recoJA, runOnMC):
578  """
579  Recluster AK4 Puppi jets and replace slimmedJetsPuppi
580  that is used as default to save AK4 Puppi jets in NanoAODs.
581  """
582  print("custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
583 
584  #
585  # Recluster AK4 Puppi jets
586  #
587  cfg = {
588  "jet" : "ak4pfpuppi",
589  "inputCollection" : "",
590  "genJetsCollection": "AK4GenJetsNoNu",
591  "bTagDiscriminators": bTagDiscriminatorsForAK4,
592  "minPtFastjet" : 0.,
593  }
594  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
595 
596  jetName = recoJetInfo.jetUpper
597  patJetFinalColl = recoJetInfo.patJetFinalCollection
598 
599  #
600  # Set the jetID for UL 16 era
601  #
602  run2_jme_2016.toModify(
603  proc.tightJetPuppiId.filterParams, version = "RUN2UL16PUPPI"
604  ).toModify(
605  proc.tightJetIdLepVeto.filterParams, version = "RUN2UL16PUPPI"
606  )
607 
608  #
609  # Change the input jet source for jetCorrFactorsNano
610  # and updatedJets
611  #
612  proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
613  proc.updatedJetsPuppi.jetSource=patJetFinalColl
614 
615  #
616  # Change pt cut
617  #
618  finalJetsPuppiCut = ""
619  if runOnMC:
620  finalJetsPuppiCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
621  else:
622  finalJetsPuppiCut = "(pt >= 8)"
623 
624  proc.finalJetsPuppi.cut = finalJetsPuppiCut
625  #
626  # Add a minimum pt cut for corrT1METJets.
627  #
628  proc.corrT1METJetPuppiTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
629 
630  #
631  # Jet table
632  #
633  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
634  run2_nanoAOD_ANY.toModify(
635  proc.jetTable, name = "Jet"
636  ).toModify(
637  # So need to change the table name for AK4 puppi here
638  proc.jetPuppiTable,
639  name = "JetPuppi",
640  src = cms.InputTag("finalJetsPuppi")
641  )
642 
643  #
644  # Jet table documentation
645  #
646  jetPuppiTableDoc = "AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored."
647  if runOnMC:
648  jetPuppiTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
649  proc.jetPuppiTable.doc = jetPuppiTableDoc
650 
651  proc.jetPuppiTable.variables.rawFactor.precision = 10
652 
653  #
654  # Add variables
655  #
656  proc.jetPuppiTable.variables.hfHEF = PFJETVARS.hfHEF
657  proc.jetPuppiTable.variables.hfEmEF = PFJETVARS.hfEmEF
658  proc.jetPuppiTable.variables.nConstChHads = PFJETVARS.nConstChHads
659  proc.jetPuppiTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
660  proc.jetPuppiTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
661  proc.jetPuppiTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
662  proc.jetPuppiTable.variables.nConstMuons = PFJETVARS.nConstMuons
663  proc.jetPuppiTable.variables.nConstElecs = PFJETVARS.nConstElecs
664  proc.jetPuppiTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
665 
666  #
667  # Add variables for pileup jet ID studies.
668  #
669 
670  proc = AddPileUpJetIDVars(proc,
671  jetName = jetName,
672  jetSrc = "updatedJetsPuppi",
673  jetTableName = "jetPuppiTable",
674  jetTaskName = "jetPuppiTask"
675  )
676  #
677  # Add variables for quark guon likelihood tagger studies.
678  # Save variables as userFloats and userInts in each jet
679  #
680  proc = AddQGLTaggerVars(proc,
681  jetName = jetName,
682  jetSrc = "updatedJetsPuppi",
683  jetTableName = "jetPuppiTable",
684  jetTaskName = "jetPuppiTask",
685  calculateQGLVars=True
686  )
687  #
688  # Save standard b-tagging and c-tagging variables
689  #
690  proc.jetPuppiTable.variables.btagDeepB = BTAGVARS.btagDeepB
691  proc.jetPuppiTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
692  proc.jetPuppiTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
693  proc.jetPuppiTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
694  #
695  # Save DeepJet b-tagging and c-tagging variables
696  #
697  proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
698  proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
699  proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
700  #
701  # Save DeepJet raw score for gluon and light quarks
702  #
703  proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
704  proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
705  proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
706  #
707  # Add ParticleNetAK4 scores
708  #
709  proc.jetPuppiTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
710  proc.jetPuppiTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
711  proc.jetPuppiTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
712  proc.jetPuppiTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
713  proc.jetPuppiTable.variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
714  proc.jetPuppiTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
715 
716  #
717  # For Run-2 eras, don't need to save the low pt AK4 Puppi jet table for MET
718  #
719  run2_nanoAOD_ANY.toReplaceWith(
720  proc.jetPuppiForMETTask,
721  proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
722  )
723 
724  #
725  # Save MC-only jet variables in jet table
726  #
727  if runOnMC:
728 
729  jetMCTableName = "jet{}MCTable".format(jetName)
730  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
731  src = proc.jetPuppiTable.src,
732  name = proc.jetPuppiTable.name
733  )
734  )
735  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
736  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
737 
738  run2_nanoAOD_ANY.toReplaceWith(
739  proc.nanoTableTaskFS,
740  proc.nanoTableTaskFS.copyAndAdd( getattr(proc,jetMCTableTaskName))
741  )
742 
743  return proc
744 
745 def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
746  """
747  Recluster AK4 CHS jets and replace slimmedJets that is used as default to
748  save AK4 CHS jets in NanoAODs (for Run-2).
749  """
750  print("custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
751 
752  #
753  # Recluster AK4 CHS jets
754  #
755  cfg = {
756  "jet" : "ak4pfchs",
757  "inputCollection" : "",
758  "genJetsCollection": "AK4GenJetsNoNu",
759  "bTagDiscriminators": bTagDiscriminatorsForAK4,
760  "minPtFastjet" : 0.,
761  }
762  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
763 
764  jetName = recoJetInfo.jetUpper
765  patJetFinalColl = recoJetInfo.patJetFinalCollection
766 
767  #
768  # Change the input jet source for jetCorrFactorsNano
769  # and updatedJets
770  #
771  proc.jetCorrFactorsNano.src=patJetFinalColl
772  proc.updatedJets.jetSource=patJetFinalColl
773 
774  #
775  # Change pt cut
776  #
777  finalJetsCut = ""
778  if runOnMC:
779  finalJetsCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
780  else:
781  finalJetsCut = "(pt >= 8)"
782 
783  proc.finalJets.cut = finalJetsCut
784  #
785  # Add a minimum pt cut for corrT1METJets.
786  #
787  proc.corrT1METJetTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
788 
789  #
790  # Jet table cut
791  #
792  jetTableCut = "" # must not have any cut at the jetTable for AK4 CHS as it has been cross-cleaned
793  proc.jetTable.src = cms.InputTag("finalJets")
794  proc.jetTable.cut = jetTableCut
795  proc.jetMCTable.cut = jetTableCut
796  proc.jetTable.name = "JetCHS"
797 
798  #
799  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
800  #
801  run2_nanoAOD_ANY.toModify(
802  proc.jetTable,
803  src = cms.InputTag("linkedObjects","jets"),
804  name = "Jet"
805  )
806 
807  #
808  # Jet table documentation
809  #
810  jetTableDoc = "AK4 PF CHS jets with JECs applied. Jets with pt >= 8 GeV are stored."
811  if runOnMC:
812  jetTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
813  proc.jetTable.doc = jetTableDoc
814 
815  proc.jetTable.variables.rawFactor.precision = 10
816 
817  #
818  # Add variables
819  #
820  proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
821  proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
822  proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
823  proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
824  proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
825  proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
826  proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
827  proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
828  proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
829 
830  #
831  # Add charged energy fraction from other primary vertices
832  #
833  proc.updatedJetsWithUserData.userFloats.chFPV1EF = cms.InputTag("jercVars:chargedFromPV1EnergyFraction")
834  proc.updatedJetsWithUserData.userFloats.chFPV2EF = cms.InputTag("jercVars:chargedFromPV2EnergyFraction")
835  proc.updatedJetsWithUserData.userFloats.chFPV3EF = cms.InputTag("jercVars:chargedFromPV3EnergyFraction")
836  proc.jetTable.variables.chFPV1EF = Var("userFloat('chFPV1EF')", float, doc="charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
837  proc.jetTable.variables.chFPV2EF = Var("userFloat('chFPV2EF')", float, doc="charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
838  proc.jetTable.variables.chFPV3EF = Var("userFloat('chFPV3EF')", float, doc="charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
839 
840  #
841  # Add variables for pileup jet ID studies.
842  #
843  proc = AddPileUpJetIDVars(proc,
844  jetName = jetName,
845  jetSrc = "updatedJets",
846  jetTableName = "jetTable",
847  jetTaskName = "jetTask"
848  )
849  #
850  # Add variables for quark guon likelihood tagger studies.
851  # Save variables as userFloats and userInts in each jet
852  #
853  proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag("qgtagger:axis2")
854  proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag("qgtagger:ptD")
855  proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag("qgtagger:mult")
856  #
857  # Save quark gluon likelihood input variables variables
858  #
859  proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
860  proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
861  proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
862  #
863  # Save standard b-tagging and c-tagging variables
864  #
865  proc.jetTable.variables.btagDeepB = BTAGVARS.btagDeepB
866  proc.jetTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
867  proc.jetTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
868  proc.jetTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
869  #
870  # Save DeepJet b-tagging and c-tagging variables
871  #
872  proc.jetTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
873  proc.jetTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
874  proc.jetTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
875  #
876  # Save DeepJet raw score for gluon and light quarks
877  #
878  proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
879  proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
880  proc.jetTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
881  #
882  # Add ParticleNetAK4 scores
883  #
884  proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
885  proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
886  proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
887  proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
888  proc.jetTable.variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
889  proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
890 
891  #Adding hf shower shape producer to the jet sequence. By default this producer is not automatically rerun at the NANOAOD step
892  #The following lines make sure it is.
893  hfJetShowerShapeforCustomNanoAOD = "hfJetShowerShapeforCustomNanoAOD"
894  setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShape.clone(jets="updatedJets", vertices="offlineSlimmedPrimaryVertices") )
895  proc.jetUserDataTask.add(getattr(proc, hfJetShowerShapeforCustomNanoAOD))
896  proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
897  proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
898  proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
899  proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
900  proc.jetTable.variables.hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
901  proc.jetTable.variables.hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
902  proc.jetTable.variables.hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) ")
903  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) ")
904 
905  #
906  # Since AK4 Puppi jet is the main AK4 jet collection for Run-3, disable
907  # b-jets/c-jets NN-based mass regression for AK4 CHS.
908  #
909  (~run2_nanoAOD_ANY).toReplaceWith(
910  proc.jetUserDataTask,
911  proc.jetUserDataTask.copyAndExclude([proc.bJetVars])
912  ).toReplaceWith(
913  proc.jetTablesTask,
914  proc.jetTablesTask.copyAndExclude([proc.bjetNN, proc.cjetNN])
915  ).toModify(proc.updatedJetsWithUserData.userFloats,
916  leadTrackPt = None,
917  leptonPtRelv0 = None,
918  leptonPtRelInvv0 = None,
919  leptonDeltaR = None,
920  vtxPt = None,
921  vtxMass = None,
922  vtx3dL = None,
923  vtx3deL = None,
924  ptD = None,
925  ).toModify(
926  proc.updatedJetsWithUserData.userInts,
927  vtxNtrk = None,
928  leptonPdgId = None
929  ).toModify(
930  proc.jetTable, externalVariables = cms.PSet()
931  ).toReplaceWith(
932  #
933  # For Run-3, don't need to save the low pt AK4 CHS jet table for MET
934  #
935  proc.jetForMETTask,
936  proc.jetForMETTask.copyAndExclude([proc.corrT1METJetTable])
937  )
938 
939  #
940  # Save MC-only jet variables in jet table
941  #
942  if runOnMC:
943  jetMCTableName = "jet{}MCTable".format(jetName)
944  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
945  src = proc.jetTable.src,
946  name = proc.jetTable.name
947  )
948  )
949  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
950  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
951 
952  (~run2_nanoAOD_ANY).toReplaceWith(
953  proc.nanoTableTaskFS,
954  proc.nanoTableTaskFS.copyAndAdd(getattr(proc,jetMCTableTaskName))
955  )
956 
957  return proc
958 
959 def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC):
960  """
961  Store a separate AK8 Puppi jet collection for JEC studies.
962  Only minimal info are stored
963  """
964  print("custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
965 
966  #
967  # Recluster AK8 Puppi jets
968  #
969  cfg = {
970  "jet" : "ak8pfpuppi",
971  "inputCollection" : "",
972  "genJetsCollection": "AK8GenJetsNoNu",
973  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
974  }
975  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
976 
977  jetName = recoJetInfo.jetUpper
978  payload = recoJetInfo.jetCorrPayload
979 
980  patJetFinalColl = recoJetInfo.patJetFinalCollection
981  jetTablePrefix = "FatJetForJEC"
982  jetTableDoc = "AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
983  ptcut = 15
984 
985  SavePatJets(proc,
986  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
987  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
988  )
989 
990  return proc
991 
992 def AddNewAK8CHSJets(proc, recoJA, runOnMC):
993  """
994  Store an AK8 CHS jet collection for JEC studies.
995  """
996  print("custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
997 
998  #
999  # Recluster AK8 CHS jets
1000  #
1001  cfg = {
1002  "jet" : "ak8pfchs",
1003  "inputCollection" : "",
1004  "genJetsCollection": "AK8GenJetsNoNu",
1005  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
1006  }
1007  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1008 
1009  jetName = recoJetInfo.jetUpper
1010  payload = recoJetInfo.jetCorrPayload
1011 
1012  patJetFinalColl = recoJetInfo.patJetFinalCollection
1013  jetTablePrefix = "FatJetCHS"
1014  jetTableDoc = "AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
1015  ptcut = 15
1016 
1017  SavePatJets(proc,
1018  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
1019  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
1020  )
1021 
1022  return proc
1023 
1025  """
1026  Add more variables for AK8 PFPUPPI jets
1027  """
1028 
1029  proc.fatJetTable.variables.rawFactor.precision = 10
1030 
1031  #
1032  # These variables are not stored for AK8PFPUPPI (slimmedJetsAK8)
1033  # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
1034  #
1035  proc.fatJetTable.variables.chHEF = Var("?isPFJet()?chargedHadronEnergyFraction():-1", float, doc="charged Hadron Energy Fraction", precision = 6)
1036  proc.fatJetTable.variables.neHEF = Var("?isPFJet()?neutralHadronEnergyFraction():-1", float, doc="neutral Hadron Energy Fraction", precision = 6)
1037  proc.fatJetTable.variables.chEmEF = Var("?isPFJet()?chargedEmEnergyFraction():-1", float, doc="charged Electromagnetic Energy Fraction", precision = 6)
1038  proc.fatJetTable.variables.neEmEF = Var("?isPFJet()?neutralEmEnergyFraction():-1", float, doc="neutral Electromagnetic Energy Fraction", precision = 6)
1039  proc.fatJetTable.variables.muEF = Var("?isPFJet()?muonEnergyFraction():-1", float, doc="muon Energy Fraction", precision = 6)
1040  proc.fatJetTable.variables.hfHEF = Var("?isPFJet()?HFHadronEnergyFraction():-1", float, doc="energy fraction in forward hadronic calorimeter", precision = 6)
1041  proc.fatJetTable.variables.hfEmEF = Var("?isPFJet()?HFEMEnergyFraction():-1", float, doc="energy fraction in forward EM calorimeter", precision = 6)
1042  proc.fatJetTable.variables.nConstChHads = Var("?isPFJet()?chargedHadronMultiplicity():-1",int, doc="number of charged hadrons in the jet")
1043  proc.fatJetTable.variables.nConstNeuHads = Var("?isPFJet()?neutralHadronMultiplicity():-1",int, doc="number of neutral hadrons in the jet")
1044  proc.fatJetTable.variables.nConstHFHads = Var("?isPFJet()?HFHadronMultiplicity():-1", int, doc="number of HF Hadrons in the jet")
1045  proc.fatJetTable.variables.nConstHFEMs = Var("?isPFJet()?HFEMMultiplicity():-1", int, doc="number of HF EMs in the jet")
1046  proc.fatJetTable.variables.nConstMuons = Var("?isPFJet()?muonMultiplicity():-1", int, doc="number of muons in the jet")
1047  proc.fatJetTable.variables.nConstElecs = Var("?isPFJet()?electronMultiplicity():-1", int, doc="number of electrons in the jet")
1048  proc.fatJetTable.variables.nConstPhotons = Var("?isPFJet()?photonMultiplicity():-1", int, doc="number of photons in the jet")
1049 
1050  return proc
1051 #******************************************
1052 #
1053 #
1054 # Gen Jets related functions
1055 #
1056 #
1057 #******************************************
1058 def AddNewGenJets(proc, genJetInfo):
1059  """
1060  Add genJet into custom nanoAOD
1061  """
1062 
1063  genJetName = genJetInfo.jetUpper
1064  genJetAlgo = genJetInfo.jetAlgo
1065  genJetSize = genJetInfo.jetSize
1066  genJetSizeNr = genJetInfo.jetSizeNr
1067  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1068  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
1069  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
1070 
1071  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1072 
1073  return proc
1074 
1075 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1076  """
1077  Schedule modules for a given genJet collection and save its variables into custom NanoAOD
1078  """
1079 
1080  genJetTableName = "jet{}Table".format(genJetName)
1081  setattr(proc, genJetTableName, genJetTable.clone(
1082  src = genJetFinalColl,
1083  cut = "", # No cut specified here. Save all gen jets after clustering
1084  name = genJetTablePrefix,
1085  doc = genJetTableDoc,
1086  variables = GENJETVARS
1087  )
1088  )
1089 
1090  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1091  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1092  jets = getattr(proc,genJetTableName).src,
1093  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1094  rParam = genJetSizeNr,
1095  )
1096  )
1097 
1098  genJetFlavourTableName = "genJet{}FlavourTable".format(genJetName)
1099  setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1100  name = getattr(proc,genJetTableName).name,
1101  src = getattr(proc,genJetTableName).src,
1102  cut = getattr(proc,genJetTableName).cut,
1103  jetFlavourInfos = genJetFlavourAssociationName,
1104  )
1105  )
1106 
1107  genJetTaskName = "genJet{}Task".format(genJetName)
1108  setattr(proc, genJetTaskName, cms.Task(
1109  getattr(proc,genJetTableName),
1110  getattr(proc,genJetFlavourAssociationName),
1111  getattr(proc,genJetFlavourTableName)
1112  )
1113  )
1114  proc.jetMCTask.add(getattr(proc,genJetTaskName))
1115 
1116  return proc
1117 
1118 def ReclusterAK4GenJets(proc, genJA):
1119  """
1120  Recluster AK4 Gen jets and replace
1121  slimmedGenJets that is used as default
1122  to save AK4 Gen jets in NanoAODs.
1123  """
1124  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1125 
1126  #
1127  # Recluster AK4 Gen jet
1128  #
1129  cfg = {
1130  "jet" : "ak4gen",
1131  }
1132  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1133 
1134  genJetName = genJetInfo.jetUpper
1135  genJetAlgo = genJetInfo.jetAlgo
1136  genJetSize = genJetInfo.jetSize
1137  genJetSizeNr = genJetInfo.jetSizeNr
1138  selectedGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1139 
1140  #
1141  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
1142  # to be stored in the GenJet Table
1143  #
1144  proc.genJetTable.src = selectedGenJets
1145  proc.genJetTable.cut = "" # No cut specified here. Save all gen jets after clustering
1146  proc.genJetTable.doc = "AK4 Gen jets (made with visible genparticles) with pt > 3 GeV" # default pt cut after clustering is 3 GeV
1147 
1148  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1149  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1150  jets = proc.genJetTable.src,
1151  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1152  rParam = genJetSizeNr,
1153  )
1154  )
1155  proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1156  return proc
1157 
1158 def AddNewAK8GenJetsForJEC(proc, genJA):
1159  """
1160  Make a separate AK8 Gen jet collection for JEC studies.
1161  """
1162  print("custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1163 
1164  #
1165  # Recluster AK8 Gen jet
1166  #
1167  cfg = {
1168  "jet" : "ak8gen",
1169  }
1170  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1171 
1172  genJetName = genJetInfo.jetUpper
1173  genJetAlgo = genJetInfo.jetAlgo
1174  genJetSize = genJetInfo.jetSize
1175  genJetSizeNr = genJetInfo.jetSizeNr
1176  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1177  genJetTablePrefix = "GenJetAK8ForJEC"
1178  genJetTableDoc = "AK8 Gen jets (made with visible genparticles) with pt > 3 GeV. Reclustered for JEC studies."
1179 
1180  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1181 
1182  return proc
1183 
1185  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1186  return proc
1187 
1189  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1190  return proc
1191 
1192 #===========================================================================
1193 #
1194 # Misc. functions
1195 #
1196 #===========================================================================
1198  """
1199  Remove default pt cuts for all jets set in jets_cff.py
1200  """
1201 
1202  proc.finalJets.cut = "" # 15 -> 10
1203  proc.finalJetsPuppi.cut = "" # 15 -> 10
1204  proc.finalJetsAK8.cut = "" # 170 -> 170
1205  proc.genJetTable.cut = "" # 10 -> 8
1206  proc.genJetFlavourTable.cut = "" # 10 -> 8
1207  proc.genJetAK8Table.cut = "" # 100 -> 80
1208  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
1209 
1210  return proc
1211 
1212 #===========================================================================
1213 #
1214 # CUSTOMIZATION function
1215 #
1216 #===========================================================================
1217 def PrepJMECustomNanoAOD(process,runOnMC):
1218 
1219 
1222  process = RemoveAllJetPtCuts(process)
1223 
1224 
1229  genJA = GenJetAdder()
1230  if runOnMC:
1231 
1234  process = AddVariablesForAK8GenJets(process)
1235 
1238  process = AddNewAK8GenJetsForJEC(process, genJA)
1239 
1242  process = ReclusterAK4GenJets(process, genJA)
1243  process = AddVariablesForAK4GenJets(process)
1244 
1247  for jetConfig in config_genjets:
1248  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1249  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1250  AddNewGenJets(process, genJetInfo)
1251 
1252 
1257  recoJA = RecoJetAdder(runOnMC=runOnMC)
1258 
1261  process = AddVariablesForAK8PuppiJets(process)
1262 
1265  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1266 
1269  process = AddNewAK8CHSJets(process, recoJA, runOnMC)
1270 
1273  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1274 
1277  process = ReclusterAK4PuppiJets(process, recoJA, runOnMC)
1278 
1281  for jetConfig in config_recojets:
1282  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1283  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1284  AddNewPatJets(process, recoJetInfo, runOnMC)
1285 
1286 
1291  def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1292  if addAK4CHSJetTasks:
1293  proc.nanoTableTaskCommon.add(proc.jetTask)
1294  proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1295  proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1296  if addAK4PuppiJetTasks:
1297  proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1298  proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1299  proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1300  return proc
1301 
1302  jmeNano_addAK4JetTasks_switch = cms.PSet(
1303  jmeNano_addAK4CHS_switch = cms.untracked.bool(True),
1304  jmeNano_addAK4Puppi_switch = cms.untracked.bool(False)
1305  )
1306  run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1307  jmeNano_addAK4CHS_switch = False,
1308  jmeNano_addAK4Puppi_switch = True
1309  )
1310  process = addAK4JetTasks(process,
1311  addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1312  addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1313  )
1314 
1315 
1318  if runOnMC:
1319  process.puTable.savePtHatMax = True
1320 
1321 
1324  if runOnMC:
1325  process.genWeightsTable.keepAllPSWeights = True
1326 
1327  return process
1328 
1330  process = PrepJMECustomNanoAOD(process,runOnMC=True)
1331 
1332  return process
1333 
1335  process = PrepJMECustomNanoAOD(process,runOnMC=False)
1336  return process
def AddBTaggingScores(proc, jetTableName="")
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
def RemoveAllJetPtCuts(proc)
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def ReclusterAK4GenJets(proc, genJA)
def AddNewAK8CHSJets(proc, recoJA, runOnMC)
def AddNewAK8GenJetsForJEC(proc, genJA)
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
def ReclusterAK4PuppiJets(proc, recoJA, runOnMC)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC)
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="")
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def AddVariablesForAK8GenJets(proc)
def PrepJMECustomNanoAOD_MC(process)
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
def PrepJMECustomNanoAOD_Data(process)