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="", jetSequenceName="")
 
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="", jetSequenceName="")
 
def AddQGLTaggerVars (proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", 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 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 386 of file custom_jme_cff.py.

386 def AddBTaggingScores(proc, jetTableName=""):
387  """
388  Store b-tagging scores from various algortihm
389  """
390 
391  getattr(proc, jetTableName).variables.btagDeepB = BTAGVARS.btagDeepB
392  getattr(proc, jetTableName).variables.btagCSVV2 = BTAGVARS.btagCSVV2
393  getattr(proc, jetTableName).variables.btagDeepCvL = BTAGVARS.btagDeepCvL
394  getattr(proc, jetTableName).variables.btagDeepCvB = BTAGVARS.btagDeepCvB
395  getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
396  getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
397  getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
398 
399  return proc
400 

Referenced by SavePatJets().

◆ AddDeepJetGluonLQuarkScores()

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

Definition at line 401 of file custom_jme_cff.py.

401 def AddDeepJetGluonLQuarkScores(proc, jetTableName=""):
402  """
403  Store DeepJet raw score in jetTable for gluon and light quark
404  """
405 
406  getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
407  getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
408  getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
409 
410  return proc
411 

Referenced by SavePatJets().

◆ AddJetID()

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

Definition at line 216 of file custom_jme_cff.py.

216 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName=""):
217  """
218  Setup modules to calculate PF jet ID
219  """
220 
221  isPUPPIJet = True if "Puppi" in jetName else False
222 
223  looseJetId = "looseJetId{}".format(jetName)
224  setattr(proc, looseJetId, proc.looseJetId.clone(
225  src = jetSrc,
226  filterParams = proc.looseJetId.filterParams.clone(
227  version = "WINTER16"
228  ),
229  )
230  )
231 
232  tightJetId = "tightJetId{}".format(jetName)
233  setattr(proc, tightJetId, proc.tightJetId.clone(
234  src = jetSrc,
235  filterParams = proc.tightJetId.filterParams.clone(
236  version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
237  ),
238  )
239  )
240 
241  tightJetIdLepVeto = "tightJetIdLepVeto{}".format(jetName)
242  setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
243  src = jetSrc,
244  filterParams = proc.tightJetIdLepVeto.filterParams.clone(
245  version = "RUN2UL{}".format("PUPPI" if isPUPPIJet else "CHS")
246  ),
247  )
248  )
249 
250  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
251  modifier.toModify(getattr(proc, tightJetId).filterParams, version = "WINTER16" )
252  modifier.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version = "WINTER16" )
253  for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
254  modifier.toModify(getattr(proc, tightJetId).filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
255  modifier.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
256  run2_nanoAOD_102Xv1.toModify(getattr(proc, tightJetId).filterParams, version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "") )
257  run2_nanoAOD_102Xv1.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "") )
258 
259  #
260  # Save variables as userInts in each jet
261  #
262  patJetWithUserData = "{}WithUserData".format(jetSrc)
263  getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
264  getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
265  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
266  modifier.toModify(getattr(proc, patJetWithUserData).userInts, looseId = cms.InputTag(looseJetId))
267 
268  #
269  # Specfiy variables in the jetTable to save in NanoAOD
270  #
271  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")
272  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
273  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"))
274 
275 
276  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, jetSrc))+1, getattr(proc, tightJetId))
277  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, tightJetId))+1, getattr(proc, tightJetIdLepVeto))
278 
279  setattr(proc,"_"+jetSequenceName+"_2016", getattr(proc,jetSequenceName).copy())
280  getattr(proc,"_"+jetSequenceName+"_2016").insert(getattr(proc, "_"+jetSequenceName+"_2016").index(getattr(proc, tightJetId)), getattr(proc, looseJetId))
281  for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
282  modifier.toReplaceWith(getattr(proc,jetSequenceName), getattr(proc, "_"+jetSequenceName+"_2016"))
283 
284  return proc
285 

References filterCSVwithJSON.copy, edm::eventsetup::heterocontainer.insert(), and common_cff.Var().

Referenced by SavePatJets().

◆ AddNewAK8CHSJets()

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

Definition at line 788 of file custom_jme_cff.py.

