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

1786  sys.stderr.write("-------------------------------------------------------\n")
1787  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1788  sys.stderr.write(" anymore by:\n")
1789  sys.stderr.write(" " + obj._label + "\n")
1790  sys.stderr.write(" please use 'outputModules' now and specify the\n")
1791  sys.stderr.write(" names of all needed OutModules in there\n")
1792  sys.stderr.write(" (default: ['out'])\n")
1793  sys.stderr.write("-------------------------------------------------------\n")
1794  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1795 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1785
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 1812 of file jetTools.py.

Referenced by setupBTagging().

1813  sys.stderr.write("-------------------------------------------------------------------\n")
1814  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1815  sys.stderr.write(" already produced by the standard reconstruction. This\n")
1816  sys.stderr.write(" option is not enabled by default so please use it only if\n")
1817  sys.stderr.write(" you know what you are doing.\n")
1818  sys.stderr.write("-------------------------------------------------------------------\n")
1819 
def rerunningIVF()
Definition: jetTools.py:1812
def jetTools.rerunningIVFMiniAOD ( )

Definition at line 1820 of file jetTools.py.

Referenced by setupBTagging().

1821  sys.stderr.write("-------------------------------------------------------------------\n")
1822  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1823  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1824  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1825  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1826  sys.stderr.write("-------------------------------------------------------------------\n")
1827 
def rerunningIVFMiniAOD()
Definition: jetTools.py:1820
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 
326  runNegativeVertexing = False
327  runNegativeCvsLVertexing = False
328  for btagInfo in requiredTagInfos:
329  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos' or btagInfo == 'pfNegativeDeepFlavourTagInfos':
330  runNegativeVertexing = True
331  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
332  runNegativeCvsLVertexing = True
333 
334  if runNegativeVertexing or runNegativeCvsLVertexing:
335  import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff as NegVertex
336 
337  if runNegativeVertexing:
338  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix,
339  NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
340  process, task)
341  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix,
342  NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
343  process, task)
344  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix,
345  NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix)
346  ,primaryVertices = pvSource
347  ,tracks=pfCandidates),
348  process, task)
349  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
350  NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix)),
351  process, task)
352 
353  if runNegativeCvsLVertexing:
354  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
355  NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
356  process, task)
357  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix,
358  NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
359  process, task)
360  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix,
361  NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix)
362  ,primaryVertices = pvSource
363  ,tracks=pfCandidates),
364  process, task)
365  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
366  NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
367  process, task)
368 
369 
370  acceptedTagInfos = list()
371  for btagInfo in requiredTagInfos:
372  if hasattr(btag,btagInfo):
373  if btagInfo == 'pfImpactParameterTagInfos':
374  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
375  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
376  process, task)
377  if explicitJTA:
378  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
379  _btagInfo.explicitJTA = cms.bool(explicitJTA)
380  if tightBTagNTkHits:
381  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
382  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
383  _btagInfo.minimumNumberOfHits = cms.int32(8)
384  if btagInfo == 'pfImpactParameterAK8TagInfos':
385  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
386  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
387  process, task)
388  if explicitJTA:
389  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
390  _btagInfo.explicitJTA = cms.bool(explicitJTA)
391  if tightBTagNTkHits:
392  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
393  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
394  _btagInfo.minimumNumberOfHits = cms.int32(8)
395  if btagInfo == 'pfImpactParameterCA15TagInfos':
396  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
397  btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
398  process, task)
399  if explicitJTA:
400  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
401  _btagInfo.explicitJTA = cms.bool(explicitJTA)
402  if tightBTagNTkHits:
403  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
404  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
405  _btagInfo.minimumNumberOfHits = cms.int32(8)
406  if btagInfo == 'pfSecondaryVertexTagInfos':
407  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
408  btag.pfSecondaryVertexTagInfos.clone(
409  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
410  process, task)
411  if tightBTagNTkHits:
412  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
413  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
414  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
415  if btagInfo == 'pfDeepCSVTagInfos':
416  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
417  btag.pfDeepCSVTagInfos.clone(
418  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
419  process, task)
420  if svClustering or fatJets != cms.InputTag(''):
421  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
422  if btagInfo == 'pfDeepCSVNegativeTagInfos':
423  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
424  btag.pfDeepCSVNegativeTagInfos.clone(
425  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
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 == 'pfDeepCSVPositiveTagInfos':
430  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
431  btag.pfDeepCSVPositiveTagInfos.clone(
432  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
433  process, task)
434  if svClustering or fatJets != cms.InputTag(''):
435  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
436  if btagInfo == 'pfDeepCMVATagInfos':
437  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
438  btag.pfDeepCMVATagInfos.clone(
439  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
440  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
441  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
442  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
443  process, task)
444  if svClustering or fatJets != cms.InputTag(''):
445  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
446  if btagInfo == 'pfDeepCMVANegativeTagInfos':
447  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
448  btag.pfDeepCMVATagInfos.clone(
449  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
450  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
451  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
452  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
453  process, task)
454  if svClustering or fatJets != cms.InputTag(''):
455  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
456  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
457  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
458  btag.pfDeepCMVATagInfos.clone(
459  deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
460  ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
461  muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
462  elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
463  process, task)
464  if svClustering or fatJets != cms.InputTag(''):
465  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
466  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
467  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
468  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
469  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
470  extSVCollection=svSource),
471  process, task)
472  if svClustering or fatJets != cms.InputTag(''):
473  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
474  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
475  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
476  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
477  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
478  extSVCollection=svSource),
479  process, task)
480  if svClustering or fatJets != cms.InputTag(''):
481  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
482  if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
483  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
484  btag.pfBoostedDoubleSVAK8TagInfos.clone(
485  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
486  process, task)
487  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
488  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
489  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
490  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
491  extSVCollection=svSource),
492  process, task)
493  if svClustering or fatJets != cms.InputTag(''):
494  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
495  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
496  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
497  btag.pfBoostedDoubleSVCA15TagInfos.clone(
498  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
499  process, task)
500  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
501  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
502  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
503  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
504  extSVCollection=svSourceCvsL),
505  process, task)
506  if svClustering or fatJets != cms.InputTag(''):
507  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
508  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
509  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
510  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
511  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
512  extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
513  process, task)
514  if svClustering or fatJets != cms.InputTag(''):
515  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
516  if btagInfo == 'pfGhostTrackVertexTagInfos':
517  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
518  btag.pfGhostTrackVertexTagInfos.clone(
519  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
520  process, task)
521  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
522  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
523  btag.pfSecondaryVertexNegativeTagInfos.clone(
524  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
525  process, task)
526  if tightBTagNTkHits:
527  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
528  _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
529  _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
530  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
531  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
532  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
533  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
534  extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
535  process, task)
536  if svClustering or fatJets != cms.InputTag(''):
537  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
538  if btagInfo == 'impactParameterTagInfos':
539  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
540  btag.impactParameterTagInfos.clone(
541  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
542  primaryVertex=pvSource),
543  process, task)
544  if btagInfo == 'secondaryVertexTagInfos':
545  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
546  btag.secondaryVertexTagInfos.clone(
547  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
548  process, task)
549  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
550  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
551  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
552  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
553  process, task)
554  if svClustering or fatJets != cms.InputTag(''):
555  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
556  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
557  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
558  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
559  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
560  process, task)
561  if svClustering or fatJets != cms.InputTag(''):
562  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
563  if btagInfo == 'secondaryVertexNegativeTagInfos':
564  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
565  btag.secondaryVertexNegativeTagInfos.clone(
566  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
567  process, task)
568  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
569  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
570  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
571  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
572  process, task)
573  if svClustering or fatJets != cms.InputTag(''):
574  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
575  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
576  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
577  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
578  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
579  process, task)
580  if svClustering or fatJets != cms.InputTag(''):
581  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
582  if btagInfo == 'softMuonTagInfos':
583  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
584  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
585  process, task)
586  if btagInfo == 'softPFMuonsTagInfos':
587  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
588  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
589  process, task)
590  if btagInfo == 'softPFElectronsTagInfos':
591  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
592  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
593  process, task)
594 
595  if 'DeepFlavourTagInfos' in btagInfo:
596  svUsed = svSource
597  if btagInfo == 'pfNegativeDeepFlavourTagInfos':
598  deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
599  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
600  flip = True
601  else:
602  deep_csv_tag_infos = 'pfDeepCSVTagInfos'
603  flip = False
604  # use right input tags when running with RECO PF candidates, which actually
605  # depens of wether jets were slimmed or not (check for s/S-limmed in name)
606  if not ('limmed' in jetSource.value()):
607  puppi_value_map = cms.InputTag("puppi")
608  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
609  else:
610  puppi_value_map = cms.InputTag("")
611  vertex_associator = cms.InputTag("")
612  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
613  btag.pfDeepFlavourTagInfos.clone(
614  jets = jetSource,
615  vertices=pvSource,
616  secondary_vertices=svUsed,
617  shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
618  puppi_value_map = puppi_value_map,
619  vertex_associator = vertex_associator,
620  ),
621  process, task)
622 
623  if btagInfo == 'pfDeepDoubleBTagInfos':
624  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
625  btag.pfDeepDoubleBTagInfos.clone(
626  jets = jetSource,
627  vertices=pvSource,
628  secondary_vertices=svSource,
629  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
630  ),
631  process, task)
632 
633  acceptedTagInfos.append(btagInfo)
634  elif hasattr(toptag, btagInfo) :
635  acceptedTagInfos.append(btagInfo)
636  else:
637  print ' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo)
638  ## setup all required btagDiscriminators
639  acceptedBtagDiscriminators = list()
640  for discriminator_name in btagDiscriminators :
641  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
642  #print discriminator_name, '-->', btagDiscr
643  if hasattr(btag,btagDiscr):
644  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
645  if hasattr(process, newDiscr):
646  pass
647  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
649  newDiscr,
650  getattr(btag, btagDiscr).clone(
651  tagInfos = cms.VInputTag(
652  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
653  for x in supportedBtagDiscr[discriminator_name][0] ]
654  )
655  ),
656  process,
657  task
658  )
659  elif hasattr(getattr(btag, btagDiscr), 'src'):
661  newDiscr,
662  getattr(btag, btagDiscr).clone(
663  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
664  ),
665  process,
666  task
667  )
668  else:
669  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
670  acceptedBtagDiscriminators.append(discriminator_name)
671  else:
672  print ' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr)
673  #update meta-taggers, if any
674  for meta_tagger in present_meta:
675  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
676  #print discriminator_name, '-->', btagDiscr
677  if hasattr(btag,btagDiscr):
678  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
679  if hasattr(process, newDiscr):
680  pass
681  else:
683  newDiscr,
684  getattr(btag, btagDiscr).clone(),
685  process,
686  task
687  )
688  for dependency in supportedMetaDiscr[meta_tagger]:
689  if ':' in dependency:
690  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
691  else:
692  new_dep = btagPrefix+dependency+labelName+postfix
693  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
694  replace.doIt(getattr(process, newDiscr), newDiscr)
695  acceptedBtagDiscriminators.append(meta_tagger)
696  else:
697  print ' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr)
698 
699  ## replace corresponding tags for pat jet production
700  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
701  patJets.discriminatorSources = cms.VInputTag(*[
702  cms.InputTag(btagPrefix+x+labelName+postfix) \
703  if ':' not in x else \
704  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
705  for x in acceptedBtagDiscriminators
706  ])
707  if len(acceptedBtagDiscriminators) > 0 :
708  patJets.addBTagInfo = True
709  ## if re-running IVF
710  if runIVF:
711  if not tightBTagNTkHits:
712  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices': ## MiniAOD case
713  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
714  else:
715  rerunningIVF()
716  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
717  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
718  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
719  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
720  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
721  if tightBTagNTkHits:
722  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
723  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
724  _temp.minHits = cms.uint32(8)
725  ## MiniAOD case
726  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
727  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
728  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
729  _temp.primaryVertices = pvSource
730  _temp.tracks = pfCandidates
731  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
732  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
733  _temp.primaryVertices = pvSource
734  _temp.tracks = pfCandidates
735  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
736  addToProcessAndTask(svSource.getModuleLabel(),
737  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
738  process, task)
739  if any(i in acceptedTagInfos for i in ivfcTagInfos):
740  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
741  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
742  if tightBTagNTkHits:
743  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
744  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
745  _temp.minHits = cms.uint32(8)
746  ## MiniAOD case
747  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
748  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
749  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
750  _temp.primaryVertices = pvSource
751  _temp.tracks = pfCandidates
752  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
753  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
754  _temp.primaryVertices = pvSource
755  _temp.tracks = pfCandidates
756  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
757  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
758  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
759  process, task)
760  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
761  if not hasattr( process, 'inclusiveVertexing' ):
762  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
763  task.add(process.inclusiveVertexingTask)
764  task.add(process.inclusiveCandidateVertexingTask)
765  task.add(process.inclusiveCandidateVertexingCvsLTask)
766  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
767  if not hasattr( process, 'inclusiveVertexing' ):
768  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
769  task.add(process.inclusiveVertexingTask)
770  task.add(process.inclusiveCandidateVertexingTask)
771  task.add(process.inclusiveCandidateVertexingCvsLTask)
772  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
773  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
774  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
775  task.add(process.inclusiveSecondaryVerticesFiltered)
776  task.add(process.bVertexFilter)
777  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
778  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
779  task.add(process.bToCharmDecayVertexMerged)
780  if 'caTopTagInfos' in acceptedTagInfos :
781  patJets.addTagInfos = True
782  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
783  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
784  task.add(process.caTopTaggersTask)
785 
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:1812
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:1820
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 1796 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

1797  sys.stderr.write("-------------------------------------------------------\n")
1798  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1799  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1800  sys.stderr.write("-------------------------------------------------------\n")
1801  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1802 
def undefinedLabelName(obj)
Definition: jetTools.py:1796
def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 1803 of file jetTools.py.

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

1804  sys.stderr.write("-------------------------------------------------------\n")
1805  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1806  sys.stderr.write(" The supported algorithms are:\n")
1807  for key in supportedJetAlgos.keys():
1808  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1809  sys.stderr.write("-------------------------------------------------------\n")
1810  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1811 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1803

Variable Documentation

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 11 of file jetTools.py.