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 setupPuppiForPackedPF (process, useExistingWeights=True, 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 23 of file jetTools.py.

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

23 def checkJetCorrectionsFormat(jetCorrections):
24 
25  if not isinstance(jetCorrections, type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL'))):
26  raise ValueError("In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
27  '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) \
28  corrections.")
29 
30 
def checkJetCorrectionsFormat(jetCorrections)
Definition: jetTools.py:23

◆ deprecatedOptionOutputModule()

def jetTools.deprecatedOptionOutputModule (   obj)

Definition at line 2214 of file jetTools.py.

2215  sys.stderr.write("-------------------------------------------------------\n")
2216  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
2217  sys.stderr.write(" anymore by:\n")
2218  sys.stderr.write(" " + obj._label + "\n")
2219  sys.stderr.write(" please use 'outputModules' now and specify the\n")
2220  sys.stderr.write(" names of all needed OutModules in there\n")
2221  sys.stderr.write(" (default: ['out'])\n")
2222  sys.stderr.write("-------------------------------------------------------\n")
2223  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
2224 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:2214

◆ 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
23 
def jetAlgo(algo)
Definition: jetTools.py:3

◆ rerunningIVF()

def jetTools.rerunningIVF ( )

Definition at line 2241 of file jetTools.py.

Referenced by setupBTagging().

2241 def rerunningIVF():
2242  sys.stderr.write("-------------------------------------------------------------------\n")
2243  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
2244  sys.stderr.write(" already produced by the standard reconstruction. This\n")
2245  sys.stderr.write(" option is not enabled by default so please use it only if\n")
2246  sys.stderr.write(" you know what you are doing.\n")
2247  sys.stderr.write("-------------------------------------------------------------------\n")
2248 
def rerunningIVF()
Definition: jetTools.py:2241

◆ rerunningIVFMiniAOD()

def jetTools.rerunningIVFMiniAOD ( )

Definition at line 2249 of file jetTools.py.

Referenced by setupBTagging().

2249 def rerunningIVFMiniAOD():
2250  sys.stderr.write("-------------------------------------------------------------------\n")
2251  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
2252  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
2253  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
2254  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
2255  sys.stderr.write("-------------------------------------------------------------------\n")
2256 
def rerunningIVFMiniAOD()
Definition: jetTools.py:2249

◆ 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 271 of file jetTools.py.

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

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

271  algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
272 
273  task = getPatAlgosToolsTask(process)
274 
275 
276  discriminators = set(btagDiscriminators)
277  present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
278  discriminators -= present_metaSet
279  for meta_tagger in present_metaSet:
280  for src in supportedMetaDiscr[meta_tagger]:
281  discriminators.add(src)
282  present_meta = sorted(present_metaSet)
283  btagDiscriminators = sorted(discriminators)
284 
285 
287  requiredTagInfos = list(btagInfos)
288  for btagDiscr in btagDiscriminators :
289  for tagInfoList in supportedBtagDiscr[btagDiscr] :
290  for requiredTagInfo in tagInfoList :
291  tagInfoCovered = False
292  for tagInfo in requiredTagInfos :
293  if requiredTagInfo == tagInfo :
294  tagInfoCovered = True
295  break
296  if not tagInfoCovered :
297  requiredTagInfos.append(requiredTagInfo)
298 
299  if hasattr( process, 'candidateJetProbabilityComputer' ) == False :
300  if loadStdRecoBTag: # also loading modules already run in the standard reconstruction
301  process.load("RecoBTag.ImpactParameter.impactParameter_cff")
302  task.add(process.impactParameterTask)
303  process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
304  task.add(process.secondaryVertexTask)
305  process.load("RecoBTag.SoftLepton.softLepton_cff")
306  task.add(process.softLeptonTask)
307  process.load("RecoBTag.Combined.combinedMVA_cff")
308  task.add(process.combinedMVATask)
309  process.load("RecoBTag.CTagging.cTagging_cff")
310  task.add(process.cTaggingTask)
311  else: # to prevent loading of modules already run in the standard reconstruction
312  process.load("RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
313  process.load("RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
314  process.load("RecoBTag.SoftLepton.softLepton_EventSetup_cff")
315  process.load("RecoBTag.Combined.combinedMVA_EventSetup_cff")
316  process.load("RecoBTag.CTagging.cTagging_EventSetup_cff")
318  import RecoJets.JetProducers.caTopTaggers_cff as toptag
319 
320  if tightBTagNTkHits:
321  if not runIVF:
322  sys.stderr.write("-------------------------------------------------------------------\n")
323  sys.stderr.write(" Warning: For a complete switch to the legacy tight b-tag track\n")
324  sys.stderr.write(" selection, please also enable the \'runIVF\' switch.\n")
325  sys.stderr.write("-------------------------------------------------------------------\n")
326  if btagPrefix == '':
327  sys.stderr.write("-------------------------------------------------------------------\n")
328  sys.stderr.write(" Warning: With the tight b-tag track selection enabled, it is\n")
329  sys.stderr.write(" advisable to set \'btagPrefix\' to a non-empty string to\n")
330  sys.stderr.write(" avoid unintentional modifications to the default\n")
331  sys.stderr.write(" b tagging setup that might be loaded in the same job.\n")
332  sys.stderr.write("-------------------------------------------------------------------\n")
333 
334 
336  svSourceCvsL = copy.deepcopy(svSource)
337  svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+'CvsL')
338 
339 
340  runIVFforCTagOnly = False
341  ivfcTagInfos = ['pfInclusiveSecondaryVertexFinderCvsLTagInfos', 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
342 
343  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices' and any(i in requiredTagInfos for i in ivfcTagInfos) and not runIVF:
344  runIVFforCTagOnly = True
345  runIVF = True
346  sys.stderr.write("-------------------------------------------------------------------\n")
347  sys.stderr.write(" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
348  sys.stderr.write(" vertices will be remade.\n")
349  sys.stderr.write("-------------------------------------------------------------------\n")
350 
351  if runIVF and btagPrefix != '':
352  if runIVFforCTagOnly:
353  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
354  else:
355  svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
356  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
357 
358 
361 
362  runNegativeVertexing = False
363  runNegativeCvsLVertexing = False
364  for btagInfo in requiredTagInfos:
365  if btagInfo in (
366  'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
367  'pfNegativeDeepFlavourTagInfos',
368  'pfNegativeParticleNetAK4TagInfos',
369  ):
370  runNegativeVertexing = True
371  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
372  runNegativeCvsLVertexing = True
373 
374  if runNegativeVertexing or runNegativeCvsLVertexing:
375  import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff as NegVertex
376 
377  if runNegativeVertexing:
378  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix,
379  NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
380  process, task)
381  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix,
382  NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
383  process, task)
384  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix,
385  NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix)
386  ,primaryVertices = pvSource
387  ,tracks=pfCandidates),
388  process, task)
389  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
390  NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix)),
391  process, task)
392 
393  if runNegativeCvsLVertexing:
394  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
395  NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
396  process, task)
397  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix,
398  NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
399  process, task)
400  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix,
401  NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix)
402  ,primaryVertices = pvSource
403  ,tracks=pfCandidates),
404  process, task)
405  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
406  NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
407  process, task)
408 
409 
410  acceptedTagInfos = list()
411  for btagInfo in requiredTagInfos:
412  if hasattr(btag,btagInfo):
413  if btagInfo == 'pfImpactParameterTagInfos':
414  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
415  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
416  process, task)
417  if explicitJTA:
418  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
419  _btagInfo.explicitJTA = cms.bool(explicitJTA)
420  if tightBTagNTkHits:
421  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
422  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
423  _btagInfo.minimumNumberOfHits = cms.int32(8)
424  if btagInfo == 'pfImpactParameterAK8TagInfos':
425  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
426  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
427  process, task)
428  if explicitJTA:
429  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
430  _btagInfo.explicitJTA = cms.bool(explicitJTA)
431  if tightBTagNTkHits:
432  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
433  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
434  _btagInfo.minimumNumberOfHits = cms.int32(8)
435  if btagInfo == 'pfImpactParameterCA15TagInfos':
436  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
437  btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
438  process, task)
439  if explicitJTA:
440  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
441  _btagInfo.explicitJTA = cms.bool(explicitJTA)
442  if tightBTagNTkHits:
443  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
444  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
445  _btagInfo.minimumNumberOfHits = cms.int32(8)
446  if btagInfo == 'pfSecondaryVertexTagInfos':
447  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
448  btag.pfSecondaryVertexTagInfos.clone(
449  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
450  process, task)
451  if tightBTagNTkHits:
452  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
453  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
454  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
455  if btagInfo == 'pfDeepCSVTagInfos':
456  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
457  btag.pfDeepCSVTagInfos.clone(
458  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
459  process, task)
460  if svClustering or fatJets != cms.InputTag(''):
461  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
462  if btagInfo == 'pfDeepCSVNegativeTagInfos':
463  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
464  btag.pfDeepCSVNegativeTagInfos.clone(
465  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+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 == 'pfDeepCSVPositiveTagInfos':
470  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
471  btag.pfDeepCSVPositiveTagInfos.clone(
472  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
473  process, task)
474  if svClustering or fatJets != cms.InputTag(''):
475  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
476  if btagInfo == 'pfDeepCMVATagInfos':
477  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
478  btag.pfDeepCMVATagInfos.clone(
479  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
480  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
481  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
482  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
483  process, task)
484  if svClustering or fatJets != cms.InputTag(''):
485  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
486  if btagInfo == 'pfDeepCMVANegativeTagInfos':
487  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
488  btag.pfDeepCMVATagInfos.clone(
489  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
490  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
491  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
492  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
493  process, task)
494  if svClustering or fatJets != cms.InputTag(''):
495  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
496  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
497  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
498  btag.pfDeepCMVATagInfos.clone(
499  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
500  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
501  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
502  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
503  process, task)
504  if svClustering or fatJets != cms.InputTag(''):
505  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
506  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
507  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
508  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
509  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
510  extSVCollection=svSource),
511  process, task)
512  if svClustering or fatJets != cms.InputTag(''):
513  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
514  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
515  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
516  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
517  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
518  extSVCollection=svSource),
519  process, task)
520  if svClustering or fatJets != cms.InputTag(''):
521  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
522  if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
523  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
524  btag.pfBoostedDoubleSVAK8TagInfos.clone(
525  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
526  process, task)
527  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
528  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
529  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
530  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
531  extSVCollection=svSource),
532  process, task)
533  if svClustering or fatJets != cms.InputTag(''):
534  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
535  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
536  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
537  btag.pfBoostedDoubleSVCA15TagInfos.clone(
538  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
539  process, task)
540  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
541  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
542  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
543  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
544  extSVCollection=svSourceCvsL),
545  process, task)
546  if svClustering or fatJets != cms.InputTag(''):
547  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
548  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
549  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
550  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
551  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
552  extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
553  process, task)
554  if svClustering or fatJets != cms.InputTag(''):
555  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
556  if btagInfo == 'pfGhostTrackVertexTagInfos':
557  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
558  btag.pfGhostTrackVertexTagInfos.clone(
559  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
560  process, task)
561  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
562  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
563  btag.pfSecondaryVertexNegativeTagInfos.clone(
564  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
565  process, task)
566  if tightBTagNTkHits:
567  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
568  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
569  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
570  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
571  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
572  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
573  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
574  extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+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 == 'impactParameterTagInfos':
579  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
580  btag.impactParameterTagInfos.clone(
581  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
582  primaryVertex=pvSource),
583  process, task)
584  if btagInfo == 'secondaryVertexTagInfos':
585  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
586  btag.secondaryVertexTagInfos.clone(
587  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
588  process, task)
589  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
590  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
591  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
592  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
593  process, task)
594  if svClustering or fatJets != cms.InputTag(''):
595  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
596  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
597  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
598  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
599  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
600  process, task)
601  if svClustering or fatJets != cms.InputTag(''):
602  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
603  if btagInfo == 'secondaryVertexNegativeTagInfos':
604  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
605  btag.secondaryVertexNegativeTagInfos.clone(
606  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
607  process, task)
608  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
609  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
610  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
611  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
612  process, task)
613  if svClustering or fatJets != cms.InputTag(''):
614  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
615  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
616  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
617  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
618  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
619  process, task)
620  if svClustering or fatJets != cms.InputTag(''):
621  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
622  if btagInfo == 'softMuonTagInfos':
623  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
624  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
625  process, task)
626  if btagInfo == 'softPFMuonsTagInfos':
627  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
628  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
629  process, task)
630  if btagInfo == 'softPFElectronsTagInfos':
631  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
632  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
633  process, task)
634  if btagInfo == 'pixelClusterTagInfos':
635  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
636  btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
637  process, task)
638 
639 
640 
641  if 'pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo:
642  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
643  if pfCandidates.value() == 'packedPFCandidates':
644  packedPFPuppiLabel = setupPuppiForPackedPF(process)[0]
645  _btagInfo.weights = cms.InputTag(packedPFPuppiLabel)
646  else:
647  _btagInfo.weights = cms.InputTag("puppi")
648 
649  if 'DeepFlavourTagInfos' in btagInfo:
650  svUsed = svSource
651  if btagInfo == 'pfNegativeDeepFlavourTagInfos':
652  deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
653  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
654  flip = True
655  else:
656  deep_csv_tag_infos = 'pfDeepCSVTagInfos'
657  flip = False
658 
659  # use right input tags when running with RECO PF candidates, which actually
660  # depends of whether jets use "particleFlow"
661  if pfCandidates.value() == 'packedPFCandidates':
662  puppi_value_map = setupPuppiForPackedPF(process)[0]
663  vertex_associator = cms.InputTag("")
664  else:
665  puppi_value_map = cms.InputTag("puppi")
666  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
667 
668  # If this jet is a puppi jet, then set is_weighted_jet to true.
669  is_weighted_jet = False
670  if ('puppi' in jetSource.value().lower()):
671  is_weighted_jet = True
672  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
673  btag.pfDeepFlavourTagInfos.clone(
674  jets = jetSource,
675  vertices=pvSource,
676  secondary_vertices=svUsed,
677  shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
678  puppi_value_map = puppi_value_map,
679  vertex_associator = vertex_associator,
680  is_weighted_jet = is_weighted_jet,
681  flip = flip),
682  process, task)
683 
684  if 'ParticleTransformerAK4TagInfos' in btagInfo:
685  svUsed = svSource
686  if btagInfo == 'pfNegativeParticleTransformerAK4TagInfos':
687  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
688  flip = True
689  else:
690  flip = False
691  # use right input tags when running with RECO PF candidates, which actually
692  # depends of whether jets use "particleFlow"
693  if pfCandidates.value() == 'packedPFCandidates':
694  puppi_value_map = setupPuppiForPackedPF(process)[0]
695  vertex_associator = cms.InputTag("")
696  else:
697  puppi_value_map = cms.InputTag("puppi")
698  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
699 
700  # If this jet is a puppi jet, then set is_weighted_jet to true.
701  is_weighted_jet = False
702  if ('puppi' in jetSource.value().lower()):
703  is_weighted_jet = True
704  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
705  btag.pfParticleTransformerAK4TagInfos.clone(
706  jets = jetSource,
707  vertices=pvSource,
708  secondary_vertices=svUsed,
709  puppi_value_map = puppi_value_map,
710  vertex_associator = vertex_associator,
711  is_weighted_jet = is_weighted_jet,
712  flip = flip),
713  process, task)
714  if btagInfo == 'pfDeepDoubleXTagInfos':
715  # can only run on PAT jets, so the updater needs to be used
716  if 'updated' not in jetSource.value().lower():
717  raise ValueError("Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
718  packedPFPuppiLabel = setupPuppiForPackedPF(process)[0]
719  puppi_value_map = cms.InputTag(packedPFPuppiLabel)
720  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
721  btag.pfDeepDoubleXTagInfos.clone(
722  jets = jetSource,
723  vertices=pvSource,
724  secondary_vertices=svSource,
725  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
726  puppi_value_map = puppi_value_map,
727  ),
728  process, task)
729  if btagInfo == 'pfHiggsInteractionNetTagInfos':
730  packedPFPuppiLabel = setupPuppiForPackedPF(process)[0]
731  puppi_value_map = cms.InputTag(packedPFPuppiLabel)
732  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
733  btag.pfHiggsInteractionNetTagInfos.clone(
734  jets = jetSource,
735  vertices = pvSource,
736  secondary_vertices = svSource,
737  pf_candidates = pfCandidates,
738  puppi_value_map = puppi_value_map
739  ),
740  process, task)
741 
742  if btagInfo == 'pfDeepBoostedJetTagInfos':
743  if pfCandidates.value() == 'packedPFCandidates':
744  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
745  if 'updated' not in jetSource.value().lower():
746  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
747  puppi_value_map = setupPuppiForPackedPF(process)[0]
748  vertex_associator = ""
749  elif pfCandidates.value() == 'particleFlow':
750  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
751  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
752  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
753  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
754 # puppi_value_map = "puppi"
755 # vertex_associator = "primaryVertexAssociation:original"
756  else:
757  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
758  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
759  btag.pfDeepBoostedJetTagInfos.clone(
760  jets = jetSource,
761  vertices = pvSource,
762  secondary_vertices = svSource,
763  pf_candidates = pfCandidates,
764  puppi_value_map = puppi_value_map,
765  vertex_associator = vertex_associator,
766  ),
767  process, task)
768 
769  if btagInfo == 'pfParticleNetTagInfos':
770  if pfCandidates.value() == 'packedPFCandidates':
771  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
772  puppi_value_map = setupPuppiForPackedPF(process)[0]
773  vertex_associator = ""
774  elif pfCandidates.value() == 'particleFlow':
775  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
776  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
777  puppi_value_map = "puppi"
778  vertex_associator = "primaryVertexAssociation:original"
779  else:
780  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
781  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
782  btag.pfParticleNetTagInfos.clone(
783  jets = jetSource,
784  vertices = pvSource,
785  secondary_vertices = svSource,
786  pf_candidates = pfCandidates,
787  puppi_value_map = puppi_value_map,
788  vertex_associator = vertex_associator,
789  ),
790  process, task)
791 
792  if 'ParticleNetAK4TagInfos' in btagInfo:
793  if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
794  secondary_vertices = btagPrefix + \
795  'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
796  flip_ip_sign = True
797  sip3dSigMax = 10
798  else:
799  secondary_vertices = svSource
800  flip_ip_sign = False
801  sip3dSigMax = -1
802  if pfCandidates.value() == 'packedPFCandidates':
803  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
804  puppi_value_map = setupPuppiForPackedPF(process)[0]
805  vertex_associator = ""
806  elif pfCandidates.value() == 'particleFlow':
807  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
808  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
809  puppi_value_map = "puppi"
810  vertex_associator = "primaryVertexAssociation:original"
811  else:
812  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
813  # If this jet is a Puppi jet, use puppi-weighted p4.
814  use_puppiP4 = False
815  if "puppi" in jetSource.value().lower():
816  use_puppiP4 = True
817  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
818  btag.pfParticleNetAK4TagInfos.clone(
819  jets = jetSource,
820  vertices = pvSource,
821  secondary_vertices = secondary_vertices,
822  pf_candidates = pfCandidates,
823  puppi_value_map = puppi_value_map,
824  vertex_associator = vertex_associator,
825  flip_ip_sign = flip_ip_sign,
826  sip3dSigMax = sip3dSigMax,
827  use_puppiP4 = use_puppiP4
828  ),
829  process, task)
830 
831  acceptedTagInfos.append(btagInfo)
832  elif hasattr(toptag, btagInfo) :
833  acceptedTagInfos.append(btagInfo)
834  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos':
835  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
836  if pfCandidates.value() != 'packedPFCandidates':
837  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
838  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
839  pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
840  jets = jetSource,
841  vertices = pvSource,
842  secondary_vertices = svSource,
843  pf_candidates = pfCandidates,
844  ),
845  process, task)
846  acceptedTagInfos.append(btagInfo)
847  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
848  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
849  if pfCandidates.value() != 'packedPFCandidates':
850  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
851  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
852  pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
853  jets = jetSource,
854  vertices = pvSource,
855  secondary_vertices = svSource,
856  pf_candidates = pfCandidates,
857  ),
858  process, task)
859  acceptedTagInfos.append(btagInfo)
860  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSCentralTagInfos':
861  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
862  if pfCandidates.value() != 'packedPFCandidates':
863  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
864  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
865  pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
866  jets = jetSource,
867  vertices = pvSource,
868  secondary_vertices = svSource,
869  pf_candidates = pfCandidates,
870  ),
871  process, task)
872  acceptedTagInfos.append(btagInfo)
873  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
874  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
875  if pfCandidates.value() != 'packedPFCandidates':
876  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
877  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
878  pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
879  jets = jetSource,
880  vertices = pvSource,
881  secondary_vertices = svSource,
882  pf_candidates = pfCandidates,
883  ),
884  process, task)
885  acceptedTagInfos.append(btagInfo)
886  elif btagInfo == 'pfParticleNetFromMiniAODAK8TagInfos':
887  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
888  if pfCandidates.value() != 'packedPFCandidates':
889  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
890  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
891  pfParticleNetFromMiniAODAK8TagInfos.clone(
892  jets = jetSource,
893  vertices = pvSource,
894  secondary_vertices = svSource,
895  pf_candidates = pfCandidates,
896  ),
897  process, task)
898  acceptedTagInfos.append(btagInfo)
899  else:
900  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
901  # setup all required btagDiscriminators
902  acceptedBtagDiscriminators = list()
903  for discriminator_name in btagDiscriminators :
904  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
905  #print discriminator_name, '-->', btagDiscr
906  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
907  if hasattr(btag,btagDiscr):
908  if hasattr(process, newDiscr):
909  pass
910  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
912  newDiscr,
913  getattr(btag, btagDiscr).clone(
914  tagInfos = cms.VInputTag(
915  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
916  for x in supportedBtagDiscr[discriminator_name][0] ]
917  )
918  ),
919  process,
920  task
921  )
922  elif hasattr(getattr(btag, btagDiscr), 'src'):
924  newDiscr,
925  getattr(btag, btagDiscr).clone(
926  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
927  ),
928  process,
929  task
930  )
931  else:
932  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
933  acceptedBtagDiscriminators.append(discriminator_name)
934  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
935  if hasattr(process, newDiscr):
936  pass
938  newDiscr,
939  pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
940  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
941  ),
942  process,
943  task
944  )
945  acceptedBtagDiscriminators.append(discriminator_name)
946  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
947  if hasattr(process, newDiscr):
948  pass
950  newDiscr,
951  pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
952  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
953  ),
954  process,
955  task
956  )
957  acceptedBtagDiscriminators.append(discriminator_name)
958  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralJetTags':
959  if hasattr(process, newDiscr):
960  pass
962  newDiscr,
963  pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
964  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
965  ),
966  process,
967  task
968  )
969  acceptedBtagDiscriminators.append(discriminator_name)
970  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardJetTags':
971  if hasattr(process, newDiscr):
972  pass
974  newDiscr,
975  pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
976  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
977  ),
978  process,
979  task
980  )
981  acceptedBtagDiscriminators.append(discriminator_name)
982  elif btagDiscr=='pfParticleNetFromMiniAODAK8JetTags':
983  if hasattr(process, newDiscr):
984  pass
986  newDiscr,
987  pfParticleNetFromMiniAODAK8JetTags.clone(
988  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
989  ),
990  process,
991  task
992  )
993  acceptedBtagDiscriminators.append(discriminator_name)
994  else:
995  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
996 
997  #update meta-taggers, if any
998  for meta_tagger in present_meta:
999  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
1000  #print discriminator_name, '-->', btagDiscr
1001  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
1002  if hasattr(btag,btagDiscr):
1003  if hasattr(process, newDiscr):
1004  pass
1005  else:
1007  newDiscr,
1008  getattr(btag, btagDiscr).clone(),
1009  process,
1010  task
1011  )
1012  for dependency in supportedMetaDiscr[meta_tagger]:
1013  if ':' in dependency:
1014  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1015  else:
1016  new_dep = btagPrefix+dependency+labelName+postfix
1017  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1018  replace.doIt(getattr(process, newDiscr), newDiscr)
1019  acceptedBtagDiscriminators.append(meta_tagger)
1020  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
1021  if hasattr(process, newDiscr):
1022  pass
1023  else:
1025  newDiscr,
1026  pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
1027  process,
1028  task
1029  )
1030  for dependency in supportedMetaDiscr[meta_tagger]:
1031  if ':' in dependency:
1032  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1033  else:
1034  new_dep = btagPrefix+dependency+labelName+postfix
1035  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1036  replace.doIt(getattr(process, newDiscr), newDiscr)
1037  acceptedBtagDiscriminators.append(meta_tagger)
1038  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
1039  if hasattr(process, newDiscr):
1040  pass
1041  else:
1043  newDiscr,
1044  pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
1045  process,
1046  task
1047  )
1048  for dependency in supportedMetaDiscr[meta_tagger]:
1049  if ':' in dependency:
1050  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1051  else:
1052  new_dep = btagPrefix+dependency+labelName+postfix
1053  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1054  replace.doIt(getattr(process, newDiscr), newDiscr)
1055  acceptedBtagDiscriminators.append(meta_tagger)
1056  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1057  if hasattr(process, newDiscr):
1058  pass
1059  else:
1061  newDiscr,
1062  pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1063  process,
1064  task
1065  )
1066  for dependency in supportedMetaDiscr[meta_tagger]:
1067  if ':' in dependency:
1068  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1069  else:
1070  new_dep = btagPrefix+dependency+labelName+postfix
1071  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1072  replace.doIt(getattr(process, newDiscr), newDiscr)
1073  acceptedBtagDiscriminators.append(meta_tagger)
1074  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1075  if hasattr(process, newDiscr):
1076  pass
1077  else:
1079  newDiscr,
1080  pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1081  process,
1082  task
1083  )
1084  for dependency in supportedMetaDiscr[meta_tagger]:
1085  if ':' in dependency:
1086  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1087  else:
1088  new_dep = btagPrefix+dependency+labelName+postfix
1089  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1090  replace.doIt(getattr(process, newDiscr), newDiscr)
1091  acceptedBtagDiscriminators.append(meta_tagger)
1092  elif btagDiscr=='pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1093  if hasattr(process, newDiscr):
1094  pass
1095  else:
1097  newDiscr,
1098  pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1099  process,
1100  task
1101  )
1102  for dependency in supportedMetaDiscr[meta_tagger]:
1103  if ':' in dependency:
1104  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1105  else:
1106  new_dep = btagPrefix+dependency+labelName+postfix
1107  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1108  replace.doIt(getattr(process, newDiscr), newDiscr)
1109  acceptedBtagDiscriminators.append(meta_tagger)
1110 
1111  else:
1112  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1113 
1114 
1115  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
1116  patJets.discriminatorSources = cms.VInputTag(*[
1117  cms.InputTag(btagPrefix+x+labelName+postfix) \
1118  if ':' not in x else \
1119  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
1120  for x in acceptedBtagDiscriminators
1121  ])
1122  if len(acceptedBtagDiscriminators) > 0 :
1123  patJets.addBTagInfo = True
1124 
1125  if runIVF:
1126  if not tightBTagNTkHits:
1127  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1128  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
1129  else:
1130  rerunningIVF()
1131  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
1132  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1133  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
1134  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1135  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1136  if tightBTagNTkHits:
1137  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1138  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1139  _temp.minHits = cms.uint32(8)
1140 
1141  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1142  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1143  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1144  _temp.primaryVertices = pvSource
1145  _temp.tracks = pfCandidates
1146  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
1147  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
1148  _temp.primaryVertices = pvSource
1149  _temp.tracks = pfCandidates
1150  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
1151  addToProcessAndTask(svSource.getModuleLabel(),
1152  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
1153  process, task)
1154  if any(i in acceptedTagInfos for i in ivfcTagInfos):
1155  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1156  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1157  if tightBTagNTkHits:
1158  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1159  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1160  _temp.minHits = cms.uint32(8)
1161 
1162  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1163  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1164  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1165  _temp.primaryVertices = pvSource
1166  _temp.tracks = pfCandidates
1167  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
1168  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
1169  _temp.primaryVertices = pvSource
1170  _temp.tracks = pfCandidates
1171  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1172  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
1173  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
1174  process, task)
1175  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1176  if not hasattr( process, 'inclusiveVertexing' ):
1177  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1178  task.add(process.inclusiveVertexingTask)
1179  task.add(process.inclusiveCandidateVertexingTask)
1180  task.add(process.inclusiveCandidateVertexingCvsLTask)
1181  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1182  if not hasattr( process, 'inclusiveVertexing' ):
1183  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1184  task.add(process.inclusiveVertexingTask)
1185  task.add(process.inclusiveCandidateVertexingTask)
1186  task.add(process.inclusiveCandidateVertexingCvsLTask)
1187  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1188  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
1189  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1190  task.add(process.inclusiveSecondaryVerticesFiltered)
1191  task.add(process.bVertexFilter)
1192  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
1193  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1194  task.add(process.bToCharmDecayVertexMerged)
1195  if 'caTopTagInfos' in acceptedTagInfos :
1196  patJets.addTagInfos = True
1197  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
1198  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
1199  task.add(process.caTopTaggersTask)
1200 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:232
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
Definition: helpers.py:49
def rerunningIVF()
Definition: jetTools.py:2241
def setupPuppiForPackedPF(process, useExistingWeights=True, postfix='')
Definition: jetTools.py:242
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:2249
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ setupJetCorrections()

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

