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 ModifyAK4JetMCTable (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
 
 genJetIdx
 
 GENJETVARS
 
 hadronFlavour
 
 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
 
 partonFlavour
 
 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 398 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by SavePatJets().

398 def AddBTaggingScores(proc, jetTableName=""):
399  """
400  Store b-tagging scores from various algortihm
401  """
402 
403  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
404  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
405  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
406 
407  run2_nanoAOD_ANY.toModify(
408  getattr(proc, jetTableName).variables,
409  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
410  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),
411  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),
412  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)
413  )
414 
415  return proc
416 
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 417 of file custom_jme_cff.py.

Referenced by SavePatJets().

417 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
418  """
419  Store DeepJet raw score in jetTable for gluon and light quark
420  """
421 
422  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
423  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
424  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
425 
426  return proc
427 
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 224 of file custom_jme_cff.py.

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

Referenced by SavePatJets().

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

References print(), and SavePatJets().

1002 def AddNewAK8CHSJets(proc, recoJA, runOnMC):
1003  """
1004  Store an AK8 CHS jet collection for JEC studies.
1005  """
1006  print("custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
1007 
1008  #
1009  # Recluster AK8 CHS jets
1010  #
1011  cfg = {
1012  "jet" : "ak8pfchs",
1013  "inputCollection" : "",
1014  "genJetsCollection": "AK8GenJetsNoNu",
1015  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
1016  }
1017  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1018 
1019  jetName = recoJetInfo.jetUpper
1020  payload = recoJetInfo.jetCorrPayload
1021 
1022  patJetFinalColl = recoJetInfo.patJetFinalCollection
1023  jetTablePrefix = "FatJetCHS"
1024  jetTableDoc = "AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
1025  ptcut = 15
1026 
1027  SavePatJets(proc,
1028  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
1029  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
1030  )
1031 
1032  return proc
1033 
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 1169 of file custom_jme_cff.py.

References print(), and SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1169 def AddNewAK8GenJetsForJEC(proc, genJA):
1170  """
1171  Make a separate AK8 Gen jet collection for JEC studies.
1172  """
1173  print("custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1174 
1175  #
1176  # Recluster AK8 Gen jet
1177  #
1178  cfg = {
1179  "jet" : "ak8gen",
1180  "minPtFastjet" : 10.
1181  }
1182  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1183 
1184  genJetName = genJetInfo.jetUpper
1185  genJetAlgo = genJetInfo.jetAlgo
1186  genJetSize = genJetInfo.jetSize
1187  genJetSizeNr = genJetInfo.jetSizeNr
1188  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1189  genJetTablePrefix = "GenJetAK8ForJEC"
1190  genJetTableDoc = "AK8 Gen jets (made with visible genparticles) with pt > 10 GeV. Reclustered for JEC studies."
1191 
1192  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1193 
1194  return proc
1195 
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 969 of file custom_jme_cff.py.

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

969 def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC):
970  """
971  Store a separate AK8 Puppi jet collection for JEC studies.
972  Only minimal info are stored
973  """
974  print("custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
975 
976  #
977  # Recluster AK8 Puppi jets
978  #
979  cfg = {
980  "jet" : "ak8pfpuppi",
981  "inputCollection" : "",
982  "genJetsCollection": "AK8GenJetsNoNu",
983  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
984  }
985  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
986 
987  jetName = recoJetInfo.jetUpper
988  payload = recoJetInfo.jetCorrPayload
989 
990  patJetFinalColl = recoJetInfo.patJetFinalCollection
991  jetTablePrefix = "FatJetForJEC"
992  jetTableDoc = "AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
993  ptcut = 15
994 
995  SavePatJets(proc,
996  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
997  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
998  )
999 
1000  return proc
1001 
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 1068 of file custom_jme_cff.py.

References SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1068 def AddNewGenJets(proc, genJetInfo):
1069  """
1070  Add genJet into custom nanoAOD
1071  """
1072 
1073  genJetName = genJetInfo.jetUpper
1074  genJetAlgo = genJetInfo.jetAlgo
1075  genJetSize = genJetInfo.jetSize
1076  genJetSizeNr = genJetInfo.jetSizeNr
1077  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1078  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
1079  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
1080 
1081  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1082 
1083  return proc
1084 
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 453 of file custom_jme_cff.py.

References SavePatJets().

Referenced by PrepJMECustomNanoAOD().

453 def AddNewPatJets(proc, recoJetInfo, runOnMC):
454  """
455  Add patJet into custom nanoAOD
456  """
457 
458  jetName = recoJetInfo.jetUpper
459  payload = recoJetInfo.jetCorrPayload
460  doPF = recoJetInfo.doPF
461  doCalo = recoJetInfo.doCalo
462  patJetFinalColl = recoJetInfo.patJetFinalCollection
463 
464  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
465  jetTablePrefix = nanoInfoForJet["name"]
466  jetTableDoc = nanoInfoForJet["doc"]
467  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else 8
468  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
469  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
470  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
471 
472  SavePatJets(proc,
473  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
474  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
475  )
476 
477  return proc
478 
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 439 of file custom_jme_cff.py.

Referenced by SavePatJets().

439 def AddParticleNetAK4Scores(proc, jetTableName=""):
440  """
441  Store ParticleNetAK4 scores in jetTable
442  """
443 
444  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
445  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
446  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
447  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
448  getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
449  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
450 
451  return proc
452 
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 293 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

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

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

360 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
361  """
362  Schedule the QGTagger module to calculate input variables to the QG likelihood
363  """
364 
365  isPUPPIJet = True if "PUPPI" in jetName.upper() else False
366 
367  QGLTagger="qgtagger{}".format(jetName)
368  patJetWithUserData="{}WithUserData".format(jetSrc)
369 
370  if calculateQGLVars:
371  setattr(proc, QGLTagger, qgtagger.clone(
372  srcJets = jetSrc,
373  computeLikelihood = False,
374  )
375  )
376  if isPUPPIJet:
377  getattr(proc,QGLTagger).srcConstituentWeights = cms.InputTag("packedpuppi")
378 
379  #
380  # Save variables as userFloats and userInts for each jet
381  #
382  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
383  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
384  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
385 
386  #
387  # Specfiy variables in the jet table to save in NanoAOD
388  #
389  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
390  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
391  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
392 
393  if calculateQGLVars:
394  getattr(proc,jetTaskName).add(getattr(proc, QGLTagger))
395 
396  return proc
397 
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 428 of file custom_jme_cff.py.

Referenced by SavePatJets().

428 def AddRobustParTAK4Scores(proc, jetTableName=""):
429  """
430  Store RobustParTAK4 scores in jetTable
431  """
432 
433  getattr(proc, jetTableName).variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
434  getattr(proc, jetTableName).variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
435  getattr(proc, jetTableName).variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
436 
437  return proc
438 
def AddRobustParTAK4Scores(proc, jetTableName="")

◆ AddVariablesForAK4GenJets()

def custom_jme_cff.AddVariablesForAK4GenJets (   proc)

Definition at line 1196 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1196 def AddVariablesForAK4GenJets(proc):
1197  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1198  return proc
1199 
def AddVariablesForAK4GenJets(proc)

◆ AddVariablesForAK8GenJets()

def custom_jme_cff.AddVariablesForAK8GenJets (   proc)

Definition at line 1200 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1200 def AddVariablesForAK8GenJets(proc):
1201  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1202  return proc
1203 
def AddVariablesForAK8GenJets(proc)

◆ AddVariablesForAK8PuppiJets()

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

Definition at line 1034 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

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

◆ ModifyAK4JetMCTable()

def custom_jme_cff.ModifyAK4JetMCTable (   proc)

Definition at line 1204 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1204 def ModifyAK4JetMCTable(proc):
1205  # Remove the genjet pt selection when saving the genJetIdx, which is
1206  # the default in main Nano
1207  proc.jetMCTable.variables.genJetIdx = PFJETVARS.genJetIdx
1208  return proc
1209 
1210 #===========================================================================
1211 #
1212 # Misc. functions
1213 #
1214 #===========================================================================
def ModifyAK4JetMCTable(proc)

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process,
  runOnMC 
)

Definition at line 1235 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD_Data(), and PrepJMECustomNanoAOD_MC().

1235 def PrepJMECustomNanoAOD(process,runOnMC):
1236 
1237 
1240  process = RemoveAllJetPtCuts(process)
1241 
1242 
1247  genJA = GenJetAdder()
1248  if runOnMC:
1249 
1252  process = AddVariablesForAK8GenJets(process)
1253 
1256  process = AddNewAK8GenJetsForJEC(process, genJA)
1257 
1260  process = ModifyAK4JetMCTable(process)
1261 
1264  process = ReclusterAK4GenJets(process, genJA)
1265  process = AddVariablesForAK4GenJets(process)
1266 
1269  for jetConfig in config_genjets:
1270  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1271  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1272  AddNewGenJets(process, genJetInfo)
1273 
1274 
1279  recoJA = RecoJetAdder(runOnMC=runOnMC)
1280 
1283  process = AddVariablesForAK8PuppiJets(process)
1284 
1287  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1288 
1291  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1292 
1295  process = ReclusterAK4PuppiJets(process, recoJA, runOnMC)
1296 
1299  for jetConfig in config_recojets:
1300  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1301  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1302  AddNewPatJets(process, recoJetInfo, runOnMC)
1303 
1304 
1309  def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1310  if addAK4CHSJetTasks:
1311  proc.nanoTableTaskCommon.add(proc.jetTask)
1312  proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1313  proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1314  if addAK4PuppiJetTasks:
1315  proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1316  proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1317  proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1318  return proc
1319 
1320  jmeNano_addAK4JetTasks_switch = cms.PSet(
1321  jmeNano_addAK4CHS_switch = cms.untracked.bool(True),
1322  jmeNano_addAK4Puppi_switch = cms.untracked.bool(False)
1323  )
1324  run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1325  jmeNano_addAK4CHS_switch = False,
1326  jmeNano_addAK4Puppi_switch = True
1327  )
1328  process = addAK4JetTasks(process,
1329  addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1330  addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1331  )
1332 
1333 
1336  if runOnMC:
1337  process.puTable.savePtHatMax = True
1338 
1339 
1342  if runOnMC:
1343  process.genWeightsTable.keepAllPSWeights = True
1344 
1345  return process
1346 
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def RemoveAllJetPtCuts(proc)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def ModifyAK4JetMCTable(proc)
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 1352 of file custom_jme_cff.py.

