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

2169  sys.stderr.write("-------------------------------------------------------\n")
2170  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
2171  sys.stderr.write(" anymore by:\n")
2172  sys.stderr.write(" " + obj._label + "\n")
2173  sys.stderr.write(" please use 'outputModules' now and specify the\n")
2174  sys.stderr.write(" names of all needed OutModules in there\n")
2175  sys.stderr.write(" (default: ['out'])\n")
2176  sys.stderr.write("-------------------------------------------------------\n")
2177  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
2178 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:2168

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

Referenced by setupBTagging().

2195 def rerunningIVF():
2196  sys.stderr.write("-------------------------------------------------------------------\n")
2197  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
2198  sys.stderr.write(" already produced by the standard reconstruction. This\n")
2199  sys.stderr.write(" option is not enabled by default so please use it only if\n")
2200  sys.stderr.write(" you know what you are doing.\n")
2201  sys.stderr.write("-------------------------------------------------------------------\n")
2202 
def rerunningIVF()
Definition: jetTools.py:2195

◆ rerunningIVFMiniAOD()

def jetTools.rerunningIVFMiniAOD ( )

Definition at line 2203 of file jetTools.py.

Referenced by setupBTagging().

2203 def rerunningIVFMiniAOD():
2204  sys.stderr.write("-------------------------------------------------------------------\n")
2205  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
2206  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
2207  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
2208  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
2209  sys.stderr.write("-------------------------------------------------------------------\n")
2210 
def rerunningIVFMiniAOD()
Definition: jetTools.py:2203

