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

2272  sys.stderr.write("-------------------------------------------------------\n")
2273  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
2274  sys.stderr.write(" anymore by:\n")
2275  sys.stderr.write(" " + obj._label + "\n")
2276  sys.stderr.write(" please use 'outputModules' now and specify the\n")
2277  sys.stderr.write(" names of all needed OutModules in there\n")
2278  sys.stderr.write(" (default: ['out'])\n")
2279  sys.stderr.write("-------------------------------------------------------\n")
2280  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
2281 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:2271

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

Referenced by setupBTagging().

2298 def rerunningIVF():
2299  sys.stderr.write("-------------------------------------------------------------------\n")
2300  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
2301  sys.stderr.write(" already produced by the standard reconstruction. This\n")
2302  sys.stderr.write(" option is not enabled by default so please use it only if\n")
2303  sys.stderr.write(" you know what you are doing.\n")
2304  sys.stderr.write("-------------------------------------------------------------------\n")
2305 
def rerunningIVF()
Definition: jetTools.py:2298

◆ rerunningIVFMiniAOD()

def jetTools.rerunningIVFMiniAOD ( )

Definition at line 2306 of file jetTools.py.

Referenced by setupBTagging().

2306 def rerunningIVFMiniAOD():
2307  sys.stderr.write("-------------------------------------------------------------------\n")
2308  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
2309  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
2310  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
2311  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
2312  sys.stderr.write("-------------------------------------------------------------------\n")
2313 
def rerunningIVFMiniAOD()
Definition: jetTools.py:2306