788 def AddNewAK8CHSJets(proc, recoJA, runOnMC):
789  """
790  Store an AK8 CHS jet collection for JEC studies.
791  """
792  print("custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
793 
794  #
795  # Recluster AK8 CHS jets
796  #
797  cfg = {
798  "jet" : "ak8pfchs",
799  "inputCollection" : "",
800  "genJetsCollection": "AK8GenJetsNoNu",
801  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
802  }
803  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
804 
805  jetName = recoJetInfo.jetUpper
806  payload = recoJetInfo.jetCorrPayload
807 
808  patJetFinalColl = recoJetInfo.patJetFinalCollection
809  jetTablePrefix = "FatJetCHS"
810  jetTableDoc = "AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
811  ptcut = ""# No need to specify ptcut. Use default in SavePatJets function
812 
813  SavePatJets(proc,
814  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
815  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
816  )
817 
818  return proc
819 

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

◆ AddNewAK8GenJetsForJEC()

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

Definition at line 952 of file custom_jme_cff.py.

952 def AddNewAK8GenJetsForJEC(proc, genJA):
953  """
954  Make a separate AK8 Gen jet collection for JEC studies.
955  """
956  print("custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
957 
958  #
959  # Recluster AK8 Gen jet
960  #
961  cfg = {
962  "jet" : "ak8gen",
963  }
964  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
965 
966  genJetName = genJetInfo.jetUpper
967  genJetAlgo = genJetInfo.jetAlgo
968  genJetSize = genJetInfo.jetSize
969  genJetSizeNr = genJetInfo.jetSizeNr
970  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
971  genJetTablePrefix = "GenJetAK8ForJEC"
972  genJetTableDoc = "AK8 Gen jets (made with visible genparticles) with pt > 3 GeV. Reclustered for JEC studies."
973 
974  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
975 
976  return proc
977 

References print(), and SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

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

755 def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC):
756  """
757  Store a separate AK8 Puppi jet collection for JEC studies.
758  Only minimal info are stored
759  """
760  print("custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
761 
762  #
763  # Recluster AK8 Puppi jets
764  #
765  cfg = {
766  "jet" : "ak8pfpuppi",
767  "inputCollection" : "",
768  "genJetsCollection": "AK8GenJetsNoNu",
769  "minPtFastjet" : 0., # Remove any pt threshold at the jet clustering stage.
770  }
771  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
772 
773  jetName = recoJetInfo.jetUpper
774  payload = recoJetInfo.jetCorrPayload
775 
776  patJetFinalColl = recoJetInfo.patJetFinalCollection
777  jetTablePrefix = "FatJetForJEC"
778  jetTableDoc = "AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored."
779  ptcut = ""# No need to specify ptcut. Use default in SavePatJets function
780 
781  SavePatJets(proc,
782  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=True,
783  doCalo=False, ptcut=ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=runOnMC
784  )
785 
786  return proc
787 

References print(), and SavePatJets().

Referenced by PrepJMECustomNanoAOD().

◆ AddNewGenJets()

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

Definition at line 852 of file custom_jme_cff.py.

852 def AddNewGenJets(proc, genJetInfo):
853  """
854  Add genJet into custom nanoAOD
855  """
856 
857  genJetName = genJetInfo.jetUpper
858  genJetAlgo = genJetInfo.jetAlgo
859  genJetSize = genJetInfo.jetSize
860  genJetSizeNr = genJetInfo.jetSizeNr
861  genJetFinalColl = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
862  genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet]["name"]
863  genJetTableDoc = nanoInfo_genjets[genJetInfo.jet]["doc"]
864 
865  SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
866 
867  return proc
868 

References SaveGenJets().

Referenced by PrepJMECustomNanoAOD().

◆ AddNewPatJets()

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

Definition at line 425 of file custom_jme_cff.py.

425 def AddNewPatJets(proc, recoJetInfo, runOnMC):
426  """
427  Add patJet into custom nanoAOD
428  """
429 
430  jetName = recoJetInfo.jetUpper
431  payload = recoJetInfo.jetCorrPayload
432  doPF = recoJetInfo.doPF
433  doCalo = recoJetInfo.doCalo
434  patJetFinalColl = recoJetInfo.patJetFinalCollection
435 
436  nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
437  jetTablePrefix = nanoInfoForJet["name"]
438  jetTableDoc = nanoInfoForJet["doc"]
439  ptcut = nanoInfoForJet["ptcut"] if "ptcut" in nanoInfoForJet else ""
440  doPUIDVar = nanoInfoForJet["doPUIDVar"] if "doPUIDVar" in nanoInfoForJet else False
441  doQGL = nanoInfoForJet["doQGL"] if "doQGL" in nanoInfoForJet else False
442  doBTag = nanoInfoForJet["doBTag"] if "doBTag" in nanoInfoForJet else False
443 
444  SavePatJets(proc,
445  jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
446  ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
447  )
448 
449  return proc
450 

References SavePatJets().

Referenced by PrepJMECustomNanoAOD().

◆ AddParticleNetAK4Scores()

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

Definition at line 412 of file custom_jme_cff.py.

412 def AddParticleNetAK4Scores(proc, jetTableName=""):
413  """
414  Store ParticleNetAK4 scores in jetTable
415  """
416 
417  getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
418  getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
419  getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
420  getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
421  getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
422 
423  return proc
424 

Referenced by SavePatJets().

◆ AddPileUpJetIDVars()

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

Definition at line 286 of file custom_jme_cff.py.

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

References edm::eventsetup::heterocontainer.insert().

Referenced by ReclusterAK4CHSJets(), and SavePatJets().

◆ AddQGLTaggerVars()

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

Definition at line 353 of file custom_jme_cff.py.

353 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", calculateQGLVars=False):
354  """
355  Schedule the QGTagger module to calculate input variables to the QG likelihood
356  """
357 
358  QGLTagger="qgtagger{}".format(jetName)
359  patJetWithUserData="{}WithUserData".format(jetSrc)
360 
361  if calculateQGLVars:
362  setattr(proc, QGLTagger, qgtagger.clone(
363  srcJets = jetSrc
364  )
365  )
366 
367  #
368  # Save variables as userFloats and userInts for each jet
369  #
370  getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+":axis2")
371  getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+":ptD")
372  getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+":mult")
373 
374  #
375  # Specfiy variables in the jet table to save in NanoAOD
376  #
377  getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
378  getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
379  getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
380 
381  if calculateQGLVars:
382  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, jetSrc))+1, getattr(proc, QGLTagger))
383 
384  return proc
385 

References edm::eventsetup::heterocontainer.insert().

Referenced by SavePatJets().

◆ AddVariablesForAK4GenJets()

def custom_jme_cff.AddVariablesForAK4GenJets (   proc)

Definition at line 978 of file custom_jme_cff.py.

978 def AddVariablesForAK4GenJets(proc):
979  proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
980  return proc
981 

Referenced by PrepJMECustomNanoAOD().

◆ AddVariablesForAK8GenJets()

def custom_jme_cff.AddVariablesForAK8GenJets (   proc)

Definition at line 982 of file custom_jme_cff.py.

