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:
332 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos' or btagInfo ==
'pfNegativeDeepFlavourTagInfos':
333 runNegativeVertexing =
True
334 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
335 runNegativeCvsLVertexing =
True
337 if runNegativeVertexing
or runNegativeCvsLVertexing:
338 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
340 if runNegativeVertexing:
342 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
345 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
348 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
349 ,primaryVertices = pvSource
350 ,tracks=pfCandidates),
352 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
353 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
356 if runNegativeCvsLVertexing:
357 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
358 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
361 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
364 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
365 ,primaryVertices = pvSource
366 ,tracks=pfCandidates),
368 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
369 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
373 acceptedTagInfos =
list()
374 for btagInfo
in requiredTagInfos:
375 if hasattr(btag,btagInfo):
376 if btagInfo ==
'pfImpactParameterTagInfos':
378 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
381 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
382 _btagInfo.explicitJTA = cms.bool(explicitJTA)
384 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
385 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
386 _btagInfo.minimumNumberOfHits = cms.int32(8)
387 if btagInfo ==
'pfImpactParameterAK8TagInfos':
389 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
392 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
393 _btagInfo.explicitJTA = cms.bool(explicitJTA)
395 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
396 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
397 _btagInfo.minimumNumberOfHits = cms.int32(8)
398 if btagInfo ==
'pfImpactParameterCA15TagInfos':
400 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
403 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
404 _btagInfo.explicitJTA = cms.bool(explicitJTA)
406 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
407 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
408 _btagInfo.minimumNumberOfHits = cms.int32(8)
409 if btagInfo ==
'pfSecondaryVertexTagInfos':
411 btag.pfSecondaryVertexTagInfos.clone(
412 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
415 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
416 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
417 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
418 if btagInfo ==
'pfDeepCSVTagInfos':
420 btag.pfDeepCSVTagInfos.clone(
421 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
423 if svClustering
or fatJets != cms.InputTag(
''):
424 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
425 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
427 btag.pfDeepCSVNegativeTagInfos.clone(
428 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
430 if svClustering
or fatJets != cms.InputTag(
''):
431 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
432 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
434 btag.pfDeepCSVPositiveTagInfos.clone(
435 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
437 if svClustering
or fatJets != cms.InputTag(
''):
438 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
439 if btagInfo ==
'pfDeepCMVATagInfos':
441 btag.pfDeepCMVATagInfos.clone(
442 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
443 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
444 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
445 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
447 if svClustering
or fatJets != cms.InputTag(
''):
448 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
449 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
451 btag.pfDeepCMVATagInfos.clone(
452 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
453 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
454 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
455 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
457 if svClustering
or fatJets != cms.InputTag(
''):
458 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
459 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
461 btag.pfDeepCMVATagInfos.clone(
462 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
463 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
464 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
465 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
467 if svClustering
or fatJets != cms.InputTag(
''):
468 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
469 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
471 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
472 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
473 extSVCollection=svSource),
475 if svClustering
or fatJets != cms.InputTag(
''):
476 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
477 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
479 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
480 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
481 extSVCollection=svSource),
483 if svClustering
or fatJets != cms.InputTag(
''):
484 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
485 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
487 btag.pfBoostedDoubleSVAK8TagInfos.clone(
488 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
490 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
492 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
493 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
494 extSVCollection=svSource),
496 if svClustering
or fatJets != cms.InputTag(
''):
497 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
498 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
500 btag.pfBoostedDoubleSVCA15TagInfos.clone(
501 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
503 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
505 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
506 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
507 extSVCollection=svSourceCvsL),
509 if svClustering
or fatJets != cms.InputTag(
''):
510 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
511 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
513 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
514 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
515 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
517 if svClustering
or fatJets != cms.InputTag(
''):
518 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
519 if btagInfo ==
'pfGhostTrackVertexTagInfos':
521 btag.pfGhostTrackVertexTagInfos.clone(
522 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
524 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
526 btag.pfSecondaryVertexNegativeTagInfos.clone(
527 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
530 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
531 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
532 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
533 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
535 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
536 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
537 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
539 if svClustering
or fatJets != cms.InputTag(
''):
540 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
541 if btagInfo ==
'impactParameterTagInfos':
543 btag.impactParameterTagInfos.clone(
544 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
545 primaryVertex=pvSource),
547 if btagInfo ==
'secondaryVertexTagInfos':
549 btag.secondaryVertexTagInfos.clone(
550 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
552 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
554 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
555 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
557 if svClustering
or fatJets != cms.InputTag(
''):
558 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
559 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
561 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
562 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
564 if svClustering
or fatJets != cms.InputTag(
''):
565 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
566 if btagInfo ==
'secondaryVertexNegativeTagInfos':
568 btag.secondaryVertexNegativeTagInfos.clone(
569 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
571 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
573 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
574 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
576 if svClustering
or fatJets != cms.InputTag(
''):
577 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
578 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
580 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
581 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
583 if svClustering
or fatJets != cms.InputTag(
''):
584 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
585 if btagInfo ==
'softMuonTagInfos':
587 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
589 if btagInfo ==
'softPFMuonsTagInfos':
591 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
593 if btagInfo ==
'softPFElectronsTagInfos':
595 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
597 if btagInfo ==
'pixelClusterTagInfos':
599 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
602 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
603 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
604 if pfCandidates.value() ==
'packedPFCandidates':
605 _btagInfo.weights = cms.InputTag(
"packedpuppi")
606 if not hasattr(process,
"packedpuppi"):
609 useExistingWeights =
True,
610 candName =
'packedPFCandidates',
611 vertexName =
'offlineSlimmedPrimaryVertices') , process, task)
613 _btagInfo.weights = cms.InputTag(
"puppi")
615 if 'DeepFlavourTagInfos' in btagInfo:
617 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
618 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos'
619 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
622 deep_csv_tag_infos =
'pfDeepCSVTagInfos'
626 if not (
'limmed' in jetSource.value()):
627 puppi_value_map = cms.InputTag(
"puppi")
628 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
630 puppi_value_map = cms.InputTag(
"")
631 vertex_associator = cms.InputTag(
"")
633 btag.pfDeepFlavourTagInfos.clone(
636 secondary_vertices=svUsed,
637 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
638 puppi_value_map = puppi_value_map,
639 vertex_associator = vertex_associator,
643 if btagInfo ==
'pfDeepDoubleXTagInfos':
645 btag.pfDeepDoubleXTagInfos.clone(
648 secondary_vertices=svSource,
649 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
653 if btagInfo ==
'pfDeepBoostedJetTagInfos':
654 if pfCandidates.value() ==
'packedPFCandidates':
656 if 'updated' not in jetSource.value().lower():
657 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
659 vertex_associator =
""
660 elif pfCandidates.value() ==
'particleFlow':
661 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
668 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
670 btag.pfDeepBoostedJetTagInfos.clone(
673 secondary_vertices = svSource,
674 pf_candidates = pfCandidates,
675 puppi_value_map = puppi_value_map,
676 vertex_associator = vertex_associator,
680 if btagInfo ==
'pfParticleNetTagInfos':
681 if pfCandidates.value() ==
'packedPFCandidates':
684 vertex_associator =
""
685 elif pfCandidates.value() ==
'particleFlow':
686 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
688 puppi_value_map =
"puppi"
689 vertex_associator =
"primaryVertexAssociation:original"
691 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
693 btag.pfParticleNetTagInfos.clone(
696 secondary_vertices = svSource,
697 pf_candidates = pfCandidates,
698 puppi_value_map = puppi_value_map,
699 vertex_associator = vertex_associator,
703 acceptedTagInfos.append(btagInfo)
704 elif hasattr(toptag, btagInfo) :
705 acceptedTagInfos.append(btagInfo)
707 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
709 acceptedBtagDiscriminators =
list()
710 for discriminator_name
in btagDiscriminators :
711 btagDiscr = discriminator_name.split(
':')[0]
713 if hasattr(btag,btagDiscr):
714 newDiscr = btagPrefix+btagDiscr+labelName+postfix
715 if hasattr(process, newDiscr):
717 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
720 getattr(btag, btagDiscr).
clone(
721 tagInfos = cms.VInputTag(
722 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
723 for x
in supportedBtagDiscr[discriminator_name][0] ]
729 elif hasattr(getattr(btag, btagDiscr),
'src'):
732 getattr(btag, btagDiscr).
clone(
733 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
739 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
740 acceptedBtagDiscriminators.append(discriminator_name)
742 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
744 for meta_tagger
in present_meta:
745 btagDiscr = meta_tagger.split(
':')[0]
747 if hasattr(btag,btagDiscr):
748 newDiscr = btagPrefix+btagDiscr+labelName+postfix
749 if hasattr(process, newDiscr):
754 getattr(btag, btagDiscr).
clone(),
758 for dependency
in supportedMetaDiscr[meta_tagger]:
759 if ':' in dependency:
760 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
762 new_dep = btagPrefix+dependency+labelName+postfix
763 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
764 replace.doIt(getattr(process, newDiscr), newDiscr)
765 acceptedBtagDiscriminators.append(meta_tagger)
767 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
770 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
771 patJets.discriminatorSources = cms.VInputTag(*[
772 cms.InputTag(btagPrefix+x+labelName+postfix) \
773 if ':' not in x
else \
774 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
775 for x
in acceptedBtagDiscriminators
777 if len(acceptedBtagDiscriminators) > 0 :
778 patJets.addBTagInfo =
True
781 if not tightBTagNTkHits:
782 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
787 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
788 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
789 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
790 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
792 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
793 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
794 _temp.minHits = cms.uint32(8)
796 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
797 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
798 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
799 _temp.primaryVertices = pvSource
800 _temp.tracks = pfCandidates
801 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
802 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
803 _temp.primaryVertices = pvSource
804 _temp.tracks = pfCandidates
805 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
807 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
809 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
810 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
811 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
813 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
814 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
815 _temp.minHits = cms.uint32(8)
817 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
818 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
819 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
820 _temp.primaryVertices = pvSource
821 _temp.tracks = pfCandidates
822 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
823 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
824 _temp.primaryVertices = pvSource
825 _temp.tracks = pfCandidates
826 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
828 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
830 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
831 if not hasattr( process,
'inclusiveVertexing' ):
832 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
833 task.add(process.inclusiveVertexingTask)
834 task.add(process.inclusiveCandidateVertexingTask)
835 task.add(process.inclusiveCandidateVertexingCvsLTask)
836 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
837 if not hasattr( process,
'inclusiveVertexing' ):
838 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
839 task.add(process.inclusiveVertexingTask)
840 task.add(process.inclusiveCandidateVertexingTask)
841 task.add(process.inclusiveCandidateVertexingCvsLTask)
842 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
843 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
844 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
845 task.add(process.inclusiveSecondaryVerticesFiltered)
846 task.add(process.bVertexFilter)
847 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
848 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
849 task.add(process.bToCharmDecayVertexMerged)
850 if 'caTopTagInfos' in acceptedTagInfos :
851 patJets.addTagInfos =
True
852 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
853 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
854 task.add(process.caTopTaggersTask)