◆ 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  # depens of wether 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 btagInfo == 'pfDeepDoubleXTagInfos':
668  # can only run on PAT jets, so the updater needs to be used
669  if 'updated' not in jetSource.value().lower():
670  raise ValueError("Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
671  packedPuppiName = setupPackedPuppi(process)
672  puppi_value_map = cms.InputTag(packedPuppiName)
673  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
674  btag.pfDeepDoubleXTagInfos.clone(
675  jets = jetSource,
676  vertices=pvSource,
677  secondary_vertices=svSource,
678  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
679  puppi_value_map = puppi_value_map,
680  ),
681  process, task)
682 
683  if btagInfo == 'pfHiggsInteractionNetTagInfos':
684  packedPuppiName = setupPackedPuppi(process)
685  puppi_value_map = cms.InputTag(packedPuppiName)
686  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
687  btag.pfHiggsInteractionNetTagInfos.clone(
688  jets = jetSource,
689  vertices = pvSource,
690  secondary_vertices = svSource,
691  pf_candidates = pfCandidates,
692  puppi_value_map = puppi_value_map
693  ),
694  process, task)
695 
696  if btagInfo == 'pfDeepBoostedJetTagInfos':
697  if pfCandidates.value() == 'packedPFCandidates':
698  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
699  if 'updated' not in jetSource.value().lower():
700  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
701  puppi_value_map = setupPackedPuppi(process)
702  vertex_associator = ""
703  elif pfCandidates.value() == 'particleFlow':
704  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
705  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
706  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
707  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
708 # puppi_value_map = "puppi"
709 # vertex_associator = "primaryVertexAssociation:original"
710  else:
711  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
712  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
713  btag.pfDeepBoostedJetTagInfos.clone(
714  jets = jetSource,
715  vertices = pvSource,
716  secondary_vertices = svSource,
717  pf_candidates = pfCandidates,
718  puppi_value_map = puppi_value_map,
719  vertex_associator = vertex_associator,
720  ),
721  process, task)
722 
723  if btagInfo == 'pfParticleNetTagInfos':
724  if pfCandidates.value() == 'packedPFCandidates':
725  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
726  puppi_value_map = setupPackedPuppi(process)
727  vertex_associator = ""
728  elif pfCandidates.value() == 'particleFlow':
729  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
730  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
731  puppi_value_map = "puppi"
732  vertex_associator = "primaryVertexAssociation:original"
733  else:
734  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
735  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
736  btag.pfParticleNetTagInfos.clone(
737  jets = jetSource,
738  vertices = pvSource,
739  secondary_vertices = svSource,
740  pf_candidates = pfCandidates,
741  puppi_value_map = puppi_value_map,
742  vertex_associator = vertex_associator,
743  ),
744  process, task)
745 
746  if 'ParticleNetAK4TagInfos' in btagInfo:
747  if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
748  secondary_vertices = btagPrefix + \
749  'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
750  flip_ip_sign = True
751  sip3dSigMax = 10
752  else:
753  secondary_vertices = svSource
754  flip_ip_sign = False
755  sip3dSigMax = -1
756  if pfCandidates.value() == 'packedPFCandidates':
757  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
758  puppi_value_map = setupPackedPuppi(process)
759  vertex_associator = ""
760  elif pfCandidates.value() == 'particleFlow':
761  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
762  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
763  puppi_value_map = "puppi"
764  vertex_associator = "primaryVertexAssociation:original"
765  else:
766  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
767  # If this jet is a Puppi jet, use puppi-weighted p4.
768  use_puppiP4 = False
769  if "puppi" in jetSource.value().lower():
770  use_puppiP4 = True
771  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
772  btag.pfParticleNetAK4TagInfos.clone(
773  jets = jetSource,
774  vertices = pvSource,
775  secondary_vertices = secondary_vertices,
776  pf_candidates = pfCandidates,
777  puppi_value_map = puppi_value_map,
778  vertex_associator = vertex_associator,
779  flip_ip_sign = flip_ip_sign,
780  sip3dSigMax = sip3dSigMax,
781  use_puppiP4 = use_puppiP4
782  ),
783  process, task)
784 
785  acceptedTagInfos.append(btagInfo)
786  elif hasattr(toptag, btagInfo) :
787  acceptedTagInfos.append(btagInfo)
788  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos':
789  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
790  if pfCandidates.value() != 'packedPFCandidates':
791  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
792  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
793  pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
794  jets = jetSource,
795  vertices = pvSource,
796  secondary_vertices = svSource,
797  pf_candidates = pfCandidates,
798  ),
799  process, task)
800  acceptedTagInfos.append(btagInfo)
801  elif btagInfo == 'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
802  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
803  if pfCandidates.value() != 'packedPFCandidates':
804  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
805  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
806  pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
807  jets = jetSource,
808  vertices = pvSource,
809  secondary_vertices = svSource,
810  pf_candidates = pfCandidates,
811  ),
812  process, task)
813  acceptedTagInfos.append(btagInfo)
814  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSCentralTagInfos':
815  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
816  if pfCandidates.value() != 'packedPFCandidates':
817  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
818  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
819  pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
820  jets = jetSource,
821  vertices = pvSource,
822  secondary_vertices = svSource,
823  pf_candidates = pfCandidates,
824  ),
825  process, task)
826  acceptedTagInfos.append(btagInfo)
827  elif btagInfo == 'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
828  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
829  if pfCandidates.value() != 'packedPFCandidates':
830  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
831  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
832  pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
833  jets = jetSource,
834  vertices = pvSource,
835  secondary_vertices = svSource,
836  pf_candidates = pfCandidates,
837  ),
838  process, task)
839  acceptedTagInfos.append(btagInfo)
840  elif btagInfo == 'pfParticleNetFromMiniAODAK8TagInfos':
841  # ParticleNetFromMiniAOD cannot be run on RECO inputs, so need a workaround
842  if pfCandidates.value() != 'packedPFCandidates':
843  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
844  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
845  pfParticleNetFromMiniAODAK8TagInfos.clone(
846  jets = jetSource,
847  vertices = pvSource,
848  secondary_vertices = svSource,
849  pf_candidates = pfCandidates,
850  ),
851  process, task)
852  acceptedTagInfos.append(btagInfo)
853  else:
854  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
855  # setup all required btagDiscriminators
856  acceptedBtagDiscriminators = list()
857  for discriminator_name in btagDiscriminators :
858  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
859  #print discriminator_name, '-->', btagDiscr
860  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
861  if hasattr(btag,btagDiscr):
862  if hasattr(process, newDiscr):
863  pass
864  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
866  newDiscr,
867  getattr(btag, btagDiscr).clone(
868  tagInfos = cms.VInputTag(
869  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
870  for x in supportedBtagDiscr[discriminator_name][0] ]
871  )
872  ),
873  process,
874  task
875  )
876  elif hasattr(getattr(btag, btagDiscr), 'src'):
878  newDiscr,
879  getattr(btag, btagDiscr).clone(
880  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
881  ),
882  process,
883  task
884  )
885  else:
886  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
887  acceptedBtagDiscriminators.append(discriminator_name)
888  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
889  if hasattr(process, newDiscr):
890  pass
892  newDiscr,
893  pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
894  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
895  ),
896  process,
897  task
898  )
899  acceptedBtagDiscriminators.append(discriminator_name)
900  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
901  if hasattr(process, newDiscr):
902  pass
904  newDiscr,
905  pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
906  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
907  ),
908  process,
909  task
910  )
911  acceptedBtagDiscriminators.append(discriminator_name)
912  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralJetTags':
913  if hasattr(process, newDiscr):
914  pass
916  newDiscr,
917  pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
918  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
919  ),
920  process,
921  task
922  )
923  acceptedBtagDiscriminators.append(discriminator_name)
924  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardJetTags':
925  if hasattr(process, newDiscr):
926  pass
928  newDiscr,
929  pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
930  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
931  ),
932  process,
933  task
934  )
935  acceptedBtagDiscriminators.append(discriminator_name)
936  elif btagDiscr=='pfParticleNetFromMiniAODAK8JetTags':
937  if hasattr(process, newDiscr):
938  pass
940  newDiscr,
941  pfParticleNetFromMiniAODAK8JetTags.clone(
942  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
943  ),
944  process,
945  task
946  )
947  acceptedBtagDiscriminators.append(discriminator_name)
948  else:
949  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
950 
951  #update meta-taggers, if any
952  for meta_tagger in present_meta:
953  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
954  #print discriminator_name, '-->', btagDiscr
955  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
956  if hasattr(btag,btagDiscr):
957  if hasattr(process, newDiscr):
958  pass
959  else:
961  newDiscr,
962  getattr(btag, btagDiscr).clone(),
963  process,
964  task
965  )
966  for dependency in supportedMetaDiscr[meta_tagger]:
967  if ':' in dependency:
968  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
969  else:
970  new_dep = btagPrefix+dependency+labelName+postfix
971  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
972  replace.doIt(getattr(process, newDiscr), newDiscr)
973  acceptedBtagDiscriminators.append(meta_tagger)
974  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
975  if hasattr(process, newDiscr):
976  pass
977  else:
979  newDiscr,
980  pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
981  process,
982  task
983  )
984  for dependency in supportedMetaDiscr[meta_tagger]:
985  if ':' in dependency:
986  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
987  else:
988  new_dep = btagPrefix+dependency+labelName+postfix
989  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
990  replace.doIt(getattr(process, newDiscr), newDiscr)
991  acceptedBtagDiscriminators.append(meta_tagger)
992  elif btagDiscr=='pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
993  if hasattr(process, newDiscr):
994  pass
995  else:
997  newDiscr,
998  pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
999  process,
1000  task
1001  )
1002  for dependency in supportedMetaDiscr[meta_tagger]:
1003  if ':' in dependency:
1004  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1005  else:
1006  new_dep = btagPrefix+dependency+labelName+postfix
1007  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1008  replace.doIt(getattr(process, newDiscr), newDiscr)
1009  acceptedBtagDiscriminators.append(meta_tagger)
1010  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1011  if hasattr(process, newDiscr):
1012  pass
1013  else:
1015  newDiscr,
1016  pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1017  process,
1018  task
1019  )
1020  for dependency in supportedMetaDiscr[meta_tagger]:
1021  if ':' in dependency:
1022  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1023  else:
1024  new_dep = btagPrefix+dependency+labelName+postfix
1025  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1026  replace.doIt(getattr(process, newDiscr), newDiscr)
1027  acceptedBtagDiscriminators.append(meta_tagger)
1028  elif btagDiscr=='pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1029  if hasattr(process, newDiscr):
1030  pass
1031  else:
1033  newDiscr,
1034  pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1035  process,
1036  task
1037  )
1038  for dependency in supportedMetaDiscr[meta_tagger]:
1039  if ':' in dependency:
1040  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1041  else:
1042  new_dep = btagPrefix+dependency+labelName+postfix
1043  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1044  replace.doIt(getattr(process, newDiscr), newDiscr)
1045  acceptedBtagDiscriminators.append(meta_tagger)
1046  elif btagDiscr=='pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1047  if hasattr(process, newDiscr):
1048  pass
1049  else:
1051  newDiscr,
1052  pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1053  process,
1054  task
1055  )
1056  for dependency in supportedMetaDiscr[meta_tagger]:
1057  if ':' in dependency:
1058  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
1059  else:
1060  new_dep = btagPrefix+dependency+labelName+postfix
1061  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1062  replace.doIt(getattr(process, newDiscr), newDiscr)
1063  acceptedBtagDiscriminators.append(meta_tagger)
1064 
1065  else:
1066  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1067 
1068 
1069  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
1070  patJets.discriminatorSources = cms.VInputTag(*[
1071  cms.InputTag(btagPrefix+x+labelName+postfix) \
1072  if ':' not in x else \
1073  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
1074  for x in acceptedBtagDiscriminators
1075  ])
1076  if len(acceptedBtagDiscriminators) > 0 :
1077  patJets.addBTagInfo = True
1078 
1079  if runIVF:
1080  if not tightBTagNTkHits:
1081  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1082  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
1083  else:
1084  rerunningIVF()
1085  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
1086  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1087  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
1088  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1089  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1090  if tightBTagNTkHits:
1091  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1092  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1093  _temp.minHits = cms.uint32(8)
1094 
1095  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1096  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
1097  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
1098  _temp.primaryVertices = pvSource
1099  _temp.tracks = pfCandidates
1100  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
1101  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
1102  _temp.primaryVertices = pvSource
1103  _temp.tracks = pfCandidates
1104  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
1105  addToProcessAndTask(svSource.getModuleLabel(),
1106  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
1107  process, task)
1108  if any(i in acceptedTagInfos for i in ivfcTagInfos):
1109  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1110  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1111  if tightBTagNTkHits:
1112  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1113  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1114  _temp.minHits = cms.uint32(8)
1115 
1116  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
1117  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
1118  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
1119  _temp.primaryVertices = pvSource
1120  _temp.tracks = pfCandidates
1121  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
1122  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
1123  _temp.primaryVertices = pvSource
1124  _temp.tracks = pfCandidates
1125  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1126  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
1127  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
1128  process, task)
1129  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1130  if not hasattr( process, 'inclusiveVertexing' ):
1131  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1132  task.add(process.inclusiveVertexingTask)
1133  task.add(process.inclusiveCandidateVertexingTask)
1134  task.add(process.inclusiveCandidateVertexingCvsLTask)
1135  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1136  if not hasattr( process, 'inclusiveVertexing' ):
1137  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1138  task.add(process.inclusiveVertexingTask)
1139  task.add(process.inclusiveCandidateVertexingTask)
1140  task.add(process.inclusiveCandidateVertexingCvsLTask)
1141  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1142  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
1143  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1144  task.add(process.inclusiveSecondaryVerticesFiltered)
1145  task.add(process.bVertexFilter)
1146  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
1147  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1148  task.add(process.bToCharmDecayVertexMerged)
1149  if 'caTopTagInfos' in acceptedTagInfos :
1150  patJets.addTagInfos = True
1151  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
1152  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
1153  task.add(process.caTopTaggersTask)
1154 
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:2195
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:2203
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 2179 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

2179 def undefinedLabelName(obj):
2180  sys.stderr.write("-------------------------------------------------------\n")
2181  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
2182  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
2183  sys.stderr.write("-------------------------------------------------------\n")
2184  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
2185 
def undefinedLabelName(obj)
Definition: jetTools.py:2179

◆ unsupportedJetAlgorithm()

def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 2186 of file jetTools.py.

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

2186 def unsupportedJetAlgorithm(obj):
2187  sys.stderr.write("-------------------------------------------------------\n")
2188  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
2189  sys.stderr.write(" The supported algorithms are:\n")
2190  for key in supportedJetAlgos.keys():
2191  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
2192  sys.stderr.write("-------------------------------------------------------\n")
2193  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
2194 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:2186

Variable Documentation

◆ supportedJetAlgos

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 17 of file jetTools.py.