CMS 3D CMS Logo

Classes | Functions | Variables
jetTools Namespace Reference

Classes

class  AddJetCollection
 
class  AddJetID
 
class  SetTagInfos
 
class  SwitchJetCollection
 
class  UpdateJetCollection
 

Functions

def checkJetCorrectionsFormat (jetCorrections)
 
def deprecatedOptionOutputModule (obj)
 
def jetAlgo (algo)
 
def rerunningIVF ()
 
def rerunningIVFMiniAOD ()
 
def setupBTagging (process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets, algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix)
 
def setupJetCorrections (process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix)
 
def setupSVClustering (btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
 
def undefinedLabelName (obj)
 
def unsupportedJetAlgorithm (obj)
 

Variables

 supportedJetAlgos
 dictionary with supported jet clustering algorithms More...
 

Function Documentation

◆ checkJetCorrectionsFormat()

def jetTools.checkJetCorrectionsFormat (   jetCorrections)

Definition at line 18 of file jetTools.py.

18 def checkJetCorrectionsFormat(jetCorrections):
19 
20  if not isinstance(jetCorrections, type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL'))):
21  raise ValueError("In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
22  'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \
23  corrections.")
24 
25 

Referenced by jetTools.AddJetCollection.toolCode(), and jetTools.UpdateJetCollection.toolCode().

◆ deprecatedOptionOutputModule()

def jetTools.deprecatedOptionOutputModule (   obj)

Definition at line 1859 of file jetTools.py.

1860  sys.stderr.write("-------------------------------------------------------\n")
1861  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1862  sys.stderr.write(" anymore by:\n")
1863  sys.stderr.write(" " + obj._label + "\n")
1864  sys.stderr.write(" please use 'outputModules' now and specify the\n")
1865  sys.stderr.write(" names of all needed OutModules in there\n")
1866  sys.stderr.write(" (default: ['out'])\n")
1867  sys.stderr.write("-------------------------------------------------------\n")
1868  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1869 

◆ jetAlgo()

def jetTools.jetAlgo (   algo)

Definition at line 3 of file jetTools.py.

3 def jetAlgo( algo ):
4 
5  # print 'PF2PAT: selecting jet algorithm ', algo
6 
7  if algo == 'IC5':
8  import RecoJets.JetProducers.ic5PFJets_cfi as jetConfig
9  jetAlgo = jetConfig.iterativeCone5PFJets.clone()
10  elif algo == 'AK4':
11  import RecoJets.JetProducers.ak4PFJets_cfi as jetConfig
12  jetAlgo = jetConfig.ak4PFJets.clone()
13  elif algo == 'AK7':
14  import RecoJets.JetProducers.ak4PFJets_cfi as jetConfig
15  jetAlgo = jetConfig.ak4PFJets.clone()
16  jetAlgo.rParam = cms.double(0.7)
17  jetAlgo.doAreaFastjet = cms.bool(False)
18 
19  jetAlgo.src = 'pfNoElectronJME'
20  jetAlgo.doPVCorrection = True
21  jetAlgo.srcPVs = cms.InputTag("goodOfflinePrimaryVertices")
22  return jetAlgo

◆ rerunningIVF()

def jetTools.rerunningIVF ( )

Definition at line 1886 of file jetTools.py.

1886 def rerunningIVF():
1887  sys.stderr.write("-------------------------------------------------------------------\n")
1888  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1889  sys.stderr.write(" already produced by the standard reconstruction. This\n")
1890  sys.stderr.write(" option is not enabled by default so please use it only if\n")
1891  sys.stderr.write(" you know what you are doing.\n")
1892  sys.stderr.write("-------------------------------------------------------------------\n")
1893 

Referenced by setupBTagging().

◆ rerunningIVFMiniAOD()

def jetTools.rerunningIVFMiniAOD ( )

Definition at line 1894 of file jetTools.py.

1894 def rerunningIVFMiniAOD():
1895  sys.stderr.write("-------------------------------------------------------------------\n")
1896  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1897  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1898  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1899  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1900  sys.stderr.write("-------------------------------------------------------------------\n")

Referenced by setupBTagging().

◆ setupBTagging()

def jetTools.setupBTagging (   process,
  jetSource,
  pfCandidates,
  explicitJTA,
  pvSource,
  svSource,
  elSource,
  muSource,
  runIVF,
  tightBTagNTkHits,
  loadStdRecoBTag,
  svClustering,
  fatJets,
  groomedFatJets,
  algo,
  rParam,
  btagDiscriminators,
  btagInfos,
  patJets,
  labelName,
  btagPrefix,
  postfix 
)

Definition at line 238 of file jetTools.py.

238 def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
239  algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
240 
241  task = getPatAlgosToolsTask(process)
242 
243 
244  discriminators = set(btagDiscriminators)
245  present_meta = discriminators.intersection(set(supportedMetaDiscr.keys()))
246  discriminators -= present_meta
247  for meta_tagger in present_meta:
248  for src in supportedMetaDiscr[meta_tagger]:
249  discriminators.add(src)
250  btagDiscriminators = list(discriminators)
251 
252 
254  requiredTagInfos = list(btagInfos)
255  for btagDiscr in btagDiscriminators :
256  for tagInfoList in supportedBtagDiscr[btagDiscr] :
257  for requiredTagInfo in tagInfoList :
258  tagInfoCovered = False
259  for tagInfo in requiredTagInfos :
260  if requiredTagInfo == tagInfo :
261  tagInfoCovered = True
262  break
263  if not tagInfoCovered :
264  requiredTagInfos.append(requiredTagInfo)
265 
266  if hasattr( process, 'candidateJetProbabilityComputer' ) == False :
267  if loadStdRecoBTag: # also loading modules already run in the standard reconstruction
268  process.load("RecoBTag.ImpactParameter.impactParameter_cff")
269  task.add(process.impactParameterTask)
270  process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
271  task.add(process.secondaryVertexTask)
272  process.load("RecoBTag.SoftLepton.softLepton_cff")
273  task.add(process.softLeptonTask)
274  process.load("RecoBTag.Combined.combinedMVA_cff")
275  task.add(process.combinedMVATask)
276  process.load("RecoBTag.CTagging.cTagging_cff")
277  task.add(process.cTaggingTask)
278  else: # to prevent loading of modules already run in the standard reconstruction
279  process.load("RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
280  process.load("RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
281  process.load("RecoBTag.SoftLepton.softLepton_EventSetup_cff")
282  process.load("RecoBTag.Combined.combinedMVA_EventSetup_cff")
283  process.load("RecoBTag.CTagging.cTagging_EventSetup_cff")
285  import RecoJets.JetProducers.caTopTaggers_cff as toptag
286 
287  if tightBTagNTkHits:
288  if not runIVF:
289  sys.stderr.write("-------------------------------------------------------------------\n")
290  sys.stderr.write(" Warning: For a complete switch to the legacy tight b-tag track\n")
291  sys.stderr.write(" selection, please also enable the \'runIVF\' switch.\n")
292  sys.stderr.write("-------------------------------------------------------------------\n")
293  if btagPrefix == '':
294  sys.stderr.write("-------------------------------------------------------------------\n")
295  sys.stderr.write(" Warning: With the tight b-tag track selection enabled, it is\n")
296  sys.stderr.write(" advisable to set \'btagPrefix\' to a non-empty string to\n")
297  sys.stderr.write(" avoid unintentional modifications to the default\n")
298  sys.stderr.write(" b tagging setup that might be loaded in the same job.\n")
299  sys.stderr.write("-------------------------------------------------------------------\n")
300 
301 
303  svSourceCvsL = copy.deepcopy(svSource)
304  svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+'CvsL')
305 
306 
307  runIVFforCTagOnly = False
308  ivfcTagInfos = ['pfInclusiveSecondaryVertexFinderCvsLTagInfos', 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
309 
310  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices' and any(i in requiredTagInfos for i in ivfcTagInfos) and not runIVF:
311  runIVFforCTagOnly = True
312  runIVF = True
313  sys.stderr.write("-------------------------------------------------------------------\n")
314  sys.stderr.write(" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
315  sys.stderr.write(" vertices will be remade.\n")
316  sys.stderr.write("-------------------------------------------------------------------\n")
317 
318  if runIVF and btagPrefix != '':
319  if runIVFforCTagOnly:
320  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
321  else:
322  svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
323  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
324 
325 
328 
329  runNegativeVertexing = False
330  runNegativeCvsLVertexing = False
331  for btagInfo in requiredTagInfos:
332  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos' or btagInfo == 'pfNegativeDeepFlavourTagInfos':
333  runNegativeVertexing = True
334  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
335  runNegativeCvsLVertexing = True
336 
337  if runNegativeVertexing or runNegativeCvsLVertexing:
338  import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff as NegVertex
339 
340  if runNegativeVertexing:
341  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix,
342  NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
343  process, task)
344  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix,
345  NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
346  process, task)
347  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix,
348  NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix)
349  ,primaryVertices = pvSource
350  ,tracks=pfCandidates),
351  process, task)
352  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
353  NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix)),
354  process, task)
355 
356  if runNegativeCvsLVertexing:
357  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
358  NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
359  process, task)
360  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix,
361  NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
362  process, task)
363  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix,
364  NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix)
365  ,primaryVertices = pvSource
366  ,tracks=pfCandidates),
367  process, task)
368  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
369  NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
370  process, task)
371 
372 
373  acceptedTagInfos = list()
374  for btagInfo in requiredTagInfos:
375  if hasattr(btag,btagInfo):
376  if btagInfo == 'pfImpactParameterTagInfos':
377  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
378  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
379  process, task)
380  if explicitJTA:
381  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
382  _btagInfo.explicitJTA = cms.bool(explicitJTA)
383  if tightBTagNTkHits:
384  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
385  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
386  _btagInfo.minimumNumberOfHits = cms.int32(8)
387  if btagInfo == 'pfImpactParameterAK8TagInfos':
388  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
389  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
390  process, task)
391  if explicitJTA:
392  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
393  _btagInfo.explicitJTA = cms.bool(explicitJTA)
394  if tightBTagNTkHits:
395  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
396  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
397  _btagInfo.minimumNumberOfHits = cms.int32(8)
398  if btagInfo == 'pfImpactParameterCA15TagInfos':
399  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
400  btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
401  process, task)
402  if explicitJTA:
403  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
404  _btagInfo.explicitJTA = cms.bool(explicitJTA)
405  if tightBTagNTkHits:
406  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
407  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
408  _btagInfo.minimumNumberOfHits = cms.int32(8)
409  if btagInfo == 'pfSecondaryVertexTagInfos':
410  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
411  btag.pfSecondaryVertexTagInfos.clone(
412  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
413  process, task)
414  if tightBTagNTkHits:
415  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
416  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
417  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
418  if btagInfo == 'pfDeepCSVTagInfos':
419  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
420  btag.pfDeepCSVTagInfos.clone(
421  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
422  process, task)
423  if svClustering or fatJets != cms.InputTag(''):
424  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
425  if btagInfo == 'pfDeepCSVNegativeTagInfos':
426  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
427  btag.pfDeepCSVNegativeTagInfos.clone(
428  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
429  process, task)
430  if svClustering or fatJets != cms.InputTag(''):
431  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
432  if btagInfo == 'pfDeepCSVPositiveTagInfos':
433  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
434  btag.pfDeepCSVPositiveTagInfos.clone(
435  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
436  process, task)
437  if svClustering or fatJets != cms.InputTag(''):
438  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
439  if btagInfo == 'pfDeepCMVATagInfos':
440  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
441  btag.pfDeepCMVATagInfos.clone(
442  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
443  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
444  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
445  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
446  process, task)
447  if svClustering or fatJets != cms.InputTag(''):
448  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
449  if btagInfo == 'pfDeepCMVANegativeTagInfos':
450  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
451  btag.pfDeepCMVATagInfos.clone(
452  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
453  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
454  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
455  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
456  process, task)
457  if svClustering or fatJets != cms.InputTag(''):
458  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
459  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
460  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
461  btag.pfDeepCMVATagInfos.clone(
462  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
463  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
464  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
465  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
466  process, task)
467  if svClustering or fatJets != cms.InputTag(''):
468  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
469  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
470  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
471  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
472  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
473  extSVCollection=svSource),
474  process, task)
475  if svClustering or fatJets != cms.InputTag(''):
476  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
477  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
478  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
479  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
480  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
481  extSVCollection=svSource),
482  process, task)
483  if svClustering or fatJets != cms.InputTag(''):
484  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
485  if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
486  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
487  btag.pfBoostedDoubleSVAK8TagInfos.clone(
488  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
489  process, task)
490  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
491  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
492  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
493  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
494  extSVCollection=svSource),
495  process, task)
496  if svClustering or fatJets != cms.InputTag(''):
497  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
498  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
499  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
500  btag.pfBoostedDoubleSVCA15TagInfos.clone(
501  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
502  process, task)
503  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
504  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
505  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
506  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
507  extSVCollection=svSourceCvsL),
508  process, task)
509  if svClustering or fatJets != cms.InputTag(''):
510  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
511  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
512  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
513  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
514  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
515  extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
516  process, task)
517  if svClustering or fatJets != cms.InputTag(''):
518  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
519  if btagInfo == 'pfGhostTrackVertexTagInfos':
520  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
521  btag.pfGhostTrackVertexTagInfos.clone(
522  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
523  process, task)
524  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
525  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
526  btag.pfSecondaryVertexNegativeTagInfos.clone(
527  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
528  process, task)
529  if tightBTagNTkHits:
530  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
531  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
532  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
533  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
534  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
535  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
536  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
537  extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
538  process, task)
539  if svClustering or fatJets != cms.InputTag(''):
540  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
541  if btagInfo == 'impactParameterTagInfos':
542  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
543  btag.impactParameterTagInfos.clone(
544  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
545  primaryVertex=pvSource),
546  process, task)
547  if btagInfo == 'secondaryVertexTagInfos':
548  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
549  btag.secondaryVertexTagInfos.clone(
550  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
551  process, task)
552  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
553  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
554  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
555  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
556  process, task)
557  if svClustering or fatJets != cms.InputTag(''):
558  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
559  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
560  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
561  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
562  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
563  process, task)
564  if svClustering or fatJets != cms.InputTag(''):
565  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
566  if btagInfo == 'secondaryVertexNegativeTagInfos':
567  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
568  btag.secondaryVertexNegativeTagInfos.clone(
569  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
570  process, task)
571  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
572  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
573  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
574  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
575  process, task)
576  if svClustering or fatJets != cms.InputTag(''):
577  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
578  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
579  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
580  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
581  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
582  process, task)
583  if svClustering or fatJets != cms.InputTag(''):
584  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
585  if btagInfo == 'softMuonTagInfos':
586  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
587  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
588  process, task)
589  if btagInfo == 'softPFMuonsTagInfos':
590  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
591  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
592  process, task)
593  if btagInfo == 'softPFElectronsTagInfos':
594  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
595  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
596  process, task)
597  if btagInfo == 'pixelClusterTagInfos':
598  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
599  btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
600  process, task)
601 
602  if 'pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo:
603  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
604  if pfCandidates.value() == 'packedPFCandidates':
605  _btagInfo.weights = cms.InputTag("packedpuppi")
606  if not hasattr(process,"packedpuppi"):
607  from CommonTools.PileupAlgos.Puppi_cff import puppi
608  addToProcessAndTask('packedpuppi', puppi.clone(
609  useExistingWeights = True,
610  candName = 'packedPFCandidates',
611  vertexName = 'offlineSlimmedPrimaryVertices') , process, task)
612  else:
613  _btagInfo.weights = cms.InputTag("puppi")
614 
615  if 'DeepFlavourTagInfos' in btagInfo:
616  svUsed = svSource
617  if btagInfo == 'pfNegativeDeepFlavourTagInfos':
618  deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
619  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
620  flip = True
621  else:
622  deep_csv_tag_infos = 'pfDeepCSVTagInfos'
623  flip = False
624  # use right input tags when running with RECO PF candidates, which actually
625  # depens of wether jets were slimmed or not (check for s/S-limmed in name)
626  if not ('limmed' in jetSource.value()):
627  puppi_value_map = cms.InputTag("puppi")
628  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
629  else:
630  puppi_value_map = cms.InputTag("")
631  vertex_associator = cms.InputTag("")
632  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
633  btag.pfDeepFlavourTagInfos.clone(
634  jets = jetSource,
635  vertices=pvSource,
636  secondary_vertices=svUsed,
637  shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
638  puppi_value_map = puppi_value_map,
639  vertex_associator = vertex_associator,
640  flip = flip),
641  process, task)
642 
643  if btagInfo == 'pfDeepDoubleXTagInfos':
644  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
645  btag.pfDeepDoubleXTagInfos.clone(
646  jets = jetSource,
647  vertices=pvSource,
648  secondary_vertices=svSource,
649  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
650  ),
651  process, task)
652 
653  if btagInfo == 'pfDeepBoostedJetTagInfos':
654  if pfCandidates.value() == 'packedPFCandidates':
655  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
656  if 'updated' not in jetSource.value().lower():
657  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
658  puppi_value_map = ""
659  vertex_associator = ""
660  elif pfCandidates.value() == 'particleFlow':
661  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
662  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
663  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
664  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
665 # puppi_value_map = "puppi"
666 # vertex_associator = "primaryVertexAssociation:original"
667  else:
668  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
669  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
670  btag.pfDeepBoostedJetTagInfos.clone(
671  jets = jetSource,
672  vertices = pvSource,
673  secondary_vertices = svSource,
674  pf_candidates = pfCandidates,
675  puppi_value_map = puppi_value_map,
676  vertex_associator = vertex_associator,
677  ),
678  process, task)
679 
680  if btagInfo == 'pfParticleNetTagInfos':
681  if pfCandidates.value() == 'packedPFCandidates':
682  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
683  puppi_value_map = ""
684  vertex_associator = ""
685  elif pfCandidates.value() == 'particleFlow':
686  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
687  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
688  puppi_value_map = "puppi"
689  vertex_associator = "primaryVertexAssociation:original"
690  else:
691  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
692  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
693  btag.pfParticleNetTagInfos.clone(
694  jets = jetSource,
695  vertices = pvSource,
696  secondary_vertices = svSource,
697  pf_candidates = pfCandidates,
698  puppi_value_map = puppi_value_map,
699  vertex_associator = vertex_associator,
700  ),
701  process, task)
702 
703  acceptedTagInfos.append(btagInfo)
704  elif hasattr(toptag, btagInfo) :
705  acceptedTagInfos.append(btagInfo)
706  else:
707  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
708 
709  acceptedBtagDiscriminators = list()
710  for discriminator_name in btagDiscriminators :
711  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
712  #print discriminator_name, '-->', btagDiscr
713  if hasattr(btag,btagDiscr):
714  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
715  if hasattr(process, newDiscr):
716  pass
717  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
719  newDiscr,
720  getattr(btag, btagDiscr).clone(
721  tagInfos = cms.VInputTag(
722  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
723  for x in supportedBtagDiscr[discriminator_name][0] ]
724  )
725  ),
726  process,
727  task
728  )
729  elif hasattr(getattr(btag, btagDiscr), 'src'):
731  newDiscr,
732  getattr(btag, btagDiscr).clone(
733  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
734  ),
735  process,
736  task
737  )
738  else:
739  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
740  acceptedBtagDiscriminators.append(discriminator_name)
741  else:
742  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
743  #update meta-taggers, if any
744  for meta_tagger in present_meta:
745  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
746  #print discriminator_name, '-->', btagDiscr
747  if hasattr(btag,btagDiscr):
748  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
749  if hasattr(process, newDiscr):
750  pass
751  else:
753  newDiscr,
754  getattr(btag, btagDiscr).clone(),
755  process,
756  task
757  )
758  for dependency in supportedMetaDiscr[meta_tagger]:
759  if ':' in dependency:
760  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
761  else:
762  new_dep = btagPrefix+dependency+labelName+postfix
763  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
764  replace.doIt(getattr(process, newDiscr), newDiscr)
765  acceptedBtagDiscriminators.append(meta_tagger)
766  else:
767  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
768 
769 
770  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
771  patJets.discriminatorSources = cms.VInputTag(*[
772  cms.InputTag(btagPrefix+x+labelName+postfix) \
773  if ':' not in x else \
774  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
775  for x in acceptedBtagDiscriminators
776  ])
777  if len(acceptedBtagDiscriminators) > 0 :
778  patJets.addBTagInfo = True
779 
780  if runIVF:
781  if not tightBTagNTkHits:
782  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
783  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
784  else:
785  rerunningIVF()
786  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
787  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
788  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
789  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
790  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
791  if tightBTagNTkHits:
792  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
793  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
794  _temp.minHits = cms.uint32(8)
795 
796  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
797  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
798  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
799  _temp.primaryVertices = pvSource
800  _temp.tracks = pfCandidates
801  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
802  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
803  _temp.primaryVertices = pvSource
804  _temp.tracks = pfCandidates
805  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
806  addToProcessAndTask(svSource.getModuleLabel(),
807  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
808  process, task)
809  if any(i in acceptedTagInfos for i in ivfcTagInfos):
810  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
811  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
812  if tightBTagNTkHits:
813  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
814  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
815  _temp.minHits = cms.uint32(8)
816 
817  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
818  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
819  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
820  _temp.primaryVertices = pvSource
821  _temp.tracks = pfCandidates
822  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
823  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
824  _temp.primaryVertices = pvSource
825  _temp.tracks = pfCandidates
826  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
827  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
828  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
829  process, task)
830  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
831  if not hasattr( process, 'inclusiveVertexing' ):
832  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
833  task.add(process.inclusiveVertexingTask)
834  task.add(process.inclusiveCandidateVertexingTask)
835  task.add(process.inclusiveCandidateVertexingCvsLTask)
836  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
837  if not hasattr( process, 'inclusiveVertexing' ):
838  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
839  task.add(process.inclusiveVertexingTask)
840  task.add(process.inclusiveCandidateVertexingTask)
841  task.add(process.inclusiveCandidateVertexingCvsLTask)
842  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
843  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
844  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
845  task.add(process.inclusiveSecondaryVerticesFiltered)
846  task.add(process.bVertexFilter)
847  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
848  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
849  task.add(process.bToCharmDecayVertexMerged)
850  if 'caTopTagInfos' in acceptedTagInfos :
851  patJets.addTagInfos = True
852  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
853  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
854  task.add(process.caTopTaggersTask)
855 

