CMS 3D CMS Logo

Functions | Variables
custom_jme_cff Namespace Reference

Functions

def AddBTaggingScores (proc, jetTableName="")
 
def AddDeepJetGluonLQuarkScores (proc, jetTableName="")
 
def AddJetID (proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
 
def AddNewAK8CHSJets (proc, recoJA, runOnMC)
 
def AddNewAK8GenJetsForJEC (proc, genJA)
 
def AddNewAK8PuppiJetsForJEC (proc, recoJA, runOnMC)
 
def AddNewGenJets (proc, genJetInfo)
 
def AddNewPatJets (proc, recoJetInfo, runOnMC)
 
def AddParticleNetAK4Scores (proc, jetTableName="")
 
def AddPileUpJetIDVars (proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
 
def AddQGLTaggerVars (proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
 
def AddRobustParTAK4Scores (proc, jetTableName="")
 
def AddVariablesForAK4GenJets (proc)
 
def AddVariablesForAK8GenJets (proc)
 
def AddVariablesForAK8PuppiJets (proc)
 
def PrepJMECustomNanoAOD (process, runOnMC)
 
def PrepJMECustomNanoAOD_Data (process)
 
def PrepJMECustomNanoAOD_MC (process)
 
def ReclusterAK4CHSJets (proc, recoJA, runOnMC)
 
def ReclusterAK4GenJets (proc, genJA)
 
def ReclusterAK4PuppiJets (proc, recoJA, runOnMC)
 
def RemoveAllJetPtCuts (proc)
 
def SaveGenJets (proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
 
def SavePatJets (proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
 

Variables

 area
 
 bTagCSVV2
 
 btagDDX
 
 btagDDXV2
 
 btagDeepB
 
 bTagDeepCSV
 
 btagDeepCvB
 
 btagDeepCvL
 
 btagDeepFlavB
 
 btagDeepFlavC
 
 btagDeepFlavCvB
 
 btagDeepFlavCvL
 
 btagDeepFlavG
 
 btagDeepFlavQG
 
 btagDeepFlavUDS
 
 bTagDeepJet
 
 bTagDiscriminatorsForAK4
 
 btagHbb
 
 btagRobustParTAK4B
 
 btagRobustParTAK4C
 
 btagRobustParTAK4CvB
 
 btagRobustParTAK4CvL
 
 btagRobustParTAK4G
 
 btagRobustParTAK4QG
 
 btagRobustParTAK4UDS
 
 BTAGVARS
 
 CALOJETVARS
 
 chEmEF
 
 chHadMultiplicity
 
 chHEF
 
 config_genjets
 
 config_recojets
 
 DEEPJETVARS
 
 doc
 
 elMultiplicity
 
 emf
 
 float
 
 foo
 
 GENJETVARS
 
 hfEmEF
 
 hfEMMultiplicity
 
 hfHadMultiplicity
 
 hfHEF
 
 muEF
 
 muMultiplicity
 
 nanoInfo_genjets
 
 nanoInfo_recojets
 
 nConstituents
 
 neEmEF
 
 neHadMultiplicity
 
 neHEF
 
 nElectrons
 
 nMuons
 
 particleNetAK4_B
 
 particleNetAK4_CvsB
 
 particleNetAK4_CvsL
 
 particleNetAK4_G
 
 particleNetAK4_puIdDisc
 
 particleNetAK4_QvsG
 
 PARTICLENETAK4VARS
 
 PFJETVARS
 
 phoMultiplicity
 
 precision
 
 puId_beta
 
 puId_dR2Mean
 
 puId_frac01
 
 puId_frac02
 
 puId_frac03
 
 puId_frac04
 
 puId_jetR
 
 puId_jetRchg
 
 puId_majW
 
 puId_minW
 
 puId_nCharged
 
 puId_ptD
 
 puId_pull
 
 PUIDVARS
 
 qgl_axis2
 
 qgl_mult
 
 qgl_ptD
 
 QGLVARS
 
 rawFactor
 
 ROBUSTPARTAK4VARS
 

Function Documentation

◆ AddBTaggingScores()

def custom_jme_cff.AddBTaggingScores (   proc,
  jetTableName = "" 
)
Store b-tagging scores from various algortihm

Definition at line 394 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by SavePatJets().

394 def AddBTaggingScores(proc, jetTableName=""):
395  """
396  Store b-tagging scores from various algortihm
397  """
398 
399  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
400  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
401  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
402 
403  run2_nanoAOD_ANY.toModify(
404  getattr(proc, jetTableName).variables,
405  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
406  btagDeepB = Var("?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc="DeepCSV b+bb tag discriminator",precision=10),
407  btagDeepCvL = Var("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc="DeepCSV c vs udsg discriminator",precision=10),
408  btagDeepCvB = Var("?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)
409  )
410 
411  return proc
412 
def AddBTaggingScores(proc, jetTableName="")
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16

◆ AddDeepJetGluonLQuarkScores()

def custom_jme_cff.AddDeepJetGluonLQuarkScores (   proc,
  jetTableName = "" 
)
Store DeepJet raw score in jetTable for gluon and light quark

Definition at line 413 of file custom_jme_cff.py.

Referenced by SavePatJets().

413 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
414  """
415  Store DeepJet raw score in jetTable for gluon and light quark
416  """
417 
418  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
419  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
420  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
421 
422  return proc
423 
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")

◆ AddJetID()

def custom_jme_cff.AddJetID (   proc,
  jetName = "",
  jetSrc = "",
  jetTableName = "",
  jetTaskName = "" 
)
Setup modules to calculate PF jet ID

Definition at line 220 of file custom_jme_cff.py.

References PVValHelper.add(), and common_cff.Var().

Referenced by SavePatJets().

220 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
221  """
222  Setup modules to calculate PF jet ID
223  """
224 
225  isPUPPIJet = True if "PUPPI" in jetName.upper() else False
226 
227  looseJetId = "looseJetId{}".format(jetName)
228  setattr(proc, looseJetId, proc.looseJetId.clone(
229  src = jetSrc,
230  filterParams = proc.looseJetId.filterParams.clone(
231  version = "WINTER16"
232  ),
233  )
234  )
235 
236  tightJetId = "tightJetId{}".format(jetName)
237  setattr(proc, tightJetId, proc.tightJetId.clone(
238  src = jetSrc,
239  filterParams = proc.tightJetId.filterParams.clone(
240  version = "RUN3WINTER22{}".format("PUPPI" if isPUPPIJet else "CHS")
241  ),
242  )
243  )
244 
245  tightJetIdLepVeto = "tightJetIdLepVeto{}".format(jetName)
246  setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
247  src = jetSrc,
248  filterParams = proc.tightJetIdLepVeto.filterParams.clone(
249  version = "RUN3WINTER22{}".format("PUPPI" if isPUPPIJet else "CHS")
250  ),
251  )
252  )
253 
254  run3_jme_Winter22runsBCDEprompt.toModify(
255  getattr(proc, tightJetId).filterParams, version = "RUN3WINTER22{}runsBCDEprompt".format("PUPPI" if isPUPPIJet else "CHS")
256  ).toModify(
257  getattr(proc, tightJetIdLepVeto).filterParams, version = "RUN3WINTER22{}runsBCDEprompt".format("PUPPI" if isPUPPIJet else "CHS")
258  )
259 
260  (run2_jme_2017 | run2_jme_2018 | run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
261  getattr(proc, tightJetId).filterParams, version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
262  ).toModify(
263  getattr(proc, tightJetIdLepVeto).filterParams, version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
264  )
265 
266  run2_jme_2016.toModify(
267  getattr(proc, tightJetId).filterParams, version = "RUN2UL16{}".format("PUPPI" if isPUPPIJet else "CHS")
268  ).toModify(
269  getattr(proc, tightJetIdLepVeto).filterParams, version = "RUN2UL16{}".format("PUPPI" if isPUPPIJet else "CHS")
270  )
271 
272  #
273  # Save variables as userInts in each jet
274  #
275  patJetWithUserData = "{}WithUserData".format(jetSrc)
276  getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
277  getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
278 
279  #
280  # Specfiy variables in the jetTable to save in NanoAOD
281  #
282  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")
283 
284  getattr(proc,jetTaskName).add(getattr(proc, tightJetId))
285  getattr(proc,jetTaskName).add(getattr(proc, tightJetIdLepVeto))
286 
287  return proc
288 
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ AddNewAK8CHSJets()

def custom_jme_cff.AddNewAK8CHSJets (   proc,
  recoJA,
  runOnMC 
)
Store an AK8 CHS jet collection for JEC studies.

Definition at line 995 of file custom_jme_cff.py.

References print(), and SavePatJets().

995 def AddNewAK8CHSJets(proc, recoJA, runOnMC):
996  """
997  Store an AK8 CHS jet collection for JEC studies.
998  """
999  print("custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
1000 
1001  #
1002  # Recluster AK8 CHS jets
1003  #
1004  cfg = {
1005  "jet" : "ak8pfchs",
1006  "inputCollection" : "",
1007  "genJetsCollection": "AK8GenJetsNoNu",
1008  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
1009  }
1010  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1011 
1012  jetName = recoJetInfo.jetUpper
1013  payload = recoJetInfo.jetCorrPayload
1014 
1015  patJetFinalColl = recoJetInfo.patJetFinalCollection
1016  jetTablePrefix = "FatJetCHS"
1017  jetTableDoc = "AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
1018  ptcut = 15
1019 
1020  SavePatJets(proc,
1021  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
1022  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
1023  )
1024 
1025  return proc
1026 
def AddNewAK8CHSJets(proc, recoJA, runOnMC)
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ AddNewAK8GenJetsForJEC()

def custom_jme_cff.AddNewAK8GenJetsForJEC (   proc,
  genJA 
)
Make a separate AK8 Gen jet collection for JEC studies.

Definition at line 1162 of file custom_jme_cff.py.

References print(), and SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1162 def AddNewAK8GenJetsForJEC(proc, genJA):
1163  """
1164  Make a separate AK8 Gen jet collection for JEC studies.
1165  """
1166  print("custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1167 
1168  #
1169  # Recluster AK8 Gen jet
1170  #
1171  cfg = {
1172  "jet" : "ak8gen",
1173  "minPtFastjet" : 10.
1174  }
1175  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1176 
1177  genJetName = genJetInfo.jetUpper
1178  genJetAlgo = genJetInfo.jetAlgo
1179  genJetSize = genJetInfo.jetSize
1180  genJetSizeNr = genJetInfo.jetSizeNr
1181  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1182  genJetTablePrefix = "GenJetAK8ForJEC"
1183  genJetTableDoc = "AK8 Gen jets (made with visible genparticles) with pt > 10 GeV. Reclustered for JEC studies."
1184 
1185  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1186 
1187  return proc
1188 
def AddNewAK8GenJetsForJEC(proc, genJA)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)

◆ AddNewAK8PuppiJetsForJEC()

def custom_jme_cff.AddNewAK8PuppiJetsForJEC (   proc,
  recoJA,
  runOnMC 
)
Store a separate AK8 Puppi jet collection for JEC studies.
Only minimal info are stored

Definition at line 962 of file custom_jme_cff.py.

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

962 def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC):
963  """
964  Store a separate AK8 Puppi jet collection for JEC studies.
965  Only minimal info are stored
966  """
967  print("custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
968 
969  #
970  # Recluster AK8 Puppi jets
971  #
972  cfg = {
973  "jet" : "ak8pfpuppi",
974  "inputCollection" : "",
975  "genJetsCollection": "AK8GenJetsNoNu",
976  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
977  }
978  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
979 
980  jetName = recoJetInfo.jetUpper
981  payload = recoJetInfo.jetCorrPayload
982 
983  patJetFinalColl = recoJetInfo.patJetFinalCollection
984  jetTablePrefix = "FatJetForJEC"
985  jetTableDoc = "AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
986  ptcut = 15
987 
988  SavePatJets(proc,
989  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
990  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
991  )
992 
993  return proc
994 
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC)

◆ AddNewGenJets()

def custom_jme_cff.AddNewGenJets (   proc,
  genJetInfo 
)
Add genJet into custom nanoAOD

Definition at line 1061 of file custom_jme_cff.py.

References SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1061 def AddNewGenJets(proc, genJetInfo):
1062  """
1063  Add genJet into custom nanoAOD
1064  """
1065 
1066  genJetName = genJetInfo.jetUpper
1067  genJetAlgo = genJetInfo.jetAlgo
1068  genJetSize = genJetInfo.jetSize
1069  genJetSizeNr = genJetInfo.jetSizeNr
1070  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1071  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
1072  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
1073 
1074  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1075 
1076  return proc
1077 
def AddNewGenJets(proc, genJetInfo)
def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)

◆ AddNewPatJets()

def custom_jme_cff.AddNewPatJets (   proc,
  recoJetInfo,
  runOnMC 
)
Add patJet into custom nanoAOD

Definition at line 449 of file custom_jme_cff.py.

References SavePatJets().

Referenced by PrepJMECustomNanoAOD().

449 def AddNewPatJets(proc, recoJetInfo, runOnMC):
450  """
451  Add patJet into custom nanoAOD
452  """
453 
454  jetName = recoJetInfo.jetUpper
455  payload = recoJetInfo.jetCorrPayload
456  doPF = recoJetInfo.doPF
457  doCalo = recoJetInfo.doCalo
458  patJetFinalColl = recoJetInfo.patJetFinalCollection
459 
460  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
461  jetTablePrefix = nanoInfoForJet["name"]
462  jetTableDoc = nanoInfoForJet["doc"]
463  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else 8
464  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
465  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
466  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
467 
468  SavePatJets(proc,
469  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
470  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
471  )
472 
473  return proc
474 
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)

◆ AddParticleNetAK4Scores()

def custom_jme_cff.AddParticleNetAK4Scores (   proc,
  jetTableName = "" 
)
Store ParticleNetAK4 scores in jetTable

Definition at line 435 of file custom_jme_cff.py.

Referenced by SavePatJets().

435 def AddParticleNetAK4Scores(proc, jetTableName=""):
436  """
437  Store ParticleNetAK4 scores in jetTable
438  """
439 
440  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
441  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
442  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
443  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
444  getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
445  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
446 
447  return proc
448 
def AddParticleNetAK4Scores(proc, jetTableName="")

◆ AddPileUpJetIDVars()

def custom_jme_cff.AddPileUpJetIDVars (   proc,
  jetName = "",
  jetSrc = "",
  jetTableName = "",
  jetTaskName = "" 
)
Setup modules to calculate pileup jet ID input variables for PF jet

Definition at line 289 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

289 def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
290  """
291  Setup modules to calculate pileup jet ID input variables for PF jet
292  """
293 
294  #
295  # Calculate pileup jet ID variables
296  #
297  puJetIdVarsCalculator = "puJetIdCalculator{}".format(jetName)
298  setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
299  jets = jetSrc,
300  vertexes = "offlineSlimmedPrimaryVertices",
301  inputIsCorrected = True,
302  applyJec = False,
303  srcConstituentWeights = "packedpuppi" if "PUPPI" in jetName.upper() else ""
304  )
305  )
306  getattr(proc,jetTaskName).add(getattr(proc, puJetIdVarsCalculator))
307 
308  #
309  # Get the variables
310  #
311  puJetIDVar = "puJetIDVar{}".format(jetName)
312  setattr(proc, puJetIDVar, cms.EDProducer("PileupJetIDVarProducer",
313  srcJet = cms.InputTag(jetSrc),
314  srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
315  )
316  )
317  getattr(proc,jetTaskName).add(getattr(proc, puJetIDVar))
318 
319  #
320  # Save variables as userFloats and userInts for each jet
321  #
322  patJetWithUserData = "{}WithUserData".format(jetSrc)
323  getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag("{}:dR2Mean".format(puJetIDVar))
324  getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag("{}:majW".format(puJetIDVar))
325  getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag("{}:minW".format(puJetIDVar))
326  getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag("{}:frac01".format(puJetIDVar))
327  getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag("{}:frac02".format(puJetIDVar))
328  getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag("{}:frac03".format(puJetIDVar))
329  getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag("{}:frac04".format(puJetIDVar))
330  getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag("{}:ptD".format(puJetIDVar))
331  getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag("{}:beta".format(puJetIDVar))
332  getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag("{}:pull".format(puJetIDVar))
333  getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag("{}:jetR".format(puJetIDVar))
334  getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag("{}:jetRchg".format(puJetIDVar))
335  getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag("{}:nCharged".format(puJetIDVar))
336 
337  #
338  # Specfiy variables in the jet table to save in NanoAOD
339  #
340  getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
341  getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
342  getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
343  getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
344  getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
345  getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
346  getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
347  getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
348  getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
349  getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
350  getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
351  getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
352  getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
353 
354  return proc
355 
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")

◆ AddQGLTaggerVars()

def custom_jme_cff.AddQGLTaggerVars (   proc,
  jetName = "",
  jetSrc = "",
  jetTableName = "",
  jetTaskName = "",
  calculateQGLVars = False 
)
Schedule the QGTagger module to calculate input variables to the QG likelihood

Definition at line 356 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

356 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
357  """
358  Schedule the QGTagger module to calculate input variables to the QG likelihood
359  """
360 
361  isPUPPIJet = True if "PUPPI" in jetName.upper() else False
362 
363  QGLTagger="qgtagger{}".format(jetName)
364  patJetWithUserData="{}WithUserData".format(jetSrc)
365 
366  if calculateQGLVars:
367  setattr(proc, QGLTagger, qgtagger.clone(
368  srcJets = jetSrc,
369  computeLikelihood = False,
370  )
371  )
372  if isPUPPIJet:
373  getattr(proc,QGLTagger).srcConstituentWeights = cms.InputTag("packedpuppi")
374 
375  #
376  # Save variables as userFloats and userInts for each jet
377  #
378  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
379  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
380  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
381 
382  #
383  # Specfiy variables in the jet table to save in NanoAOD
384  #
385  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
386  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
387  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
388 
389  if calculateQGLVars:
390  getattr(proc,jetTaskName).add(getattr(proc, QGLTagger))
391 
392  return proc
393 
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ AddRobustParTAK4Scores()

def custom_jme_cff.AddRobustParTAK4Scores (   proc,
  jetTableName = "" 
)
Store RobustParTAK4 scores in jetTable

Definition at line 424 of file custom_jme_cff.py.

Referenced by SavePatJets().

424 def AddRobustParTAK4Scores(proc, jetTableName=""):
425  """
426  Store RobustParTAK4 scores in jetTable
427  """
428 
429  getattr(proc, jetTableName).variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
430  getattr(proc, jetTableName).variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
431  getattr(proc, jetTableName).variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
432 
433  return proc
434 
def AddRobustParTAK4Scores(proc, jetTableName="")

◆ AddVariablesForAK4GenJets()

def custom_jme_cff.AddVariablesForAK4GenJets (   proc)

Definition at line 1189 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1189 def AddVariablesForAK4GenJets(proc):
1190  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1191  return proc
1192 
def AddVariablesForAK4GenJets(proc)

◆ AddVariablesForAK8GenJets()

def custom_jme_cff.AddVariablesForAK8GenJets (   proc)

Definition at line 1193 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1193 def AddVariablesForAK8GenJets(proc):
1194  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1195  return proc
1196 
1197 #===========================================================================
1198 #
1199 # Misc. functions
1200 #
1201 #===========================================================================
def AddVariablesForAK8GenJets(proc)

◆ AddVariablesForAK8PuppiJets()

def custom_jme_cff.AddVariablesForAK8PuppiJets (   proc)
Add more variables for AK8 PFPUPPI jets

Definition at line 1027 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

1027 def AddVariablesForAK8PuppiJets(proc):
1028  """
1029  Add more variables for AK8 PFPUPPI jets
1030  """
1031 
1032  proc.fatJetTable.variables.rawFactor.precision = 10
1033 
1034  #
1035  # These variables are not stored for AK8PFPUPPI (slimmedJetsAK8)
1036  # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
1037  #
1038  proc.fatJetTable.variables.chHEF = Var("?isPFJet()?chargedHadronEnergyFraction():-1", float, doc="charged Hadron Energy Fraction", precision = 6)
1039  proc.fatJetTable.variables.neHEF = Var("?isPFJet()?neutralHadronEnergyFraction():-1", float, doc="neutral Hadron Energy Fraction", precision = 6)
1040  proc.fatJetTable.variables.chEmEF = Var("?isPFJet()?chargedEmEnergyFraction():-1", float, doc="charged Electromagnetic Energy Fraction", precision = 6)
1041  proc.fatJetTable.variables.neEmEF = Var("?isPFJet()?neutralEmEnergyFraction():-1", float, doc="neutral Electromagnetic Energy Fraction", precision = 6)
1042  proc.fatJetTable.variables.muEF = Var("?isPFJet()?muonEnergyFraction():-1", float, doc="muon Energy Fraction", precision = 6)
1043  proc.fatJetTable.variables.hfHEF = Var("?isPFJet()?HFHadronEnergyFraction():-1", float, doc="energy fraction in forward hadronic calorimeter", precision = 6)
1044  proc.fatJetTable.variables.hfEmEF = Var("?isPFJet()?HFEMEnergyFraction():-1", float, doc="energy fraction in forward EM calorimeter", precision = 6)
1045  proc.fatJetTable.variables.chHadMultiplicity = Var("?isPFJet()?chargedHadronMultiplicity():-1","int16", doc="(Puppi-weighted) number of charged hadrons in the jet")
1046  proc.fatJetTable.variables.neHadMultiplicity = Var("?isPFJet()?neutralHadronMultiplicity():-1","int16", doc="(Puppi-weighted) number of neutral hadrons in the jet")
1047  proc.fatJetTable.variables.hfHadMultiplicity = Var("?isPFJet()?HFHadronMultiplicity():-1", "int16", doc="(Puppi-weighted) number of HF Hadrons in the jet")
1048  proc.fatJetTable.variables.hfEMMultiplicity = Var("?isPFJet()?HFEMMultiplicity():-1", "int16", doc="(Puppi-weighted) number of HF EMs in the jet")
1049  proc.fatJetTable.variables.muMultiplicity = Var("?isPFJet()?muonMultiplicity():-1", "int16", doc="(Puppi-weighted) number of muons in the jet")
1050  proc.fatJetTable.variables.elMultiplicity = Var("?isPFJet()?electronMultiplicity():-1", "int16", doc="(Puppi-weighted) number of electrons in the jet")
1051  proc.fatJetTable.variables.phoMultiplicity = Var("?isPFJet()?photonMultiplicity():-1", "int16", doc="(Puppi-weighted) number of photons in the jet")
1052 
1053  return proc
1054 #******************************************
1055 #
1056 #
1057 # Gen Jets related functions
1058 #
1059 #
1060 #******************************************
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
def AddVariablesForAK8PuppiJets(proc)

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process,
  runOnMC 
)

Definition at line 1222 of file custom_jme_cff.py.

References AddNewAK8GenJetsForJEC(), AddNewAK8PuppiJetsForJEC(), AddNewGenJets(), AddNewPatJets(), AddVariablesForAK4GenJets(), AddVariablesForAK8GenJets(), AddVariablesForAK8PuppiJets(), ReclusterAK4CHSJets(), ReclusterAK4GenJets(), ReclusterAK4PuppiJets(), and RemoveAllJetPtCuts().

Referenced by PrepJMECustomNanoAOD_Data(), and PrepJMECustomNanoAOD_MC().

1222 def PrepJMECustomNanoAOD(process,runOnMC):
1223 
1224 
1227  process = RemoveAllJetPtCuts(process)
1228 
1229 
1234  genJA = GenJetAdder()
1235  if runOnMC:
1236 
1239  process = AddVariablesForAK8GenJets(process)
1240 
1243  process = AddNewAK8GenJetsForJEC(process, genJA)
1244 
1247  process = ReclusterAK4GenJets(process, genJA)
1248  process = AddVariablesForAK4GenJets(process)
1249 
1252  for jetConfig in config_genjets:
1253  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1254  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1255  AddNewGenJets(process, genJetInfo)
1256 
1257 
1262  recoJA = RecoJetAdder(runOnMC=runOnMC)
1263 
1266  process = AddVariablesForAK8PuppiJets(process)
1267 
1270  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1271 
1274  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1275 
1278  process = ReclusterAK4PuppiJets(process, recoJA, runOnMC)
1279 
1282  for jetConfig in config_recojets:
1283  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1284  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1285  AddNewPatJets(process, recoJetInfo, runOnMC)
1286 
1287 
1292  def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1293  if addAK4CHSJetTasks:
1294  proc.nanoTableTaskCommon.add(proc.jetTask)
1295  proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1296  proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1297  if addAK4PuppiJetTasks:
1298  proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1299  proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1300  proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1301  return proc
1302 
1303  jmeNano_addAK4JetTasks_switch = cms.PSet(
1304  jmeNano_addAK4CHS_switch = cms.untracked.bool(True),
1305  jmeNano_addAK4Puppi_switch = cms.untracked.bool(False)
1306  )
1307  run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1308  jmeNano_addAK4CHS_switch = False,
1309  jmeNano_addAK4Puppi_switch = True
1310  )
1311  process = addAK4JetTasks(process,
1312  addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1313  addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1314  )
1315 
1316 
1319  if runOnMC:
1320  process.puTable.savePtHatMax = True
1321 
1322 
1325  if runOnMC:
1326  process.genWeightsTable.keepAllPSWeights = True
1327 
1328  return process
1329 
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def RemoveAllJetPtCuts(proc)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def ReclusterAK4GenJets(proc, genJA)
def AddNewAK8GenJetsForJEC(proc, genJA)
def ReclusterAK4PuppiJets(proc, recoJA, runOnMC)
def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC)
def AddNewGenJets(proc, genJetInfo)
def AddVariablesForAK4GenJets(proc)
def AddVariablesForAK8PuppiJets(proc)
def AddVariablesForAK8GenJets(proc)

