238 def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
239 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
244 discriminators = set(btagDiscriminators)
245 present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
246 discriminators -= present_metaSet
247 for meta_tagger
in present_metaSet:
248 for src
in supportedMetaDiscr[meta_tagger]:
249 discriminators.add(src)
250 present_meta = sorted(present_metaSet)
251 btagDiscriminators = sorted(discriminators)
255 requiredTagInfos = list(btagInfos)
256 for btagDiscr
in btagDiscriminators :
257 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
258 for requiredTagInfo
in tagInfoList :
259 tagInfoCovered =
False
260 for tagInfo
in requiredTagInfos :
261 if requiredTagInfo == tagInfo :
262 tagInfoCovered =
True
264 if not tagInfoCovered :
265 requiredTagInfos.append(requiredTagInfo)
267 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
269 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
270 task.add(process.impactParameterTask)
271 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
272 task.add(process.secondaryVertexTask)
273 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
274 task.add(process.softLeptonTask)
275 process.load(
"RecoBTag.Combined.combinedMVA_cff")
276 task.add(process.combinedMVATask)
277 process.load(
"RecoBTag.CTagging.cTagging_cff")
278 task.add(process.cTaggingTask)
280 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
281 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
282 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
283 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
284 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
286 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
290 sys.stderr.write(
"-------------------------------------------------------------------\n")
291 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
292 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
293 sys.stderr.write(
"-------------------------------------------------------------------\n")
295 sys.stderr.write(
"-------------------------------------------------------------------\n")
296 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
297 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
298 sys.stderr.write(
" avoid unintentional modifications to the default\n")
299 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
300 sys.stderr.write(
"-------------------------------------------------------------------\n")
304 svSourceCvsL = copy.deepcopy(svSource)
305 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
308 runIVFforCTagOnly =
False
309 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
311 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
312 runIVFforCTagOnly =
True
314 sys.stderr.write(
"-------------------------------------------------------------------\n")
315 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
316 sys.stderr.write(
" vertices will be remade.\n")
317 sys.stderr.write(
"-------------------------------------------------------------------\n")
319 if runIVF
and btagPrefix !=
'':
320 if runIVFforCTagOnly:
321 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
323 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
324 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
330 runNegativeVertexing =
False
331 runNegativeCvsLVertexing =
False
332 for btagInfo
in requiredTagInfos:
334 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
335 'pfNegativeDeepFlavourTagInfos',
336 'pfNegativeParticleNetAK4TagInfos',
338 runNegativeVertexing =
True
339 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
340 runNegativeCvsLVertexing =
True
342 if runNegativeVertexing
or runNegativeCvsLVertexing:
343 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
345 if runNegativeVertexing:
347 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
350 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
353 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
354 ,primaryVertices = pvSource
355 ,tracks=pfCandidates),
357 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
358 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
361 if runNegativeCvsLVertexing:
362 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
363 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
366 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
369 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
370 ,primaryVertices = pvSource
371 ,tracks=pfCandidates),
373 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
374 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
378 acceptedTagInfos = list()
379 for btagInfo
in requiredTagInfos:
380 if hasattr(btag,btagInfo):
381 if btagInfo ==
'pfImpactParameterTagInfos':
383 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
386 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
387 _btagInfo.explicitJTA = cms.bool(explicitJTA)
389 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
390 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
391 _btagInfo.minimumNumberOfHits = cms.int32(8)
392 if btagInfo ==
'pfImpactParameterAK8TagInfos':
394 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
397 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
398 _btagInfo.explicitJTA = cms.bool(explicitJTA)
400 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
401 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
402 _btagInfo.minimumNumberOfHits = cms.int32(8)
403 if btagInfo ==
'pfImpactParameterCA15TagInfos':
405 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
408 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
409 _btagInfo.explicitJTA = cms.bool(explicitJTA)
411 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
412 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
413 _btagInfo.minimumNumberOfHits = cms.int32(8)
414 if btagInfo ==
'pfSecondaryVertexTagInfos':
416 btag.pfSecondaryVertexTagInfos.clone(
417 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
420 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
421 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
422 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
423 if btagInfo ==
'pfDeepCSVTagInfos':
425 btag.pfDeepCSVTagInfos.clone(
426 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
428 if svClustering
or fatJets != cms.InputTag(
''):
429 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
430 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
432 btag.pfDeepCSVNegativeTagInfos.clone(
433 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
435 if svClustering
or fatJets != cms.InputTag(
''):
436 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
437 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
439 btag.pfDeepCSVPositiveTagInfos.clone(
440 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
442 if svClustering
or fatJets != cms.InputTag(
''):
443 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
444 if btagInfo ==
'pfDeepCMVATagInfos':
446 btag.pfDeepCMVATagInfos.clone(
447 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
448 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
449 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
450 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
452 if svClustering
or fatJets != cms.InputTag(
''):
453 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
454 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
456 btag.pfDeepCMVATagInfos.clone(
457 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
458 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
459 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
460 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
462 if svClustering
or fatJets != cms.InputTag(
''):
463 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
464 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
466 btag.pfDeepCMVATagInfos.clone(
467 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
468 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
469 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
470 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
472 if svClustering
or fatJets != cms.InputTag(
''):
473 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
474 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
476 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
477 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
478 extSVCollection=svSource),
480 if svClustering
or fatJets != cms.InputTag(
''):
481 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
482 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
484 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
485 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
486 extSVCollection=svSource),
488 if svClustering
or fatJets != cms.InputTag(
''):
489 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
490 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
492 btag.pfBoostedDoubleSVAK8TagInfos.clone(
493 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
495 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
497 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
498 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
499 extSVCollection=svSource),
501 if svClustering
or fatJets != cms.InputTag(
''):
502 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
503 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
505 btag.pfBoostedDoubleSVCA15TagInfos.clone(
506 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
508 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
510 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
511 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
512 extSVCollection=svSourceCvsL),
514 if svClustering
or fatJets != cms.InputTag(
''):
515 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
516 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
518 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
519 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
520 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
522 if svClustering
or fatJets != cms.InputTag(
''):
523 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
524 if btagInfo ==
'pfGhostTrackVertexTagInfos':
526 btag.pfGhostTrackVertexTagInfos.clone(
527 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
529 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
531 btag.pfSecondaryVertexNegativeTagInfos.clone(
532 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
535 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
536 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
537 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
538 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
540 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
541 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
542 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
544 if svClustering
or fatJets != cms.InputTag(
''):
545 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
546 if btagInfo ==
'impactParameterTagInfos':
548 btag.impactParameterTagInfos.clone(
549 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
550 primaryVertex=pvSource),
552 if btagInfo ==
'secondaryVertexTagInfos':
554 btag.secondaryVertexTagInfos.clone(
555 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
557 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
559 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
560 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
562 if svClustering
or fatJets != cms.InputTag(
''):
563 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
564 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
566 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
567 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
569 if svClustering
or fatJets != cms.InputTag(
''):
570 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
571 if btagInfo ==
'secondaryVertexNegativeTagInfos':
573 btag.secondaryVertexNegativeTagInfos.clone(
574 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
576 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
578 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
579 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
581 if svClustering
or fatJets != cms.InputTag(
''):
582 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
583 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
585 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
586 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
588 if svClustering
or fatJets != cms.InputTag(
''):
589 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
590 if btagInfo ==
'softMuonTagInfos':
592 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
594 if btagInfo ==
'softPFMuonsTagInfos':
596 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
598 if btagInfo ==
'softPFElectronsTagInfos':
600 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
602 if btagInfo ==
'pixelClusterTagInfos':
604 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
607 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
608 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
609 if pfCandidates.value() ==
'packedPFCandidates':
610 _btagInfo.weights = cms.InputTag(
"packedpuppi")
611 if not hasattr(process,
"packedpuppi"):
614 useExistingWeights =
True,
615 candName =
'packedPFCandidates',
616 vertexName =
'offlineSlimmedPrimaryVertices') , process, task)
618 _btagInfo.weights = cms.InputTag(
"puppi")
620 if 'DeepFlavourTagInfos' in btagInfo:
622 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
623 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos'
624 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
627 deep_csv_tag_infos =
'pfDeepCSVTagInfos'
631 if not (
'limmed' in jetSource.value()):
632 puppi_value_map = cms.InputTag(
"puppi")
633 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
635 puppi_value_map = cms.InputTag(
"")
636 vertex_associator = cms.InputTag(
"")
638 btag.pfDeepFlavourTagInfos.clone(
641 secondary_vertices=svUsed,
642 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
643 puppi_value_map = puppi_value_map,
644 vertex_associator = vertex_associator,
648 if btagInfo ==
'pfDeepDoubleXTagInfos':
650 btag.pfDeepDoubleXTagInfos.clone(
653 secondary_vertices=svSource,
654 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
658 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
660 btag.pfHiggsInteractionNetTagInfos.clone(
663 secondary_vertices = svSource,
664 pf_candidates = pfCandidates,
668 if btagInfo ==
'pfDeepBoostedJetTagInfos':
669 if pfCandidates.value() ==
'packedPFCandidates':
671 if 'updated' not in jetSource.value().lower():
672 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
674 vertex_associator =
""
675 elif pfCandidates.value() ==
'particleFlow':
676 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
683 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
685 btag.pfDeepBoostedJetTagInfos.clone(
688 secondary_vertices = svSource,
689 pf_candidates = pfCandidates,
690 puppi_value_map = puppi_value_map,
691 vertex_associator = vertex_associator,
695 if btagInfo ==
'pfParticleNetTagInfos':
696 if pfCandidates.value() ==
'packedPFCandidates':
699 vertex_associator =
""
700 elif pfCandidates.value() ==
'particleFlow':
701 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
703 puppi_value_map =
"puppi"
704 vertex_associator =
"primaryVertexAssociation:original"
706 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
708 btag.pfParticleNetTagInfos.clone(
711 secondary_vertices = svSource,
712 pf_candidates = pfCandidates,
713 puppi_value_map = puppi_value_map,
714 vertex_associator = vertex_associator,
718 if 'ParticleNetAK4TagInfos' in btagInfo:
719 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
720 secondary_vertices = btagPrefix + \
721 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
725 secondary_vertices = svSource
728 if pfCandidates.value() ==
'packedPFCandidates':
731 vertex_associator =
""
732 elif pfCandidates.value() ==
'particleFlow':
733 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
735 puppi_value_map =
"puppi"
736 vertex_associator =
"primaryVertexAssociation:original"
738 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
740 btag.pfParticleNetAK4TagInfos.clone(
743 secondary_vertices = secondary_vertices,
744 pf_candidates = pfCandidates,
745 puppi_value_map = puppi_value_map,
746 vertex_associator = vertex_associator,
747 flip_ip_sign = flip_ip_sign,
748 sip3dSigMax = sip3dSigMax,
752 acceptedTagInfos.append(btagInfo)
753 elif hasattr(toptag, btagInfo) :
754 acceptedTagInfos.append(btagInfo)
756 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
758 acceptedBtagDiscriminators = list()
759 for discriminator_name
in btagDiscriminators :
760 btagDiscr = discriminator_name.split(
':')[0]
762 if hasattr(btag,btagDiscr):
763 newDiscr = btagPrefix+btagDiscr+labelName+postfix
764 if hasattr(process, newDiscr):
766 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
769 getattr(btag, btagDiscr).
clone(
770 tagInfos = cms.VInputTag(
771 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
772 for x
in supportedBtagDiscr[discriminator_name][0] ]
778 elif hasattr(getattr(btag, btagDiscr),
'src'):
781 getattr(btag, btagDiscr).
clone(
782 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
788 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
789 acceptedBtagDiscriminators.append(discriminator_name)
791 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
793 for meta_tagger
in present_meta:
794 btagDiscr = meta_tagger.split(
':')[0]
796 if hasattr(btag,btagDiscr):
797 newDiscr = btagPrefix+btagDiscr+labelName+postfix
798 if hasattr(process, newDiscr):
803 getattr(btag, btagDiscr).
clone(),
807 for dependency
in supportedMetaDiscr[meta_tagger]:
808 if ':' in dependency:
809 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
811 new_dep = btagPrefix+dependency+labelName+postfix
812 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
813 replace.doIt(getattr(process, newDiscr), newDiscr)
814 acceptedBtagDiscriminators.append(meta_tagger)
816 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
819 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
820 patJets.discriminatorSources = cms.VInputTag(*[
821 cms.InputTag(btagPrefix+x+labelName+postfix) \
822 if ':' not in x
else \
823 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
824 for x
in acceptedBtagDiscriminators
826 if len(acceptedBtagDiscriminators) > 0 :
827 patJets.addBTagInfo =
True
830 if not tightBTagNTkHits:
831 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
836 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
837 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
838 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
839 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
841 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
842 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
843 _temp.minHits = cms.uint32(8)
845 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
846 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
847 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
848 _temp.primaryVertices = pvSource
849 _temp.tracks = pfCandidates
850 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
851 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
852 _temp.primaryVertices = pvSource
853 _temp.tracks = pfCandidates
854 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
856 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
858 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
859 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
860 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
862 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
863 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
864 _temp.minHits = cms.uint32(8)
866 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
867 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
868 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
869 _temp.primaryVertices = pvSource
870 _temp.tracks = pfCandidates
871 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
872 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
873 _temp.primaryVertices = pvSource
874 _temp.tracks = pfCandidates
875 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
877 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
879 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
880 if not hasattr( process,
'inclusiveVertexing' ):
881 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
882 task.add(process.inclusiveVertexingTask)
883 task.add(process.inclusiveCandidateVertexingTask)
884 task.add(process.inclusiveCandidateVertexingCvsLTask)
885 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
886 if not hasattr( process,
'inclusiveVertexing' ):
887 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
888 task.add(process.inclusiveVertexingTask)
889 task.add(process.inclusiveCandidateVertexingTask)
890 task.add(process.inclusiveCandidateVertexingCvsLTask)
891 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
892 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
893 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
894 task.add(process.inclusiveSecondaryVerticesFiltered)
895 task.add(process.bVertexFilter)
896 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
897 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
898 task.add(process.bToCharmDecayVertexMerged)
899 if 'caTopTagInfos' in acceptedTagInfos :
900 patJets.addTagInfos =
True
901 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
902 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
903 task.add(process.caTopTaggersTask)