982 def AddVariablesForAK8GenJets(proc):
983  proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
984  return proc
985 
986 #===========================================================================
987 #
988 # Misc. functions
989 #
990 #===========================================================================

Referenced by PrepJMECustomNanoAOD().

◆ AddVariablesForAK8PuppiJets()

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

Definition at line 820 of file custom_jme_cff.py.

821  """
822  Add more variables for AK8 PFPUPPI jets
823  """
824 
825  #
826  # These variables are not stored for AK8PFPUPPI (slimmedJetsAK8)
827  # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
828  #
829  proc.fatJetTable.variables.chHEF = Var("?isPFJet()?chargedHadronEnergyFraction():-1", float, doc="charged Hadron Energy Fraction", precision = 6)
830  proc.fatJetTable.variables.neHEF = Var("?isPFJet()?neutralHadronEnergyFraction():-1", float, doc="neutral Hadron Energy Fraction", precision = 6)
831  proc.fatJetTable.variables.chEmEF = Var("?isPFJet()?chargedEmEnergyFraction():-1", float, doc="charged Electromagnetic Energy Fraction", precision = 6)
832  proc.fatJetTable.variables.neEmEF = Var("?isPFJet()?neutralEmEnergyFraction():-1", float, doc="neutral Electromagnetic Energy Fraction", precision = 6)
833  proc.fatJetTable.variables.muEF = Var("?isPFJet()?muonEnergyFraction():-1", float, doc="muon Energy Fraction", precision = 6)
834  proc.fatJetTable.variables.hfHEF = Var("?isPFJet()?HFHadronEnergyFraction():-1", float, doc="energy fraction in forward hadronic calorimeter", precision = 6)
835  proc.fatJetTable.variables.hfEmEF = Var("?isPFJet()?HFEMEnergyFraction():-1", float, doc="energy fraction in forward EM calorimeter", precision = 6)
836  proc.fatJetTable.variables.nConstChHads = Var("?isPFJet()?chargedHadronMultiplicity():-1",int, doc="number of charged hadrons in the jet")
837  proc.fatJetTable.variables.nConstNeuHads = Var("?isPFJet()?neutralHadronMultiplicity():-1",int, doc="number of neutral hadrons in the jet")
838  proc.fatJetTable.variables.nConstHFHads = Var("?isPFJet()?HFHadronMultiplicity():-1", int, doc="number of HF Hadrons in the jet")
839  proc.fatJetTable.variables.nConstHFEMs = Var("?isPFJet()?HFEMMultiplicity():-1", int, doc="number of HF EMs in the jet")
840  proc.fatJetTable.variables.nConstMuons = Var("?isPFJet()?muonMultiplicity():-1", int, doc="number of muons in the jet")
841  proc.fatJetTable.variables.nConstElecs = Var("?isPFJet()?electronMultiplicity():-1", int, doc="number of electrons in the jet")
842  proc.fatJetTable.variables.nConstPhotons = Var("?isPFJet()?photonMultiplicity():-1", int, doc="number of photons in the jet")
843 
844  return proc
845 #******************************************
846 #
847 #
848 # Gen Jets related functions
849 #
850 #
851 #******************************************

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process,
  runOnMC 
)

Definition at line 1010 of file custom_jme_cff.py.

1010 def PrepJMECustomNanoAOD(process,runOnMC):
1011 
1012 
1015  process = RemoveAllJetPtCuts(process)
1016 
1017 
1022  genJA = GenJetAdder()
1023  if runOnMC:
1024 
1027  process = AddVariablesForAK8GenJets(process)
1028 
1031  process = AddNewAK8GenJetsForJEC(process, genJA)
1032 
1035  process = ReclusterAK4GenJets(process, genJA)
1036  process = AddVariablesForAK4GenJets(process)
1037 
1040  for jetConfig in config_genjets:
1041  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1042  genJetInfo = genJA.addGenJetCollection(process, **cfg)
1043  AddNewGenJets(process, genJetInfo)
1044 
1045 
1050  recoJA = RecoJetAdder(runOnMC=runOnMC)
1051 
1054  process = AddVariablesForAK8PuppiJets(process)
1055 
1058  process = AddNewAK8PuppiJetsForJEC(process, recoJA, runOnMC)
1059 
1062  process = AddNewAK8CHSJets(process, recoJA, runOnMC)
1063 
1066  process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
1067 
1070  for jetConfig in config_recojets:
1071  cfg = { k : v for k, v in jetConfig.items() if k != "enabled"}
1072  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1073  AddNewPatJets(process, recoJetInfo, runOnMC)
1074 
1075 
1078  if runOnMC:
1079  process.puTable.savePtHatMax = True
1080 
1081 
1084  if runOnMC:
1085  process.genWeightsTable.keepAllPSWeights = True
1086 
1087  return process
1088 

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

Referenced by PrepJMECustomNanoAOD_Data(), and PrepJMECustomNanoAOD_MC().

◆ PrepJMECustomNanoAOD_Data()

def custom_jme_cff.PrepJMECustomNanoAOD_Data (   process)

Definition at line 1093 of file custom_jme_cff.py.

1093 def PrepJMECustomNanoAOD_Data(process):
1094  PrepJMECustomNanoAOD(process,runOnMC=False)
1095  return process

References PrepJMECustomNanoAOD().

◆ PrepJMECustomNanoAOD_MC()

def custom_jme_cff.PrepJMECustomNanoAOD_MC (   process)

Definition at line 1089 of file custom_jme_cff.py.

1089 def PrepJMECustomNanoAOD_MC(process):
1090  PrepJMECustomNanoAOD(process,runOnMC=True)
1091  return process
1092 

References PrepJMECustomNanoAOD().

