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 AddUnifiedParTAK4Scores (proc, jetTableName="")
 
def AddVariablesForAK4GenJets (proc)
 
def AddVariablesForAK8GenJets (proc)
 
def AddVariablesForAK8PuppiJets (proc)
 
def ModifyAK4JetMCTable (proc)
 
def PrepJMECustomNanoAOD (process)
 
def ReclusterAK4CHSJets (proc, recoJA, runOnMC)
 
def ReclusterAK4GenJets (proc, genJA)
 
def ReclusterAK4PuppiJets (proc, recoJA, runOnMC)
 
def RecomputePuppiMET (proc)
 
def RecomputePuppiWeights (proc)
 
def RecomputePuppiWeightsAndMET (proc)
 
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
 
 btagUParTAK4B
 
 btagUParTAK4CvB
 
 btagUParTAK4CvL
 
 btagUParTAK4QvG
 
 btagUParTAK4TauVJet
 
 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
 
 UNIFIEDPARTAK4VARS
 
 UParTAK4RegPtRawCorr
 
 UParTAK4RegPtRawCorrNeutrino
 
 UParTAK4RegPtRawRes
 

Function Documentation

◆ AddBTaggingScores()

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

Definition at line 408 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by SavePatJets().

408 def AddBTaggingScores(proc, jetTableName=""):
409  """
410  Store b-tagging scores from various algortihm
411  """
412 
413  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
414  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
415  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
416 
417  run2_nanoAOD_ANY.toModify(
418  getattr(proc, jetTableName).variables,
419  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
420  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),
421  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),
422  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)
423  )
424 
425  return proc
426 
def AddBTaggingScores(proc, jetTableName="")
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17

◆ AddDeepJetGluonLQuarkScores()

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

Definition at line 427 of file custom_jme_cff.py.

Referenced by SavePatJets().

427 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
428  """
429  Store DeepJet raw score in jetTable for gluon and light quark
430  """
431 
432  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
433  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
434  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
435 
436  return proc
437 
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 234 of file custom_jme_cff.py.

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

Referenced by SavePatJets().

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

References print(), and SavePatJets().

