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

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

Referenced by setupBTagging().

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

Definition at line 1932 of file jetTools.py.

Referenced by setupBTagging().

1933  sys.stderr.write("-------------------------------------------------------------------\n")
1934  sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1935  sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1936  sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1937  sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1938  sys.stderr.write("-------------------------------------------------------------------\n")
1939 
def rerunningIVFMiniAOD()
Definition: jetTools.py:1932
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  # can only run on PAT jets, so the updater needs to be used
630  if 'updated' not in jetSource.value().lower():
631  raise ValueError("Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
632  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
633  btag.pfDeepDoubleXTagInfos.clone(
634  jets = jetSource,
635  vertices=pvSource,
636  secondary_vertices=svSource,
637  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
638  ),
639  process, task)
640 
641  if btagInfo == 'pfHiggsInteractionNetTagInfos':
642  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
643  btag.pfHiggsInteractionNetTagInfos.clone(
644  jets = jetSource,
645  vertices = pvSource,
646  secondary_vertices = svSource,
647  pf_candidates = pfCandidates,
648  ),
649  process, task)
650 
651  if btagInfo == 'pfDeepBoostedJetTagInfos':
652  if pfCandidates.value() == 'packedPFCandidates':
653  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
654  if 'updated' not in jetSource.value().lower():
655  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
656  puppi_value_map = ""
657  vertex_associator = ""
658  elif pfCandidates.value() == 'particleFlow':
659  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
660  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
661  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
662  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
663 # puppi_value_map = "puppi"
664 # vertex_associator = "primaryVertexAssociation:original"
665  else:
666  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
667  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
668  btag.pfDeepBoostedJetTagInfos.clone(
669  jets = jetSource,
670  vertices = pvSource,
671  secondary_vertices = svSource,
672  pf_candidates = pfCandidates,
673  puppi_value_map = puppi_value_map,
674  vertex_associator = vertex_associator,
675  ),
676  process, task)
677 
678  if btagInfo == 'pfParticleNetTagInfos':
679  if pfCandidates.value() == 'packedPFCandidates':
680  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
681  puppi_value_map = ""
682  vertex_associator = ""
683  elif pfCandidates.value() == 'particleFlow':
684  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
685  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
686  puppi_value_map = "puppi"
687  vertex_associator = "primaryVertexAssociation:original"
688  else:
689  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
690  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
691  btag.pfParticleNetTagInfos.clone(
692  jets = jetSource,
693  vertices = pvSource,
694  secondary_vertices = svSource,
695  pf_candidates = pfCandidates,
696  puppi_value_map = puppi_value_map,
697  vertex_associator = vertex_associator,
698  ),
699  process, task)
700 
701  if 'ParticleNetAK4TagInfos' in btagInfo:
702  if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
703  secondary_vertices = btagPrefix + \
704  'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
705  flip_ip_sign = True
706  sip3dSigMax = 10
707  else:
708  secondary_vertices = svSource
709  flip_ip_sign = False
710  sip3dSigMax = -1
711  if pfCandidates.value() == 'packedPFCandidates':
712  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
713  puppi_value_map = ""
714  vertex_associator = ""
715  elif pfCandidates.value() == 'particleFlow':
716  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
717  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
718  puppi_value_map = "puppi"
719  vertex_associator = "primaryVertexAssociation:original"
720  else:
721  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
722  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
723  btag.pfParticleNetAK4TagInfos.clone(
724  jets = jetSource,
725  vertices = pvSource,
726  secondary_vertices = secondary_vertices,
727  pf_candidates = pfCandidates,
728  puppi_value_map = puppi_value_map,
729  vertex_associator = vertex_associator,
730  flip_ip_sign = flip_ip_sign,
731  sip3dSigMax = sip3dSigMax,
732  ),
733  process, task)
734 
735  acceptedTagInfos.append(btagInfo)
736  elif hasattr(toptag, btagInfo) :
737  acceptedTagInfos.append(btagInfo)
738  else:
739  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
740  ## setup all required btagDiscriminators
741  acceptedBtagDiscriminators = list()
742  for discriminator_name in btagDiscriminators :
743  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
744  #print discriminator_name, '-->', btagDiscr
745  if hasattr(btag,btagDiscr):
746  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
747  if hasattr(process, newDiscr):
748  pass
749  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
751  newDiscr,
752  getattr(btag, btagDiscr).clone(
753  tagInfos = cms.VInputTag(
754  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
755  for x in supportedBtagDiscr[discriminator_name][0] ]
756  )
757  ),
758  process,
759  task
760  )
761  elif hasattr(getattr(btag, btagDiscr), 'src'):
763  newDiscr,
764  getattr(btag, btagDiscr).clone(
765  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
766  ),
767  process,
768  task
769  )
770  else:
771  raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
772  acceptedBtagDiscriminators.append(discriminator_name)
773  else:
774  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
775  #update meta-taggers, if any
776  for meta_tagger in present_meta:
777  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
778  #print discriminator_name, '-->', btagDiscr
779  if hasattr(btag,btagDiscr):
780  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
781  if hasattr(process, newDiscr):
782  pass
783  else:
785  newDiscr,
786  getattr(btag, btagDiscr).clone(),
787  process,
788  task
789  )
790  for dependency in supportedMetaDiscr[meta_tagger]:
791  if ':' in dependency:
792  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
793  else:
794  new_dep = btagPrefix+dependency+labelName+postfix
795  replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
796  replace.doIt(getattr(process, newDiscr), newDiscr)
797  acceptedBtagDiscriminators.append(meta_tagger)
798  else:
799  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
800 
801  ## replace corresponding tags for pat jet production
802  patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
803  patJets.discriminatorSources = cms.VInputTag(*[
804  cms.InputTag(btagPrefix+x+labelName+postfix) \
805  if ':' not in x else \
806  cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
807  for x in acceptedBtagDiscriminators
808  ])
809  if len(acceptedBtagDiscriminators) > 0 :
810  patJets.addBTagInfo = True
811  ## if re-running IVF
812  if runIVF:
813  if not tightBTagNTkHits:
814  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices': ## MiniAOD case
815  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
816  else:
817  rerunningIVF()
818  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
819  ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
820  if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
821  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
822  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
823  if tightBTagNTkHits:
824  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
825  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
826  _temp.minHits = cms.uint32(8)
827  ## MiniAOD case
828  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
829  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
830  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
831  _temp.primaryVertices = pvSource
832  _temp.tracks = pfCandidates
833  if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
834  _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
835  _temp.primaryVertices = pvSource
836  _temp.tracks = pfCandidates
837  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
838  addToProcessAndTask(svSource.getModuleLabel(),
839  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
840  process, task)
841  if any(i in acceptedTagInfos for i in ivfcTagInfos):
842  if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
843  loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
844  if tightBTagNTkHits:
845  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
846  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
847  _temp.minHits = cms.uint32(8)
848  ## MiniAOD case
849  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
850  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
851  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
852  _temp.primaryVertices = pvSource
853  _temp.tracks = pfCandidates
854  if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
855  _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
856  _temp.primaryVertices = pvSource
857  _temp.tracks = pfCandidates
858  if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
859  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
860  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
861  process, task)
862  if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
863  if not hasattr( process, 'inclusiveVertexing' ):
864  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
865  task.add(process.inclusiveVertexingTask)
866  task.add(process.inclusiveCandidateVertexingTask)
867  task.add(process.inclusiveCandidateVertexingCvsLTask)
868  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
869  if not hasattr( process, 'inclusiveVertexing' ):
870  process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
871  task.add(process.inclusiveVertexingTask)
872  task.add(process.inclusiveCandidateVertexingTask)
873  task.add(process.inclusiveCandidateVertexingCvsLTask)
874  if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
875  if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
876  process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
877  task.add(process.inclusiveSecondaryVerticesFiltered)
878  task.add(process.bVertexFilter)
879  if not hasattr( process, 'bToCharmDecayVertexMerged' ):
880  process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
881  task.add(process.bToCharmDecayVertexMerged)
882  if 'caTopTagInfos' in acceptedTagInfos :
883  patJets.addTagInfos = True
884  if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
885  process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
886  task.add(process.caTopTaggersTask)
887 
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:1924
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:1932
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 1908 of file jetTools.py.

Referenced by jetTools.AddJetCollection.toolCode().

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

Definition at line 1915 of file jetTools.py.

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

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

Variable Documentation

jetTools.supportedJetAlgos

dictionary with supported jet clustering algorithms

Definition at line 12 of file jetTools.py.