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_meta = discriminators.intersection(set(supportedMetaDiscr.keys()))
246 discriminators -= present_meta
247 for meta_tagger
in present_meta:
248 for src
in supportedMetaDiscr[meta_tagger]:
249 discriminators.add(src)
250 btagDiscriminators = list(discriminators)
254 requiredTagInfos = list(btagInfos)
255 for btagDiscr
in btagDiscriminators :
256 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
257 for requiredTagInfo
in tagInfoList :
258 tagInfoCovered =
False
259 for tagInfo
in requiredTagInfos :
260 if requiredTagInfo == tagInfo :
261 tagInfoCovered =
True
263 if not tagInfoCovered :
264 requiredTagInfos.append(requiredTagInfo)
266 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
268 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
269 task.add(process.impactParameterTask)
270 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
271 task.add(process.secondaryVertexTask)
272 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
273 task.add(process.softLeptonTask)
274 process.load(
"RecoBTag.Combined.combinedMVA_cff")
275 task.add(process.combinedMVATask)
276 process.load(
"RecoBTag.CTagging.cTagging_cff")
277 task.add(process.cTaggingTask)
279 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
280 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
281 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
282 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
283 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
285 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
289 sys.stderr.write(
"-------------------------------------------------------------------\n")
290 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
291 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
292 sys.stderr.write(
"-------------------------------------------------------------------\n")
294 sys.stderr.write(
"-------------------------------------------------------------------\n")
295 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
296 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
297 sys.stderr.write(
" avoid unintentional modifications to the default\n")
298 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
299 sys.stderr.write(
"-------------------------------------------------------------------\n")
303 svSourceCvsL = copy.deepcopy(svSource)
304 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
307 runIVFforCTagOnly =
False
308 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
310 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
311 runIVFforCTagOnly =
True
313 sys.stderr.write(
"-------------------------------------------------------------------\n")
314 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
315 sys.stderr.write(
" vertices will be remade.\n")
316 sys.stderr.write(
"-------------------------------------------------------------------\n")
318 if runIVF
and btagPrefix !=
'':
319 if runIVFforCTagOnly:
320 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
322 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
323 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
329 runNegativeVertexing =
False
330 runNegativeCvsLVertexing =
False
331 for btagInfo
in requiredTagInfos:
333 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
334 'pfNegativeDeepFlavourTagInfos',
335 'pfNegativeParticleNetAK4TagInfos',
337 runNegativeVertexing =
True
338 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
339 runNegativeCvsLVertexing =
True
341 if runNegativeVertexing
or runNegativeCvsLVertexing:
342 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
344 if runNegativeVertexing:
346 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
349 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
352 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
353 ,primaryVertices = pvSource
354 ,tracks=pfCandidates),
356 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
357 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
360 if runNegativeCvsLVertexing:
361 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
362 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
365 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
368 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
369 ,primaryVertices = pvSource
370 ,tracks=pfCandidates),
372 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
373 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
377 acceptedTagInfos = list()
378 for btagInfo
in requiredTagInfos:
379 if hasattr(btag,btagInfo):
380 if btagInfo ==
'pfImpactParameterTagInfos':
382 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
385 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
386 _btagInfo.explicitJTA = cms.bool(explicitJTA)
388 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
389 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
390 _btagInfo.minimumNumberOfHits = cms.int32(8)
391 if btagInfo ==
'pfImpactParameterAK8TagInfos':
393 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
396 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
397 _btagInfo.explicitJTA = cms.bool(explicitJTA)
399 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
400 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
401 _btagInfo.minimumNumberOfHits = cms.int32(8)
402 if btagInfo ==
'pfImpactParameterCA15TagInfos':
404 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
407 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
408 _btagInfo.explicitJTA = cms.bool(explicitJTA)
410 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
411 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
412 _btagInfo.minimumNumberOfHits = cms.int32(8)
413 if btagInfo ==
'pfSecondaryVertexTagInfos':
415 btag.pfSecondaryVertexTagInfos.clone(
416 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
419 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
420 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
421 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
422 if btagInfo ==
'pfDeepCSVTagInfos':
424 btag.pfDeepCSVTagInfos.clone(
425 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
427 if svClustering
or fatJets != cms.InputTag(
''):
428 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
429 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
431 btag.pfDeepCSVNegativeTagInfos.clone(
432 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
434 if svClustering
or fatJets != cms.InputTag(
''):
435 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
436 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
438 btag.pfDeepCSVPositiveTagInfos.clone(
439 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
441 if svClustering
or fatJets != cms.InputTag(
''):
442 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
443 if btagInfo ==
'pfDeepCMVATagInfos':
445 btag.pfDeepCMVATagInfos.clone(
446 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
447 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
448 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
449 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
451 if svClustering
or fatJets != cms.InputTag(
''):
452 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
453 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
455 btag.pfDeepCMVATagInfos.clone(
456 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
457 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
458 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
459 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
461 if svClustering
or fatJets != cms.InputTag(
''):
462 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
463 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
465 btag.pfDeepCMVATagInfos.clone(
466 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
467 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
468 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
469 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
471 if svClustering
or fatJets != cms.InputTag(
''):
472 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
473 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
475 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
476 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
477 extSVCollection=svSource),
479 if svClustering
or fatJets != cms.InputTag(
''):
480 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
481 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
483 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
484 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
485 extSVCollection=svSource),
487 if svClustering
or fatJets != cms.InputTag(
''):
488 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
489 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
491 btag.pfBoostedDoubleSVAK8TagInfos.clone(
492 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
494 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
496 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
497 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
498 extSVCollection=svSource),
500 if svClustering
or fatJets != cms.InputTag(
''):
501 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
502 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
504 btag.pfBoostedDoubleSVCA15TagInfos.clone(
505 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
507 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
509 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
510 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
511 extSVCollection=svSourceCvsL),
513 if svClustering
or fatJets != cms.InputTag(
''):
514 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
515 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
517 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
518 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
519 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
521 if svClustering
or fatJets != cms.InputTag(
''):
522 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
523 if btagInfo ==
'pfGhostTrackVertexTagInfos':
525 btag.pfGhostTrackVertexTagInfos.clone(
526 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
528 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
530 btag.pfSecondaryVertexNegativeTagInfos.clone(
531 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
534 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
535 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
536 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
537 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
539 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
540 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
541 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
543 if svClustering
or fatJets != cms.InputTag(
''):
544 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
545 if btagInfo ==
'impactParameterTagInfos':
547 btag.impactParameterTagInfos.clone(
548 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
549 primaryVertex=pvSource),
551 if btagInfo ==
'secondaryVertexTagInfos':
553 btag.secondaryVertexTagInfos.clone(
554 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
556 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
558 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
559 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
561 if svClustering
or fatJets != cms.InputTag(
''):
562 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
563 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
565 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
566 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
568 if svClustering
or fatJets != cms.InputTag(
''):
569 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
570 if btagInfo ==
'secondaryVertexNegativeTagInfos':
572 btag.secondaryVertexNegativeTagInfos.clone(
573 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
575 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
577 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
578 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
580 if svClustering
or fatJets != cms.InputTag(
''):
581 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
582 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
584 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
585 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
587 if svClustering
or fatJets != cms.InputTag(
''):
588 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
589 if btagInfo ==
'softMuonTagInfos':
591 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
593 if btagInfo ==
'softPFMuonsTagInfos':
595 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
597 if btagInfo ==
'softPFElectronsTagInfos':
599 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
601 if btagInfo ==
'pixelClusterTagInfos':
603 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
606 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
607 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
608 if pfCandidates.value() ==
'packedPFCandidates':
609 _btagInfo.weights = cms.InputTag(
"packedpuppi")
610 if not hasattr(process,
"packedpuppi"):
613 useExistingWeights =
True,
614 candName =
'packedPFCandidates',
615 vertexName =
'offlineSlimmedPrimaryVertices') , process, task)
617 _btagInfo.weights = cms.InputTag(
"puppi")
619 if 'DeepFlavourTagInfos' in btagInfo:
621 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
622 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos'
623 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
626 deep_csv_tag_infos =
'pfDeepCSVTagInfos'
630 if not (
'limmed' in jetSource.value()):
631 puppi_value_map = cms.InputTag(
"puppi")
632 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
634 puppi_value_map = cms.InputTag(
"")
635 vertex_associator = cms.InputTag(
"")
637 btag.pfDeepFlavourTagInfos.clone(
640 secondary_vertices=svUsed,
641 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
642 puppi_value_map = puppi_value_map,
643 vertex_associator = vertex_associator,
647 if btagInfo ==
'pfDeepDoubleXTagInfos':
649 btag.pfDeepDoubleXTagInfos.clone(
652 secondary_vertices=svSource,
653 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
657 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
659 btag.pfHiggsInteractionNetTagInfos.clone(
662 secondary_vertices = svSource,
663 pf_candidates = pfCandidates,
667 if btagInfo ==
'pfDeepBoostedJetTagInfos':
668 if pfCandidates.value() ==
'packedPFCandidates':
670 if 'updated' not in jetSource.value().lower():
671 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
673 vertex_associator =
""
674 elif pfCandidates.value() ==
'particleFlow':
675 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
682 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
684 btag.pfDeepBoostedJetTagInfos.clone(
687 secondary_vertices = svSource,
688 pf_candidates = pfCandidates,
689 puppi_value_map = puppi_value_map,
690 vertex_associator = vertex_associator,
694 if btagInfo ==
'pfParticleNetTagInfos':
695 if pfCandidates.value() ==
'packedPFCandidates':
698 vertex_associator =
""
699 elif pfCandidates.value() ==
'particleFlow':
700 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
702 puppi_value_map =
"puppi"
703 vertex_associator =
"primaryVertexAssociation:original"
705 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
707 btag.pfParticleNetTagInfos.clone(
710 secondary_vertices = svSource,
711 pf_candidates = pfCandidates,
712 puppi_value_map = puppi_value_map,
713 vertex_associator = vertex_associator,
717 if 'ParticleNetAK4TagInfos' in btagInfo:
718 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
719 secondary_vertices = btagPrefix + \
720 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
724 secondary_vertices = svSource
727 if pfCandidates.value() ==
'packedPFCandidates':
730 vertex_associator =
""
731 elif pfCandidates.value() ==
'particleFlow':
732 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
734 puppi_value_map =
"puppi"
735 vertex_associator =
"primaryVertexAssociation:original"
737 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
739 btag.pfParticleNetAK4TagInfos.clone(
742 secondary_vertices = secondary_vertices,
743 pf_candidates = pfCandidates,
744 puppi_value_map = puppi_value_map,
745 vertex_associator = vertex_associator,
746 flip_ip_sign = flip_ip_sign,
747 sip3dSigMax = sip3dSigMax,
751 acceptedTagInfos.append(btagInfo)
752 elif hasattr(toptag, btagInfo) :
753 acceptedTagInfos.append(btagInfo)
755 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
757 acceptedBtagDiscriminators = list()
758 for discriminator_name
in btagDiscriminators :
759 btagDiscr = discriminator_name.split(
':')[0]
761 if hasattr(btag,btagDiscr):
762 newDiscr = btagPrefix+btagDiscr+labelName+postfix
763 if hasattr(process, newDiscr):
765 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
768 getattr(btag, btagDiscr).
clone(
769 tagInfos = cms.VInputTag(
770 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
771 for x
in supportedBtagDiscr[discriminator_name][0] ]
777 elif hasattr(getattr(btag, btagDiscr),
'src'):
780 getattr(btag, btagDiscr).
clone(
781 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
787 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
788 acceptedBtagDiscriminators.append(discriminator_name)
790 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
792 for meta_tagger
in present_meta:
793 btagDiscr = meta_tagger.split(
':')[0]
795 if hasattr(btag,btagDiscr):
796 newDiscr = btagPrefix+btagDiscr+labelName+postfix
797 if hasattr(process, newDiscr):
802 getattr(btag, btagDiscr).
clone(),
806 for dependency
in supportedMetaDiscr[meta_tagger]:
807 if ':' in dependency:
808 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
810 new_dep = btagPrefix+dependency+labelName+postfix
811 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
812 replace.doIt(getattr(process, newDiscr), newDiscr)
813 acceptedBtagDiscriminators.append(meta_tagger)
815 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
818 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
819 patJets.discriminatorSources = cms.VInputTag(*[
820 cms.InputTag(btagPrefix+x+labelName+postfix) \
821 if ':' not in x
else \
822 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
823 for x
in acceptedBtagDiscriminators
825 if len(acceptedBtagDiscriminators) > 0 :
826 patJets.addBTagInfo =
True
829 if not tightBTagNTkHits:
830 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
835 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
836 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
837 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
838 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
840 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
841 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
842 _temp.minHits = cms.uint32(8)
844 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
845 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
846 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
847 _temp.primaryVertices = pvSource
848 _temp.tracks = pfCandidates
849 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
850 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
851 _temp.primaryVertices = pvSource
852 _temp.tracks = pfCandidates
853 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
855 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
857 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
858 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
859 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
861 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
862 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
863 _temp.minHits = cms.uint32(8)
865 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
866 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
867 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
868 _temp.primaryVertices = pvSource
869 _temp.tracks = pfCandidates
870 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
871 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
872 _temp.primaryVertices = pvSource
873 _temp.tracks = pfCandidates
874 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
876 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
878 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
879 if not hasattr( process,
'inclusiveVertexing' ):
880 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
881 task.add(process.inclusiveVertexingTask)
882 task.add(process.inclusiveCandidateVertexingTask)
883 task.add(process.inclusiveCandidateVertexingCvsLTask)
884 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
885 if not hasattr( process,
'inclusiveVertexing' ):
886 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
887 task.add(process.inclusiveVertexingTask)
888 task.add(process.inclusiveCandidateVertexingTask)
889 task.add(process.inclusiveCandidateVertexingCvsLTask)
890 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
891 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
892 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
893 task.add(process.inclusiveSecondaryVerticesFiltered)
894 task.add(process.bVertexFilter)
895 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
896 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
897 task.add(process.bToCharmDecayVertexMerged)
898 if 'caTopTagInfos' in acceptedTagInfos :
899 patJets.addTagInfos =
True
900 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
901 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
902 task.add(process.caTopTaggersTask)