CMS 3D CMS Logo

Functions | Variables
custom_jme_cff Namespace Reference

Functions

def AddBTaggingScores (proc, jetTableName="")
 
def AddDeepJetGluonLQuarkScores (proc, jetTableName="")
 
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
 
 btagUParTAK4SvCB
 
 btagUParTAK4SvUDG
 
 btagUParTAK4TauVJet
 
 btagUParTAK4UDG
 
 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 342 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by SavePatJets().

342 def AddBTaggingScores(proc, jetTableName=""):
343  """
344  Store b-tagging scores from various algortihm
345  """
346 
347  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
348  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
349  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
350 
351  run2_nanoAOD_ANY.toModify(
352  getattr(proc, jetTableName).variables,
353  btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
354  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),
355  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),
356  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)
357  )
358 
359  return proc
360 
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 361 of file custom_jme_cff.py.

Referenced by SavePatJets().

361 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
362  """
363  Store DeepJet raw score in jetTable for gluon and light quark
364  """
365 
366  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
367  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
368  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
369 
370  return proc
371 
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")

◆ AddNewAK8CHSJets()

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

Definition at line 986 of file custom_jme_cff.py.

References print(), and SavePatJets().

986 def AddNewAK8CHSJets(proc, recoJA, runOnMC):
987  """
988  Store an AK8 CHS jet collection for JEC studies.
989  """
990  print("custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
991 
992  #
993  # Recluster AK8 CHS jets
994  #
995  cfg = {
996  "jet" : "ak8pfchs",
997  "inputCollection" : "",
998  "genJetsCollection": "AK8GenJetsNoNu",
999  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
1000  }
1001  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1002 
1003  jetName = recoJetInfo.jetUpper
1004  payload = recoJetInfo.jetCorrPayload
1005 
1006  patJetFinalColl = recoJetInfo.patJetFinalCollection
1007  jetTablePrefix = "FatJetCHS"
1008  jetTableDoc = "AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
1009  ptcut = 15
1010 
1011  SavePatJets(proc,
1012  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
1013  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
1014  )
1015 
1016  return proc
1017 
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 1153 of file custom_jme_cff.py.

References print(), and SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1153 def AddNewAK8GenJetsForJEC(proc, genJA):
1154  """
1155  Make a separate AK8 Gen jet collection for JEC studies.
1156  """
1157  print("custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1158 
1159  #
1160  # Recluster AK8 Gen jet
1161  #
1162  cfg = {
1163  "jet" : "ak8gen",
1164  "minPtFastjet" : 10.
1165  }
1166  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1167 
1168  genJetName = genJetInfo.jetUpper
1169  genJetAlgo = genJetInfo.jetAlgo
1170  genJetSize = genJetInfo.jetSize
1171  genJetSizeNr = genJetInfo.jetSizeNr
1172  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1173  genJetTablePrefix = "GenJetAK8ForJEC"
1174  genJetTableDoc = "AK8 Gen jets (made with visible genparticles) with pt > 10 GeV. Reclustered for JEC studies."
1175 
1176  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1177 
1178  return proc
1179 
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 953 of file custom_jme_cff.py.

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

953 def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC):
954  """
955  Store a separate AK8 Puppi jet collection for JEC studies.
956  Only minimal info are stored
957  """
958  print("custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
959 
960  #
961  # Recluster AK8 Puppi jets
962  #
963  cfg = {
964  "jet" : "ak8pfpuppi",
965  "inputCollection" : "",
966  "genJetsCollection": "AK8GenJetsNoNu",
967  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
968  }
969  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
970 
971  jetName = recoJetInfo.jetUpper
972  payload = recoJetInfo.jetCorrPayload
973 
974  patJetFinalColl = recoJetInfo.patJetFinalCollection
975  jetTablePrefix = "FatJetForJEC"
976  jetTableDoc = "AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
977  ptcut = 15
978 
979  SavePatJets(proc,
980  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
981  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
982  )
983 
984  return proc
985 
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 1052 of file custom_jme_cff.py.

References SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

1052 def AddNewGenJets(proc, genJetInfo):
1053  """
1054  Add genJet into custom nanoAOD
1055  """
1056 
1057  genJetName = genJetInfo.jetUpper
1058  genJetAlgo = genJetInfo.jetAlgo
1059  genJetSize = genJetInfo.jetSize
1060  genJetSizeNr = genJetInfo.jetSizeNr
1061  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1062  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
1063  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
1064 
1065  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
1066 
1067  return proc
1068 
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 416 of file custom_jme_cff.py.

References SavePatJets().

Referenced by PrepJMECustomNanoAOD().

416 def AddNewPatJets(proc, recoJetInfo, runOnMC):
417  """
418  Add patJet into custom nanoAOD
419  """
420 
421  jetName = recoJetInfo.jetUpper
422  payload = recoJetInfo.jetCorrPayload
423  doPF = recoJetInfo.doPF
424  doCalo = recoJetInfo.doCalo
425  patJetFinalColl = recoJetInfo.patJetFinalCollection
426 
427  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
428  jetTablePrefix = nanoInfoForJet["name"]
429  jetTableDoc = nanoInfoForJet["doc"]
430  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else 8
431  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
432  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
433  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
434 
435  SavePatJets(proc,
436  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
437  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
438  )
439 
440  return proc
441 
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 402 of file custom_jme_cff.py.

Referenced by SavePatJets().

402 def AddParticleNetAK4Scores(proc, jetTableName=""):
403  """
404  Store ParticleNetAK4 scores in jetTable
405  """
406 
407  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
408  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
409  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
410  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
411  getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
412  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
413 
414  return proc
415 
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 237 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

237 def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
238  """
239  Setup modules to calculate pileup jet ID input variables for PF jet
240  """
241 
242  #
243  # Calculate pileup jet ID variables
244  #
245  puJetIdVarsCalculator = "puJetIdCalculator{}".format(jetName)
246  setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
247  jets = jetSrc,
248  vertexes = "offlineSlimmedPrimaryVertices",
249  inputIsCorrected = True,
250  applyJec = False,
251  srcConstituentWeights = "packedpuppi" if "PUPPI" in jetName.upper() else ""
252  )
253  )
254  getattr(proc,jetTaskName).add(getattr(proc, puJetIdVarsCalculator))
255 
256  #
257  # Get the variables
258  #
259  puJetIDVar = "puJetIDVar{}".format(jetName)
260  setattr(proc, puJetIDVar, cms.EDProducer("PileupJetIDVarProducer",
261  srcJet = cms.InputTag(jetSrc),
262  srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
263  )
264  )
265  getattr(proc,jetTaskName).add(getattr(proc, puJetIDVar))
266 
267  #
268  # Save variables as userFloats and userInts for each jet
269  #
270  patJetWithUserData = "{}WithUserData".format(jetSrc)
271  getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag("{}:dR2Mean".format(puJetIDVar))
272  getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag("{}:majW".format(puJetIDVar))
273  getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag("{}:minW".format(puJetIDVar))
274  getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag("{}:frac01".format(puJetIDVar))
275  getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag("{}:frac02".format(puJetIDVar))
276  getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag("{}:frac03".format(puJetIDVar))
277  getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag("{}:frac04".format(puJetIDVar))
278  getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag("{}:ptD".format(puJetIDVar))
279  getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag("{}:beta".format(puJetIDVar))
280  getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag("{}:pull".format(puJetIDVar))
281  getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag("{}:jetR".format(puJetIDVar))
282  getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag("{}:jetRchg".format(puJetIDVar))
283  getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag("{}:nCharged".format(puJetIDVar))
284 
285  #
286  # Specfiy variables in the jet table to save in NanoAOD
287  #
288  getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
289  getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
290  getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
291  getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
292  getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
293  getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
294  getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
295  getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
296  getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
297  getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
298  getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
299  getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
300  getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
301 
302  return proc
303 
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 304 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

