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

1895  sys.stderr.write("-------------------------------------------------------\n")
1896  sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1897  sys.stderr.write(" anymore by:\n")
1898  sys.stderr.write(" " + obj._label + "\n")
1899  sys.stderr.write(" please use 'outputModules' now and specify the\n")
1900  sys.stderr.write(" names of all needed OutModules in there\n")
1901  sys.stderr.write(" (default: ['out'])\n")
1902  sys.stderr.write("-------------------------------------------------------\n")
1903  raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1904 
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1894
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 1921 of file jetTools.py.

Referenced by setupBTagging().

1922  sys.stderr.write("-------------------------------------------------------------------\n")
1923  sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1924  sys.stderr.write(" already produced by the standard reconstruction. This\n")
1925  sys.stderr.write(" option is not enabled by default so please use it only if\n")
1926  sys.stderr.write(" you know what you are doing.\n")
1927  sys.stderr.write("-------------------------------------------------------------------\n")
1928 
def rerunningIVF()
Definition: jetTools.py:1921
def jetTools.rerunningIVFMiniAOD ( )

Definition at line 1929 of file jetTools.py.

Referenced by setupBTagging().

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

Referenced by jetTools.AddJetCollection.toolCode().

1906  sys.stderr.write("-------------------------------------------------------\n")
1907  sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1908  sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1909  sys.stderr.write("-------------------------------------------------------\n")
1910  raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1911 
def undefinedLabelName(obj)
Definition: jetTools.py:1905
def jetTools.unsupportedJetAlgorithm (   obj)

Definition at line 1912 of file jetTools.py.

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

1913  sys.stderr.write("-------------------------------------------------------\n")
1914  sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1915  sys.stderr.write(" The supported algorithms are:\n")
1916  for key in supportedJetAlgos.keys():
1917  sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1918  sys.stderr.write("-------------------------------------------------------\n")
1919  raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1920 
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1912

Variable Documentation

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 12 of file jetTools.py.