References PrepJMECustomNanoAOD().

1352 def PrepJMECustomNanoAOD_Data(process):
1353  process = PrepJMECustomNanoAOD(process,runOnMC=False)
1354  return process
1355 
def PrepJMECustomNanoAOD(process, runOnMC)
def PrepJMECustomNanoAOD_Data(process)

◆ PrepJMECustomNanoAOD_MC()

def custom_jme_cff.PrepJMECustomNanoAOD_MC (   process)

Definition at line 1347 of file custom_jme_cff.py.

References PrepJMECustomNanoAOD().

1347 def PrepJMECustomNanoAOD_MC(process):
1348  process = PrepJMECustomNanoAOD(process,runOnMC=True)
1349 
1350  return process
1351 
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 780 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

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

References print().

Referenced by PrepJMECustomNanoAOD().

1128 def ReclusterAK4GenJets(proc, genJA):
1129  """
1130  Recluster AK4 Gen jets and replace
1131  slimmedGenJets that is used as default
1132  to save AK4 Gen jets in NanoAODs.
1133  """
1134  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1135 
1136  #
1137  # Recluster AK4 Gen jet
1138  #
1139  cfg = {
1140  "jet" : "ak4gen",
1141  "minPtFastjet" : 5.
1142  }
1143  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1144 
1145  genJetName = genJetInfo.jetUpper
1146  genJetAlgo = genJetInfo.jetAlgo
1147  genJetSize = genJetInfo.jetSize
1148  genJetSizeNr = genJetInfo.jetSizeNr
1149  selectedGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1150 
1151  #
1152  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
1153  # to be stored in the GenJet Table
1154  #
1155  proc.genJetTable.src = selectedGenJets
1156  proc.genJetTable.cut = "" # No cut specified here. Save all gen jets after clustering
1157  proc.genJetTable.doc = "AK4 Gen jets (made with visible genparticles) with pt > 5 GeV"
1158 
1159  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1160  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1161  jets = proc.genJetTable.src,
1162  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1163  rParam = genJetSizeNr,
1164  )
1165  )
1166  proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1167  return proc
1168 
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 623 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

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

