240 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
245 discriminators = set(btagDiscriminators)
246 present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
247 discriminators -= present_metaSet
248 for meta_tagger
in present_metaSet:
249 for src
in supportedMetaDiscr[meta_tagger]:
250 discriminators.add(src)
251 present_meta = sorted(present_metaSet)
252 btagDiscriminators = sorted(discriminators)
256 requiredTagInfos = list(btagInfos)
257 for btagDiscr
in btagDiscriminators :
258 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
259 for requiredTagInfo
in tagInfoList :
260 tagInfoCovered =
False
261 for tagInfo
in requiredTagInfos :
262 if requiredTagInfo == tagInfo :
263 tagInfoCovered =
True
265 if not tagInfoCovered :
266 requiredTagInfos.append(requiredTagInfo)
268 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
270 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
271 task.add(process.impactParameterTask)
272 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
273 task.add(process.secondaryVertexTask)
274 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
275 task.add(process.softLeptonTask)
276 process.load(
"RecoBTag.Combined.combinedMVA_cff")
277 task.add(process.combinedMVATask)
278 process.load(
"RecoBTag.CTagging.cTagging_cff")
279 task.add(process.cTaggingTask)
281 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
282 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
283 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
284 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
285 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
287 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
291 sys.stderr.write(
"-------------------------------------------------------------------\n")
292 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
293 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
294 sys.stderr.write(
"-------------------------------------------------------------------\n")
296 sys.stderr.write(
"-------------------------------------------------------------------\n")
297 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
298 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
299 sys.stderr.write(
" avoid unintentional modifications to the default\n")
300 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
301 sys.stderr.write(
"-------------------------------------------------------------------\n")
305 svSourceCvsL = copy.deepcopy(svSource)
306 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
309 runIVFforCTagOnly =
False
310 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
312 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
313 runIVFforCTagOnly =
True
315 sys.stderr.write(
"-------------------------------------------------------------------\n")
316 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
317 sys.stderr.write(
" vertices will be remade.\n")
318 sys.stderr.write(
"-------------------------------------------------------------------\n")
320 if runIVF
and btagPrefix !=
'':
321 if runIVFforCTagOnly:
322 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
324 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
325 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
331 runNegativeVertexing =
False
332 runNegativeCvsLVertexing =
False
333 for btagInfo
in requiredTagInfos:
335 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
336 'pfNegativeDeepFlavourTagInfos',
337 'pfNegativeParticleNetAK4TagInfos',
339 runNegativeVertexing =
True
340 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
341 runNegativeCvsLVertexing =
True
343 if runNegativeVertexing
or runNegativeCvsLVertexing:
344 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
346 if runNegativeVertexing:
348 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
351 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
354 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
355 ,primaryVertices = pvSource
356 ,tracks=pfCandidates),
358 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
359 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
362 if runNegativeCvsLVertexing:
363 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
364 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
367 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
370 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
371 ,primaryVertices = pvSource
372 ,tracks=pfCandidates),
374 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
375 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
379 acceptedTagInfos = list()
380 for btagInfo
in requiredTagInfos:
381 if hasattr(btag,btagInfo):
382 if btagInfo ==
'pfImpactParameterTagInfos':
384 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
387 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
388 _btagInfo.explicitJTA = cms.bool(explicitJTA)
390 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
391 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
392 _btagInfo.minimumNumberOfHits = cms.int32(8)
393 if btagInfo ==
'pfImpactParameterAK8TagInfos':
395 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
398 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
399 _btagInfo.explicitJTA = cms.bool(explicitJTA)
401 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
402 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
403 _btagInfo.minimumNumberOfHits = cms.int32(8)
404 if btagInfo ==
'pfImpactParameterCA15TagInfos':
406 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
409 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
410 _btagInfo.explicitJTA = cms.bool(explicitJTA)
412 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
413 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
414 _btagInfo.minimumNumberOfHits = cms.int32(8)
415 if btagInfo ==
'pfSecondaryVertexTagInfos':
417 btag.pfSecondaryVertexTagInfos.clone(
418 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
421 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
422 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
423 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
424 if btagInfo ==
'pfDeepCSVTagInfos':
426 btag.pfDeepCSVTagInfos.clone(
427 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
429 if svClustering
or fatJets != cms.InputTag(
''):
430 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
431 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
433 btag.pfDeepCSVNegativeTagInfos.clone(
434 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
436 if svClustering
or fatJets != cms.InputTag(
''):
437 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
438 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
440 btag.pfDeepCSVPositiveTagInfos.clone(
441 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
443 if svClustering
or fatJets != cms.InputTag(
''):
444 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
445 if btagInfo ==
'pfDeepCMVATagInfos':
447 btag.pfDeepCMVATagInfos.clone(
448 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
449 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
450 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
451 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
453 if svClustering
or fatJets != cms.InputTag(
''):
454 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
455 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
457 btag.pfDeepCMVATagInfos.clone(
458 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
459 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
460 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
461 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
463 if svClustering
or fatJets != cms.InputTag(
''):
464 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
465 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
467 btag.pfDeepCMVATagInfos.clone(
468 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
469 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
470 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
471 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
473 if svClustering
or fatJets != cms.InputTag(
''):
474 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
475 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
477 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
478 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
479 extSVCollection=svSource),
481 if svClustering
or fatJets != cms.InputTag(
''):
482 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
483 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
485 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
486 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
487 extSVCollection=svSource),
489 if svClustering
or fatJets != cms.InputTag(
''):
490 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
491 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
493 btag.pfBoostedDoubleSVAK8TagInfos.clone(
494 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
496 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
498 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
499 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
500 extSVCollection=svSource),
502 if svClustering
or fatJets != cms.InputTag(
''):
503 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
504 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
506 btag.pfBoostedDoubleSVCA15TagInfos.clone(
507 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
509 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
511 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
512 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
513 extSVCollection=svSourceCvsL),
515 if svClustering
or fatJets != cms.InputTag(
''):
516 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
517 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
519 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
520 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
521 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
523 if svClustering
or fatJets != cms.InputTag(
''):
524 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
525 if btagInfo ==
'pfGhostTrackVertexTagInfos':
527 btag.pfGhostTrackVertexTagInfos.clone(
528 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
530 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
532 btag.pfSecondaryVertexNegativeTagInfos.clone(
533 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
536 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
537 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
538 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
539 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
541 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
542 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
543 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
545 if svClustering
or fatJets != cms.InputTag(
''):
546 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
547 if btagInfo ==
'impactParameterTagInfos':
549 btag.impactParameterTagInfos.clone(
550 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
551 primaryVertex=pvSource),
553 if btagInfo ==
'secondaryVertexTagInfos':
555 btag.secondaryVertexTagInfos.clone(
556 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
558 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
560 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
561 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
563 if svClustering
or fatJets != cms.InputTag(
''):
564 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
565 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
567 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
568 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
570 if svClustering
or fatJets != cms.InputTag(
''):
571 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
572 if btagInfo ==
'secondaryVertexNegativeTagInfos':
574 btag.secondaryVertexNegativeTagInfos.clone(
575 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
577 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
579 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
580 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
582 if svClustering
or fatJets != cms.InputTag(
''):
583 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
584 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
586 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
587 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
589 if svClustering
or fatJets != cms.InputTag(
''):
590 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
591 if btagInfo ==
'softMuonTagInfos':
593 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
595 if btagInfo ==
'softPFMuonsTagInfos':
597 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
599 if btagInfo ==
'softPFElectronsTagInfos':
601 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
603 if btagInfo ==
'pixelClusterTagInfos':
605 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
608 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
609 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
610 if pfCandidates.value() ==
'packedPFCandidates':
611 _btagInfo.weights = cms.InputTag(
"packedpuppi")
612 if not hasattr(process,
"packedpuppi"):
615 useExistingWeights =
True,
616 candName =
'packedPFCandidates',
617 vertexName =
'offlineSlimmedPrimaryVertices') , process, task)
619 _btagInfo.weights = cms.InputTag(
"puppi")
621 if 'DeepFlavourTagInfos' in btagInfo:
623 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
624 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos'
625 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
628 deep_csv_tag_infos =
'pfDeepCSVTagInfos'
632 if not (
'limmed' in jetSource.value()):
633 puppi_value_map = cms.InputTag(
"puppi")
634 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
636 puppi_value_map = cms.InputTag(
"")
637 vertex_associator = cms.InputTag(
"")
639 btag.pfDeepFlavourTagInfos.clone(
642 secondary_vertices=svUsed,
643 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
644 puppi_value_map = puppi_value_map,
645 vertex_associator = vertex_associator,
649 if btagInfo ==
'pfDeepDoubleXTagInfos':
651 btag.pfDeepDoubleXTagInfos.clone(
654 secondary_vertices=svSource,
655 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
659 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
661 btag.pfHiggsInteractionNetTagInfos.clone(
664 secondary_vertices = svSource,
665 pf_candidates = pfCandidates,
669 if btagInfo ==
'pfDeepBoostedJetTagInfos':
670 if pfCandidates.value() ==
'packedPFCandidates':
672 if 'updated' not in jetSource.value().lower():
673 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
675 vertex_associator =
""
676 elif pfCandidates.value() ==
'particleFlow':
677 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
684 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
686 btag.pfDeepBoostedJetTagInfos.clone(
689 secondary_vertices = svSource,
690 pf_candidates = pfCandidates,
691 puppi_value_map = puppi_value_map,
692 vertex_associator = vertex_associator,
696 if btagInfo ==
'pfParticleNetTagInfos':
697 if pfCandidates.value() ==
'packedPFCandidates':
700 vertex_associator =
""
701 elif pfCandidates.value() ==
'particleFlow':
702 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
704 puppi_value_map =
"puppi"
705 vertex_associator =
"primaryVertexAssociation:original"
707 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
709 btag.pfParticleNetTagInfos.clone(
712 secondary_vertices = svSource,
713 pf_candidates = pfCandidates,
714 puppi_value_map = puppi_value_map,
715 vertex_associator = vertex_associator,
719 if 'ParticleNetAK4TagInfos' in btagInfo:
720 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
721 secondary_vertices = btagPrefix + \
722 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
726 secondary_vertices = svSource
729 if pfCandidates.value() ==
'packedPFCandidates':
732 vertex_associator =
""
733 elif pfCandidates.value() ==
'particleFlow':
734 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
736 puppi_value_map =
"puppi"
737 vertex_associator =
"primaryVertexAssociation:original"
739 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
741 btag.pfParticleNetAK4TagInfos.clone(
744 secondary_vertices = secondary_vertices,
745 pf_candidates = pfCandidates,
746 puppi_value_map = puppi_value_map,
747 vertex_associator = vertex_associator,
748 flip_ip_sign = flip_ip_sign,
749 sip3dSigMax = sip3dSigMax,
753 acceptedTagInfos.append(btagInfo)
754 elif hasattr(toptag, btagInfo) :
755 acceptedTagInfos.append(btagInfo)
757 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
759 acceptedBtagDiscriminators = list()
760 for discriminator_name
in btagDiscriminators :
761 btagDiscr = discriminator_name.split(
':')[0]
763 if hasattr(btag,btagDiscr):
764 newDiscr = btagPrefix+btagDiscr+labelName+postfix
765 if hasattr(process, newDiscr):
767 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
770 getattr(btag, btagDiscr).
clone(
771 tagInfos = cms.VInputTag(
772 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
773 for x
in supportedBtagDiscr[discriminator_name][0] ]
779 elif hasattr(getattr(btag, btagDiscr),
'src'):
782 getattr(btag, btagDiscr).
clone(
783 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
789 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
790 acceptedBtagDiscriminators.append(discriminator_name)
792 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
794 for meta_tagger
in present_meta:
795 btagDiscr = meta_tagger.split(
':')[0]
797 if hasattr(btag,btagDiscr):
798 newDiscr = btagPrefix+btagDiscr+labelName+postfix
799 if hasattr(process, newDiscr):
804 getattr(btag, btagDiscr).
clone(),
808 for dependency
in supportedMetaDiscr[meta_tagger]:
809 if ':' in dependency:
810 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
812 new_dep = btagPrefix+dependency+labelName+postfix
813 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
814 replace.doIt(getattr(process, newDiscr), newDiscr)
815 acceptedBtagDiscriminators.append(meta_tagger)
817 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
820 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
821 patJets.discriminatorSources = cms.VInputTag(*[
822 cms.InputTag(btagPrefix+x+labelName+postfix) \
823 if ':' not in x
else \
824 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
825 for x
in acceptedBtagDiscriminators
827 if len(acceptedBtagDiscriminators) > 0 :
828 patJets.addBTagInfo =
True
831 if not tightBTagNTkHits:
832 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
837 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
838 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
839 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
840 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
842 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
843 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
844 _temp.minHits = cms.uint32(8)
846 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
847 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
848 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
849 _temp.primaryVertices = pvSource
850 _temp.tracks = pfCandidates
851 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
852 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
853 _temp.primaryVertices = pvSource
854 _temp.tracks = pfCandidates
855 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
857 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
859 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
860 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
861 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
863 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
864 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
865 _temp.minHits = cms.uint32(8)
867 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
868 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
869 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
870 _temp.primaryVertices = pvSource
871 _temp.tracks = pfCandidates
872 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
873 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
874 _temp.primaryVertices = pvSource
875 _temp.tracks = pfCandidates
876 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
878 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
880 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
881 if not hasattr( process,
'inclusiveVertexing' ):
882 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
883 task.add(process.inclusiveVertexingTask)
884 task.add(process.inclusiveCandidateVertexingTask)
885 task.add(process.inclusiveCandidateVertexingCvsLTask)
886 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
887 if not hasattr( process,
'inclusiveVertexing' ):
888 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
889 task.add(process.inclusiveVertexingTask)
890 task.add(process.inclusiveCandidateVertexingTask)
891 task.add(process.inclusiveCandidateVertexingCvsLTask)
892 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
893 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
894 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
895 task.add(process.inclusiveSecondaryVerticesFiltered)
896 task.add(process.bVertexFilter)
897 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
898 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
899 task.add(process.bToCharmDecayVertexMerged)
900 if 'caTopTagInfos' in acceptedTagInfos :
901 patJets.addTagInfos =
True
902 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
903 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
904 task.add(process.caTopTaggersTask)