CMS 3D CMS Logo

Classes | Functions | Variables
jetTools Namespace Reference

Classes

class  AddJetCollection
 
class  AddJetID
 
class  SetTagInfos
 
class  SwitchJetCollection
 
class  UpdateJetCollection
 

Functions

def checkJetCorrectionsFormat (jetCorrections)
 
def deprecatedOptionOutputModule (obj)
 
def jetAlgo (algo)
 
def rerunningIVF ()
 
def rerunningIVFMiniAOD ()
 
def setupBTagging (process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets, algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix)
 
def setupJetCorrections (process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix)
 
def setupSVClustering (btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
 
def undefinedLabelName (obj)
 
def unsupportedJetAlgorithm (obj)
 

Variables

 supportedJetAlgos
 dictionary with supported jet clustering algorithms More...
 

Function Documentation

def jetTools.checkJetCorrectionsFormat (   jetCorrections)

Definition at line 18 of file jetTools.py.

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

18 def checkJetCorrectionsFormat(jetCorrections):
19  ## check for the correct format
20  if not isinstance(jetCorrections, type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL'))):
21  raise ValueError("In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
22  'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \
23  corrections.")
24 
25 
def checkJetCorrectionsFormat(jetCorrections)
Definition: jetTools.py:18
def jetTools.deprecatedOptionOutputModule (   obj)

Definition at line 1846 of file jetTools.py.

1847  sys.stderr.write("-------------------------------------------------------\n")
1848  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1849  sys.stderr.write(" anymore by:\n")
1850  sys.stderr.write(" " + obj._label + "\n")
1851  sys.stderr.write(" please use 'outputModules' now and specify the\n")
1852  sys.stderr.write(" names of all needed OutModules in there\n")
1853  sys.stderr.write(" (default: ['out'])\n")
1854  sys.stderr.write("-------------------------------------------------------\n")
1855  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1856 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1846
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 1873 of file jetTools.py.

Referenced by setupBTagging().

1874  sys.stderr.write("-------------------------------------------------------------------\n")
1875  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1876  sys.stderr.write(" already produced by the standard reconstruction. This\n")
1877  sys.stderr.write(" option is not enabled by default so please use it only if\n")
1878  sys.stderr.write(" you know what you are doing.\n")
1879  sys.stderr.write("-------------------------------------------------------------------\n")
1880 
def rerunningIVF()
Definition: jetTools.py:1873
def jetTools.rerunningIVFMiniAOD ( )

Definition at line 1881 of file jetTools.py.

Referenced by setupBTagging().

1882  sys.stderr.write("-------------------------------------------------------------------\n")
1883  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1884  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1885  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1886  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1887  sys.stderr.write("-------------------------------------------------------------------\n")
1888 
def rerunningIVFMiniAOD()
Definition: jetTools.py:1881
def jetTools.setupBTagging (   process,
  jetSource,
  pfCandidates,
  explicitJTA,
  pvSource,
  svSource,
  elSource,
  muSource,
  runIVF,
  tightBTagNTkHits,
  loadStdRecoBTag,
  svClustering,
  fatJets,
  groomedFatJets,
  algo,
  rParam,
  btagDiscriminators,
  btagInfos,
  patJets,
  labelName,
  btagPrefix,
  postfix 
)

Definition at line 237 of file jetTools.py.

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

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

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

Definition at line 26 of file jetTools.py.

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

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

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

Definition at line 225 of file jetTools.py.

References setupBTagging().

Referenced by setupBTagging().

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

Definition at line 1857 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

1858  sys.stderr.write("-------------------------------------------------------\n")
1859  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1860  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1861  sys.stderr.write("-------------------------------------------------------\n")
1862  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1863 
def undefinedLabelName(obj)
Definition: jetTools.py:1857
def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 1864 of file jetTools.py.

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

1865  sys.stderr.write("-------------------------------------------------------\n")
1866  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1867  sys.stderr.write(" The supported algorithms are:\n")
1868  for key in supportedJetAlgos.keys():
1869  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1870  sys.stderr.write("-------------------------------------------------------\n")
1871  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1872 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1864

Variable Documentation

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 12 of file jetTools.py.