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 setupPackedPuppi (process)
 
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 2199 of file jetTools.py.

2200  sys.stderr.write("-------------------------------------------------------\n")
2201  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
2202  sys.stderr.write(" anymore by:\n")
2203  sys.stderr.write(" " + obj._label + "\n")
2204  sys.stderr.write(" please use 'outputModules' now and specify the\n")
2205  sys.stderr.write(" names of all needed OutModules in there\n")
2206  sys.stderr.write(" (default: ['out'])\n")
2207  sys.stderr.write("-------------------------------------------------------\n")
2208  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
2209 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:2199

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

Referenced by setupBTagging().

2226 def rerunningIVF():
2227  sys.stderr.write("-------------------------------------------------------------------\n")
2228  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
2229  sys.stderr.write(" already produced by the standard reconstruction. This\n")
2230  sys.stderr.write(" option is not enabled by default so please use it only if\n")
2231  sys.stderr.write(" you know what you are doing.\n")
2232  sys.stderr.write("-------------------------------------------------------------------\n")
2233 
def rerunningIVF()
Definition: jetTools.py:2226

◆ rerunningIVFMiniAOD()

def jetTools.rerunningIVFMiniAOD ( )

Definition at line 2234 of file jetTools.py.

Referenced by setupBTagging().

2234 def rerunningIVFMiniAOD():
2235  sys.stderr.write("-------------------------------------------------------------------\n")
2236  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
2237  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
2238  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
2239  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
2240  sys.stderr.write("-------------------------------------------------------------------\n")
2241 
def rerunningIVFMiniAOD()
Definition: jetTools.py:2234

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

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

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

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

◆ setupPackedPuppi()

def jetTools.setupPackedPuppi (   process)

Definition at line 242 of file jetTools.py.

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

Referenced by setupBTagging().

242 def setupPackedPuppi(process):
243  task = getPatAlgosToolsTask(process)
244  packedPuppiName = "packedpuppi"
245  if not hasattr(process,packedPuppiName):
246  from CommonTools.PileupAlgos.Puppi_cff import puppi
247  addToProcessAndTask(packedPuppiName, puppi.clone(
248  useExistingWeights = True,
249  candName = 'packedPFCandidates',
250  vertexName = 'offlineSlimmedPrimaryVertices') , process, task)
251  return packedPuppiName
252 
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
def setupPackedPuppi(process)
Definition: jetTools.py:242
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 2210 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

2210 def undefinedLabelName(obj):
2211  sys.stderr.write("-------------------------------------------------------\n")
2212  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
2213  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
2214  sys.stderr.write("-------------------------------------------------------\n")
2215  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
2216 
def undefinedLabelName(obj)
Definition: jetTools.py:2210

◆ unsupportedJetAlgorithm()

def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 2217 of file jetTools.py.

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

2217 def unsupportedJetAlgorithm(obj):
2218  sys.stderr.write("-------------------------------------------------------\n")
2219  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
2220  sys.stderr.write(" The supported algorithms are:\n")
2221  for key in supportedJetAlgos.keys():
2222  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
2223  sys.stderr.write("-------------------------------------------------------\n")
2224  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
2225 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:2217

Variable Documentation

◆ supportedJetAlgos

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 17 of file jetTools.py.