CMS 3D CMS Logo

Classes | Functions | Variables
custom_jme_cff Namespace Reference

Classes

class  TableGenJetAdder
 
class  TableRecoJetAdder
 

Functions

def AddDeepJetGluonLQuarkScores (proc)
 
def AddPileUpJetIDVars (proc)
 
def AddQGLTaggerVars (proc)
 
def PrepJMECustomNanoAOD (process, runOnMC)
 
def PrepJMECustomNanoAOD_Data (process)
 
def PrepJMECustomNanoAOD_MC (process)
 

Variables

 area
 
 chEmEF
 
 chFPV0EF
 
 chFPV1EF
 
 chFPV2EF
 
 chFPV3EF
 
 chHEF
 
 config_genjets
 
 config_recojets
 
 doc
 
 float
 
 genjetNameInNano
 
 HFEMEF
 
 HFHEF
 
 jetId
 
 JETVARS
 
 muEF
 
 nanoInfo_genjets
 
 nanoInfo_recojets
 
 neEmEF
 
 neHEF
 
 precision
 
 rawFactor
 
 recojetNameInNano
 

Function Documentation

◆ AddDeepJetGluonLQuarkScores()

def custom_jme_cff.AddDeepJetGluonLQuarkScores (   proc)

Definition at line 400 of file custom_jme_cff.py.

401  #
402  # Save DeepJet raw score for gluon and light quark
403  #
404  proc.jetTable.variables.btagDeepFlavG = Var("bDiscriminator('pfDeepFlavourJetTags:probg')",float,doc="DeepFlavour gluon tag raw score",precision=10)
405  proc.jetTable.variables.btagDeepFlavUDS = Var("bDiscriminator('pfDeepFlavourJetTags:probuds')",float,doc="DeepFlavour uds tag raw score",precision=10)
406 

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

◆ AddPileUpJetIDVars()

def custom_jme_cff.AddPileUpJetIDVars (   proc)

Definition at line 327 of file custom_jme_cff.py.

327 def AddPileUpJetIDVars(proc):
328 
329  print("custom_jme_cff::AddPileUpJetIDVars: Recalculate pile-up jet ID variables and save them")
330 
331  #
332  # Recalculate PUJet ID variables
333  #
334  from RecoJets.JetProducers.PileupJetID_cfi import pileupJetIdCalculator
335  proc.pileupJetIdCalculatorAK4PFCHS = pileupJetIdCalculator.clone(
336  jets = "updatedJets",
337  vertexes = "offlineSlimmedPrimaryVertices",
338  inputIsCorrected = True,
339  applyJec = False
340  )
341  proc.jetSequence.insert(proc.jetSequence.index(proc.updatedJets)+1, proc.pileupJetIdCalculatorAK4PFCHS)
342 
343  #
344  # Get the variables
345  #
346  proc.puJetVarAK4PFCHS = cms.EDProducer("PileupJetIDVarProducer",
347  srcJet = cms.InputTag("updatedJets"),
348  srcPileupJetId = cms.InputTag("pileupJetIdCalculatorAK4PFCHS")
349  )
350  proc.jetSequence.insert(proc.jetSequence.index(proc.jercVars)+1, proc.puJetVarAK4PFCHS)
351 
352  #
353  # Save variables as userFloats and userInts in each jet
354  #
355  proc.updatedJetsWithUserData.userFloats.dR2Mean = cms.InputTag("puJetVarAK4PFCHS:dR2Mean")
356  proc.updatedJetsWithUserData.userFloats.majW = cms.InputTag("puJetVarAK4PFCHS:majW")
357  proc.updatedJetsWithUserData.userFloats.minW = cms.InputTag("puJetVarAK4PFCHS:minW")
358  proc.updatedJetsWithUserData.userFloats.frac01 = cms.InputTag("puJetVarAK4PFCHS:frac01")
359  proc.updatedJetsWithUserData.userFloats.frac02 = cms.InputTag("puJetVarAK4PFCHS:frac02")
360  proc.updatedJetsWithUserData.userFloats.frac03 = cms.InputTag("puJetVarAK4PFCHS:frac03")
361  proc.updatedJetsWithUserData.userFloats.frac04 = cms.InputTag("puJetVarAK4PFCHS:frac04")
362  proc.updatedJetsWithUserData.userFloats.ptD = cms.InputTag("puJetVarAK4PFCHS:ptD")
363  proc.updatedJetsWithUserData.userFloats.beta = cms.InputTag("puJetVarAK4PFCHS:beta")
364  proc.updatedJetsWithUserData.userFloats.pull = cms.InputTag("puJetVarAK4PFCHS:pull")
365  proc.updatedJetsWithUserData.userFloats.jetR = cms.InputTag("puJetVarAK4PFCHS:jetR")
366  proc.updatedJetsWithUserData.userFloats.jetRchg = cms.InputTag("puJetVarAK4PFCHS:jetRchg")
367  proc.updatedJetsWithUserData.userInts.nCharged = cms.InputTag("puJetVarAK4PFCHS:nCharged")
368 
369  #
370  # Specfiy variables in the jetTable to save in NanoAOD
371  #
372  proc.jetTable.variables.dR2Mean = Var("userFloat('dR2Mean')", float, doc="pT^2-weighted average square distance of jet constituents from the jet axis", precision= 6)
373  proc.jetTable.variables.majW = Var("userFloat('majW')", float, doc="major axis of jet ellipsoid in eta-phi plane", precision= 6)
374  proc.jetTable.variables.minW = Var("userFloat('minW')", float, doc="minor axis of jet ellipsoid in eta-phi plane", precision= 6)
375  proc.jetTable.variables.frac01 = Var("userFloat('frac01')", float, doc="frac of constituents' pT contained within dR<0.1", precision= 6)
376  proc.jetTable.variables.frac02 = Var("userFloat('frac02')", float, doc="frac of constituents' pT contained within 0.1<dR<0.2", precision= 6)
377  proc.jetTable.variables.frac03 = Var("userFloat('frac03')", float, doc="frac of constituents' pT contained within 0.2<dR<0.3", precision= 6)
378  proc.jetTable.variables.frac04 = Var("userFloat('frac04')", float, doc="frac of constituents' pT contained within 0.3<dR<0.4", precision= 6)
379  proc.jetTable.variables.ptD = Var("userFloat('ptD')", float, doc="pT-weighted average pT of constituents", precision= 6)
380  proc.jetTable.variables.beta = Var("userFloat('beta')", float, doc="fraction of pT of charged constituents associated to PV", precision= 6)
381  proc.jetTable.variables.pull = Var("userFloat('pull')", float, doc="magnitude of pull vector", precision= 6)
382  proc.jetTable.variables.jetR = Var("userFloat('jetR')", float, doc="fraction of jet pT carried by the leading constituent", precision= 6)
383  proc.jetTable.variables.jetRchg = Var("userFloat('jetRchg')", float, doc="fraction of jet pT carried by the leading charged constituent", precision= 6)
384  proc.jetTable.variables.nCharged = Var("userInt('nCharged')", int, doc="number of charged constituents")
385 

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

