239 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
244 discriminators = set(btagDiscriminators)
245 present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
246 discriminators -= present_metaSet
247 for meta_tagger
in present_metaSet:
248 for src
in supportedMetaDiscr[meta_tagger]:
249 discriminators.add(src)
250 present_meta = sorted(present_metaSet)
251 btagDiscriminators = sorted(discriminators)
255 requiredTagInfos = list(btagInfos)
256 for btagDiscr
in btagDiscriminators :
257 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
258 for requiredTagInfo
in tagInfoList :
259 tagInfoCovered =
False 260 for tagInfo
in requiredTagInfos :
261 if requiredTagInfo == tagInfo :
262 tagInfoCovered =
True 264 if not tagInfoCovered :
265 requiredTagInfos.append(requiredTagInfo)
267 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
269 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
270 task.add(process.impactParameterTask)
271 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
272 task.add(process.secondaryVertexTask)
273 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
274 task.add(process.softLeptonTask)
275 process.load(
"RecoBTag.Combined.combinedMVA_cff")
276 task.add(process.combinedMVATask)
277 process.load(
"RecoBTag.CTagging.cTagging_cff")
278 task.add(process.cTaggingTask)
280 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
281 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
282 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
283 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
284 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
286 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
290 sys.stderr.write(
"-------------------------------------------------------------------\n")
291 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
292 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
293 sys.stderr.write(
"-------------------------------------------------------------------\n")
295 sys.stderr.write(
"-------------------------------------------------------------------\n")
296 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
297 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
298 sys.stderr.write(
" avoid unintentional modifications to the default\n")
299 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
300 sys.stderr.write(
"-------------------------------------------------------------------\n")
304 svSourceCvsL = copy.deepcopy(svSource)
305 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
308 runIVFforCTagOnly =
False 309 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
311 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
312 runIVFforCTagOnly =
True 314 sys.stderr.write(
"-------------------------------------------------------------------\n")
315 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
316 sys.stderr.write(
" vertices will be remade.\n")
317 sys.stderr.write(
"-------------------------------------------------------------------\n")
319 if runIVF
and btagPrefix !=
'':
320 if runIVFforCTagOnly:
321 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
323 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
324 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
330 runNegativeVertexing =
False 331 runNegativeCvsLVertexing =
False 332 for btagInfo
in requiredTagInfos:
334 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
335 'pfNegativeDeepFlavourTagInfos',
336 'pfNegativeParticleNetAK4TagInfos',
338 runNegativeVertexing =
True 339 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
340 runNegativeCvsLVertexing =
True 342 if runNegativeVertexing
or runNegativeCvsLVertexing:
343 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
345 if runNegativeVertexing:
347 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
350 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
353 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
354 ,primaryVertices = pvSource
355 ,tracks=pfCandidates),
357 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
358 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
361 if runNegativeCvsLVertexing:
362 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
363 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
366 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
369 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
370 ,primaryVertices = pvSource
371 ,tracks=pfCandidates),
373 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
374 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
378 acceptedTagInfos = list()
379 for btagInfo
in requiredTagInfos:
380 if hasattr(btag,btagInfo):
381 if btagInfo ==
'pfImpactParameterTagInfos':
383 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
386 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
387 _btagInfo.explicitJTA = cms.bool(explicitJTA)
389 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
390 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
391 _btagInfo.minimumNumberOfHits = cms.int32(8)
392 if btagInfo ==
'pfImpactParameterAK8TagInfos':
394 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
397 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
398 _btagInfo.explicitJTA = cms.bool(explicitJTA)
400 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
401 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
402 _btagInfo.minimumNumberOfHits = cms.int32(8)
403 if btagInfo ==
'pfImpactParameterCA15TagInfos':
405 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
408 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
409 _btagInfo.explicitJTA = cms.bool(explicitJTA)
411 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
412 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
413 _btagInfo.minimumNumberOfHits = cms.int32(8)
414 if btagInfo ==
'pfSecondaryVertexTagInfos':
416 btag.pfSecondaryVertexTagInfos.clone(
417 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
420 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
421 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
422 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
423 if btagInfo ==
'pfDeepCSVTagInfos':
425 btag.pfDeepCSVTagInfos.clone(
426 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
428 if svClustering
or fatJets != cms.InputTag(
''):
429 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
430 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
432 btag.pfDeepCSVNegativeTagInfos.clone(
433 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
435 if svClustering
or fatJets != cms.InputTag(
''):
436 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
437 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
439 btag.pfDeepCSVPositiveTagInfos.clone(
440 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
442 if svClustering
or fatJets != cms.InputTag(
''):
443 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
444 if btagInfo ==
'pfDeepCMVATagInfos':
446 btag.pfDeepCMVATagInfos.clone(
447 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
448 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
449 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
450 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
452 if svClustering
or fatJets != cms.InputTag(
''):
453 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
454 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
456 btag.pfDeepCMVATagInfos.clone(
457 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
458 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
459 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
460 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
462 if svClustering
or fatJets != cms.InputTag(
''):
463 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
464 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
466 btag.pfDeepCMVATagInfos.clone(
467 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
468 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
469 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
470 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
472 if svClustering
or fatJets != cms.InputTag(
''):
473 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
474 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
476 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
477 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
478 extSVCollection=svSource),
480 if svClustering
or fatJets != cms.InputTag(
''):
481 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
482 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
484 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
485 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
486 extSVCollection=svSource),
488 if svClustering
or fatJets != cms.InputTag(
''):
489 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
490 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
492 btag.pfBoostedDoubleSVAK8TagInfos.clone(
493 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
495 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
497 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
498 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
499 extSVCollection=svSource),
501 if svClustering
or fatJets != cms.InputTag(
''):
502 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
503 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
505 btag.pfBoostedDoubleSVCA15TagInfos.clone(
506 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
508 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
510 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
511 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
512 extSVCollection=svSourceCvsL),
514 if svClustering
or fatJets != cms.InputTag(
''):
515 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
516 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
518 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
519 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
520 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
522 if svClustering
or fatJets != cms.InputTag(
''):
523 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
524 if btagInfo ==
'pfGhostTrackVertexTagInfos':
526 btag.pfGhostTrackVertexTagInfos.clone(
527 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
529 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
531 btag.pfSecondaryVertexNegativeTagInfos.clone(
532 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
535 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
536 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
537 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
538 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
540 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
541 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
542 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
544 if svClustering
or fatJets != cms.InputTag(
''):
545 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
546 if btagInfo ==
'impactParameterTagInfos':
548 btag.impactParameterTagInfos.clone(
549 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
550 primaryVertex=pvSource),
552 if btagInfo ==
'secondaryVertexTagInfos':
554 btag.secondaryVertexTagInfos.clone(
555 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
557 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
559 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
560 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
562 if svClustering
or fatJets != cms.InputTag(
''):
563 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
564 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
566 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
567 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
569 if svClustering
or fatJets != cms.InputTag(
''):
570 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
571 if btagInfo ==
'secondaryVertexNegativeTagInfos':
573 btag.secondaryVertexNegativeTagInfos.clone(
574 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
576 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
578 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
579 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
581 if svClustering
or fatJets != cms.InputTag(
''):
582 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
583 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
585 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
586 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
588 if svClustering
or fatJets != cms.InputTag(
''):
589 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
590 if btagInfo ==
'softMuonTagInfos':
592 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
594 if btagInfo ==
'softPFMuonsTagInfos':
596 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
598 if btagInfo ==
'softPFElectronsTagInfos':
600 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
602 if btagInfo ==
'pixelClusterTagInfos':
604 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
607 if 'pfBoostedDouble' in btagInfo
or 'SecondaryVertex' in btagInfo:
608 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
609 if pfCandidates.value() ==
'packedPFCandidates':
610 _btagInfo.weights = cms.InputTag(
"packedpuppi")
611 if not hasattr(process,
"packedpuppi"):
614 useExistingWeights =
True,
615 candName =
'packedPFCandidates',
616 vertexName =
'offlineSlimmedPrimaryVertices') , process, task)
618 _btagInfo.weights = cms.InputTag(
"puppi")
620 if 'DeepFlavourTagInfos' in btagInfo:
622 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
623 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos' 624 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
627 deep_csv_tag_infos =
'pfDeepCSVTagInfos' 631 if not (
'limmed' in jetSource.value()):
632 puppi_value_map = cms.InputTag(
"puppi")
633 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
635 puppi_value_map = cms.InputTag(
"")
636 vertex_associator = cms.InputTag(
"")
638 btag.pfDeepFlavourTagInfos.clone(
641 secondary_vertices=svUsed,
642 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
643 puppi_value_map = puppi_value_map,
644 vertex_associator = vertex_associator,
648 if btagInfo ==
'pfDeepDoubleXTagInfos':
650 if 'updated' not in jetSource.value().lower():
651 raise ValueError(
"Invalid jet collection: %s. pfDeepDoubleXTagInfos only supports running via updateJetCollection." % jetSource.value())
653 btag.pfDeepDoubleXTagInfos.clone(
656 secondary_vertices=svSource,
657 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
661 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
663 btag.pfHiggsInteractionNetTagInfos.clone(
666 secondary_vertices = svSource,
667 pf_candidates = pfCandidates,
671 if btagInfo ==
'pfDeepBoostedJetTagInfos':
672 if pfCandidates.value() ==
'packedPFCandidates':
674 if 'updated' not in jetSource.value().lower():
675 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
677 vertex_associator =
"" 678 elif pfCandidates.value() ==
'particleFlow':
679 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
686 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
688 btag.pfDeepBoostedJetTagInfos.clone(
691 secondary_vertices = svSource,
692 pf_candidates = pfCandidates,
693 puppi_value_map = puppi_value_map,
694 vertex_associator = vertex_associator,
698 if btagInfo ==
'pfParticleNetTagInfos':
699 if pfCandidates.value() ==
'packedPFCandidates':
702 vertex_associator =
"" 703 elif pfCandidates.value() ==
'particleFlow':
704 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
706 puppi_value_map =
"puppi" 707 vertex_associator =
"primaryVertexAssociation:original" 709 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
711 btag.pfParticleNetTagInfos.clone(
714 secondary_vertices = svSource,
715 pf_candidates = pfCandidates,
716 puppi_value_map = puppi_value_map,
717 vertex_associator = vertex_associator,
721 if 'ParticleNetAK4TagInfos' in btagInfo:
722 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
723 secondary_vertices = btagPrefix + \
724 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
728 secondary_vertices = svSource
731 if pfCandidates.value() ==
'packedPFCandidates':
734 vertex_associator =
"" 735 elif pfCandidates.value() ==
'particleFlow':
736 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
738 puppi_value_map =
"puppi" 739 vertex_associator =
"primaryVertexAssociation:original" 741 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
743 btag.pfParticleNetAK4TagInfos.clone(
746 secondary_vertices = secondary_vertices,
747 pf_candidates = pfCandidates,
748 puppi_value_map = puppi_value_map,
749 vertex_associator = vertex_associator,
750 flip_ip_sign = flip_ip_sign,
751 sip3dSigMax = sip3dSigMax,
755 acceptedTagInfos.append(btagInfo)
756 elif hasattr(toptag, btagInfo) :
757 acceptedTagInfos.append(btagInfo)
759 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
761 acceptedBtagDiscriminators = list()
762 for discriminator_name
in btagDiscriminators :
763 btagDiscr = discriminator_name.split(
':')[0]
765 if hasattr(btag,btagDiscr):
766 newDiscr = btagPrefix+btagDiscr+labelName+postfix
767 if hasattr(process, newDiscr):
769 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
772 getattr(btag, btagDiscr).
clone(
773 tagInfos = cms.VInputTag(
774 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
775 for x
in supportedBtagDiscr[discriminator_name][0] ]
781 elif hasattr(getattr(btag, btagDiscr),
'src'):
784 getattr(btag, btagDiscr).
clone(
785 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
791 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
792 acceptedBtagDiscriminators.append(discriminator_name)
794 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
796 for meta_tagger
in present_meta:
797 btagDiscr = meta_tagger.split(
':')[0]
799 if hasattr(btag,btagDiscr):
800 newDiscr = btagPrefix+btagDiscr+labelName+postfix
801 if hasattr(process, newDiscr):
806 getattr(btag, btagDiscr).
clone(),
810 for dependency
in supportedMetaDiscr[meta_tagger]:
811 if ':' in dependency:
812 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
814 new_dep = btagPrefix+dependency+labelName+postfix
815 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
816 replace.doIt(getattr(process, newDiscr), newDiscr)
817 acceptedBtagDiscriminators.append(meta_tagger)
819 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
822 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
823 patJets.discriminatorSources = cms.VInputTag(*[
824 cms.InputTag(btagPrefix+x+labelName+postfix) \
825 if ':' not in x
else \
826 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
827 for x
in acceptedBtagDiscriminators
829 if len(acceptedBtagDiscriminators) > 0 :
830 patJets.addBTagInfo =
True 833 if not tightBTagNTkHits:
834 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
839 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
840 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
841 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
842 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
844 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
845 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
846 _temp.minHits = cms.uint32(8)
848 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
849 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
850 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
851 _temp.primaryVertices = pvSource
852 _temp.tracks = pfCandidates
853 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
854 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
855 _temp.primaryVertices = pvSource
856 _temp.tracks = pfCandidates
857 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
859 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
861 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
862 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
863 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
865 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
866 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
867 _temp.minHits = cms.uint32(8)
869 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
870 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
871 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
872 _temp.primaryVertices = pvSource
873 _temp.tracks = pfCandidates
874 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
875 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
876 _temp.primaryVertices = pvSource
877 _temp.tracks = pfCandidates
878 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
880 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
882 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
883 if not hasattr( process,
'inclusiveVertexing' ):
884 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
885 task.add(process.inclusiveVertexingTask)
886 task.add(process.inclusiveCandidateVertexingTask)
887 task.add(process.inclusiveCandidateVertexingCvsLTask)
888 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
889 if not hasattr( process,
'inclusiveVertexing' ):
890 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
891 task.add(process.inclusiveVertexingTask)
892 task.add(process.inclusiveCandidateVertexingTask)
893 task.add(process.inclusiveCandidateVertexingCvsLTask)
894 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
895 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
896 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
897 task.add(process.inclusiveSecondaryVerticesFiltered)
898 task.add(process.bVertexFilter)
899 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
900 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
901 task.add(process.bToCharmDecayVertexMerged)
902 if 'caTopTagInfos' in acceptedTagInfos :
903 patJets.addTagInfos =
True 904 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
905 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
906 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)