1037 def AddNewAK8CHSJets(proc, recoJA, runOnMC):
1038  """
1039  Store an AK8 CHS jet collection for JEC studies.
1040  """
1041  print("custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
1042 
1043  #
1044  # Recluster AK8 CHS jets
1045  #
1046  cfg = {
1047  "jet" : "ak8pfchs",
1048  "inputCollection" : "",
1049  "genJetsCollection": "AK8GenJetsNoNu",
1050  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
1051  }
1052  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1053 
1054  jetName = recoJetInfo.jetUpper
1055  payload = recoJetInfo.jetCorrPayload
1056 
1057  patJetFinalColl = recoJetInfo.patJetFinalCollection
1058  jetTablePrefix = "FatJetCHS"
1059  jetTableDoc = "AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
1060  ptcut = 15
1061 
1062  SavePatJets(proc,
1063  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
1064  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
1065  )
1066 
1067  return proc
1068 
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 1204 of file custom_jme_cff.py.

References print(), and SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1204 def AddNewAK8GenJetsForJEC(proc, genJA):
1205  """
1206  Make a separate AK8 Gen jet collection for JEC studies.
1207  """
1208  print("custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1209 
1210  #
1211  # Recluster AK8 Gen jet
1212  #
1213  cfg = {
1214  "jet" : "ak8gen",
1215  "minPtFastjet" : 10.
1216  }
1217  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1218 
1219  genJetName = genJetInfo.jetUpper
1220  genJetAlgo = genJetInfo.jetAlgo
1221  genJetSize = genJetInfo.jetSize
1222  genJetSizeNr = genJetInfo.jetSizeNr
1223  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1224  genJetTablePrefix = "GenJetAK8ForJEC"
1225  genJetTableDoc = "AK8 Gen jets (made with visible genparticles) with pt > 10 GeV. Reclustered for JEC studies."
1226 
1227  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1228 
1229  return proc
1230 
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 1004 of file custom_jme_cff.py.

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

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

References SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1103 def AddNewGenJets(proc, genJetInfo):
1104  """
1105  Add genJet into custom nanoAOD
1106  """
1107 
1108  genJetName = genJetInfo.jetUpper
1109  genJetAlgo = genJetInfo.jetAlgo
1110  genJetSize = genJetInfo.jetSize
1111  genJetSizeNr = genJetInfo.jetSizeNr
1112  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1113  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
1114  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
1115 
1116  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1117 
1118  return proc
1119 
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 478 of file custom_jme_cff.py.

References SavePatJets().

Referenced by PrepJMECustomNanoAOD().

478 def AddNewPatJets(proc, recoJetInfo, runOnMC):
479  """
480  Add patJet into custom nanoAOD
481  """
482 
483  jetName = recoJetInfo.jetUpper
484  payload = recoJetInfo.jetCorrPayload
485  doPF = recoJetInfo.doPF
486  doCalo = recoJetInfo.doCalo
487  patJetFinalColl = recoJetInfo.patJetFinalCollection
488 
489  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
490  jetTablePrefix = nanoInfoForJet["name"]
491  jetTableDoc = nanoInfoForJet["doc"]
492  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else 8
493  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
494  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
495  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
496 
497  SavePatJets(proc,
498  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
499  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
500  )
501 
502  return proc
503 
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 464 of file custom_jme_cff.py.

Referenced by SavePatJets().

464 def AddParticleNetAK4Scores(proc, jetTableName=""):
465  """
466  Store ParticleNetAK4 scores in jetTable
467  """
468 
469  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
470  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
471  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
472  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
473  getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
474  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
475 
476  return proc
477 
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 303 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

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

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

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

Referenced by SavePatJets().

438 def AddRobustParTAK4Scores(proc, jetTableName=""):
439  """
440  Store RobustParTAK4 scores in jetTable
441  """
442 
443  getattr(proc, jetTableName).variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
444  getattr(proc, jetTableName).variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
445  getattr(proc, jetTableName).variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
446 
447  return proc
448 
def AddRobustParTAK4Scores(proc, jetTableName="")

◆ AddUnifiedParTAK4Scores()

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

Definition at line 449 of file custom_jme_cff.py.

Referenced by SavePatJets().

449 def AddUnifiedParTAK4Scores(proc, jetTableName=""):
450  """
451  Store RobustParTAK4 scores in jetTable
452  """
453 
454  getattr(proc, jetTableName).variables.btagUParTAK4B = UNIFIEDPARTAK4VARS.btagUParTAK4B
455  getattr(proc, jetTableName).variables.btagUParTAK4CvL = UNIFIEDPARTAK4VARS.btagUParTAK4CvL
456  getattr(proc, jetTableName).variables.btagUParTAK4CvB = UNIFIEDPARTAK4VARS.btagUParTAK4CvB
457  getattr(proc, jetTableName).variables.btagUParTAK4TauVJet = UNIFIEDPARTAK4VARS.btagUParTAK4TauVJet
458  getattr(proc, jetTableName).variables.UParTAK4RegPtRawCorr = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawCorr
459  getattr(proc, jetTableName).variables.UParTAK4RegPtRawCorrNeutrino = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawCorrNeutrino
460  getattr(proc, jetTableName).variables.UParTAK4RegPtRawRes = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawRes
461 
462  return proc
463 
def AddUnifiedParTAK4Scores(proc, jetTableName="")

◆ AddVariablesForAK4GenJets()

def custom_jme_cff.AddVariablesForAK4GenJets (   proc)

Definition at line 1231 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1231 def AddVariablesForAK4GenJets(proc):
1232  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1233  return proc
1234 
def AddVariablesForAK4GenJets(proc)

◆ AddVariablesForAK8GenJets()

def custom_jme_cff.AddVariablesForAK8GenJets (   proc)

Definition at line 1235 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1235 def AddVariablesForAK8GenJets(proc):
1236  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1237  return proc
1238 
def AddVariablesForAK8GenJets(proc)

◆ AddVariablesForAK8PuppiJets()

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

Definition at line 1069 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

1069 def AddVariablesForAK8PuppiJets(proc):
1070  """
1071  Add more variables for AK8 PFPUPPI jets
1072  """
1073 
1074  proc.fatJetTable.variables.rawFactor.precision = 10
1075 
1076  #
1077  # These variables are not stored for AK8PFPUPPI (slimmedJetsAK8)
1078  # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
1079  #
1080  proc.fatJetTable.variables.chHEF = Var("?isPFJet()?chargedHadronEnergyFraction():-1", float, doc="charged Hadron Energy Fraction", precision = 6)
1081  proc.fatJetTable.variables.neHEF = Var("?isPFJet()?neutralHadronEnergyFraction():-1", float, doc="neutral Hadron Energy Fraction", precision = 6)
1082  proc.fatJetTable.variables.chEmEF = Var("?isPFJet()?chargedEmEnergyFraction():-1", float, doc="charged Electromagnetic Energy Fraction", precision = 6)
1083  proc.fatJetTable.variables.neEmEF = Var("?isPFJet()?neutralEmEnergyFraction():-1", float, doc="neutral Electromagnetic Energy Fraction", precision = 6)
1084  proc.fatJetTable.variables.muEF = Var("?isPFJet()?muonEnergyFraction():-1", float, doc="muon Energy Fraction", precision = 6)
1085  proc.fatJetTable.variables.hfHEF = Var("?isPFJet()?HFHadronEnergyFraction():-1", float, doc="energy fraction in forward hadronic calorimeter", precision = 6)
1086  proc.fatJetTable.variables.hfEmEF = Var("?isPFJet()?HFEMEnergyFraction():-1", float, doc="energy fraction in forward EM calorimeter", precision = 6)
1087  proc.fatJetTable.variables.chHadMultiplicity = Var("?isPFJet()?chargedHadronMultiplicity():-1","int16", doc="(Puppi-weighted) number of charged hadrons in the jet")
1088  proc.fatJetTable.variables.neHadMultiplicity = Var("?isPFJet()?neutralHadronMultiplicity():-1","int16", doc="(Puppi-weighted) number of neutral hadrons in the jet")
1089  proc.fatJetTable.variables.hfHadMultiplicity = Var("?isPFJet()?HFHadronMultiplicity():-1", "int16", doc="(Puppi-weighted) number of HF Hadrons in the jet")
1090  proc.fatJetTable.variables.hfEMMultiplicity = Var("?isPFJet()?HFEMMultiplicity():-1", "int16", doc="(Puppi-weighted) number of HF EMs in the jet")
1091  proc.fatJetTable.variables.muMultiplicity = Var("?isPFJet()?muonMultiplicity():-1", "int16", doc="(Puppi-weighted) number of muons in the jet")
1092  proc.fatJetTable.variables.elMultiplicity = Var("?isPFJet()?electronMultiplicity():-1", "int16", doc="(Puppi-weighted) number of electrons in the jet")
1093  proc.fatJetTable.variables.phoMultiplicity = Var("?isPFJet()?photonMultiplicity():-1", "int16", doc="(Puppi-weighted) number of photons in the jet")
1094 
1095  return proc
1096 #******************************************
1097 #
1098 #
1099 # Gen Jets related functions
1100 #
1101 #
1102 #******************************************
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
def AddVariablesForAK8PuppiJets(proc)

◆ ModifyAK4JetMCTable()

def custom_jme_cff.ModifyAK4JetMCTable (   proc)

Definition at line 1239 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1239 def ModifyAK4JetMCTable(proc):
1240  # Remove the genjet pt selection when saving the genJetIdx, which is
1241  # the default in main Nano
1242  proc.jetMCTable.variables.genJetIdx = PFJETVARS.genJetIdx
1243  return proc
1244 
1245 #===========================================================================
1246 #
1247 # Misc. functions
1248 #
1249 #===========================================================================
def ModifyAK4JetMCTable(proc)

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process)

Definition at line 1304 of file custom_jme_cff.py.

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

1304 def PrepJMECustomNanoAOD(process):
1305 
1306  runOnMC=True
1307  if hasattr(process,"NANOEDMAODoutput") or hasattr(process,"NANOAODoutput"):
1308  runOnMC = False
1309 
1312  process = RemoveAllJetPtCuts(process)
1313 
1314 
1319  genJA = GenJetAdder()
1320  if runOnMC:
1321 
1324  process = AddVariablesForAK8GenJets(process)
1325 
1328  process = AddNewAK8GenJetsForJEC(process, genJA)
1329 
1332  process = ModifyAK4JetMCTable(process)
1333 
1336  process = ReclusterAK4GenJets(process, genJA)
1337  process = AddVariablesForAK4GenJets(process)
1338 
1341  for jetConfig in config_genjets:
1342  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1343  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1344  AddNewGenJets(process, genJetInfo)
1345 
1346 
1351  recoJA = RecoJetAdder(runOnMC=runOnMC)
1352 
1355  process = AddVariablesForAK8PuppiJets(process)
1356 
1359  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1360 
1363  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1364 
1367  process = ReclusterAK4PuppiJets(process, recoJA, runOnMC)
1368 
1371  for jetConfig in config_recojets:
1372  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1373  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1374  AddNewPatJets(process, recoJetInfo, runOnMC)
1375 
1376 
1381  def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1382  if addAK4CHSJetTasks:
1383  proc.nanoTableTaskCommon.add(proc.jetTask)
1384  proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1385  proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1386  if addAK4PuppiJetTasks:
1387  proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1388  proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1389  proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1390  return proc
1391 
1392  jmeNano_addAK4JetTasks_switch = cms.PSet(
1393  jmeNano_addAK4CHS_switch = cms.untracked.bool(True),
1394  jmeNano_addAK4Puppi_switch = cms.untracked.bool(False)
1395  )
1396  run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1397  jmeNano_addAK4CHS_switch = False,
1398  jmeNano_addAK4Puppi_switch = True
1399  )
1400  process = addAK4JetTasks(process,
1401  addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1402  addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1403  )
1404 
1405 
1408  if runOnMC:
1409  process.puTable.savePtHatMax = True
1410 
1411 
1414  if runOnMC:
1415  process.genWeightsTable.keepAllPSWeights = True
1416 
1417  return process
1418 
1419 
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def RemoveAllJetPtCuts(proc)
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)
def PrepJMECustomNanoAOD(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 815 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

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

References print().

Referenced by PrepJMECustomNanoAOD().

1163 def ReclusterAK4GenJets(proc, genJA):
1164  """
1165  Recluster AK4 Gen jets and replace
1166  slimmedGenJets that is used as default
1167  to save AK4 Gen jets in NanoAODs.
1168  """
1169  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1170 
1171  #
1172  # Recluster AK4 Gen jet
1173  #
1174  cfg = {
1175  "jet" : "ak4gen",
1176  "minPtFastjet" : 5.
1177  }
1178  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1179 
1180  genJetName = genJetInfo.jetUpper
1181  genJetAlgo = genJetInfo.jetAlgo
1182  genJetSize = genJetInfo.jetSize
1183  genJetSizeNr = genJetInfo.jetSizeNr
1184  selectedGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1185 
1186  #
1187  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
1188  # to be stored in the GenJet Table
1189  #
1190  proc.genJetTable.src = selectedGenJets
1191  proc.genJetTable.cut = "" # No cut specified here. Save all gen jets after clustering
1192  proc.genJetTable.doc = "AK4 Gen jets (made with visible genparticles) with pt > 5 GeV"
1193 
1194  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1195  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1196  jets = proc.genJetTable.src,
1197  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1198  rParam = genJetSizeNr,
1199  )
1200  )
1201  proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1202  return proc
1203 
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 649 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

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