Definition at line 31 of file jetTools.py.

References helpers.addToProcessAndTask(), clone(), submitPVResolutionJobs.count, helpers.getPatAlgosToolsTask(), and submitPVValidationJobs.split().

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

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

◆ setupPuppiForPackedPF()

def jetTools.setupPuppiForPackedPF (   process,
  useExistingWeights = True,
  postfix = '' 
)
Setup puppi weights
Two instances of PuppiProducer:
- packedpuppi (for jet reclustering)
- packedpuppiNoLep (for MET reclustering)

Definition at line 242 of file jetTools.py.

References helpers.addToProcessAndTask(), clone(), helpers.getPatAlgosToolsTask(), and setupBTagging().

Referenced by jetCollectionTools.RecoJetAdder.addRecoJetCollection(), and setupBTagging().

242 def setupPuppiForPackedPF(process, useExistingWeights=True, postfix=''):
243  """
244  Setup puppi weights
245  Two instances of PuppiProducer:
246  - packedpuppi (for jet reclustering)
247  - packedpuppiNoLep (for MET reclustering)
248  """
249  from CommonTools.PileupAlgos.Puppi_cff import puppi
250  task = getPatAlgosToolsTask(process)
251 
252  puppiLabel = 'packedpuppi'+postfix
253 
254 
256  if not hasattr(process, puppiLabel):
257  addToProcessAndTask(puppiLabel, puppi.clone(
258  useExistingWeights = useExistingWeights,
259  candName = 'packedPFCandidates',
260  vertexName = 'offlineSlimmedPrimaryVertices'), process, task)
261 
262  puppiNoLepLabel = puppiLabel+'NoLep'
263 
264  if hasattr(process, puppiLabel) and not hasattr(process, puppiNoLepLabel):
265  addToProcessAndTask(puppiNoLepLabel, getattr(process, puppiLabel).clone(
266  puppiNoLep = True), process, task)
267 
268  return puppiLabel, puppiNoLepLabel
269 
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
def setupPuppiForPackedPF(process, useExistingWeights=True, postfix='')
Definition: jetTools.py:242
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ setupSVClustering()

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