◆ 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.  

Definition at line 596 of file custom_jme_cff.py.

596 def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
597  """
598  Recluster AK4 CHS jets and replace slimmedJets
599  that is used as default to save AK4 CHS jets
600  in NanoAODs.
601  """
602  print("custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
603 
604  #
605  # Recluster AK4 CHS jets
606  #
607  cfg = {
608  "jet" : "ak4pfchs",
609  "inputCollection" : "",
610  "genJetsCollection": "AK4GenJetsNoNu",
611  "bTagDiscriminators": bTagDiscriminatorsForAK4,
612  "minPtFastjet" : 0.,
613  }
614  recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
615 
616  jetName = recoJetInfo.jetUpper
617  patJetFinalColl = recoJetInfo.patJetFinalCollection
618 
619  #
620  # Change the input jet source for jetCorrFactorsNano
621  # and updatedJets
622  #
623  proc.jetCorrFactorsNano.src=patJetFinalColl
624  proc.updatedJets.jetSource=patJetFinalColl
625 
626  #
627  # Change pt cut
628  #
629  finalJetsCut = ""
630  if runOnMC:
631  finalJetsCut = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
632  else:
633  finalJetsCut = "(pt >= 8)"
634 
635  proc.finalJets.cut = finalJetsCut
636  #
637  # Add a minimum pt cut for corrT1METJets.
638  #
639  proc.corrT1METJetTable.cut = "pt>=8 && pt<15 && abs(eta)<9.9"
640 
641  #
642  # Jet table cut
643  #
644  jetTableCut = "" # must not have any cut at the jetTable for AK4 CHS as it has been cross-cleaned
645  proc.jetTable.cut = jetTableCut
646  proc.jetMCTable.cut = jetTableCut
647 
648  #
649  # Jet table documentation
650  #
651  jetTableDoc = "AK4 PF CHS jets with JECs applied. Jets with pt > 8 GeV are stored."
652  if runOnMC:
653  jetTableDoc += "For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored."
654  proc.jetTable.doc = jetTableDoc
655 
656  #
657  # Add variables
658  #
659  proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
660  proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
661  proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
662  proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
663  proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
664  proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
665  proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
666  proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
667  proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
668 
669  #
670  # Setup pileup jet ID with 80X training.
671  #
672  pileupJetId80X = "pileupJetId80X"
673  setattr(proc, pileupJetId80X, pileupJetId.clone(
674  jets = "updatedJets",
675  algos = cms.VPSet(_chsalgos_81x),
676  inputIsCorrected = True,
677  applyJec = False,
678  vertexes = "offlineSlimmedPrimaryVertices"
679  )
680  )
681  proc.jetSequence.insert(proc.jetSequence.index(proc.pileupJetId94X), getattr(proc, pileupJetId80X))
682 
683  proc.updatedJetsWithUserData.userInts.puId80XfullId = cms.InputTag('pileupJetId80X:fullId')
684  run2_jme_2016.toModify(proc.updatedJetsWithUserData.userFloats, puId80XDisc = cms.InputTag("pileupJetId80X:fullDiscriminant"))
685 
686  proc.jetTable.variables.puId = Var("userInt('puId80XfullId')", int, doc="Pilup ID flags with 80X (2016) training")
687  run2_jme_2016.toModify(proc.jetTable.variables, puIdDisc = Var("userFloat('puId80XDisc')",float,doc="Pilup ID discriminant with 80X (2016) training",precision=10))
688 
689  #
690  # Add variables for pileup jet ID studies.
691  #
692  proc = AddPileUpJetIDVars(proc,
693  jetName = "",
694  jetSrc = "updatedJets",
695  jetTableName = "jetTable",
696  jetSequenceName = "jetSequence"
697  )
698  #
699  # Add variables for quark guon likelihood tagger studies.
700  # Save variables as userFloats and userInts in each jet
701  #
702  proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag("qgtagger:axis2")
703  proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag("qgtagger:ptD")
704  proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag("qgtagger:mult")
705  #
706  # Save quark gluon likelihood input variables variables
707  #
708  proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
709  proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
710  proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
711  #
712  # Save standard b-tagging and c-tagging variables
713  #
714  proc.jetTable.variables.btagDeepB = BTAGVARS.btagDeepB
715  proc.jetTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
716  proc.jetTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
717  proc.jetTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
718  #
719  # Save DeepJet b-tagging and c-tagging variables
720  #
721  proc.jetTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
722  proc.jetTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
723  proc.jetTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
724  #
725  # Save DeepJet raw score for gluon and light quarks
726  #
727  proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
728  proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
729  proc.jetTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
730  #
731  # Add ParticleNetAK4 scores
732  #
733  proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
734  proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
735  proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
736  proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
737  proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
738 
739  #Adding hf shower shape producer to the jet sequence. By default this producer is not automatically rerun at the NANOAOD step
740  #The following lines make sure it is.
741  hfJetShowerShapeforCustomNanoAOD = "hfJetShowerShapeforCustomNanoAOD"
742  setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShapeforNanoAOD.clone(jets="updatedJets",vertices="offlineSlimmedPrimaryVertices") )
743  proc.jetSequence.insert(proc.jetSequence.index(proc.updatedJetsWithUserData), getattr(proc, hfJetShowerShapeforCustomNanoAOD))
744  proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
745  proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
746  proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
747  proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag('hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
748  proc.jetTable.variables.hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
749  proc.jetTable.variables.hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
750  proc.jetTable.variables.hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable) ")
751  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) ")
752 
753  return proc
754 

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

Referenced by PrepJMECustomNanoAOD().

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