304 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
305  """
306  Schedule the QGTagger module to calculate input variables to the QG likelihood
307  """
308 
309  isPUPPIJet = True if "PUPPI" in jetName.upper() else False
310 
311  QGLTagger="qgtagger{}".format(jetName)
312  patJetWithUserData="{}WithUserData".format(jetSrc)
313 
314  if calculateQGLVars:
315  setattr(proc, QGLTagger, qgtagger.clone(
316  srcJets = jetSrc,
317  computeLikelihood = False,
318  )
319  )
320  if isPUPPIJet:
321  getattr(proc,QGLTagger).srcConstituentWeights = cms.InputTag("packedpuppi")
322 
323  #
324  # Save variables as userFloats and userInts for each jet
325  #
326  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
327  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
328  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
329 
330  #
331  # Specfiy variables in the jet table to save in NanoAOD
332  #
333  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
334  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
335  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
336 
337  if calculateQGLVars:
338  getattr(proc,jetTaskName).add(getattr(proc, QGLTagger))
339 
340  return proc
341 
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 372 of file custom_jme_cff.py.

Referenced by SavePatJets().

372 def AddRobustParTAK4Scores(proc, jetTableName=""):
373  """
374  Store RobustParTAK4 scores in jetTable
375  """
376 
377  getattr(proc, jetTableName).variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
378  getattr(proc, jetTableName).variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
379  getattr(proc, jetTableName).variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
380 
381  return proc
382 
def AddRobustParTAK4Scores(proc, jetTableName="")