◆ RecomputePuppiMET()

def custom_jme_cff.RecomputePuppiMET (   proc)
Recompute PuppiMET. This is useful when puppi weights are recomputed.

Definition at line 1275 of file custom_jme_cff.py.

References runMETCorrectionsAndUncertainties.runMetCorAndUncFromMiniAOD().

Referenced by RecomputePuppiWeightsAndMET().

1275 def RecomputePuppiMET(proc):
1276  """
1277  Recompute PuppiMET. This is useful when puppi weights are recomputed.
1278  """
1279  runOnMC=True
1280  if hasattr(proc,"NANOEDMAODoutput") or hasattr(proc,"NANOAODoutput"):
1281  runOnMC = False
1282 
1283  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
1284  runMetCorAndUncFromMiniAOD(proc, isData=not(runOnMC),
1285  jetCollUnskimmed='updatedJetsPuppi',metType='Puppi',postfix='Puppi',jetFlavor='AK4PFPuppi',
1286  puppiProducerLabel='packedpuppi',puppiProducerForMETLabel='packedpuppiNoLep',
1287  recoMetFromPFCs=True
1288  )
1289  return proc
1290 
def runMetCorAndUncFromMiniAOD(process, metType="PF", jetCollUnskimmed="slimmedJets", photonColl="slimmedPhotons", electronColl="slimmedElectrons", muonColl="slimmedMuons", tauColl="slimmedTaus", pfCandColl="packedPFCandidates", jetFlavor="AK4PFchs", jetCleaning="LepClean", isData=False, manualJetConfig=False, reclusterJets=None, jetSelection="pt>15 && abs(eta)<9.9", recoMetFromPFCs=None, jetCorLabelL3="ak4PFCHSL1FastL2L3Corrector", jetCorLabelRes="ak4PFCHSL1FastL2L3ResidualCorrector", CHS=False, puppiProducerLabel="puppi", puppiProducerForMETLabel="puppiNoLep", reapplyJEC=True, jecUncFile="", computeMETSignificance=True, fixEE2017=False, fixEE2017Params=None, extractDeepMETs=False, campaign="", era="", postfix="")
def RecomputePuppiMET(proc)