◆ PrepJMECustomNanoAOD_Data()

def custom_jme_cff.PrepJMECustomNanoAOD_Data (   process)

Definition at line 1335 of file custom_jme_cff.py.

References PrepJMECustomNanoAOD().

1335 def PrepJMECustomNanoAOD_Data(process):
1336  process = PrepJMECustomNanoAOD(process,runOnMC=False)
1337  return process
1338 
def PrepJMECustomNanoAOD(process, runOnMC)
def PrepJMECustomNanoAOD_Data(process)

◆ PrepJMECustomNanoAOD_MC()

def custom_jme_cff.PrepJMECustomNanoAOD_MC (   process)

Definition at line 1330 of file custom_jme_cff.py.

References PrepJMECustomNanoAOD().

1330 def PrepJMECustomNanoAOD_MC(process):
1331  process = PrepJMECustomNanoAOD(process,runOnMC=True)
1332 
1333  return process
1334 
def PrepJMECustomNanoAOD(process, runOnMC)
def PrepJMECustomNanoAOD_MC(process)

◆ ReclusterAK4CHSJets()

def custom_jme_cff.ReclusterAK4CHSJets (   proc,
  recoJA,
  runOnMC 
)
Recluster AK4 CHS jets and replace slimmedJets that is used as default to
save AK4 CHS jets in NanoAODs (for Run-2).