◆ AddUnifiedParTAK4Scores()

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

Definition at line 383 of file custom_jme_cff.py.

Referenced by SavePatJets().

383 def AddUnifiedParTAK4Scores(proc, jetTableName=""):
384  """
385  Store RobustParTAK4 scores in jetTable
386  """
387 
388  getattr(proc, jetTableName).variables.btagUParTAK4B = UNIFIEDPARTAK4VARS.btagUParTAK4B
389  getattr(proc, jetTableName).variables.btagUParTAK4CvL = UNIFIEDPARTAK4VARS.btagUParTAK4CvL
390  getattr(proc, jetTableName).variables.btagUParTAK4CvB = UNIFIEDPARTAK4VARS.btagUParTAK4CvB
391  getattr(proc, jetTableName).variables.btagUParTAK4SvCB = UNIFIEDPARTAK4VARS.btagUParTAK4SvCB
392  getattr(proc, jetTableName).variables.btagUParTAK4SvUDG = UNIFIEDPARTAK4VARS.btagUParTAK4SvUDG
393  getattr(proc, jetTableName).variables.btagUParTAK4UDG = UNIFIEDPARTAK4VARS.btagUParTAK4UDG
394  getattr(proc, jetTableName).variables.btagUParTAK4QvG = UNIFIEDPARTAK4VARS.btagUParTAK4QvG
395  getattr(proc, jetTableName).variables.btagUParTAK4TauVJet = UNIFIEDPARTAK4VARS.btagUParTAK4TauVJet
396  getattr(proc, jetTableName).variables.UParTAK4RegPtRawCorr = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawCorr
397  getattr(proc, jetTableName).variables.UParTAK4RegPtRawCorrNeutrino = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawCorrNeutrino
398  getattr(proc, jetTableName).variables.UParTAK4RegPtRawRes = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawRes
399 
400  return proc
401 
def AddUnifiedParTAK4Scores(proc, jetTableName="")

◆ AddVariablesForAK4GenJets()

def custom_jme_cff.AddVariablesForAK4GenJets (   proc)

Definition at line 1180 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1180 def AddVariablesForAK4GenJets(proc):
1181  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1182  return proc
1183 
def AddVariablesForAK4GenJets(proc)

◆ AddVariablesForAK8GenJets()

def custom_jme_cff.AddVariablesForAK8GenJets (   proc)

Definition at line 1184 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1184 def AddVariablesForAK8GenJets(proc):
1185  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1186  return proc
1187 
def AddVariablesForAK8GenJets(proc)

◆ AddVariablesForAK8PuppiJets()

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

Definition at line 1018 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

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

Referenced by PrepJMECustomNanoAOD().

1188 def ModifyAK4JetMCTable(proc):
1189  # Remove the genjet pt selection when saving the genJetIdx, which is
1190  # the default in main Nano
1191  proc.jetMCTable.variables.genJetIdx = PFJETVARS.genJetIdx
1192  return proc
1193 
1194 #===========================================================================
1195 #
1196 # Misc. functions
1197 #
1198 #===========================================================================
def ModifyAK4JetMCTable(proc)

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process)

Definition at line 1253 of file custom_jme_cff.py.

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

