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 btagInfo ==
'pfDeepDoubleXTagInfos':
669 if 'updated' not in jetSource.value().lower():
670 raise ValueError(
"Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
672 puppi_value_map = cms.InputTag(packedPuppiName)
674 btag.pfDeepDoubleXTagInfos.clone(
677 secondary_vertices=svSource,
678 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
679 puppi_value_map = puppi_value_map,
683 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
685 puppi_value_map = cms.InputTag(packedPuppiName)
687 btag.pfHiggsInteractionNetTagInfos.clone(
690 secondary_vertices = svSource,
691 pf_candidates = pfCandidates,
692 puppi_value_map = puppi_value_map
696 if btagInfo ==
'pfDeepBoostedJetTagInfos':
697 if pfCandidates.value() ==
'packedPFCandidates':
699 if 'updated' not in jetSource.value().lower():
700 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
702 vertex_associator =
"" 703 elif pfCandidates.value() ==
'particleFlow':
704 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
711 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
713 btag.pfDeepBoostedJetTagInfos.clone(
716 secondary_vertices = svSource,
717 pf_candidates = pfCandidates,
718 puppi_value_map = puppi_value_map,
719 vertex_associator = vertex_associator,
723 if btagInfo ==
'pfParticleNetTagInfos':
724 if pfCandidates.value() ==
'packedPFCandidates':
727 vertex_associator =
"" 728 elif pfCandidates.value() ==
'particleFlow':
729 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
731 puppi_value_map =
"puppi" 732 vertex_associator =
"primaryVertexAssociation:original" 734 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
736 btag.pfParticleNetTagInfos.clone(
739 secondary_vertices = svSource,
740 pf_candidates = pfCandidates,
741 puppi_value_map = puppi_value_map,
742 vertex_associator = vertex_associator,
746 if 'ParticleNetAK4TagInfos' in btagInfo:
747 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
748 secondary_vertices = btagPrefix + \
749 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
753 secondary_vertices = svSource
756 if pfCandidates.value() ==
'packedPFCandidates':
759 vertex_associator =
"" 760 elif pfCandidates.value() ==
'particleFlow':
761 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
763 puppi_value_map =
"puppi" 764 vertex_associator =
"primaryVertexAssociation:original" 766 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
769 if "puppi" in jetSource.value().lower():
772 btag.pfParticleNetAK4TagInfos.clone(
775 secondary_vertices = secondary_vertices,
776 pf_candidates = pfCandidates,
777 puppi_value_map = puppi_value_map,
778 vertex_associator = vertex_associator,
779 flip_ip_sign = flip_ip_sign,
780 sip3dSigMax = sip3dSigMax,
781 use_puppiP4 = use_puppiP4
785 acceptedTagInfos.append(btagInfo)
786 elif hasattr(toptag, btagInfo) :
787 acceptedTagInfos.append(btagInfo)
788 elif btagInfo ==
'pfParticleNetFromMiniAODAK4PuppiCentralTagInfos':
790 if pfCandidates.value() !=
'packedPFCandidates':
791 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
793 pfParticleNetFromMiniAODAK4PuppiCentralTagInfos.clone(
796 secondary_vertices = svSource,
797 pf_candidates = pfCandidates,
800 acceptedTagInfos.append(btagInfo)
801 elif btagInfo ==
'pfParticleNetFromMiniAODAK4PuppiForwardTagInfos':
803 if pfCandidates.value() !=
'packedPFCandidates':
804 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
806 pfParticleNetFromMiniAODAK4PuppiForwardTagInfos.clone(
809 secondary_vertices = svSource,
810 pf_candidates = pfCandidates,
813 acceptedTagInfos.append(btagInfo)
814 elif btagInfo ==
'pfParticleNetFromMiniAODAK4CHSCentralTagInfos':
816 if pfCandidates.value() !=
'packedPFCandidates':
817 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
819 pfParticleNetFromMiniAODAK4CHSCentralTagInfos.clone(
822 secondary_vertices = svSource,
823 pf_candidates = pfCandidates,
826 acceptedTagInfos.append(btagInfo)
827 elif btagInfo ==
'pfParticleNetFromMiniAODAK4CHSForwardTagInfos':
829 if pfCandidates.value() !=
'packedPFCandidates':
830 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
832 pfParticleNetFromMiniAODAK4CHSForwardTagInfos.clone(
835 secondary_vertices = svSource,
836 pf_candidates = pfCandidates,
839 acceptedTagInfos.append(btagInfo)
840 elif btagInfo ==
'pfParticleNetFromMiniAODAK8TagInfos':
842 if pfCandidates.value() !=
'packedPFCandidates':
843 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
845 pfParticleNetFromMiniAODAK8TagInfos.clone(
848 secondary_vertices = svSource,
849 pf_candidates = pfCandidates,
852 acceptedTagInfos.append(btagInfo)
854 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
856 acceptedBtagDiscriminators = list()
857 for discriminator_name
in btagDiscriminators :
858 btagDiscr = discriminator_name.split(
':')[0]
860 newDiscr = btagPrefix+btagDiscr+labelName+postfix
861 if hasattr(btag,btagDiscr):
862 if hasattr(process, newDiscr):
864 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
867 getattr(btag, btagDiscr).
clone(
868 tagInfos = cms.VInputTag(
869 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
870 for x
in supportedBtagDiscr[discriminator_name][0] ]
876 elif hasattr(getattr(btag, btagDiscr),
'src'):
879 getattr(btag, btagDiscr).
clone(
880 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
886 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
887 acceptedBtagDiscriminators.append(discriminator_name)
888 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiCentralJetTags':
889 if hasattr(process, newDiscr):
893 pfParticleNetFromMiniAODAK4PuppiCentralJetTags.clone(
894 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
899 acceptedBtagDiscriminators.append(discriminator_name)
900 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiForwardJetTags':
901 if hasattr(process, newDiscr):
905 pfParticleNetFromMiniAODAK4PuppiForwardJetTags.clone(
906 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
911 acceptedBtagDiscriminators.append(discriminator_name)
912 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSCentralJetTags':
913 if hasattr(process, newDiscr):
917 pfParticleNetFromMiniAODAK4CHSCentralJetTags.clone(
918 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
923 acceptedBtagDiscriminators.append(discriminator_name)
924 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSForwardJetTags':
925 if hasattr(process, newDiscr):
929 pfParticleNetFromMiniAODAK4CHSForwardJetTags.clone(
930 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
935 acceptedBtagDiscriminators.append(discriminator_name)
936 elif btagDiscr==
'pfParticleNetFromMiniAODAK8JetTags':
937 if hasattr(process, newDiscr):
941 pfParticleNetFromMiniAODAK8JetTags.clone(
942 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
947 acceptedBtagDiscriminators.append(discriminator_name)
949 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
952 for meta_tagger
in present_meta:
953 btagDiscr = meta_tagger.split(
':')[0]
955 newDiscr = btagPrefix+btagDiscr+labelName+postfix
956 if hasattr(btag,btagDiscr):
957 if hasattr(process, newDiscr):
962 getattr(btag, btagDiscr).
clone(),
966 for dependency
in supportedMetaDiscr[meta_tagger]:
967 if ':' in dependency:
968 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
970 new_dep = btagPrefix+dependency+labelName+postfix
971 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
972 replace.doIt(getattr(process, newDiscr), newDiscr)
973 acceptedBtagDiscriminators.append(meta_tagger)
974 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags':
975 if hasattr(process, newDiscr):
980 pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags.clone(),
984 for dependency
in supportedMetaDiscr[meta_tagger]:
985 if ':' in dependency:
986 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
988 new_dep = btagPrefix+dependency+labelName+postfix
989 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
990 replace.doIt(getattr(process, newDiscr), newDiscr)
991 acceptedBtagDiscriminators.append(meta_tagger)
992 elif btagDiscr==
'pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags':
993 if hasattr(process, newDiscr):
998 pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags.clone(),
1002 for dependency
in supportedMetaDiscr[meta_tagger]:
1003 if ':' in dependency:
1004 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1006 new_dep = btagPrefix+dependency+labelName+postfix
1007 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1008 replace.doIt(getattr(process, newDiscr), newDiscr)
1009 acceptedBtagDiscriminators.append(meta_tagger)
1010 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags':
1011 if hasattr(process, newDiscr):
1016 pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags.clone(),
1020 for dependency
in supportedMetaDiscr[meta_tagger]:
1021 if ':' in dependency:
1022 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1024 new_dep = btagPrefix+dependency+labelName+postfix
1025 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1026 replace.doIt(getattr(process, newDiscr), newDiscr)
1027 acceptedBtagDiscriminators.append(meta_tagger)
1028 elif btagDiscr==
'pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags':
1029 if hasattr(process, newDiscr):
1034 pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags.clone(),
1038 for dependency
in supportedMetaDiscr[meta_tagger]:
1039 if ':' in dependency:
1040 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1042 new_dep = btagPrefix+dependency+labelName+postfix
1043 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1044 replace.doIt(getattr(process, newDiscr), newDiscr)
1045 acceptedBtagDiscriminators.append(meta_tagger)
1046 elif btagDiscr==
'pfParticleNetFromMiniAODAK8DiscriminatorsJetTags':
1047 if hasattr(process, newDiscr):
1052 pfParticleNetFromMiniAODAK8DiscriminatorsJetTags.clone(),
1056 for dependency
in supportedMetaDiscr[meta_tagger]:
1057 if ':' in dependency:
1058 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
1060 new_dep = btagPrefix+dependency+labelName+postfix
1061 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
1062 replace.doIt(getattr(process, newDiscr), newDiscr)
1063 acceptedBtagDiscriminators.append(meta_tagger)
1066 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
1069 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
1070 patJets.discriminatorSources = cms.VInputTag(*[
1071 cms.InputTag(btagPrefix+x+labelName+postfix) \
1072 if ':' not in x
else \
1073 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
1074 for x
in acceptedBtagDiscriminators
1076 if len(acceptedBtagDiscriminators) > 0 :
1077 patJets.addBTagInfo =
True 1080 if not tightBTagNTkHits:
1081 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1086 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
1087 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
1088 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1089 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1090 if tightBTagNTkHits:
1091 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1092 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
1093 _temp.minHits = cms.uint32(8)
1095 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1096 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
1097 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
1098 _temp.primaryVertices = pvSource
1099 _temp.tracks = pfCandidates
1100 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
1101 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
1102 _temp.primaryVertices = pvSource
1103 _temp.tracks = pfCandidates
1104 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
1106 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
1108 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
1109 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1110 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
1111 if tightBTagNTkHits:
1112 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1113 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
1114 _temp.minHits = cms.uint32(8)
1116 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
1117 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
1118 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
1119 _temp.primaryVertices = pvSource
1120 _temp.tracks = pfCandidates
1121 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
1122 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
1123 _temp.primaryVertices = pvSource
1124 _temp.tracks = pfCandidates
1125 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
1127 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
1129 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
1130 if not hasattr( process,
'inclusiveVertexing' ):
1131 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1132 task.add(process.inclusiveVertexingTask)
1133 task.add(process.inclusiveCandidateVertexingTask)
1134 task.add(process.inclusiveCandidateVertexingCvsLTask)
1135 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1136 if not hasattr( process,
'inclusiveVertexing' ):
1137 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
1138 task.add(process.inclusiveVertexingTask)
1139 task.add(process.inclusiveCandidateVertexingTask)
1140 task.add(process.inclusiveCandidateVertexingCvsLTask)
1141 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
1142 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
1143 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
1144 task.add(process.inclusiveSecondaryVerticesFiltered)
1145 task.add(process.bVertexFilter)
1146 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
1147 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
1148 task.add(process.bToCharmDecayVertexMerged)
1149 if 'caTopTagInfos' in acceptedTagInfos :
1150 patJets.addTagInfos =
True 1151 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
1152 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
1153 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)