912 def ReclusterAK4GenJets(proc, genJA):
913  """
914  Recluster AK4 Gen jets and replace
915  slimmedGenJets that is used as default
916  to save AK4 Gen jets in NanoAODs.
917  """
918  print("custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
919 
920  #
921  # Recluster AK4 Gen jet
922  #
923  cfg = {
924  "jet" : "ak4gen",
925  }
926  genJetInfo = genJA.addGenJetCollection(proc, **cfg)
927 
928  genJetName = genJetInfo.jetUpper
929  genJetAlgo = genJetInfo.jetAlgo
930  genJetSize = genJetInfo.jetSize
931  genJetSizeNr = genJetInfo.jetSizeNr
932  selectedGenJets = "{}{}{}".format(genJetAlgo.upper(), genJetSize, "GenJetsNoNu")
933 
934  #
935  # Change jet source to the newly clustered jet collection. Set very low pt cut for jets
936  # to be stored in the GenJet Table
937  #
938  proc.genJetTable.src = selectedGenJets
939  proc.genJetTable.cut = "" # No cut specified here. Save all gen jets after clustering
940  proc.genJetTable.doc = "AK4 Gen jets (made with visible genparticles) with pt > 3 GeV" # default pt cut after clustering is 3 GeV
941 
942  genJetFlavourAssociationThisJet = "genJet{}FlavourAssociation".format(genJetName)
943  setattr(proc, genJetFlavourAssociationThisJet, genJetFlavourAssociation.clone(
944  jets = proc.genJetTable.src,
945  jetAlgorithm = supportedJetAlgos[genJetAlgo],
946  rParam = genJetSizeNr,
947  )
948  )
949  proc.jetMC.insert(proc.jetMC.index(proc.genJetFlavourTable), getattr(proc, genJetFlavourAssociationThisJet))
950  return proc
951 

References print().

Referenced by PrepJMECustomNanoAOD().

◆ RemoveAllJetPtCuts()

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

Definition at line 991 of file custom_jme_cff.py.

991 def RemoveAllJetPtCuts(proc):
992  """
993  Remove default pt cuts for all jets set in jets_cff.py
994  """
995 
996  proc.finalJets.cut = "" # 15 -> 10
997  proc.finalJetsAK8.cut = "" # 170 -> 170
998  proc.genJetTable.cut = "" # 10 -> 8
999  proc.genJetFlavourTable.cut = "" # 10 -> 8
1000  proc.genJetAK8Table.cut = "" # 100 -> 80
1001  proc.genJetAK8FlavourTable.cut = "" # 100 -> 80
1002 
1003  return proc
1004 
1005 #===========================================================================
1006 #
1007 # CUSTOMIZATION function
1008 #
1009 #===========================================================================

Referenced by PrepJMECustomNanoAOD().

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

869 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
870  """
871  Schedule modules for a given genJet collection and save its variables into custom NanoAOD
872  """
873 
874  genJetTableThisJet = "jet{}Table".format(genJetName)
875  setattr(proc, genJetTableThisJet, genJetTable.clone(
876  src = genJetFinalColl,
877  cut = "", # No cut specified here. Save all gen jets after clustering
878  name = genJetTablePrefix,
879  doc = genJetTableDoc,
880  variables = GENJETVARS
881  )
882  )
883 
884  genJetFlavourAssociationThisJet = "genJet{}FlavourAssociation".format(genJetName)
885  setattr(proc, genJetFlavourAssociationThisJet, genJetFlavourAssociation.clone(
886  jets = getattr(proc,genJetTableThisJet).src,
887  jetAlgorithm = supportedJetAlgos[genJetAlgo],
888  rParam = genJetSizeNr,
889  )
890  )
891 
892  genJetFlavourTableThisJet = "genJet{}FlavourTable".format(genJetName)
893  setattr(proc, genJetFlavourTableThisJet, genJetFlavourTable.clone(
894  name = getattr(proc,genJetTableThisJet).name,
895  src = getattr(proc,genJetTableThisJet).src,
896  cut = getattr(proc,genJetTableThisJet).cut,
897  jetFlavourInfos = genJetFlavourAssociationThisJet,
898  )
899  )
900 
901  genJetSequenceName = "genJet{}Sequence".format(genJetName)
902  setattr(proc, genJetSequenceName, cms.Sequence(
903  getattr(proc,genJetTableThisJet)+
904  getattr(proc,genJetFlavourAssociationThisJet)+
905  getattr(proc,genJetFlavourTableThisJet)
906  )
907  )
908  proc.nanoSequenceMC.insert(proc.nanoSequenceMC.index(proc.jetMC)+1, getattr(proc,genJetSequenceName))
909 
910  return proc
911 

Referenced by AddNewAK8GenJetsForJEC(), and AddNewGenJets().

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

451 def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc,
452  doPF, doCalo, ptcut="", doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
453  """
454  Schedule modules for a given patJet collection and save its variables into custom NanoAOD
455  """
456 
457  #
458  # Setup jet correction factors
459  #
460  jetCorrFactors = "jetCorrFactorsNano{}".format(jetName)
461  setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
462  src = patJetFinalColl,
463  payload = payload,
464  )
465  )
466 
467  #
468  # Update jets
469  #
470  srcJets = "updatedJets{}".format(jetName)
471  setattr(proc, srcJets, updatedJets.clone(
472  jetSource = patJetFinalColl,
473  jetCorrFactorsSource = [jetCorrFactors],
474  )
475  )
476 
477  #
478  # Setup UserDataEmbedder
479  #
480  srcJetsWithUserData = "updatedJets{}WithUserData".format(jetName)
481  setattr(proc, srcJetsWithUserData, cms.EDProducer("PATJetUserDataEmbedder",
482  src = cms.InputTag(srcJets),
483  userFloats = cms.PSet(),
484  userInts = cms.PSet(),
485  )
486  )
487 
488  #
489  # Filter jets with pt cut
490  #
491  finalJetsCutDefault = "(pt >= 8)"
492  if runOnMC:
493  finalJetsCutDefault = "(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))"
494 
495  finalJetsForTable = "finalJets{}".format(jetName)
496  setattr(proc, finalJetsForTable, finalJets.clone(
497  src = srcJetsWithUserData,
498  cut = ptcut if ptcut != "" else finalJetsCutDefault
499  )
500  )
501 
502  #
503  # Save jets in table
504  #
505  tableContent = PFJETVARS
506  if doCalo:
507  tableContent = CALOJETVARS
508 
509  jetTableCutDefault = "" #Don't apply any cuts for the table.
510 
511  jetTableDocDefault = jetTableDoc + " with JECs applied. Jets with pt > 8 GeV are stored."
512  if runOnMC:
513  jetTableDocDefault += "For jets with pt < 8 GeV, only those matched to gen jets are stored."
514 
515  jetTable = "jet{}Table".format(jetName)
516  setattr(proc,jetTable, cms.EDProducer("SimpleCandidateFlatTableProducer",
517  src = cms.InputTag(finalJetsForTable),
518  cut = cms.string(jetTableCutDefault),
519  name = cms.string(jetTablePrefix),
520  doc = cms.string(jetTableDocDefault),
521  singleton = cms.bool(False), # the number of entries is variable
522  extension = cms.bool(False), # this is the main table for the jets
523  variables = cms.PSet(tableContent)
524  )
525  )
526  getattr(proc,jetTable).variables.pt.precision=10
527 
528  #
529  # Save MC-only jet variables in table
530  #
531  jetMCTable = "jet{}MCTable".format(jetName)
532  setattr(proc, jetMCTable, cms.EDProducer("SimpleCandidateFlatTableProducer",
533  src = cms.InputTag(finalJetsForTable),
534  cut = getattr(proc,jetTable).cut,
535  name = cms.string(jetTablePrefix),
536  singleton = cms.bool(False),
537  extension = cms.bool(True), # this is an extension table
538  variables = cms.PSet(
539  partonFlavour = Var("partonFlavour()", int, doc="flavour from parton matching"),
540  hadronFlavour = Var("hadronFlavour()", int, doc="flavour from hadron ghost clustering"),
541  genJetIdx = Var("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc="index of matched gen jet"),
542  )
543  )
544  )
545 
546  #
547  # Define the jet modules sequence first
548  #
549  jetSequenceName = "jet{}Sequence".format(jetName)
550  setattr(proc, jetSequenceName, cms.Sequence(
551  getattr(proc,jetCorrFactors)+
552  getattr(proc,srcJets)+
553  getattr(proc,srcJetsWithUserData)+
554  getattr(proc,finalJetsForTable)
555  )
556  )
557 
558  #
559  # Define the jet table sequences
560  #
561  jetTableSequenceName = "jet{}TablesSequence".format(jetName)
562  setattr(proc, jetTableSequenceName, cms.Sequence(getattr(proc,jetTable)))
563 
564  jetTableSequenceMCName = "jet{}MCTablesSequence".format(jetName)
565  setattr(proc, jetTableSequenceMCName, cms.Sequence(getattr(proc,jetMCTable)))
566 
567  if runOnMC:
568  proc.nanoSequenceMC += getattr(proc,jetSequenceName)
569  proc.nanoSequenceMC += getattr(proc,jetTableSequenceName)
570  proc.nanoSequenceMC += getattr(proc,jetTableSequenceMCName)
571  else:
572  proc.nanoSequence += getattr(proc,jetSequenceName)
573  proc.nanoSequence += getattr(proc,jetTableSequenceName)
574 
575  #
576  # Schedule plugins to calculate Jet ID, PileUp Jet ID input variables, and Quark-Gluon Likehood input variables.
577  #
578  if doPF:
579  proc = AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName)
580  if doPUIDVar:
581  proc = AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName)
582  if doQGL:
583  proc = AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName, calculateQGLVars=True)
584 
585  #
586  # Save b-tagging algorithm scores. Should only be done for jet collection with b-tagging
587  # calculated when reclustered or collection saved with b-tagging info in MiniAOD
588  #
589  if doBTag:
590  AddBTaggingScores(proc,jetTableName=jetTable)
591  AddDeepJetGluonLQuarkScores(proc,jetTableName=jetTable)
592  AddParticleNetAK4Scores(proc,jetTableName=jetTable)
593 
594  return proc
595 

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

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