1253 def PrepJMECustomNanoAOD(process):
1254 
1255  runOnMC=True
1256  if hasattr(process,"NANOEDMAODoutput") or hasattr(process,"NANOAODoutput"):
1257  runOnMC = False
1258 
1261  process = RemoveAllJetPtCuts(process)
1262 
1263 
1268  genJA = GenJetAdder()
1269  if runOnMC:
1270 
1273  process = AddVariablesForAK8GenJets(process)
1274 
1277  process = AddNewAK8GenJetsForJEC(process, genJA)
1278 
1281  process = ModifyAK4JetMCTable(process)
1282 
1285  process = ReclusterAK4GenJets(process, genJA)
1286  process = AddVariablesForAK4GenJets(process)
1287 
1290  for jetConfig in config_genjets:
1291  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1292  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1293  AddNewGenJets(process, genJetInfo)
1294 
1295 
1300  recoJA = RecoJetAdder(runOnMC=runOnMC)
1301 
1304  process = AddVariablesForAK8PuppiJets(process)
1305 
1308  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1309 
1312  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1313 
1316  process = ReclusterAK4PuppiJets(process, recoJA, runOnMC)
1317 
1320  for jetConfig in config_recojets:
1321  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1322  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1323  AddNewPatJets(process, recoJetInfo, runOnMC)
1324 
1325 
1330  def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1331  if addAK4CHSJetTasks:
1332  proc.nanoTableTaskCommon.add(proc.jetTask)
1333  proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1334  proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1335  if addAK4PuppiJetTasks:
1336  proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1337  proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1338  proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1339  return proc
1340 
1341  jmeNano_addAK4JetTasks_switch = cms.PSet(
1342  jmeNano_addAK4CHS_switch = cms.untracked.bool(True),
1343  jmeNano_addAK4Puppi_switch = cms.untracked.bool(False)
1344  )
1345  run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1346  jmeNano_addAK4CHS_switch = False,
1347  jmeNano_addAK4Puppi_switch = True
1348  )
1349  process = addAK4JetTasks(process,
1350  addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1351  addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1352  )
1353 
1354 
1357  if runOnMC:
1358  process.puTable.savePtHatMax = True
1359 
1360 
1363  if runOnMC:
1364  process.genWeightsTable.keepAllPSWeights = True
1365 
1366  return process
1367 
1368 
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 764 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

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

References print().

Referenced by PrepJMECustomNanoAOD().

1112 def ReclusterAK4GenJets(proc, genJA):
1113  """
1114  Recluster AK4 Gen jets and replace
1115  slimmedGenJets that is used as default
1116  to save AK4 Gen jets in NanoAODs.
1117  """
1118  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1119 
1120  #
1121  # Recluster AK4 Gen jet
1122  #
1123  cfg = {
1124  "jet" : "ak4gen",
1125  "minPtFastjet" : 5.
1126  }
1127  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1128 
1129  genJetName = genJetInfo.jetUpper
1130  genJetAlgo = genJetInfo.jetAlgo
1131  genJetSize = genJetInfo.jetSize
1132  genJetSizeNr = genJetInfo.jetSizeNr
1133  selectedGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
1134 
1135  #
1136  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
1137  # to be stored in the GenJet Table
1138  #
1139  proc.genJetTable.src = selectedGenJets
1140  proc.genJetTable.cut = "" # No cut specified here. Save all gen jets after clustering
1141  proc.genJetTable.doc = "AK4 Gen jets (made with visible genparticles) with pt > 5 GeV"
1142 
1143  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1144  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1145  jets = proc.genJetTable.src,
1146  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1147  rParam = genJetSizeNr,
1148  )
1149  )
1150  proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1151  return proc
1152 
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 586 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