◆ RecomputePuppiWeights()

def custom_jme_cff.RecomputePuppiWeights (   proc)
Setup packedpuppi and packedpuppiNoLep to recompute puppi weights

Definition at line 1265 of file custom_jme_cff.py.

Referenced by RecomputePuppiWeightsAndMET().

1265 def RecomputePuppiWeights(proc):
1266  """
1267  Setup packedpuppi and packedpuppiNoLep to recompute puppi weights
1268  """
1269  if hasattr(proc,"packedpuppi"):
1270  proc.packedpuppi.useExistingWeights = False
1271  if hasattr(proc,"packedpuppiNoLep"):
1272  proc.packedpuppiNoLep.useExistingWeights = False
1273  return proc
1274 
def RecomputePuppiWeights(proc)

◆ RecomputePuppiWeightsAndMET()

def custom_jme_cff.RecomputePuppiWeightsAndMET (   proc)
Recompute Puppi weights PuppiMET.

Definition at line 1291 of file custom_jme_cff.py.

References RecomputePuppiMET(), and RecomputePuppiWeights().

1291 def RecomputePuppiWeightsAndMET(proc):
1292  """
1293  Recompute Puppi weights PuppiMET.
1294  """
1295  proc = RecomputePuppiWeights(proc)
1296  proc = RecomputePuppiMET(proc)
1297  return proc
1298 
1299 #===========================================================================
1300 #
1301 # CUSTOMIZATION function
1302 #
1303 #===========================================================================
def RecomputePuppiWeightsAndMET(proc)
def RecomputePuppiWeights(proc)
def RecomputePuppiMET(proc)

