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

2283  sys.stderr.write("-------------------------------------------------------\n")
2284  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
2285  sys.stderr.write(" anymore by:\n")
2286  sys.stderr.write(" " + obj._label + "\n")
2287  sys.stderr.write(" please use 'outputModules' now and specify the\n")
2288  sys.stderr.write(" names of all needed OutModules in there\n")
2289  sys.stderr.write(" (default: ['out'])\n")
2290  sys.stderr.write("-------------------------------------------------------\n")
2291  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
2292 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:2282

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

Referenced by setupBTagging().

2309 def rerunningIVF():
2310  sys.stderr.write("-------------------------------------------------------------------\n")
2311  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
2312  sys.stderr.write(" already produced by the standard reconstruction. This\n")
2313  sys.stderr.write(" option is not enabled by default so please use it only if\n")
2314  sys.stderr.write(" you know what you are doing.\n")
2315  sys.stderr.write("-------------------------------------------------------------------\n")
2316 
def rerunningIVF()
Definition: jetTools.py:2309

◆ rerunningIVFMiniAOD()

def jetTools.rerunningIVFMiniAOD ( )

Definition at line 2317 of file jetTools.py.

Referenced by setupBTagging().

2317 def rerunningIVFMiniAOD():
2318  sys.stderr.write("-------------------------------------------------------------------\n")
2319  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
2320  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
2321  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
2322  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
2323  sys.stderr.write("-------------------------------------------------------------------\n")
2324 
def rerunningIVFMiniAOD()
Definition: jetTools.py:2317