586 def ReclusterAK4PuppiJets(proc, recoJA, runOnMC):
587  """
588  Recluster AK4 Puppi jets and replace slimmedJetsPuppi
589  that is used as default to save AK4 Puppi jets in NanoAODs.
590  """
591  print("custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
592 
593  #
594  # Recluster AK4 Puppi jets
595  #
596  cfg = {
597  "jet" : "ak4pfpuppi",
598  "inputCollection" : "",
599  "genJetsCollection": "AK4GenJetsNoNu",
600  "bTagDiscriminators": bTagDiscriminatorsForAK4,
601  "minPtFastjet" : 0.,
602  }
603  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
604 
605  jetName = recoJetInfo.jetUpper
606  patJetFinalColl = recoJetInfo.patJetFinalCollection
607 
608  #
609  # Change the input jet source for jetCorrFactorsNano
610  # and updatedJets
611  #
612  proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
613  proc.updatedJetsPuppi.jetSource=patJetFinalColl
614 
615  #
616  # Change pt cut
617  #
618  finalJetsPuppiCut = ""
619  if runOnMC:
620  finalJetsPuppiCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
621  else:
622  finalJetsPuppiCut = "(pt >= 8)"
623 
624  proc.finalJetsPuppi.cut = finalJetsPuppiCut
625  #
626  # Add a minimum pt cut for corrT1METJets.
627  #
628  proc.corrT1METJetPuppiTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
629 
630  #
631  # Jet table
632  #
633  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
634  run2_nanoAOD_ANY.toModify(
635  proc.jetTable, name = "Jet"
636  ).toModify(
637  # So need to change the table name for AK4 puppi here
638  proc.jetPuppiTable,
639  name = "JetPuppi",
640  src = cms.InputTag("finalJetsPuppi")
641  )
642 
643  #
644  # Jet table documentation
645  #
646  jetPuppiTableDoc = "AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored."
647  if runOnMC:
648  jetPuppiTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
649  proc.jetPuppiTable.doc = jetPuppiTableDoc
650 
651  proc.jetPuppiTable.variables.rawFactor.precision = 10
652 
653  #
654  # Add variables
655  #
656  proc.jetPuppiTable.variables.chHadMultiplicity = PFJETVARS.chHadMultiplicity
657  proc.jetPuppiTable.variables.neHadMultiplicity = PFJETVARS.neHadMultiplicity
658  proc.jetPuppiTable.variables.hfHadMultiplicity = PFJETVARS.hfHadMultiplicity
659  proc.jetPuppiTable.variables.hfEMMultiplicity = PFJETVARS.hfEMMultiplicity
660  proc.jetPuppiTable.variables.muMultiplicity = PFJETVARS.muMultiplicity
661  proc.jetPuppiTable.variables.elMultiplicity = PFJETVARS.elMultiplicity
662  proc.jetPuppiTable.variables.phoMultiplicity = PFJETVARS.phoMultiplicity
663 
664  #
665  # Add Pileup Jet ID for Puppi jets
666  #
667  from RecoJets.JetProducers.PileupJetID_cfi import pileupJetIdPuppi
668  pileupJetIdName = "pileupJetId{}".format(jetName)
669  setattr(proc, pileupJetIdName, pileupJetIdPuppi.clone(
670  jets = "updatedJetsPuppi",
671  srcConstituentWeights = "packedpuppi",
672  vertexes = "offlineSlimmedPrimaryVertices",
673  inputIsCorrected=True,
674  applyJec=False
675  )
676  )
677  proc.jetPuppiTask.add(getattr(proc, pileupJetIdName))
678  proc.updatedJetsPuppiWithUserData.userFloats.puIdDisc = cms.InputTag(pileupJetIdName+':fullDiscriminant')
679  proc.jetPuppiTable.variables.puIdDisc = Var("userFloat('puIdDisc')", float, doc="Pileup ID BDT discriminant with 133X Winter24 PuppiV18 training",precision=10)
680 
681 
682  #
683  # Add variables for pileup jet ID studies.
684  #
685  proc = AddPileUpJetIDVars(proc,
686  jetName = jetName,
687  jetSrc = "updatedJetsPuppi",
688  jetTableName = "jetPuppiTable",
689  jetTaskName = "jetPuppiTask"
690  )
691  #
692  # Add variables for quark guon likelihood tagger studies.
693  # Save variables as userFloats and userInts in each jet
694  #
695  proc = AddQGLTaggerVars(proc,
696  jetName = jetName,
697  jetSrc = "updatedJetsPuppi",
698  jetTableName = "jetPuppiTable",
699  jetTaskName = "jetPuppiTask",
700  calculateQGLVars=True
701  )
702  #
703  # Save DeepJet b-tagging and c-tagging variables
704  #
705  proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
706  proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
707  proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
708  #
709  # Save DeepJet raw score for gluon and light quarks
710  #
711  proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
712  proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
713  proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
714  #
715  # Save RobustParTAK4 b-tagging and c-tagging variables
716  #
717  proc.jetPuppiTable.variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
718  proc.jetPuppiTable.variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
719  proc.jetPuppiTable.variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
720  #
721  # Save UnifiedParTAK4 b-tagging and c-tagging variables
722  #
723  proc.jetPuppiTable.variables.btagUParTAK4B = UNIFIEDPARTAK4VARS.btagUParTAK4B
724  proc.jetPuppiTable.variables.btagUParTAK4CvL = UNIFIEDPARTAK4VARS.btagUParTAK4CvL
725  proc.jetPuppiTable.variables.btagUParTAK4CvB = UNIFIEDPARTAK4VARS.btagUParTAK4CvB
726  proc.jetPuppiTable.variables.btagUParTAK4SvCB = UNIFIEDPARTAK4VARS.btagUParTAK4SvCB
727  proc.jetPuppiTable.variables.btagUParTAK4SvUDG = UNIFIEDPARTAK4VARS.btagUParTAK4SvUDG
728  proc.jetPuppiTable.variables.btagUParTAK4UDG = UNIFIEDPARTAK4VARS.btagUParTAK4UDG
729  proc.jetPuppiTable.variables.btagUParTAK4QvG = UNIFIEDPARTAK4VARS.btagUParTAK4QvG
730  proc.jetPuppiTable.variables.btagUParTAK4TauVJet = UNIFIEDPARTAK4VARS.btagUParTAK4TauVJet
731  proc.jetPuppiTable.variables.UParTAK4RegPtRawCorr = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawCorr
732  proc.jetPuppiTable.variables.UParTAK4RegPtRawCorrNeutrino = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawCorrNeutrino
733  proc.jetPuppiTable.variables.UParTAK4RegPtRawRes = UNIFIEDPARTAK4VARS.UParTAK4RegPtRawRes
734  #
735  # For Run-2 eras, don't need to save the low pt AK4 Puppi jet table for MET
736  #
737  run2_nanoAOD_ANY.toReplaceWith(
738  proc.jetPuppiForMETTask,
739  proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
740  )
741 
742  #
743  # Save MC-only jet variables in jet table
744  #
745  if runOnMC:
746  jetMCTableName = "jet{}MCTable".format(jetName)
747  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
748  src = proc.jetPuppiTable.src,
749  name = proc.jetPuppiTable.name
750  )
751  )
752  getattr(proc,jetMCTableName).variables.genJetIdx = PFJETVARS.genJetIdx
753 
754  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
755  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
756 
757  run2_nanoAOD_ANY.toReplaceWith(
758  proc.nanoTableTaskFS,
759  proc.nanoTableTaskFS.copyAndAdd( getattr(proc,jetMCTableTaskName))
760  )
761 
762  return proc
763 
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
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 1224 of file custom_jme_cff.py.

