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

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

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

Definition at line 1728 of file jetTools.py.

1729  sys.stderr.write("-------------------------------------------------------\n")
1730  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1731  sys.stderr.write(" anymore by:\n")
1732  sys.stderr.write(" " + obj._label + "\n")
1733  sys.stderr.write(" please use 'outputModules' now and specify the\n")
1734  sys.stderr.write(" names of all needed OutModules in there\n")
1735  sys.stderr.write(" (default: ['out'])\n")
1736  sys.stderr.write("-------------------------------------------------------\n")
1737  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1738 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1728
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 1755 of file jetTools.py.

Referenced by setupBTagging().

1756  sys.stderr.write("-------------------------------------------------------------------\n")
1757  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1758  sys.stderr.write(" already produced by the standard reconstruction. This\n")
1759  sys.stderr.write(" option is not enabled by default so please use it only if\n")
1760  sys.stderr.write(" you know what you are doing.\n")
1761  sys.stderr.write("-------------------------------------------------------------------\n")
1762 
def rerunningIVF()
Definition: jetTools.py:1755
def jetTools.rerunningIVFMiniAOD ( )

Definition at line 1763 of file jetTools.py.

Referenced by setupBTagging().

1764  sys.stderr.write("-------------------------------------------------------------------\n")
1765  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1766  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1767  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1768  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1769  sys.stderr.write("-------------------------------------------------------------------\n")
1770 
def rerunningIVFMiniAOD()
Definition: jetTools.py:1763
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 236 of file jetTools.py.

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

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