Variable Documentation

◆ area

custom_jme_cff.area

◆ bTagCSVV2

custom_jme_cff.bTagCSVV2

Definition at line 20 of file custom_jme_cff.py.

◆ btagCSVV2

custom_jme_cff.btagCSVV2

Definition at line 181 of file custom_jme_cff.py.

◆ btagDDX

custom_jme_cff.btagDDX

Definition at line 33 of file custom_jme_cff.py.

◆ btagDDXV2

custom_jme_cff.btagDDXV2

Definition at line 41 of file custom_jme_cff.py.

◆ btagDeepB

custom_jme_cff.btagDeepB

Definition at line 180 of file custom_jme_cff.py.

◆ bTagDeepCSV

custom_jme_cff.bTagDeepCSV

Definition at line 21 of file custom_jme_cff.py.

◆ btagDeepCvB

custom_jme_cff.btagDeepCvB

Definition at line 183 of file custom_jme_cff.py.

◆ btagDeepCvL

custom_jme_cff.btagDeepCvL

Definition at line 182 of file custom_jme_cff.py.

◆ btagDeepFlavB

custom_jme_cff.btagDeepFlavB

Definition at line 186 of file custom_jme_cff.py.

◆ btagDeepFlavC

custom_jme_cff.btagDeepFlavC

