From ec5e2f592a66f5e4e209f7aa8e8b3f01040d71ec Mon Sep 17 00:00:00 2001 From: Giovanni Abbiendi Date: Tue, 1 Jun 2021 22:55:48 +0200 Subject: [PATCH 1/3] protect for missing reco::BeamSpot --- Validation/RecoMuon/plugins/MuonTrackValidator.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Validation/RecoMuon/plugins/MuonTrackValidator.cc b/Validation/RecoMuon/plugins/MuonTrackValidator.cc index 9450ceb52181d..7f904e608ebd2 100644 --- a/Validation/RecoMuon/plugins/MuonTrackValidator.cc +++ b/Validation/RecoMuon/plugins/MuonTrackValidator.cc @@ -421,8 +421,10 @@ void MuonTrackValidator::analyze(const edm::Event& event, const edm::EventSetup& TrackingParticleRefVector const& tPC = *ptr_TPrefV; edm::Handle recoBeamSpotHandle; - event.getByToken(bsSrc_Token, recoBeamSpotHandle); - reco::BeamSpot bs = *recoBeamSpotHandle; + bool bs_Available = event.getByToken(bsSrc_Token, recoBeamSpotHandle); + reco::BeamSpot bs; + if (bs_Available) bs = *recoBeamSpotHandle; + edm::LogVerbatim("MuonTrackValidator") << bs; std::vector associator; if (UseAssociators) { From 0600d8902ff44ae106a2a8a8933a67993750364a Mon Sep 17 00:00:00 2001 From: Giovanni Abbiendi Date: Tue, 1 Jun 2021 22:56:28 +0200 Subject: [PATCH 2/3] protect for missing HLT muon tracks --- SimMuon/MCTruth/plugins/MuonAssociatorEDProducer.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SimMuon/MCTruth/plugins/MuonAssociatorEDProducer.cc b/SimMuon/MCTruth/plugins/MuonAssociatorEDProducer.cc index 1ece0d8deeefd..7fc685e60e5dc 100644 --- a/SimMuon/MCTruth/plugins/MuonAssociatorEDProducer.cc +++ b/SimMuon/MCTruth/plugins/MuonAssociatorEDProducer.cc @@ -108,10 +108,6 @@ void MuonAssociatorEDProducer::produce(edm::Event &event, const edm::EventSetup else LogTrace("MuonAssociatorEDProducer") << "\t... NOT FOUND."; - edm::RefToBaseVector tmpT; - for (size_t i = 0; i < trackCollection->size(); ++i) - tmpT.push_back(trackCollection->refAt(i)); - std::unique_ptr rts; std::unique_ptr str; @@ -122,6 +118,10 @@ void MuonAssociatorEDProducer::produce(edm::Event &event, const edm::EventSetup LogTrace("MuonAssociatorEDProducer") << "\n ignoring missing track collection." << "\n"; } else { + edm::RefToBaseVector tmpT; + for (size_t i = 0; i < trackCollection->size(); ++i) + tmpT.push_back(trackCollection->refAt(i)); + edm::LogVerbatim("MuonAssociatorEDProducer") << "\n >>> RecoToSim association <<< \n" << " Track collection : " << tracksTag.label() << ":" << tracksTag.instance() From 04affc87befcfce4ff1eebe9457f62dab6dd4244 Mon Sep 17 00:00:00 2001 From: Giovanni Abbiendi Date: Tue, 1 Jun 2021 23:29:48 +0200 Subject: [PATCH 3/3] code format --- Validation/RecoMuon/plugins/MuonTrackValidator.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Validation/RecoMuon/plugins/MuonTrackValidator.cc b/Validation/RecoMuon/plugins/MuonTrackValidator.cc index 7f904e608ebd2..4b510f47e3642 100644 --- a/Validation/RecoMuon/plugins/MuonTrackValidator.cc +++ b/Validation/RecoMuon/plugins/MuonTrackValidator.cc @@ -423,7 +423,8 @@ void MuonTrackValidator::analyze(const edm::Event& event, const edm::EventSetup& edm::Handle recoBeamSpotHandle; bool bs_Available = event.getByToken(bsSrc_Token, recoBeamSpotHandle); reco::BeamSpot bs; - if (bs_Available) bs = *recoBeamSpotHandle; + if (bs_Available) + bs = *recoBeamSpotHandle; edm::LogVerbatim("MuonTrackValidator") << bs; std::vector associator;