Definition at line 775 of file custom_jme_cff.py.

References print(), and common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

775 def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
776  """
777  Recluster AK4 CHS jets and replace slimmedJets that is used as default to
778  save AK4 CHS jets in NanoAODs (for Run-2).
779  """
780  print("custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
781 
782  from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
783  from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
784 
785  bTagDiscriminatorsForAK4CHS = cms.PSet(
786  foo = cms.vstring(_pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll+_pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll)
787  )
788  bTagDiscriminatorsForAK4CHS = bTagDiscriminatorsForAK4CHS.foo.value()
789 
790  #
791  # Recluster AK4 CHS jets
792  #
793  cfg = {
794  "jet" : "ak4pfchs",
795  "inputCollection" : "",
796  "genJetsCollection": "AK4GenJetsNoNu",
797  "bTagDiscriminators": bTagDiscriminatorsForAK4CHS,
798  "minPtFastjet" : 0.,
799  }
800  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
801 
802  jetName = recoJetInfo.jetUpper
803  patJetFinalColl = recoJetInfo.patJetFinalCollection
804 
805  #
806  # Change the input jet source for jetCorrFactorsNano
807  # and updatedJets
808  #
809  proc.jetCorrFactorsNano.src=patJetFinalColl
810  proc.updatedJets.jetSource=patJetFinalColl
811 
812  #
813  # Change pt cut
814  #
815  finalJetsCut = ""
816  if runOnMC:
817  finalJetsCut = "(pt >= 10) || ((pt < 10) && (genJetFwdRef().backRef().isNonnull()))"
818  else:
819  finalJetsCut = "(pt >= 10)"
820 
821  proc.finalJets.cut = finalJetsCut
822  #
823  # Add a minimum pt cut for corrT1METJets.
824  #
825  proc.corrT1METJetTable.cut = "pt>=10 && pt<15 && abs(eta)<9.9"
826 
827  #
828  # Jet table cut
829  #
830  jetTableCut = "" # must not have any cut at the jetTable for AK4 CHS as it has been cross-cleaned
831  proc.jetTable.src = cms.InputTag("finalJets")
832  proc.jetTable.cut = jetTableCut
833  proc.jetMCTable.cut = jetTableCut
834  proc.jetTable.name = "JetCHS"
835 
836  #
837  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
838  #
839  run2_nanoAOD_ANY.toModify(
840  proc.jetTable,
841  src = cms.InputTag("linkedObjects","jets"),
842  name = "Jet"
843  )
844 
845  #
846  # Jet table documentation
847  #
848  jetTableDoc = "AK4 PF CHS jets with JECs applied. Jets with pt >= 10 GeV are stored."
849  if runOnMC:
850  jetTableDoc += "For jets with pt < 10 GeV, only those matched to AK4 Gen jets are stored."
851  proc.jetTable.doc = jetTableDoc
852 
853  proc.jetTable.variables.rawFactor.precision = 10
854 
855  #
856  # Add variables
857  #
858  proc.jetTable.variables.chHadMultiplicity = PFJETVARS.chHadMultiplicity
859  proc.jetTable.variables.neHadMultiplicity = PFJETVARS.neHadMultiplicity
860  proc.jetTable.variables.hfHadMultiplicity = PFJETVARS.hfHadMultiplicity
861  proc.jetTable.variables.hfEMMultiplicity = PFJETVARS.hfEMMultiplicity
862  proc.jetTable.variables.muMultiplicity = PFJETVARS.muMultiplicity
863  proc.jetTable.variables.elMultiplicity = PFJETVARS.elMultiplicity
864  proc.jetTable.variables.phoMultiplicity = PFJETVARS.phoMultiplicity
865 
866  #
867  # Add charged energy fraction from other primary vertices
868  #
869  proc.updatedJetsWithUserData.userFloats.chFPV1EF = cms.InputTag("jercVars:chargedFromPV1EnergyFraction")
870  proc.updatedJetsWithUserData.userFloats.chFPV2EF = cms.InputTag("jercVars:chargedFromPV2EnergyFraction")
871  proc.updatedJetsWithUserData.userFloats.chFPV3EF = cms.InputTag("jercVars:chargedFromPV3EnergyFraction")
872  proc.jetTable.variables.chFPV1EF = Var("userFloat('chFPV1EF')", float, doc="charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
873  proc.jetTable.variables.chFPV2EF = Var("userFloat('chFPV2EF')", float, doc="charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
874  proc.jetTable.variables.chFPV3EF = Var("userFloat('chFPV3EF')", float, doc="charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
875 
876  #
877  # Remove these tagger branches since for CHS, we just want to store
878  # one tagger only.
879  #
880  for varNames in proc.jetTable.variables.parameterNames_():
881  if "btagDeepFlav" in varNames or "btagRobustParT" in varNames:
882  delattr(proc.jetTable.variables, varNames)
883 
884  proc.jetTable.variables.btagPNetB = Var("?pt>15 && bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc="ParticleNet b vs. udscg")
885  proc.jetTable.variables.btagPNetCvL = Var("?pt>15 && bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc="ParticleNet c vs. udsg")
886  proc.jetTable.variables.btagPNetCvB = Var("?pt>15 && bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc="ParticleNet c vs. b")
887  proc.jetTable.variables.btagPNetQvG = Var("?pt>15 && abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:QvsG'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags:QvsG')",float,precision=10,doc="ParticleNet q (udsbc) vs. g")
888  proc.jetTable.variables.btagPNetTauVJet = Var("?pt>15 && bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc="ParticleNet tau vs. jet")
889  proc.jetTable.variables.PNetRegPtRawCorr = Var("?pt>15 && abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptcorr'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptcorr')",float,precision=10,doc="ParticleNet universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT")
890  proc.jetTable.variables.PNetRegPtRawCorrNeutrino = Var("?pt>15 && abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptnu'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptnu')",float,precision=10,doc="ParticleNet universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both PNetRegPtRawCorr and PNetRegPtRawCorrNeutrino.")
891  proc.jetTable.variables.PNetRegPtRawRes = Var("?pt>15 && abs(eta())<2.5?0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptreslow')):0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptreslow'))",float,precision=10,doc="ParticleNet universal flavor-aware jet pT resolution estimator, (q84 - q16)/2")
892 
893 
894  #Adding hf shower shape producer to the jet sequence. By default this producer is not automatically rerun at the NANOAOD step
895  #The following lines make sure it is.
896  hfJetShowerShapeforCustomNanoAOD = "hfJetShowerShapeforCustomNanoAOD"
897  setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShape.clone(jets="updatedJets", vertices="offlineSlimmedPrimaryVertices") )
898  proc.jetUserDataTask.add(getattr(proc, hfJetShowerShapeforCustomNanoAOD))
899  proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
900  proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
901  proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
902  proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
903  proc.jetTable.variables.hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
904  proc.jetTable.variables.hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
905  proc.jetTable.variables.hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) ")
906  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) ")
907 
908  #
909  # Since AK4 Puppi jet is the main AK4 jet collection for Run-3, disable
910  # b-jets/c-jets NN-based mass regression for AK4 CHS.
911  #
912  (~run2_nanoAOD_ANY).toReplaceWith(
913  proc.jetUserDataTask,
914  proc.jetUserDataTask.copyAndExclude([proc.bJetVars])
915  ).toReplaceWith(
916  proc.jetTablesTask,
917  proc.jetTablesTask.copyAndExclude([proc.bjetNN, proc.cjetNN])
918  ).toModify(proc.updatedJetsWithUserData.userFloats,
919  leadTrackPt = None,
920  leptonPtRelv0 = None,
921  leptonPtRelInvv0 = None,
922  leptonDeltaR = None,
923  vtxPt = None,
924  vtxMass = None,
925  vtx3dL = None,
926  vtx3deL = None,
927  ptD = None,
928  ).toModify(
929  proc.updatedJetsWithUserData.userInts,
930  vtxNtrk = None,
931  leptonPdgId = None
932  ).toModify(
933  proc.jetTable, externalVariables = cms.PSet()
934  ).toReplaceWith(
935  #
936  # For Run-3, don't need to save the low pt AK4 CHS jet table for MET
937  #
938  proc.jetForMETTask,
939  proc.jetForMETTask.copyAndExclude([proc.corrT1METJetTable])
940  )
941 
942  #
943  # Save MC-only jet variables in jet table
944  #
945  if runOnMC:
946  jetMCTableName = "jet{}MCTable".format(jetName)
947  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
948  src = proc.jetTable.src,
949  name = proc.jetTable.name
950  )
951  )
952  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
953  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
954 
955  (~run2_nanoAOD_ANY).toReplaceWith(
956  proc.nanoTableTaskFS,
957  proc.nanoTableTaskFS.copyAndAdd(getattr(proc,jetMCTableTaskName))
958  )
959 
960  return proc
961 
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ ReclusterAK4GenJets()

def custom_jme_cff.ReclusterAK4GenJets (   proc,
  genJA 
)
Recluster AK4 Gen jets and replace
slimmedGenJets that is used as default
to save AK4 Gen jets in NanoAODs.

Definition at line 1121 of file custom_jme_cff.py.

References print().

Referenced by PrepJMECustomNanoAOD().

1121 def ReclusterAK4GenJets(proc, genJA):
1122  """
1123  Recluster AK4 Gen jets and replace
1124  slimmedGenJets that is used as default
1125  to save AK4 Gen jets in NanoAODs.
1126  """
1127  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1128 
1129  #
1130  # Recluster AK4 Gen jet
1131  #
1132  cfg = {
1133  "jet" : "ak4gen",
1134  "minPtFastjet" : 5.
1135  }
1136  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1137 
1138  genJetName = genJetInfo.jetUpper
1139  genJetAlgo = genJetInfo.jetAlgo
1140  genJetSize = genJetInfo.jetSize
1141  genJetSizeNr = genJetInfo.jetSizeNr
1142  selectedGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1143 
1144  #
1145  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
1146  # to be stored in the GenJet Table
1147  #
1148  proc.genJetTable.src = selectedGenJets
1149  proc.genJetTable.cut = "" # No cut specified here. Save all gen jets after clustering
1150  proc.genJetTable.doc = "AK4 Gen jets (made with visible genparticles) with pt > 5 GeV"
1151 
1152  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1153  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1154  jets = proc.genJetTable.src,
1155  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1156  rParam = genJetSizeNr,
1157  )
1158  )
1159  proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1160  return proc
1161 
def ReclusterAK4GenJets(proc, genJA)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ ReclusterAK4PuppiJets()

def custom_jme_cff.ReclusterAK4PuppiJets (   proc,
  recoJA,
  runOnMC 
)
Recluster AK4 Puppi jets and replace slimmedJetsPuppi
that is used as default to save AK4 Puppi jets in NanoAODs.

Definition at line 619 of file custom_jme_cff.py.

References AddPileUpJetIDVars(), AddQGLTaggerVars(), and print().

Referenced by PrepJMECustomNanoAOD().

619 def ReclusterAK4PuppiJets(proc, recoJA, runOnMC):
620  """
621  Recluster AK4 Puppi jets and replace slimmedJetsPuppi
622  that is used as default to save AK4 Puppi jets in NanoAODs.
623  """
624  print("custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
625 
626  #
627  # Recluster AK4 Puppi jets
628  #
629  cfg = {
630  "jet" : "ak4pfpuppi",
631  "inputCollection" : "",
632  "genJetsCollection": "AK4GenJetsNoNu",
633  "bTagDiscriminators": bTagDiscriminatorsForAK4,
634  "minPtFastjet" : 0.,
635  }
636  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
637 
638  jetName = recoJetInfo.jetUpper
639  patJetFinalColl = recoJetInfo.patJetFinalCollection
640 
641  #
642  # Set the jetID for UL 16 era
643  #
644  run2_jme_2016.toModify(
645  proc.tightJetPuppiId.filterParams, version = "RUN2UL16PUPPI"
646  ).toModify(
647  proc.tightJetIdLepVeto.filterParams, version = "RUN2UL16PUPPI"
648  )
649 
650  #
651  # Change the input jet source for jetCorrFactorsNano
652  # and updatedJets
653  #
654  proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
655  proc.updatedJetsPuppi.jetSource=patJetFinalColl
656 
657  #
658  # Change pt cut
659  #
660  finalJetsPuppiCut = ""
661  if runOnMC:
662  finalJetsPuppiCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
663  else:
664  finalJetsPuppiCut = "(pt >= 8)"
665 
666  proc.finalJetsPuppi.cut = finalJetsPuppiCut
667  #
668  # Add a minimum pt cut for corrT1METJets.
669  #
670  proc.corrT1METJetPuppiTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
671 
672  #
673  # Jet table
674  #
675  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
676  run2_nanoAOD_ANY.toModify(
677  proc.jetTable, name = "Jet"
678  ).toModify(
679  # So need to change the table name for AK4 puppi here
680  proc.jetPuppiTable,
681  name = "JetPuppi",
682  src = cms.InputTag("finalJetsPuppi")
683  )
684 
685  #
686  # Jet table documentation
687  #
688  jetPuppiTableDoc = "AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored."
689  if runOnMC:
690  jetPuppiTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
691  proc.jetPuppiTable.doc = jetPuppiTableDoc
692 
693  proc.jetPuppiTable.variables.rawFactor.precision = 10
694 
695  #
696  # Add variables
697  #
698  proc.jetPuppiTable.variables.chHadMultiplicity = PFJETVARS.chHadMultiplicity
699  proc.jetPuppiTable.variables.neHadMultiplicity = PFJETVARS.neHadMultiplicity
700  proc.jetPuppiTable.variables.hfHadMultiplicity = PFJETVARS.hfHadMultiplicity
701  proc.jetPuppiTable.variables.hfEMMultiplicity = PFJETVARS.hfEMMultiplicity
702  proc.jetPuppiTable.variables.muMultiplicity = PFJETVARS.muMultiplicity
703  proc.jetPuppiTable.variables.elMultiplicity = PFJETVARS.elMultiplicity
704  proc.jetPuppiTable.variables.phoMultiplicity = PFJETVARS.phoMultiplicity
705 
706  #
707  # Add variables for pileup jet ID studies.
708  #
709 
710  proc = AddPileUpJetIDVars(proc,
711  jetName = jetName,
712  jetSrc = "updatedJetsPuppi",
713  jetTableName = "jetPuppiTable",
714  jetTaskName = "jetPuppiTask"
715  )
716  #
717  # Add variables for quark guon likelihood tagger studies.
718  # Save variables as userFloats and userInts in each jet
719  #
720  proc = AddQGLTaggerVars(proc,
721  jetName = jetName,
722  jetSrc = "updatedJetsPuppi",
723  jetTableName = "jetPuppiTable",
724  jetTaskName = "jetPuppiTask",
725  calculateQGLVars=True
726  )
727  #
728  # Save DeepJet b-tagging and c-tagging variables
729  #
730  proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
731  proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
732  proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
733  #
734  # Save DeepJet raw score for gluon and light quarks
735  #
736  proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
737  proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
738  proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
739  #
740  # Save RobustParTAK4 b-tagging and c-tagging variables
741  #
742  proc.jetPuppiTable.variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
743  proc.jetPuppiTable.variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
744  proc.jetPuppiTable.variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
745 
746  #
747  # For Run-2 eras, don't need to save the low pt AK4 Puppi jet table for MET
748  #
749  run2_nanoAOD_ANY.toReplaceWith(
750  proc.jetPuppiForMETTask,
751  proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
752  )
753 
754  #
755  # Save MC-only jet variables in jet table
756  #
757  if runOnMC:
758 
759  jetMCTableName = "jet{}MCTable".format(jetName)
760  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
761  src = proc.jetPuppiTable.src,
762  name = proc.jetPuppiTable.name
763  )
764  )
765  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
766  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
767 
768  run2_nanoAOD_ANY.toReplaceWith(
769  proc.nanoTableTaskFS,
770  proc.nanoTableTaskFS.copyAndAdd( getattr(proc,jetMCTableTaskName))
771  )
772 
773  return proc
774 
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
def ReclusterAK4PuppiJets(proc, recoJA, runOnMC)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")

