237 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
242 discriminators = set(btagDiscriminators)
243 present_meta = discriminators.intersection(set(supportedMetaDiscr.keys()))
244 discriminators -= present_meta
245 for meta_tagger
in present_meta:
246 for src
in supportedMetaDiscr[meta_tagger]:
247 discriminators.add(src)
248 btagDiscriminators =
list(discriminators)
252 requiredTagInfos =
list(btagInfos)
253 for btagDiscr
in btagDiscriminators :
254 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
255 for requiredTagInfo
in tagInfoList :
256 tagInfoCovered =
False 257 for tagInfo
in requiredTagInfos :
258 if requiredTagInfo == tagInfo :
259 tagInfoCovered =
True 261 if not tagInfoCovered :
262 requiredTagInfos.append(requiredTagInfo)
264 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
266 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
267 task.add(process.impactParameterTask)
268 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
269 task.add(process.secondaryVertexTask)
270 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
271 task.add(process.softLeptonTask)
272 process.load(
"RecoBTag.Combined.combinedMVA_cff")
273 task.add(process.combinedMVATask)
274 process.load(
"RecoBTag.CTagging.cTagging_cff")
275 task.add(process.cTaggingTask)
277 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
278 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
279 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
280 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
281 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
283 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
287 sys.stderr.write(
"-------------------------------------------------------------------\n")
288 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
289 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
290 sys.stderr.write(
"-------------------------------------------------------------------\n")
292 sys.stderr.write(
"-------------------------------------------------------------------\n")
293 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
294 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
295 sys.stderr.write(
" avoid unintentional modifications to the default\n")
296 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
297 sys.stderr.write(
"-------------------------------------------------------------------\n")
301 svSourceCvsL = copy.deepcopy(svSource)
302 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
305 runIVFforCTagOnly =
False 306 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
308 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
309 runIVFforCTagOnly =
True 311 sys.stderr.write(
"-------------------------------------------------------------------\n")
312 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
313 sys.stderr.write(
" vertices will be remade.\n")
314 sys.stderr.write(
"-------------------------------------------------------------------\n")
316 if runIVF
and btagPrefix !=
'':
317 if runIVFforCTagOnly:
318 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
320 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
321 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
327 runNegativeVertexing =
False 328 runNegativeCvsLVertexing =
False 329 for btagInfo
in requiredTagInfos:
330 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos' or btagInfo ==
'pfNegativeDeepFlavourTagInfos':
331 runNegativeVertexing =
True 332 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
333 runNegativeCvsLVertexing =
True 335 if runNegativeVertexing
or runNegativeCvsLVertexing:
336 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
338 if runNegativeVertexing:
340 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
343 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
346 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
347 ,primaryVertices = pvSource
348 ,tracks=pfCandidates),
350 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
351 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
354 if runNegativeCvsLVertexing:
355 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
356 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
359 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
362 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
363 ,primaryVertices = pvSource
364 ,tracks=pfCandidates),
366 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
367 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
371 acceptedTagInfos =
list()
372 for btagInfo
in requiredTagInfos:
373 if hasattr(btag,btagInfo):
374 if btagInfo ==
'pfImpactParameterTagInfos':
376 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
379 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
380 _btagInfo.explicitJTA = cms.bool(explicitJTA)
382 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
383 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
384 _btagInfo.minimumNumberOfHits = cms.int32(8)
385 if btagInfo ==
'pfImpactParameterAK8TagInfos':
387 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
390 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
391 _btagInfo.explicitJTA = cms.bool(explicitJTA)
393 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
394 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
395 _btagInfo.minimumNumberOfHits = cms.int32(8)
396 if btagInfo ==
'pfImpactParameterCA15TagInfos':
398 btag.pfImpactParameterCA15TagInfos.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 ==
'pfSecondaryVertexTagInfos':
409 btag.pfSecondaryVertexTagInfos.clone(
410 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
413 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
414 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
415 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
416 if btagInfo ==
'pfDeepCSVTagInfos':
418 btag.pfDeepCSVTagInfos.clone(
419 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
421 if svClustering
or fatJets != cms.InputTag(
''):
422 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
423 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
425 btag.pfDeepCSVNegativeTagInfos.clone(
426 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+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 ==
'pfDeepCSVPositiveTagInfos':
432 btag.pfDeepCSVPositiveTagInfos.clone(
433 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+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 ==
'pfDeepCMVATagInfos':
439 btag.pfDeepCMVATagInfos.clone(
440 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
441 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
442 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
443 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
445 if svClustering
or fatJets != cms.InputTag(
''):
446 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
447 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
449 btag.pfDeepCMVATagInfos.clone(
450 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
451 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
452 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
453 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
455 if svClustering
or fatJets != cms.InputTag(
''):
456 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
457 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
459 btag.pfDeepCMVATagInfos.clone(
460 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
461 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
462 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
463 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
465 if svClustering
or fatJets != cms.InputTag(
''):
466 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
467 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
469 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
470 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
471 extSVCollection=svSource),
473 if svClustering
or fatJets != cms.InputTag(
''):
474 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
475 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
477 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
478 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
479 extSVCollection=svSource),
481 if svClustering
or fatJets != cms.InputTag(
''):
482 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
483 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
485 btag.pfBoostedDoubleSVAK8TagInfos.clone(
486 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
488 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
490 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
491 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
492 extSVCollection=svSource),
494 if svClustering
or fatJets != cms.InputTag(
''):
495 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
496 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
498 btag.pfBoostedDoubleSVCA15TagInfos.clone(
499 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
501 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
503 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
504 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
505 extSVCollection=svSourceCvsL),
507 if svClustering
or fatJets != cms.InputTag(
''):
508 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
509 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
511 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
512 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
513 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
515 if svClustering
or fatJets != cms.InputTag(
''):
516 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
517 if btagInfo ==
'pfGhostTrackVertexTagInfos':
519 btag.pfGhostTrackVertexTagInfos.clone(
520 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
522 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
524 btag.pfSecondaryVertexNegativeTagInfos.clone(
525 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
528 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
529 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
530 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
531 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
533 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
534 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
535 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+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 ==
'impactParameterTagInfos':
541 btag.impactParameterTagInfos.clone(
542 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
543 primaryVertex=pvSource),
545 if btagInfo ==
'secondaryVertexTagInfos':
547 btag.secondaryVertexTagInfos.clone(
548 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
550 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
552 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
553 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
555 if svClustering
or fatJets != cms.InputTag(
''):
556 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
557 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
559 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.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 ==
'secondaryVertexNegativeTagInfos':
566 btag.secondaryVertexNegativeTagInfos.clone(
567 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
569 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
571 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
572 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
574 if svClustering
or fatJets != cms.InputTag(
''):
575 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
576 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
578 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.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 ==
'softMuonTagInfos':
585 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
587 if btagInfo ==
'softPFMuonsTagInfos':
589 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
591 if btagInfo ==
'softPFElectronsTagInfos':
593 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
596 if 'DeepFlavourTagInfos' in btagInfo:
598 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
599 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos' 600 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
603 deep_csv_tag_infos =
'pfDeepCSVTagInfos' 607 if not (
'limmed' in jetSource.value()):
608 puppi_value_map = cms.InputTag(
"puppi")
609 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
611 puppi_value_map = cms.InputTag(
"")
612 vertex_associator = cms.InputTag(
"")
614 btag.pfDeepFlavourTagInfos.clone(
617 secondary_vertices=svUsed,
618 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
619 puppi_value_map = puppi_value_map,
620 vertex_associator = vertex_associator,
624 if btagInfo ==
'pfDeepDoubleXTagInfos':
626 btag.pfDeepDoubleXTagInfos.clone(
629 secondary_vertices=svSource,
630 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
634 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
636 btag.pfHiggsInteractionNetTagInfos.clone(
639 secondary_vertices = svSource,
640 pf_candidates = pfCandidates,
644 if btagInfo ==
'pfDeepBoostedJetTagInfos':
645 if pfCandidates.value() ==
'packedPFCandidates':
647 if 'updated' not in jetSource.value().lower():
648 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
650 vertex_associator =
"" 651 elif pfCandidates.value() ==
'particleFlow':
652 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
659 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
661 btag.pfDeepBoostedJetTagInfos.clone(
664 secondary_vertices = svSource,
665 pf_candidates = pfCandidates,
666 puppi_value_map = puppi_value_map,
667 vertex_associator = vertex_associator,
671 if btagInfo ==
'pfParticleNetTagInfos':
672 if pfCandidates.value() ==
'packedPFCandidates':
675 vertex_associator =
"" 676 elif pfCandidates.value() ==
'particleFlow':
677 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
679 puppi_value_map =
"puppi" 680 vertex_associator =
"primaryVertexAssociation:original" 682 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
684 btag.pfParticleNetTagInfos.clone(
687 secondary_vertices = svSource,
688 pf_candidates = pfCandidates,
689 puppi_value_map = puppi_value_map,
690 vertex_associator = vertex_associator,
694 acceptedTagInfos.append(btagInfo)
695 elif hasattr(toptag, btagInfo) :
696 acceptedTagInfos.append(btagInfo)
698 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
700 acceptedBtagDiscriminators =
list()
701 for discriminator_name
in btagDiscriminators :
702 btagDiscr = discriminator_name.split(
':')[0]
704 if hasattr(btag,btagDiscr):
705 newDiscr = btagPrefix+btagDiscr+labelName+postfix
706 if hasattr(process, newDiscr):
708 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
711 getattr(btag, btagDiscr).
clone(
712 tagInfos = cms.VInputTag(
713 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
714 for x
in supportedBtagDiscr[discriminator_name][0] ]
720 elif hasattr(getattr(btag, btagDiscr),
'src'):
723 getattr(btag, btagDiscr).
clone(
724 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
730 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
731 acceptedBtagDiscriminators.append(discriminator_name)
733 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
735 for meta_tagger
in present_meta:
736 btagDiscr = meta_tagger.split(
':')[0]
738 if hasattr(btag,btagDiscr):
739 newDiscr = btagPrefix+btagDiscr+labelName+postfix
740 if hasattr(process, newDiscr):
745 getattr(btag, btagDiscr).
clone(),
749 for dependency
in supportedMetaDiscr[meta_tagger]:
750 if ':' in dependency:
751 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
753 new_dep = btagPrefix+dependency+labelName+postfix
754 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
755 replace.doIt(getattr(process, newDiscr), newDiscr)
756 acceptedBtagDiscriminators.append(meta_tagger)
758 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
761 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
762 patJets.discriminatorSources = cms.VInputTag(*[
763 cms.InputTag(btagPrefix+x+labelName+postfix) \
764 if ':' not in x
else \
765 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
766 for x
in acceptedBtagDiscriminators
768 if len(acceptedBtagDiscriminators) > 0 :
769 patJets.addBTagInfo =
True 772 if not tightBTagNTkHits:
773 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
778 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
779 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
780 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
781 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
783 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
784 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
785 _temp.minHits = cms.uint32(8)
787 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
788 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
789 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
790 _temp.primaryVertices = pvSource
791 _temp.tracks = pfCandidates
792 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
793 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
794 _temp.primaryVertices = pvSource
795 _temp.tracks = pfCandidates
796 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
798 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
800 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
801 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
802 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
804 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
805 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
806 _temp.minHits = cms.uint32(8)
808 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
809 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
810 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
811 _temp.primaryVertices = pvSource
812 _temp.tracks = pfCandidates
813 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
814 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
815 _temp.primaryVertices = pvSource
816 _temp.tracks = pfCandidates
817 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
819 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
821 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
822 if not hasattr( process,
'inclusiveVertexing' ):
823 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
824 task.add(process.inclusiveVertexingTask)
825 task.add(process.inclusiveCandidateVertexingTask)
826 task.add(process.inclusiveCandidateVertexingCvsLTask)
827 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
828 if not hasattr( process,
'inclusiveVertexing' ):
829 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
830 task.add(process.inclusiveVertexingTask)
831 task.add(process.inclusiveCandidateVertexingTask)
832 task.add(process.inclusiveCandidateVertexingCvsLTask)
833 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
834 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
835 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
836 task.add(process.inclusiveSecondaryVerticesFiltered)
837 task.add(process.bVertexFilter)
838 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
839 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
840 task.add(process.bToCharmDecayVertexMerged)
841 if 'caTopTagInfos' in acceptedTagInfos :
842 patJets.addTagInfos =
True 843 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
844 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
845 task.add(process.caTopTaggersTask)
bool any(const std::vector< T > &v, const T &what)
def addToProcessAndTask(label, module, process, task)
S & print(S &os, JobReport::InputFile const &f)
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
def getPatAlgosToolsTask(process)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run