Definition at line 187 of file custom_jme_cff.py.

◆ btagDeepFlavCvB

custom_jme_cff.btagDeepFlavCvB

Definition at line 191 of file custom_jme_cff.py.

◆ btagDeepFlavCvL

custom_jme_cff.btagDeepFlavCvL

Definition at line 190 of file custom_jme_cff.py.

◆ btagDeepFlavG

custom_jme_cff.btagDeepFlavG

Definition at line 188 of file custom_jme_cff.py.

◆ btagDeepFlavQG

custom_jme_cff.btagDeepFlavQG

Definition at line 192 of file custom_jme_cff.py.

◆ btagDeepFlavUDS

custom_jme_cff.btagDeepFlavUDS

Definition at line 189 of file custom_jme_cff.py.

◆ bTagDeepJet

custom_jme_cff.bTagDeepJet

Definition at line 22 of file custom_jme_cff.py.

◆ bTagDiscriminatorsForAK4

custom_jme_cff.bTagDiscriminatorsForAK4

Definition at line 27 of file custom_jme_cff.py.

◆ btagHbb

custom_jme_cff.btagHbb

Definition at line 32 of file custom_jme_cff.py.

◆ BTAGVARS

custom_jme_cff.BTAGVARS

Definition at line 179 of file custom_jme_cff.py.

◆ CALOJETVARS

custom_jme_cff.CALOJETVARS

Definition at line 202 of file custom_jme_cff.py.

◆ chEmEF

custom_jme_cff.chEmEF

Definition at line 143 of file custom_jme_cff.py.

◆ chHEF

custom_jme_cff.chHEF

Definition at line 141 of file custom_jme_cff.py.

◆ config_genjets

custom_jme_cff.config_genjets

Definition at line 53 of file custom_jme_cff.py.

◆ config_recojets

custom_jme_cff.config_recojets

Definition at line 76 of file custom_jme_cff.py.

◆ DEEPJETVARS

custom_jme_cff.DEEPJETVARS

Definition at line 185 of file custom_jme_cff.py.

◆ doc

custom_jme_cff.doc

Definition at line 139 of file custom_jme_cff.py.

◆ emf

custom_jme_cff.emf

◆ float

custom_jme_cff.float

Definition at line 139 of file custom_jme_cff.py.

◆ GENJETVARS

custom_jme_cff.GENJETVARS

Definition at line 135 of file custom_jme_cff.py.

◆ hfEmEF

custom_jme_cff.hfEmEF

Definition at line 147 of file custom_jme_cff.py.

◆ hfHEF

custom_jme_cff.hfHEF

Definition at line 146 of file custom_jme_cff.py.

◆ int

custom_jme_cff.int

Definition at line 151 of file custom_jme_cff.py.

◆ muEF

custom_jme_cff.muEF

Definition at line 145 of file custom_jme_cff.py.

◆ nanoInfo_genjets

custom_jme_cff.nanoInfo_genjets

Definition at line 63 of file custom_jme_cff.py.

◆ nanoInfo_recojets

custom_jme_cff.nanoInfo_recojets

Definition at line 110 of file custom_jme_cff.py.

◆ nConstChHads

custom_jme_cff.nConstChHads

Definition at line 151 of file custom_jme_cff.py.

◆ nConstElecs

custom_jme_cff.nConstElecs

Definition at line 156 of file custom_jme_cff.py.

◆ nConstHFEMs

custom_jme_cff.nConstHFEMs

Definition at line 154 of file custom_jme_cff.py.

◆ nConstHFHads

custom_jme_cff.nConstHFHads

Definition at line 153 of file custom_jme_cff.py.

◆ nConstituents

custom_jme_cff.nConstituents

◆ nConstMuons

custom_jme_cff.nConstMuons

Definition at line 155 of file custom_jme_cff.py.

◆ nConstNeuHads

custom_jme_cff.nConstNeuHads

Definition at line 152 of file custom_jme_cff.py.

◆ nConstPhotons

custom_jme_cff.nConstPhotons

Definition at line 157 of file custom_jme_cff.py.

◆ neEmEF

custom_jme_cff.neEmEF

Definition at line 144 of file custom_jme_cff.py.

◆ neHEF

custom_jme_cff.neHEF

Definition at line 142 of file custom_jme_cff.py.

◆ nElectrons

custom_jme_cff.nElectrons

◆ nMuons

custom_jme_cff.nMuons

◆ particleNetAK4_B

custom_jme_cff.particleNetAK4_B

Definition at line 195 of file custom_jme_cff.py.

◆ particleNetAK4_CvsB

custom_jme_cff.particleNetAK4_CvsB

Definition at line 197 of file custom_jme_cff.py.

◆ particleNetAK4_CvsL

custom_jme_cff.particleNetAK4_CvsL

Definition at line 196 of file custom_jme_cff.py.

◆ particleNetAK4_puIdDisc

custom_jme_cff.particleNetAK4_puIdDisc

Definition at line 199 of file custom_jme_cff.py.

◆ particleNetAK4_QvsG

custom_jme_cff.particleNetAK4_QvsG

Definition at line 198 of file custom_jme_cff.py.

◆ PARTICLENETAK4VARS

custom_jme_cff.PARTICLENETAK4VARS

Definition at line 194 of file custom_jme_cff.py.

◆ PFJETVARS

custom_jme_cff.PFJETVARS