◆ RemoveAllJetPtCuts()

def custom_jme_cff.RemoveAllJetPtCuts (   proc)
Remove default pt cuts for all jets set in jets_cff.py

Definition at line 1202 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1202 def RemoveAllJetPtCuts(proc):
1203  """
1204  Remove default pt cuts for all jets set in jets_cff.py
1205  """
1206 
1207  proc.finalJets.cut = "" # 15 -> 10
1208  proc.finalJetsPuppi.cut = "" # 15 -> 10
1209  proc.finalJetsAK8.cut = "" # 170 -> 170
1210  proc.genJetTable.cut = "" # 10 -> 8
1211  proc.genJetFlavourTable.cut = "" # 10 -> 8
1212  proc.genJetAK8Table.cut = "" # 100 -> 80
1213  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
1214 
1215  return proc
1216 
1217 #===========================================================================
1218 #
1219 # CUSTOMIZATION function
1220 #
1221 #===========================================================================
def RemoveAllJetPtCuts(proc)

◆ SaveGenJets()

def custom_jme_cff.SaveGenJets (   proc,
  genJetName,
  genJetAlgo,
  genJetSizeNr,
  genJetFinalColl,
  genJetTablePrefix,
  genJetTableDoc,
  runOnMC = False 
)
Schedule modules for a given genJet collection and save its variables into custom NanoAOD