References runMETCorrectionsAndUncertainties.runMetCorAndUncFromMiniAOD().

Referenced by RecomputePuppiWeightsAndMET().

1224 def RecomputePuppiMET(proc):
1225  """
1226  Recompute PuppiMET. This is useful when puppi weights are recomputed.
1227  """
1228  runOnMC=True
1229  if hasattr(proc,"NANOEDMAODoutput") or hasattr(proc,"NANOAODoutput"):
1230  runOnMC = False
1231 
1232  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
1233  runMetCorAndUncFromMiniAOD(proc, isData=not(runOnMC),
1234  jetCollUnskimmed='updatedJetsPuppi',metType='Puppi',postfix='Puppi',jetFlavor='AK4PFPuppi',
1235  puppiProducerLabel='packedpuppi',puppiProducerForMETLabel='packedpuppiNoLep',
1236  recoMetFromPFCs=True
1237  )
1238  return proc
1239 
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 1214 of file custom_jme_cff.py.

Referenced by RecomputePuppiWeightsAndMET().

1214 def RecomputePuppiWeights(proc):
1215  """
1216  Setup packedpuppi and packedpuppiNoLep to recompute puppi weights
1217  """
1218  if hasattr(proc,"packedpuppi"):
1219  proc.packedpuppi.useExistingWeights = False
1220  if hasattr(proc,"packedpuppiNoLep"):
1221  proc.packedpuppiNoLep.useExistingWeights = False
1222  return proc
1223 
def RecomputePuppiWeights(proc)

◆ RecomputePuppiWeightsAndMET()

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

Definition at line 1240 of file custom_jme_cff.py.

References RecomputePuppiMET(), and RecomputePuppiWeights().

1240 def RecomputePuppiWeightsAndMET(proc):
1241  """
1242  Recompute Puppi weights PuppiMET.
1243  """
1244  proc = RecomputePuppiWeights(proc)
1245  proc = RecomputePuppiMET(proc)
1246  return proc
1247 
1248 #===========================================================================
1249 #
1250 # CUSTOMIZATION function
1251 #
1252 #===========================================================================
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 1199 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1199 def RemoveAllJetPtCuts(proc):
1200  """
1201  Remove default pt cuts for all jets set in jets_cff.py
1202  """
1203 
1204  proc.finalJets.cut = "" # 15 -> 10
1205  proc.finalJetsPuppi.cut = "" # 15 -> 10
1206  proc.finalJetsAK8.cut = "" # 170 -> 170
1207  proc.genJetTable.cut = "" # 10 -> 8
1208  proc.genJetFlavourTable.cut = "" # 10 -> 8
1209  proc.genJetAK8Table.cut = "" # 100 -> 80
1210  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
1211 
1212  return proc
1213 
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 1069 of file custom_jme_cff.py.

Referenced by AddNewAK8GenJetsForJEC(), and AddNewGenJets().