Referenced by PrepJMECustomNanoAOD().

◆ AddQGLTaggerVars()

def custom_jme_cff.AddQGLTaggerVars (   proc)

Definition at line 386 of file custom_jme_cff.py.

386 def AddQGLTaggerVars(proc):
387  #
388  # Save variables as userFloats and userInts
389  #
390  proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag("qgtagger:axis2")
391  proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag("qgtagger:ptD")
392  proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag("qgtagger:mult")
393  #
394  # Specfiy variables in the jetTable to save in NanoAOD
395  #
396  proc.jetTable.variables.qgl_axis2 = Var("userFloat('qgl_axis2')", float, doc="ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision= 6)
397  proc.jetTable.variables.qgl_ptD = Var("userFloat('qgl_ptD')", float, doc="pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)", precision= 6)
398  proc.jetTable.variables.qgl_mult = Var("userInt('qgl_mult')", int, doc="PF candidates multiplicity (Quark vs Gluon likelihood input variable)")
399 

References common_cff.Var().

Referenced by PrepJMECustomNanoAOD().

◆ PrepJMECustomNanoAOD()

def custom_jme_cff.PrepJMECustomNanoAOD (   process,
  runOnMC 
)

Definition at line 407 of file custom_jme_cff.py.

407 def PrepJMECustomNanoAOD(process,runOnMC):
408  #
409  # Additional variables to AK4GenJets
410  #
411  process.genJetTable.variables.area = JETVARS.area
412  #
413  # Additional variables to AK8GenJets
414  #
415  process.genJetAK8Table.variables.area = JETVARS.area
416  #
417  # Additional variables for AK4PFCHS
418  #
419  process.jetTable.variables.HFHEF = JETVARS.HFHEF
420  process.jetTable.variables.HFEMEF = JETVARS.HFEMEF
421  #
422  # Additional variables to AK8PFPUPPI
423  #
424  # These variables are not stored for AK8PFCHS (slimmedJetsAK8)
425  # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
426  #
427  process.fatJetTable.variables.chHEF = Var("?isPFJet()?chargedHadronEnergyFraction():-1", float, doc="charged Hadron Energy Fraction", precision = 6)
428  process.fatJetTable.variables.neHEF = Var("?isPFJet()?neutralHadronEnergyFraction():-1", float, doc="neutral Hadron Energy Fraction", precision = 6)
429  process.fatJetTable.variables.chEmEF = Var("?isPFJet()?chargedEmEnergyFraction():-1", float, doc="charged Electromagnetic Energy Fraction", precision = 6)
430  process.fatJetTable.variables.neEmEF = Var("?isPFJet()?neutralEmEnergyFraction():-1", float, doc="neutral Electromagnetic Energy Fraction", precision = 6)
431  process.fatJetTable.variables.muEF = Var("?isPFJet()?muonEnergyFraction():-1", float, doc="muon Energy Fraction", precision = 6)
432  process.fatJetTable.variables.HFHEF = Var("?isPFJet()?HFHadronEnergyFraction():-1", float, doc="energy fraction in forward hadronic calorimeter", precision = 6)
433  process.fatJetTable.variables.HFEMEF = Var("?isPFJet()?HFEMEnergyFraction():-1", float, doc="energy fraction in forward EM calorimeter", precision = 6)
434  #
435  #
436  #
437  process.jercVarsFatJet = process.jercVars.clone(
438  srcJet = "updatedJetsAK8",
439  maxDR = 0.8,
440  )
441  process.jetSequence.insert(process.jetSequence.index(process.updatedJetsAK8WithUserData), process.jercVarsFatJet)
442 
443  process.updatedJetsAK8WithUserData.userFloats = cms.PSet(
444  chFPV0EF = cms.InputTag("%s:chargedFromPV0EnergyFraction" %process.jercVarsFatJet.label()),
445  chFPV1EF = cms.InputTag("%s:chargedFromPV1EnergyFraction" %process.jercVarsFatJet.label()),
446  chFPV2EF = cms.InputTag("%s:chargedFromPV2EnergyFraction" %process.jercVarsFatJet.label()),
447  chFPV3EF = cms.InputTag("%s:chargedFromPV3EnergyFraction" %process.jercVarsFatJet.label()),
448  )
449 
450  process.fatJetTable.variables.chFPV0EF = JETVARS.chFPV0EF
451  process.fatJetTable.variables.chFPV1EF = JETVARS.chFPV1EF
452  process.fatJetTable.variables.chFPV2EF = JETVARS.chFPV2EF
453  process.fatJetTable.variables.chFPV3EF = JETVARS.chFPV3EF
454 
455  #
456  #
457  #
458  process.finalJets.cut = "" # 15 -> 10
459  process.finalJetsAK8.cut = "" # 170 -> 170
460  process.genJetTable.cut = "" # 10 -> 8
461  process.genJetFlavourTable.cut = "" # 10 -> 8
462  process.genJetAK8Table.cut = "" # 100 -> 80
463  process.genJetAK8FlavourTable.cut = "" # 100 -> 80
464  #
465  # Add variables for pileup jet ID studies.
466  #
467  AddPileUpJetIDVars(process)
468  #
469  # Add variables for quark guon likelihood tagger studies.
470  #
471  AddQGLTaggerVars(process)
472  #
473  # Add DeepJet scores for gluon and light quarks tagging
474  #
476 
477 
478 
479  #
480  # Add GenJets to NanoAOD
481  #
482  genJA = GenJetAdder()
483  tableGenJA = TableGenJetAdder()
484 
485  for jetConfig in config_genjets:
486  cfg = { k : v for k, v in jetConfig.items() if k != "enabled" }
487  genJetInfo = genJA.addGenJetCollection(process, **cfg)
488  tableGenJA.addTable(process, genJetInfo)
489 
490  #
491  # Add RecoJets to NanoAOD
492  #
493  recoJA = RecoJetAdder(runOnMC=runOnMC)
494  tableRecoJA = TableRecoJetAdder()
495 
496  for jetConfig in config_recojets:
497  cfg = { k : v for k, v in jetConfig.items() if k != "enabled" }
498  recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
499  tableRecoJA.addTable(process, recoJetInfo)
500 
501  if runOnMC:
502  process.nanoSequenceMC += genJA.getSequence(process)
503  process.nanoSequenceMC += recoJA.getSequence(process)
504  process.nanoSequenceMC += tableGenJA.getSequence(process)
505  process.nanoSequenceMC += tableRecoJA.getSequence(process)
506  else:
507  process.nanoSequence += recoJA.getSequence(process)
508  process.nanoSequence += tableRecoJA.getSequence(process)
509 
510  return process
511 

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

Referenced by PrepJMECustomNanoAOD_Data(), and PrepJMECustomNanoAOD_MC().

◆ PrepJMECustomNanoAOD_Data()

def custom_jme_cff.PrepJMECustomNanoAOD_Data (   process)

Definition at line 516 of file custom_jme_cff.py.

516 def PrepJMECustomNanoAOD_Data(process):
517  PrepJMECustomNanoAOD(process,runOnMC=False)
518  return process

References PrepJMECustomNanoAOD().

◆ PrepJMECustomNanoAOD_MC()

def custom_jme_cff.PrepJMECustomNanoAOD_MC (   process)

Definition at line 512 of file custom_jme_cff.py.

512 def PrepJMECustomNanoAOD_MC(process):
513  PrepJMECustomNanoAOD(process,runOnMC=True)
514  return process
515 

References PrepJMECustomNanoAOD().

Variable Documentation

◆ area

custom_jme_cff.area

◆ chEmEF

custom_jme_cff.chEmEF

Definition at line 172 of file custom_jme_cff.py.

◆ chFPV0EF

custom_jme_cff.chFPV0EF

Definition at line 177 of file custom_jme_cff.py.

◆ chFPV1EF

custom_jme_cff.chFPV1EF

Definition at line 178 of file custom_jme_cff.py.

◆ chFPV2EF

custom_jme_cff.chFPV2EF

Definition at line 179 of file custom_jme_cff.py.

◆ chFPV3EF

custom_jme_cff.chFPV3EF

Definition at line 180 of file custom_jme_cff.py.

◆ chHEF

custom_jme_cff.chHEF

Definition at line 170 of file custom_jme_cff.py.

◆ config_genjets

custom_jme_cff.config_genjets

Definition at line 19 of file custom_jme_cff.py.

◆ config_recojets

custom_jme_cff.config_recojets

Definition at line 76 of file custom_jme_cff.py.

◆ doc

custom_jme_cff.doc

Definition at line 167 of file custom_jme_cff.py.

◆ float

custom_jme_cff.float

Definition at line 167 of file custom_jme_cff.py.

◆ genjetNameInNano

custom_jme_cff.genjetNameInNano

Definition at line 164 of file custom_jme_cff.py.

◆ HFEMEF

custom_jme_cff.HFEMEF

Definition at line 168 of file custom_jme_cff.py.

◆ HFHEF

custom_jme_cff.HFHEF

Definition at line 167 of file custom_jme_cff.py.

◆ jetId

custom_jme_cff.jetId

Definition at line 176 of file custom_jme_cff.py.

◆ JETVARS

custom_jme_cff.JETVARS

Definition at line 166 of file custom_jme_cff.py.

◆ muEF

custom_jme_cff.muEF

Definition at line 174 of file custom_jme_cff.py.

◆ nanoInfo_genjets

custom_jme_cff.nanoInfo_genjets

Definition at line 45 of file custom_jme_cff.py.

◆ nanoInfo_recojets

custom_jme_cff.nanoInfo_recojets

Definition at line 124 of file custom_jme_cff.py.

◆ neEmEF

custom_jme_cff.neEmEF

Definition at line 173 of file custom_jme_cff.py.

◆ neHEF

custom_jme_cff.neHEF

Definition at line 171 of file custom_jme_cff.py.

◆ precision

custom_jme_cff.precision

Definition at line 167 of file custom_jme_cff.py.

◆ rawFactor

custom_jme_cff.rawFactor

Definition at line 175 of file custom_jme_cff.py.

◆ recojetNameInNano

custom_jme_cff.recojetNameInNano

Definition at line 159 of file custom_jme_cff.py.

custom_jme_cff.AddPileUpJetIDVars
def AddPileUpJetIDVars(proc)
Definition: custom_jme_cff.py:327
custom_jme_cff.PrepJMECustomNanoAOD_MC
def PrepJMECustomNanoAOD_MC(process)
Definition: custom_jme_cff.py:512
common_cff.Var
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
custom_jme_cff.AddQGLTaggerVars
def AddQGLTaggerVars(proc)
Definition: custom_jme_cff.py:386
custom_jme_cff.PrepJMECustomNanoAOD
def PrepJMECustomNanoAOD(process, runOnMC)
Definition: custom_jme_cff.py:407
custom_jme_cff.PrepJMECustomNanoAOD_Data
def PrepJMECustomNanoAOD_Data(process)
Definition: custom_jme_cff.py:516
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
PileupJetID_cfi
custom_jme_cff.AddDeepJetGluonLQuarkScores
def AddDeepJetGluonLQuarkScores(proc)
Definition: custom_jme_cff.py:400