254 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
259 discriminators = set(btagDiscriminators)
260 present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
261 discriminators -= present_metaSet
262 for meta_tagger
in present_metaSet:
263 for src
in supportedMetaDiscr[meta_tagger]:
264 discriminators.add(src)
265 present_meta = sorted(present_metaSet)
266 btagDiscriminators = sorted(discriminators)
270 requiredTagInfos = list(btagInfos)
271 for btagDiscr
in btagDiscriminators :
272 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
273 for requiredTagInfo
in tagInfoList :
274 tagInfoCovered =
False 275 for tagInfo
in requiredTagInfos :
276 if requiredTagInfo == tagInfo :
277 tagInfoCovered =
True 279 if not tagInfoCovered :
280 requiredTagInfos.append(requiredTagInfo)
282 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
284 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
285 task.add(process.impactParameterTask)
286 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
287 task.add(process.secondaryVertexTask)
288 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
289 task.add(process.softLeptonTask)
290 process.load(
"RecoBTag.Combined.combinedMVA_cff")
291 task.add(process.combinedMVATask)
292 process.load(
"RecoBTag.CTagging.cTagging_cff")
293 task.add(process.cTaggingTask)
295 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
296 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
297 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
298 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
299 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
301 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
305 sys.stderr.write(
"-------------------------------------------------------------------\n")
306 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
307 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
308 sys.stderr.write(
"-------------------------------------------------------------------\n")
310 sys.stderr.write(
"-------------------------------------------------------------------\n")
311 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
312 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
313 sys.stderr.write(
" avoid unintentional modifications to the default\n")
314 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
315 sys.stderr.write(
"-------------------------------------------------------------------\n")
319 svSourceCvsL = copy.deepcopy(svSource)
320 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
323 runIVFforCTagOnly =
False 324 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
326 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
327 runIVFforCTagOnly =
True 329 sys.stderr.write(
"-------------------------------------------------------------------\n")
330 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
331 sys.stderr.write(
" vertices will be remade.\n")
332 sys.stderr.write(
"-------------------------------------------------------------------\n")
334 if runIVF
and btagPrefix !=
'':
335 if runIVFforCTagOnly:
336 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
338 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
339 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
345 runNegativeVertexing =
False 346 runNegativeCvsLVertexing =
False 347 for btagInfo
in requiredTagInfos:
349 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
350 'pfNegativeDeepFlavourTagInfos',
351 'pfNegativeParticleNetAK4TagInfos',
353 runNegativeVertexing =
True 354 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
355 runNegativeCvsLVertexing =
True 357 if runNegativeVertexing
or runNegativeCvsLVertexing:
358 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
360 if runNegativeVertexing:
362 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
365 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
368 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
369 ,primaryVertices = pvSource
370 ,tracks=pfCandidates),
372 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
373 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
376 if runNegativeCvsLVertexing:
377 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
378 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
381 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
384 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
385 ,primaryVertices = pvSource
386 ,tracks=pfCandidates),
388 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
389 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
393 acceptedTagInfos = list()
394 for btagInfo
in requiredTagInfos:
395 if hasattr(btag,btagInfo):
396 if btagInfo ==
'pfImpactParameterTagInfos':
398 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
401 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
402 _btagInfo.explicitJTA = cms.bool(explicitJTA)
404 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
405 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
406 _btagInfo.minimumNumberOfHits = cms.int32(8)
407 if btagInfo ==
'pfImpactParameterAK8TagInfos':
409 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
412 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
413 _btagInfo.explicitJTA = cms.bool(explicitJTA)
415 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
416 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
417 _btagInfo.minimumNumberOfHits = cms.int32(8)
418 if btagInfo ==
'pfImpactParameterCA15TagInfos':
420 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
423 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
424 _btagInfo.explicitJTA = cms.bool(explicitJTA)
426 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
427 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
428 _btagInfo.minimumNumberOfHits = cms.int32(8)
429 if btagInfo ==
'pfSecondaryVertexTagInfos':
431 btag.pfSecondaryVertexTagInfos.clone(
432 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
435 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
436 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
437 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
438 if btagInfo ==
'pfDeepCSVTagInfos':
440 btag.pfDeepCSVTagInfos.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 ==
'pfDeepCSVNegativeTagInfos':
447 btag.pfDeepCSVNegativeTagInfos.clone(
448 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
450 if svClustering
or fatJets != cms.InputTag(
''):
451 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
452 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
454 btag.pfDeepCSVPositiveTagInfos.clone(
455 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+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 ==
'pfDeepCMVATagInfos':
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 ==
'pfDeepCMVANegativeTagInfos':
471 btag.pfDeepCMVATagInfos.clone(
472 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
473 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
474 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
475 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
477 if svClustering
or fatJets != cms.InputTag(
''):
478 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
479 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
481 btag.pfDeepCMVATagInfos.clone(
482 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
483 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
484 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
485 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
487 if svClustering
or fatJets != cms.InputTag(
''):
488 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
489 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
491 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
492 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
493 extSVCollection=svSource),
495 if svClustering
or fatJets != cms.InputTag(
''):
496 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
497 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
499 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
500 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
501 extSVCollection=svSource),
503 if svClustering
or fatJets != cms.InputTag(
''):
504 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
505 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
507 btag.pfBoostedDoubleSVAK8TagInfos.clone(
508 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
510 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
512 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
513 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
514 extSVCollection=svSource),
516 if svClustering
or fatJets != cms.InputTag(
''):
517 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
518 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
520 btag.pfBoostedDoubleSVCA15TagInfos.clone(
521 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
523 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
525 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
526 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
527 extSVCollection=svSourceCvsL),
529 if svClustering
or fatJets != cms.InputTag(
''):
530 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
531 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
533 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
534 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
535 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
537 if svClustering
or fatJets != cms.InputTag(
''):
538 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
539 if btagInfo ==
'pfGhostTrackVertexTagInfos':
541 btag.pfGhostTrackVertexTagInfos.clone(
542 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
544 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
546 btag.pfSecondaryVertexNegativeTagInfos.clone(
547 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
550 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
551 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
552 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
553 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
555 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
556 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
557 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
559 if svClustering
or fatJets != cms.InputTag(
''):
560 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
561 if btagInfo ==
'impactParameterTagInfos':
563 btag.impactParameterTagInfos.clone(
564 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
565 primaryVertex=pvSource),
567 if btagInfo ==
'secondaryVertexTagInfos':
569 btag.secondaryVertexTagInfos.clone(
570 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
572 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
574 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
575 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
577 if svClustering
or fatJets != cms.InputTag(
''):
578 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
579 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
581 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
582 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
584 if svClustering
or fatJets != cms.InputTag(
''):
585 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
586 if btagInfo ==
'secondaryVertexNegativeTagInfos':
588 btag.secondaryVertexNegativeTagInfos.clone(
589 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
591 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
593 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
594 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
596 if svClustering
or fatJets != cms.InputTag(
''):
597 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
598 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
600 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
601 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
603 if svClustering
or fatJets != cms.InputTag(
''):
604 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
605 if btagInfo ==
'softMuonTagInfos':
607 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
609 if btagInfo ==
'softPFMuonsTagInfos':
611 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
613 if btagInfo ==
'softPFElectronsTagInfos':
615 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
617 if btagInfo ==
'pixelClusterTagInfos':
619 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
624 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
625 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
626 if pfCandidates.value() ==
'packedPFCandidates':
628 _btagInfo.weights = cms.InputTag(packedPuppiName)
630 _btagInfo.weights = cms.InputTag(
"puppi")
632 if 'DeepFlavourTagInfos' in btagInfo:
634 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
635 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos' 636 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
639 deep_csv_tag_infos =
'pfDeepCSVTagInfos' 644 if pfCandidates.value() ==
'packedPFCandidates':
646 vertex_associator = cms.InputTag(
"")
648 puppi_value_map = cms.InputTag(
"puppi")
649 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
652 is_weighted_jet =
False 653 if (
'puppi' in jetSource.value().lower()):
654 is_weighted_jet =
True 656 btag.pfDeepFlavourTagInfos.clone(
659 secondary_vertices=svUsed,
660 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
661 puppi_value_map = puppi_value_map,
662 vertex_associator = vertex_associator,
663 is_weighted_jet = is_weighted_jet,
667 if 'ParticleTransformerAK4TagInfos' in btagInfo:
669 if btagInfo ==
'pfNegativeParticleTransformerAK4TagInfos':
670 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
676 if pfCandidates.value() ==
'packedPFCandidates':
678 vertex_associator = cms.InputTag(
"")
680 puppi_value_map = cms.InputTag(
"puppi")
681 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
684 is_weighted_jet =
False 685 if (
'puppi' in jetSource.value().lower()):
686 is_weighted_jet =
True 688 btag.pfParticleTransformerAK4TagInfos.clone(
691 secondary_vertices=svUsed,
692 puppi_value_map = puppi_value_map,
693 vertex_associator = vertex_associator,
694 is_weighted_jet = is_weighted_jet,
698 if btagInfo ==
'pfDeepDoubleXTagInfos':
700 if 'updated' not in jetSource.value().lower():
701 raise ValueError(
"Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
703 puppi_value_map = cms.InputTag(packedPuppiName)
705 btag.pfDeepDoubleXTagInfos.clone(
708 secondary_vertices=svSource,
709 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
710 puppi_value_map = puppi_value_map,
714 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
716 puppi_value_map = cms.InputTag(packedPuppiName)
718 btag.pfHiggsInteractionNetTagInfos.clone(
721 secondary_vertices = svSource,
722 pf_candidates = pfCandidates,
723 puppi_value_map = puppi_value_map
727 if btagInfo ==
'pfDeepBoostedJetTagInfos':
728 if pfCandidates.value() ==
'packedPFCandidates':
730 if 'updated' not in jetSource.value().lower():
731 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
733 vertex_associator =
"" 734 elif pfCandidates.value() ==
'particleFlow':
735 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
742 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
744 btag.pfDeepBoostedJetTagInfos.clone(
747 secondary_vertices = svSource,
748 pf_candidates = pfCandidates,
749 puppi_value_map = puppi_value_map,
750 vertex_associator = vertex_associator,
754 if btagInfo ==
'pfParticleNetTagInfos':
755 if pfCandidates.value() ==
'packedPFCandidates':
758 vertex_associator =
"" 759 elif pfCandidates.value() ==
'particleFlow':
760 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
762 puppi_value_map =
"puppi" 763 vertex_associator =
"primaryVertexAssociation:original" 765 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
767 btag.pfParticleNetTagInfos.clone(
770 secondary_vertices = svSource,
771 pf_candidates = pfCandidates,
772 puppi_value_map = puppi_value_map,
773 vertex_associator = vertex_associator,
777 if 'ParticleNetAK4TagInfos' in btagInfo:
778 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
779 secondary_vertices = btagPrefix + \
780 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
784 secondary_vertices = svSource
787 if pfCandidates.value() ==
'packedPFCandidates':
790 vertex_associator =
"" 791 elif pfCandidates.value() ==
'particleFlow':
792 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
794 puppi_value_map =
"puppi" 795 vertex_associator =
"primaryVertexAssociation:original" 797 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
800 if "puppi" in jetSource.value().lower():
803 btag.pfParticleNetAK4TagInfos.clone(
806 secondary_vertices = secondary_vertices,
807 pf_candidates = pfCandidates,
808 puppi_value_map = puppi_value_map,
809 vertex_associator = vertex_associator,
810 flip_ip_sign = flip_ip_sign,
811 sip3dSigMax = sip3dSigMax,
812 use_puppiP4 = use_puppiP4
816 acceptedTagInfos.append(btagInfo)
817 elif hasattr(toptag, btagInfo) :
818 acceptedTagInfos.append(btagInfo)
819 elif btagInfo ==
'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos':
821 if pfCandidates.value() !=
'packedPFCandidates':
822 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
824 pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
827 secondary_vertices = svSource,
828 pf_candidates = pfCandidates,
831 acceptedTagInfos.append(btagInfo)
832 elif btagInfo ==
'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
834 if pfCandidates.value() !=
'packedPFCandidates':
835 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
837 pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
840 secondary_vertices = svSource,
841 pf_candidates = pfCandidates,
844 acceptedTagInfos.append(btagInfo)
845 elif btagInfo ==
'pfParticleNetFromMiniAODAK4CHSCentralTagInfos':
847 if pfCandidates.value() !=
'packedPFCandidates':
848 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
850 pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
853 secondary_vertices = svSource,
854 pf_candidates = pfCandidates,
857 acceptedTagInfos.append(btagInfo)
858 elif btagInfo ==
'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
860 if pfCandidates.value() !=
'packedPFCandidates':
861 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
863 pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
866 secondary_vertices = svSource,
867 pf_candidates = pfCandidates,
870 acceptedTagInfos.append(btagInfo)
871 elif btagInfo ==
'pfParticleNetFromMiniAODAK8TagInfos':
873 if pfCandidates.value() !=
'packedPFCandidates':
874 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
876 pfParticleNetFromMiniAODAK8TagInfos.clone(
879 secondary_vertices = svSource,
880 pf_candidates = pfCandidates,
883 acceptedTagInfos.append(btagInfo)
885 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
887 acceptedBtagDiscriminators = list()
888 for discriminator_name
in btagDiscriminators :
889 btagDiscr = discriminator_name.split(
':')[0]
891 newDiscr = btagPrefix+btagDiscr+labelName+postfix
892 if hasattr(btag,btagDiscr):
893 if hasattr(process, newDiscr):
895 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
898 getattr(btag, btagDiscr).
clone(
899 tagInfos = cms.VInputTag(
900 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
901 for x
in supportedBtagDiscr[discriminator_name][0] ]
907 elif hasattr(getattr(btag, btagDiscr),
'src'):
910 getattr(btag, btagDiscr).
clone(
911 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
917 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
918 acceptedBtagDiscriminators.append(discriminator_name)
919 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
920 if hasattr(process, newDiscr):
924 pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
925 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
930 acceptedBtagDiscriminators.append(discriminator_name)
931 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
932 if hasattr(process, newDiscr):
936 pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
937 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
942 acceptedBtagDiscriminators.append(discriminator_name)
943 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSCentralJetTags':
944 if hasattr(process, newDiscr):
948 pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
949 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
954 acceptedBtagDiscriminators.append(discriminator_name)
955 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSForwardJetTags':
956 if hasattr(process, newDiscr):
960 pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
961 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
966 acceptedBtagDiscriminators.append(discriminator_name)
967 elif btagDiscr==
'pfParticleNetFromMiniAODAK8JetTags':
968 if hasattr(process, newDiscr):
972 pfParticleNetFromMiniAODAK8JetTags.clone(
973 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
978 acceptedBtagDiscriminators.append(discriminator_name)
980 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
983 for meta_tagger
in present_meta:
984 btagDiscr = meta_tagger.split(
':')[0]
986 newDiscr = btagPrefix+btagDiscr+labelName+postfix
987 if hasattr(btag,btagDiscr):
988 if hasattr(process, newDiscr):
993 getattr(btag, btagDiscr).
clone(),
997 for dependency
in supportedMetaDiscr[meta_tagger]:
998 if ':' in dependency:
999 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1001 new_dep = btagPrefix+dependency+labelName+postfix
1002 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1003 replace.doIt(getattr(process, newDiscr), newDiscr)
1004 acceptedBtagDiscriminators.append(meta_tagger)
1005 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
1006 if hasattr(process, newDiscr):
1011 pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
1015 for dependency
in supportedMetaDiscr[meta_tagger]:
1016 if ':' in dependency:
1017 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1019 new_dep = btagPrefix+dependency+labelName+postfix
1020 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1021 replace.doIt(getattr(process, newDiscr), newDiscr)
1022 acceptedBtagDiscriminators.append(meta_tagger)
1023 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
1024 if hasattr(process, newDiscr):
1029 pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
1033 for dependency
in supportedMetaDiscr[meta_tagger]:
1034 if ':' in dependency:
1035 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1037 new_dep = btagPrefix+dependency+labelName+postfix
1038 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1039 replace.doIt(getattr(process, newDiscr), newDiscr)
1040 acceptedBtagDiscriminators.append(meta_tagger)
1041 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1042 if hasattr(process, newDiscr):
1047 pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1051 for dependency
in supportedMetaDiscr[meta_tagger]:
1052 if ':' in dependency:
1053 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1055 new_dep = btagPrefix+dependency+labelName+postfix
1056 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1057 replace.doIt(getattr(process, newDiscr), newDiscr)
1058 acceptedBtagDiscriminators.append(meta_tagger)
1059 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1060 if hasattr(process, newDiscr):
1065 pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1069 for dependency
in supportedMetaDiscr[meta_tagger]:
1070 if ':' in dependency:
1071 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1073 new_dep = btagPrefix+dependency+labelName+postfix
1074 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1075 replace.doIt(getattr(process, newDiscr), newDiscr)
1076 acceptedBtagDiscriminators.append(meta_tagger)
1077 elif btagDiscr==
'pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1078 if hasattr(process, newDiscr):
1083 pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1087 for dependency
in supportedMetaDiscr[meta_tagger]:
1088 if ':' in dependency:
1089 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1091 new_dep = btagPrefix+dependency+labelName+postfix
1092 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1093 replace.doIt(getattr(process, newDiscr), newDiscr)
1094 acceptedBtagDiscriminators.append(meta_tagger)
1097 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1100 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
1101 patJets.discriminatorSources = cms.VInputTag(*[
1102 cms.InputTag(btagPrefix+x+labelName+postfix) \
1103 if ':' not in x
else \
1104 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
1105 for x
in acceptedBtagDiscriminators
1107 if len(acceptedBtagDiscriminators) > 0 :
1108 patJets.addBTagInfo =
True 1111 if not tightBTagNTkHits:
1112 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1117 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1118 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
1119 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1120 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1121 if tightBTagNTkHits:
1122 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1123 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
1124 _temp.minHits = cms.uint32(8)
1126 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1127 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1128 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
1129 _temp.primaryVertices = pvSource
1130 _temp.tracks = pfCandidates
1131 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
1132 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
1133 _temp.primaryVertices = pvSource
1134 _temp.tracks = pfCandidates
1135 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
1137 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
1139 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
1140 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1141 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1142 if tightBTagNTkHits:
1143 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1144 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
1145 _temp.minHits = cms.uint32(8)
1147 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1148 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1149 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
1150 _temp.primaryVertices = pvSource
1151 _temp.tracks = pfCandidates
1152 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
1153 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
1154 _temp.primaryVertices = pvSource
1155 _temp.tracks = pfCandidates
1156 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1158 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
1160 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1161 if not hasattr( process,
'inclusiveVertexing' ):
1162 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1163 task.add(process.inclusiveVertexingTask)
1164 task.add(process.inclusiveCandidateVertexingTask)
1165 task.add(process.inclusiveCandidateVertexingCvsLTask)
1166 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1167 if not hasattr( process,
'inclusiveVertexing' ):
1168 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1169 task.add(process.inclusiveVertexingTask)
1170 task.add(process.inclusiveCandidateVertexingTask)
1171 task.add(process.inclusiveCandidateVertexingCvsLTask)
1172 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1173 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
1174 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1175 task.add(process.inclusiveSecondaryVerticesFiltered)
1176 task.add(process.bVertexFilter)
1177 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
1178 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1179 task.add(process.bToCharmDecayVertexMerged)
1180 if 'caTopTagInfos' in acceptedTagInfos :
1181 patJets.addTagInfos =
True 1182 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
1183 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
1184 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)