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 AddVariablesForAK4GenJets (proc)
 
def AddVariablesForAK8GenJets (proc)
 
def AddVariablesForAK8PuppiJets (proc)
 
def PrepJMECustomNanoAOD (process, runOnMC)
 
def PrepJMECustomNanoAOD_Data (process)
 
def PrepJMECustomNanoAOD_MC (process)
 
def ReclusterAK4CHSJets (proc, recoJA, runOnMC)
 
def ReclusterAK4GenJets (proc, genJA)
 
def ReclusterAK4PuppiJets (proc, recoJA, runOnMC)
 
def RemoveAllJetPtCuts (proc)
 
def SaveGenJets (proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
 
def SavePatJets (proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
 

Variables

 area
 
 bTagCSVV2
 
 btagCSVV2
 
 btagDDX
 
 btagDDXV2
 
 btagDeepB
 
 bTagDeepCSV
 
 btagDeepCvB
 
 btagDeepCvL
 
 btagDeepFlavB
 
 btagDeepFlavC
 
 btagDeepFlavCvB
 
 btagDeepFlavCvL
 
 btagDeepFlavG
 
 btagDeepFlavQG
 
 btagDeepFlavUDS
 
 bTagDeepJet
 
 bTagDiscriminatorsForAK4
 
 btagHbb
 
 BTAGVARS
 
 CALOJETVARS
 
 chEmEF
 
 chHEF
 
 config_genjets
 
 config_recojets
 
 DEEPJETVARS
 
 doc
 
 emf
 
 float
 
 GENJETVARS
 
 hfEmEF
 
 hfHEF
 
 int
 
 muEF
 
 nanoInfo_genjets
 
 nanoInfo_recojets
 
 nConstChHads
 
 nConstElecs
 
 nConstHFEMs
 
 nConstHFHads
 
 nConstituents
 
 nConstMuons
 
 nConstNeuHads
 
 nConstPhotons
 
 neEmEF
 
 neHEF
 
 nElectrons
 
 nMuons
 
 particleNetAK4_B
 
 particleNetAK4_CvsB
 
 particleNetAK4_CvsL
 
 particleNetAK4_puIdDisc
 
 particleNetAK4_QvsG
 
 PARTICLENETAK4VARS
 
 PFJETVARS
 
 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
 

Function Documentation

◆ AddBTaggingScores()

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

Definition at line 371 of file custom_jme_cff.py.

Referenced by SavePatJets().

371 def AddBTaggingScores(proc, jetTableName=""):
372  """
373  Store b-tagging scores from various algortihm
374  """
375 
376  getattr(proc, jetTableName).variables.btagDeepB = BTAGVARS.btagDeepB
377  getattr(proc, jetTableName).variables.btagCSVV2 = BTAGVARS.btagCSVV2
378  getattr(proc, jetTableName).variables.btagDeepCvL = BTAGVARS.btagDeepCvL
379  getattr(proc, jetTableName).variables.btagDeepCvB = BTAGVARS.btagDeepCvB
380  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
381  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
382  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
383 
384  return proc
385 
def AddBTaggingScores(proc, jetTableName="")

◆ AddDeepJetGluonLQuarkScores()

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

Definition at line 386 of file custom_jme_cff.py.

Referenced by SavePatJets().

386 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
387  """
388  Store DeepJet raw score in jetTable for gluon and light quark
389  """
390 
391  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
392  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
393  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
394 
395  return proc
396 
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 201 of file custom_jme_cff.py.

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

Referenced by SavePatJets().

201 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
202  """
203  Setup modules to calculate PF jet ID
204  """
205 
206  isPUPPIJet = True if "Puppi" in jetName else False
207 
208  looseJetId = "looseJetId{}".format(jetName)
209  setattr(proc, looseJetId, proc.looseJetId.clone(
210  src = jetSrc,
211  filterParams = proc.looseJetId.filterParams.clone(
212  version = "WINTER16"
213  ),
214  )
215  )
216 
217  tightJetId = "tightJetId{}".format(jetName)
218  setattr(proc, tightJetId, proc.tightJetId.clone(
219  src = jetSrc,
220  filterParams = proc.tightJetId.filterParams.clone(
221  version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
222  ),
223  )
224  )
225 
226  tightJetIdLepVeto = "tightJetIdLepVeto{}".format(jetName)
227  setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
228  src = jetSrc,
229  filterParams = proc.tightJetIdLepVeto.filterParams.clone(
230  version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
231  ),
232  )
233  )
234 
235  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
236  modifier.toModify(getattr(proc, tightJetId).filterParams, version = "WINTER16" )
237  modifier.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version = "WINTER16" )
238  for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
239  modifier.toModify(getattr(proc, tightJetId).filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
240  modifier.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
241  run2_nanoAOD_102Xv1.toModify(getattr(proc, tightJetId).filterParams, version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "") )
242  run2_nanoAOD_102Xv1.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "") )
243 
244  #
245  # Save variables as userInts in each jet
246  #
247  patJetWithUserData = "{}WithUserData".format(jetSrc)
248  getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
249  getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
250  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
251  modifier.toModify(getattr(proc, patJetWithUserData).userInts, looseId = cms.InputTag(looseJetId))
252 
253  #
254  # Specfiy variables in the jetTable to save in NanoAOD
255  #
256  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")
257  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
258  modifier.toModify(getattr(proc, jetTableName).variables, jetId = Var("userInt('tightIdLepVeto')*4+userInt('tightId')*2+userInt('looseId')",int, doc="Jet ID flags bit1 is loose, bit2 is tight, bit3 is tightLepVeto"))
259 
260 
261  getattr(proc,jetTaskName).add(getattr(proc, tightJetId))
262  getattr(proc,jetTaskName).add(getattr(proc, tightJetIdLepVeto))
263 
264  setattr(proc,"_"+jetTaskName+"_2016", getattr(proc,jetTaskName).copy())
265  getattr(proc,"_"+jetTaskName+"_2016").add(getattr(proc, looseJetId))
266  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
267  modifier.toReplaceWith(getattr(proc,jetTaskName), getattr(proc, "_"+jetTaskName+"_2016"))
268 
269  return proc
270 
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
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 1004 of file custom_jme_cff.py.

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

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