Definition at line 1078 of file custom_jme_cff.py.

Referenced by AddNewAK8GenJetsForJEC(), and AddNewGenJets().

1078 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1079  """
1080  Schedule modules for a given genJet collection and save its variables into custom NanoAOD
1081  """
1082 
1083  genJetTableName = "jet{}Table".format(genJetName)
1084  setattr(proc, genJetTableName, genJetTable.clone(
1085  src = genJetFinalColl,
1086  cut = "", # No cut specified here. Save all gen jets after clustering
1087  name = genJetTablePrefix,
1088  doc = genJetTableDoc,
1089  variables = GENJETVARS
1090  )
1091  )
1092 
1093  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1094  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1095  jets = getattr(proc,genJetTableName).src,
1096  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1097  rParam = genJetSizeNr,
1098  )
1099  )
1100 
1101  genJetFlavourTableName = "genJet{}FlavourTable".format(genJetName)
1102  setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1103  name = getattr(proc,genJetTableName).name,
1104  src = getattr(proc,genJetTableName).src,
1105  cut = getattr(proc,genJetTableName).cut,
1106  jetFlavourInfos = genJetFlavourAssociationName,
1107  )
1108  )
1109 
1110  genJetTaskName = "genJet{}Task".format(genJetName)
1111  setattr(proc, genJetTaskName, cms.Task(
1112  getattr(proc,genJetTableName),
1113  getattr(proc,genJetFlavourAssociationName),
1114  getattr(proc,genJetFlavourTableName)
1115  )
1116  )
1117  proc.jetMCTask.add(getattr(proc,genJetTaskName))
1118 
1119  return proc
1120 
def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)

