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 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

def jetTools.checkJetCorrectionsFormat (   jetCorrections)

Definition at line 18 of file jetTools.py.

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

18 def checkJetCorrectionsFormat(jetCorrections):
19  ## check for the correct format
20  if not isinstance(jetCorrections, type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL'))):
21  raise ValueError("In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
22  '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) \
23  corrections.")
24 
25 
def checkJetCorrectionsFormat(jetCorrections)
Definition: jetTools.py:18
def jetTools.deprecatedOptionOutputModule (   obj)

Definition at line 1817 of file jetTools.py.

1818  sys.stderr.write("-------------------------------------------------------\n")
1819  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1820  sys.stderr.write(" anymore by:\n")
1821  sys.stderr.write(" " + obj._label + "\n")
1822  sys.stderr.write(" please use 'outputModules' now and specify the\n")
1823  sys.stderr.write(" names of all needed OutModules in there\n")
1824  sys.stderr.write(" (default: ['out'])\n")
1825  sys.stderr.write("-------------------------------------------------------\n")
1826  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1827 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1817
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
def jetTools.rerunningIVF ( )

Definition at line 1844 of file jetTools.py.

Referenced by setupBTagging().

1845  sys.stderr.write("-------------------------------------------------------------------\n")
1846  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1847  sys.stderr.write(" already produced by the standard reconstruction. This\n")
1848  sys.stderr.write(" option is not enabled by default so please use it only if\n")
1849  sys.stderr.write(" you know what you are doing.\n")
1850  sys.stderr.write("-------------------------------------------------------------------\n")
1851 
def rerunningIVF()
Definition: jetTools.py:1844
def jetTools.rerunningIVFMiniAOD ( )

Definition at line 1852 of file jetTools.py.

Referenced by setupBTagging().

1853  sys.stderr.write("-------------------------------------------------------------------\n")
1854  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1855  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1856  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1857  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1858  sys.stderr.write("-------------------------------------------------------------------\n")
1859 
def rerunningIVFMiniAOD()
Definition: jetTools.py:1852
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 237 of file jetTools.py.

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

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

237  algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
238 
239  task = getPatAlgosToolsTask(process)
240 
241  ## expand the btagDiscriminators to remove the meta taggers and substitute the equivalent sources
242  discriminators = set(btagDiscriminators)
243  present_meta = discriminators.intersection(set(supportedMetaDiscr.keys()))
244  discriminators -= present_meta
245  for meta_tagger in present_meta:
246  for src in supportedMetaDiscr[meta_tagger]:
247  discriminators.add(src)
248  btagDiscriminators = list(discriminators)
249 
250  ## expand tagInfos to what is explicitly required by user + implicit
251  ## requirements that come in from one or the other discriminator
252  requiredTagInfos = list(btagInfos)
253  for btagDiscr in btagDiscriminators :
254  for tagInfoList in supportedBtagDiscr[btagDiscr] :
255  for requiredTagInfo in tagInfoList :
256  tagInfoCovered = False
257  for tagInfo in requiredTagInfos :
258  if requiredTagInfo == tagInfo :
259  tagInfoCovered = True
260  break
261  if not tagInfoCovered :
262  requiredTagInfos.append(requiredTagInfo)
263  ## load sequences and setups needed for btagging
264  if hasattr( process, 'candidateJetProbabilityComputer' ) == False :
265  if loadStdRecoBTag: # also loading modules already run in the standard reconstruction
266  process.load("RecoBTag.ImpactParameter.impactParameter_cff")
267  task.add(process.impactParameterTask)
268  process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
269  task.add(process.secondaryVertexTask)
270  process.load("RecoBTag.SoftLepton.softLepton_cff")
271  task.add(process.softLeptonTask)
272  process.load("RecoBTag.Combined.combinedMVA_cff")
273  task.add(process.combinedMVATask)
274  process.load("RecoBTag.CTagging.cTagging_cff")
275  task.add(process.cTaggingTask)
276  else: # to prevent loading of modules already run in the standard reconstruction
277  process.load("RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
278  process.load("RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
279  process.load("RecoBTag.SoftLepton.softLepton_EventSetup_cff")
280  process.load("RecoBTag.Combined.combinedMVA_EventSetup_cff")
281  process.load("RecoBTag.CTagging.cTagging_EventSetup_cff")
283  import RecoJets.JetProducers.caTopTaggers_cff as toptag
284 
285  if tightBTagNTkHits:
286  if not runIVF:
287  sys.stderr.write("-------------------------------------------------------------------\n")
288  sys.stderr.write(" Warning: For a complete switch to the legacy tight b-tag track\n")
289  sys.stderr.write(" selection, please also enable the \'runIVF\' switch.\n")
290  sys.stderr.write("-------------------------------------------------------------------\n")
291  if btagPrefix == '':
292  sys.stderr.write("-------------------------------------------------------------------\n")
293  sys.stderr.write(" Warning: With the tight b-tag track selection enabled, it is\n")
294  sys.stderr.write(" advisable to set \'btagPrefix\' to a non-empty string to\n")
295  sys.stderr.write(" avoid unintentional modifications to the default\n")
296  sys.stderr.write(" b tagging setup that might be loaded in the same job.\n")
297  sys.stderr.write("-------------------------------------------------------------------\n")
298 
299  ## define c tagging CvsL SV source (for now tied to the default SV source
300  ## in the first part of the module label, product instance label and process name)
301  svSourceCvsL = copy.deepcopy(svSource)
302  svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+'CvsL')
303 
304  ## check if and under what conditions to re-run IVF
305  runIVFforCTagOnly = False
306  ivfcTagInfos = ['pfInclusiveSecondaryVertexFinderCvsLTagInfos', 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
307  ## if MiniAOD and running c tagging
308  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices' and any(i in requiredTagInfos for i in ivfcTagInfos) and not runIVF:
309  runIVFforCTagOnly = True
310  runIVF = True
311  sys.stderr.write("-------------------------------------------------------------------\n")
312  sys.stderr.write(" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
313  sys.stderr.write(" vertices will be remade.\n")
314  sys.stderr.write("-------------------------------------------------------------------\n")
315  ## adjust svSources
316  if runIVF and btagPrefix != '':
317  if runIVFforCTagOnly:
318  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
319  else:
320  svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
321  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
322 
323  ## setup all required btagInfos : we give a dedicated treatment for different
324  ## types of tagInfos here. A common treatment is possible but might require a more
325  ## general approach anyway in coordination with the btagging POG.
326 
327  runNegativeVertexing = False
328  runNegativeCvsLVertexing = False
329  for btagInfo in requiredTagInfos:
330  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos' or btagInfo == 'pfNegativeDeepFlavourTagInfos':
331  runNegativeVertexing = True
332  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
333  runNegativeCvsLVertexing = True
334 
335  if runNegativeVertexing or runNegativeCvsLVertexing:
336  import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff as NegVertex
337 
338  if runNegativeVertexing:
339  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix,
340  NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
341  process, task)
342  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix,
343  NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
344  process, task)
345  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix,
346  NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix)
347  ,primaryVertices = pvSource
348  ,tracks=pfCandidates),
349  process, task)
350  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
351  NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix)),
352  process, task)
353 
354  if runNegativeCvsLVertexing:
355  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
356  NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
357  process, task)
358  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix,
359  NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
360  process, task)
361  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix,
362  NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix)
363  ,primaryVertices = pvSource
364  ,tracks=pfCandidates),
365  process, task)
366  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
367  NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
368  process, task)
369 
370 
371  acceptedTagInfos = list()
372  for btagInfo in requiredTagInfos:
373  if hasattr(btag,btagInfo):
374  if btagInfo == 'pfImpactParameterTagInfos':
375  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
376  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
377  process, task)
378  if explicitJTA:
379  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
380  _btagInfo.explicitJTA = cms.bool(explicitJTA)
381  if tightBTagNTkHits:
382  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
383  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
384  _btagInfo.minimumNumberOfHits = cms.int32(8)
385  if btagInfo == 'pfImpactParameterAK8TagInfos':
386  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
387  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
388  process, task)
389  if explicitJTA:
390  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
391  _btagInfo.explicitJTA = cms.bool(explicitJTA)
392  if tightBTagNTkHits:
393  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
394  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
395  _btagInfo.minimumNumberOfHits = cms.int32(8)
396  if btagInfo == 'pfImpactParameterCA15TagInfos':
397  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
398  btag.pfImpactParameterCA15TagInfos.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 == 'pfSecondaryVertexTagInfos':
408  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
409  btag.pfSecondaryVertexTagInfos.clone(
410  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
411  process, task)
412  if tightBTagNTkHits:
413  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
414  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
415  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
416  if btagInfo == 'pfDeepCSVTagInfos':
417  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
418  btag.pfDeepCSVTagInfos.clone(
419  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
420  process, task)
421  if svClustering or fatJets != cms.InputTag(''):
422  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
423  if btagInfo == 'pfDeepCSVNegativeTagInfos':
424  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
425  btag.pfDeepCSVNegativeTagInfos.clone(
426  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
427  process, task)
428  if svClustering or fatJets != cms.InputTag(''):
429  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
430  if btagInfo == 'pfDeepCSVPositiveTagInfos':
431  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
432  btag.pfDeepCSVPositiveTagInfos.clone(
433  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
434  process, task)
435  if svClustering or fatJets != cms.InputTag(''):
436  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
437  if btagInfo == 'pfDeepCMVATagInfos':
438  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
439  btag.pfDeepCMVATagInfos.clone(
440  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
441  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
442  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
443  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
444  process, task)
445  if svClustering or fatJets != cms.InputTag(''):
446  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
447  if btagInfo == 'pfDeepCMVANegativeTagInfos':
448  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
449  btag.pfDeepCMVATagInfos.clone(
450  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
451  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
452  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
453  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
454  process, task)
455  if svClustering or fatJets != cms.InputTag(''):
456  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
457  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
458  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
459  btag.pfDeepCMVATagInfos.clone(
460  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
461  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
462  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
463  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
464  process, task)
465  if svClustering or fatJets != cms.InputTag(''):
466  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
467  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
468  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
469  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
470  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
471  extSVCollection=svSource),
472  process, task)
473  if svClustering or fatJets != cms.InputTag(''):
474  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
475  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
476  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
477  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
478  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
479  extSVCollection=svSource),
480  process, task)
481  if svClustering or fatJets != cms.InputTag(''):
482  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
483  if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
484  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
485  btag.pfBoostedDoubleSVAK8TagInfos.clone(
486  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
487  process, task)
488  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
489  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
490  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
491  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
492  extSVCollection=svSource),
493  process, task)
494  if svClustering or fatJets != cms.InputTag(''):
495  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
496  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
497  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
498  btag.pfBoostedDoubleSVCA15TagInfos.clone(
499  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
500  process, task)
501  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
502  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
503  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
504  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
505  extSVCollection=svSourceCvsL),
506  process, task)
507  if svClustering or fatJets != cms.InputTag(''):
508  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
509  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
510  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
511  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
512  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
513  extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
514  process, task)
515  if svClustering or fatJets != cms.InputTag(''):
516  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
517  if btagInfo == 'pfGhostTrackVertexTagInfos':
518  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
519  btag.pfGhostTrackVertexTagInfos.clone(
520  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
521  process, task)
522  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
523  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
524  btag.pfSecondaryVertexNegativeTagInfos.clone(
525  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
526  process, task)
527  if tightBTagNTkHits:
528  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
529  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
530  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
531  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
532  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
533  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
534  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
535  extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+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 == 'impactParameterTagInfos':
540  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
541  btag.impactParameterTagInfos.clone(
542  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
543  primaryVertex=pvSource),
544  process, task)
545  if btagInfo == 'secondaryVertexTagInfos':
546  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
547  btag.secondaryVertexTagInfos.clone(
548  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
549  process, task)
550  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
551  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
552  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
553  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
554  process, task)
555  if svClustering or fatJets != cms.InputTag(''):
556  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
557  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
558  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
559  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
560  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
561  process, task)
562  if svClustering or fatJets != cms.InputTag(''):
563  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
564  if btagInfo == 'secondaryVertexNegativeTagInfos':
565  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
566  btag.secondaryVertexNegativeTagInfos.clone(
567  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
568  process, task)
569  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
570  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
571  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
572  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
573  process, task)
574  if svClustering or fatJets != cms.InputTag(''):
575  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
576  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
577  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
578  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
579  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
580  process, task)
581  if svClustering or fatJets != cms.InputTag(''):
582  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
583  if btagInfo == 'softMuonTagInfos':
584  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
585  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
586  process, task)
587  if btagInfo == 'softPFMuonsTagInfos':
588  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
589  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
590  process, task)
591  if btagInfo == 'softPFElectronsTagInfos':
592  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
593  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
594  process, task)
595  if btagInfo == 'pixelClusterTagInfos':
596  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
597  btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
598  process, task)
599 
600  if 'DeepFlavourTagInfos' in btagInfo:
601  svUsed = svSource
602  if btagInfo == 'pfNegativeDeepFlavourTagInfos':
603  deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
604  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
605  flip = True
606  else:
607  deep_csv_tag_infos = 'pfDeepCSVTagInfos'
608  flip = False
609  # use right input tags when running with RECO PF candidates, which actually
610  # depens of wether jets were slimmed or not (check for s/S-limmed in name)
611  if not ('limmed' in jetSource.value()):
612  puppi_value_map = cms.InputTag("puppi")
613  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
614  else:
615  puppi_value_map = cms.InputTag("")
616  vertex_associator = cms.InputTag("")
617  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
618  btag.pfDeepFlavourTagInfos.clone(
619  jets = jetSource,
620  vertices=pvSource,
621  secondary_vertices=svUsed,
622  shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
623  puppi_value_map = puppi_value_map,
624  vertex_associator = vertex_associator,
625  flip = flip),
626  process, task)
627 
628  if btagInfo == 'pfDeepDoubleXTagInfos':
629  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
630  btag.pfDeepDoubleXTagInfos.clone(
631  jets = jetSource,
632  vertices=pvSource,
633  secondary_vertices=svSource,
634  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
635  ),
636  process, task)
637 
638  if btagInfo == 'pfDeepBoostedJetTagInfos':
639  if pfCandidates.value() == 'packedPFCandidates':
640  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
641  if 'updated' not in jetSource.value().lower():
642  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
643  puppi_value_map = ""
644  vertex_associator = ""
645  elif pfCandidates.value() == 'particleFlow':
646  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
647  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
648  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
649  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
650 # puppi_value_map = "puppi"
651 # vertex_associator = "primaryVertexAssociation:original"
652  else:
653  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
654  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
655  btag.pfDeepBoostedJetTagInfos.clone(
656  jets = jetSource,
657  vertices = pvSource,
658  secondary_vertices = svSource,
659  pf_candidates = pfCandidates,
660  puppi_value_map = puppi_value_map,
661  vertex_associator = vertex_associator,
662  ),
663  process, task)
664 
665  acceptedTagInfos.append(btagInfo)
666  elif hasattr(toptag, btagInfo) :
667  acceptedTagInfos.append(btagInfo)
668  else:
669  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
670  ## setup all required btagDiscriminators
671  acceptedBtagDiscriminators = list()
672  for discriminator_name in btagDiscriminators :
673  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
674  #print discriminator_name, '-->', btagDiscr
675  if hasattr(btag,btagDiscr):
676  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
677  if hasattr(process, newDiscr):
678  pass
679  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
681  newDiscr,
682  getattr(btag, btagDiscr).clone(
683  tagInfos = cms.VInputTag(
684  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
685  for x in supportedBtagDiscr[discriminator_name][0] ]
686  )
687  ),
688  process,
689  task
690  )
691  elif hasattr(getattr(btag, btagDiscr), 'src'):
693  newDiscr,
694  getattr(btag, btagDiscr).clone(
695  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
696  ),
697  process,
698  task
699  )
700  else:
701  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
702  acceptedBtagDiscriminators.append(discriminator_name)
703  else:
704  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
705  #update meta-taggers, if any
706  for meta_tagger in present_meta:
707  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
708  #print discriminator_name, '-->', btagDiscr
709  if hasattr(btag,btagDiscr):
710  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
711  if hasattr(process, newDiscr):
712  pass
713  else:
715  newDiscr,
716  getattr(btag, btagDiscr).clone(),
717  process,
718  task
719  )
720  for dependency in supportedMetaDiscr[meta_tagger]:
721  if ':' in dependency:
722  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
723  else:
724  new_dep = btagPrefix+dependency+labelName+postfix
725  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
726  replace.doIt(getattr(process, newDiscr), newDiscr)
727  acceptedBtagDiscriminators.append(meta_tagger)
728  else:
729  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
730 
731  ## replace corresponding tags for pat jet production
732  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
733  patJets.discriminatorSources = cms.VInputTag(*[
734  cms.InputTag(btagPrefix+x+labelName+postfix) \
735  if ':' not in x else \
736  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
737  for x in acceptedBtagDiscriminators
738  ])
739  if len(acceptedBtagDiscriminators) > 0 :
740  patJets.addBTagInfo = True
741  ## if re-running IVF
742  if runIVF:
743  if not tightBTagNTkHits:
744  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices': ## MiniAOD case
745  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
746  else:
747  rerunningIVF()
748  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
749  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
750  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
751  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
752  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
753  if tightBTagNTkHits:
754  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
755  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
756  _temp.minHits = cms.uint32(8)
757  ## MiniAOD case
758  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
759  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
760  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
761  _temp.primaryVertices = pvSource
762  _temp.tracks = pfCandidates
763  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
764  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
765  _temp.primaryVertices = pvSource
766  _temp.tracks = pfCandidates
767  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
768  addToProcessAndTask(svSource.getModuleLabel(),
769  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
770  process, task)
771  if any(i in acceptedTagInfos for i in ivfcTagInfos):
772  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
773  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
774  if tightBTagNTkHits:
775  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
776  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
777  _temp.minHits = cms.uint32(8)
778  ## MiniAOD case
779  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
780  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
781  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
782  _temp.primaryVertices = pvSource
783  _temp.tracks = pfCandidates
784  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
785  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
786  _temp.primaryVertices = pvSource
787  _temp.tracks = pfCandidates
788  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
789  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
790  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
791  process, task)
792  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
793  if not hasattr( process, 'inclusiveVertexing' ):
794  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
795  task.add(process.inclusiveVertexingTask)
796  task.add(process.inclusiveCandidateVertexingTask)
797  task.add(process.inclusiveCandidateVertexingCvsLTask)
798  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
799  if not hasattr( process, 'inclusiveVertexing' ):
800  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
801  task.add(process.inclusiveVertexingTask)
802  task.add(process.inclusiveCandidateVertexingTask)
803  task.add(process.inclusiveCandidateVertexingCvsLTask)
804  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
805  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
806  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
807  task.add(process.inclusiveSecondaryVerticesFiltered)
808  task.add(process.bVertexFilter)
809  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
810  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
811  task.add(process.bToCharmDecayVertexMerged)
812  if 'caTopTagInfos' in acceptedTagInfos :
813  patJets.addTagInfos = True
814  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
815  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
816  task.add(process.caTopTaggersTask)
817 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:40
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:29
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:225
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
Definition: helpers.py:44
def rerunningIVF()
Definition: jetTools.py:1844
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:1852
def getPatAlgosToolsTask(process)
Definition: helpers.py:14
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def jetTools.setupJetCorrections (   process,
  knownModules,
  jetCorrections,
  jetSource,
  pvSource,
  patJets,
  labelName,
  postfix 
)