236  algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
237 
238  task = getPatAlgosToolsTask(process)
239 
240  ## expand the btagDiscriminators to remove the meta taggers and substitute the equivalent sources
241  discriminators = set(btagDiscriminators)
242  present_meta = discriminators.intersection(set(supportedMetaDiscr.keys()))
243  discriminators -= present_meta
244  for meta_tagger in present_meta:
245  for src in supportedMetaDiscr[meta_tagger]:
246  discriminators.add(src)
247  btagDiscriminators = list(discriminators)
248 
249  ## expand tagInfos to what is explicitly required by user + implicit
250  ## requirements that come in from one or the other discriminator
251  requiredTagInfos = list(btagInfos)
252  for btagDiscr in btagDiscriminators :
253  for tagInfoList in supportedBtagDiscr[btagDiscr] :
254  for requiredTagInfo in tagInfoList :
255  tagInfoCovered = False
256  for tagInfo in requiredTagInfos :
257  if requiredTagInfo == tagInfo :
258  tagInfoCovered = True
259  break
260  if not tagInfoCovered :
261  requiredTagInfos.append(requiredTagInfo)
262  ## load sequences and setups needed for btagging
263  if hasattr( process, 'candidateJetProbabilityComputer' ) == False :
264  if loadStdRecoBTag: # also loading modules already run in the standard reconstruction
265  process.load("RecoBTag.ImpactParameter.impactParameter_cff")
266  task.add(process.impactParameterTask)
267  process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
268  task.add(process.secondaryVertexTask)
269  process.load("RecoBTag.SoftLepton.softLepton_cff")
270  task.add(process.softLeptonTask)
271  process.load("RecoBTag.Combined.combinedMVA_cff")
272  task.add(process.combinedMVATask)
273  process.load("RecoBTag.CTagging.cTagging_cff")
274  task.add(process.cTaggingTask)
275  else: # to prevent loading of modules already run in the standard reconstruction
276  process.load("RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
277  process.load("RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
278  process.load("RecoBTag.SoftLepton.softLepton_EventSetup_cff")
279  process.load("RecoBTag.Combined.combinedMVA_EventSetup_cff")
280  process.load("RecoBTag.CTagging.cTagging_EventSetup_cff")
282  import RecoJets.JetProducers.caTopTaggers_cff as toptag
283 
284  if tightBTagNTkHits:
285  if not runIVF:
286  sys.stderr.write("-------------------------------------------------------------------\n")
287  sys.stderr.write(" Warning: For a complete switch to the legacy tight b-tag track\n")
288  sys.stderr.write(" selection, please also enable the \'runIVF\' switch.\n")
289  sys.stderr.write("-------------------------------------------------------------------\n")
290  if btagPrefix == '':
291  sys.stderr.write("-------------------------------------------------------------------\n")
292  sys.stderr.write(" Warning: With the tight b-tag track selection enabled, it is\n")
293  sys.stderr.write(" advisable to set \'btagPrefix\' to a non-empty string to\n")
294  sys.stderr.write(" avoid unintentional modifications to the default\n")
295  sys.stderr.write(" b tagging setup that might be loaded in the same job.\n")
296  sys.stderr.write("-------------------------------------------------------------------\n")
297 
298  ## define c tagging CvsL SV source (for now tied to the default SV source
299  ## in the first part of the module label, product instance label and process name)
300  svSourceCvsL = copy.deepcopy(svSource)
301  svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+'CvsL')
302 
303  ## check if and under what conditions to re-run IVF
304  runIVFforCTagOnly = False
305  ivfcTagInfos = ['pfInclusiveSecondaryVertexFinderCvsLTagInfos', 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
306  ## if MiniAOD and running c tagging
307  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices' and any(i in requiredTagInfos for i in ivfcTagInfos) and not runIVF:
308  runIVFforCTagOnly = True
309  runIVF = True
310  sys.stderr.write("-------------------------------------------------------------------\n")
311  sys.stderr.write(" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
312  sys.stderr.write(" vertices will be remade.\n")
313  sys.stderr.write("-------------------------------------------------------------------\n")
314  ## adjust svSources
315  if runIVF and btagPrefix != '':
316  if runIVFforCTagOnly:
317  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
318  else:
319  svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
320  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
321 
322  ## setup all required btagInfos : we give a dedicated treatment for different
323  ## types of tagInfos here. A common treatment is possible but might require a more
324  ## general approach anyway in coordination with the btagging POG.
325  acceptedTagInfos = list()
326  for btagInfo in requiredTagInfos:
327  if hasattr(btag,btagInfo):
328  if btagInfo == 'pfImpactParameterTagInfos':
329  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
330  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
331  process, task)
332  if explicitJTA:
333  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
334  _btagInfo.explicitJTA = cms.bool(explicitJTA)
335  if tightBTagNTkHits:
336  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
337  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
338  _btagInfo.minimumNumberOfHits = cms.int32(8)
339  if btagInfo == 'pfImpactParameterAK8TagInfos':
340  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
341  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
342  process, task)
343  if explicitJTA:
344  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
345  _btagInfo.explicitJTA = cms.bool(explicitJTA)
346  if tightBTagNTkHits:
347  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
348  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
349  _btagInfo.minimumNumberOfHits = cms.int32(8)
350  if btagInfo == 'pfImpactParameterCA15TagInfos':
351  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
352  btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
353  process, task)
354  if explicitJTA:
355  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
356  _btagInfo.explicitJTA = cms.bool(explicitJTA)
357  if tightBTagNTkHits:
358  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
359  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
360  _btagInfo.minimumNumberOfHits = cms.int32(8)
361  if btagInfo == 'pfSecondaryVertexTagInfos':
362  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
363  btag.pfSecondaryVertexTagInfos.clone(
364  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
365  process, task)
366  if tightBTagNTkHits:
367  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
368  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
369  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
370  if btagInfo == 'pfDeepCSVTagInfos':
371  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
372  btag.pfDeepCSVTagInfos.clone(
373  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
374  process, task)
375  if svClustering or fatJets != cms.InputTag(''):
376  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
377  if btagInfo == 'pfDeepCSVNegativeTagInfos':
378  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
379  btag.pfDeepCSVNegativeTagInfos.clone(
380  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
381  process, task)
382  if svClustering or fatJets != cms.InputTag(''):
383  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
384  if btagInfo == 'pfDeepCSVPositiveTagInfos':
385  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
386  btag.pfDeepCSVPositiveTagInfos.clone(
387  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
388  process, task)
389  if svClustering or fatJets != cms.InputTag(''):
390  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
391  if btagInfo == 'pfDeepCMVATagInfos':
392  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
393  btag.pfDeepCMVATagInfos.clone(
394  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
395  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
396  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
397  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
398  process, task)
399  if svClustering or fatJets != cms.InputTag(''):
400  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
401  if btagInfo == 'pfDeepCMVANegativeTagInfos':
402  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
403  btag.pfDeepCMVATagInfos.clone(
404  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
405  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
406  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
407  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
408  process, task)
409  if svClustering or fatJets != cms.InputTag(''):
410  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
411  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
412  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
413  btag.pfDeepCMVATagInfos.clone(
414  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
415  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
416  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
417  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
418  process, task)
419  if svClustering or fatJets != cms.InputTag(''):
420  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
421  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
422  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
423  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
424  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
425  extSVCollection=svSource),
426  process, task)
427  if svClustering or fatJets != cms.InputTag(''):
428  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
429  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
430  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
431  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
432  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
433  extSVCollection=svSource),
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 == 'pfBoostedDoubleSVAK8TagInfos':
438  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
439  btag.pfBoostedDoubleSVAK8TagInfos.clone(
440  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
441  process, task)
442  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
443  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
444  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
445  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
446  extSVCollection=svSource),
447  process, task)
448  if svClustering or fatJets != cms.InputTag(''):
449  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
450  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
451  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
452  btag.pfBoostedDoubleSVCA15TagInfos.clone(
453  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
454  process, task)
455  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
456  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
457  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
458  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
459  extSVCollection=svSourceCvsL),
460  process, task)
461  if svClustering or fatJets != cms.InputTag(''):
462  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
463  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
464  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
465  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
466  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
467  extSVCollection=svSourceCvsL),
468  process, task)
469  if svClustering or fatJets != cms.InputTag(''):
470  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
471  if btagInfo == 'pfGhostTrackVertexTagInfos':
472  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
473  btag.pfGhostTrackVertexTagInfos.clone(
474  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
475  process, task)
476  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
477  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
478  btag.pfSecondaryVertexNegativeTagInfos.clone(
479  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
480  process, task)
481  if tightBTagNTkHits:
482  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
483  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
484  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
485  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
486  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
487  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
488  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
489  extSVCollection=svSource),
490  process, task)
491  if svClustering or fatJets != cms.InputTag(''):
492  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
493  if btagInfo == 'impactParameterTagInfos':
494  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
495  btag.impactParameterTagInfos.clone(
496  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
497  primaryVertex=pvSource),
498  process, task)
499  if btagInfo == 'secondaryVertexTagInfos':
500  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
501  btag.secondaryVertexTagInfos.clone(
502  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
503  process, task)
504  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
505  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
506  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
507  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
508  process, task)
509  if svClustering or fatJets != cms.InputTag(''):
510  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
511  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
512  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
513  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
514  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
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 == 'secondaryVertexNegativeTagInfos':
519  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
520  btag.secondaryVertexNegativeTagInfos.clone(
521  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
522  process, task)
523  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
524  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
525  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
526  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
527  process, task)
528  if svClustering or fatJets != cms.InputTag(''):
529  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
530  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
531  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
532  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
533  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
534  process, task)
535  if svClustering or fatJets != cms.InputTag(''):
536  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
537  if btagInfo == 'softMuonTagInfos':
538  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
539  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
540  process, task)
541  if btagInfo == 'softPFMuonsTagInfos':
542  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
543  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
544  process, task)
545  if btagInfo == 'softPFElectronsTagInfos':
546  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
547  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
548  process, task)
549 
550  if 'DeepFlavourTagInfos' in btagInfo:
551 
552  if btagInfo == 'pfNegativeDeepFlavourTagInfos':
553  deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
554  else:
555  deep_csv_tag_infos = 'pfDeepCSVTagInfos'
556 
557  # use right input tags when running with RECO PF candidates, which actually
558  # depens of wether jets were slimmed or not (check for s/S-limmed in name)
559  if not ('limmed' in jetSource.value()):
560  puppi_value_map = cms.InputTag("puppi")
561  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
562  else:
563  puppi_value_map = cms.InputTag("")
564  vertex_associator = cms.InputTag("")
565  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
566  btag.pfDeepFlavourTagInfos.clone(
567  jets = jetSource,
568  vertices=pvSource,
569  secondary_vertices=svSource,
570  shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
571  puppi_value_map = puppi_value_map,
572  vertex_associator = vertex_associator,
573  ),
574  process, task)
575 
576  acceptedTagInfos.append(btagInfo)
577  elif hasattr(toptag, btagInfo) :
578  acceptedTagInfos.append(btagInfo)
579  else:
580  print ' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo)
581  ## setup all required btagDiscriminators
582  acceptedBtagDiscriminators = list()
583  for discriminator_name in btagDiscriminators :
584  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
585  #print discriminator_name, '-->', btagDiscr
586  if hasattr(btag,btagDiscr):
587  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
588  if hasattr(process, newDiscr):
589  pass
590  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
592  newDiscr,
593  getattr(btag, btagDiscr).clone(
594  tagInfos = cms.VInputTag(
595  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
596  for x in supportedBtagDiscr[discriminator_name][0] ]
597  )
598  ),
599  process,
600  task
601  )
602  elif hasattr(getattr(btag, btagDiscr), 'src'):
604  newDiscr,
605  getattr(btag, btagDiscr).clone(
606  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
607  ),
608  process,
609  task
610  )
611  else:
612  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
613  acceptedBtagDiscriminators.append(discriminator_name)
614  else:
615  print ' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr)
616  #update meta-taggers, if any
617  for meta_tagger in present_meta:
618  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
619  #print discriminator_name, '-->', btagDiscr
620  if hasattr(btag,btagDiscr):
621  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
622  if hasattr(process, newDiscr):
623  pass
624  else:
626  newDiscr,
627  getattr(btag, btagDiscr).clone(),
628  process,
629  task
630  )
631  for dependency in supportedMetaDiscr[meta_tagger]:
632  if ':' in dependency:
633  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
634  else:
635  new_dep = btagPrefix+dependency+labelName+postfix
636  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
637  replace.doIt(getattr(process, newDiscr), newDiscr)
638  acceptedBtagDiscriminators.append(meta_tagger)
639  else:
640  print ' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr)
641 
642  ## replace corresponding tags for pat jet production
643  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
644  patJets.discriminatorSources = cms.VInputTag(*[
645  cms.InputTag(btagPrefix+x+labelName+postfix) \
646  if ':' not in x else \
647  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
648  for x in acceptedBtagDiscriminators
649  ])
650  if len(acceptedBtagDiscriminators) > 0 :
651  patJets.addBTagInfo = True
652  ## if re-running IVF
653  if runIVF:
654  if not tightBTagNTkHits:
655  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices': ## MiniAOD case
656  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
657  else:
658  rerunningIVF()
659  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
660  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
661  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
662  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
663  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
664  if tightBTagNTkHits:
665  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
666  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
667  _temp.minHits = cms.uint32(8)
668  ## MiniAOD case
669  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
670  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
671  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
672  _temp.primaryVertices = pvSource
673  _temp.tracks = pfCandidates
674  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
675  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
676  _temp.primaryVertices = pvSource
677  _temp.tracks = pfCandidates
678  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
679  addToProcessAndTask(svSource.getModuleLabel(),
680  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
681  process, task)
682  if any(i in acceptedTagInfos for i in ivfcTagInfos):
683  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
684  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
685  if tightBTagNTkHits:
686  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
687  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
688  _temp.minHits = cms.uint32(8)
689  ## MiniAOD case
690  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
691  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
692  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
693  _temp.primaryVertices = pvSource
694  _temp.tracks = pfCandidates
695  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
696  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
697  _temp.primaryVertices = pvSource
698  _temp.tracks = pfCandidates
699  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
700  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
701  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
702  process, task)
703  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
704  if not hasattr( process, 'inclusiveVertexing' ):
705  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
706  task.add(process.inclusiveVertexingTask)
707  task.add(process.inclusiveCandidateVertexingTask)
708  task.add(process.inclusiveCandidateVertexingCvsLTask)
709  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
710  if not hasattr( process, 'inclusiveVertexing' ):
711  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
712  task.add(process.inclusiveVertexingTask)
713  task.add(process.inclusiveCandidateVertexingTask)
714  task.add(process.inclusiveCandidateVertexingCvsLTask)
715  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
716  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
717  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
718  task.add(process.inclusiveSecondaryVerticesFiltered)
719  task.add(process.bVertexFilter)
720  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
721  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
722  task.add(process.bToCharmDecayVertexMerged)
723  if 'caTopTagInfos' in acceptedTagInfos :
724  patJets.addTagInfos = True
725  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
726  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
727  task.add(process.caTopTaggersTask)
728 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:27
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:224
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
Definition: helpers.py:42
def rerunningIVF()
Definition: jetTools.py:1755
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:1763
def getPatAlgosToolsTask(process)
Definition: helpers.py:12
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 25 of file jetTools.py.

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

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

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

Definition at line 224 of file jetTools.py.

References setupBTagging().

Referenced by setupBTagging().

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

Definition at line 1739 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

1740  sys.stderr.write("-------------------------------------------------------\n")
1741  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1742  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1743  sys.stderr.write("-------------------------------------------------------\n")
1744  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1745 
def undefinedLabelName(obj)
Definition: jetTools.py:1739
def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 1746 of file jetTools.py.

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

1747  sys.stderr.write("-------------------------------------------------------\n")
1748  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1749  sys.stderr.write(" The supported algorithms are:\n")
1750  for key in supportedJetAlgos.keys():
1751  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1752  sys.stderr.write("-------------------------------------------------------\n")
1753  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1754 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1746

Variable Documentation

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 11 of file jetTools.py.