References print(), and SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

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

◆ AddNewAK8PuppiJetsForJEC()

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

Definition at line 971 of file custom_jme_cff.py.

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

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

References SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

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

References SavePatJets().

Referenced by PrepJMECustomNanoAOD().

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

Referenced by SavePatJets().

397 def AddParticleNetAK4Scores(proc, jetTableName=""):
398  """
399  Store ParticleNetAK4 scores in jetTable
400  """
401 
402  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
403  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
404  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
405  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
406  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
407 
408  return proc
409 
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 271 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4CHSJets(), ReclusterAK4PuppiJets(), and SavePatJets().

271 def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
272  """
273  Setup modules to calculate pileup jet ID input variables for PF jet
274  """
275 
276  #
277  # Calculate pileup jet ID variables
278  #
279  puJetIdVarsCalculator = "puJetIdCalculator{}".format(jetName)
280  setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
281  jets = jetSrc,
282  vertexes = "offlineSlimmedPrimaryVertices",
283  inputIsCorrected = True,
284  applyJec = False,
285  usePuppi = True if "Puppi" in jetName else False
286  )
287  )
288  getattr(proc,jetTaskName).add(getattr(proc, puJetIdVarsCalculator))
289 
290  #
291  # Get the variables
292  #
293  puJetIDVar = "puJetIDVar{}".format(jetName)
294  setattr(proc, puJetIDVar, cms.EDProducer("PileupJetIDVarProducer",
295  srcJet = cms.InputTag(jetSrc),
296  srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
297  )
298  )
299  getattr(proc,jetTaskName).add(getattr(proc, puJetIDVar))
300 
301  #
302  # Save variables as userFloats and userInts for each jet
303  #
304  patJetWithUserData = "{}WithUserData".format(jetSrc)
305  getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag("{}:dR2Mean".format(puJetIDVar))
306  getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag("{}:majW".format(puJetIDVar))
307  getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag("{}:minW".format(puJetIDVar))
308  getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag("{}:frac01".format(puJetIDVar))
309  getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag("{}:frac02".format(puJetIDVar))
310  getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag("{}:frac03".format(puJetIDVar))
311  getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag("{}:frac04".format(puJetIDVar))
312  getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag("{}:ptD".format(puJetIDVar))
313  getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag("{}:beta".format(puJetIDVar))
314  getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag("{}:pull".format(puJetIDVar))
315  getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag("{}:jetR".format(puJetIDVar))
316  getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag("{}:jetRchg".format(puJetIDVar))
317  getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag("{}:nCharged".format(puJetIDVar))
318 
319  #
320  # Specfiy variables in the jet table to save in NanoAOD
321  #
322  getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
323  getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
324  getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
325  getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
326  getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
327  getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
328  getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
329  getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
330  getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
331  getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
332  getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
333  getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
334  getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
335 
336  return proc
337 
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 338 of file custom_jme_cff.py.

References PVValHelper.add().

Referenced by ReclusterAK4PuppiJets(), and SavePatJets().

338 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
339  """
340  Schedule the QGTagger module to calculate input variables to the QG likelihood
341  """
342 
343  QGLTagger="qgtagger{}".format(jetName)
344  patJetWithUserData="{}WithUserData".format(jetSrc)
345 
346  if calculateQGLVars:
347  setattr(proc, QGLTagger, qgtagger.clone(
348  srcJets = jetSrc
349  )
350  )
351 
352  #
353  # Save variables as userFloats and userInts for each jet
354  #
355  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
356  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
357  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
358 
359  #
360  # Specfiy variables in the jet table to save in NanoAOD
361  #
362  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
363  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
364  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
365 
366  if calculateQGLVars:
367  getattr(proc,jetTaskName).add(getattr(proc, QGLTagger))
368 
369  return proc
370 
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ AddVariablesForAK4GenJets()