Referenced by PrepJMECustomNanoAOD().

1215 def RemoveAllJetPtCuts(proc):
1216  """
1217  Remove default pt cuts for all jets set in jets_cff.py
1218  """
1219 
1220  proc.finalJets.cut = "" # 15 -> 10
1221  proc.finalJetsPuppi.cut = "" # 15 -> 10
1222  proc.finalJetsAK8.cut = "" # 170 -> 170
1223  proc.genJetTable.cut = "" # 10 -> 8
1224  proc.genJetFlavourTable.cut = "" # 10 -> 8
1225  proc.genJetAK8Table.cut = "" # 100 -> 80
1226  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
1227 
1228  return proc
1229 
1230 #===========================================================================
1231 #
1232 # CUSTOMIZATION function
1233 #
1234 #===========================================================================
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 1085 of file custom_jme_cff.py.

Referenced by AddNewAK8GenJetsForJEC(), and AddNewGenJets().

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

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

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

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

◆ btagDeepCvL

custom_jme_cff.btagDeepCvL

Definition at line 180 of file custom_jme_cff.py.

◆ btagDeepFlavB

custom_jme_cff.btagDeepFlavB

Definition at line 184 of file custom_jme_cff.py.

◆ btagDeepFlavC

custom_jme_cff.btagDeepFlavC