◆ RemoveAllJetPtCuts()

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

Definition at line 1250 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1250 def RemoveAllJetPtCuts(proc):
1251  """
1252  Remove default pt cuts for all jets set in jets_cff.py
1253  """
1254 
1255  proc.finalJets.cut = "" # 15 -> 10
1256  proc.finalJetsPuppi.cut = "" # 15 -> 10
1257  proc.finalJetsAK8.cut = "" # 170 -> 170
1258  proc.genJetTable.cut = "" # 10 -> 8
1259  proc.genJetFlavourTable.cut = "" # 10 -> 8
1260  proc.genJetAK8Table.cut = "" # 100 -> 80
1261  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
1262 
1263  return proc
1264 
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 1120 of file custom_jme_cff.py.

Referenced by AddNewAK8GenJetsForJEC(), and AddNewGenJets().

1120 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1121  """
1122  Schedule modules for a given genJet collection and save its variables into custom NanoAOD
1123  """
1124 
1125  genJetTableName = "jet{}Table".format(genJetName)
1126  setattr(proc, genJetTableName, genJetTable.clone(
1127  src = genJetFinalColl,
1128  cut = "", # No cut specified here. Save all gen jets after clustering
1129  name = genJetTablePrefix,
1130  doc = genJetTableDoc,
1131  variables = GENJETVARS
1132  )
1133  )
1134 
1135  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1136  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1137  jets = getattr(proc,genJetTableName).src,
1138  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1139  rParam = genJetSizeNr,
1140  )
1141  )
1142 
1143  genJetFlavourTableName = "genJet{}FlavourTable".format(genJetName)
1144  setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1145  name = getattr(proc,genJetTableName).name,
1146  src = getattr(proc,genJetTableName).src,
1147  cut = getattr(proc,genJetTableName).cut,
1148  jetFlavourInfos = genJetFlavourAssociationName,
1149  )
1150  )
1151 
1152  genJetTaskName = "genJet{}Task".format(genJetName)
1153  setattr(proc, genJetTaskName, cms.Task(
1154  getattr(proc,genJetTableName),
1155  getattr(proc,genJetFlavourAssociationName),
1156  getattr(proc,genJetFlavourTableName)
1157  )
1158  )
1159  proc.jetMCTask.add(getattr(proc,genJetTaskName))
1160 
1161  return proc
1162 
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 505 of file custom_jme_cff.py.

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

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

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