References helpers.addToProcessAndTask(), any(), clone(), helpers.getPatAlgosToolsTask(), list(), helpers.loadWithPrefix(), edm.print(), rerunningIVF(), rerunningIVFMiniAOD(), and setupSVClustering().

Referenced by jetTools.AddJetCollection.toolCode(), and jetTools.UpdateJetCollection.toolCode().

◆ setupJetCorrections()

def jetTools.setupJetCorrections (   process,
  knownModules,
  jetCorrections,
  jetSource,
  pvSource,
  patJets,
  labelName,
  postfix 
)

Definition at line 26 of file jetTools.py.

26 def setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix):
27 
28  task = getPatAlgosToolsTask(process)
29 
30 
34  _type="NONE"
35  if jetCorrections[0].count('PF')>0:
36  _type='PF'
37  elif jetCorrections[0].count('Calo')>0:
38  _type='Calo'
39  elif jetCorrections[0].count('JPT')>0:
40  _type='JPT'
41  else:
42  raise TypeError("In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets.")
43  from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
44  if 'patJetCorrFactors'+labelName+postfix in knownModules :
45  _newPatJetCorrFactors=getattr(process, 'patJetCorrFactors'+labelName+postfix)
46  _newPatJetCorrFactors.src=jetSource
47  _newPatJetCorrFactors.primaryVertices=pvSource
48  else:
49  addToProcessAndTask('patJetCorrFactors'+labelName+postfix,
50  patJetCorrFactors.clone(src=jetSource, primaryVertices=pvSource),
51  process, task)
52  _newPatJetCorrFactors=getattr(process, "patJetCorrFactors"+labelName+postfix)
53  _newPatJetCorrFactors.payload=jetCorrections[0]
54  _newPatJetCorrFactors.levels=jetCorrections[1]
55 
56  error=False
57  for x in jetCorrections[1]:
58  if x == 'L1Offset' :
59  if not error :
60  _newPatJetCorrFactors.useNPV=True
61  _newPatJetCorrFactors.primaryVertices='offlinePrimaryVertices'
62  _newPatJetCorrFactors.useRho=False
63 
65  error=True
66  else:
67  raise ValueError("In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
68  once. Check the list of correction levels you requested to be applied: "+ jetCorrections[1])
69  if x == 'L1FastJet' :
70  if not error :
71  if _type == "JPT" :
72  raise TypeError("In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets.")
73 
74  _newPatJetCorrFactors.useRho=True
75  if "PF" in _type :
76  _newPatJetCorrFactors.rho=cms.InputTag('fixedGridRhoFastjetAll')
77  else :
78  _newPatJetCorrFactors.rho=cms.InputTag('fixedGridRhoFastjetAllCalo')
79 
81  error=True
82  else:
83  raise ValueError("In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
84  once. Check the list of correction levels you requested to be applied: "+ jetCorrections[1])
85  patJets.jetCorrFactorsSource=cms.VInputTag(cms.InputTag('patJetCorrFactors'+labelName+postfix))
86 
87  if jetCorrections[2].lower() != 'none' and jetCorrections[2] != '':
88  if not jetCorrections[2].lower() == 'type-1' and not jetCorrections[2].lower() == 'type-2':
89  raise ValueError("In addJetCollection: Wrong choice of MET corrections for new jet collection. Possible choices are None (or empty string), Type-1, Type-2 (i.e.\
90  Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: "+ jetCorrections[2])
91  if _type == "JPT":
92  raise ValueError("In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to \"None\" (as string in quatiation \
93  marks) and use raw tcMET together with JPTJets.")
94 
95  process.load( "JetMETCorrections.Configuration.JetCorrectorsAllAlgos_cff") # FIXME: This adds a lot of garbage
96  # I second the FIXME comment on the last line. When I counted it, this brought in 344 EDProducers
97  # to be available to run unscheduled. All jet correctors, probably some small fraction of which
98  # are actually used.
99  task.add(process.jetCorrectorsAllAlgosTask)
100  _payloadType = jetCorrections[0].split(_type)[0].lower()+_type
101  if "PF" in _type :
102  addToProcessAndTask(jetCorrections[0]+'L1FastJet',
103  getattr(process, _payloadType+'L1FastjetCorrector').clone(srcRho=cms.InputTag('fixedGridRhoFastjetAll')),
104  process, task)
105  else :
106  addToProcessAndTask(jetCorrections[0]+'L1FastJet',
107  getattr(process, _payloadType+'L1FastjetCorrector').clone(srcRho=cms.InputTag('fixedGridRhoFastjetAllCalo')),
108  process, task)
109  addToProcessAndTask(jetCorrections[0]+'L1Offset', getattr(process, _payloadType+'L1OffsetCorrector').clone(), process, task)
110  addToProcessAndTask(jetCorrections[0]+'L2Relative', getattr(process, _payloadType+'L2RelativeCorrector').clone(), process, task)
111  addToProcessAndTask(jetCorrections[0]+'L3Absolute', getattr(process, _payloadType+'L3AbsoluteCorrector').clone(), process, task)
112  addToProcessAndTask(jetCorrections[0]+'L2L3Residual', getattr(process, _payloadType+'ResidualCorrector').clone(), process, task)
113  addToProcessAndTask(jetCorrections[0]+'CombinedCorrector',
114  cms.EDProducer( 'ChainedJetCorrectorProducer', correctors = cms.VInputTag()),
115  process, task)
116  for x in jetCorrections[1]:
117  if x != 'L1FastJet' and x != 'L1Offset' and x != 'L2Relative' and x != 'L3Absolute' and x != 'L2L3Residual':
118  raise ValueError('In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, L3Asolute, L2L3Residual. Requested was: %s'%(x))
119  else:
120  _corrector = _payloadType
121  if x == 'L1FastJet':
122  _corrector += 'L1Fastjet'
123  elif x == 'L2L3Residual':
124  _corrector += 'Residual'
125  else:
126  _corrector += x
127  _corrector += 'Corrector'
128  getattr(process, jetCorrections[0]+'CombinedCorrector').correctors.append(cms.InputTag(_corrector))
129 
130 
131  _labelCorrName = labelName
132  if labelName != '':
133  _labelCorrName = 'For' + labelName
134  if _type == 'Calo':
135  from JetMETCorrections.Type1MET.correctionTermsCaloMet_cff import corrCaloMetType1
136  from JetMETCorrections.Type1MET.correctionTermsCaloMet_cff import corrCaloMetType2
137  from JetMETCorrections.Type1MET.correctedMet_cff import caloMetT1
138  from JetMETCorrections.Type1MET.correctedMet_cff import caloMetT1T2
140  jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix,
141  corrCaloMetType1.clone(src=jetSource,srcMET = "caloMetM",jetCorrLabel = cms.InputTag(jetCorrections[0]+'CombinedCorrector')),
142  process, task)
144  jetCorrections[0]+_labelCorrName+'JetMETcorr2'+postfix,
145  corrCaloMetType2.clone(srcUnclEnergySums = cms.VInputTag(
146  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type2'),
147  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'offset'),
148  cms.InputTag('muCaloMetCorr'))),
149  process, task)
151  jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix,
152  caloMetT1.clone(src = "caloMetM", srcCorrections = cms.VInputTag(
153  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'))),
154  process, task)
155  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix,
156  caloMetT1T2.clone(src = "caloMetM", srcCorrections = cms.VInputTag(
157  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'),
158  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr2'+postfix))),
159  process, task)
160  elif _type == 'PF':
162  from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandsNotInJetsPtrForMetCorr
163  from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandsNotInJetsForMetCorr
167  from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1
168  from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1T2
169  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'pfJetsPtrForMetCorr'+postfix,
170  pfJetsPtrForMetCorr.clone(src = jetSource), process, task)
172  jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsPtrForMetCorr'+postfix,
173  pfCandsNotInJetsPtrForMetCorr.clone(topCollection = jetCorrections[0]+_labelCorrName+'pfJetsPtrForMetCorr'+postfix),
174  process, task)
176  jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsForMetCorr'+postfix,
177  pfCandsNotInJetsForMetCorr.clone(src = jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsPtrForMetCorr'+postfix),
178  process, task)
180  jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix,
181  pfCandMETcorr.clone(src = cms.InputTag(jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsForMetCorr'+postfix)),
182  process, task)
184  jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix,
185  corrPfMetType1.clone(src = jetSource, jetCorrLabel = cms.InputTag(jetCorrections[0]+'CombinedCorrector')),
186  process, task) # FIXME: Originally w/o jet corrections?
187  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'corrPfMetType2'+postfix,
188  corrPfMetType2.clone(srcUnclEnergySums = cms.VInputTag(
189  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type2'),
190  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'offset'),
191  cms.InputTag(jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix))),
192  process, task)
193  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix,
194  pfMetT1.clone(srcCorrections = cms.VInputTag(
195  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'))),
196  process, task)
197  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix,
198  pfMetT1T2.clone(srcCorrections = cms.VInputTag(
199  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'),
200  jetCorrections[0]+_labelCorrName+'corrPfMetType2'+postfix)),
201  process, task)
202  if 'Puppi' in jetSource.value() and pfCandidates.value() == 'particleFlow':
203  getattr(process,jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix).srcWeights = "puppiNoLep"
204 
205 
206  if ('L1FastJet' in jetCorrections[1] or 'L1Fastjet' in jetCorrections[1]):
207  getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag(jetCorrections[0]+'L1FastJet')
208  #FIXME: What is wrong here?
209  #elif ('L1Offset' in jetCorrections[1]):
210  #getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag(jetCorrections[0]+'L1Offset')
211  else:
212  getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag('')
213 
215  if jetCorrections[2].lower() == 'type-1':
216  addToProcessAndTask('patMETs'+labelName+postfix,
217  patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix),
218  addMuonCorrections = False),
219  process, task)
220  elif jetCorrections[2].lower() == 'type-2':
221  addToProcessAndTask('patMETs'+labelName+postfix,
222  patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix),
223  addMuonCorrections = False),
224  process, task)
225 
226 