Definition at line 26 of file jetTools.py.

References helpers.addToProcessAndTask(), clone(), KineDebug3.count(), helpers.getPatAlgosToolsTask(), and cms::dd.split().

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

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

Definition at line 225 of file jetTools.py.

References setupBTagging().

Referenced by setupBTagging().

225 def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag('')):
226  btagInfo.useSVClustering = cms.bool(svClustering)
227  btagInfo.jetAlgorithm = cms.string(algo)
228  btagInfo.rParam = cms.double(rParam)
229  ## if the jet is actually a subjet
230  if fatJets != cms.InputTag(''):
231  btagInfo.fatJets = fatJets
232  if groomedFatJets != cms.InputTag(''):
233  btagInfo.groomedFatJets = groomedFatJets
234 
235 
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:225
def jetTools.undefinedLabelName (   obj)

Definition at line 1828 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

1829  sys.stderr.write("-------------------------------------------------------\n")
1830  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1831  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1832  sys.stderr.write("-------------------------------------------------------\n")
1833  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1834 
def undefinedLabelName(obj)
Definition: jetTools.py:1828
def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 1835 of file jetTools.py.

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

1836  sys.stderr.write("-------------------------------------------------------\n")
1837  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1838  sys.stderr.write(" The supported algorithms are:\n")
1839  for key in supportedJetAlgos.keys():
1840  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1841  sys.stderr.write("-------------------------------------------------------\n")
1842  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1843 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1835

Variable Documentation

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 12 of file jetTools.py.