1069 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1070  """
1071  Schedule modules for a given genJet collection and save its variables into custom NanoAOD
1072  """
1073 
1074  genJetTableName = "jet{}Table".format(genJetName)
1075  setattr(proc, genJetTableName, genJetTable.clone(
1076  src = genJetFinalColl,
1077  cut = "", # No cut specified here. Save all gen jets after clustering
1078  name = genJetTablePrefix,
1079  doc = genJetTableDoc,
1080  variables = GENJETVARS
1081  )
1082  )
1083 
1084  genJetFlavourAssociationName = "genJet{}FlavourAssociation".format(genJetName)
1085  setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1086  jets = getattr(proc,genJetTableName).src,
1087  jetAlgorithm = supportedJetAlgos[genJetAlgo],
1088  rParam = genJetSizeNr,
1089  )
1090  )
1091 
1092  genJetFlavourTableName = "genJet{}FlavourTable".format(genJetName)
1093  setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1094  name = getattr(proc,genJetTableName).name,
1095  src = getattr(proc,genJetTableName).src,
1096  cut = getattr(proc,genJetTableName).cut,
1097  jetFlavourInfos = genJetFlavourAssociationName,
1098  )
1099  )
1100 
1101  genJetTaskName = "genJet{}Task".format(genJetName)
1102  setattr(proc, genJetTaskName, cms.Task(
1103  getattr(proc,genJetTableName),
1104  getattr(proc,genJetFlavourAssociationName),
1105  getattr(proc,genJetFlavourTableName)
1106  )
1107  )
1108  proc.jetMCTask.add(getattr(proc,genJetTaskName))
1109 
1110  return proc
1111 
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 443 of file custom_jme_cff.py.

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

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

443  doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
444  """
445  Schedule modules for a given patJet collection and save its variables into custom NanoAOD
446  """
447 
448  #
449  # Setup jet correction factors
450  #
451  jetCorrFactors = "jetCorrFactorsNano{}".format(jetName)
452  setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
453  src = patJetFinalColl,
454  payload = payload,
455  )
456  )
457 
458  #
459  # Update jets
460  #
461  srcJets = "updatedJets{}".format(jetName)
462  setattr(proc, srcJets, updatedJets.clone(
463  jetSource = patJetFinalColl,
464  jetCorrFactorsSource = [jetCorrFactors],
465  )
466  )
467 
468  #
469  # Setup UserDataEmbedder
470  #
471  srcJetsWithUserData = "updatedJets{}WithUserData".format(jetName)
472  setattr(proc, srcJetsWithUserData, cms.EDProducer("PATJetUserDataEmbedder",
473  src = cms.InputTag(srcJets),
474  userFloats = cms.PSet(),
475  userInts = cms.PSet(),
476  )
477  )
478 
479  #
480  # Filter jets with pt cut
481  #
482  finalJetsCut = "(pt >= {ptcut:.0f})".format(ptcut=ptcut)
483  if runOnMC:
484  finalJetsCut = "(pt >= {ptcut:.0f}) || ((pt < {ptcut:.0f}) && (genJetFwdRef().backRef().isNonnull()))".format(ptcut=ptcut)
485 
486  finalJetsForTable = "finalJets{}".format(jetName)
487  setattr(proc, finalJetsForTable, finalJets.clone(
488  src = srcJetsWithUserData,
489  cut = finalJetsCut
490  )
491  )
492 
493  #
494  # Save jets in table
495  #
496  tableContent = PFJETVARS
497  if doCalo:
498  tableContent = CALOJETVARS
499 
500  jetTableCutDefault = "" #Don't apply any cuts for the table.
501 
502  jetTableDocDefault = jetTableDoc + " with JECs applied. Jets with pt >= {ptcut:.0f} GeV are stored.".format(ptcut=ptcut)
503  if runOnMC:
504  jetTableDocDefault += "For jets with pt < {ptcut:.0f} GeV, only those matched to gen jets are stored.".format(ptcut=ptcut)
505 
506  if doCalo:
507  jetTableDocDefault = jetTableDoc
508 
509  jetTableName = "jet{}Table".format(jetName)
510  setattr(proc,jetTableName, simplePATJetFlatTableProducer.clone(
511  src = cms.InputTag(finalJetsForTable),
512  cut = cms.string(jetTableCutDefault),
513  name = cms.string(jetTablePrefix),
514  doc = cms.string(jetTableDocDefault),
515  variables = cms.PSet(tableContent)
516  )
517  )
518  getattr(proc,jetTableName).variables.pt.precision=10
519  getattr(proc,jetTableName).variables.rawFactor.precision=10
520 
521  #
522  # Save MC-only jet variables in table
523  #
524  jetMCTableName = "jet{}MCTable".format(jetName)
525  setattr(proc, jetMCTableName, simplePATJetFlatTableProducer.clone(
526  src = cms.InputTag(finalJetsForTable),
527  cut = getattr(proc,jetTableName).cut,
528  name = cms.string(jetTablePrefix),
529  extension = cms.bool(True), # this is an extension table
530  variables = cms.PSet(
531  partonFlavour = PFJETVARS.partonFlavour,
532  hadronFlavour = PFJETVARS.hadronFlavour,
533  genJetIdx = PFJETVARS.genJetIdx,
534  )
535  )
536  )
537 
538  #
539  # Define the jet modules Task first
540  #
541  jetTaskName = "jet{}Task".format(jetName)
542  setattr(proc, jetTaskName, cms.Task(
543  getattr(proc,jetCorrFactors),
544  getattr(proc,srcJets),
545  getattr(proc,srcJetsWithUserData),
546  getattr(proc,finalJetsForTable)
547  )
548  )
549  proc.nanoTableTaskCommon.add(getattr(proc,jetTaskName))
550 
551  #
552  # Define the jet tables Task
553  #
554  jetTableTaskName = "jet{}TablesTask".format(jetName)
555  setattr(proc, jetTableTaskName, cms.Task(getattr(proc,jetTableName)))
556  proc.nanoTableTaskCommon.add(getattr(proc,jetTableTaskName))
557 
558  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
559  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
560  if runOnMC:
561  proc.nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
562 
563  #
564  # Schedule plugins to calculate Jet ID, PileUp Jet ID input variables, and Quark-Gluon Likehood input variables.
565  #
566  if doPF:
567  if doPUIDVar:
568  proc = AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
569  if doQGL:
570  proc = AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName, calculateQGLVars=True)
571 
572  #
573  # Save b-tagging algorithm scores. Should only be done for jet collection with b-tagging
574  # calculated when reclustered or collection saved with b-tagging info in MiniAOD
575  #
576  if doBTag:
577  AddBTaggingScores(proc,jetTableName=jetTableName)
578  AddDeepJetGluonLQuarkScores(proc,jetTableName=jetTableName)
579  AddParticleNetAK4Scores(proc,jetTableName=jetTableName)
580  AddRobustParTAK4Scores(proc,jetTableName=jetTableName)
581  AddUnifiedParTAK4Scores(proc,jetTableName=jetTableName)
582 
583  return proc
584 
585 
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 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 208 of file custom_jme_cff.py.