def custom_jme_cff.AddVariablesForAK4GenJets (   proc)

Definition at line 1196 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

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

◆ AddVariablesForAK8GenJets()

def custom_jme_cff.AddVariablesForAK8GenJets (   proc)

Definition at line 1200 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

1200 def AddVariablesForAK8GenJets(proc):
1201  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1202  return proc
1203 
1204 #===========================================================================
1205 #
1206 # Misc. functions
1207 #
1208 #===========================================================================
def AddVariablesForAK8GenJets(proc)

◆ AddVariablesForAK8PuppiJets()

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

Definition at line 1036 of file custom_jme_cff.py.

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

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

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process,
  runOnMC 
)

Definition at line 1229 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD_Data(), and PrepJMECustomNanoAOD_MC().

1229 def PrepJMECustomNanoAOD(process,runOnMC):
1230 
1231 
1234  process = RemoveAllJetPtCuts(process)
1235 
1236 
1241  genJA = GenJetAdder()
1242  if runOnMC:
1243 
1246  process = AddVariablesForAK8GenJets(process)
1247 
1250  process = AddNewAK8GenJetsForJEC(process, genJA)
1251 
1254  process = ReclusterAK4GenJets(process, genJA)
1255  process = AddVariablesForAK4GenJets(process)
1256 
1259  for jetConfig in config_genjets:
1260  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1261  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1262  AddNewGenJets(process, genJetInfo)
1263 
1264 
1269  recoJA = RecoJetAdder(runOnMC=runOnMC)
1270 
1273  process = AddVariablesForAK8PuppiJets(process)
1274 
1277  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1278 
1281  process = AddNewAK8CHSJets(process, recoJA, runOnMC)
1282 
1285  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1286 
1289  process = ReclusterAK4PuppiJets(process, recoJA, runOnMC)
1290 
1293  for jetConfig in config_recojets:
1294  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1295  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1296  AddNewPatJets(process, recoJetInfo, runOnMC)
1297 
1298 
1303  def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1304  if addAK4CHSJetTasks:
1305  proc.nanoTableTaskCommon.add(proc.jetTask)
1306  proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1307  proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1308  if addAK4PuppiJetTasks:
1309  proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1310  proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1311  proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1312  return proc
1313 
1314  jmeNano_addAK4JetTasks_switch = cms.PSet(
1315  jmeNano_addAK4CHS_switch = cms.untracked.bool(True),
1316  jmeNano_addAK4Puppi_switch = cms.untracked.bool(False)
1317  )
1318  run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1319  jmeNano_addAK4CHS_switch = False,
1320  jmeNano_addAK4Puppi_switch = True
1321  )
1322  process = addAK4JetTasks(process,
1323  addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1324  addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1325  )
1326 
1327 
1330  if runOnMC:
1331  process.puTable.savePtHatMax = True
1332 
1333 
1336  if runOnMC:
1337  process.genWeightsTable.keepAllPSWeights = True
1338 
1339  return process
1340 
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def RemoveAllJetPtCuts(proc)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def ReclusterAK4GenJets(proc, genJA)
def AddNewAK8CHSJets(proc, recoJA, runOnMC)
def AddNewAK8GenJetsForJEC(proc, genJA)
def ReclusterAK4PuppiJets(proc, recoJA, runOnMC)
def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC)
def AddNewGenJets(proc, genJetInfo)
def AddVariablesForAK4GenJets(proc)
def AddVariablesForAK8PuppiJets(proc)
def AddVariablesForAK8GenJets(proc)

◆ PrepJMECustomNanoAOD_Data()

def custom_jme_cff.PrepJMECustomNanoAOD_Data (   process)

Definition at line 1349 of file custom_jme_cff.py.

References nano_cff.nanoAOD_customizeV10(), and PrepJMECustomNanoAOD().

1349 def PrepJMECustomNanoAOD_Data(process):
1350  process = nanoAOD_customizeV10(process)
1351  process = PrepJMECustomNanoAOD(process,runOnMC=False)
1352  return process
1353 
def PrepJMECustomNanoAOD(process, runOnMC)
def nanoAOD_customizeV10(process)
Definition: nano_cff.py:6
def PrepJMECustomNanoAOD_Data(process)

◆ PrepJMECustomNanoAOD_MC()

def custom_jme_cff.PrepJMECustomNanoAOD_MC (   process)

Definition at line 1343 of file custom_jme_cff.py.

References nano_cff.nanoAOD_customizeV10(), and PrepJMECustomNanoAOD().