◆ btagUParTAK4B

custom_jme_cff.btagUParTAK4B

Definition at line 202 of file custom_jme_cff.py.

◆ btagUParTAK4CvB

custom_jme_cff.btagUParTAK4CvB

Definition at line 204 of file custom_jme_cff.py.

◆ btagUParTAK4CvL

custom_jme_cff.btagUParTAK4CvL

Definition at line 203 of file custom_jme_cff.py.

◆ btagUParTAK4QvG

custom_jme_cff.btagUParTAK4QvG

Definition at line 205 of file custom_jme_cff.py.

◆ btagUParTAK4TauVJet

custom_jme_cff.btagUParTAK4TauVJet

Definition at line 206 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 220 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 212 of file custom_jme_cff.py.

◆ particleNetAK4_CvsB

custom_jme_cff.particleNetAK4_CvsB

Definition at line 214 of file custom_jme_cff.py.

◆ particleNetAK4_CvsL

custom_jme_cff.particleNetAK4_CvsL

Definition at line 213 of file custom_jme_cff.py.

◆ particleNetAK4_G

custom_jme_cff.particleNetAK4_G

Definition at line 216 of file custom_jme_cff.py.

◆ particleNetAK4_puIdDisc

custom_jme_cff.particleNetAK4_puIdDisc

Definition at line 217 of file custom_jme_cff.py.

◆ particleNetAK4_QvsG

custom_jme_cff.particleNetAK4_QvsG

Definition at line 215 of file custom_jme_cff.py.

◆ PARTICLENETAK4VARS

custom_jme_cff.PARTICLENETAK4VARS

Definition at line 211 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.

◆ UNIFIEDPARTAK4VARS

custom_jme_cff.UNIFIEDPARTAK4VARS

Definition at line 201 of file custom_jme_cff.py.

◆ UParTAK4RegPtRawCorr

custom_jme_cff.UParTAK4RegPtRawCorr

Definition at line 207 of file custom_jme_cff.py.

◆ UParTAK4RegPtRawCorrNeutrino

custom_jme_cff.UParTAK4RegPtRawCorrNeutrino

Definition at line 208 of file custom_jme_cff.py.

◆ UParTAK4RegPtRawRes

custom_jme_cff.UParTAK4RegPtRawRes

Definition at line 209 of file custom_jme_cff.py.