Definition at line 185 of file custom_jme_cff.py.

◆ btagDeepFlavCvB

custom_jme_cff.btagDeepFlavCvB

Definition at line 189 of file custom_jme_cff.py.

◆ btagDeepFlavCvL

custom_jme_cff.btagDeepFlavCvL

Definition at line 188 of file custom_jme_cff.py.

◆ btagDeepFlavG

custom_jme_cff.btagDeepFlavG

Definition at line 186 of file custom_jme_cff.py.

◆ btagDeepFlavQG

custom_jme_cff.btagDeepFlavQG

Definition at line 190 of file custom_jme_cff.py.

◆ btagDeepFlavUDS

custom_jme_cff.btagDeepFlavUDS

Definition at line 187 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 193 of file custom_jme_cff.py.

◆ btagRobustParTAK4C

custom_jme_cff.btagRobustParTAK4C

Definition at line 194 of file custom_jme_cff.py.

◆ btagRobustParTAK4CvB

custom_jme_cff.btagRobustParTAK4CvB

Definition at line 198 of file custom_jme_cff.py.

◆ btagRobustParTAK4CvL

custom_jme_cff.btagRobustParTAK4CvL

Definition at line 197 of file custom_jme_cff.py.

◆ btagRobustParTAK4G

custom_jme_cff.btagRobustParTAK4G

Definition at line 195 of file custom_jme_cff.py.

◆ btagRobustParTAK4QG