1343 def PrepJMECustomNanoAOD_MC(process):
1344  process = nanoAOD_customizeV10(process)
1345  process = PrepJMECustomNanoAOD(process,runOnMC=True)
1346 
1347  return process
1348 
def PrepJMECustomNanoAOD(process, runOnMC)
def nanoAOD_customizeV10(process)
Definition: nano_cff.py:6
def PrepJMECustomNanoAOD_MC(process)

◆ ReclusterAK4CHSJets()

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

Definition at line 732 of file custom_jme_cff.py.

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

Referenced by PrepJMECustomNanoAOD().

732 def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
733  """
734  Recluster AK4 CHS jets and replace slimmedJets that is used as default to
735  save AK4 CHS jets in NanoAODs (for Run-2).
736  """
737  print("custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
738 
739  #
740  # Recluster AK4 CHS jets
741  #
742  cfg = {
743  "jet" : "ak4pfchs",
744  "inputCollection" : "",
745  "genJetsCollection": "AK4GenJetsNoNu",
746  "bTagDiscriminators": bTagDiscriminatorsForAK4,
747  "minPtFastjet" : 0.,
748  }
749  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
750 
751  jetName = recoJetInfo.jetUpper
752  patJetFinalColl = recoJetInfo.patJetFinalCollection
753 
754  #
755  # Change the input jet source for jetCorrFactorsNano
756  # and updatedJets
757  #
758  proc.jetCorrFactorsNano.src=patJetFinalColl
759  proc.updatedJets.jetSource=patJetFinalColl
760 
761  #
762  # Change pt cut
763  #
764  finalJetsCut = ""
765  if runOnMC:
766  finalJetsCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
767  else:
768  finalJetsCut = "(pt >= 8)"
769 
770  proc.finalJets.cut = finalJetsCut
771  #
772  # Add a minimum pt cut for corrT1METJets.
773  #
774  proc.corrT1METJetTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
775 
776  #
777  # Jet table cut
778  #
779  jetTableCut = "" # must not have any cut at the jetTable for AK4 CHS as it has been cross-cleaned
780  proc.jetTable.src = cms.InputTag("finalJets")
781  proc.jetTable.cut = jetTableCut
782  proc.jetMCTable.cut = jetTableCut
783  proc.jetTable.name = "JetCHS"
784 
785  #
786  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
787  #
788  run2_nanoAOD_ANY.toModify(proc.jetTable,
789  src = cms.InputTag("linkedObjects","jets"),
790  name = "Jet"
791  )
792 
793  #
794  # Jet table documentation
795  #
796  jetTableDoc = "AK4 PF CHS jets with JECs applied. Jets with pt >= 8 GeV are stored."
797  if runOnMC:
798  jetTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
799  proc.jetTable.doc = jetTableDoc
800 
801  proc.jetTable.variables.rawFactor.precision = 10
802 
803  #
804  # Add variables
805  #
806  proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
807  proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
808  proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
809  proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
810  proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
811  proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
812  proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
813  proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
814  proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
815 
816  #
817  # Setup pileup jet ID with 80X training.
818  #
819  pileupJetId80X = "pileupJetId80X"
820  setattr(proc, pileupJetId80X, pileupJetId.clone(
821  jets = "updatedJets",
822  algos = cms.VPSet(_chsalgos_81x),
823  inputIsCorrected = True,
824  applyJec = False,
825  vertexes = "offlineSlimmedPrimaryVertices"
826  )
827  )
828  _jetUserDataTask = proc.jetUserDataTask.copy()
829  _jetUserDataTask.add(getattr(proc,pileupJetId80X))
830  for modifier in run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1:
831  modifier.toReplaceWith(proc.jetUserDataTask, _jetUserDataTask)
832  modifier.toModify(proc.updatedJetsWithUserData.userInts, puId80XfullId = cms.InputTag('pileupJetId80X:fullId'))
833  modifier.toModify(proc.jetTable.variables, puId = Var("userInt('puId80XfullId')", int, doc="Pileup ID flags with 80X (2016) training"))
834  run2_nanoAOD_94X2016.toModify(proc.updatedJetsWithUserData.userFloats, puId80XDisc = cms.InputTag("pileupJetId80X:fullDiscriminant"))
835  run2_nanoAOD_94X2016.toModify(proc.jetTable.variables, puIdDisc = Var("userFloat('puId80XDisc')",float,doc="Pilup ID discriminant with 80X (2016) training",precision=10))
836 
837  #
838  # Add charged energy fraction from other primary vertices
839  #
840  proc.updatedJetsWithUserData.userFloats.chFPV1EF = cms.InputTag("jercVars:chargedFromPV1EnergyFraction")
841  proc.updatedJetsWithUserData.userFloats.chFPV2EF = cms.InputTag("jercVars:chargedFromPV2EnergyFraction")
842  proc.updatedJetsWithUserData.userFloats.chFPV3EF = cms.InputTag("jercVars:chargedFromPV3EnergyFraction")
843  proc.jetTable.variables.chFPV1EF = Var("userFloat('chFPV1EF')", float, doc="charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
844  proc.jetTable.variables.chFPV2EF = Var("userFloat('chFPV2EF')", float, doc="charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
845  proc.jetTable.variables.chFPV3EF = Var("userFloat('chFPV3EF')", float, doc="charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
846 
847  #
848  # Add variables for pileup jet ID studies.
849  #
850  proc = AddPileUpJetIDVars(proc,
851  jetName = jetName,
852  jetSrc = "updatedJets",
853  jetTableName = "jetTable",
854  jetTaskName = "jetTask"
855  )
856  #
857  # Add variables for quark guon likelihood tagger studies.
858  # Save variables as userFloats and userInts in each jet
859  #
860  proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag("qgtagger:axis2")
861  proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag("qgtagger:ptD")
862  proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag("qgtagger:mult")
863  #
864  # Save quark gluon likelihood input variables variables
865  #
866  proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
867  proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
868  proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
869  #
870  # Save standard b-tagging and c-tagging variables
871  #
872  proc.jetTable.variables.btagDeepB = BTAGVARS.btagDeepB
873  proc.jetTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
874  proc.jetTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
875  proc.jetTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
876  #
877  # Save DeepJet b-tagging and c-tagging variables
878  #
879  proc.jetTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
880  proc.jetTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
881  proc.jetTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
882  #
883  # Save DeepJet raw score for gluon and light quarks
884  #
885  proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
886  proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
887  proc.jetTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
888  #
889  # Add ParticleNetAK4 scores
890  #
891  proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
892  proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
893  proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
894  proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
895  proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
896 
897  #Adding hf shower shape producer to the jet sequence. By default this producer is not automatically rerun at the NANOAOD step
898  #The following lines make sure it is.
899  hfJetShowerShapeforCustomNanoAOD = "hfJetShowerShapeforCustomNanoAOD"
900  setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShapeforNanoAOD.clone(jets="updatedJets",vertices="offlineSlimmedPrimaryVertices") )
901  proc.jetUserDataTask.add(getattr(proc, hfJetShowerShapeforCustomNanoAOD))
902  proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
903  proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
904  proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
905  proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
906  proc.jetTable.variables.hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
907  proc.jetTable.variables.hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
908  proc.jetTable.variables.hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) ")
909  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) ")
910 
911  #
912  # Since AK4 Puppi jet is the main AK4 jet collection for Run-3, disable
913  # b-jets/c-jets NN-based mass regression for AK4 CHS.
914  #
915  _jetUserDataTask = proc.jetUserDataTask.copyAndExclude([proc.bJetVars])
916  (~run2_nanoAOD_ANY).toReplaceWith(proc.jetUserDataTask, _jetUserDataTask)
917 
918  _jetTablesTask = proc.jetTablesTask.copyAndExclude([proc.bjetNN, proc.cjetNN])
919  (~run2_nanoAOD_ANY).toReplaceWith(proc.jetTablesTask, _jetTablesTask)
920 
921  (~run2_nanoAOD_ANY).toModify(proc.updatedJetsWithUserData.userFloats,
922  leadTrackPt = None,
923  leptonPtRel = None,
924  leptonPtRatio = None,
925  leptonPtRelInv = None,
926  leptonPtRelv0 = None,
927  leptonPtRatiov0 = None,
928  leptonPtRelInvv0 = None,
929  leptonDeltaR = None,
930  leptonPt = None,
931  vtxPt = None,
932  vtxMass = None,
933  vtx3dL = None,
934  vtx3deL = None,
935  ptD = None,
936  genPtwNu = None
937  )
938 
939  (~run2_nanoAOD_ANY).toModify(proc.updatedJetsWithUserData.userInts,
940  vtxNtrk = None,
941  leptonPdgId = None
942  )
943 
944  (~run2_nanoAOD_ANY).toModify(proc.jetTable, externalVariables = cms.PSet())
945 
946  #
947  # For Run-3, don't need to save the low pt AK4 CHS jet table for MET
948  #
949  _jetForMETTask = proc.jetForMETTask.copyAndExclude([proc.corrT1METJetTable])
950  (~run2_nanoAOD_ANY).toReplaceWith(proc.jetForMETTask, _jetForMETTask)
951 
952  #
953  # Save MC-only jet variables in jet table
954  #
955  if runOnMC:
956  jetMCTableName = "jet{}MCTable".format(jetName)
957  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
958  src = proc.jetTable.src,
959  name = proc.jetTable.name
960  )
961  )
962  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
963  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
964 
965  _nanoTableTaskFS = proc.nanoTableTaskFS.copy()
966  _nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
967  (~run2_nanoAOD_ANY).toReplaceWith(proc.nanoTableTaskFS, _nanoTableTaskFS)
968 
969  return proc
970 
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")

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