◆ 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) and ('UnifiedParticleTransformerAK4TagInfos' not in btagInfo): #We also have to veto UParT is we select ParT
685  svUsed = svSource
686  if btagInfo == 'pfNegativeParticleTransformerAK4TagInfos':
687  svUsed, flip, max_sip3dsig_for_flip = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix), True, 10.
688  else:
689  svUsed, flip, max_sip3dsig_for_flip = svSource, False, -1.
690  # use right input tags when running with RECO PF candidates, which actually
691  # depends of whether jets use "particleFlow"
692  if pfCandidates.value() == 'packedPFCandidates':
693  puppi_value_map = setupPuppiForPackedPF(process)[0]
694  vertex_associator = cms.InputTag("")
695  else:
696  puppi_value_map = cms.InputTag("puppi")
697  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
698 
699  # If this jet is a puppi jet, then set is_weighted_jet to true.
700  is_weighted_jet = False
701  if ('puppi' in jetSource.value().lower()):
702  is_weighted_jet = True
703  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
704  btag.pfParticleTransformerAK4TagInfos.clone(
705  jets = jetSource,
706  vertices=pvSource,
707  secondary_vertices=svUsed,
708  puppi_value_map = puppi_value_map,
709  vertex_associator = vertex_associator,
710  is_weighted_jet = is_weighted_jet,
711  flip = flip,
712  max_sip3dsig_for_flip=max_sip3dsig_for_flip),
713  process, task)
714 
715  if 'UnifiedParticleTransformerAK4TagInfos' in btagInfo:
716  svUsed = svSource
717  if btagInfo == 'pfNegativeUnifiedParticleTransformerAK4TagInfos':
718  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
719  flip = True
720  else:
721  flip = False
722  # use right input tags when running with RECO PF candidates, which actually
723  # depends of whether jets use "particleFlow"
724  if pfCandidates.value() == 'packedPFCandidates':
725  puppi_value_map = setupPuppiForPackedPF(process)[0]
726  vertex_associator = cms.InputTag("")
727  else:
728  puppi_value_map = cms.InputTag("puppi")
729  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
730 
731  # If this jet is a puppi jet, then set is_weighted_jet to true.
732  is_weighted_jet = False
733  if ('puppi' in jetSource.value().lower()):
734  is_weighted_jet = True
735  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
736  btag.pfUnifiedParticleTransformerAK4TagInfos.clone(
737  jets = jetSource,
738  vertices=pvSource,
739  secondary_vertices=svUsed,
740  puppi_value_map = puppi_value_map,
741  vertex_associator = vertex_associator,
742  is_weighted_jet = is_weighted_jet,
743  flip = flip),
744  process, task)
745 
746  if btagInfo == 'pfDeepDoubleXTagInfos':
747  # can only run on PAT jets, so the updater needs to be used
748  if 'updated' not in jetSource.value().lower():
749  raise ValueError("Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
750  packedPFPuppiLabel = setupPuppiForPackedPF(process)[0]
751  puppi_value_map = cms.InputTag(packedPFPuppiLabel)
752  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
753  btag.pfDeepDoubleXTagInfos.clone(
754  jets = jetSource,
755  vertices=pvSource,
756  secondary_vertices=svSource,
757  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
758  puppi_value_map = puppi_value_map,
759  ),
760  process, task)
761  if btagInfo == 'pfHiggsInteractionNetTagInfos':
762  packedPFPuppiLabel = setupPuppiForPackedPF(process)[0]
763  puppi_value_map = cms.InputTag(packedPFPuppiLabel)
764  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
765  btag.pfHiggsInteractionNetTagInfos.clone(
766  jets = jetSource,
767  vertices = pvSource,
768  secondary_vertices = svSource,
769  pf_candidates = pfCandidates,
770  puppi_value_map = puppi_value_map
771  ),
772  process, task)
773 
774  if btagInfo == 'pfDeepBoostedJetTagInfos':
775  if pfCandidates.value() == 'packedPFCandidates':
776  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
777  if 'updated' not in jetSource.value().lower():
778  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
779  puppi_value_map = setupPuppiForPackedPF(process)[0]
780  vertex_associator = ""
781  elif pfCandidates.value() == 'particleFlow':
782  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
783  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
784  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
785  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
786 # puppi_value_map = "puppi"
787 # vertex_associator = "primaryVertexAssociation:original"
788  else:
789  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
790  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
791  btag.pfDeepBoostedJetTagInfos.clone(
792  jets = jetSource,
793  vertices = pvSource,
794  secondary_vertices = svSource,
795  pf_candidates = pfCandidates,
796  puppi_value_map = puppi_value_map,
797  vertex_associator = vertex_associator,
798  ),
799  process, task)
800 
801  if btagInfo == 'pfParticleNetTagInfos':
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  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
814  btag.pfParticleNetTagInfos.clone(
815  jets = jetSource,
816  vertices = pvSource,
817  secondary_vertices = svSource,
818  pf_candidates = pfCandidates,
819  puppi_value_map = puppi_value_map,
820  vertex_associator = vertex_associator,
821  ),
822  process, task)
823 
824  if 'ParticleNetAK4TagInfos' in btagInfo:
825  if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
826  secondary_vertices = btagPrefix + \
827  'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
828  flip_ip_sign = True
829  sip3dSigMax = 10
830  else:
831  secondary_vertices = svSource
832  flip_ip_sign = False
833  sip3dSigMax = -1
834  if pfCandidates.value() == 'packedPFCandidates':
835  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
836  puppi_value_map = setupPuppiForPackedPF(process)[0]
837  vertex_associator = ""
838  elif pfCandidates.value() == 'particleFlow':
839  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
840  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
841  puppi_value_map = "puppi"
842  vertex_associator = "primaryVertexAssociation:original"
843  else:
844  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
845  # If this jet is a Puppi jet, use puppi-weighted p4.
846  use_puppiP4 = False
847  if "puppi" in jetSource.value().lower():
848  use_puppiP4 = True
849  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
850  btag.pfParticleNetAK4TagInfos.clone(
851  jets = jetSource,
852  vertices = pvSource,
853  secondary_vertices = secondary_vertices,
854  pf_candidates = pfCandidates,
855  puppi_value_map = puppi_value_map,
856  vertex_associator = vertex_associator,
857  flip_ip_sign = flip_ip_sign,
858  sip3dSigMax = sip3dSigMax,
859  use_puppiP4 = use_puppiP4
860  ),
861  process, task)
862 
863  acceptedTagInfos.append(btagInfo)
864  elif hasattr(toptag, btagInfo) :
865  acceptedTagInfos.append(btagInfo)
866  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos' or btagInfo == 'pfNegativeParticleNetFromMiniAODAK4PuppiCentralTagInfos':
867  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
868  if btagInfo == 'pfNegativeParticleNetFromMiniAODAK4PuppiCentralTagInfos':
869  svUsed, flip_ip_sign, max_sip3dsig_for_flip = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix), True, 10.
870  else:
871  svUsed, flip_ip_sign, max_sip3dsig_for_flip = svSource, False, -1.
872  if pfCandidates.value() != 'packedPFCandidates':
873  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
874  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
875  pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
876  jets = jetSource,
877  vertices = pvSource,
878  secondary_vertices = svUsed,
879  pf_candidates = pfCandidates,
880  flip_ip_sign = flip_ip_sign,
881  max_sip3dsig_for_flip = max_sip3dsig_for_flip,
882  ),
883  process, task)
884  acceptedTagInfos.append(btagInfo)
885  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
886  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
887  if pfCandidates.value() != 'packedPFCandidates':
888  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
889  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
890  pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
891  jets = jetSource,
892  vertices = pvSource,
893  secondary_vertices = svSource,
894  pf_candidates = pfCandidates,
895  ),
896  process, task)
897  acceptedTagInfos.append(btagInfo)
898  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSCentralTagInfos' or btagInfo == 'pfNegativeParticleNetFromMiniAODAK4PuppiForwardTagInfos':
899  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
900  if btagInfo == 'pfNegativeParticleNetFromMiniAODAK4PuppiForwardTagInfos':
901  svUsed, flip_ip_sign, max_sip3dsig_for_flip = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix), True, 10.
902  else:
903  svUsed, flip_ip_sign, max_sip3dsig_for_flip = svSource, False, -1.
904  if pfCandidates.value() != 'packedPFCandidates':
905  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
906  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
907  pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
908  jets = jetSource,
909  vertices = pvSource,
910  secondary_vertices = svUsed,
911  pf_candidates = pfCandidates,
912  flip_ip_sign = flip_ip_sign,
913  max_sip3dsig_for_flip = max_sip3dsig_for_flip,
914  ),
915  process, task)
916  acceptedTagInfos.append(btagInfo)
917  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
918  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
919  if pfCandidates.value() != 'packedPFCandidates':
920  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
921  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
922  pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
923  jets = jetSource,
924  vertices = pvSource,
925  secondary_vertices = svSource,
926  pf_candidates = pfCandidates,
927  ),
928  process, task)
929  acceptedTagInfos.append(btagInfo)
930  elif btagInfo == 'pfParticleNetFromMiniAODAK8TagInfos':
931  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
932  if pfCandidates.value() != 'packedPFCandidates':
933  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
934  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
935  pfParticleNetFromMiniAODAK8TagInfos.clone(
936  jets = jetSource,
937  vertices = pvSource,
938  secondary_vertices = svSource,
939  pf_candidates = pfCandidates,
940  ),
941  process, task)
942  acceptedTagInfos.append(btagInfo)
943  else:
944  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
945  # setup all required btagDiscriminators
946  acceptedBtagDiscriminators = list()
947  for discriminator_name in btagDiscriminators :
948  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
949  #print discriminator_name, '-->', btagDiscr
950  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
951  if hasattr(btag,btagDiscr):
952  if hasattr(process, newDiscr):
953  pass
954  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
956  newDiscr,
957  getattr(btag, btagDiscr).clone(
958  tagInfos = cms.VInputTag(
959  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
960  for x in supportedBtagDiscr[discriminator_name][0] ]
961  )
962  ),
963  process,
964  task
965  )
966  elif hasattr(getattr(btag, btagDiscr), 'src'):
968  newDiscr,
969  getattr(btag, btagDiscr).clone(
970  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
971  ),
972  process,
973  task
974  )
975  else:
976  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
977  acceptedBtagDiscriminators.append(discriminator_name)
978  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
979  if hasattr(process, newDiscr):
980  pass
982  newDiscr,
983  pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
984  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
985  ),
986  process,
987  task
988  )
989  acceptedBtagDiscriminators.append(discriminator_name)
990  elif btagDiscr=='pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags':
991  if hasattr(process, newDiscr):
992  pass
994  newDiscr,
995  pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
996  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
997  ),
998  process,
999  task
1000  )
1001  acceptedBtagDiscriminators.append(discriminator_name)
1002  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
1003  if hasattr(process, newDiscr):
1004  pass
1006  newDiscr,
1007  pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
1008  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1009  ),
1010  process,
1011  task
1012  )
1013  acceptedBtagDiscriminators.append(discriminator_name)
1014  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralJetTags':
1015  if hasattr(process, newDiscr):
1016  pass
1018  newDiscr,
1019  pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
1020  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1021  ),
1022  process,
1023  task
1024  )
1025  acceptedBtagDiscriminators.append(discriminator_name)
1026  elif btagDiscr=='pfNegativeParticleNetFromMiniAODAK4CHSCentralJetTags':
1027  if hasattr(process, newDiscr):
1028  pass
1030  newDiscr,
1031  pfNegativeParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
1032  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1033  ),
1034  process,
1035  task
1036  )
1037  acceptedBtagDiscriminators.append(discriminator_name)
1038  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardJetTags':
1039  if hasattr(process, newDiscr):
1040  pass
1042  newDiscr,
1043  pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
1044  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1045  ),
1046  process,
1047  task
1048  )
1049  acceptedBtagDiscriminators.append(discriminator_name)
1050  elif btagDiscr=='pfParticleNetFromMiniAODAK8JetTags':
1051  if hasattr(process, newDiscr):
1052  pass
1054  newDiscr,
1055  pfParticleNetFromMiniAODAK8JetTags.clone(
1056  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1057  ),
1058  process,
1059  task
1060  )
1061  acceptedBtagDiscriminators.append(discriminator_name)
1062  else:
1063  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1064 
1065  #update meta-taggers, if any
1066  for meta_tagger in present_meta:
1067  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
1068  #print discriminator_name, '-->', btagDiscr
1069  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
1070  if hasattr(btag,btagDiscr):
1071  if hasattr(process, newDiscr):
1072  pass
1073  else:
1075  newDiscr,
1076  getattr(btag, btagDiscr).clone(),
1077  process,
1078  task
1079  )
1080  for dependency in supportedMetaDiscr[meta_tagger]:
1081  if ':' in dependency:
1082  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1083  else:
1084  new_dep = btagPrefix+dependency+labelName+postfix
1085  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1086  replace.doIt(getattr(process, newDiscr), newDiscr)
1087  acceptedBtagDiscriminators.append(meta_tagger)
1088  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
1089  if hasattr(process, newDiscr):
1090  pass
1091  else:
1093  newDiscr,
1094  pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
1095  process,
1096  task
1097  )
1098  for dependency in supportedMetaDiscr[meta_tagger]:
1099  if ':' in dependency:
1100  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1101  else:
1102  new_dep = btagPrefix+dependency+labelName+postfix
1103  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1104  replace.doIt(getattr(process, newDiscr), newDiscr)
1105  acceptedBtagDiscriminators.append(meta_tagger)
1106  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
1107  if hasattr(process, newDiscr):
1108  pass
1109  else:
1111  newDiscr,
1112  pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
1113  process,
1114  task
1115  )
1116  for dependency in supportedMetaDiscr[meta_tagger]:
1117  if ':' in dependency:
1118  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1119  else:
1120  new_dep = btagPrefix+dependency+labelName+postfix
1121  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1122  replace.doIt(getattr(process, newDiscr), newDiscr)
1123  acceptedBtagDiscriminators.append(meta_tagger)
1124  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1125  if hasattr(process, newDiscr):
1126  pass
1127  else:
1129  newDiscr,
1130  pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1131  process,
1132  task
1133  )
1134  for dependency in supportedMetaDiscr[meta_tagger]:
1135  if ':' in dependency:
1136  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1137  else:
1138  new_dep = btagPrefix+dependency+labelName+postfix
1139  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1140  replace.doIt(getattr(process, newDiscr), newDiscr)
1141  acceptedBtagDiscriminators.append(meta_tagger)
1142  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1143  if hasattr(process, newDiscr):
1144  pass
1145  else:
1147  newDiscr,
1148  pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1149  process,
1150  task
1151  )
1152  for dependency in supportedMetaDiscr[meta_tagger]:
1153  if ':' in dependency:
1154  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1155  else:
1156  new_dep = btagPrefix+dependency+labelName+postfix
1157  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1158  replace.doIt(getattr(process, newDiscr), newDiscr)
1159  acceptedBtagDiscriminators.append(meta_tagger)
1160  elif btagDiscr=='pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1161  if hasattr(process, newDiscr):
1162  pass
1163  else:
1165  newDiscr,
1166  pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1167  process,
1168  task
1169  )
1170  for dependency in supportedMetaDiscr[meta_tagger]:
1171  if ':' in dependency:
1172  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1173  else:
1174  new_dep = btagPrefix+dependency+labelName+postfix
1175  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1176  replace.doIt(getattr(process, newDiscr), newDiscr)
1177  acceptedBtagDiscriminators.append(meta_tagger)
1178 
1179  else:
1180  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1181 
1182 
1183  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
1184  patJets.discriminatorSources = cms.VInputTag(*[
1185  cms.InputTag(btagPrefix+x+labelName+postfix) \
1186  if ':' not in x else \
1187  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
1188  for x in acceptedBtagDiscriminators
1189  ])
1190  if len(acceptedBtagDiscriminators) > 0 :
1191  patJets.addBTagInfo = True
1192 
1193  if runIVF:
1194  if not tightBTagNTkHits:
1195  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1196  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
1197  else:
1198  rerunningIVF()
1199  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
1200  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1201  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
1202  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1203  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1204  if tightBTagNTkHits:
1205  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1206  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1207  _temp.minHits = cms.uint32(8)
1208 
1209  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1210  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1211  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1212  _temp.primaryVertices = pvSource
1213  _temp.tracks = pfCandidates
1214  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
1215  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
1216  _temp.primaryVertices = pvSource
1217  _temp.tracks = pfCandidates
1218  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
1219  addToProcessAndTask(svSource.getModuleLabel(),
1220  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
1221  process, task)
1222  if any(i in acceptedTagInfos for i in ivfcTagInfos):
1223  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1224  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1225  if tightBTagNTkHits:
1226  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1227  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1228  _temp.minHits = cms.uint32(8)
1229 
1230  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1231  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1232  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1233  _temp.primaryVertices = pvSource
1234  _temp.tracks = pfCandidates
1235  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
1236  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
1237  _temp.primaryVertices = pvSource
1238  _temp.tracks = pfCandidates
1239  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1240  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
1241  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
1242  process, task)
1243  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1244  if not hasattr( process, 'inclusiveVertexing' ):
1245  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1246  task.add(process.inclusiveVertexingTask)
1247  task.add(process.inclusiveCandidateVertexingTask)
1248  task.add(process.inclusiveCandidateVertexingCvsLTask)
1249  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1250  if not hasattr( process, 'inclusiveVertexing' ):
1251  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1252  task.add(process.inclusiveVertexingTask)
1253  task.add(process.inclusiveCandidateVertexingTask)
1254  task.add(process.inclusiveCandidateVertexingCvsLTask)
1255  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1256  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
1257  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1258  task.add(process.inclusiveSecondaryVerticesFiltered)
1259  task.add(process.bVertexFilter)
1260  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
1261  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1262  task.add(process.bToCharmDecayVertexMerged)
1263  if 'caTopTagInfos' in acceptedTagInfos :
1264  patJets.addTagInfos = True
1265  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
1266  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
1267  task.add(process.caTopTaggersTask)
1268 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:36
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:2309
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:2317
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 2293 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

2293 def undefinedLabelName(obj):
2294  sys.stderr.write("-------------------------------------------------------\n")
2295  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
2296  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
2297  sys.stderr.write("-------------------------------------------------------\n")
2298  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
2299 
def undefinedLabelName(obj)
Definition: jetTools.py:2293

◆ unsupportedJetAlgorithm()

def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 2300 of file jetTools.py.

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

2300 def unsupportedJetAlgorithm(obj):
2301  sys.stderr.write("-------------------------------------------------------\n")
2302  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
2303  sys.stderr.write(" The supported algorithms are:\n")
2304  for key in supportedJetAlgos.keys():
2305  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
2306  sys.stderr.write("-------------------------------------------------------\n")
2307  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
2308 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:2300

Variable Documentation

◆ supportedJetAlgos

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 17 of file jetTools.py.