◆ SavePatJets()

def custom_jme_cff.SavePatJets (   proc,
  jetName,
  payload,
  patJetFinalColl,
  jetTablePrefix,
  jetTableDoc,
  doPF,
  doCalo,
  ptcut,
  doPUIDVar = False,
  doQGL = False,
  doBTag = False,
  runOnMC = False 
)
Schedule modules for a given patJet collection and save its variables into custom NanoAOD

Definition at line 476 of file custom_jme_cff.py.

References AddBTaggingScores(), AddDeepJetGluonLQuarkScores(), AddJetID(), AddParticleNetAK4Scores(), AddPileUpJetIDVars(), AddQGLTaggerVars(), AddRobustParTAK4Scores(), and common_cff.Var().

Referenced by AddNewAK8CHSJets(), AddNewAK8PuppiJetsForJEC(), and AddNewPatJets().

476  doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
477  """
478  Schedule modules for a given patJet collection and save its variables into custom NanoAOD
479  """
480 
481  #
482  # Setup jet correction factors
483  #
484  jetCorrFactors = "jetCorrFactorsNano{}".format(jetName)
485  setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
486  src = patJetFinalColl,
487  payload = payload,
488  )
489  )
490 
491  #
492  # Update jets
493  #
494  srcJets = "updatedJets{}".format(jetName)
495  setattr(proc, srcJets, updatedJets.clone(
496  jetSource = patJetFinalColl,
497  jetCorrFactorsSource = [jetCorrFactors],
498  )
499  )
500 
501  #
502  # Setup UserDataEmbedder
503  #
504  srcJetsWithUserData = "updatedJets{}WithUserData".format(jetName)
505  setattr(proc, srcJetsWithUserData, cms.EDProducer("PATJetUserDataEmbedder",
506  src = cms.InputTag(srcJets),
507  userFloats = cms.PSet(),
508  userInts = cms.PSet(),
509  )
510  )
511 
512  #
513  # Filter jets with pt cut
514  #
515  finalJetsCut = "(pt >= {ptcut:.0f})".format(ptcut=ptcut)
516  if runOnMC:
517  finalJetsCut = "(pt >= {ptcut:.0f}) || ((pt < {ptcut:.0f}) && (genJetFwdRef().backRef().isNonnull()))".format(ptcut=ptcut)
518 
519  finalJetsForTable = "finalJets{}".format(jetName)
520  setattr(proc, finalJetsForTable, finalJets.clone(
521  src = srcJetsWithUserData,
522  cut = finalJetsCut
523  )
524  )
525 
526  #
527  # Save jets in table
528  #
529  tableContent = PFJETVARS
530  if doCalo:
531  tableContent = CALOJETVARS
532 
533  jetTableCutDefault = "" #Don't apply any cuts for the table.
534 
535  jetTableDocDefault = jetTableDoc + " with JECs applied. Jets with pt >= {ptcut:.0f} GeV are stored.".format(ptcut=ptcut)
536  if runOnMC:
537  jetTableDocDefault += "For jets with pt < {ptcut:.0f} GeV, only those matched to gen jets are stored.".format(ptcut=ptcut)
538 
539  if doCalo:
540  jetTableDocDefault = jetTableDoc
541 
542  jetTableName = "jet{}Table".format(jetName)
543  setattr(proc,jetTableName, simpleCandidateFlatTableProducer.clone(
544  src = cms.InputTag(finalJetsForTable),
545  cut = cms.string(jetTableCutDefault),
546  name = cms.string(jetTablePrefix),
547  doc = cms.string(jetTableDocDefault),
548  variables = cms.PSet(tableContent)
549  )
550  )
551  getattr(proc,jetTableName).variables.pt.precision=10
552  getattr(proc,jetTableName).variables.rawFactor.precision=10
553 
554  #
555  # Save MC-only jet variables in table
556  #
557  jetMCTableName = "jet{}MCTable".format(jetName)
558  setattr(proc, jetMCTableName, simpleCandidateFlatTableProducer.clone(
559  src = cms.InputTag(finalJetsForTable),
560  cut = getattr(proc,jetTableName).cut,
561  name = cms.string(jetTablePrefix),
562  extension = cms.bool(True), # this is an extension table
563  variables = cms.PSet(
564  partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
565  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
566  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
567  )
568  )
569  )
570 
571  #
572  # Define the jet modules Task first
573  #
574  jetTaskName = "jet{}Task".format(jetName)
575  setattr(proc, jetTaskName, cms.Task(
576  getattr(proc,jetCorrFactors),
577  getattr(proc,srcJets),
578  getattr(proc,srcJetsWithUserData),
579  getattr(proc,finalJetsForTable)
580  )
581  )
582  proc.nanoTableTaskCommon.add(getattr(proc,jetTaskName))
583 
584  #
585  # Define the jet tables Task
586  #
587  jetTableTaskName = "jet{}TablesTask".format(jetName)
588  setattr(proc, jetTableTaskName, cms.Task(getattr(proc,jetTableName)))
589  proc.nanoTableTaskCommon.add(getattr(proc,jetTableTaskName))
590 
591  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
592  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
593  if runOnMC:
594  proc.nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
595 
596  #
597  # Schedule plugins to calculate Jet ID, PileUp Jet ID input variables, and Quark-Gluon Likehood input variables.
598  #
599  if doPF:
600  proc = AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
601  if doPUIDVar:
602  proc = AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
603  if doQGL:
604  proc = AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName, calculateQGLVars=True)
605 
606  #
607  # Save b-tagging algorithm scores. Should only be done for jet collection with b-tagging
608  # calculated when reclustered or collection saved with b-tagging info in MiniAOD
609  #
610  if doBTag:
611  AddBTaggingScores(proc,jetTableName=jetTableName)
612  AddDeepJetGluonLQuarkScores(proc,jetTableName=jetTableName)
613  AddParticleNetAK4Scores(proc,jetTableName=jetTableName)
614  AddRobustParTAK4Scores(proc,jetTableName=jetTableName)
615 
616  return proc
617 
618 
def AddBTaggingScores(proc, jetTableName="")
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
def AddRobustParTAK4Scores(proc, jetTableName="")
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
def AddParticleNetAK4Scores(proc, jetTableName="")
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")