◆ btagUParTAK4SvCB

custom_jme_cff.btagUParTAK4SvCB

Definition at line 205 of file custom_jme_cff.py.

◆ btagUParTAK4SvUDG

custom_jme_cff.btagUParTAK4SvUDG

Definition at line 206 of file custom_jme_cff.py.

◆ btagUParTAK4TauVJet

custom_jme_cff.btagUParTAK4TauVJet

Definition at line 209 of file custom_jme_cff.py.

◆ btagUParTAK4UDG

custom_jme_cff.btagUParTAK4UDG

Definition at line 207 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 223 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 215 of file custom_jme_cff.py.

◆ particleNetAK4_CvsB

custom_jme_cff.particleNetAK4_CvsB

Definition at line 217 of file custom_jme_cff.py.

◆ particleNetAK4_CvsL

custom_jme_cff.particleNetAK4_CvsL

Definition at line 216 of file custom_jme_cff.py.

◆ particleNetAK4_G

custom_jme_cff.particleNetAK4_G

Definition at line 219 of file custom_jme_cff.py.

◆ particleNetAK4_puIdDisc

custom_jme_cff.particleNetAK4_puIdDisc

Definition at line 220 of file custom_jme_cff.py.

◆ particleNetAK4_QvsG

custom_jme_cff.particleNetAK4_QvsG

Definition at line 218 of file custom_jme_cff.py.

◆ PARTICLENETAK4VARS

custom_jme_cff.PARTICLENETAK4VARS

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

◆ UParTAK4RegPtRawCorrNeutrino

custom_jme_cff.UParTAK4RegPtRawCorrNeutrino

Definition at line 211 of file custom_jme_cff.py.

◆ UParTAK4RegPtRawRes

custom_jme_cff.UParTAK4RegPtRawRes

Definition at line 212 of file custom_jme_cff.py.