◆ 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  # Setup the PUPPI ValueMap that will consumed by the TagInfo producers.
411  puppi_value_map = "puppi"
412  if pfCandidates.value() == 'packedPFCandidates':
413  puppi_value_map = setupPuppiForPackedPF(process)[0]
414 
415  acceptedTagInfos = list()
416  for btagInfo in requiredTagInfos:
417  if hasattr(btag,btagInfo):
418  if btagInfo == 'pfImpactParameterTagInfos':
419  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
420  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
421  process, task)
422  if explicitJTA:
423  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
424  _btagInfo.explicitJTA = cms.bool(explicitJTA)
425  if tightBTagNTkHits:
426  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
427  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
428  _btagInfo.minimumNumberOfHits = cms.int32(8)
429  if btagInfo == 'pfImpactParameterAK8TagInfos':
430  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
431  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
432  process, task)
433  if explicitJTA:
434  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
435  _btagInfo.explicitJTA = cms.bool(explicitJTA)
436  if tightBTagNTkHits:
437  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
438  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
439  _btagInfo.minimumNumberOfHits = cms.int32(8)
440  if btagInfo == 'pfImpactParameterCA15TagInfos':
441  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
442  btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
443  process, task)
444  if explicitJTA:
445  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
446  _btagInfo.explicitJTA = cms.bool(explicitJTA)
447  if tightBTagNTkHits:
448  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
449  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
450  _btagInfo.minimumNumberOfHits = cms.int32(8)
451  if btagInfo == 'pfSecondaryVertexTagInfos':
452  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
453  btag.pfSecondaryVertexTagInfos.clone(
454  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
455  process, task)
456  if tightBTagNTkHits:
457  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
458  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
459  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
460  if btagInfo == 'pfDeepCSVTagInfos':
461  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
462  btag.pfDeepCSVTagInfos.clone(
463  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
464  process, task)
465  if svClustering or fatJets != cms.InputTag(''):
466  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
467  if btagInfo == 'pfDeepCSVNegativeTagInfos':
468  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
469  btag.pfDeepCSVNegativeTagInfos.clone(
470  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
471  process, task)
472  if svClustering or fatJets != cms.InputTag(''):
473  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
474  if btagInfo == 'pfDeepCSVPositiveTagInfos':
475  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
476  btag.pfDeepCSVPositiveTagInfos.clone(
477  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
478  process, task)
479  if svClustering or fatJets != cms.InputTag(''):
480  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
481  if btagInfo == 'pfDeepCMVATagInfos':
482  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
483  btag.pfDeepCMVATagInfos.clone(
484  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
485  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
486  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
487  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
488  process, task)
489  if svClustering or fatJets != cms.InputTag(''):
490  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
491  if btagInfo == 'pfDeepCMVANegativeTagInfos':
492  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
493  btag.pfDeepCMVATagInfos.clone(
494  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
495  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
496  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
497  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
498  process, task)
499  if svClustering or fatJets != cms.InputTag(''):
500  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
501  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
502  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
503  btag.pfDeepCMVATagInfos.clone(
504  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
505  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
506  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
507  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
508  process, task)
509  if svClustering or fatJets != cms.InputTag(''):
510  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
511  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
512  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
513  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
514  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
515  extSVCollection=svSource),
516  process, task)
517  if svClustering or fatJets != cms.InputTag(''):
518  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
519  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
520  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
521  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
522  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
523  extSVCollection=svSource),
524  process, task)
525  if svClustering or fatJets != cms.InputTag(''):
526  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
527  if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
528  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
529  btag.pfBoostedDoubleSVAK8TagInfos.clone(
530  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
531  process, task)
532  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
533  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
534  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
535  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
536  extSVCollection=svSource),
537  process, task)
538  if svClustering or fatJets != cms.InputTag(''):
539  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
540  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
541  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
542  btag.pfBoostedDoubleSVCA15TagInfos.clone(
543  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
544  process, task)
545  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
546  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
547  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
548  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
549  extSVCollection=svSourceCvsL),
550  process, task)
551  if svClustering or fatJets != cms.InputTag(''):
552  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
553  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
554  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
555  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
556  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
557  extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
558  process, task)
559  if svClustering or fatJets != cms.InputTag(''):
560  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
561  if btagInfo == 'pfGhostTrackVertexTagInfos':
562  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
563  btag.pfGhostTrackVertexTagInfos.clone(
564  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
565  process, task)
566  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
567  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
568  btag.pfSecondaryVertexNegativeTagInfos.clone(
569  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
570  process, task)
571  if tightBTagNTkHits:
572  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
573  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
574  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
575  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
576  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
577  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
578  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
579  extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
580  process, task)
581  if svClustering or fatJets != cms.InputTag(''):
582  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
583  if btagInfo == 'impactParameterTagInfos':
584  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
585  btag.impactParameterTagInfos.clone(
586  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
587  primaryVertex=pvSource),
588  process, task)
589  if btagInfo == 'secondaryVertexTagInfos':
590  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
591  btag.secondaryVertexTagInfos.clone(
592  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
593  process, task)
594  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
595  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
596  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
597  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
598  process, task)
599  if svClustering or fatJets != cms.InputTag(''):
600  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
601  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
602  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
603  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
604  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
605  process, task)
606  if svClustering or fatJets != cms.InputTag(''):
607  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
608  if btagInfo == 'secondaryVertexNegativeTagInfos':
609  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
610  btag.secondaryVertexNegativeTagInfos.clone(
611  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
612  process, task)
613  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
614  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
615  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
616  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
617  process, task)
618  if svClustering or fatJets != cms.InputTag(''):
619  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
620  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
621  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
622  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
623  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
624  process, task)
625  if svClustering or fatJets != cms.InputTag(''):
626  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
627  if btagInfo == 'softMuonTagInfos':
628  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
629  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
630  process, task)
631  if btagInfo == 'softPFMuonsTagInfos':
632  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
633  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
634  process, task)
635  if btagInfo == 'softPFElectronsTagInfos':
636  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
637  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
638  process, task)
639  if btagInfo == 'pixelClusterTagInfos':
640  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
641  btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
642  process, task)
643 
644 
645  if 'pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo:
646  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
647  _btagInfo.weights = cms.InputTag(puppi_value_map)
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  vertex_associator = cms.InputTag("")
663  else:
664  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
665 
666  # If this jet is a puppi jet, then set is_weighted_jet to true.
667  is_weighted_jet = False
668  if ('puppi' in jetSource.value().lower()):
669  is_weighted_jet = True
670  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
671  btag.pfDeepFlavourTagInfos.clone(
672  jets = jetSource,
673  vertices=pvSource,
674  secondary_vertices=svUsed,
675  shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
676  puppi_value_map = puppi_value_map,
677  vertex_associator = vertex_associator,
678  is_weighted_jet = is_weighted_jet,
679  flip = flip),
680  process, task)
681 
682  if ('ParticleTransformerAK4TagInfos' in btagInfo) and ('UnifiedParticleTransformerAK4TagInfos' not in btagInfo): #We also have to veto UParT is we select ParT
683  svUsed = svSource
684  if btagInfo == 'pfNegativeParticleTransformerAK4TagInfos':
685  svUsed, flip, max_sip3dsig_for_flip = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix), True, 10.
686  else:
687  svUsed, flip, max_sip3dsig_for_flip = svSource, False, -1.
688  # use right input tags when running with RECO PF candidates, which actually
689  # depends of whether jets use "particleFlow"
690  if pfCandidates.value() == 'packedPFCandidates':
691  vertex_associator = cms.InputTag("")
692  else:
693  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
694 
695  # If this jet is a puppi jet, then set is_weighted_jet to true.
696  is_weighted_jet = False
697  if ('puppi' in jetSource.value().lower()):
698  is_weighted_jet = True
699  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
700  btag.pfParticleTransformerAK4TagInfos.clone(
701  jets = jetSource,
702  vertices=pvSource,
703  secondary_vertices=svUsed,
704  puppi_value_map = puppi_value_map,
705  vertex_associator = vertex_associator,
706  is_weighted_jet = is_weighted_jet,
707  flip = flip,
708  max_sip3dsig_for_flip=max_sip3dsig_for_flip),
709  process, task)
710 
711  if 'UnifiedParticleTransformerAK4TagInfos' in btagInfo:
712  svUsed = svSource
713  if btagInfo == 'pfNegativeUnifiedParticleTransformerAK4TagInfos':
714  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
715  flip = True
716  else:
717  flip = False
718  # use right input tags when running with RECO PF candidates, which actually
719  # depends of whether jets use "particleFlow"
720  if pfCandidates.value() == 'packedPFCandidates':
721  vertex_associator = cms.InputTag("")
722  else:
723  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
724 
725  # If this jet is a puppi jet, then set is_weighted_jet to true.
726  is_weighted_jet = False
727  if ('puppi' in jetSource.value().lower()):
728  is_weighted_jet = True
729  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
730  btag.pfUnifiedParticleTransformerAK4TagInfos.clone(
731  jets = jetSource,
732  vertices=pvSource,
733  secondary_vertices=svUsed,
734  puppi_value_map = puppi_value_map,
735  vertex_associator = vertex_associator,
736  is_weighted_jet = is_weighted_jet,
737  flip = flip),
738  process, task)
739 
740  if btagInfo == 'pfDeepDoubleXTagInfos':
741  # can only run on PAT jets, so the updater needs to be used
742  if 'updated' not in jetSource.value().lower():
743  raise ValueError("Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
744  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
745  btag.pfDeepDoubleXTagInfos.clone(
746  jets = jetSource,
747  vertices=pvSource,
748  secondary_vertices=svSource,
749  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
750  puppi_value_map = puppi_value_map,
751  ),
752  process, task)
753  if btagInfo == 'pfHiggsInteractionNetTagInfos':
754  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
755  btag.pfHiggsInteractionNetTagInfos.clone(
756  jets = jetSource,
757  vertices = pvSource,
758  secondary_vertices = svSource,
759  pf_candidates = pfCandidates,
760  puppi_value_map = puppi_value_map
761  ),
762  process, task)
763 
764  if btagInfo == 'pfDeepBoostedJetTagInfos':
765  if pfCandidates.value() == 'packedPFCandidates':
766  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
767  if 'updated' not in jetSource.value().lower():
768  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
769  vertex_associator = ""
770  elif pfCandidates.value() == 'particleFlow':
771  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
772  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
773  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
774  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
775 # vertex_associator = "primaryVertexAssociation:original"
776  else:
777  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
778  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
779  btag.pfDeepBoostedJetTagInfos.clone(
780  jets = jetSource,
781  vertices = pvSource,
782  secondary_vertices = svSource,
783  pf_candidates = pfCandidates,
784  puppi_value_map = puppi_value_map,
785  vertex_associator = vertex_associator,
786  ),
787  process, task)
788 
789  if btagInfo == 'pfParticleNetTagInfos' or btagInfo == 'pfGlobalParticleTransformerAK8TagInfos':
790  if pfCandidates.value() == 'packedPFCandidates':
791  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
792  vertex_associator = ""
793  elif pfCandidates.value() == 'particleFlow':
794  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
795  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
796  vertex_associator = "primaryVertexAssociation:original"
797  else:
798  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
799  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
800  getattr(btag, btagInfo).clone(
801  jets = jetSource,
802  vertices = pvSource,
803  secondary_vertices = svSource,
804  pf_candidates = pfCandidates,
805  puppi_value_map = puppi_value_map,
806  vertex_associator = vertex_associator,
807  ),
808  process, task)
809 
810  if 'ParticleNetAK4TagInfos' in btagInfo:
811  if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
812  secondary_vertices = btagPrefix + \
813  'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
814  flip_ip_sign = True
815  sip3dSigMax = 10
816  else:
817  secondary_vertices = svSource
818  flip_ip_sign = False
819  sip3dSigMax = -1
820  if pfCandidates.value() == 'packedPFCandidates':
821  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
822  vertex_associator = ""
823  elif pfCandidates.value() == 'particleFlow':
824  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
825  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
826  vertex_associator = "primaryVertexAssociation:original"
827  else:
828  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
829  # If this jet is a Puppi jet, use puppi-weighted p4.
830  use_puppiP4 = False
831  if "puppi" in jetSource.value().lower():
832  use_puppiP4 = True
833  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
834  btag.pfParticleNetAK4TagInfos.clone(
835  jets = jetSource,
836  vertices = pvSource,
837  secondary_vertices = secondary_vertices,
838  pf_candidates = pfCandidates,
839  puppi_value_map = puppi_value_map,
840  vertex_associator = vertex_associator,
841  flip_ip_sign = flip_ip_sign,
842  sip3dSigMax = sip3dSigMax,
843  use_puppiP4 = use_puppiP4
844  ),
845  process, task)
846 
847  acceptedTagInfos.append(btagInfo)
848  elif hasattr(toptag, btagInfo) :
849  acceptedTagInfos.append(btagInfo)
850  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos' or btagInfo == 'pfNegativeParticleNetFromMiniAODAK4PuppiCentralTagInfos':
851  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
852  if btagInfo == 'pfNegativeParticleNetFromMiniAODAK4PuppiCentralTagInfos':
853  svUsed, flip_ip_sign, max_sip3dsig_for_flip = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix), True, 10.
854  else:
855  svUsed, flip_ip_sign, max_sip3dsig_for_flip = svSource, False, -1.
856  if pfCandidates.value() != 'packedPFCandidates':
857  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
858  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
859  pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
860  jets = jetSource,
861  vertices = pvSource,
862  secondary_vertices = svUsed,
863  pf_candidates = pfCandidates,
864  puppi_value_map = puppi_value_map,
865  flip_ip_sign = flip_ip_sign,
866  max_sip3dsig_for_flip = max_sip3dsig_for_flip,
867  ),
868  process, task)
869  acceptedTagInfos.append(btagInfo)
870  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
871  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
872  if pfCandidates.value() != 'packedPFCandidates':
873  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
874  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
875  pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
876  jets = jetSource,
877  vertices = pvSource,
878  secondary_vertices = svSource,
879  pf_candidates = pfCandidates,
880  puppi_value_map = puppi_value_map
881  ),
882  process, task)
883  acceptedTagInfos.append(btagInfo)
884  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSCentralTagInfos' or btagInfo == 'pfNegativeParticleNetFromMiniAODAK4CHSCentralTagInfos':
885  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
886  if btagInfo == 'pfNegativeParticleNetFromMiniAODAK4CHSCentralTagInfos':
887  svUsed, flip_ip_sign, max_sip3dsig_for_flip = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix), True, 10.
888  else:
889  svUsed, flip_ip_sign, max_sip3dsig_for_flip = svSource, False, -1.
890  if pfCandidates.value() != 'packedPFCandidates':
891  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
892  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
893  pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
894  jets = jetSource,
895  vertices = pvSource,
896  secondary_vertices = svUsed,
897  pf_candidates = pfCandidates,
898  puppi_value_map = puppi_value_map,
899  flip_ip_sign = flip_ip_sign,
900  max_sip3dsig_for_flip = max_sip3dsig_for_flip,
901  ),
902  process, task)
903  acceptedTagInfos.append(btagInfo)
904  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
905  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
906  if pfCandidates.value() != 'packedPFCandidates':
907  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
908  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
909  pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
910  jets = jetSource,
911  vertices = pvSource,
912  secondary_vertices = svSource,
913  pf_candidates = pfCandidates,
914  puppi_value_map = puppi_value_map,
915  ),
916  process, task)
917  acceptedTagInfos.append(btagInfo)
918  elif btagInfo == 'pfParticleNetFromMiniAODAK8TagInfos':
919  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
920  if pfCandidates.value() != 'packedPFCandidates':
921  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
922  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
923  pfParticleNetFromMiniAODAK8TagInfos.clone(
924  jets = jetSource,
925  vertices = pvSource,
926  secondary_vertices = svSource,
927  pf_candidates = pfCandidates,
928  puppi_value_map = puppi_value_map,
929  ),
930  process, task)
931  acceptedTagInfos.append(btagInfo)
932  else:
933  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
934  # setup all required btagDiscriminators
935  acceptedBtagDiscriminators = list()
936  for discriminator_name in btagDiscriminators :
937  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
938  #print discriminator_name, '-->', btagDiscr
939  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
940  if hasattr(btag,btagDiscr):
941  if hasattr(process, newDiscr):
942  pass
943  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
945  newDiscr,
946  getattr(btag, btagDiscr).clone(
947  tagInfos = cms.VInputTag(
948  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
949  for x in supportedBtagDiscr[discriminator_name][0] ]
950  )
951  ),
952  process,
953  task
954  )
955  elif hasattr(getattr(btag, btagDiscr), 'src'):
957  newDiscr,
958  getattr(btag, btagDiscr).clone(
959  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
960  ),
961  process,
962  task
963  )
964  else:
965  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
966  acceptedBtagDiscriminators.append(discriminator_name)
967  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
968  if hasattr(process, newDiscr):
969  pass
971  newDiscr,
972  pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
973  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
974  ),
975  process,
976  task
977  )
978  acceptedBtagDiscriminators.append(discriminator_name)
979  elif btagDiscr=='pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags':
980  if hasattr(process, newDiscr):
981  pass
983  newDiscr,
984  pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
985  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
986  ),
987  process,
988  task
989  )
990  acceptedBtagDiscriminators.append(discriminator_name)
991  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
992  if hasattr(process, newDiscr):
993  pass
995  newDiscr,
996  pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
997  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
998  ),
999  process,
1000  task
1001  )
1002  acceptedBtagDiscriminators.append(discriminator_name)
1003  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralJetTags':
1004  if hasattr(process, newDiscr):
1005  pass
1007  newDiscr,
1008  pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
1009  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1010  ),
1011  process,
1012  task
1013  )
1014  acceptedBtagDiscriminators.append(discriminator_name)
1015  elif btagDiscr=='pfNegativeParticleNetFromMiniAODAK4CHSCentralJetTags':
1016  if hasattr(process, newDiscr):
1017  pass
1019  newDiscr,
1020  pfNegativeParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
1021  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1022  ),
1023  process,
1024  task
1025  )
1026  acceptedBtagDiscriminators.append(discriminator_name)
1027  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardJetTags':
1028  if hasattr(process, newDiscr):
1029  pass
1031  newDiscr,
1032  pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
1033  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1034  ),
1035  process,
1036  task
1037  )
1038  acceptedBtagDiscriminators.append(discriminator_name)
1039  elif btagDiscr=='pfParticleNetFromMiniAODAK8JetTags':
1040  if hasattr(process, newDiscr):
1041  pass
1043  newDiscr,
1044  pfParticleNetFromMiniAODAK8JetTags.clone(
1045  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
1046  ),
1047  process,
1048  task
1049  )
1050  acceptedBtagDiscriminators.append(discriminator_name)
1051  else:
1052  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1053 
1054  #update meta-taggers, if any
1055  for meta_tagger in present_meta:
1056  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
1057  #print discriminator_name, '-->', btagDiscr
1058  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
1059  if hasattr(btag,btagDiscr):
1060  if hasattr(process, newDiscr):
1061  pass
1062  else:
1064  newDiscr,
1065  getattr(btag, btagDiscr).clone(),
1066  process,
1067  task
1068  )
1069  for dependency in supportedMetaDiscr[meta_tagger]:
1070  if ':' in dependency:
1071  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1072  else:
1073  new_dep = btagPrefix+dependency+labelName+postfix
1074  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1075  replace.doIt(getattr(process, newDiscr), newDiscr)
1076  acceptedBtagDiscriminators.append(meta_tagger)
1077  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
1078  if hasattr(process, newDiscr):
1079  pass
1080  else:
1082  newDiscr,
1083  pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
1084  process,
1085  task
1086  )
1087  for dependency in supportedMetaDiscr[meta_tagger]:
1088  if ':' in dependency:
1089  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1090  else:
1091  new_dep = btagPrefix+dependency+labelName+postfix
1092  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1093  replace.doIt(getattr(process, newDiscr), newDiscr)
1094  acceptedBtagDiscriminators.append(meta_tagger)
1095  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
1096  if hasattr(process, newDiscr):
1097  pass
1098  else:
1100  newDiscr,
1101  pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
1102  process,
1103  task
1104  )
1105  for dependency in supportedMetaDiscr[meta_tagger]:
1106  if ':' in dependency:
1107  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1108  else:
1109  new_dep = btagPrefix+dependency+labelName+postfix
1110  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1111  replace.doIt(getattr(process, newDiscr), newDiscr)
1112  acceptedBtagDiscriminators.append(meta_tagger)
1113  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1114  if hasattr(process, newDiscr):
1115  pass
1116  else:
1118  newDiscr,
1119  pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1120  process,
1121  task
1122  )
1123  for dependency in supportedMetaDiscr[meta_tagger]:
1124  if ':' in dependency:
1125  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1126  else:
1127  new_dep = btagPrefix+dependency+labelName+postfix
1128  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1129  replace.doIt(getattr(process, newDiscr), newDiscr)
1130  acceptedBtagDiscriminators.append(meta_tagger)
1131  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1132  if hasattr(process, newDiscr):
1133  pass
1134  else:
1136  newDiscr,
1137  pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1138  process,
1139  task
1140  )
1141  for dependency in supportedMetaDiscr[meta_tagger]:
1142  if ':' in dependency:
1143  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1144  else:
1145  new_dep = btagPrefix+dependency+labelName+postfix
1146  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1147  replace.doIt(getattr(process, newDiscr), newDiscr)
1148  acceptedBtagDiscriminators.append(meta_tagger)
1149  elif btagDiscr=='pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1150  if hasattr(process, newDiscr):
1151  pass
1152  else:
1154  newDiscr,
1155  pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1156  process,
1157  task
1158  )
1159  for dependency in supportedMetaDiscr[meta_tagger]:
1160  if ':' in dependency:
1161  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1162  else:
1163  new_dep = btagPrefix+dependency+labelName+postfix
1164  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1165  replace.doIt(getattr(process, newDiscr), newDiscr)
1166  acceptedBtagDiscriminators.append(meta_tagger)
1167 
1168  else:
1169  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1170 
1171 
1172  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
1173  patJets.discriminatorSources = cms.VInputTag(*[
1174  cms.InputTag(btagPrefix+x+labelName+postfix) \
1175  if ':' not in x else \
1176  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
1177  for x in acceptedBtagDiscriminators
1178  ])
1179  if len(acceptedBtagDiscriminators) > 0 :
1180  patJets.addBTagInfo = True
1181 
1182  if runIVF:
1183  if not tightBTagNTkHits:
1184  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1185  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
1186  else:
1187  rerunningIVF()
1188  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
1189  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1190  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
1191  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1192  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1193  if tightBTagNTkHits:
1194  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1195  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1196  _temp.minHits = cms.uint32(8)
1197 
1198  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1199  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1200  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1201  _temp.primaryVertices = pvSource
1202  _temp.tracks = pfCandidates
1203  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
1204  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
1205  _temp.primaryVertices = pvSource
1206  _temp.tracks = pfCandidates
1207  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
1208  addToProcessAndTask(svSource.getModuleLabel(),
1209  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
1210  process, task)
1211  if any(i in acceptedTagInfos for i in ivfcTagInfos):
1212  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1213  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1214  if tightBTagNTkHits:
1215  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1216  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1217  _temp.minHits = cms.uint32(8)
1218 
1219  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1220  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1221  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1222  _temp.primaryVertices = pvSource
1223  _temp.tracks = pfCandidates
1224  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
1225  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
1226  _temp.primaryVertices = pvSource
1227  _temp.tracks = pfCandidates
1228  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1229  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
1230  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
1231  process, task)
1232  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1233  if not hasattr( process, 'inclusiveVertexing' ):
1234  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1235  task.add(process.inclusiveVertexingTask)
1236  task.add(process.inclusiveCandidateVertexingTask)
1237  task.add(process.inclusiveCandidateVertexingCvsLTask)
1238  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1239  if not hasattr( process, 'inclusiveVertexing' ):
1240  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1241  task.add(process.inclusiveVertexingTask)
1242  task.add(process.inclusiveCandidateVertexingTask)
1243  task.add(process.inclusiveCandidateVertexingCvsLTask)
1244  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1245  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
1246  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1247  task.add(process.inclusiveSecondaryVerticesFiltered)
1248  task.add(process.bVertexFilter)
1249  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
1250  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1251  task.add(process.bToCharmDecayVertexMerged)
1252  if 'caTopTagInfos' in acceptedTagInfos :
1253  patJets.addTagInfos = True
1254  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
1255  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
1256  task.add(process.caTopTaggersTask)
1257 
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:2298
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:2306
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(), puppiJetMETReclusteringTools.puppiAK4METReclusterFromMiniAOD(), puppiJetMETReclusteringTools.puppiAK8ReclusterFromMiniAOD(), 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 2282 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

2282 def undefinedLabelName(obj):
2283  sys.stderr.write("-------------------------------------------------------\n")
2284  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
2285  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
2286  sys.stderr.write("-------------------------------------------------------\n")
2287  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
2288 
def undefinedLabelName(obj)
Definition: jetTools.py:2282

◆ unsupportedJetAlgorithm()

def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 2289 of file jetTools.py.

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

2289 def unsupportedJetAlgorithm(obj):
2290  sys.stderr.write("-------------------------------------------------------\n")
2291  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
2292  sys.stderr.write(" The supported algorithms are:\n")
2293  for key in supportedJetAlgos.keys():
2294  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
2295  sys.stderr.write("-------------------------------------------------------\n")
2296  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
2297 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:2289

Variable Documentation

◆ supportedJetAlgos

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 17 of file jetTools.py.