References helpers.addToProcessAndTask(), clone(), KineDebug3.count(), helpers.getPatAlgosToolsTask(), and cms::dd.split().

Referenced by jetTools.AddJetCollection.toolCode(), and jetTools.UpdateJetCollection.toolCode().

◆ setupSVClustering()

def jetTools.setupSVClustering (   btagInfo,
  svClustering,
  algo,
  rParam,
  fatJets = cms.InputTag(''),
  groomedFatJets = cms.InputTag('') 
)

Definition at line 227 of file jetTools.py.

227 def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag('')):
228  btagInfo.useSVClustering = cms.bool(svClustering)
229  btagInfo.jetAlgorithm = cms.string(algo)
230  btagInfo.rParam = cms.double(rParam)
231 
232  if fatJets != cms.InputTag(''):
233  btagInfo.fatJets = fatJets
234  if groomedFatJets != cms.InputTag(''):
235  btagInfo.groomedFatJets = groomedFatJets
236 
237 

Referenced by setupBTagging().

◆ undefinedLabelName()

def jetTools.undefinedLabelName (   obj)

Definition at line 1870 of file jetTools.py.

1870 def undefinedLabelName(obj):
1871  sys.stderr.write("-------------------------------------------------------\n")
1872  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1873  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1874  sys.stderr.write("-------------------------------------------------------\n")
1875  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1876 

