271 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
276 discriminators = set(btagDiscriminators)
277 present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
278 discriminators -= present_metaSet
279 for meta_tagger
in present_metaSet:
280 for src
in supportedMetaDiscr[meta_tagger]:
281 discriminators.add(src)
282 present_meta = sorted(present_metaSet)
283 btagDiscriminators = sorted(discriminators)
287 requiredTagInfos = list(btagInfos)
288 for btagDiscr
in btagDiscriminators :
289 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
290 for requiredTagInfo
in tagInfoList :
291 tagInfoCovered =
False 292 for tagInfo
in requiredTagInfos :
293 if requiredTagInfo == tagInfo :
294 tagInfoCovered =
True 296 if not tagInfoCovered :
297 requiredTagInfos.append(requiredTagInfo)
299 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
301 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
302 task.add(process.impactParameterTask)
303 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
304 task.add(process.secondaryVertexTask)
305 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
306 task.add(process.softLeptonTask)
307 process.load(
"RecoBTag.Combined.combinedMVA_cff")
308 task.add(process.combinedMVATask)
309 process.load(
"RecoBTag.CTagging.cTagging_cff")
310 task.add(process.cTaggingTask)
312 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
313 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
314 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
315 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
316 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
318 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
322 sys.stderr.write(
"-------------------------------------------------------------------\n")
323 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
324 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
325 sys.stderr.write(
"-------------------------------------------------------------------\n")
327 sys.stderr.write(
"-------------------------------------------------------------------\n")
328 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
329 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
330 sys.stderr.write(
" avoid unintentional modifications to the default\n")
331 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
332 sys.stderr.write(
"-------------------------------------------------------------------\n")
336 svSourceCvsL = copy.deepcopy(svSource)
337 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
340 runIVFforCTagOnly =
False 341 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
343 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
344 runIVFforCTagOnly =
True 346 sys.stderr.write(
"-------------------------------------------------------------------\n")
347 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
348 sys.stderr.write(
" vertices will be remade.\n")
349 sys.stderr.write(
"-------------------------------------------------------------------\n")
351 if runIVF
and btagPrefix !=
'':
352 if runIVFforCTagOnly:
353 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
355 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
356 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
362 runNegativeVertexing =
False 363 runNegativeCvsLVertexing =
False 364 for btagInfo
in requiredTagInfos:
366 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
367 'pfNegativeDeepFlavourTagInfos',
368 'pfNegativeParticleNetAK4TagInfos',
370 runNegativeVertexing =
True 371 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
372 runNegativeCvsLVertexing =
True 374 if runNegativeVertexing
or runNegativeCvsLVertexing:
375 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
377 if runNegativeVertexing:
379 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
382 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
385 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
386 ,primaryVertices = pvSource
387 ,tracks=pfCandidates),
389 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
390 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
393 if runNegativeCvsLVertexing:
394 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
395 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
398 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
401 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
402 ,primaryVertices = pvSource
403 ,tracks=pfCandidates),
405 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
406 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
410 acceptedTagInfos = list()
411 for btagInfo
in requiredTagInfos:
412 if hasattr(btag,btagInfo):
413 if btagInfo ==
'pfImpactParameterTagInfos':
415 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
418 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
419 _btagInfo.explicitJTA = cms.bool(explicitJTA)
421 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
422 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
423 _btagInfo.minimumNumberOfHits = cms.int32(8)
424 if btagInfo ==
'pfImpactParameterAK8TagInfos':
426 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
429 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
430 _btagInfo.explicitJTA = cms.bool(explicitJTA)
432 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
433 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
434 _btagInfo.minimumNumberOfHits = cms.int32(8)
435 if btagInfo ==
'pfImpactParameterCA15TagInfos':
437 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
440 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
441 _btagInfo.explicitJTA = cms.bool(explicitJTA)
443 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
444 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
445 _btagInfo.minimumNumberOfHits = cms.int32(8)
446 if btagInfo ==
'pfSecondaryVertexTagInfos':
448 btag.pfSecondaryVertexTagInfos.clone(
449 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
452 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
453 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
454 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
455 if btagInfo ==
'pfDeepCSVTagInfos':
457 btag.pfDeepCSVTagInfos.clone(
458 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
460 if svClustering
or fatJets != cms.InputTag(
''):
461 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
462 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
464 btag.pfDeepCSVNegativeTagInfos.clone(
465 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+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 ==
'pfDeepCSVPositiveTagInfos':
471 btag.pfDeepCSVPositiveTagInfos.clone(
472 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
474 if svClustering
or fatJets != cms.InputTag(
''):
475 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
476 if btagInfo ==
'pfDeepCMVATagInfos':
478 btag.pfDeepCMVATagInfos.clone(
479 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
480 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
481 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
482 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
484 if svClustering
or fatJets != cms.InputTag(
''):
485 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
486 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
488 btag.pfDeepCMVATagInfos.clone(
489 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
490 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
491 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
492 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
494 if svClustering
or fatJets != cms.InputTag(
''):
495 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
496 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
498 btag.pfDeepCMVATagInfos.clone(
499 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
500 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
501 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
502 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
504 if svClustering
or fatJets != cms.InputTag(
''):
505 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
506 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
508 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
509 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
510 extSVCollection=svSource),
512 if svClustering
or fatJets != cms.InputTag(
''):
513 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
514 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
516 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
517 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
518 extSVCollection=svSource),
520 if svClustering
or fatJets != cms.InputTag(
''):
521 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
522 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
524 btag.pfBoostedDoubleSVAK8TagInfos.clone(
525 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
527 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
529 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
530 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
531 extSVCollection=svSource),
533 if svClustering
or fatJets != cms.InputTag(
''):
534 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
535 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
537 btag.pfBoostedDoubleSVCA15TagInfos.clone(
538 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
540 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
542 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
543 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
544 extSVCollection=svSourceCvsL),
546 if svClustering
or fatJets != cms.InputTag(
''):
547 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
548 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
550 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
551 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
552 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
554 if svClustering
or fatJets != cms.InputTag(
''):
555 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
556 if btagInfo ==
'pfGhostTrackVertexTagInfos':
558 btag.pfGhostTrackVertexTagInfos.clone(
559 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
561 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
563 btag.pfSecondaryVertexNegativeTagInfos.clone(
564 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
567 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
568 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
569 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
570 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
572 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
573 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
574 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+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 ==
'impactParameterTagInfos':
580 btag.impactParameterTagInfos.clone(
581 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
582 primaryVertex=pvSource),
584 if btagInfo ==
'secondaryVertexTagInfos':
586 btag.secondaryVertexTagInfos.clone(
587 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
589 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
591 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
592 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
594 if svClustering
or fatJets != cms.InputTag(
''):
595 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
596 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
598 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
599 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
601 if svClustering
or fatJets != cms.InputTag(
''):
602 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
603 if btagInfo ==
'secondaryVertexNegativeTagInfos':
605 btag.secondaryVertexNegativeTagInfos.clone(
606 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
608 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
610 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
611 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
613 if svClustering
or fatJets != cms.InputTag(
''):
614 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
615 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
617 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
618 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
620 if svClustering
or fatJets != cms.InputTag(
''):
621 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
622 if btagInfo ==
'softMuonTagInfos':
624 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
626 if btagInfo ==
'softPFMuonsTagInfos':
628 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
630 if btagInfo ==
'softPFElectronsTagInfos':
632 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
634 if btagInfo ==
'pixelClusterTagInfos':
636 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
641 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
642 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
643 if pfCandidates.value() ==
'packedPFCandidates':
645 _btagInfo.weights = cms.InputTag(packedPFPuppiLabel)
647 _btagInfo.weights = cms.InputTag(
"puppi")
649 if 'DeepFlavourTagInfos' in btagInfo:
651 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
652 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos' 653 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
656 deep_csv_tag_infos =
'pfDeepCSVTagInfos' 661 if pfCandidates.value() ==
'packedPFCandidates':
663 vertex_associator = cms.InputTag(
"")
665 puppi_value_map = cms.InputTag(
"puppi")
666 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
669 is_weighted_jet =
False 670 if (
'puppi' in jetSource.value().lower()):
671 is_weighted_jet =
True 673 btag.pfDeepFlavourTagInfos.clone(
676 secondary_vertices=svUsed,
677 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
678 puppi_value_map = puppi_value_map,
679 vertex_associator = vertex_associator,
680 is_weighted_jet = is_weighted_jet,
684 if 'ParticleTransformerAK4TagInfos' in btagInfo:
686 if btagInfo ==
'pfNegativeParticleTransformerAK4TagInfos':
687 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
693 if pfCandidates.value() ==
'packedPFCandidates':
695 vertex_associator = cms.InputTag(
"")
697 puppi_value_map = cms.InputTag(
"puppi")
698 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
701 is_weighted_jet =
False 702 if (
'puppi' in jetSource.value().lower()):
703 is_weighted_jet =
True 705 btag.pfParticleTransformerAK4TagInfos.clone(
708 secondary_vertices=svUsed,
709 puppi_value_map = puppi_value_map,
710 vertex_associator = vertex_associator,
711 is_weighted_jet = is_weighted_jet,
714 if btagInfo ==
'pfDeepDoubleXTagInfos':
716 if 'updated' not in jetSource.value().lower():
717 raise ValueError(
"Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
719 puppi_value_map = cms.InputTag(packedPFPuppiLabel)
721 btag.pfDeepDoubleXTagInfos.clone(
724 secondary_vertices=svSource,
725 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
726 puppi_value_map = puppi_value_map,
729 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
731 puppi_value_map = cms.InputTag(packedPFPuppiLabel)
733 btag.pfHiggsInteractionNetTagInfos.clone(
736 secondary_vertices = svSource,
737 pf_candidates = pfCandidates,
738 puppi_value_map = puppi_value_map
742 if btagInfo ==
'pfDeepBoostedJetTagInfos':
743 if pfCandidates.value() ==
'packedPFCandidates':
745 if 'updated' not in jetSource.value().lower():
746 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
748 vertex_associator =
"" 749 elif pfCandidates.value() ==
'particleFlow':
750 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
757 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
759 btag.pfDeepBoostedJetTagInfos.clone(
762 secondary_vertices = svSource,
763 pf_candidates = pfCandidates,
764 puppi_value_map = puppi_value_map,
765 vertex_associator = vertex_associator,
769 if btagInfo ==
'pfParticleNetTagInfos':
770 if pfCandidates.value() ==
'packedPFCandidates':
773 vertex_associator =
"" 774 elif pfCandidates.value() ==
'particleFlow':
775 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
777 puppi_value_map =
"puppi" 778 vertex_associator =
"primaryVertexAssociation:original" 780 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
782 btag.pfParticleNetTagInfos.clone(
785 secondary_vertices = svSource,
786 pf_candidates = pfCandidates,
787 puppi_value_map = puppi_value_map,
788 vertex_associator = vertex_associator,
792 if 'ParticleNetAK4TagInfos' in btagInfo:
793 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
794 secondary_vertices = btagPrefix + \
795 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
799 secondary_vertices = svSource
802 if pfCandidates.value() ==
'packedPFCandidates':
805 vertex_associator =
"" 806 elif pfCandidates.value() ==
'particleFlow':
807 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
809 puppi_value_map =
"puppi" 810 vertex_associator =
"primaryVertexAssociation:original" 812 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
815 if "puppi" in jetSource.value().lower():
818 btag.pfParticleNetAK4TagInfos.clone(
821 secondary_vertices = secondary_vertices,
822 pf_candidates = pfCandidates,
823 puppi_value_map = puppi_value_map,
824 vertex_associator = vertex_associator,
825 flip_ip_sign = flip_ip_sign,
826 sip3dSigMax = sip3dSigMax,
827 use_puppiP4 = use_puppiP4
831 acceptedTagInfos.append(btagInfo)
832 elif hasattr(toptag, btagInfo) :
833 acceptedTagInfos.append(btagInfo)
834 elif btagInfo ==
'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos':
836 if pfCandidates.value() !=
'packedPFCandidates':
837 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
839 pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
842 secondary_vertices = svSource,
843 pf_candidates = pfCandidates,
846 acceptedTagInfos.append(btagInfo)
847 elif btagInfo ==
'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
849 if pfCandidates.value() !=
'packedPFCandidates':
850 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
852 pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
855 secondary_vertices = svSource,
856 pf_candidates = pfCandidates,
859 acceptedTagInfos.append(btagInfo)
860 elif btagInfo ==
'pfParticleNetFromMiniAODAK4CHSCentralTagInfos':
862 if pfCandidates.value() !=
'packedPFCandidates':
863 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
865 pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
868 secondary_vertices = svSource,
869 pf_candidates = pfCandidates,
872 acceptedTagInfos.append(btagInfo)
873 elif btagInfo ==
'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
875 if pfCandidates.value() !=
'packedPFCandidates':
876 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
878 pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
881 secondary_vertices = svSource,
882 pf_candidates = pfCandidates,
885 acceptedTagInfos.append(btagInfo)
886 elif btagInfo ==
'pfParticleNetFromMiniAODAK8TagInfos':
888 if pfCandidates.value() !=
'packedPFCandidates':
889 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
891 pfParticleNetFromMiniAODAK8TagInfos.clone(
894 secondary_vertices = svSource,
895 pf_candidates = pfCandidates,
898 acceptedTagInfos.append(btagInfo)
900 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
902 acceptedBtagDiscriminators = list()
903 for discriminator_name
in btagDiscriminators :
904 btagDiscr = discriminator_name.split(
':')[0]
906 newDiscr = btagPrefix+btagDiscr+labelName+postfix
907 if hasattr(btag,btagDiscr):
908 if hasattr(process, newDiscr):
910 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
913 getattr(btag, btagDiscr).
clone(
914 tagInfos = cms.VInputTag(
915 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
916 for x
in supportedBtagDiscr[discriminator_name][0] ]
922 elif hasattr(getattr(btag, btagDiscr),
'src'):
925 getattr(btag, btagDiscr).
clone(
926 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
932 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
933 acceptedBtagDiscriminators.append(discriminator_name)
934 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
935 if hasattr(process, newDiscr):
939 pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
940 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
945 acceptedBtagDiscriminators.append(discriminator_name)
946 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
947 if hasattr(process, newDiscr):
951 pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
952 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
957 acceptedBtagDiscriminators.append(discriminator_name)
958 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSCentralJetTags':
959 if hasattr(process, newDiscr):
963 pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
964 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
969 acceptedBtagDiscriminators.append(discriminator_name)
970 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSForwardJetTags':
971 if hasattr(process, newDiscr):
975 pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
976 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
981 acceptedBtagDiscriminators.append(discriminator_name)
982 elif btagDiscr==
'pfParticleNetFromMiniAODAK8JetTags':
983 if hasattr(process, newDiscr):
987 pfParticleNetFromMiniAODAK8JetTags.clone(
988 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
993 acceptedBtagDiscriminators.append(discriminator_name)
995 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
998 for meta_tagger
in present_meta:
999 btagDiscr = meta_tagger.split(
':')[0]
1001 newDiscr = btagPrefix+btagDiscr+labelName+postfix
1002 if hasattr(btag,btagDiscr):
1003 if hasattr(process, newDiscr):
1008 getattr(btag, btagDiscr).
clone(),
1012 for dependency
in supportedMetaDiscr[meta_tagger]:
1013 if ':' in dependency:
1014 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1016 new_dep = btagPrefix+dependency+labelName+postfix
1017 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1018 replace.doIt(getattr(process, newDiscr), newDiscr)
1019 acceptedBtagDiscriminators.append(meta_tagger)
1020 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
1021 if hasattr(process, newDiscr):
1026 pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
1030 for dependency
in supportedMetaDiscr[meta_tagger]:
1031 if ':' in dependency:
1032 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1034 new_dep = btagPrefix+dependency+labelName+postfix
1035 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1036 replace.doIt(getattr(process, newDiscr), newDiscr)
1037 acceptedBtagDiscriminators.append(meta_tagger)
1038 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
1039 if hasattr(process, newDiscr):
1044 pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
1048 for dependency
in supportedMetaDiscr[meta_tagger]:
1049 if ':' in dependency:
1050 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1052 new_dep = btagPrefix+dependency+labelName+postfix
1053 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1054 replace.doIt(getattr(process, newDiscr), newDiscr)
1055 acceptedBtagDiscriminators.append(meta_tagger)
1056 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1057 if hasattr(process, newDiscr):
1062 pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1066 for dependency
in supportedMetaDiscr[meta_tagger]:
1067 if ':' in dependency:
1068 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1070 new_dep = btagPrefix+dependency+labelName+postfix
1071 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1072 replace.doIt(getattr(process, newDiscr), newDiscr)
1073 acceptedBtagDiscriminators.append(meta_tagger)
1074 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1075 if hasattr(process, newDiscr):
1080 pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1084 for dependency
in supportedMetaDiscr[meta_tagger]:
1085 if ':' in dependency:
1086 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1088 new_dep = btagPrefix+dependency+labelName+postfix
1089 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1090 replace.doIt(getattr(process, newDiscr), newDiscr)
1091 acceptedBtagDiscriminators.append(meta_tagger)
1092 elif btagDiscr==
'pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1093 if hasattr(process, newDiscr):
1098 pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1102 for dependency
in supportedMetaDiscr[meta_tagger]:
1103 if ':' in dependency:
1104 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1106 new_dep = btagPrefix+dependency+labelName+postfix
1107 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1108 replace.doIt(getattr(process, newDiscr), newDiscr)
1109 acceptedBtagDiscriminators.append(meta_tagger)
1112 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1115 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
1116 patJets.discriminatorSources = cms.VInputTag(*[
1117 cms.InputTag(btagPrefix+x+labelName+postfix) \
1118 if ':' not in x
else \
1119 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
1120 for x
in acceptedBtagDiscriminators
1122 if len(acceptedBtagDiscriminators) > 0 :
1123 patJets.addBTagInfo =
True 1126 if not tightBTagNTkHits:
1127 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1132 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1133 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
1134 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1135 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1136 if tightBTagNTkHits:
1137 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1138 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
1139 _temp.minHits = cms.uint32(8)
1141 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1142 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1143 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
1144 _temp.primaryVertices = pvSource
1145 _temp.tracks = pfCandidates
1146 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
1147 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
1148 _temp.primaryVertices = pvSource
1149 _temp.tracks = pfCandidates
1150 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
1152 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
1154 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
1155 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1156 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1157 if tightBTagNTkHits:
1158 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1159 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
1160 _temp.minHits = cms.uint32(8)
1162 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1163 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1164 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
1165 _temp.primaryVertices = pvSource
1166 _temp.tracks = pfCandidates
1167 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
1168 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
1169 _temp.primaryVertices = pvSource
1170 _temp.tracks = pfCandidates
1171 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1173 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
1175 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1176 if not hasattr( process,
'inclusiveVertexing' ):
1177 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1178 task.add(process.inclusiveVertexingTask)
1179 task.add(process.inclusiveCandidateVertexingTask)
1180 task.add(process.inclusiveCandidateVertexingCvsLTask)
1181 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1182 if not hasattr( process,
'inclusiveVertexing' ):
1183 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1184 task.add(process.inclusiveVertexingTask)
1185 task.add(process.inclusiveCandidateVertexingTask)
1186 task.add(process.inclusiveCandidateVertexingCvsLTask)
1187 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1188 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
1189 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1190 task.add(process.inclusiveSecondaryVerticesFiltered)
1191 task.add(process.bVertexFilter)
1192 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
1193 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1194 task.add(process.bToCharmDecayVertexMerged)
1195 if 'caTopTagInfos' in acceptedTagInfos :
1196 patJets.addTagInfos =
True 1197 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
1198 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
1199 task.add(process.caTopTaggersTask)
bool any(const std::vector< T > &v, const T &what)
def addToProcessAndTask(label, module, process, task)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
def getPatAlgosToolsTask(process)