Variable Documentation

◆ area

◆ bTagCSVV2

custom_jme_cff.bTagCSVV2

Definition at line 19 of file custom_jme_cff.py.

◆ btagDDX

custom_jme_cff.btagDDX

Definition at line 44 of file custom_jme_cff.py.

◆ btagDDXV2

custom_jme_cff.btagDDXV2

Definition at line 52 of file custom_jme_cff.py.

◆ btagDeepB

custom_jme_cff.btagDeepB

Definition at line 175 of file custom_jme_cff.py.

◆ bTagDeepCSV

custom_jme_cff.bTagDeepCSV

Definition at line 20 of file custom_jme_cff.py.

◆ btagDeepCvB

custom_jme_cff.btagDeepCvB

Definition at line 177 of file custom_jme_cff.py.

◆ btagDeepCvL

custom_jme_cff.btagDeepCvL

Definition at line 176 of file custom_jme_cff.py.

◆ btagDeepFlavB

custom_jme_cff.btagDeepFlavB

Definition at line 180 of file custom_jme_cff.py.

◆ btagDeepFlavC

custom_jme_cff.btagDeepFlavC

Definition at line 181 of file custom_jme_cff.py.

◆ btagDeepFlavCvB

custom_jme_cff.btagDeepFlavCvB

Definition at line 185 of file custom_jme_cff.py.

◆ btagDeepFlavCvL

custom_jme_cff.btagDeepFlavCvL

Definition at line 184 of file custom_jme_cff.py.

◆ btagDeepFlavG

custom_jme_cff.btagDeepFlavG

Definition at line 182 of file custom_jme_cff.py.

◆ btagDeepFlavQG

custom_jme_cff.btagDeepFlavQG

Definition at line 186 of file custom_jme_cff.py.

◆ btagDeepFlavUDS

custom_jme_cff.btagDeepFlavUDS

Definition at line 183 of file custom_jme_cff.py.

◆ bTagDeepJet

custom_jme_cff.bTagDeepJet

Definition at line 21 of file custom_jme_cff.py.

◆ bTagDiscriminatorsForAK4

custom_jme_cff.bTagDiscriminatorsForAK4