References print().

Referenced by PrepJMECustomNanoAOD().

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

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

Referenced by PrepJMECustomNanoAOD().

579 def ReclusterAK4PuppiJets(proc, recoJA, runOnMC):
580  """
581  Recluster AK4 Puppi jets and replace slimmedJetsPuppi
582  that is used as default to save AK4 Puppi jets in NanoAODs.
583  """
584  print("custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
585 
586  #
587  # Recluster AK4 Puppi jets
588  #
589  cfg = {
590  "jet" : "ak4pfpuppi",
591  "inputCollection" : "",
592  "genJetsCollection": "AK4GenJetsNoNu",
593  "bTagDiscriminators": bTagDiscriminatorsForAK4,
594  "minPtFastjet" : 0.,
595  }
596  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
597 
598  jetName = recoJetInfo.jetUpper
599  patJetFinalColl = recoJetInfo.patJetFinalCollection
600 
601  #
602  # Change the input jet source for jetCorrFactorsNano
603  # and updatedJets
604  #
605  proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
606  proc.updatedJetsPuppi.jetSource=patJetFinalColl
607 
608  #
609  # Change pt cut
610  #
611  finalJetsPuppiCut = ""
612  if runOnMC:
613  finalJetsPuppiCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
614  else:
615  finalJetsPuppiCut = "(pt >= 8)"
616 
617  proc.finalJetsPuppi.cut = finalJetsPuppiCut
618  #
619  # Add a minimum pt cut for corrT1METJets.
620  #
621  proc.corrT1METJetPuppiTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
622 
623  #
624  # Jet table
625  #
626  # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
627  run2_nanoAOD_ANY.toModify(proc.jetTable, name = "Jet")
628  # So need to change the table name for AK4 puppi here
629  run2_nanoAOD_ANY.toModify(proc.jetPuppiTable,
630  name = "JetPuppi",
631  src = cms.InputTag("finalJetsPuppi")
632  )
633 
634  #
635  # Jet table documentation
636  #
637  jetPuppiTableDoc = "AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored."
638  if runOnMC:
639  jetPuppiTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
640  proc.jetPuppiTable.doc = jetPuppiTableDoc
641 
642  proc.jetPuppiTable.variables.rawFactor.precision = 10
643 
644  #
645  # Add variables
646  #
647  proc.jetPuppiTable.variables.hfHEF = PFJETVARS.hfHEF
648  proc.jetPuppiTable.variables.hfEmEF = PFJETVARS.hfEmEF
649  proc.jetPuppiTable.variables.nConstChHads = PFJETVARS.nConstChHads
650  proc.jetPuppiTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
651  proc.jetPuppiTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
652  proc.jetPuppiTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
653  proc.jetPuppiTable.variables.nConstMuons = PFJETVARS.nConstMuons
654  proc.jetPuppiTable.variables.nConstElecs = PFJETVARS.nConstElecs
655  proc.jetPuppiTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
656 
657  #
658  # Add variables for pileup jet ID studies.
659  #
660 
661  proc = AddPileUpJetIDVars(proc,
662  jetName = jetName,
663  jetSrc = "updatedJetsPuppi",
664  jetTableName = "jetPuppiTable",
665  jetTaskName = "jetPuppiTask"
666  )
667  #
668  # Add variables for quark guon likelihood tagger studies.
669  # Save variables as userFloats and userInts in each jet
670  #
671  proc = AddQGLTaggerVars(proc,
672  jetName = jetName,
673  jetSrc = "updatedJetsPuppi",
674  jetTableName = "jetPuppiTable",
675  jetTaskName = "jetPuppiTask",
676  calculateQGLVars=True
677  )
678  #
679  # Save standard b-tagging and c-tagging variables
680  #
681  proc.jetPuppiTable.variables.btagDeepB = BTAGVARS.btagDeepB
682  proc.jetPuppiTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
683  proc.jetPuppiTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
684  proc.jetPuppiTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
685  #
686  # Save DeepJet b-tagging and c-tagging variables
687  #
688  proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
689  proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
690  proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
691  #
692  # Save DeepJet raw score for gluon and light quarks
693  #
694  proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
695  proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
696  proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
697  #
698  # Add ParticleNetAK4 scores
699  #
700  proc.jetPuppiTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
701  proc.jetPuppiTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
702  proc.jetPuppiTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
703  proc.jetPuppiTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
704  proc.jetPuppiTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
705 
706  #
707  # For Run-2 eras, don't need to save the low pt AK4 Puppi jet table for MET
708  #
709  _jetPuppiForMETTask = proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
710  run2_nanoAOD_ANY.toReplaceWith(proc.jetPuppiForMETTask, _jetPuppiForMETTask)
711 
712  #
713  # Save MC-only jet variables in jet table
714  #
715  if runOnMC:
716 
717  jetMCTableName = "jet{}MCTable".format(jetName)
718  setattr(proc, jetMCTableName, proc.jetMCTable.clone(
719  src = proc.jetPuppiTable.src,
720  name = proc.jetPuppiTable.name
721  )
722  )
723  jetMCTableTaskName = "jet{}MCTablesTask".format(jetName)
724  setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
725 
726  _nanoTableTaskFS = proc.nanoTableTaskFS.copy()
727  _nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
728  run2_nanoAOD_ANY.toReplaceWith(proc.nanoTableTaskFS, _nanoTableTaskFS)
729 
730  return proc
731 
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
def ReclusterAK4PuppiJets(proc, recoJA, runOnMC)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")

◆ RemoveAllJetPtCuts()

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

Definition at line 1209 of file custom_jme_cff.py.

Referenced by PrepJMECustomNanoAOD().

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

Referenced by AddNewAK8GenJetsForJEC(), and AddNewGenJets().

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

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

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

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

◆ btagCSVV2

custom_jme_cff.btagCSVV2

Definition at line 166 of file custom_jme_cff.py.

◆ btagDDX

custom_jme_cff.btagDDX

Definition at line 34 of file custom_jme_cff.py.

◆ btagDDXV2

custom_jme_cff.btagDDXV2

Definition at line 42 of file custom_jme_cff.py.

◆ btagDeepB

custom_jme_cff.btagDeepB

Definition at line 165 of file custom_jme_cff.py.

◆ bTagDeepCSV

custom_jme_cff.bTagDeepCSV

Definition at line 22 of file custom_jme_cff.py.

◆ btagDeepCvB

custom_jme_cff.btagDeepCvB

Definition at line 168 of file custom_jme_cff.py.

◆ btagDeepCvL

custom_jme_cff.btagDeepCvL

Definition at line 167 of file custom_jme_cff.py.

◆ btagDeepFlavB

custom_jme_cff.btagDeepFlavB

Definition at line 171 of file custom_jme_cff.py.

◆ btagDeepFlavC

custom_jme_cff.btagDeepFlavC

Definition at line 172 of file custom_jme_cff.py.

◆ btagDeepFlavCvB

custom_jme_cff.btagDeepFlavCvB

Definition at line 176 of file custom_jme_cff.py.

◆ btagDeepFlavCvL

custom_jme_cff.btagDeepFlavCvL

Definition at line 175 of file custom_jme_cff.py.

◆ btagDeepFlavG

custom_jme_cff.btagDeepFlavG

Definition at line 173 of file custom_jme_cff.py.

◆ btagDeepFlavQG

custom_jme_cff.btagDeepFlavQG

Definition at line 177 of file custom_jme_cff.py.

◆ btagDeepFlavUDS

custom_jme_cff.btagDeepFlavUDS

Definition at line 174 of file custom_jme_cff.py.

◆ bTagDeepJet

custom_jme_cff.bTagDeepJet

Definition at line 23 of file custom_jme_cff.py.

◆ bTagDiscriminatorsForAK4

custom_jme_cff.bTagDiscriminatorsForAK4

Definition at line 28 of file custom_jme_cff.py.

◆ btagHbb

custom_jme_cff.btagHbb

Definition at line 33 of file custom_jme_cff.py.

◆ BTAGVARS

custom_jme_cff.BTAGVARS

Definition at line 164 of file custom_jme_cff.py.

◆ CALOJETVARS

custom_jme_cff.CALOJETVARS

Definition at line 187 of file custom_jme_cff.py.

◆ chEmEF

custom_jme_cff.chEmEF

Definition at line 128 of file custom_jme_cff.py.

◆ chHEF

custom_jme_cff.chHEF

Definition at line 126 of file custom_jme_cff.py.

◆ config_genjets

custom_jme_cff.config_genjets

Definition at line 54 of file custom_jme_cff.py.

◆ config_recojets

custom_jme_cff.config_recojets

Definition at line 77 of file custom_jme_cff.py.

◆ DEEPJETVARS

custom_jme_cff.DEEPJETVARS

Definition at line 170 of file custom_jme_cff.py.

◆ doc

custom_jme_cff.doc

Definition at line 124 of file custom_jme_cff.py.

◆ emf

◆ float

custom_jme_cff.float

Definition at line 124 of file custom_jme_cff.py.

◆ GENJETVARS

custom_jme_cff.GENJETVARS

Definition at line 120 of file custom_jme_cff.py.

◆ hfEmEF

custom_jme_cff.hfEmEF

Definition at line 132 of file custom_jme_cff.py.

◆ hfHEF

custom_jme_cff.hfHEF

Definition at line 131 of file custom_jme_cff.py.

◆ int

custom_jme_cff.int

Definition at line 136 of file custom_jme_cff.py.

◆ muEF

custom_jme_cff.muEF

Definition at line 130 of file custom_jme_cff.py.

◆ nanoInfo_genjets

custom_jme_cff.nanoInfo_genjets

Definition at line 64 of file custom_jme_cff.py.

◆ nanoInfo_recojets

custom_jme_cff.nanoInfo_recojets

Definition at line 103 of file custom_jme_cff.py.

◆ nConstChHads

custom_jme_cff.nConstChHads

Definition at line 136 of file custom_jme_cff.py.

◆ nConstElecs

custom_jme_cff.nConstElecs

Definition at line 141 of file custom_jme_cff.py.

◆ nConstHFEMs

custom_jme_cff.nConstHFEMs

Definition at line 139 of file custom_jme_cff.py.

◆ nConstHFHads

custom_jme_cff.nConstHFHads

Definition at line 138 of file custom_jme_cff.py.

◆ nConstituents

◆ nConstMuons

custom_jme_cff.nConstMuons

Definition at line 140 of file custom_jme_cff.py.

◆ nConstNeuHads

custom_jme_cff.nConstNeuHads

Definition at line 137 of file custom_jme_cff.py.

◆ nConstPhotons

custom_jme_cff.nConstPhotons

Definition at line 142 of file custom_jme_cff.py.

◆ neEmEF

custom_jme_cff.neEmEF

Definition at line 129 of file custom_jme_cff.py.

◆ neHEF

custom_jme_cff.neHEF

Definition at line 127 of file custom_jme_cff.py.

◆ nElectrons

◆ nMuons

◆ particleNetAK4_B

custom_jme_cff.particleNetAK4_B

Definition at line 180 of file custom_jme_cff.py.

◆ particleNetAK4_CvsB

custom_jme_cff.particleNetAK4_CvsB

Definition at line 182 of file custom_jme_cff.py.

◆ particleNetAK4_CvsL

custom_jme_cff.particleNetAK4_CvsL

Definition at line 181 of file custom_jme_cff.py.

◆ particleNetAK4_puIdDisc

custom_jme_cff.particleNetAK4_puIdDisc

Definition at line 184 of file custom_jme_cff.py.

◆ particleNetAK4_QvsG

custom_jme_cff.particleNetAK4_QvsG

Definition at line 183 of file custom_jme_cff.py.

◆ PARTICLENETAK4VARS

custom_jme_cff.PARTICLENETAK4VARS

Definition at line 179 of file custom_jme_cff.py.

◆ PFJETVARS

custom_jme_cff.PFJETVARS

Definition at line 123 of file custom_jme_cff.py.

◆ precision

custom_jme_cff.precision

Definition at line 124 of file custom_jme_cff.py.

◆ puId_beta

custom_jme_cff.puId_beta

Definition at line 153 of file custom_jme_cff.py.

◆ puId_dR2Mean

custom_jme_cff.puId_dR2Mean

Definition at line 145 of file custom_jme_cff.py.

◆ puId_frac01

custom_jme_cff.puId_frac01

Definition at line 148 of file custom_jme_cff.py.

◆ puId_frac02

custom_jme_cff.puId_frac02

Definition at line 149 of file custom_jme_cff.py.

◆ puId_frac03

custom_jme_cff.puId_frac03

Definition at line 150 of file custom_jme_cff.py.

◆ puId_frac04

custom_jme_cff.puId_frac04

Definition at line 151 of file custom_jme_cff.py.

◆ puId_jetR

custom_jme_cff.puId_jetR

Definition at line 155 of file custom_jme_cff.py.

◆ puId_jetRchg

custom_jme_cff.puId_jetRchg

Definition at line 156 of file custom_jme_cff.py.

◆ puId_majW

custom_jme_cff.puId_majW

Definition at line 146 of file custom_jme_cff.py.

◆ puId_minW

custom_jme_cff.puId_minW

Definition at line 147 of file custom_jme_cff.py.

◆ puId_nCharged

custom_jme_cff.puId_nCharged

Definition at line 157 of file custom_jme_cff.py.

◆ puId_ptD

custom_jme_cff.puId_ptD

Definition at line 152 of file custom_jme_cff.py.

◆ puId_pull

custom_jme_cff.puId_pull

Definition at line 154 of file custom_jme_cff.py.

◆ PUIDVARS

custom_jme_cff.PUIDVARS

Definition at line 144 of file custom_jme_cff.py.

◆ qgl_axis2

custom_jme_cff.qgl_axis2

Definition at line 160 of file custom_jme_cff.py.

◆ qgl_mult

custom_jme_cff.qgl_mult

Definition at line 162 of file custom_jme_cff.py.

◆ qgl_ptD

custom_jme_cff.qgl_ptD

Definition at line 161 of file custom_jme_cff.py.

◆ QGLVARS

custom_jme_cff.QGLVARS

Definition at line 159 of file custom_jme_cff.py.

◆ rawFactor

custom_jme_cff.rawFactor

Definition at line 124 of file custom_jme_cff.py.