Referenced by jetTools.AddJetCollection.toolCode().

◆ unsupportedJetAlgorithm()

def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 1877 of file jetTools.py.

1877 def unsupportedJetAlgorithm(obj):
1878  sys.stderr.write("-------------------------------------------------------\n")
1879  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1880  sys.stderr.write(" The supported algorithms are:\n")
1881  for key in supportedJetAlgos.keys():
1882  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1883  sys.stderr.write("-------------------------------------------------------\n")
1884  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1885 

Referenced by jetTools.AddJetCollection.toolCode(), and jetTools.UpdateJetCollection.toolCode().

Variable Documentation

◆ supportedJetAlgos

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 12 of file jetTools.py.

RecoBTag_cff
jetTools.rerunningIVF
def rerunningIVF()
Definition: jetTools.py:1886
helpers.getPatAlgosToolsTask
def getPatAlgosToolsTask(process)
Definition: helpers.py:14
jetTools.checkJetCorrectionsFormat
def checkJetCorrectionsFormat(jetCorrections)
Definition: jetTools.py:18
correctionTermsPfMetType1Type2_cff
Puppi_cff
cms::dd::split
std::vector< std::string_view > split(std::string_view, const char *)
jetTools.jetAlgo
def jetAlgo(algo)
Definition: jetTools.py:3
any
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
jetCorrFactors_cfi
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
metProducer_cfi
jetTools.deprecatedOptionOutputModule
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1859
ak4PFJets_cfi
jetTools.undefinedLabelName
def undefinedLabelName(obj)
Definition: jetTools.py:1870
jetTools.setupJetCorrections
def setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix)
Definition: jetTools.py:26
jetTools.unsupportedJetAlgorithm
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1877
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
helpers
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
jetTools.setupBTagging
def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets, algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix)
Definition: jetTools.py:238
helpers.loadWithPrefix
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
Definition: helpers.py:44
correctionTermsCaloMet_cff
list
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*", "!HLTx*" if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL. It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of "!*" before the partial wildcard feature was incorporated). Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
jetTools.setupSVClustering
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:227
helpers.addToProcessAndTask
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:29
jetTools.rerunningIVFMiniAOD
def rerunningIVFMiniAOD()
Definition: jetTools.py:1894