custom_jme_cff.btagRobustParTAK4QG

Definition at line 199 of file custom_jme_cff.py.

◆ btagRobustParTAK4UDS

custom_jme_cff.btagRobustParTAK4UDS

Definition at line 196 of file custom_jme_cff.py.

◆ BTAGVARS

custom_jme_cff.BTAGVARS

Definition at line 178 of file custom_jme_cff.py.

◆ CALOJETVARS

custom_jme_cff.CALOJETVARS

Definition at line 210 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 183 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

◆ genJetIdx

custom_jme_cff.genJetIdx

Definition at line 156 of file custom_jme_cff.py.

◆ GENJETVARS

custom_jme_cff.GENJETVARS

Definition at line 130 of file custom_jme_cff.py.

◆ hadronFlavour

◆ 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 202 of file custom_jme_cff.py.

◆ particleNetAK4_CvsB

custom_jme_cff.particleNetAK4_CvsB

Definition at line 204 of file custom_jme_cff.py.

◆ particleNetAK4_CvsL

custom_jme_cff.particleNetAK4_CvsL

Definition at line 203 of file custom_jme_cff.py.

◆ particleNetAK4_G

custom_jme_cff.particleNetAK4_G

Definition at line 206 of file custom_jme_cff.py.

◆ particleNetAK4_puIdDisc

custom_jme_cff.particleNetAK4_puIdDisc

Definition at line 207 of file custom_jme_cff.py.

◆ particleNetAK4_QvsG

custom_jme_cff.particleNetAK4_QvsG

Definition at line 205 of file custom_jme_cff.py.

◆ PARTICLENETAK4VARS

custom_jme_cff.PARTICLENETAK4VARS

Definition at line 201 of file custom_jme_cff.py.

◆ partonFlavour

◆ 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 167 of file custom_jme_cff.py.

◆ puId_dR2Mean

custom_jme_cff.puId_dR2Mean

Definition at line 159 of file custom_jme_cff.py.

◆ puId_frac01

custom_jme_cff.puId_frac01

Definition at line 162 of file custom_jme_cff.py.

◆ puId_frac02

custom_jme_cff.puId_frac02

Definition at line 163 of file custom_jme_cff.py.

◆ puId_frac03

custom_jme_cff.puId_frac03

Definition at line 164 of file custom_jme_cff.py.

◆ puId_frac04

custom_jme_cff.puId_frac04

Definition at line 165 of file custom_jme_cff.py.

◆ puId_jetR

custom_jme_cff.puId_jetR

Definition at line 169 of file custom_jme_cff.py.

◆ puId_jetRchg

custom_jme_cff.puId_jetRchg

Definition at line 170 of file custom_jme_cff.py.

◆ puId_majW

custom_jme_cff.puId_majW

Definition at line 160 of file custom_jme_cff.py.

◆ puId_minW

custom_jme_cff.puId_minW

Definition at line 161 of file custom_jme_cff.py.

◆ puId_nCharged

custom_jme_cff.puId_nCharged

Definition at line 171 of file custom_jme_cff.py.

◆ puId_ptD

custom_jme_cff.puId_ptD

Definition at line 166 of file custom_jme_cff.py.

◆ puId_pull

custom_jme_cff.puId_pull

Definition at line 168 of file custom_jme_cff.py.

◆ PUIDVARS

custom_jme_cff.PUIDVARS

Definition at line 158 of file custom_jme_cff.py.

◆ qgl_axis2

custom_jme_cff.qgl_axis2

Definition at line 174 of file custom_jme_cff.py.

◆ qgl_mult

custom_jme_cff.qgl_mult

Definition at line 176 of file custom_jme_cff.py.

◆ qgl_ptD

custom_jme_cff.qgl_ptD

Definition at line 175 of file custom_jme_cff.py.

◆ QGLVARS

custom_jme_cff.QGLVARS

Definition at line 173 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 192 of file custom_jme_cff.py.