From e90cc2ea1b3bdbe5eceb8a8c19cd14b36db6853d Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Mon, 31 Jan 2022 12:53:50 +0100 Subject: [PATCH 01/21] Add sequences to process displacedTracks, displacedGlobalMuons and displacedStandAloneMuons to create a recoMuon collection with MuonReducedTrackExtras --- .../python/RecoMuonPPonly_cff.py | 17 +- .../python/RecoMuon_EventContent_cff.py | 12 +- RecoMuon/Configuration/python/RecoMuon_cff.py | 4 +- .../displacedMuonReducedTrackExtras_cfi.py | 15 + .../python/displacedMuons_cfi.py | 103 +++ .../displacedMuonPFIsolationDeposits_cff.py | 20 + .../displacedMuonPFIsolationValues_cff.py | 618 ++++++++++++++++++ .../python/muonPFIsolation_cff.py | 9 + .../python/isoDepositProducerIOBlocks_cff.py | 14 + .../python/muIsoDepositCopies_cfi.py | 14 + .../python/muIsoDeposits_cff.py | 3 + .../python/muIsolation_cff.py | 4 + 12 files changed, 829 insertions(+), 4 deletions(-) create mode 100644 RecoMuon/MuonIdentification/python/displacedMuonReducedTrackExtras_cfi.py create mode 100644 RecoMuon/MuonIdentification/python/displacedMuons_cfi.py create mode 100644 RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py create mode 100644 RecoMuon/MuonIsolation/python/displacedMuonPFIsolationValues_cff.py diff --git a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py index 7d05060ffbc85..f1add3b267d05 100644 --- a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py +++ b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py @@ -40,6 +40,16 @@ from RecoMuon.MuonIdentification.muonIdProducerSequence_cff import * muons1stStep.fillGlobalTrackQuality = True +displacedMuons1stStep = muons1stStep.clone( + inputCollectionLabels = ['displacedTracks', + 'displacedGlobalMuons', + 'displacedStandAloneMuons'], + inputCollectionTypes = ['inner tracks', + 'links', + 'outer tracks'], + fillGlobalTrackQuality = False +) + #Muon Id isGood flag ValueMap producer sequence from RecoMuon.MuonIdentification.muonSelectionTypeValueMapProducer_cff import * @@ -70,7 +80,8 @@ muontrackingTask = cms.Task(standalonemuontrackingTask,globalmuontrackingTask) muontracking = cms.Sequence(muontrackingTask) # Muon Reconstruction -muonrecoTask = cms.Task(muontrackingTask,muonIdProducerTask) +displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep) +muonrecoTask = cms.Task(muontrackingTask,muonIdProducerTask, displacedMuonIdProducerTask) muonreco = cms.Sequence(muonrecoTask) # Muon Reconstruction plus Isolation muonreco_plus_isolationTask = cms.Task(muonrecoTask,muIsolationTask) @@ -90,8 +101,10 @@ muonGlobalRecoTask = cms.Task(globalmuontrackingTask, muonIdProducerTask, + displacedMuonIdProducerTask, muonSelectionTypeTask, - muIsolationTask) + muIsolationTask, + muIsolationDisplacedTask) muonGlobalReco = cms.Sequence(muonGlobalRecoTask) # ... instead, the sequences will be run in the following order: diff --git a/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py b/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py index 9463e22dfcec5..b16103a5971e3 100644 --- a/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py +++ b/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py @@ -36,6 +36,15 @@ #'drop *_muons_muons1stStep2muonsMap_*', #'drop recoIsoDepositedmValueMap_muons_*_*', #not really used #'drop doubleedmValueMap_muons_muPFIso*_*', #already inside the muon + # displacedMuons collection + 'keep recoMuons_displacedMuons_*_*', + 'keep booledmValueMap_displacedMuons_*_*', + 'keep doubleedmValueMap_displacedMuons_dispMuPFMean*_*', + 'keep doubleedmValueMap_displacedMuons_dispMuPFSum*_*', + 'keep recoMuonTimeExtraedmValueMap_displacedMuons_*_*', + 'keep uintedmValueMap_displacedMuons_*_*', + 'keep *_particleFlow_displacedMuons_*', + 'keep recoIsoDepositedmValueMap_*Displaced_*_*', # Tracks known by the Muon obj 'keep recoTracks_standAloneMuons_*_*', 'keep recoTrackExtras_standAloneMuons_*_*', @@ -64,7 +73,8 @@ 'keep recoTracks_displacedStandAloneMuons__*', 'keep recoTrackExtras_displacedStandAloneMuons_*_*', 'keep TrackingRecHitsOwned_displacedStandAloneMuons_*_*', - 'keep *_muonReducedTrackExtras_*_*') + 'keep *_muonReducedTrackExtras_*_*', + 'keep *_displacedMuonReducedTrackExtras_*_*') ) RecoMuonAOD.outputCommands.extend(RecoMuonIsolationAOD.outputCommands) diff --git a/RecoMuon/Configuration/python/RecoMuon_cff.py b/RecoMuon/Configuration/python/RecoMuon_cff.py index a2d0f63e6863a..a141290af78b7 100644 --- a/RecoMuon/Configuration/python/RecoMuon_cff.py +++ b/RecoMuon/Configuration/python/RecoMuon_cff.py @@ -71,8 +71,10 @@ #### High level sequence (i.e., post PF reconstruction) ### from RecoMuon.MuonIdentification.muons_cfi import * +from RecoMuon.MuonIdentification.displacedMuons_cfi import * from RecoMuon.MuonIsolation.muonPFIsolation_cff import * from RecoMuon.MuonIdentification.muonReducedTrackExtras_cfi import * +from RecoMuon.MuonIdentification.displacedMuonReducedTrackExtras_cfi import * # clusters are not present in fastsim from Configuration.Eras.Modifier_fastSim_cff import fastSim @@ -82,5 +84,5 @@ from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker phase2_tracker.toModify(muonReducedTrackExtras, outputClusters = False) -muonshighlevelrecoTask = cms.Task(muonPFIsolationTask,muons,muonReducedTrackExtras) +muonshighlevelrecoTask = cms.Task(muonPFIsolationTask,displacedMuonPFIsolationTask,muons,displacedMuons,muonReducedTrackExtras, displacedMuonReducedTrackExtras) muonshighlevelreco = cms.Sequence(muonshighlevelrecoTask) diff --git a/RecoMuon/MuonIdentification/python/displacedMuonReducedTrackExtras_cfi.py b/RecoMuon/MuonIdentification/python/displacedMuonReducedTrackExtras_cfi.py new file mode 100644 index 0000000000000..ed60cab92dd15 --- /dev/null +++ b/RecoMuon/MuonIdentification/python/displacedMuonReducedTrackExtras_cfi.py @@ -0,0 +1,15 @@ +import FWCore.ParameterSet.Config as cms + +displacedMuonReducedTrackExtras = cms.EDProducer('MuonReducedTrackExtraProducer', + muonTag = cms.InputTag('displacedMuons'), + trackExtraTags = cms.VInputTag( + 'displacedTracks', + 'displacedGlobalMuons' + ), + trackExtraAssocs = cms.VInputTag(), + pixelClusterTag = cms.InputTag('siPixelClusters'), + stripClusterTag = cms.InputTag('siStripClusters'), + cut = cms.string('pt > 3.0'), + outputClusters = cms.bool(True), + mightGet = cms.optional.untracked.vstring +) diff --git a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py new file mode 100644 index 0000000000000..653f820ae7d2d --- /dev/null +++ b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py @@ -0,0 +1,103 @@ +# This file name is temporary and ment for development only. +# The content of this file will be moved to displacedMuons_cfi as soon as the complete work flow is in place. + +import FWCore.ParameterSet.Config as cms + +displacedMuons = cms.EDProducer("MuonProducer", + ActivateDebug = cms.untracked.bool(False), + InputMuons = cms.InputTag("displacedMuons1stStep"), + + FillPFMomentumAndAssociation = cms.bool(True), + PFCandidates = cms.InputTag("particleFlowTmp"), + + FillTimingInfo = cms.bool(True), + + FillDetectorBasedIsolation = cms.bool(True), + EcalIsoDeposits = cms.InputTag("muIsoDepositCalByAssociatorTowersDisplaced","ecal"), + HcalIsoDeposits = cms.InputTag("muIsoDepositCalByAssociatorTowersDisplaced","hcal"), + HoIsoDeposits = cms.InputTag("muIsoDepositCalByAssociatorTowersDisplaced","ho"), + TrackIsoDeposits = cms.InputTag("muIsoDepositTkDisplaced"), + JetIsoDeposits = cms.InputTag("muIsoDepositJetsDisplaced"), + + FillPFIsolation = cms.bool(True), + PFIsolation = cms.PSet( + pfIsolationR03 = cms.PSet(chargedParticle = cms.InputTag("dispMuPFIsoValueChargedAll03"), + chargedHadron = cms.InputTag("dispMuPFIsoValueCharged03"), + neutralHadron = cms.InputTag("dispMuPFIsoValueNeutral03"), + neutralHadronHighThreshold = cms.InputTag("dispMuPFIsoValueNeutralHighThreshold03"), + photon = cms.InputTag("dispMuPFIsoValueGamma03"), + photonHighThreshold = cms.InputTag("dispMuPFIsoValueGammaHighThreshold03"), + pu = cms.InputTag("dispMuPFIsoValuePU03")), + pfIsolationR04 = cms.PSet(chargedParticle = cms.InputTag("dispMuPFIsoValueChargedAll04"), + chargedHadron = cms.InputTag("dispMuPFIsoValueCharged04"), + neutralHadron = cms.InputTag("dispMuPFIsoValueNeutral04"), + neutralHadronHighThreshold = cms.InputTag("dispMuPFIsoValueNeutralHighThreshold04"), + photon = cms.InputTag("dispMuPFIsoValueGamma04"), + photonHighThreshold = cms.InputTag("dispMuPFIsoValueGammaHighThreshold04"), + pu = cms.InputTag("dispMuPFIsoValuePU04")), + pfIsoMeanDRProfileR03 = cms.PSet(chargedParticle = cms.InputTag("dispMuPFMeanDRIsoValueChargedAll03"), + chargedHadron = cms.InputTag("dispMuPFMeanDRIsoValueCharged03"), + neutralHadron = cms.InputTag("dispMuPFMeanDRIsoValueNeutral03"), + neutralHadronHighThreshold = cms.InputTag("dispMuPFMeanDRIsoValueNeutralHighThreshold03"), + photon = cms.InputTag("dispMuPFMeanDRIsoValueGamma03"), + photonHighThreshold = cms.InputTag("dispMuPFMeanDRIsoValueGammaHighThreshold03"), + pu = cms.InputTag("dispMuPFMeanDRIsoValuePU03")), + pfIsoMeanDRProfileR04 = cms.PSet(chargedParticle = cms.InputTag("dispMuPFMeanDRIsoValueChargedAll04"), + chargedHadron = cms.InputTag("dispMuPFMeanDRIsoValueCharged04"), + neutralHadron = cms.InputTag("dispMuPFMeanDRIsoValueNeutral04"), + neutralHadronHighThreshold = cms.InputTag("dispMuPFMeanDRIsoValueNeutralHighThreshold04"), + photon = cms.InputTag("dispMuPFMeanDRIsoValueGamma04"), + photonHighThreshold = cms.InputTag("dispMuPFMeanDRIsoValueGammaHighThreshold04"), + pu = cms.InputTag("dispMuPFMeanDRIsoValuePU04")), + pfIsoSumDRProfileR03 = cms.PSet(chargedParticle = cms.InputTag("dispMuPFSumDRIsoValueChargedAll03"), + chargedHadron = cms.InputTag("dispMuPFSumDRIsoValueCharged03"), + neutralHadron = cms.InputTag("dispMuPFSumDRIsoValueNeutral03"), + neutralHadronHighThreshold = cms.InputTag("dispMuPFSumDRIsoValueNeutralHighThreshold03"), + photon = cms.InputTag("dispMuPFSumDRIsoValueGamma03"), + photonHighThreshold = cms.InputTag("dispMuPFSumDRIsoValueGammaHighThreshold03"), + pu = cms.InputTag("dispMuPFSumDRIsoValuePU03")), + pfIsoSumDRProfileR04 = cms.PSet(chargedParticle = cms.InputTag("dispMuPFSumDRIsoValueChargedAll04"), + chargedHadron = cms.InputTag("dispMuPFSumDRIsoValueCharged04"), + neutralHadron = cms.InputTag("dispMuPFSumDRIsoValueNeutral04"), + neutralHadronHighThreshold = cms.InputTag("dispMuPFSumDRIsoValueNeutralHighThreshold04"), + photon = cms.InputTag("dispMuPFSumDRIsoValueGamma04"), + photonHighThreshold = cms.InputTag("dispMuPFSumDRIsoValueGammaHighThreshold04"), + pu = cms.InputTag("dispMuPFSumDRIsoValuePU04")) + ), + + FillSelectorMaps = cms.bool(False), + SelectorMaps = cms.VInputTag(cms.InputTag("muidTMLastStationOptimizedLowPtLoose"), + cms.InputTag("muidTMLastStationOptimizedLowPtTight"), + cms.InputTag("muidTM2DCompatibilityLoose"), + cms.InputTag("muidTM2DCompatibilityTight"), + cms.InputTag("muidTrackerMuonArbitrated"), + cms.InputTag("muidTMLastStationAngLoose"), + cms.InputTag("muidGlobalMuonPromptTight"), + cms.InputTag("muidGMStaChiCompatibility"), + cms.InputTag("muidTMLastStationAngTight"), + cms.InputTag("muidGMTkChiCompatibility"), + cms.InputTag("muidTMOneStationAngTight"), + cms.InputTag("muidTMOneStationAngLoose"), + cms.InputTag("muidTMLastStationLoose"), + cms.InputTag("muidTMLastStationTight"), + cms.InputTag("muidTMOneStationTight"), + cms.InputTag("muidTMOneStationLoose"), + cms.InputTag("muidAllArbitrated"), + cms.InputTag("muidGMTkKinkTight"), + cms.InputTag("muidRPCMuLoose") + ), + + FillShoweringInfo = cms.bool(False), + ShowerInfoMap = cms.InputTag("muonShowerInformation"), + + FillCosmicsIdMap = cms.bool(False), + CosmicIdMap = cms.InputTag("cosmicsVeto"), + + ComputeStandardSelectors = cms.bool(True), + vertices = cms.InputTag("offlinePrimaryVertices") + + ) + +# not commisoned and not relevant in FastSim (?): +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(displacedMuons, FillCosmicsIdMap = False, FillSelectorMaps = False) diff --git a/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py new file mode 100644 index 0000000000000..53f5cd53a737e --- /dev/null +++ b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py @@ -0,0 +1,20 @@ +import FWCore.ParameterSet.Config as cms + +from CommonTools.ParticleFlow.Isolation.tools_cfi import * + + +#Now prepare the iso deposits for displacedMuons +dispMuPFIsoDepositCharged=isoDepositReplace('displacedMuons1stStep','pfAllChargedHadrons') +dispMuPFIsoDepositChargedAll=isoDepositReplace('displacedMuons1stStep','pfAllChargedParticles') +dispMuPFIsoDepositNeutral=isoDepositReplace('displacedMuons1stStep','pfAllNeutralHadrons') +dispMuPFIsoDepositGamma=isoDepositReplace('displacedMuons1stStep','pfAllPhotons') +dispMuPFIsoDepositPU=isoDepositReplace('displacedMuons1stStep','pfPileUpAllChargedParticles') + +displacedMuonPFIsolationDepositsTask = cms.Task( + dispMuPFIsoDepositCharged, + dispMuPFIsoDepositChargedAll, + dispMuPFIsoDepositGamma, + dispMuPFIsoDepositNeutral, + dispMuPFIsoDepositPU + ) +displacedMuonPFIsolationDepositsSequence = cms.Sequence(displacedMuonPFIsolationDepositsTask) diff --git a/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationValues_cff.py b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationValues_cff.py new file mode 100644 index 0000000000000..8206fc284948b --- /dev/null +++ b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationValues_cff.py @@ -0,0 +1,618 @@ +import FWCore.ParameterSet.Config as cms + + + +dispMuPFIsoValueCharged03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositCharged"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + + +dispMuPFSumDRIsoValueCharged03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositCharged"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueCharged03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositCharged"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + +dispMuPFIsoValueChargedAll03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositChargedAll"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFSumDRIsoValueChargedAll03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositChargedAll"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueChargedAll03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositChargedAll"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + +dispMuPFIsoValueGamma03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) +dispMuPFSumDRIsoValueGamma03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueGamma03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + +dispMuPFIsoValueNeutral03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) +dispMuPFSumDRIsoValueNeutral03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueNeutral03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + + +dispMuPFIsoValueGammaHighThreshold03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) +dispMuPFSumDRIsoValueGammaHighThreshold03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueGammaHighThreshold03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + +dispMuPFIsoValueNeutralHighThreshold03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFMeanDRIsoValueNeutralHighThreshold03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + +dispMuPFSumDRIsoValueNeutralHighThreshold03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFIsoValuePU03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositPU"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFSumDRIsoValuePU03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositPU"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValuePU03 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositPU"), + deltaR = cms.double(0.3), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + + +dispMuPFIsoValueCharged04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositCharged"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFSumDRIsoValueCharged04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositCharged"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueCharged04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositCharged"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + + + +dispMuPFIsoValueChargedAll04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositChargedAll"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFSumDRIsoValueChargedAll04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositChargedAll"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueChargedAll04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositChargedAll"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.0001','Threshold(0.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + + + + +dispMuPFIsoValueGamma04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFSumDRIsoValueGamma04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +dispMuPFMeanDRIsoValueGamma04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + + +dispMuPFIsoValueNeutral04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) + +) + +dispMuPFSumDRIsoValueNeutral04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) + +) + +dispMuPFMeanDRIsoValueNeutral04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) + +) + + +dispMuPFIsoValueGammaHighThreshold04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFMeanDRIsoValueGammaHighThreshold04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + +dispMuPFSumDRIsoValueGammaHighThreshold04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositGamma"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + + +dispMuPFIsoValueNeutralHighThreshold04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) + +) + +dispMuPFMeanDRIsoValueNeutralHighThreshold04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) + +) + +dispMuPFSumDRIsoValueNeutralHighThreshold04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositNeutral"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(1.0)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) + +) + +dispMuPFIsoValuePU04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositPU"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sum') + ) + ) +) + +dispMuPFMeanDRIsoValuePU04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositPU"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('meanDR') + ) + ) +) + +dispMuPFSumDRIsoValuePU04 = cms.EDProducer("CandIsolatorFromDeposits", + deposits = cms.VPSet( + cms.PSet( + src = cms.InputTag("dispMuPFIsoDepositPU"), + deltaR = cms.double(0.4), + weight = cms.string('1'), + vetos = cms.vstring('0.01','Threshold(0.5)'), + skipDefaultVeto = cms.bool(True), + mode = cms.string('sumDR') + ) + ) +) + +displacedMuonPFIsolationValuesTask = cms.Task( + dispMuPFIsoValueCharged03, + dispMuPFMeanDRIsoValueCharged03, + dispMuPFSumDRIsoValueCharged03, + dispMuPFIsoValueChargedAll03, + dispMuPFMeanDRIsoValueChargedAll03, + dispMuPFSumDRIsoValueChargedAll03, + dispMuPFIsoValueGamma03, + dispMuPFMeanDRIsoValueGamma03, + dispMuPFSumDRIsoValueGamma03, + dispMuPFIsoValueNeutral03, + dispMuPFMeanDRIsoValueNeutral03, + dispMuPFSumDRIsoValueNeutral03, + dispMuPFIsoValueGammaHighThreshold03, + dispMuPFMeanDRIsoValueGammaHighThreshold03, + dispMuPFSumDRIsoValueGammaHighThreshold03, + dispMuPFIsoValueNeutralHighThreshold03, + dispMuPFMeanDRIsoValueNeutralHighThreshold03, + dispMuPFSumDRIsoValueNeutralHighThreshold03, + dispMuPFIsoValuePU03, + dispMuPFMeanDRIsoValuePU03, + dispMuPFSumDRIsoValuePU03, + ############################## + dispMuPFIsoValueCharged04, + dispMuPFMeanDRIsoValueCharged04, + dispMuPFSumDRIsoValueCharged04, + dispMuPFIsoValueChargedAll04, + dispMuPFMeanDRIsoValueChargedAll04, + dispMuPFSumDRIsoValueChargedAll04, + dispMuPFIsoValueGamma04, + dispMuPFMeanDRIsoValueGamma04, + dispMuPFSumDRIsoValueGamma04, + dispMuPFIsoValueNeutral04, + dispMuPFMeanDRIsoValueNeutral04, + dispMuPFSumDRIsoValueNeutral04, + dispMuPFIsoValueGammaHighThreshold04, + dispMuPFMeanDRIsoValueGammaHighThreshold04, + dispMuPFSumDRIsoValueGammaHighThreshold04, + dispMuPFIsoValueNeutralHighThreshold04, + dispMuPFMeanDRIsoValueNeutralHighThreshold04, + dispMuPFSumDRIsoValueNeutralHighThreshold04, + dispMuPFIsoValuePU04, + dispMuPFMeanDRIsoValuePU04, + dispMuPFSumDRIsoValuePU04 + ) +displacedMuonPFIsolationValuesSequence = cms.Sequence(displacedMuonPFIsolationValuesTask) diff --git a/RecoMuon/MuonIsolation/python/muonPFIsolation_cff.py b/RecoMuon/MuonIsolation/python/muonPFIsolation_cff.py index 72d8b3e1274da..59e645fd86b73 100644 --- a/RecoMuon/MuonIsolation/python/muonPFIsolation_cff.py +++ b/RecoMuon/MuonIsolation/python/muonPFIsolation_cff.py @@ -9,3 +9,12 @@ muonPFIsolationValuesTask ) muonPFIsolationSequence = cms.Sequence(muonPFIsolationTask) + +from RecoMuon.MuonIsolation.displacedMuonPFIsolationDeposits_cff import * +from RecoMuon.MuonIsolation.displacedMuonPFIsolationValues_cff import * + +displacedMuonPFIsolationTask = cms.Task( + displacedMuonPFIsolationDepositsTask, + displacedMuonPFIsolationValuesTask +) +displacedMuonPFIsolationSequence = cms.Sequence(displacedMuonPFIsolationTask) diff --git a/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py b/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py index 712bcda522156..134c8e4ab3b2f 100644 --- a/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py +++ b/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py @@ -15,6 +15,20 @@ InputType = cms.string('MuonCollection'), MuonTrackRefType = cms.string('bestTrkSta') ) +MIsoDepositDisplacedViewMultiIOBlock = cms.PSet( + ExtractForCandidate = cms.bool(False), + inputMuonCollection = cms.InputTag("displacedMuons1stStep"), + MultipleDepositsFlag = cms.bool(True), + InputType = cms.string('MuonCollection'), + MuonTrackRefType = cms.string('bestTrkSta') +) +MIsoDepositDisplacedViewIOBlock = cms.PSet( + ExtractForCandidate = cms.bool(False), + inputMuonCollection = cms.InputTag("displacedMuons1stStep"), + MultipleDepositsFlag = cms.bool(False), + InputType = cms.string('MuonCollection'), + MuonTrackRefType = cms.string('bestTrkSta') +) MIsoDepositParamGlobalViewMultiIOBlock = cms.PSet( ExtractForCandidate = cms.bool(False), inputMuonCollection = cms.InputTag("paramMuons","ParamGlobalMuons"), diff --git a/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py b/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py index fed75c5caeaec..cf95ff86f022d 100644 --- a/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py +++ b/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py @@ -5,14 +5,28 @@ depositNames = cms.vstring('') ) +muIsoDepositTkDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", + inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:tracker")), + depositNames = cms.vstring('') +) + muIsoDepositJets = cms.EDProducer("MuIsoDepositCopyProducer", inputTags = cms.VInputTag(cms.InputTag("muons1stStep:jets")), depositNames = cms.vstring('') ) +muIsoDepositJetsDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", + inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:jets")), + depositNames = cms.vstring('') +) + muIsoDepositCalByAssociatorTowers = cms.EDProducer("MuIsoDepositCopyProducer", inputTags = cms.VInputTag(cms.InputTag("muons1stStep:ecal"), cms.InputTag("muons1stStep:hcal"), cms.InputTag("muons1stStep:ho")), depositNames = cms.vstring('ecal', 'hcal', 'ho') ) +muIsoDepositCalByAssociatorTowersDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", + inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:ecal"), cms.InputTag("displacedMuons1stStep:hcal"), cms.InputTag("displacedMuons1stStep:ho")), + depositNames = cms.vstring('ecal', 'hcal', 'ho') +) diff --git a/RecoMuon/MuonIsolationProducers/python/muIsoDeposits_cff.py b/RecoMuon/MuonIsolationProducers/python/muIsoDeposits_cff.py index 404884c074e18..7c5e64f0e1324 100644 --- a/RecoMuon/MuonIsolationProducers/python/muIsoDeposits_cff.py +++ b/RecoMuon/MuonIsolationProducers/python/muIsoDeposits_cff.py @@ -32,6 +32,9 @@ # "standard sequences" muIsoDeposits_muonsTask = cms.Task(muIsoDepositTk,muIsoDepositCalByAssociatorTowers,muIsoDepositJets) muIsoDeposits_muons = cms.Sequence(muIsoDeposits_muonsTask) +# "displaced sequences" +muIsoDeposits_displacedMuonsTask = cms.Task(muIsoDepositTkDisplaced,muIsoDepositCalByAssociatorTowersDisplaced,muIsoDepositJetsDisplaced) +muIsoDeposits_displacedMuons = cms.Sequence(muIsoDeposits_displacedMuonsTask) #old one, using a reduced config set muIsoDeposits_ParamGlobalMuonsOldTask = cms.Task(muParamGlobalIsoDepositGsTk,muParamGlobalIsoDepositCalEcal,muParamGlobalIsoDepositCalHcal) muIsoDeposits_ParamGlobalMuonsOld = cms.Sequence(muIsoDeposits_ParamGlobalMuonsOldTask) diff --git a/RecoMuon/MuonIsolationProducers/python/muIsolation_cff.py b/RecoMuon/MuonIsolationProducers/python/muIsolation_cff.py index 1d69b8046550f..7ba50afec4a2b 100644 --- a/RecoMuon/MuonIsolationProducers/python/muIsolation_cff.py +++ b/RecoMuon/MuonIsolationProducers/python/muIsolation_cff.py @@ -6,6 +6,8 @@ # sequences suggested for reco (only isoDeposits are produced at this point) muIsolation_muonsTask = cms.Task(muIsoDeposits_muonsTask) muIsolation_muons = cms.Sequence(muIsolation_muonsTask) +muIsolation_displacedMuonsTask = cms.Task(muIsoDeposits_displacedMuonsTask) +muIsolation_displacedMuons = cms.Sequence(muIsolation_displacedMuonsTask) muIsolation_ParamGlobalMuonsTask = cms.Task(muIsoDeposits_ParamGlobalMuonsTask) muIsolation_ParamGlobalMuons = cms.Sequence(muIsolation_ParamGlobalMuonsTask) muIsolation_ParamGlobalMuonsOldTask = cms.Task(muIsoDeposits_ParamGlobalMuonsOldTask) @@ -13,4 +15,6 @@ #standard sequence muIsolationTask = cms.Task(muIsolation_muonsTask) muIsolation = cms.Sequence(muIsolationTask) +muIsolationDisplacedTask = cms.Task(muIsolation_displacedMuonsTask) +muIsolationDisplaced = cms.Sequence(muIsolationDisplacedTask) From 25764cec6623f00b8c969ca25375b0e76ca0889b Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Tue, 1 Feb 2022 10:44:36 +0100 Subject: [PATCH 02/21] Modify detector based isolation processing: Deposits only saved in RECO now but not in AOD, remove unecessary producers. --- .../python/RecoMuon_EventContent_cff.py | 2 +- .../python/isoDepositProducerIOBlocks_cff.py | 14 -------------- .../python/muIsolation_EventContent_cff.py | 4 ++++ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py b/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py index b16103a5971e3..b56b04cb1bc1d 100644 --- a/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py +++ b/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py @@ -44,7 +44,7 @@ 'keep recoMuonTimeExtraedmValueMap_displacedMuons_*_*', 'keep uintedmValueMap_displacedMuons_*_*', 'keep *_particleFlow_displacedMuons_*', - 'keep recoIsoDepositedmValueMap_*Displaced_*_*', + #'keep recoIsoDepositedmValueMap_*Displaced_*_*', # saved in RECO # Tracks known by the Muon obj 'keep recoTracks_standAloneMuons_*_*', 'keep recoTrackExtras_standAloneMuons_*_*', diff --git a/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py b/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py index 134c8e4ab3b2f..712bcda522156 100644 --- a/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py +++ b/RecoMuon/MuonIsolationProducers/python/isoDepositProducerIOBlocks_cff.py @@ -15,20 +15,6 @@ InputType = cms.string('MuonCollection'), MuonTrackRefType = cms.string('bestTrkSta') ) -MIsoDepositDisplacedViewMultiIOBlock = cms.PSet( - ExtractForCandidate = cms.bool(False), - inputMuonCollection = cms.InputTag("displacedMuons1stStep"), - MultipleDepositsFlag = cms.bool(True), - InputType = cms.string('MuonCollection'), - MuonTrackRefType = cms.string('bestTrkSta') -) -MIsoDepositDisplacedViewIOBlock = cms.PSet( - ExtractForCandidate = cms.bool(False), - inputMuonCollection = cms.InputTag("displacedMuons1stStep"), - MultipleDepositsFlag = cms.bool(False), - InputType = cms.string('MuonCollection'), - MuonTrackRefType = cms.string('bestTrkSta') -) MIsoDepositParamGlobalViewMultiIOBlock = cms.PSet( ExtractForCandidate = cms.bool(False), inputMuonCollection = cms.InputTag("paramMuons","ParamGlobalMuons"), diff --git a/RecoMuon/MuonIsolationProducers/python/muIsolation_EventContent_cff.py b/RecoMuon/MuonIsolationProducers/python/muIsolation_EventContent_cff.py index d8ef478a30458..a7df782f4cac0 100644 --- a/RecoMuon/MuonIsolationProducers/python/muIsolation_EventContent_cff.py +++ b/RecoMuon/MuonIsolationProducers/python/muIsolation_EventContent_cff.py @@ -27,6 +27,10 @@ 'keep *_muIsoDepositCalByAssociatorTowers_*_*', 'keep *_muIsoDepositCalByAssociatorHits_*_*', 'keep *_muIsoDepositJets_*_*', + 'keep *_muIsoDepositTkDisplaced_*_*', + 'keep *_muIsoDepositCalByAssociatorTowersDisplaced_*_*', + 'keep *_muIsoDepositCalByAssociatorHitsDisplaced_*_*', + 'keep *_muIsoDepositJetsDisplaced_*_*', 'keep *_muGlobalIsoDepositCtfTk_*_*', 'keep *_muGlobalIsoDepositCalByAssociatorTowers_*_*', 'keep *_muGlobalIsoDepositCalByAssociatorHits_*_*', From 0c974b066690e8a2b885fe41359acd5ca19a267b Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Fri, 11 Feb 2022 15:14:22 +0100 Subject: [PATCH 03/21] Remove displacedMuons sequences from fastsim since displacedTrack reconstruction is not available there --- RecoMuon/Configuration/python/RecoMuonPPonly_cff.py | 3 ++- RecoMuon/Configuration/python/RecoMuon_cff.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py index f1add3b267d05..f390d73b97017 100644 --- a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py +++ b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py @@ -82,6 +82,7 @@ # Muon Reconstruction displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep) muonrecoTask = cms.Task(muontrackingTask,muonIdProducerTask, displacedMuonIdProducerTask) +fastSim.toReplaceWith(muonrecoTask,muonrecoTask.copyAndExclude([displacedMuonIdProducerTask])) muonreco = cms.Sequence(muonrecoTask) # Muon Reconstruction plus Isolation muonreco_plus_isolationTask = cms.Task(muonrecoTask,muIsolationTask) @@ -117,4 +118,4 @@ ######################################################## # not commisoned and not relevant in FastSim (?): -fastSim.toReplaceWith(muonGlobalRecoTask, muonGlobalRecoTask.copyAndExclude([muonreco_with_SET_Task,muonSelectionTypeTask])) +fastSim.toReplaceWith(muonGlobalRecoTask, muonGlobalRecoTask.copyAndExclude([muonreco_with_SET_Task,muonSelectionTypeTask,displacedMuonIdProducerTask,muIsolationDisplacedTask])) diff --git a/RecoMuon/Configuration/python/RecoMuon_cff.py b/RecoMuon/Configuration/python/RecoMuon_cff.py index a141290af78b7..82f3fabb2309c 100644 --- a/RecoMuon/Configuration/python/RecoMuon_cff.py +++ b/RecoMuon/Configuration/python/RecoMuon_cff.py @@ -86,3 +86,6 @@ muonshighlevelrecoTask = cms.Task(muonPFIsolationTask,displacedMuonPFIsolationTask,muons,displacedMuons,muonReducedTrackExtras, displacedMuonReducedTrackExtras) muonshighlevelreco = cms.Sequence(muonshighlevelrecoTask) + +# displaced sequences do not run in fastsim +fastSim.toReplaceWith(muonshighlevelrecoTask,muonshighlevelrecoTask.copyAndExclude([displacedMuonPFIsolationTask,displacedMuons,displacedMuonReducedTrackExtras])) From 0e2664c86879c8b98318323355a34b5bfaa004c2 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Fri, 11 Feb 2022 16:09:10 +0100 Subject: [PATCH 04/21] Remove outdated lines --- RecoMuon/MuonIdentification/python/displacedMuons_cfi.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py index 653f820ae7d2d..b82eb11a0fa70 100644 --- a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py +++ b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py @@ -1,6 +1,3 @@ -# This file name is temporary and ment for development only. -# The content of this file will be moved to displacedMuons_cfi as soon as the complete work flow is in place. - import FWCore.ParameterSet.Config as cms displacedMuons = cms.EDProducer("MuonProducer", From 4d2de56674c12e6e7dfbbcb8adeeee2f92e289bc Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Mon, 14 Feb 2022 08:20:38 +0100 Subject: [PATCH 05/21] Do not use clusters in displacedMuonReducedTrackExtras since clusters are different there --- RecoMuon/Configuration/python/RecoMuon_cff.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoMuon/Configuration/python/RecoMuon_cff.py b/RecoMuon/Configuration/python/RecoMuon_cff.py index 82f3fabb2309c..2363b949eeba2 100644 --- a/RecoMuon/Configuration/python/RecoMuon_cff.py +++ b/RecoMuon/Configuration/python/RecoMuon_cff.py @@ -83,6 +83,7 @@ # cluster collections are different in phase 2 from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker phase2_tracker.toModify(muonReducedTrackExtras, outputClusters = False) +phase2_tracker.toModify(displacedMuonReducedTrackExtras, outputClusters = False) muonshighlevelrecoTask = cms.Task(muonPFIsolationTask,displacedMuonPFIsolationTask,muons,displacedMuons,muonReducedTrackExtras, displacedMuonReducedTrackExtras) muonshighlevelreco = cms.Sequence(muonshighlevelrecoTask) From 25022c0f744b913546e0311c37799d4435487f71 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Tue, 8 Mar 2022 14:43:11 +0100 Subject: [PATCH 06/21] Add displacedMuons to miniAOD --- .../displacedMuonProducer_cff.py | 92 +++++++++++++++++++ .../producersLayer1/patCandidates_cff.py | 3 + .../displacedMuonSelector_cfi.py | 10 ++ .../selectedPatCandidates_cff.py | 3 + .../python/slimming/MicroEventContent_cff.py | 6 ++ .../slimming/slimmedDisplacedMuons_cfi.py | 21 +++++ .../python/slimming/slimmedTrackExtras_cff.py | 8 ++ .../PatAlgos/python/slimming/slimming_cff.py | 3 + 8 files changed, 146 insertions(+) create mode 100644 PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py create mode 100644 PhysicsTools/PatAlgos/python/selectionLayer1/displacedMuonSelector_cfi.py create mode 100644 PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py new file mode 100644 index 0000000000000..6e27f3c9f08dd --- /dev/null +++ b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py @@ -0,0 +1,92 @@ +import FWCore.ParameterSet.Config as cms + +#from PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi import * # This should be turn on when doing the muonMatch for displacedMuons +from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * +from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import * + +sourceMuons = cms.InputTag("displacedMuons") + +patDisplacedMuons = patMuons.clone( + + # Input collection + muonSource = sourceMuons, + + # embedding objects + embedMuonBestTrack = cms.bool(False), ## embed in AOD externally stored muon best track from global pflow + embedTunePMuonBestTrack = cms.bool(False), ## embed in AOD externally stored muon best track from muon only + forceBestTrackEmbedding = cms.bool(False), ## force embedding separately the best tracks even if they're already embedded e.g. as tracker or global tracks + embedTrack = cms.bool(False), ## embed in AOD externally stored tracker track + embedCombinedMuon = cms.bool(True), ## embed in AOD externally stored combined muon track + embedStandAloneMuon = cms.bool(True), ## embed in AOD externally stored standalone muon track + embedPickyMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit picky muon track + embedTpfmsMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit TPFMS muon track + embedDytMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit DYT muon track + embedPFCandidate = cms.bool(False), ## embed in AOD externally stored particle flow candidate + + # embedding of muon MET corrections for caloMET + embedCaloMETMuonCorrs = cms.bool(False), + # embedding of muon MET corrections for tcMET + embedTcMETMuonCorrs = cms.bool(False), # removed from RECO/AOD! + + # Read and store combined inverse beta + addInverseBeta = cms.bool(True), + sourceMuonTimeExtra = cms.InputTag("displacedMuons","combined"), #Use combined info, not only csc or dt (need to check if this is 'on' for displaced) + + # mc matching (deactivated) + addGenMatch = cms.bool(False), + embedGenMatch = cms.bool(False), + genParticleMatch = "displacedMuonMatch", # deactivated + + # high level selections + embedHighLevelSelection = cms.bool(False), + beamLineSrc = cms.InputTag("offlineBeamSpot"), + pvSrc = cms.InputTag("offlinePrimaryVertices"), + + # ecal PF energy + embedPfEcalEnergy = cms.bool(False), + addPuppiIsolation = cms.bool(False), + + # Compute and store Mini-Isolation. + # Implemention and a description of parameters can be found in: + # PhysicsTools/PatUtils/src/PFIsolation.cc + # only works in miniaod, so set to True in miniAOD_tools.py + computeMiniIso = cms.bool(False), + effectiveAreaVec = cms.vdouble(0.0566, 0.0562, 0.0363, 0.0119, 0.0064), + pfCandsForMiniIso = cms.InputTag("packedPFCandidates"), + miniIsoParams = cms.vdouble(0.05, 0.2, 10.0, 0.5, 0.0001, 0.01, 0.01, 0.01, 0.0), + + computePuppiCombinedIso = cms.bool(False), + # Standard Muon Selectors and Jet-related observables + # Depends on MiniIsolation, so only works in miniaod + # Don't forget to set flags properly in miniAOD_tools.py + computeMuonMVA = cms.bool(False), + mvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/mu_2017_BDTG.weights.xml"), + lowPtmvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/mu_lowpt_BDTG.weights.xml"), + recomputeBasicSelectors = cms.bool(False), + mvaUseJec = cms.bool(False), + mvaDrMax = cms.double(0.4), + mvaJetTag = cms.InputTag("pfCombinedInclusiveSecondaryVertexV2BJetTags"), + mvaL1Corrector = cms.InputTag("ak4PFCHSL1FastjetCorrector"), + mvaL1L2L3ResCorrector = cms.InputTag("ak4PFCHSL1FastL2L3Corrector"), + rho = cms.InputTag("fixedGridRhoFastjetCentralNeutral"), + + computeSoftMuonMVA = cms.bool(False), + softMvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/TMVA-muonid-bmm4-B-25.weights.xml"), + + # MC Info + muonSimInfo = cms.InputTag("displacedMuonSimClassifier"), # This module does not exists but producer check existence but itself + + # Trigger Info + addTriggerMatching = cms.bool(False), + triggerObjects = cms.InputTag("slimmedPatTrigger"), + triggerResults = cms.InputTag("TriggerResults","","HLT"), + hltCollectionFilters = cms.vstring('*') + +) + +patDisplacedMuons.isoDeposits = cms.PSet() +patDisplacedMuons.isolationValues = cms.PSet() + +makePatDisplacedMuonsTask = cms.Task(patDisplacedMuons) +makePatDisplacedMuons = cms.Sequence(makePatDisplacedMuonsTask) + diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py index 6f40251875909..9b6b9d394f82e 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py @@ -3,6 +3,7 @@ from PhysicsTools.PatAlgos.producersLayer1.electronProducer_cff import * from PhysicsTools.PatAlgos.producersLayer1.lowPtElectronProducer_cff import * from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cff import * +from PhysicsTools.PatAlgos.producersLayer1.displacedMuonProducer_cff import * from PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff import * from PhysicsTools.PatAlgos.producersLayer1.photonProducer_cff import * from PhysicsTools.PatAlgos.producersLayer1.ootPhotonProducer_cff import * @@ -16,6 +17,7 @@ cms.InputTag("patElectrons"), cms.InputTag("patLowPtElectrons"), cms.InputTag("patMuons"), + cms.InputTag("patDisplacedMuons"), cms.InputTag("patTaus"), cms.InputTag("patPhotons"), cms.InputTag("patOOTPhotons"), @@ -28,6 +30,7 @@ makePatElectronsTask, makePatLowPtElectronsTask, makePatMuonsTask, + makePatDisplacedMuonsTask, makePatTausTask, makePatPhotonsTask, makePatOOTPhotonsTask, diff --git a/PhysicsTools/PatAlgos/python/selectionLayer1/displacedMuonSelector_cfi.py b/PhysicsTools/PatAlgos/python/selectionLayer1/displacedMuonSelector_cfi.py new file mode 100644 index 0000000000000..5de4cb6fd54f5 --- /dev/null +++ b/PhysicsTools/PatAlgos/python/selectionLayer1/displacedMuonSelector_cfi.py @@ -0,0 +1,10 @@ +import FWCore.ParameterSet.Config as cms + +# module to select displacedMuons +# +selectedPatDisplacedMuons = cms.EDFilter("PATMuonSelector", + src = cms.InputTag("patDisplacedMuons"), + cut = cms.string("") +) + + diff --git a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py index 50381daef2318..9b57e1a85ec03 100644 --- a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py @@ -3,6 +3,7 @@ from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import * from PhysicsTools.PatAlgos.selectionLayer1.lowPtElectronSelector_cfi import * from PhysicsTools.PatAlgos.selectionLayer1.muonSelector_cfi import * +from PhysicsTools.PatAlgos.selectionLayer1.displacedMuonSelector_cfi import * from PhysicsTools.PatAlgos.selectionLayer1.tauSelector_cfi import * from PhysicsTools.PatAlgos.selectionLayer1.photonSelector_cfi import * from PhysicsTools.PatAlgos.selectionLayer1.ootPhotonSelector_cff import * @@ -16,6 +17,7 @@ cms.InputTag("selectedPatElectrons"), cms.InputTag("selectedPatLowPtElectrons"), cms.InputTag("selectedPatMuons"), + cms.InputTag("selectedPatDisplacedMuons"), cms.InputTag("selectedPatTaus"), cms.InputTag("selectedPatPhotons"), cms.InputTag("selectedPatOOTPhotons"), @@ -27,6 +29,7 @@ selectedPatElectrons, selectedPatLowPtElectrons, selectedPatMuons, + selectedPatDisplacedMuons, selectedPatTaus, selectedPatPhotons, selectedPatOOTPhotons, diff --git a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py index 5035ec39e78e4..7b285010e986c 100644 --- a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py @@ -95,6 +95,12 @@ # patLowPtElectrons 'keep *_slimmedLowPtElectrons_*_*', 'keep *_gsfTracksOpenConversions_*_*', + # patDisplacedMuons + 'keep *_slimmedDisplacedMuons_*_*', + 'keep recoTrackExtras_slimmedDisplacedMuonTrackExtras_*_*', + 'keep TrackingRecHitsOwned_slimmedDisplacedMuonTrackExtras_*_*', + 'keep SiPixelClusteredmNewDetSetVector_slimmedDisplacedMuonTrackExtras_*_*', + 'keep SiStripClusteredmNewDetSetVector_slimmedDisplacedMuonTrackExtras_*_*', ) ) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py b/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py new file mode 100644 index 0000000000000..bc2b38c46696a --- /dev/null +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py @@ -0,0 +1,21 @@ +import FWCore.ParameterSet.Config as cms + +slimmedDisplacedMuons = cms.EDProducer("PATMuonSlimmer", + src = cms.InputTag("selectedPatDisplacedMuons"), + linkToPackedPFCandidates = cms.bool(False), + pfCandidates = cms.VInputTag(cms.InputTag("particleFlow")), + packedPFCandidates = cms.VInputTag(cms.InputTag("packedPFCandidates")), + saveTeVMuons = cms.string("0"), # you can put a cut to slim selectively, e.g. pt > 10 + dropDirectionalIso = cms.string("0"), + dropPfP4 = cms.string("1"), + slimCaloVars = cms.string("1"), + slimKinkVars = cms.string("1"), + slimCaloMETCorr = cms.string("1"), + slimMatches = cms.string("1"), + segmentsMuonSelection = cms.string("pt > 50"), #segments are needed for EXO analysis looking at TOF and for very high pt from e.g. Z' + saveSegments = cms.bool(True), + modifyMuons = cms.bool(True), + modifierConfig = cms.PSet( modifications = cms.VPSet() ), + trackExtraAssocs = cms.VInputTag(["displacedMuonReducedTrackExtras", "slimmedDisplacedMuonTrackExtras"]), +) + diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py index 61997c42e81f4..614a4583c1088 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py @@ -9,6 +9,14 @@ pixelClusterTag = "muonReducedTrackExtras", stripClusterTag = "muonReducedTrackExtras") +from RecoMuon.MuonIdentification.displacedMuonReducedTrackExtras_cfi import displacedMuonReducedTrackExtras +slimmedDisplacedMuonTrackExtras = displacedMuonReducedTrackExtras.clone(muonTag = "selectedPatDisplacedMuons", + cut = "pt > 4.5", + trackExtraTags = ["displacedMuonReducedTrackExtras", "displacedStandAloneMuons"], + trackExtraAssocs = ["displacedMuonReducedTrackExtras"], + pixelClusterTag = "displacedMuonReducedTrackExtras", + stripClusterTag = "displacedMuonReducedTrackExtras") + # no clusters in fastsim from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toModify(slimmedMuonTrackExtras, outputClusters = False) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py index 306efa71e690e..1281bb9ee94bb 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py @@ -18,6 +18,7 @@ from PhysicsTools.PatAlgos.slimming.slimmedLowPtElectrons_cff import * from PhysicsTools.PatAlgos.slimming.slimmedTrackExtras_cff import * from PhysicsTools.PatAlgos.slimming.slimmedMuons_cfi import * +from PhysicsTools.PatAlgos.slimming.slimmedDisplacedMuons_cfi import * from PhysicsTools.PatAlgos.slimming.slimmedPhotons_cfi import * from PhysicsTools.PatAlgos.slimming.slimmedOOTPhotons_cff import * from PhysicsTools.PatAlgos.slimming.slimmedTaus_cfi import * @@ -52,6 +53,8 @@ slimmedLowPtElectronsTask, slimmedMuonTrackExtras, slimmedMuons, + slimmedDisplacedMuonTrackExtras, + slimmedDisplacedMuons, slimmedPhotons, slimmedOOTPhotons, slimmedTaus, From bcf92d54f4a7d156f955d4d90a5623dca29c1b3e Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Tue, 8 Mar 2022 15:18:04 +0100 Subject: [PATCH 07/21] Add displacedMuon filter --- .../python/RecoMuonPPonly_cff.py | 5 +- .../plugins/DisplacedMuonFilterProducer.cc | 241 ++++++++++++++++++ .../plugins/DisplacedMuonFilterProducer.h | 89 +++++++ RecoMuon/MuonIdentification/plugins/Module.cc | 2 + .../python/displacedMuons_cfi.py | 2 +- .../filteredDisplacedMuons1stStep_cfi.py | 27 ++ .../displacedMuonPFIsolationDeposits_cff.py | 10 +- .../python/muIsoDepositCopies_cfi.py | 6 +- 8 files changed, 372 insertions(+), 10 deletions(-) create mode 100644 RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc create mode 100644 RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h create mode 100644 RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py diff --git a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py index f390d73b97017..a3aca0e273425 100644 --- a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py +++ b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py @@ -40,6 +40,7 @@ from RecoMuon.MuonIdentification.muonIdProducerSequence_cff import * muons1stStep.fillGlobalTrackQuality = True +# Displaced muons displacedMuons1stStep = muons1stStep.clone( inputCollectionLabels = ['displacedTracks', 'displacedGlobalMuons', @@ -49,6 +50,9 @@ 'outer tracks'], fillGlobalTrackQuality = False ) +from RecoMuon.MuonIdentification.filteredDisplacedMuons1stStep_cfi import * + +displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep, filteredDisplacedMuons1stStep) #Muon Id isGood flag ValueMap producer sequence from RecoMuon.MuonIdentification.muonSelectionTypeValueMapProducer_cff import * @@ -80,7 +84,6 @@ muontrackingTask = cms.Task(standalonemuontrackingTask,globalmuontrackingTask) muontracking = cms.Sequence(muontrackingTask) # Muon Reconstruction -displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep) muonrecoTask = cms.Task(muontrackingTask,muonIdProducerTask, displacedMuonIdProducerTask) fastSim.toReplaceWith(muonrecoTask,muonrecoTask.copyAndExclude([displacedMuonIdProducerTask])) muonreco = cms.Sequence(muonrecoTask) diff --git a/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc b/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc new file mode 100644 index 0000000000000..0b9025c2896df --- /dev/null +++ b/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc @@ -0,0 +1,241 @@ +/** \class DisplacedMuonFilterProducer + * + * \author C. Fernandez Madrazo + */ + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/Math/interface/deltaR.h" + + +DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::ParameterSet& iConfig) + : srcMuons_(iConfig.getParameter("srcMuons")), + srcMuonToken_(consumes(srcMuons_)), + refMuons_(iConfig.getParameter("refMuons")), + refMuonToken_(consumes(refMuons_)), + min_Dxy_(iConfig.getParameter("minDxy")), + min_Dz_(iConfig.getParameter("minDz")), + min_DeltaR_(iConfig.getParameter("minDeltaR")), + min_DeltaPt_(iConfig.getParameter("minDeltaPt")), + fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), + fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { + + produces(); + + if (fillTimingInfo_) { + timeMapCmbToken_ = consumes(edm::InputTag(srcMuons_.label(), "combined")); + timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); + timeMapCSCToken_ = consumes(edm::InputTag(srcMuons_.label(), "csc")); + + produces("combined"); + produces("dt"); + produces("csc"); + } + + + if (fillDetectorBasedIsolation_) { + + theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); + theTrackDepositToken_ = consumes(theTrackDepositName); + + theJetDepositName = iConfig.getParameter("JetIsoDeposits"); + theJetDepositToken_ = consumes(theJetDepositName); + + theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); + theEcalDepositToken_ = consumes(theEcalDepositName); + + theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); + theHcalDepositToken_ = consumes(theHcalDepositName); + + theHoDepositName = iConfig.getParameter("HoIsoDeposits"); + theHoDepositToken_ = consumes(theHoDepositName); + + produces("tracker"); + + produces("ecal"); + + produces("hcal"); + + produces("ho"); + + produces("jets"); + } + + +} + +DisplacedMuonFilterProducer::~DisplacedMuonFilterProducer() {} +void DisplacedMuonFilterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("srcMuons", edm::InputTag("displacedMuons1stStep")); + desc.add("refMuons", edm::InputTag("muons1stStep")); + desc.add("minDxy", 0.); + desc.add("minDz", 0.); + desc.add("minDeltaR", 0.); + desc.add("minDeltaPt", 0.); + desc.add("TrackIsoDeposits", edm::InputTag("displacedMuons1stStep:tracker")); + desc.add("EcalIsoDeposits", edm::InputTag("displacedMuons1stStep:ecal")); + desc.add("HcalIsoDeposits", edm::InputTag("displacedMuons1stStep:hcal")); + desc.add("HoIsoDeposits", edm::InputTag("displacedMuons1stStep:ho")); + desc.add("JetIsoDeposits", edm::InputTag("displacedMuons1stStep:jets")); + desc.add("FillTimingInfo", true); + desc.add("FillDetectorBasedIsolation", true); + descriptions.addWithDefaultLabel(desc); +} + +// Filter muons + +void DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + auto output = std::make_unique(); + + + // muon collections + edm::Handle srcMuons; + iEvent.getByToken(srcMuonToken_, srcMuons); + + edm::Handle refMuons; + iEvent.getByToken(refMuonToken_, refMuons); + + int nMuons = srcMuons->size(); + + + // filter the muons + std::vector filteredmuons(nMuons, true); + int oMuons = nMuons; + for (unsigned int i = 0; i < srcMuons->size(); i++) { + const reco::Muon& muon(srcMuons->at(i)); + // save muon if it is displaced enough + if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ || fabs(muon.bestTrack()->dz()) > min_Dz_) { + continue; + } + // look for overlapping muons if not + for (unsigned int j = 0; j < refMuons->size(); j++) { + const reco::Muon& ref(refMuons->at(j)); + double dR = deltaR(muon.eta(), muon.phi(), ref.eta(), ref.phi() ); + double dPt = fabs(muon.pt() - ref.pt()); + if (dR < min_DeltaR_ && dPt < min_DeltaPt_) { + filteredmuons[i] = false; + oMuons = oMuons - 1; + break; + } + } + } + + // timing information + edm::Handle timeMapCmb; + edm::Handle timeMapDT; + edm::Handle timeMapCSC; + + std::vector dtTimeColl(oMuons); + std::vector cscTimeColl(oMuons); + std::vector combinedTimeColl(oMuons); + + if (fillTimingInfo_) { + iEvent.getByToken(timeMapCmbToken_, timeMapCmb); + iEvent.getByToken(timeMapDTToken_, timeMapDT); + iEvent.getByToken(timeMapCSCToken_, timeMapCSC); + } + + + // detector based isolation + std::vector trackDepColl(oMuons); + std::vector ecalDepColl(oMuons); + std::vector hcalDepColl(oMuons); + std::vector hoDepColl(oMuons); + std::vector jetDepColl(oMuons); + + edm::Handle trackIsoDepMap; + edm::Handle ecalIsoDepMap; + edm::Handle hcalIsoDepMap; + edm::Handle hoIsoDepMap; + edm::Handle jetIsoDepMap; + + if (fillDetectorBasedIsolation_) { + iEvent.getByToken(theTrackDepositToken_, trackIsoDepMap); + iEvent.getByToken(theEcalDepositToken_, ecalIsoDepMap); + iEvent.getByToken(theHcalDepositToken_, hcalIsoDepMap); + iEvent.getByToken(theHoDepositToken_, hoIsoDepMap); + iEvent.getByToken(theJetDepositToken_, jetIsoDepMap); + } + + + + // save filtered muons + unsigned int k = 0; + for (unsigned int i = 0; i < srcMuons->size(); i++) { + if (filteredmuons[i]) { + const reco::Muon& inMuon(srcMuons->at(i)); + reco::MuonRef muRef(srcMuons, i); + + // Copy the muon + reco::Muon outMuon = inMuon; + + // Fill timing information + if (fillTimingInfo_) { + combinedTimeColl[k] = (*timeMapCmb)[muRef]; + dtTimeColl[k] = (*timeMapDT)[muRef]; + cscTimeColl[k] = (*timeMapCSC)[muRef]; + } + + // Fill detector based isolation + if (fillDetectorBasedIsolation_) { + trackDepColl[k] = (*trackIsoDepMap)[muRef]; + ecalDepColl[k] = (*ecalIsoDepMap)[muRef]; + hcalDepColl[k] = (*hcalIsoDepMap)[muRef]; + hoDepColl[k] = (*hoIsoDepMap)[muRef]; + jetDepColl[k] = (*jetIsoDepMap)[muRef]; + } + + output->push_back(outMuon); + k++; + } + } + + + // fill information + edm::OrphanHandle muonHandle = iEvent.put(std::move(output)); + + fillMuonMap(iEvent, muonHandle, combinedTimeColl, "combined"); + fillMuonMap(iEvent, muonHandle, dtTimeColl, "dt"); + fillMuonMap(iEvent, muonHandle, cscTimeColl, "csc"); + + fillMuonMap(iEvent, muonHandle, trackDepColl, "tracker"); + fillMuonMap(iEvent, muonHandle, jetDepColl, "jets"); + fillMuonMap(iEvent, muonHandle, ecalDepColl, "ecal"); + fillMuonMap(iEvent, muonHandle, hcalDepColl, "hcal"); + fillMuonMap(iEvent, muonHandle, hoDepColl, "ho"); + +} + + +template +void DisplacedMuonFilterProducer::fillMuonMap(edm::Event& event, + const edm::OrphanHandle& muonHandle, + const std::vector& muonExtra, + const std::string& label) { + typedef typename edm::ValueMap::Filler FILLER; + + auto muonMap = std::make_unique>(); + if (!muonExtra.empty()) { + FILLER filler(*muonMap); + filler.insert(muonHandle, muonExtra.begin(), muonExtra.end()); + filler.fill(); + } + event.put(std::move(muonMap), label); +} + diff --git a/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h b/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h new file mode 100644 index 0000000000000..d6b245cb35311 --- /dev/null +++ b/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h @@ -0,0 +1,89 @@ +#ifndef MuonIdentification_DisplacedMuonFilterProducer_h +#define MuonIdentification_DisplacedMuonFilterProducer_h + +/** \class DisplacedMuonFilterProducer + * + * Filter applied to a given input reco::Muon collection. + * It cross-cleans between this input collection and one collection + * set for reference by removing overlapping muons. + * Output collection is made from input muons that differ from the + * ones present in the reference collection. + * + * \author C. Fernandez Madrazo + */ + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonTimeExtra.h" +#include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h" + +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h" +#include "DataFormats/RecoCandidate/interface/IsoDeposit.h" + +class DisplacedMuonFilterProducer : public edm::stream::EDProducer<> { +public: + explicit DisplacedMuonFilterProducer(const edm::ParameterSet&); + + ~DisplacedMuonFilterProducer() override; + + void produce(edm::Event&, const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + template + void fillMuonMap(edm::Event& event, + const edm::OrphanHandle& muonHandle, + const std::vector& muonExtra, + const std::string& label); + + // muon collections + const edm::InputTag srcMuons_; + const edm::EDGetTokenT srcMuonToken_; + + const edm::InputTag refMuons_; + const edm::EDGetTokenT refMuonToken_; + + // filter criteria and selection + const double min_Dxy_; // dxy threshold in cm + const double min_Dz_; // dz threshold in cm + const double min_DeltaR_; // cutoff in difference with ref eta + const double min_DeltaPt_; // cutoff in difference with ref pt + + // what information to fill + bool fillDetectorBasedIsolation_; + bool fillTimingInfo_; + + // timing info + edm::EDGetTokenT timeMapCmbToken_; + edm::EDGetTokenT timeMapDTToken_; + edm::EDGetTokenT timeMapCSCToken_; + + + // detector based isolation + edm::InputTag theTrackDepositName; + edm::InputTag theEcalDepositName; + edm::InputTag theHcalDepositName; + edm::InputTag theHoDepositName; + edm::InputTag theJetDepositName; + + std::string trackDepositName_; + std::string ecalDepositName_; + std::string hcalDepositName_; + std::string hoDepositName_; + std::string jetDepositName_; + + edm::EDGetTokenT theTrackDepositToken_; + edm::EDGetTokenT theEcalDepositToken_; + edm::EDGetTokenT theHcalDepositToken_; + edm::EDGetTokenT theHoDepositToken_; + edm::EDGetTokenT theJetDepositToken_; + +}; +#endif diff --git a/RecoMuon/MuonIdentification/plugins/Module.cc b/RecoMuon/MuonIdentification/plugins/Module.cc index 7c740feff3184..b2c3bae87b9cd 100644 --- a/RecoMuon/MuonIdentification/plugins/Module.cc +++ b/RecoMuon/MuonIdentification/plugins/Module.cc @@ -12,6 +12,7 @@ #include "RecoMuon/MuonIdentification/plugins/InterestingEcalDetIdProducer.h" #include "RecoMuon/MuonIdentification/plugins/MuonIDFilterProducerForHLT.h" #include "RecoMuon/MuonIdentification/plugins/MuonReducedTrackExtraProducer.h" +#include "RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h" DEFINE_FWK_MODULE(MuonIdProducer); DEFINE_FWK_MODULE(MuonLinksProducer); @@ -23,6 +24,7 @@ DEFINE_FWK_MODULE(MuonSelectionTypeValueMapProducer); DEFINE_FWK_MODULE(InterestingEcalDetIdProducer); DEFINE_FWK_MODULE(MuonIDFilterProducerForHLT); DEFINE_FWK_MODULE(MuonReducedTrackExtraProducer); +DEFINE_FWK_MODULE(DisplacedMuonFilterProducer); // For the VID framework #include "PhysicsTools/SelectorUtils/interface/VersionedIdProducer.h" diff --git a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py index b82eb11a0fa70..7ef209df57b8d 100644 --- a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py +++ b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py @@ -2,7 +2,7 @@ displacedMuons = cms.EDProducer("MuonProducer", ActivateDebug = cms.untracked.bool(False), - InputMuons = cms.InputTag("displacedMuons1stStep"), + InputMuons = cms.InputTag("filteredDisplacedMuons1stStep"), FillPFMomentumAndAssociation = cms.bool(True), PFCandidates = cms.InputTag("particleFlowTmp"), diff --git a/RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py b/RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py new file mode 100644 index 0000000000000..104da69c8687c --- /dev/null +++ b/RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py @@ -0,0 +1,27 @@ +import FWCore.ParameterSet.Config as cms +from RecoMuon.MuonIdentification.isolation_cff import * + +filteredDisplacedMuons1stStep = cms.EDProducer("DisplacedMuonFilterProducer", + + # Muon collections + srcMuons = cms.InputTag("displacedMuons1stStep"), + refMuons = cms.InputTag("muons1stStep"), + + FillTimingInfo = cms.bool(True), + + # Muon detector based isolation + FillDetectorBasedIsolation = cms.bool(True), + + TrackIsoDeposits = cms.InputTag("displacedMuons1stStep:tracker"), + JetIsoDeposits = cms.InputTag("displacedMuons1stStep:jets"), + EcalIsoDeposits = cms.InputTag("displacedMuons1stStep:ecal"), + HcalIsoDeposits = cms.InputTag("displacedMuons1stStep:hcal"), + HoIsoDeposits = cms.InputTag("displacedMuons1stStep:ho"), + + # Filter + minDxy = cms.double( 0.1 ), + minDz = cms.double( 5. ), + minDeltaR = cms.double( 0.01 ), + minDeltaPt = cms.double( 1.0 ) +) + diff --git a/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py index 53f5cd53a737e..38da54620a0cb 100644 --- a/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py +++ b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py @@ -4,11 +4,11 @@ #Now prepare the iso deposits for displacedMuons -dispMuPFIsoDepositCharged=isoDepositReplace('displacedMuons1stStep','pfAllChargedHadrons') -dispMuPFIsoDepositChargedAll=isoDepositReplace('displacedMuons1stStep','pfAllChargedParticles') -dispMuPFIsoDepositNeutral=isoDepositReplace('displacedMuons1stStep','pfAllNeutralHadrons') -dispMuPFIsoDepositGamma=isoDepositReplace('displacedMuons1stStep','pfAllPhotons') -dispMuPFIsoDepositPU=isoDepositReplace('displacedMuons1stStep','pfPileUpAllChargedParticles') +dispMuPFIsoDepositCharged=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllChargedHadrons') +dispMuPFIsoDepositChargedAll=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllChargedParticles') +dispMuPFIsoDepositNeutral=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllNeutralHadrons') +dispMuPFIsoDepositGamma=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllPhotons') +dispMuPFIsoDepositPU=isoDepositReplace('filteredDisplacedMuons1stStep','pfPileUpAllChargedParticles') displacedMuonPFIsolationDepositsTask = cms.Task( dispMuPFIsoDepositCharged, diff --git a/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py b/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py index cf95ff86f022d..9138242db0c8e 100644 --- a/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py +++ b/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py @@ -6,7 +6,7 @@ ) muIsoDepositTkDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", - inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:tracker")), + inputTags = cms.VInputTag(cms.InputTag("filteredDisplacedMuons1stStep:tracker")), depositNames = cms.vstring('') ) @@ -16,7 +16,7 @@ ) muIsoDepositJetsDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", - inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:jets")), + inputTags = cms.VInputTag(cms.InputTag("filteredDisplacedMuons1stStep:jets")), depositNames = cms.vstring('') ) @@ -26,7 +26,7 @@ ) muIsoDepositCalByAssociatorTowersDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", - inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:ecal"), cms.InputTag("displacedMuons1stStep:hcal"), cms.InputTag("displacedMuons1stStep:ho")), + inputTags = cms.VInputTag(cms.InputTag("filteredDisplacedMuons1stStep:ecal"), cms.InputTag("filteredDisplacedMuons1stStep:hcal"), cms.InputTag("filteredDisplacedMuons1stStep:ho")), depositNames = cms.vstring('ecal', 'hcal', 'ho') ) From e7546c9ab98f0d9ebf6411615120a8f5f7de902d Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Fri, 11 Mar 2022 13:05:18 +0100 Subject: [PATCH 08/21] Set embedHighLevelSelection to True so impact parameter info is also saved inside the pat muon --- .../python/producersLayer1/displacedMuonProducer_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py index 6e27f3c9f08dd..e5c37d020cfdb 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py @@ -38,7 +38,7 @@ genParticleMatch = "displacedMuonMatch", # deactivated # high level selections - embedHighLevelSelection = cms.bool(False), + embedHighLevelSelection = cms.bool(True), beamLineSrc = cms.InputTag("offlineBeamSpot"), pvSrc = cms.InputTag("offlinePrimaryVertices"), From 4e2b9a7e4e6046f87eef7ae05089446b8d267d5b Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Sun, 10 Apr 2022 11:04:39 +0200 Subject: [PATCH 09/21] Remove filter from RECO step --- .../python/RecoMuonPPonly_cff.py | 3 +- .../plugins/DisplacedMuonFilterProducer.cc | 241 ------------------ .../plugins/DisplacedMuonFilterProducer.h | 89 ------- RecoMuon/MuonIdentification/plugins/Module.cc | 2 - .../python/displacedMuons_cfi.py | 2 +- .../filteredDisplacedMuons1stStep_cfi.py | 27 -- .../displacedMuonPFIsolationDeposits_cff.py | 10 +- .../python/muIsoDepositCopies_cfi.py | 6 +- 8 files changed, 10 insertions(+), 370 deletions(-) delete mode 100644 RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc delete mode 100644 RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h delete mode 100644 RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py diff --git a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py index a3aca0e273425..613c927ad9f7f 100644 --- a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py +++ b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py @@ -50,9 +50,8 @@ 'outer tracks'], fillGlobalTrackQuality = False ) -from RecoMuon.MuonIdentification.filteredDisplacedMuons1stStep_cfi import * -displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep, filteredDisplacedMuons1stStep) +displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep) #Muon Id isGood flag ValueMap producer sequence from RecoMuon.MuonIdentification.muonSelectionTypeValueMapProducer_cff import * diff --git a/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc b/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc deleted file mode 100644 index 0b9025c2896df..0000000000000 --- a/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.cc +++ /dev/null @@ -1,241 +0,0 @@ -/** \class DisplacedMuonFilterProducer - * - * \author C. Fernandez Madrazo - */ - -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/Handle.h" -#include "RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h" -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "FWCore/Utilities/interface/InputTag.h" - -#include "DataFormats/Math/interface/deltaR.h" - - -DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::ParameterSet& iConfig) - : srcMuons_(iConfig.getParameter("srcMuons")), - srcMuonToken_(consumes(srcMuons_)), - refMuons_(iConfig.getParameter("refMuons")), - refMuonToken_(consumes(refMuons_)), - min_Dxy_(iConfig.getParameter("minDxy")), - min_Dz_(iConfig.getParameter("minDz")), - min_DeltaR_(iConfig.getParameter("minDeltaR")), - min_DeltaPt_(iConfig.getParameter("minDeltaPt")), - fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), - fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { - - produces(); - - if (fillTimingInfo_) { - timeMapCmbToken_ = consumes(edm::InputTag(srcMuons_.label(), "combined")); - timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); - timeMapCSCToken_ = consumes(edm::InputTag(srcMuons_.label(), "csc")); - - produces("combined"); - produces("dt"); - produces("csc"); - } - - - if (fillDetectorBasedIsolation_) { - - theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); - theTrackDepositToken_ = consumes(theTrackDepositName); - - theJetDepositName = iConfig.getParameter("JetIsoDeposits"); - theJetDepositToken_ = consumes(theJetDepositName); - - theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); - theEcalDepositToken_ = consumes(theEcalDepositName); - - theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); - theHcalDepositToken_ = consumes(theHcalDepositName); - - theHoDepositName = iConfig.getParameter("HoIsoDeposits"); - theHoDepositToken_ = consumes(theHoDepositName); - - produces("tracker"); - - produces("ecal"); - - produces("hcal"); - - produces("ho"); - - produces("jets"); - } - - -} - -DisplacedMuonFilterProducer::~DisplacedMuonFilterProducer() {} -void DisplacedMuonFilterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("srcMuons", edm::InputTag("displacedMuons1stStep")); - desc.add("refMuons", edm::InputTag("muons1stStep")); - desc.add("minDxy", 0.); - desc.add("minDz", 0.); - desc.add("minDeltaR", 0.); - desc.add("minDeltaPt", 0.); - desc.add("TrackIsoDeposits", edm::InputTag("displacedMuons1stStep:tracker")); - desc.add("EcalIsoDeposits", edm::InputTag("displacedMuons1stStep:ecal")); - desc.add("HcalIsoDeposits", edm::InputTag("displacedMuons1stStep:hcal")); - desc.add("HoIsoDeposits", edm::InputTag("displacedMuons1stStep:ho")); - desc.add("JetIsoDeposits", edm::InputTag("displacedMuons1stStep:jets")); - desc.add("FillTimingInfo", true); - desc.add("FillDetectorBasedIsolation", true); - descriptions.addWithDefaultLabel(desc); -} - -// Filter muons - -void DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - auto output = std::make_unique(); - - - // muon collections - edm::Handle srcMuons; - iEvent.getByToken(srcMuonToken_, srcMuons); - - edm::Handle refMuons; - iEvent.getByToken(refMuonToken_, refMuons); - - int nMuons = srcMuons->size(); - - - // filter the muons - std::vector filteredmuons(nMuons, true); - int oMuons = nMuons; - for (unsigned int i = 0; i < srcMuons->size(); i++) { - const reco::Muon& muon(srcMuons->at(i)); - // save muon if it is displaced enough - if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ || fabs(muon.bestTrack()->dz()) > min_Dz_) { - continue; - } - // look for overlapping muons if not - for (unsigned int j = 0; j < refMuons->size(); j++) { - const reco::Muon& ref(refMuons->at(j)); - double dR = deltaR(muon.eta(), muon.phi(), ref.eta(), ref.phi() ); - double dPt = fabs(muon.pt() - ref.pt()); - if (dR < min_DeltaR_ && dPt < min_DeltaPt_) { - filteredmuons[i] = false; - oMuons = oMuons - 1; - break; - } - } - } - - // timing information - edm::Handle timeMapCmb; - edm::Handle timeMapDT; - edm::Handle timeMapCSC; - - std::vector dtTimeColl(oMuons); - std::vector cscTimeColl(oMuons); - std::vector combinedTimeColl(oMuons); - - if (fillTimingInfo_) { - iEvent.getByToken(timeMapCmbToken_, timeMapCmb); - iEvent.getByToken(timeMapDTToken_, timeMapDT); - iEvent.getByToken(timeMapCSCToken_, timeMapCSC); - } - - - // detector based isolation - std::vector trackDepColl(oMuons); - std::vector ecalDepColl(oMuons); - std::vector hcalDepColl(oMuons); - std::vector hoDepColl(oMuons); - std::vector jetDepColl(oMuons); - - edm::Handle trackIsoDepMap; - edm::Handle ecalIsoDepMap; - edm::Handle hcalIsoDepMap; - edm::Handle hoIsoDepMap; - edm::Handle jetIsoDepMap; - - if (fillDetectorBasedIsolation_) { - iEvent.getByToken(theTrackDepositToken_, trackIsoDepMap); - iEvent.getByToken(theEcalDepositToken_, ecalIsoDepMap); - iEvent.getByToken(theHcalDepositToken_, hcalIsoDepMap); - iEvent.getByToken(theHoDepositToken_, hoIsoDepMap); - iEvent.getByToken(theJetDepositToken_, jetIsoDepMap); - } - - - - // save filtered muons - unsigned int k = 0; - for (unsigned int i = 0; i < srcMuons->size(); i++) { - if (filteredmuons[i]) { - const reco::Muon& inMuon(srcMuons->at(i)); - reco::MuonRef muRef(srcMuons, i); - - // Copy the muon - reco::Muon outMuon = inMuon; - - // Fill timing information - if (fillTimingInfo_) { - combinedTimeColl[k] = (*timeMapCmb)[muRef]; - dtTimeColl[k] = (*timeMapDT)[muRef]; - cscTimeColl[k] = (*timeMapCSC)[muRef]; - } - - // Fill detector based isolation - if (fillDetectorBasedIsolation_) { - trackDepColl[k] = (*trackIsoDepMap)[muRef]; - ecalDepColl[k] = (*ecalIsoDepMap)[muRef]; - hcalDepColl[k] = (*hcalIsoDepMap)[muRef]; - hoDepColl[k] = (*hoIsoDepMap)[muRef]; - jetDepColl[k] = (*jetIsoDepMap)[muRef]; - } - - output->push_back(outMuon); - k++; - } - } - - - // fill information - edm::OrphanHandle muonHandle = iEvent.put(std::move(output)); - - fillMuonMap(iEvent, muonHandle, combinedTimeColl, "combined"); - fillMuonMap(iEvent, muonHandle, dtTimeColl, "dt"); - fillMuonMap(iEvent, muonHandle, cscTimeColl, "csc"); - - fillMuonMap(iEvent, muonHandle, trackDepColl, "tracker"); - fillMuonMap(iEvent, muonHandle, jetDepColl, "jets"); - fillMuonMap(iEvent, muonHandle, ecalDepColl, "ecal"); - fillMuonMap(iEvent, muonHandle, hcalDepColl, "hcal"); - fillMuonMap(iEvent, muonHandle, hoDepColl, "ho"); - -} - - -template -void DisplacedMuonFilterProducer::fillMuonMap(edm::Event& event, - const edm::OrphanHandle& muonHandle, - const std::vector& muonExtra, - const std::string& label) { - typedef typename edm::ValueMap::Filler FILLER; - - auto muonMap = std::make_unique>(); - if (!muonExtra.empty()) { - FILLER filler(*muonMap); - filler.insert(muonHandle, muonExtra.begin(), muonExtra.end()); - filler.fill(); - } - event.put(std::move(muonMap), label); -} - diff --git a/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h b/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h deleted file mode 100644 index d6b245cb35311..0000000000000 --- a/RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef MuonIdentification_DisplacedMuonFilterProducer_h -#define MuonIdentification_DisplacedMuonFilterProducer_h - -/** \class DisplacedMuonFilterProducer - * - * Filter applied to a given input reco::Muon collection. - * It cross-cleans between this input collection and one collection - * set for reference by removing overlapping muons. - * Output collection is made from input muons that differ from the - * ones present in the reference collection. - * - * \author C. Fernandez Madrazo - */ - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/MuonReco/interface/MuonFwd.h" -#include "DataFormats/MuonReco/interface/Muon.h" -#include "DataFormats/MuonReco/interface/MuonTimeExtra.h" -#include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h" - -#include "DataFormats/Common/interface/ValueMap.h" -#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h" -#include "DataFormats/RecoCandidate/interface/IsoDeposit.h" - -class DisplacedMuonFilterProducer : public edm::stream::EDProducer<> { -public: - explicit DisplacedMuonFilterProducer(const edm::ParameterSet&); - - ~DisplacedMuonFilterProducer() override; - - void produce(edm::Event&, const edm::EventSetup&) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - template - void fillMuonMap(edm::Event& event, - const edm::OrphanHandle& muonHandle, - const std::vector& muonExtra, - const std::string& label); - - // muon collections - const edm::InputTag srcMuons_; - const edm::EDGetTokenT srcMuonToken_; - - const edm::InputTag refMuons_; - const edm::EDGetTokenT refMuonToken_; - - // filter criteria and selection - const double min_Dxy_; // dxy threshold in cm - const double min_Dz_; // dz threshold in cm - const double min_DeltaR_; // cutoff in difference with ref eta - const double min_DeltaPt_; // cutoff in difference with ref pt - - // what information to fill - bool fillDetectorBasedIsolation_; - bool fillTimingInfo_; - - // timing info - edm::EDGetTokenT timeMapCmbToken_; - edm::EDGetTokenT timeMapDTToken_; - edm::EDGetTokenT timeMapCSCToken_; - - - // detector based isolation - edm::InputTag theTrackDepositName; - edm::InputTag theEcalDepositName; - edm::InputTag theHcalDepositName; - edm::InputTag theHoDepositName; - edm::InputTag theJetDepositName; - - std::string trackDepositName_; - std::string ecalDepositName_; - std::string hcalDepositName_; - std::string hoDepositName_; - std::string jetDepositName_; - - edm::EDGetTokenT theTrackDepositToken_; - edm::EDGetTokenT theEcalDepositToken_; - edm::EDGetTokenT theHcalDepositToken_; - edm::EDGetTokenT theHoDepositToken_; - edm::EDGetTokenT theJetDepositToken_; - -}; -#endif diff --git a/RecoMuon/MuonIdentification/plugins/Module.cc b/RecoMuon/MuonIdentification/plugins/Module.cc index b2c3bae87b9cd..7c740feff3184 100644 --- a/RecoMuon/MuonIdentification/plugins/Module.cc +++ b/RecoMuon/MuonIdentification/plugins/Module.cc @@ -12,7 +12,6 @@ #include "RecoMuon/MuonIdentification/plugins/InterestingEcalDetIdProducer.h" #include "RecoMuon/MuonIdentification/plugins/MuonIDFilterProducerForHLT.h" #include "RecoMuon/MuonIdentification/plugins/MuonReducedTrackExtraProducer.h" -#include "RecoMuon/MuonIdentification/plugins/DisplacedMuonFilterProducer.h" DEFINE_FWK_MODULE(MuonIdProducer); DEFINE_FWK_MODULE(MuonLinksProducer); @@ -24,7 +23,6 @@ DEFINE_FWK_MODULE(MuonSelectionTypeValueMapProducer); DEFINE_FWK_MODULE(InterestingEcalDetIdProducer); DEFINE_FWK_MODULE(MuonIDFilterProducerForHLT); DEFINE_FWK_MODULE(MuonReducedTrackExtraProducer); -DEFINE_FWK_MODULE(DisplacedMuonFilterProducer); // For the VID framework #include "PhysicsTools/SelectorUtils/interface/VersionedIdProducer.h" diff --git a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py index 7ef209df57b8d..b82eb11a0fa70 100644 --- a/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py +++ b/RecoMuon/MuonIdentification/python/displacedMuons_cfi.py @@ -2,7 +2,7 @@ displacedMuons = cms.EDProducer("MuonProducer", ActivateDebug = cms.untracked.bool(False), - InputMuons = cms.InputTag("filteredDisplacedMuons1stStep"), + InputMuons = cms.InputTag("displacedMuons1stStep"), FillPFMomentumAndAssociation = cms.bool(True), PFCandidates = cms.InputTag("particleFlowTmp"), diff --git a/RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py b/RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py deleted file mode 100644 index 104da69c8687c..0000000000000 --- a/RecoMuon/MuonIdentification/python/filteredDisplacedMuons1stStep_cfi.py +++ /dev/null @@ -1,27 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from RecoMuon.MuonIdentification.isolation_cff import * - -filteredDisplacedMuons1stStep = cms.EDProducer("DisplacedMuonFilterProducer", - - # Muon collections - srcMuons = cms.InputTag("displacedMuons1stStep"), - refMuons = cms.InputTag("muons1stStep"), - - FillTimingInfo = cms.bool(True), - - # Muon detector based isolation - FillDetectorBasedIsolation = cms.bool(True), - - TrackIsoDeposits = cms.InputTag("displacedMuons1stStep:tracker"), - JetIsoDeposits = cms.InputTag("displacedMuons1stStep:jets"), - EcalIsoDeposits = cms.InputTag("displacedMuons1stStep:ecal"), - HcalIsoDeposits = cms.InputTag("displacedMuons1stStep:hcal"), - HoIsoDeposits = cms.InputTag("displacedMuons1stStep:ho"), - - # Filter - minDxy = cms.double( 0.1 ), - minDz = cms.double( 5. ), - minDeltaR = cms.double( 0.01 ), - minDeltaPt = cms.double( 1.0 ) -) - diff --git a/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py index 38da54620a0cb..53f5cd53a737e 100644 --- a/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py +++ b/RecoMuon/MuonIsolation/python/displacedMuonPFIsolationDeposits_cff.py @@ -4,11 +4,11 @@ #Now prepare the iso deposits for displacedMuons -dispMuPFIsoDepositCharged=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllChargedHadrons') -dispMuPFIsoDepositChargedAll=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllChargedParticles') -dispMuPFIsoDepositNeutral=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllNeutralHadrons') -dispMuPFIsoDepositGamma=isoDepositReplace('filteredDisplacedMuons1stStep','pfAllPhotons') -dispMuPFIsoDepositPU=isoDepositReplace('filteredDisplacedMuons1stStep','pfPileUpAllChargedParticles') +dispMuPFIsoDepositCharged=isoDepositReplace('displacedMuons1stStep','pfAllChargedHadrons') +dispMuPFIsoDepositChargedAll=isoDepositReplace('displacedMuons1stStep','pfAllChargedParticles') +dispMuPFIsoDepositNeutral=isoDepositReplace('displacedMuons1stStep','pfAllNeutralHadrons') +dispMuPFIsoDepositGamma=isoDepositReplace('displacedMuons1stStep','pfAllPhotons') +dispMuPFIsoDepositPU=isoDepositReplace('displacedMuons1stStep','pfPileUpAllChargedParticles') displacedMuonPFIsolationDepositsTask = cms.Task( dispMuPFIsoDepositCharged, diff --git a/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py b/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py index 9138242db0c8e..cf95ff86f022d 100644 --- a/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py +++ b/RecoMuon/MuonIsolationProducers/python/muIsoDepositCopies_cfi.py @@ -6,7 +6,7 @@ ) muIsoDepositTkDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", - inputTags = cms.VInputTag(cms.InputTag("filteredDisplacedMuons1stStep:tracker")), + inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:tracker")), depositNames = cms.vstring('') ) @@ -16,7 +16,7 @@ ) muIsoDepositJetsDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", - inputTags = cms.VInputTag(cms.InputTag("filteredDisplacedMuons1stStep:jets")), + inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:jets")), depositNames = cms.vstring('') ) @@ -26,7 +26,7 @@ ) muIsoDepositCalByAssociatorTowersDisplaced = cms.EDProducer("MuIsoDepositCopyProducer", - inputTags = cms.VInputTag(cms.InputTag("filteredDisplacedMuons1stStep:ecal"), cms.InputTag("filteredDisplacedMuons1stStep:hcal"), cms.InputTag("filteredDisplacedMuons1stStep:ho")), + inputTags = cms.VInputTag(cms.InputTag("displacedMuons1stStep:ecal"), cms.InputTag("displacedMuons1stStep:hcal"), cms.InputTag("displacedMuons1stStep:ho")), depositNames = cms.vstring('ecal', 'hcal', 'ho') ) From 8dd921b1e18fe5eeb64c183d9d888932530bba57 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Wed, 13 Apr 2022 09:35:49 +0200 Subject: [PATCH 10/21] Add filter to PAT displacedMuons processing --- .../plugins/DisplacedMuonFilterProducer.cc | 299 ++++++++++++++++++ .../displacedMuonProducer_cff.py | 24 +- .../recoLayer0/filteredDisplacedMuons_cfi.py | 25 ++ 3 files changed, 341 insertions(+), 7 deletions(-) create mode 100644 PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc create mode 100644 PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc new file mode 100644 index 0000000000000..8eb97bb949e84 --- /dev/null +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -0,0 +1,299 @@ +/** \class DisplacedMuonFilterProducer + * + * \author C. Fernandez Madrazo + */ + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonTimeExtra.h" +#include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h" + +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h" +#include "DataFormats/RecoCandidate/interface/IsoDeposit.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/Math/interface/deltaR.h" + +namespace pat { + class DisplacedMuonFilterProducer : public edm::stream::EDProducer<> { + public: + explicit DisplacedMuonFilterProducer(const edm::ParameterSet&); + + ~DisplacedMuonFilterProducer() override; + + void produce(edm::Event&, const edm::EventSetup&) override; + + private: + template + void fillMuonMap(edm::Event& event, + const edm::OrphanHandle& muonHandle, + const std::vector& muonExtra, + const std::string& label); + + // muon collections + const edm::InputTag srcMuons_; + const edm::EDGetTokenT srcMuonToken_; + + const edm::InputTag refMuons_; + const edm::EDGetTokenT refMuonToken_; + + // filter criteria and selection + const double min_Dxy_; // dxy threshold in cm + const double min_Dz_; // dz threshold in cm + const double min_DeltaR_; // cutoff in difference with ref eta + const double min_DeltaPt_; // cutoff in difference with ref pt + + // what information to fill + bool fillDetectorBasedIsolation_; + bool fillTimingInfo_; + + // timing info + edm::EDGetTokenT timeMapCmbToken_; + edm::EDGetTokenT timeMapDTToken_; + edm::EDGetTokenT timeMapCSCToken_; + + + // detector based isolation + edm::InputTag theTrackDepositName; + edm::InputTag theEcalDepositName; + edm::InputTag theHcalDepositName; + edm::InputTag theHoDepositName; + edm::InputTag theJetDepositName; + + std::string trackDepositName_; + std::string ecalDepositName_; + std::string hcalDepositName_; + std::string hoDepositName_; + std::string jetDepositName_; + + edm::EDGetTokenT theTrackDepositToken_; + edm::EDGetTokenT theEcalDepositToken_; + edm::EDGetTokenT theHcalDepositToken_; + edm::EDGetTokenT theHoDepositToken_; + edm::EDGetTokenT theJetDepositToken_; + + std::vector > pfIsoMapNames; + std::vector > > > pfIsoMapTokens_; + + }; +} // namespace path + +pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::ParameterSet& iConfig) + : srcMuons_(iConfig.getParameter("srcMuons")), + srcMuonToken_(consumes(srcMuons_)), + refMuons_(iConfig.getParameter("refMuons")), + refMuonToken_(consumes(refMuons_)), + min_Dxy_(iConfig.getParameter("minDxy")), + min_Dz_(iConfig.getParameter("minDz")), + min_DeltaR_(iConfig.getParameter("minDeltaR")), + min_DeltaPt_(iConfig.getParameter("minDeltaPt")), + fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), + fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { + + produces(); + + if (fillTimingInfo_) { + timeMapCmbToken_ = consumes(edm::InputTag(srcMuons_.label(), "combined")); + timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); + timeMapCSCToken_ = consumes(edm::InputTag(srcMuons_.label(), "csc")); + + produces("combined"); + produces("dt"); + produces("csc"); + } + + + if (fillDetectorBasedIsolation_) { + + theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); + theTrackDepositToken_ = consumes(theTrackDepositName); + + theJetDepositName = iConfig.getParameter("JetIsoDeposits"); + theJetDepositToken_ = consumes(theJetDepositName); + + theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); + theEcalDepositToken_ = consumes(theEcalDepositName); + + theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); + theHcalDepositToken_ = consumes(theHcalDepositName); + + theHoDepositName = iConfig.getParameter("HoIsoDeposits"); + theHoDepositToken_ = consumes(theHoDepositName); + + produces("tracker"); + + produces("ecal"); + + produces("hcal"); + + produces("ho"); + + produces("jets"); + } + +} + +pat::DisplacedMuonFilterProducer::~DisplacedMuonFilterProducer() {} + +// Filter muons + +void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + auto output = std::make_unique(); + + + // muon collections + edm::Handle srcMuons; + iEvent.getByToken(srcMuonToken_, srcMuons); + + edm::Handle refMuons; + iEvent.getByToken(refMuonToken_, refMuons); + + int nMuons = srcMuons->size(); + + + // filter the muons + std::vector filteredmuons(nMuons, true); + int oMuons = nMuons; + for (unsigned int i = 0; i < srcMuons->size(); i++) { + const reco::Muon& muon(srcMuons->at(i)); + // save muon if it is displaced enough + if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ || fabs(muon.bestTrack()->dz()) > min_Dz_) { + continue; + } + // look for overlapping muons if not + for (unsigned int j = 0; j < refMuons->size(); j++) { + const reco::Muon& ref(refMuons->at(j)); + double dR = deltaR(muon.eta(), muon.phi(), ref.eta(), ref.phi() ); + double dPt = fabs(muon.pt() - ref.pt()); + if (dR < min_DeltaR_ && dPt < min_DeltaPt_) { + filteredmuons[i] = false; + oMuons = oMuons - 1; + break; + } + } + } + + // timing information + edm::Handle timeMapCmb; + edm::Handle timeMapDT; + edm::Handle timeMapCSC; + + std::vector dtTimeColl(oMuons); + std::vector cscTimeColl(oMuons); + std::vector combinedTimeColl(oMuons); + + if (fillTimingInfo_) { + iEvent.getByToken(timeMapCmbToken_, timeMapCmb); + iEvent.getByToken(timeMapDTToken_, timeMapDT); + iEvent.getByToken(timeMapCSCToken_, timeMapCSC); + } + + + // detector based isolation + std::vector trackDepColl(oMuons); + std::vector ecalDepColl(oMuons); + std::vector hcalDepColl(oMuons); + std::vector hoDepColl(oMuons); + std::vector jetDepColl(oMuons); + + edm::Handle trackIsoDepMap; + edm::Handle ecalIsoDepMap; + edm::Handle hcalIsoDepMap; + edm::Handle hoIsoDepMap; + edm::Handle jetIsoDepMap; + + if (fillDetectorBasedIsolation_) { + iEvent.getByToken(theTrackDepositToken_, trackIsoDepMap); + iEvent.getByToken(theEcalDepositToken_, ecalIsoDepMap); + iEvent.getByToken(theHcalDepositToken_, hcalIsoDepMap); + iEvent.getByToken(theHoDepositToken_, hoIsoDepMap); + iEvent.getByToken(theJetDepositToken_, jetIsoDepMap); + } + + + // save filtered muons + unsigned int k = 0; + for (unsigned int i = 0; i < srcMuons->size(); i++) { + if (filteredmuons[i]) { + const reco::Muon& inMuon(srcMuons->at(i)); + reco::MuonRef muRef(srcMuons, i); + + // Copy the muon + reco::Muon outMuon = inMuon; + + // Fill timing information + if (fillTimingInfo_) { + combinedTimeColl[k] = (*timeMapCmb)[muRef]; + dtTimeColl[k] = (*timeMapDT)[muRef]; + cscTimeColl[k] = (*timeMapCSC)[muRef]; + } + + // Fill detector based isolation + if (fillDetectorBasedIsolation_) { + trackDepColl[k] = (*trackIsoDepMap)[muRef]; + ecalDepColl[k] = (*ecalIsoDepMap)[muRef]; + hcalDepColl[k] = (*hcalIsoDepMap)[muRef]; + hoDepColl[k] = (*hoIsoDepMap)[muRef]; + jetDepColl[k] = (*jetIsoDepMap)[muRef]; + } + + output->push_back(outMuon); + k++; + } + } + + + // fill information + edm::OrphanHandle muonHandle = iEvent.put(std::move(output)); + + if (fillTimingInfo_) { + fillMuonMap(iEvent, muonHandle, combinedTimeColl, "combined"); + fillMuonMap(iEvent, muonHandle, dtTimeColl, "dt"); + fillMuonMap(iEvent, muonHandle, cscTimeColl, "csc"); + } + + if (fillDetectorBasedIsolation_) { + fillMuonMap(iEvent, muonHandle, trackDepColl, "tracker"); + fillMuonMap(iEvent, muonHandle, jetDepColl, "jets"); + fillMuonMap(iEvent, muonHandle, ecalDepColl, "ecal"); + fillMuonMap(iEvent, muonHandle, hcalDepColl, "hcal"); + fillMuonMap(iEvent, muonHandle, hoDepColl, "ho"); + } + +} + + +template +void pat::DisplacedMuonFilterProducer::fillMuonMap(edm::Event& event, + const edm::OrphanHandle& muonHandle, + const std::vector& muonExtra, + const std::string& label) { + typedef typename edm::ValueMap::Filler FILLER; + + auto muonMap = std::make_unique>(); + if (!muonExtra.empty()) { + FILLER filler(*muonMap); + filler.insert(muonHandle, muonExtra.begin(), muonExtra.end()); + filler.fill(); + } + event.put(std::move(muonMap), label); +} + +#include "FWCore/Framework/interface/MakerMacros.h" +using pat::DisplacedMuonFilterProducer; +DEFINE_FWK_MODULE(DisplacedMuonFilterProducer); diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py index e5c37d020cfdb..96839b6e83cd1 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py @@ -4,7 +4,10 @@ from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import * -sourceMuons = cms.InputTag("displacedMuons") +from PhysicsTools.PatAlgos.recoLayer0.filteredDisplacedMuons_cfi import * +filteredDisplacedMuonsTask = cms.Task(filteredDisplacedMuons) + +sourceMuons = cms.InputTag("filteredDisplacedMuons") patDisplacedMuons = patMuons.clone( @@ -12,10 +15,10 @@ muonSource = sourceMuons, # embedding objects - embedMuonBestTrack = cms.bool(False), ## embed in AOD externally stored muon best track from global pflow - embedTunePMuonBestTrack = cms.bool(False), ## embed in AOD externally stored muon best track from muon only + embedMuonBestTrack = cms.bool(True), ## embed in AOD externally stored muon best track from global pflow + embedTunePMuonBestTrack = cms.bool(True), ## embed in AOD externally stored muon best track from muon only forceBestTrackEmbedding = cms.bool(False), ## force embedding separately the best tracks even if they're already embedded e.g. as tracker or global tracks - embedTrack = cms.bool(False), ## embed in AOD externally stored tracker track + embedTrack = cms.bool(True), ## embed in AOD externally stored tracker track embedCombinedMuon = cms.bool(True), ## embed in AOD externally stored combined muon track embedStandAloneMuon = cms.bool(True), ## embed in AOD externally stored standalone muon track embedPickyMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit picky muon track @@ -30,7 +33,7 @@ # Read and store combined inverse beta addInverseBeta = cms.bool(True), - sourceMuonTimeExtra = cms.InputTag("displacedMuons","combined"), #Use combined info, not only csc or dt (need to check if this is 'on' for displaced) + sourceMuonTimeExtra = cms.InputTag("filteredDisplacedMuons","combined"), #Use combined info, not only csc or dt (need to check if this is 'on' for displaced) # mc matching (deactivated) addGenMatch = cms.bool(False), @@ -74,7 +77,7 @@ softMvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/TMVA-muonid-bmm4-B-25.weights.xml"), # MC Info - muonSimInfo = cms.InputTag("displacedMuonSimClassifier"), # This module does not exists but producer check existence but itself + muonSimInfo = cms.InputTag("displacedMuonSimClassifier"), # This module does not exists but producer checks existence by itself # Trigger Info addTriggerMatching = cms.bool(False), @@ -87,6 +90,13 @@ patDisplacedMuons.isoDeposits = cms.PSet() patDisplacedMuons.isolationValues = cms.PSet() -makePatDisplacedMuonsTask = cms.Task(patDisplacedMuons) + + +# Displaced muon task filters the displacedMuons that overlap with standard muons +makePatDisplacedMuonsTask = cms.Task( + filteredDisplacedMuonsTask, + patDisplacedMuons + ) + makePatDisplacedMuons = cms.Sequence(makePatDisplacedMuonsTask) diff --git a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py new file mode 100644 index 0000000000000..a421d3aa93114 --- /dev/null +++ b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py @@ -0,0 +1,25 @@ +import FWCore.ParameterSet.Config as cms + +filteredDisplacedMuons = cms.EDProducer("DisplacedMuonFilterProducer", + + # Muon collections + srcMuons = cms.InputTag("displacedMuons"), + refMuons = cms.InputTag("muons"), + + FillTimingInfo = cms.bool(True), + + # Muon detector based isolation + FillDetectorBasedIsolation = cms.bool(False), + + TrackIsoDeposits = cms.InputTag("displacedMuons:tracker"), + JetIsoDeposits = cms.InputTag("displacedMuons:jets"), + EcalIsoDeposits = cms.InputTag("displacedMuons:ecal"), + HcalIsoDeposits = cms.InputTag("displacedMuons:hcal"), + HoIsoDeposits = cms.InputTag("displacedMuons:ho"), + + # Filter + minDxy = cms.double( 0.1 ), + minDz = cms.double( 5. ), + minDeltaR = cms.double( 0.01 ), + minDeltaPt = cms.double( 1.0 ) +) From a79d06d3fc30c7f16201b916bc02e6c24813c717 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Tue, 26 Apr 2022 01:12:30 +0200 Subject: [PATCH 11/21] Adjust filter parameters and add selection of PAT displacedMuons --- .../plugins/DisplacedMuonFilterProducer.cc | 49 +++++++++++++------ .../recoLayer0/filteredDisplacedMuons_cfi.py | 10 ++-- .../PatAlgos/python/slimming/miniAOD_tools.py | 1 + 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index 8eb97bb949e84..ee1a011622193 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -55,8 +55,10 @@ namespace pat { // filter criteria and selection const double min_Dxy_; // dxy threshold in cm const double min_Dz_; // dz threshold in cm - const double min_DeltaR_; // cutoff in difference with ref eta - const double min_DeltaPt_; // cutoff in difference with ref pt + const double min_DeltaR_; // cutoff in difference with ref dR (from bestTrack) + const double min_RelDeltaPt_; // cutoff in difference with ref pt (from bestTrack) + const double min_DeltaR_STA_; // cutoff in difference with ref dR (from outerTrack) + const double min_RelDeltaPt_STA_; // cutoff in difference with ref pt (from outerTrack) // what information to fill bool fillDetectorBasedIsolation_; @@ -101,7 +103,9 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet min_Dxy_(iConfig.getParameter("minDxy")), min_Dz_(iConfig.getParameter("minDz")), min_DeltaR_(iConfig.getParameter("minDeltaR")), - min_DeltaPt_(iConfig.getParameter("minDeltaPt")), + min_RelDeltaPt_(iConfig.getParameter("minRelDeltaPt")), + min_DeltaR_STA_(iConfig.getParameter("minDeltaRSTA")), + min_RelDeltaPt_STA_(iConfig.getParameter("minRelDeltaPtSTA")), fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { @@ -109,7 +113,7 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet if (fillTimingInfo_) { timeMapCmbToken_ = consumes(edm::InputTag(srcMuons_.label(), "combined")); - timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); + timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); timeMapCSCToken_ = consumes(edm::InputTag(srcMuons_.label(), "csc")); produces("combined"); @@ -120,20 +124,20 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet if (fillDetectorBasedIsolation_) { - theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); + theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); theTrackDepositToken_ = consumes(theTrackDepositName); - theJetDepositName = iConfig.getParameter("JetIsoDeposits"); - theJetDepositToken_ = consumes(theJetDepositName); + theJetDepositName = iConfig.getParameter("JetIsoDeposits"); + theJetDepositToken_ = consumes(theJetDepositName); - theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); - theEcalDepositToken_ = consumes(theEcalDepositName); + theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); + theEcalDepositToken_ = consumes(theEcalDepositName); - theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); - theHcalDepositToken_ = consumes(theHcalDepositName); + theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); + theHcalDepositToken_ = consumes(theHcalDepositName); - theHoDepositName = iConfig.getParameter("HoIsoDeposits"); - theHoDepositToken_ = consumes(theHoDepositName); + theHoDepositName = iConfig.getParameter("HoIsoDeposits"); + theHoDepositToken_ = consumes(theHoDepositName); produces("tracker"); @@ -172,19 +176,32 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev for (unsigned int i = 0; i < srcMuons->size(); i++) { const reco::Muon& muon(srcMuons->at(i)); // save muon if it is displaced enough - if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ || fabs(muon.bestTrack()->dz()) > min_Dz_) { + if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ && fabs(muon.bestTrack()->dz()) > min_Dz_) { continue; } // look for overlapping muons if not for (unsigned int j = 0; j < refMuons->size(); j++) { const reco::Muon& ref(refMuons->at(j)); double dR = deltaR(muon.eta(), muon.phi(), ref.eta(), ref.phi() ); - double dPt = fabs(muon.pt() - ref.pt()); - if (dR < min_DeltaR_ && dPt < min_DeltaPt_) { + double reldPt = fabs(muon.pt() - ref.pt())/muon.pt(); + // No STA case: + if (!muon.isStandAloneMuon() && !muon.outerTrack().isNonnull() && dR < min_DeltaR_ && reldPt < min_RelDeltaPt_) { filteredmuons[i] = false; oMuons = oMuons - 1; break; } + // STA case: + if (muon.isStandAloneMuon() && muon.outerTrack().isNonnull() && ref.isStandAloneMuon() && ref.outerTrack().isNonnull()) { + reco::TrackRef muonSTA = muon.outerTrack(); + reco::TrackRef refSTA = ref.outerTrack(); + double dRSTA = deltaR(muonSTA->eta(), muonSTA->phi(), refSTA->eta(), refSTA->phi() ); + double reldPtSTA = fabs(muonSTA->pt() - refSTA->pt())/muonSTA->pt(); + if (dR < min_DeltaR_ && reldPt < min_RelDeltaPt_ && dRSTA < min_DeltaR_STA_ && reldPtSTA < min_RelDeltaPt_STA_){ + filteredmuons[i] = false; + oMuons = oMuons - 1; + break; + } + } } } diff --git a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py index a421d3aa93114..a908594eaa938 100644 --- a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py +++ b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py @@ -18,8 +18,10 @@ HoIsoDeposits = cms.InputTag("displacedMuons:ho"), # Filter - minDxy = cms.double( 0.1 ), - minDz = cms.double( 5. ), - minDeltaR = cms.double( 0.01 ), - minDeltaPt = cms.double( 1.0 ) + minDxy = cms.double( 2 ), + minDz = cms.double( 10. ), + minDeltaR = cms.double( 0.1 ), + minRelDeltaPt = cms.double( 0.1 ), + minDeltaRSTA = cms.double( 0.1 ), + minRelDeltaPtSTA = cms.double( 0.1 ) ) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index f4ee51a85d229..c34acb0f57f92 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -120,6 +120,7 @@ def miniAOD_customizeCommon(process): # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))") + process.selectedPatDisplacedMuons.cut = cms.string("pt > 3 || (standAloneMuon().isNonnull() && standAloneMuon().pt() > 3)") from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )") From ed93959d1af21a85d5a0a51651187928b81b6df6 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Mon, 2 May 2022 11:59:50 +0200 Subject: [PATCH 12/21] Modify displacedMuon filter parameters to keep good DSA and DGL and apply filter to DTR --- .../plugins/DisplacedMuonFilterProducer.cc | 54 ++++++++----------- .../recoLayer0/filteredDisplacedMuons_cfi.py | 2 - 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index ee1a011622193..67082facb12e4 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -52,13 +52,11 @@ namespace pat { const edm::InputTag refMuons_; const edm::EDGetTokenT refMuonToken_; - // filter criteria and selection - const double min_Dxy_; // dxy threshold in cm - const double min_Dz_; // dz threshold in cm - const double min_DeltaR_; // cutoff in difference with ref dR (from bestTrack) - const double min_RelDeltaPt_; // cutoff in difference with ref pt (from bestTrack) - const double min_DeltaR_STA_; // cutoff in difference with ref dR (from outerTrack) - const double min_RelDeltaPt_STA_; // cutoff in difference with ref pt (from outerTrack) + // filter criteria and selection (displacedTracker muons) + const double min_Dxy_; // Minimum dxy + const double min_Dz_; // Minimum dz + const double min_DeltaR_; // dR difference between displaced-prompt muon + const double min_RelDeltaPt_; // Rel. pT difference between displaced-prompt // what information to fill bool fillDetectorBasedIsolation_; @@ -89,9 +87,6 @@ namespace pat { edm::EDGetTokenT theHoDepositToken_; edm::EDGetTokenT theJetDepositToken_; - std::vector > pfIsoMapNames; - std::vector > > > pfIsoMapTokens_; - }; } // namespace path @@ -104,8 +99,6 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet min_Dz_(iConfig.getParameter("minDz")), min_DeltaR_(iConfig.getParameter("minDeltaR")), min_RelDeltaPt_(iConfig.getParameter("minRelDeltaPt")), - min_DeltaR_STA_(iConfig.getParameter("minDeltaRSTA")), - min_RelDeltaPt_STA_(iConfig.getParameter("minRelDeltaPtSTA")), fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { @@ -175,28 +168,26 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev int oMuons = nMuons; for (unsigned int i = 0; i < srcMuons->size(); i++) { const reco::Muon& muon(srcMuons->at(i)); - // save muon if it is displaced enough - if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ && fabs(muon.bestTrack()->dz()) > min_Dz_) { - continue; - } - // look for overlapping muons if not - for (unsigned int j = 0; j < refMuons->size(); j++) { - const reco::Muon& ref(refMuons->at(j)); - double dR = deltaR(muon.eta(), muon.phi(), ref.eta(), ref.phi() ); - double reldPt = fabs(muon.pt() - ref.pt())/muon.pt(); - // No STA case: - if (!muon.isStandAloneMuon() && !muon.outerTrack().isNonnull() && dR < min_DeltaR_ && reldPt < min_RelDeltaPt_) { + + if (muon.isStandAloneMuon()) { + if (muon.innerTrack().isNonnull()) + continue; + if (!muon.isMatchesValid() || muon.numberOfMatches() < 2) { filteredmuons[i] = false; oMuons = oMuons - 1; - break; } - // STA case: - if (muon.isStandAloneMuon() && muon.outerTrack().isNonnull() && ref.isStandAloneMuon() && ref.outerTrack().isNonnull()) { - reco::TrackRef muonSTA = muon.outerTrack(); - reco::TrackRef refSTA = ref.outerTrack(); - double dRSTA = deltaR(muonSTA->eta(), muonSTA->phi(), refSTA->eta(), refSTA->phi() ); - double reldPtSTA = fabs(muonSTA->pt() - refSTA->pt())/muonSTA->pt(); - if (dR < min_DeltaR_ && reldPt < min_RelDeltaPt_ && dRSTA < min_DeltaR_STA_ && reldPtSTA < min_RelDeltaPt_STA_){ + } else { + // save the muon if its impact parameters are above thresholds + if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ && fabs(muon.bestTrack()->dz()) > min_Dz_) + continue; + // look for overlapping muons if not + for (unsigned int j = 0; j < refMuons->size(); j++) { + const reco::Muon& ref(refMuons->at(j)); + if (!ref.innerTrack().isNonnull()) + continue; + double dR = deltaR(muon.eta(), muon.phi(), ref.innerTrack()->eta(), ref.innerTrack()->phi() ); + double reldPt = fabs(muon.pt() - ref.innerTrack()->pt())/muon.pt(); + if (dR < min_DeltaR_ && reldPt < min_RelDeltaPt_) { filteredmuons[i] = false; oMuons = oMuons - 1; break; @@ -205,6 +196,7 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev } } + // timing information edm::Handle timeMapCmb; edm::Handle timeMapDT; diff --git a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py index a908594eaa938..5315cdd0d6c67 100644 --- a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py +++ b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py @@ -22,6 +22,4 @@ minDz = cms.double( 10. ), minDeltaR = cms.double( 0.1 ), minRelDeltaPt = cms.double( 0.1 ), - minDeltaRSTA = cms.double( 0.1 ), - minRelDeltaPtSTA = cms.double( 0.1 ) ) From 09287e009041a3418363783edef19a04b5d19b2c Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Wed, 4 May 2022 19:16:58 +0200 Subject: [PATCH 13/21] Update the filter to last version and remove the displaced sequences from eras modifiers --- .../plugins/DisplacedMuonFilterProducer.cc | 84 +++++++++++-------- .../producersLayer1/patCandidates_cff.py | 7 +- .../recoLayer0/filteredDisplacedMuons_cfi.py | 10 +-- .../selectedPatCandidates_cff.py | 7 +- .../PatAlgos/python/slimming/miniAOD_tools.py | 1 - .../python/slimming/slimmedTrackExtras_cff.py | 1 + .../PatAlgos/python/slimming/slimming_cff.py | 5 +- 7 files changed, 66 insertions(+), 49 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index 67082facb12e4..1975e0a8c7b89 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -1,6 +1,22 @@ /** \class DisplacedMuonFilterProducer * - * \author C. Fernandez Madrazo + * The filter takes a reco::Muon collection as an input and preselects + * the muons that will be processed by the next sequences. + * + * 1) StandAlone muons matched to an inner track (either as Tracker or Global muons) + * are preselected if the StandAlone track has pt > minPtSTA_ or the tracker track + * has pt > minPtTK_ + * + * (Global muon are contained in this subset) + * + * 2) StandAlone-only muons are preselected if they have number of segments > minMatches_ + * and they have pt > minPtSTA_ + * + * 3) Tracker muons without an StandAlone track are preselected if they have pt > minPtTK_ + * and they are labelled as isTrackerMuon() i.e. not RPC/GEM muons. + * + * \author C. Fernandez Madrazo + * */ // system include files @@ -49,14 +65,10 @@ namespace pat { const edm::InputTag srcMuons_; const edm::EDGetTokenT srcMuonToken_; - const edm::InputTag refMuons_; - const edm::EDGetTokenT refMuonToken_; - - // filter criteria and selection (displacedTracker muons) - const double min_Dxy_; // Minimum dxy - const double min_Dz_; // Minimum dz - const double min_DeltaR_; // dR difference between displaced-prompt muon - const double min_RelDeltaPt_; // Rel. pT difference between displaced-prompt + // filter criteria and selection + const double minPtTK_; // Minimum pt of inner tracks + const double minPtSTA_; // Minimum pt of standalone tracks + const double minMatches_; // Minimum number of matches of standalone-only muons // what information to fill bool fillDetectorBasedIsolation_; @@ -93,12 +105,9 @@ namespace pat { pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::ParameterSet& iConfig) : srcMuons_(iConfig.getParameter("srcMuons")), srcMuonToken_(consumes(srcMuons_)), - refMuons_(iConfig.getParameter("refMuons")), - refMuonToken_(consumes(refMuons_)), - min_Dxy_(iConfig.getParameter("minDxy")), - min_Dz_(iConfig.getParameter("minDz")), - min_DeltaR_(iConfig.getParameter("minDeltaR")), - min_RelDeltaPt_(iConfig.getParameter("minRelDeltaPt")), + minPtTK_(iConfig.getParameter("minPtTK")), + minPtSTA_(iConfig.getParameter("minPtSTA")), + minMatches_(iConfig.getParameter("minMatches")), fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { @@ -157,41 +166,42 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev edm::Handle srcMuons; iEvent.getByToken(srcMuonToken_, srcMuons); - edm::Handle refMuons; - iEvent.getByToken(refMuonToken_, refMuons); - int nMuons = srcMuons->size(); - // filter the muons std::vector filteredmuons(nMuons, true); int oMuons = nMuons; + for (unsigned int i = 0; i < srcMuons->size(); i++) { - const reco::Muon& muon(srcMuons->at(i)); + const reco::Muon& muon(srcMuons->at(i)); if (muon.isStandAloneMuon()) { - if (muon.innerTrack().isNonnull()) - continue; - if (!muon.isMatchesValid() || muon.numberOfMatches() < 2) { - filteredmuons[i] = false; - oMuons = oMuons - 1; + if (muon.innerTrack().isNonnull()) { + // Discard STA + GL/TR muons that are below pt threshold + if (muon.innerTrack()->pt() < minPtTK_ && muon.standAloneMuon()->pt() < minPtSTA_) { + filteredmuons[i] = false; + oMuons = oMuons - 1; + continue; + } + } else { + // Discard STA-only muons with less than minMatches_ segments and below pt threshold + if (!muon.isMatchesValid() || muon.numberOfMatches() < minMatches_ || muon.standAloneMuon()->pt() < minPtSTA_) { + filteredmuons[i] = false; + oMuons = oMuons - 1; + continue; + } } } else { - // save the muon if its impact parameters are above thresholds - if ( fabs(muon.bestTrack()->dxy()) > min_Dxy_ && fabs(muon.bestTrack()->dz()) > min_Dz_) - continue; - // look for overlapping muons if not - for (unsigned int j = 0; j < refMuons->size(); j++) { - const reco::Muon& ref(refMuons->at(j)); - if (!ref.innerTrack().isNonnull()) - continue; - double dR = deltaR(muon.eta(), muon.phi(), ref.innerTrack()->eta(), ref.innerTrack()->phi() ); - double reldPt = fabs(muon.pt() - ref.innerTrack()->pt())/muon.pt(); - if (dR < min_DeltaR_ && reldPt < min_RelDeltaPt_) { + if (muon.innerTrack().isNonnull()) { + if (muon.innerTrack()->pt() < minPtTK_ || !muon.isTrackerMuon()) { filteredmuons[i] = false; oMuons = oMuons - 1; - break; + continue; } + } else { // Should never happen + filteredmuons[i] = false; + oMuons = oMuons - 1; + continue; } } } diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py index 9b6b9d394f82e..cf77b4143e253 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py @@ -48,9 +48,12 @@ from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _mAOD = (run2_miniAOD_94XFall17 | run2_miniAOD_80XLegacy) (pp_on_AA | _mAOD).toReplaceWith(patCandidatesTask, - patCandidatesTask.copyAndExclude([makePatLowPtElectronsTask])) + patCandidatesTask.copyAndExclude([makePatLowPtElectronsTask, makePatDisplacedMuonsTask])) (pp_on_AA | _mAOD).toModify(patCandidateSummary.candidates, - func = lambda list: list.remove(cms.InputTag("patLowPtElectrons")) ) + func = lambda list: [l for l in list if l not in [cms.InputTag("patLowPtElectrons"), cms.InputTag("patDisplacedMuons")]] ) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toReplaceWith(patCandidatesTask, patCandidatesTask.copyAndExclude([makePatDisplacedMuonsTask])) patCandidates = cms.Sequence(patCandidateSummary, patCandidatesTask) diff --git a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py index 5315cdd0d6c67..b88bbd927f800 100644 --- a/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py +++ b/PhysicsTools/PatAlgos/python/recoLayer0/filteredDisplacedMuons_cfi.py @@ -4,7 +4,6 @@ # Muon collections srcMuons = cms.InputTag("displacedMuons"), - refMuons = cms.InputTag("muons"), FillTimingInfo = cms.bool(True), @@ -17,9 +16,8 @@ HcalIsoDeposits = cms.InputTag("displacedMuons:hcal"), HoIsoDeposits = cms.InputTag("displacedMuons:ho"), - # Filter - minDxy = cms.double( 2 ), - minDz = cms.double( 10. ), - minDeltaR = cms.double( 0.1 ), - minRelDeltaPt = cms.double( 0.1 ), + # Preselection criteria + minPtSTA = cms.double( 3.5 ), + minPtTK = cms.double( 3.5 ), + minMatches = cms.double( 2 ), ) diff --git a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py index 9b57e1a85ec03..3dc21d4aa4abc 100644 --- a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py @@ -46,6 +46,9 @@ from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _mAOD = (run2_miniAOD_94XFall17 | run2_miniAOD_80XLegacy) (pp_on_AA | _mAOD).toReplaceWith(selectedPatCandidatesTask, - selectedPatCandidatesTask.copyAndExclude([selectedPatLowPtElectrons])) + selectedPatCandidatesTask.copyAndExclude([selectedPatLowPtElectrons, selectedPatDisplacedMuons])) (pp_on_AA | _mAOD).toModify(selectedPatCandidateSummary.candidates, - func = lambda list: list.remove(cms.InputTag("selectedPatLowPtElectrons")) ) + func = lambda list: [l for l in list if l not in [cms.InputTag("selectedPatLowPtElectrons"), cms.InputTag("selectedPatDisplacedMuons")]] ) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toReplaceWith(selectedPatCandidatesTask, selectedPatCandidatesTask.copyAndExclude([selectedPatDisplacedMuons])) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index c34acb0f57f92..f4ee51a85d229 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -120,7 +120,6 @@ def miniAOD_customizeCommon(process): # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))") - process.selectedPatDisplacedMuons.cut = cms.string("pt > 3 || (standAloneMuon().isNonnull() && standAloneMuon().pt() > 3)") from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )") diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py index 614a4583c1088..43c4d1feceb77 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedTrackExtras_cff.py @@ -24,6 +24,7 @@ # cluster collections are different in phase 2, so skip this for now from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker phase2_tracker.toModify(slimmedMuonTrackExtras, outputClusters = False) +phase2_tracker.toModify(slimmedDisplacedMuonTrackExtras, outputClusters = False) # lower minimum pt for B-parking from Configuration.Eras.Modifier_bParking_cff import bParking diff --git a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py index 1281bb9ee94bb..2dc414dffd5fc 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py @@ -76,7 +76,7 @@ from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _mAOD = (run2_miniAOD_94XFall17 | run2_miniAOD_80XLegacy) (pp_on_AA | _mAOD).toReplaceWith(slimmingTask, - slimmingTask.copyAndExclude([slimmedLowPtElectronsTask])) + slimmingTask.copyAndExclude([slimmedLowPtElectronsTask, slimmedDisplacedMuons, slimmedDisplacedMuonTrackExtras])) from PhysicsTools.PatAlgos.slimming.hiPixelTracks_cfi import hiPixelTracks from RecoHI.HiEvtPlaneAlgos.HiEvtPlane_cfi import hiEvtPlane @@ -101,6 +101,9 @@ slimmingTask, cms.Task(slimmingTask.copy(), offlinePrimaryVerticesRecovery, offlineSlimmedPrimaryVerticesRecovery)) +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toReplaceWith(slimmingTask, slimmingTask.copyAndExclude([slimmedDisplacedMuons, slimmedDisplacedMuonTrackExtras])) + from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing _phase2_timing_slimmingTask = cms.Task(slimmingTask.copy(), offlineSlimmedPrimaryVertices4D) From ded45827d24572bb0c0ce977f2dd866d8ffcd616 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Wed, 4 May 2022 19:48:17 +0200 Subject: [PATCH 14/21] Code quality checks on new filter --- .../plugins/DisplacedMuonFilterProducer.cc | 81 ++++++++----------- 1 file changed, 34 insertions(+), 47 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index 1975e0a8c7b89..bc1e980e408ce 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -65,10 +65,10 @@ namespace pat { const edm::InputTag srcMuons_; const edm::EDGetTokenT srcMuonToken_; - // filter criteria and selection - const double minPtTK_; // Minimum pt of inner tracks - const double minPtSTA_; // Minimum pt of standalone tracks - const double minMatches_; // Minimum number of matches of standalone-only muons + // filter criteria and selection + const double minPtTK_; // Minimum pt of inner tracks + const double minPtSTA_; // Minimum pt of standalone tracks + const double minMatches_; // Minimum number of matches of standalone-only muons // what information to fill bool fillDetectorBasedIsolation_; @@ -79,7 +79,6 @@ namespace pat { edm::EDGetTokenT timeMapDTToken_; edm::EDGetTokenT timeMapCSCToken_; - // detector based isolation edm::InputTag theTrackDepositName; edm::InputTag theEcalDepositName; @@ -98,9 +97,8 @@ namespace pat { edm::EDGetTokenT theHcalDepositToken_; edm::EDGetTokenT theHoDepositToken_; edm::EDGetTokenT theJetDepositToken_; - }; -} // namespace path +} // namespace pat pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::ParameterSet& iConfig) : srcMuons_(iConfig.getParameter("srcMuons")), @@ -110,12 +108,11 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet minMatches_(iConfig.getParameter("minMatches")), fillDetectorBasedIsolation_(iConfig.getParameter("FillDetectorBasedIsolation")), fillTimingInfo_(iConfig.getParameter("FillTimingInfo")) { - produces(); if (fillTimingInfo_) { timeMapCmbToken_ = consumes(edm::InputTag(srcMuons_.label(), "combined")); - timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); + timeMapDTToken_ = consumes(edm::InputTag(srcMuons_.label(), "dt")); timeMapCSCToken_ = consumes(edm::InputTag(srcMuons_.label(), "csc")); produces("combined"); @@ -123,23 +120,21 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet produces("csc"); } - if (fillDetectorBasedIsolation_) { - - theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); + theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); theTrackDepositToken_ = consumes(theTrackDepositName); - theJetDepositName = iConfig.getParameter("JetIsoDeposits"); - theJetDepositToken_ = consumes(theJetDepositName); + theJetDepositName = iConfig.getParameter("JetIsoDeposits"); + theJetDepositToken_ = consumes(theJetDepositName); - theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); - theEcalDepositToken_ = consumes(theEcalDepositName); + theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); + theEcalDepositToken_ = consumes(theEcalDepositName); - theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); - theHcalDepositToken_ = consumes(theHcalDepositName); + theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); + theHcalDepositToken_ = consumes(theHcalDepositName); - theHoDepositName = iConfig.getParameter("HoIsoDeposits"); - theHoDepositToken_ = consumes(theHoDepositName); + theHoDepositName = iConfig.getParameter("HoIsoDeposits"); + theHoDepositToken_ = consumes(theHoDepositName); produces("tracker"); @@ -151,7 +146,6 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet produces("jets"); } - } pat::DisplacedMuonFilterProducer::~DisplacedMuonFilterProducer() {} @@ -161,7 +155,6 @@ pat::DisplacedMuonFilterProducer::~DisplacedMuonFilterProducer() {} void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { auto output = std::make_unique(); - // muon collections edm::Handle srcMuons; iEvent.getByToken(srcMuonToken_, srcMuons); @@ -171,24 +164,24 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev // filter the muons std::vector filteredmuons(nMuons, true); int oMuons = nMuons; - + for (unsigned int i = 0; i < srcMuons->size(); i++) { - const reco::Muon& muon(srcMuons->at(i)); + const reco::Muon& muon(srcMuons->at(i)); if (muon.isStandAloneMuon()) { if (muon.innerTrack().isNonnull()) { // Discard STA + GL/TR muons that are below pt threshold if (muon.innerTrack()->pt() < minPtTK_ && muon.standAloneMuon()->pt() < minPtSTA_) { - filteredmuons[i] = false; - oMuons = oMuons - 1; - continue; + filteredmuons[i] = false; + oMuons = oMuons - 1; + continue; } } else { // Discard STA-only muons with less than minMatches_ segments and below pt threshold if (!muon.isMatchesValid() || muon.numberOfMatches() < minMatches_ || muon.standAloneMuon()->pt() < minPtSTA_) { - filteredmuons[i] = false; - oMuons = oMuons - 1; - continue; + filteredmuons[i] = false; + oMuons = oMuons - 1; + continue; } } } else { @@ -198,7 +191,7 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev oMuons = oMuons - 1; continue; } - } else { // Should never happen + } else { // Should never happen filteredmuons[i] = false; oMuons = oMuons - 1; continue; @@ -206,7 +199,6 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev } } - // timing information edm::Handle timeMapCmb; edm::Handle timeMapDT; @@ -222,7 +214,6 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev iEvent.getByToken(timeMapCSCToken_, timeMapCSC); } - // detector based isolation std::vector trackDepColl(oMuons); std::vector ecalDepColl(oMuons); @@ -244,7 +235,6 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev iEvent.getByToken(theJetDepositToken_, jetIsoDepMap); } - // save filtered muons unsigned int k = 0; for (unsigned int i = 0; i < srcMuons->size(); i++) { @@ -256,19 +246,19 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev reco::Muon outMuon = inMuon; // Fill timing information - if (fillTimingInfo_) { + if (fillTimingInfo_) { combinedTimeColl[k] = (*timeMapCmb)[muRef]; - dtTimeColl[k] = (*timeMapDT)[muRef]; - cscTimeColl[k] = (*timeMapCSC)[muRef]; + dtTimeColl[k] = (*timeMapDT)[muRef]; + cscTimeColl[k] = (*timeMapCSC)[muRef]; } // Fill detector based isolation if (fillDetectorBasedIsolation_) { trackDepColl[k] = (*trackIsoDepMap)[muRef]; - ecalDepColl[k] = (*ecalIsoDepMap)[muRef]; - hcalDepColl[k] = (*hcalIsoDepMap)[muRef]; - hoDepColl[k] = (*hoIsoDepMap)[muRef]; - jetDepColl[k] = (*jetIsoDepMap)[muRef]; + ecalDepColl[k] = (*ecalIsoDepMap)[muRef]; + hcalDepColl[k] = (*hcalIsoDepMap)[muRef]; + hoDepColl[k] = (*hoIsoDepMap)[muRef]; + jetDepColl[k] = (*jetIsoDepMap)[muRef]; } output->push_back(outMuon); @@ -276,7 +266,6 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev } } - // fill information edm::OrphanHandle muonHandle = iEvent.put(std::move(output)); @@ -293,15 +282,13 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev fillMuonMap(iEvent, muonHandle, hcalDepColl, "hcal"); fillMuonMap(iEvent, muonHandle, hoDepColl, "ho"); } - } - template void pat::DisplacedMuonFilterProducer::fillMuonMap(edm::Event& event, - const edm::OrphanHandle& muonHandle, - const std::vector& muonExtra, - const std::string& label) { + const edm::OrphanHandle& muonHandle, + const std::vector& muonExtra, + const std::string& label) { typedef typename edm::ValueMap::Filler FILLER; auto muonMap = std::make_unique>(); From 8c15ceb457ec3a9a6a79d85ac768ce04ac6a13a4 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Fri, 6 May 2022 15:01:03 +0200 Subject: [PATCH 15/21] Modify tracker isolation parameters to ones optimized for displacedMuon reconstruction --- RecoMuon/Configuration/python/RecoMuonPPonly_cff.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py index 613c927ad9f7f..f534a9dca7484 100644 --- a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py +++ b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py @@ -50,6 +50,8 @@ 'outer tracks'], fillGlobalTrackQuality = False ) +displacedMuons1stStep.TrackExtractorPSet.Diff_r = cms.double(0.2) +displacedMuons1stStep.TrackExtractorPSet.Diff_z = cms.double(0.5) displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep) From c81d14301777290b3fdbd7a12d82ae72192d9f51 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Fri, 6 May 2022 15:08:24 +0200 Subject: [PATCH 16/21] Add linkToLostTrack parameter in slimmedDisplacedMuons_cfi --- .../PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py b/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py index bc2b38c46696a..fda6baa221747 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimmedDisplacedMuons_cfi.py @@ -3,8 +3,10 @@ slimmedDisplacedMuons = cms.EDProducer("PATMuonSlimmer", src = cms.InputTag("selectedPatDisplacedMuons"), linkToPackedPFCandidates = cms.bool(False), + linkToLostTrack = cms.bool(False), pfCandidates = cms.VInputTag(cms.InputTag("particleFlow")), packedPFCandidates = cms.VInputTag(cms.InputTag("packedPFCandidates")), + lostTracks = cms.InputTag("lostTracks"), saveTeVMuons = cms.string("0"), # you can put a cut to slim selectively, e.g. pt > 10 dropDirectionalIso = cms.string("0"), dropPfP4 = cms.string("1"), From 8a68b59d0f19b450725103e35ae92b4087c20298 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Sat, 7 May 2022 17:56:31 +0200 Subject: [PATCH 17/21] Exclude displacedMuons from 'run2_miniAOD_UL_preSummer20' processModifier --- .../python/producersLayer1/patCandidates_cff.py | 10 ++++++++-- .../selectionLayer1/selectedPatCandidates_cff.py | 10 ++++++++-- PhysicsTools/PatAlgos/python/slimming/slimming_cff.py | 6 +++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py index cf77b4143e253..ec234211ae007 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py @@ -48,9 +48,15 @@ from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _mAOD = (run2_miniAOD_94XFall17 | run2_miniAOD_80XLegacy) (pp_on_AA | _mAOD).toReplaceWith(patCandidatesTask, - patCandidatesTask.copyAndExclude([makePatLowPtElectronsTask, makePatDisplacedMuonsTask])) + patCandidatesTask.copyAndExclude([makePatLowPtElectronsTask])) (pp_on_AA | _mAOD).toModify(patCandidateSummary.candidates, - func = lambda list: [l for l in list if l not in [cms.InputTag("patLowPtElectrons"), cms.InputTag("patDisplacedMuons")]] ) + func = lambda list: list.remove(cms.InputTag("patLowPtElectrons")) ) + +from Configuration.ProcessModifiers.run2_miniAOD_UL_preSummer20_cff import run2_miniAOD_UL_preSummer20 +(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toReplaceWith(patCandidatesTask, + patCandidatesTask.copyAndExclude([makePatDisplacedMuonsTask])) +(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toModify(patCandidateSummary.candidates, + func = lambda list: list.remove(cms.InputTag("patDisplacedMuons")) ) from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(patCandidatesTask, patCandidatesTask.copyAndExclude([makePatDisplacedMuonsTask])) diff --git a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py index 3dc21d4aa4abc..382707db7e268 100644 --- a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py @@ -46,9 +46,15 @@ from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _mAOD = (run2_miniAOD_94XFall17 | run2_miniAOD_80XLegacy) (pp_on_AA | _mAOD).toReplaceWith(selectedPatCandidatesTask, - selectedPatCandidatesTask.copyAndExclude([selectedPatLowPtElectrons, selectedPatDisplacedMuons])) + selectedPatCandidatesTask.copyAndExclude([selectedPatLowPtElectrons])) (pp_on_AA | _mAOD).toModify(selectedPatCandidateSummary.candidates, - func = lambda list: [l for l in list if l not in [cms.InputTag("selectedPatLowPtElectrons"), cms.InputTag("selectedPatDisplacedMuons")]] ) + func = lambda list: list.remove(cms.InputTag("selectedPatLowPtElectrons")) ) + +from Configuration.ProcessModifiers.run2_miniAOD_UL_preSummer20_cff import run2_miniAOD_UL_preSummer20 +(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toReplaceWith(selectedPatCandidatesTask, + selectedPatCandidatesTask.copyAndExclude([selectedPatDisplacedMuons])) +(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toModify(selectedPatCandidateSummary.candidates, + func = lambda list: list.remove(cms.InputTag("selectedPatDisplacedMuons")) ) from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(selectedPatCandidatesTask, selectedPatCandidatesTask.copyAndExclude([selectedPatDisplacedMuons])) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py index 2dc414dffd5fc..bfd6c9d5edd46 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py @@ -76,7 +76,11 @@ from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _mAOD = (run2_miniAOD_94XFall17 | run2_miniAOD_80XLegacy) (pp_on_AA | _mAOD).toReplaceWith(slimmingTask, - slimmingTask.copyAndExclude([slimmedLowPtElectronsTask, slimmedDisplacedMuons, slimmedDisplacedMuonTrackExtras])) + slimmingTask.copyAndExclude([slimmedLowPtElectronsTask])) + +from Configuration.ProcessModifiers.run2_miniAOD_UL_preSummer20_cff import run2_miniAOD_UL_preSummer20 +(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toReplaceWith(slimmingTask, + slimmingTask.copyAndExclude([slimmedDisplacedMuons, slimmedDisplacedMuonTrackExtras])) from PhysicsTools.PatAlgos.slimming.hiPixelTracks_cfi import hiPixelTracks from RecoHI.HiEvtPlaneAlgos.HiEvtPlane_cfi import hiEvtPlane From 58a52772414c870de9acd9e8fb71f792170b9369 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Mon, 9 May 2022 15:07:30 +0200 Subject: [PATCH 18/21] Remove displacedMuon sequences from integration tests that read input without this collection --- PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py | 3 +++ PhysicsTools/PatAlgos/test/patTuple_addTriggerInfo_cfg.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py b/PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py index fa1bd5897bfd7..a5ceb82bfad31 100644 --- a/PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py +++ b/PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py @@ -27,6 +27,9 @@ process.patLowPtElectrons.genParticleMatch = "electronMatch" process.selectedPatLowPtElectrons.cut = "pt>99999." +process.filteredDisplacedMuons.srcMuons = "muons" +process.selectedPatDisplacedMuons.cut = "pt>99999." + ## ------------------------------------------------------ # In addition you usually want to change the following # parameters: diff --git a/PhysicsTools/PatAlgos/test/patTuple_addTriggerInfo_cfg.py b/PhysicsTools/PatAlgos/test/patTuple_addTriggerInfo_cfg.py index 9e7c2fe6ffa7e..c31d5b90344d8 100644 --- a/PhysicsTools/PatAlgos/test/patTuple_addTriggerInfo_cfg.py +++ b/PhysicsTools/PatAlgos/test/patTuple_addTriggerInfo_cfg.py @@ -23,6 +23,9 @@ process.patLowPtElectrons.genParticleMatch = "electronMatch" process.selectedPatLowPtElectrons.cut = "pt>99999." +process.filteredDisplacedMuons.srcMuons = "muons" +process.selectedPatDisplacedMuons.cut = "pt>99999." + ### Get PAT trigger tools from PhysicsTools.PatAlgos.tools.trigTools import * From e764212733141f9e1d633753024adb4f188318b6 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Mon, 9 May 2022 20:32:44 +0200 Subject: [PATCH 19/21] Add fillDescriptions and LogWarning to DisplacedMuonFilterProducer, exclude displacedMuons from run2_miniAOD_UL and remove unnecessary lines --- .../plugins/DisplacedMuonFilterProducer.cc | 25 +++++++++++++++++++ .../displacedMuonProducer_cff.py | 3 +-- .../producersLayer1/patCandidates_cff.py | 10 ++++---- .../selectedPatCandidates_cff.py | 10 ++++---- .../PatAlgos/python/slimming/slimming_cff.py | 6 ++--- .../python/RecoMuon_EventContent_cff.py | 1 - 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index bc1e980e408ce..b3dcde562c1db 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -28,6 +28,10 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/MuonReco/interface/Muon.h" @@ -53,6 +57,8 @@ namespace pat { ~DisplacedMuonFilterProducer() override; void produce(edm::Event&, const edm::EventSetup&) override; + /// description of config file parameters + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: template @@ -150,6 +156,23 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet pat::DisplacedMuonFilterProducer::~DisplacedMuonFilterProducer() {} +void pat::DisplacedMuonFilterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // filteredDisplacedMuons + edm::ParameterSetDescription desc; + desc.add("srcMuons", edm::InputTag("displacedMuons")); + desc.add("FillTimingInfo", true); + desc.add("FillDetectorBasedIsolation", false); + desc.add("TrackIsoDeposits", edm::InputTag("displacedMuons", "tracker")); + desc.add("JetIsoDeposits", edm::InputTag("displacedMuons", "jets")); + desc.add("EcalIsoDeposits", edm::InputTag("displacedMuons", "ecal")); + desc.add("HcalIsoDeposits", edm::InputTag("displacedMuons", "hcal")); + desc.add("HoIsoDeposits", edm::InputTag("displacedMuons", "ho")); + desc.add("minPtSTA", 3.5); + desc.add("minPtTK", 3.5); + desc.add("minMatches", 2); + descriptions.add("filteredDisplacedMuons", desc); +} + // Filter muons void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -192,6 +215,8 @@ void pat::DisplacedMuonFilterProducer::produce(edm::Event& iEvent, const edm::Ev continue; } } else { // Should never happen + edm::LogWarning("muonBadTracks") << "Muon that has not standalone nor tracker track." + << "There should be no such object. Muon is skipped."; filteredmuons[i] = false; oMuons = oMuons - 1; continue; diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py index 96839b6e83cd1..8d91957728bea 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py @@ -1,6 +1,5 @@ import FWCore.ParameterSet.Config as cms -#from PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi import * # This should be turn on when doing the muonMatch for displacedMuons from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import * @@ -33,7 +32,7 @@ # Read and store combined inverse beta addInverseBeta = cms.bool(True), - sourceMuonTimeExtra = cms.InputTag("filteredDisplacedMuons","combined"), #Use combined info, not only csc or dt (need to check if this is 'on' for displaced) + sourceMuonTimeExtra = cms.InputTag("filteredDisplacedMuons","combined"), # mc matching (deactivated) addGenMatch = cms.bool(False), diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py index ec234211ae007..1286dca89bbfd 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/patCandidates_cff.py @@ -52,11 +52,11 @@ (pp_on_AA | _mAOD).toModify(patCandidateSummary.candidates, func = lambda list: list.remove(cms.InputTag("patLowPtElectrons")) ) -from Configuration.ProcessModifiers.run2_miniAOD_UL_preSummer20_cff import run2_miniAOD_UL_preSummer20 -(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toReplaceWith(patCandidatesTask, - patCandidatesTask.copyAndExclude([makePatDisplacedMuonsTask])) -(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toModify(patCandidateSummary.candidates, - func = lambda list: list.remove(cms.InputTag("patDisplacedMuons")) ) +from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL +(pp_on_AA | _mAOD | run2_miniAOD_UL).toReplaceWith(patCandidatesTask, + patCandidatesTask.copyAndExclude([makePatDisplacedMuonsTask])) +(pp_on_AA | _mAOD | run2_miniAOD_UL).toModify(patCandidateSummary.candidates, + func = lambda list: list.remove(cms.InputTag("patDisplacedMuons")) ) from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(patCandidatesTask, patCandidatesTask.copyAndExclude([makePatDisplacedMuonsTask])) diff --git a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py index 382707db7e268..e4a4d968ac500 100644 --- a/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py +++ b/PhysicsTools/PatAlgos/python/selectionLayer1/selectedPatCandidates_cff.py @@ -50,11 +50,11 @@ (pp_on_AA | _mAOD).toModify(selectedPatCandidateSummary.candidates, func = lambda list: list.remove(cms.InputTag("selectedPatLowPtElectrons")) ) -from Configuration.ProcessModifiers.run2_miniAOD_UL_preSummer20_cff import run2_miniAOD_UL_preSummer20 -(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toReplaceWith(selectedPatCandidatesTask, - selectedPatCandidatesTask.copyAndExclude([selectedPatDisplacedMuons])) -(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toModify(selectedPatCandidateSummary.candidates, - func = lambda list: list.remove(cms.InputTag("selectedPatDisplacedMuons")) ) +from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL +(pp_on_AA | _mAOD | run2_miniAOD_UL).toReplaceWith(selectedPatCandidatesTask, + selectedPatCandidatesTask.copyAndExclude([selectedPatDisplacedMuons])) +(pp_on_AA | _mAOD | run2_miniAOD_UL).toModify(selectedPatCandidateSummary.candidates, + func = lambda list: list.remove(cms.InputTag("selectedPatDisplacedMuons")) ) from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(selectedPatCandidatesTask, selectedPatCandidatesTask.copyAndExclude([selectedPatDisplacedMuons])) diff --git a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py index bfd6c9d5edd46..1de9d39cab7a7 100644 --- a/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/slimming_cff.py @@ -78,9 +78,9 @@ (pp_on_AA | _mAOD).toReplaceWith(slimmingTask, slimmingTask.copyAndExclude([slimmedLowPtElectronsTask])) -from Configuration.ProcessModifiers.run2_miniAOD_UL_preSummer20_cff import run2_miniAOD_UL_preSummer20 -(pp_on_AA | _mAOD | run2_miniAOD_UL_preSummer20).toReplaceWith(slimmingTask, - slimmingTask.copyAndExclude([slimmedDisplacedMuons, slimmedDisplacedMuonTrackExtras])) +from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL +(pp_on_AA | _mAOD | run2_miniAOD_UL).toReplaceWith(slimmingTask, + slimmingTask.copyAndExclude([slimmedDisplacedMuons, slimmedDisplacedMuonTrackExtras])) from PhysicsTools.PatAlgos.slimming.hiPixelTracks_cfi import hiPixelTracks from RecoHI.HiEvtPlaneAlgos.HiEvtPlane_cfi import hiEvtPlane diff --git a/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py b/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py index b56b04cb1bc1d..06be3e0ba451f 100644 --- a/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py +++ b/RecoMuon/Configuration/python/RecoMuon_EventContent_cff.py @@ -44,7 +44,6 @@ 'keep recoMuonTimeExtraedmValueMap_displacedMuons_*_*', 'keep uintedmValueMap_displacedMuons_*_*', 'keep *_particleFlow_displacedMuons_*', - #'keep recoIsoDepositedmValueMap_*Displaced_*_*', # saved in RECO # Tracks known by the Muon obj 'keep recoTracks_standAloneMuons_*_*', 'keep recoTrackExtras_standAloneMuons_*_*', From 8f0ca8c6c6327c60515d5fe826f5cd642bc8aded Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Fri, 13 May 2022 19:53:52 +0200 Subject: [PATCH 20/21] Apply comments and clean the code --- .../plugins/DisplacedMuonFilterProducer.cc | 31 +------ .../displacedMuonProducer_cff.py | 91 +++++++++---------- .../python/RecoMuonPPonly_cff.py | 4 +- 3 files changed, 52 insertions(+), 74 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index b3dcde562c1db..ba81ca1e91108 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -43,11 +43,7 @@ #include "DataFormats/RecoCandidate/interface/IsoDeposit.h" #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/Math/interface/deltaR.h" namespace pat { class DisplacedMuonFilterProducer : public edm::stream::EDProducer<> { @@ -86,18 +82,6 @@ namespace pat { edm::EDGetTokenT timeMapCSCToken_; // detector based isolation - edm::InputTag theTrackDepositName; - edm::InputTag theEcalDepositName; - edm::InputTag theHcalDepositName; - edm::InputTag theHoDepositName; - edm::InputTag theJetDepositName; - - std::string trackDepositName_; - std::string ecalDepositName_; - std::string hcalDepositName_; - std::string hoDepositName_; - std::string jetDepositName_; - edm::EDGetTokenT theTrackDepositToken_; edm::EDGetTokenT theEcalDepositToken_; edm::EDGetTokenT theHcalDepositToken_; @@ -127,20 +111,15 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet } if (fillDetectorBasedIsolation_) { - theTrackDepositName = iConfig.getParameter("TrackIsoDeposits"); - theTrackDepositToken_ = consumes(theTrackDepositName); + theTrackDepositToken_ = consumes(iConfig.getParameter("TrackIsoDeposits")); - theJetDepositName = iConfig.getParameter("JetIsoDeposits"); - theJetDepositToken_ = consumes(theJetDepositName); + theJetDepositToken_ = consumes(iConfig.getParameter("JetIsoDeposits")); - theEcalDepositName = iConfig.getParameter("EcalIsoDeposits"); - theEcalDepositToken_ = consumes(theEcalDepositName); + theEcalDepositToken_ = consumes(iConfig.getParameter("EcalIsoDeposits")); - theHcalDepositName = iConfig.getParameter("HcalIsoDeposits"); - theHcalDepositToken_ = consumes(theHcalDepositName); + theHcalDepositToken_ = consumes(iConfig.getParameter("HcalIsoDeposits")); - theHoDepositName = iConfig.getParameter("HoIsoDeposits"); - theHoDepositToken_ = consumes(theHoDepositName); + theHoDepositToken_ = consumes(iConfig.getParameter("HoIsoDeposits")); produces("tracker"); diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py index 8d91957728bea..33fa195521ff9 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/displacedMuonProducer_cff.py @@ -6,83 +6,82 @@ from PhysicsTools.PatAlgos.recoLayer0.filteredDisplacedMuons_cfi import * filteredDisplacedMuonsTask = cms.Task(filteredDisplacedMuons) -sourceMuons = cms.InputTag("filteredDisplacedMuons") patDisplacedMuons = patMuons.clone( # Input collection - muonSource = sourceMuons, + muonSource = "filteredDisplacedMuons", # embedding objects - embedMuonBestTrack = cms.bool(True), ## embed in AOD externally stored muon best track from global pflow - embedTunePMuonBestTrack = cms.bool(True), ## embed in AOD externally stored muon best track from muon only - forceBestTrackEmbedding = cms.bool(False), ## force embedding separately the best tracks even if they're already embedded e.g. as tracker or global tracks - embedTrack = cms.bool(True), ## embed in AOD externally stored tracker track - embedCombinedMuon = cms.bool(True), ## embed in AOD externally stored combined muon track - embedStandAloneMuon = cms.bool(True), ## embed in AOD externally stored standalone muon track - embedPickyMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit picky muon track - embedTpfmsMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit TPFMS muon track - embedDytMuon = cms.bool(False), ## embed in AOD externally stored TeV-refit DYT muon track - embedPFCandidate = cms.bool(False), ## embed in AOD externally stored particle flow candidate + embedMuonBestTrack = True, ## embed in AOD externally stored muon best track from global pflow + embedTunePMuonBestTrack = True, ## embed in AOD externally stored muon best track from muon only + forceBestTrackEmbedding = False, ## force embedding separately the best tracks even if they're already embedded e.g. as tracker or global tracks + embedTrack = True, ## embed in AOD externally stored tracker track + embedCombinedMuon = True, ## embed in AOD externally stored combined muon track + embedStandAloneMuon = True, ## embed in AOD externally stored standalone muon track + embedPickyMuon = False, ## embed in AOD externally stored TeV-refit picky muon track + embedTpfmsMuon = False, ## embed in AOD externally stored TeV-refit TPFMS muon track + embedDytMuon = False, ## embed in AOD externally stored TeV-refit DYT muon track + embedPFCandidate = False, ## embed in AOD externally stored particle flow candidate # embedding of muon MET corrections for caloMET - embedCaloMETMuonCorrs = cms.bool(False), + embedCaloMETMuonCorrs = False, # embedding of muon MET corrections for tcMET - embedTcMETMuonCorrs = cms.bool(False), # removed from RECO/AOD! + embedTcMETMuonCorrs = False, # removed from RECO/AOD! # Read and store combined inverse beta - addInverseBeta = cms.bool(True), - sourceMuonTimeExtra = cms.InputTag("filteredDisplacedMuons","combined"), + addInverseBeta = True, + sourceMuonTimeExtra = ["filteredDisplacedMuons","combined"], # mc matching (deactivated) - addGenMatch = cms.bool(False), - embedGenMatch = cms.bool(False), + addGenMatch = False, + embedGenMatch = False, genParticleMatch = "displacedMuonMatch", # deactivated # high level selections - embedHighLevelSelection = cms.bool(True), - beamLineSrc = cms.InputTag("offlineBeamSpot"), - pvSrc = cms.InputTag("offlinePrimaryVertices"), + embedHighLevelSelection = True, + beamLineSrc = "offlineBeamSpot", + pvSrc = "offlinePrimaryVertices", # ecal PF energy - embedPfEcalEnergy = cms.bool(False), - addPuppiIsolation = cms.bool(False), + embedPfEcalEnergy = False, + addPuppiIsolation = False, # Compute and store Mini-Isolation. # Implemention and a description of parameters can be found in: # PhysicsTools/PatUtils/src/PFIsolation.cc # only works in miniaod, so set to True in miniAOD_tools.py - computeMiniIso = cms.bool(False), - effectiveAreaVec = cms.vdouble(0.0566, 0.0562, 0.0363, 0.0119, 0.0064), - pfCandsForMiniIso = cms.InputTag("packedPFCandidates"), - miniIsoParams = cms.vdouble(0.05, 0.2, 10.0, 0.5, 0.0001, 0.01, 0.01, 0.01, 0.0), + computeMiniIso = False, + effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064], + pfCandsForMiniIso = "packedPFCandidates", + miniIsoParams = [0.05, 0.2, 10.0, 0.5, 0.0001, 0.01, 0.01, 0.01, 0.0], - computePuppiCombinedIso = cms.bool(False), + computePuppiCombinedIso = False, # Standard Muon Selectors and Jet-related observables # Depends on MiniIsolation, so only works in miniaod # Don't forget to set flags properly in miniAOD_tools.py - computeMuonMVA = cms.bool(False), - mvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/mu_2017_BDTG.weights.xml"), - lowPtmvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/mu_lowpt_BDTG.weights.xml"), - recomputeBasicSelectors = cms.bool(False), - mvaUseJec = cms.bool(False), - mvaDrMax = cms.double(0.4), - mvaJetTag = cms.InputTag("pfCombinedInclusiveSecondaryVertexV2BJetTags"), - mvaL1Corrector = cms.InputTag("ak4PFCHSL1FastjetCorrector"), - mvaL1L2L3ResCorrector = cms.InputTag("ak4PFCHSL1FastL2L3Corrector"), - rho = cms.InputTag("fixedGridRhoFastjetCentralNeutral"), - - computeSoftMuonMVA = cms.bool(False), - softMvaTrainingFile = cms.FileInPath("RecoMuon/MuonIdentification/data/TMVA-muonid-bmm4-B-25.weights.xml"), + computeMuonMVA = False, + mvaTrainingFile = "RecoMuon/MuonIdentification/data/mu_2017_BDTG.weights.xml", + lowPtmvaTrainingFile = "RecoMuon/MuonIdentification/data/mu_lowpt_BDTG.weights.xml", + recomputeBasicSelectors = False, + mvaUseJec = False, + mvaDrMax = 0.4, + mvaJetTag = "pfCombinedInclusiveSecondaryVertexV2BJetTags", + mvaL1Corrector = "ak4PFCHSL1FastjetCorrector", + mvaL1L2L3ResCorrector = "ak4PFCHSL1FastL2L3Corrector", + rho = "fixedGridRhoFastjetCentralNeutral", + + computeSoftMuonMVA = False, + softMvaTrainingFile = "RecoMuon/MuonIdentification/data/TMVA-muonid-bmm4-B-25.weights.xml", # MC Info - muonSimInfo = cms.InputTag("displacedMuonSimClassifier"), # This module does not exists but producer checks existence by itself + muonSimInfo = "displacedMuonSimClassifier", # This module does not exists but producer checks existence by itself # Trigger Info - addTriggerMatching = cms.bool(False), - triggerObjects = cms.InputTag("slimmedPatTrigger"), - triggerResults = cms.InputTag("TriggerResults","","HLT"), - hltCollectionFilters = cms.vstring('*') + addTriggerMatching = False, + triggerObjects = "slimmedPatTrigger", + triggerResults = ["TriggerResults","","HLT"], + hltCollectionFilters = ['*'] ) diff --git a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py index f534a9dca7484..a59d02fa956a1 100644 --- a/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py +++ b/RecoMuon/Configuration/python/RecoMuonPPonly_cff.py @@ -50,8 +50,8 @@ 'outer tracks'], fillGlobalTrackQuality = False ) -displacedMuons1stStep.TrackExtractorPSet.Diff_r = cms.double(0.2) -displacedMuons1stStep.TrackExtractorPSet.Diff_z = cms.double(0.5) +displacedMuons1stStep.TrackExtractorPSet.Diff_r = 0.2 +displacedMuons1stStep.TrackExtractorPSet.Diff_z = 0.5 displacedMuonIdProducerTask = cms.Task(displacedMuons1stStep) From 27c8a9938bcaeb1f80e7fb2c4ba5a97c4dd79cc6 Mon Sep 17 00:00:00 2001 From: Andrea Perrotta Date: Fri, 13 May 2022 23:38:44 +0200 Subject: [PATCH 21/21] Update DisplacedMuonFilterProducer.cc --- .../PatAlgos/plugins/DisplacedMuonFilterProducer.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc index ba81ca1e91108..28c227dd6f963 100644 --- a/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/DisplacedMuonFilterProducer.cc @@ -32,6 +32,7 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/MuonReco/interface/Muon.h" @@ -44,7 +45,6 @@ #include "DataFormats/Common/interface/Handle.h" - namespace pat { class DisplacedMuonFilterProducer : public edm::stream::EDProducer<> { public: @@ -112,23 +112,14 @@ pat::DisplacedMuonFilterProducer::DisplacedMuonFilterProducer(const edm::Paramet if (fillDetectorBasedIsolation_) { theTrackDepositToken_ = consumes(iConfig.getParameter("TrackIsoDeposits")); - theJetDepositToken_ = consumes(iConfig.getParameter("JetIsoDeposits")); - theEcalDepositToken_ = consumes(iConfig.getParameter("EcalIsoDeposits")); - theHcalDepositToken_ = consumes(iConfig.getParameter("HcalIsoDeposits")); - theHoDepositToken_ = consumes(iConfig.getParameter("HoIsoDeposits")); - produces("tracker"); - produces("ecal"); - produces("hcal"); - produces("ho"); - produces("jets"); } }