Definition at line 29 of file custom_jme_cff.py.

◆ btagHbb

custom_jme_cff.btagHbb

Definition at line 43 of file custom_jme_cff.py.

◆ btagRobustParTAK4B

custom_jme_cff.btagRobustParTAK4B

Definition at line 189 of file custom_jme_cff.py.

◆ btagRobustParTAK4C

custom_jme_cff.btagRobustParTAK4C

Definition at line 190 of file custom_jme_cff.py.

◆ btagRobustParTAK4CvB

custom_jme_cff.btagRobustParTAK4CvB

Definition at line 194 of file custom_jme_cff.py.

◆ btagRobustParTAK4CvL

custom_jme_cff.btagRobustParTAK4CvL

Definition at line 193 of file custom_jme_cff.py.

◆ btagRobustParTAK4G

custom_jme_cff.btagRobustParTAK4G

Definition at line 191 of file custom_jme_cff.py.

◆ btagRobustParTAK4QG

custom_jme_cff.btagRobustParTAK4QG

Definition at line 195 of file custom_jme_cff.py.

◆ btagRobustParTAK4UDS

custom_jme_cff.btagRobustParTAK4UDS

Definition at line 192 of file custom_jme_cff.py.

◆ BTAGVARS

custom_jme_cff.BTAGVARS

Definition at line 174 of file custom_jme_cff.py.

◆ CALOJETVARS

custom_jme_cff.CALOJETVARS

Definition at line 206 of file custom_jme_cff.py.

◆ chEmEF

custom_jme_cff.chEmEF

Definition at line 138 of file custom_jme_cff.py.

◆ chHadMultiplicity

custom_jme_cff.chHadMultiplicity

Definition at line 146 of file custom_jme_cff.py.

◆ chHEF

custom_jme_cff.chHEF

Definition at line 136 of file custom_jme_cff.py.

◆ config_genjets

custom_jme_cff.config_genjets

Definition at line 64 of file custom_jme_cff.py.

◆ config_recojets

custom_jme_cff.config_recojets

Definition at line 87 of file custom_jme_cff.py.

◆ DEEPJETVARS

custom_jme_cff.DEEPJETVARS

Definition at line 179 of file custom_jme_cff.py.

◆ doc

custom_jme_cff.doc

Definition at line 141 of file custom_jme_cff.py.

◆ elMultiplicity

custom_jme_cff.elMultiplicity

Definition at line 151 of file custom_jme_cff.py.

◆ emf

◆ float

custom_jme_cff.float

Definition at line 141 of file custom_jme_cff.py.

◆ foo

◆ GENJETVARS

custom_jme_cff.GENJETVARS

Definition at line 130 of file custom_jme_cff.py.

◆ hfEmEF

custom_jme_cff.hfEmEF

Definition at line 142 of file custom_jme_cff.py.

◆ hfEMMultiplicity

custom_jme_cff.hfEMMultiplicity

Definition at line 149 of file custom_jme_cff.py.

◆ hfHadMultiplicity

custom_jme_cff.hfHadMultiplicity

Definition at line 148 of file custom_jme_cff.py.

◆ hfHEF

custom_jme_cff.hfHEF

Definition at line 141 of file custom_jme_cff.py.

◆ muEF

custom_jme_cff.muEF

Definition at line 140 of file custom_jme_cff.py.

◆ muMultiplicity

custom_jme_cff.muMultiplicity

Definition at line 150 of file custom_jme_cff.py.

◆ nanoInfo_genjets

custom_jme_cff.nanoInfo_genjets

Definition at line 74 of file custom_jme_cff.py.

◆ nanoInfo_recojets

custom_jme_cff.nanoInfo_recojets

Definition at line 113 of file custom_jme_cff.py.

◆ nConstituents

◆ neEmEF

custom_jme_cff.neEmEF

Definition at line 139 of file custom_jme_cff.py.

◆ neHadMultiplicity

custom_jme_cff.neHadMultiplicity

Definition at line 147 of file custom_jme_cff.py.

◆ neHEF

custom_jme_cff.neHEF

Definition at line 137 of file custom_jme_cff.py.

◆ nElectrons

◆ nMuons

◆ particleNetAK4_B

custom_jme_cff.particleNetAK4_B

Definition at line 198 of file custom_jme_cff.py.

◆ particleNetAK4_CvsB

custom_jme_cff.particleNetAK4_CvsB

Definition at line 200 of file custom_jme_cff.py.

◆ particleNetAK4_CvsL

custom_jme_cff.particleNetAK4_CvsL

Definition at line 199 of file custom_jme_cff.py.

◆ particleNetAK4_G

custom_jme_cff.particleNetAK4_G

Definition at line 202 of file custom_jme_cff.py.

◆ particleNetAK4_puIdDisc

custom_jme_cff.particleNetAK4_puIdDisc

Definition at line 203 of file custom_jme_cff.py.

◆ particleNetAK4_QvsG

custom_jme_cff.particleNetAK4_QvsG

Definition at line 201 of file custom_jme_cff.py.

◆ PARTICLENETAK4VARS

custom_jme_cff.PARTICLENETAK4VARS

Definition at line 197 of file custom_jme_cff.py.

◆ PFJETVARS

custom_jme_cff.PFJETVARS

Definition at line 133 of file custom_jme_cff.py.

◆ phoMultiplicity

custom_jme_cff.phoMultiplicity

Definition at line 152 of file custom_jme_cff.py.

◆ precision

custom_jme_cff.precision

Definition at line 141 of file custom_jme_cff.py.

◆ puId_beta

custom_jme_cff.puId_beta

Definition at line 163 of file custom_jme_cff.py.

◆ puId_dR2Mean

custom_jme_cff.puId_dR2Mean

Definition at line 155 of file custom_jme_cff.py.

◆ puId_frac01

custom_jme_cff.puId_frac01

Definition at line 158 of file custom_jme_cff.py.

◆ puId_frac02

custom_jme_cff.puId_frac02

Definition at line 159 of file custom_jme_cff.py.

◆ puId_frac03

custom_jme_cff.puId_frac03

Definition at line 160 of file custom_jme_cff.py.

◆ puId_frac04

custom_jme_cff.puId_frac04

Definition at line 161 of file custom_jme_cff.py.

◆ puId_jetR

custom_jme_cff.puId_jetR

Definition at line 165 of file custom_jme_cff.py.

◆ puId_jetRchg

custom_jme_cff.puId_jetRchg

Definition at line 166 of file custom_jme_cff.py.

◆ puId_majW

custom_jme_cff.puId_majW

Definition at line 156 of file custom_jme_cff.py.

◆ puId_minW

custom_jme_cff.puId_minW

Definition at line 157 of file custom_jme_cff.py.

◆ puId_nCharged

custom_jme_cff.puId_nCharged

Definition at line 167 of file custom_jme_cff.py.

◆ puId_ptD

custom_jme_cff.puId_ptD

Definition at line 162 of file custom_jme_cff.py.

◆ puId_pull

custom_jme_cff.puId_pull

Definition at line 164 of file custom_jme_cff.py.

◆ PUIDVARS

custom_jme_cff.PUIDVARS

Definition at line 154 of file custom_jme_cff.py.

◆ qgl_axis2

custom_jme_cff.qgl_axis2

Definition at line 170 of file custom_jme_cff.py.

◆ qgl_mult

custom_jme_cff.qgl_mult

Definition at line 172 of file custom_jme_cff.py.

◆ qgl_ptD

custom_jme_cff.qgl_ptD

Definition at line 171 of file custom_jme_cff.py.

◆ QGLVARS

custom_jme_cff.QGLVARS

Definition at line 169 of file custom_jme_cff.py.

◆ rawFactor

custom_jme_cff.rawFactor

Definition at line 134 of file custom_jme_cff.py.

◆ ROBUSTPARTAK4VARS

custom_jme_cff.ROBUSTPARTAK4VARS

Definition at line 188 of file custom_jme_cff.py.