Definition at line 138 of file custom_jme_cff.py.

◆ precision

custom_jme_cff.precision

Definition at line 139 of file custom_jme_cff.py.

◆ puId_beta

custom_jme_cff.puId_beta

Definition at line 168 of file custom_jme_cff.py.

◆ puId_dR2Mean

custom_jme_cff.puId_dR2Mean

Definition at line 160 of file custom_jme_cff.py.

◆ puId_frac01

custom_jme_cff.puId_frac01

Definition at line 163 of file custom_jme_cff.py.

◆ puId_frac02

custom_jme_cff.puId_frac02

Definition at line 164 of file custom_jme_cff.py.

◆ puId_frac03

custom_jme_cff.puId_frac03

Definition at line 165 of file custom_jme_cff.py.

◆ puId_frac04

custom_jme_cff.puId_frac04

Definition at line 166 of file custom_jme_cff.py.

◆ puId_jetR

custom_jme_cff.puId_jetR

Definition at line 170 of file custom_jme_cff.py.

◆ puId_jetRchg

custom_jme_cff.puId_jetRchg

Definition at line 171 of file custom_jme_cff.py.

◆ puId_majW

custom_jme_cff.puId_majW

Definition at line 161 of file custom_jme_cff.py.

◆ puId_minW

custom_jme_cff.puId_minW

Definition at line 162 of file custom_jme_cff.py.

◆ puId_nCharged

custom_jme_cff.puId_nCharged

Definition at line 172 of file custom_jme_cff.py.

◆ puId_ptD

custom_jme_cff.puId_ptD

Definition at line 167 of file custom_jme_cff.py.

◆ puId_pull

custom_jme_cff.puId_pull

Definition at line 169 of file custom_jme_cff.py.

◆ PUIDVARS

custom_jme_cff.PUIDVARS

Definition at line 159 of file custom_jme_cff.py.

◆ qgl_axis2

custom_jme_cff.qgl_axis2

Definition at line 175 of file custom_jme_cff.py.

◆ qgl_mult

custom_jme_cff.qgl_mult

Definition at line 177 of file custom_jme_cff.py.

◆ qgl_ptD

custom_jme_cff.qgl_ptD

Definition at line 176 of file custom_jme_cff.py.

◆ QGLVARS

custom_jme_cff.QGLVARS

Definition at line 174 of file custom_jme_cff.py.

◆ rawFactor

custom_jme_cff.rawFactor

Definition at line 139 of file custom_jme_cff.py.

custom_jme_cff.AddDeepJetGluonLQuarkScores
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")
Definition: custom_jme_cff.py:401
custom_jme_cff.AddPileUpJetIDVars
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="")
Definition: custom_jme_cff.py:286
custom_jme_cff.AddNewAK8GenJetsForJEC
def AddNewAK8GenJetsForJEC(proc, genJA)
Definition: custom_jme_cff.py:952
custom_jme_cff.ReclusterAK4GenJets
def ReclusterAK4GenJets(proc, genJA)
Definition: custom_jme_cff.py:912
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
custom_jme_cff.AddVariablesForAK8PuppiJets
def AddVariablesForAK8PuppiJets(proc)
Definition: custom_jme_cff.py:820
custom_jme_cff.AddNewGenJets
def AddNewGenJets(proc, genJetInfo)
Definition: custom_jme_cff.py:852
custom_jme_cff.PrepJMECustomNanoAOD_MC
def PrepJMECustomNanoAOD_MC(process)
Definition: custom_jme_cff.py:1089
custom_jme_cff.AddNewAK8PuppiJetsForJEC
def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC)
Definition: custom_jme_cff.py:755
common_cff.Var
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
custom_jme_cff.AddVariablesForAK4GenJets
def AddVariablesForAK4GenJets(proc)
Definition: custom_jme_cff.py:978
custom_jme_cff.AddVariablesForAK8GenJets
def AddVariablesForAK8GenJets(proc)
Definition: custom_jme_cff.py:982
custom_jme_cff.AddBTaggingScores
def AddBTaggingScores(proc, jetTableName="")
Definition: custom_jme_cff.py:386
custom_jme_cff.SaveGenJets
def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
Definition: custom_jme_cff.py:869
custom_jme_cff.AddParticleNetAK4Scores
def AddParticleNetAK4Scores(proc, jetTableName="")
Definition: custom_jme_cff.py:412
custom_jme_cff.PrepJMECustomNanoAOD
def PrepJMECustomNanoAOD(process, runOnMC)
Definition: custom_jme_cff.py:1010
custom_jme_cff.RemoveAllJetPtCuts
def RemoveAllJetPtCuts(proc)
Definition: custom_jme_cff.py:991
custom_jme_cff.ReclusterAK4CHSJets
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
Definition: custom_jme_cff.py:596
custom_jme_cff.PrepJMECustomNanoAOD_Data
def PrepJMECustomNanoAOD_Data(process)
Definition: custom_jme_cff.py:1093
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
custom_jme_cff.AddJetID
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="")
Definition: custom_jme_cff.py:216
custom_jme_cff.AddNewAK8CHSJets
def AddNewAK8CHSJets(proc, recoJA, runOnMC)
Definition: custom_jme_cff.py:788
custom_jme_cff.AddQGLTaggerVars
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", calculateQGLVars=False)
Definition: custom_jme_cff.py:353
custom_jme_cff.AddNewPatJets
def AddNewPatJets(proc, recoJetInfo, runOnMC)
Definition: custom_jme_cff.py:425
format
edm::eventsetup::heterocontainer::insert
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
custom_jme_cff.SavePatJets
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut="", doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
Definition: custom_jme_cff.py:451