Definition at line 232 of file jetTools.py.

Referenced by setupBTagging().

232 def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag('')):
233  btagInfo.useSVClustering = cms.bool(svClustering)
234  btagInfo.jetAlgorithm = cms.string(algo)
235  btagInfo.rParam = cms.double(rParam)
236 
237  if fatJets != cms.InputTag(''):
238  btagInfo.fatJets = fatJets
239  if groomedFatJets != cms.InputTag(''):
240  btagInfo.groomedFatJets = groomedFatJets
241 
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:232

◆ undefinedLabelName()

def jetTools.undefinedLabelName (   obj)

Definition at line 2225 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

2225 def undefinedLabelName(obj):
2226  sys.stderr.write("-------------------------------------------------------\n")
2227  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
2228  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
2229  sys.stderr.write("-------------------------------------------------------\n")
2230  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
2231 
def undefinedLabelName(obj)
Definition: jetTools.py:2225

◆ unsupportedJetAlgorithm()

def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 2232 of file jetTools.py.

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

2232 def unsupportedJetAlgorithm(obj):
2233  sys.stderr.write("-------------------------------------------------------\n")
2234  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
2235  sys.stderr.write(" The supported algorithms are:\n")
2236  for key in supportedJetAlgos.keys():
2237  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
2238  sys.stderr.write("-------------------------------------------------------\n")
2239  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
2240 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:2232

Variable Documentation

◆ supportedJetAlgos

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 17 of file jetTools.py.