From 87a4b125cbedea6b2e8e79fb79c747757ab0c474 Mon Sep 17 00:00:00 2001 From: Benjamin Huber Date: Tue, 16 Apr 2024 15:12:33 +0200 Subject: [PATCH] Adapt HLT filters to new AlgoBlock container --- HLTrigger/HLTfilters/plugins/HLTDoubletDZ.cc | 43 +++++++++---------- HLTrigger/HLTfilters/plugins/HLTDoubletDZ.h | 2 +- .../Muon/plugins/HLTMuonTrkL1TkMuFilter.cc | 20 ++++----- .../Muon/plugins/HLTMuonTrkL1TkMuFilter.h | 2 +- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.cc b/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.cc index 7a1acc02db6e4..85574dcfaac3e 100644 --- a/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.cc +++ b/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.cc @@ -47,7 +47,7 @@ HLTDoubletDZ::HLTDoubletDZ(const edm::Pa originTag2_(iConfig.getParameter>("originTag2")), electronToken_(edm::EDGetTokenT()), l1GTAlgoBlockTag_(iConfig.template getParameter("l1GTAlgoBlockTag")), - algoBlockToken_(consumes>(l1GTAlgoBlockTag_)), + algoBlockToken_(consumes(l1GTAlgoBlockTag_)), l1GTAlgoName1_(iConfig.template getParameter("l1GTAlgoName1")), l1GTAlgoName2_(iConfig.template getParameter("l1GTAlgoName2")), triggerType1_(iConfig.getParameter("triggerType1")), @@ -394,29 +394,26 @@ bool HLTDoubletDZ::getCollections( std::vector& coll1, std::vector& coll2, trigger::TriggerFilterObjectWithRefs& filterproduct) const { - const std::vector& algos = iEvent.get(algoBlockToken_); - - if (!algos.empty()) { - for (const l1t::P2GTAlgoBlock& algo : algos) { - if (algo.algoName() == l1GTAlgoName1_ && algo.decisionBeforeBxMaskAndPrescale()) { - const l1t::P2GTCandidateVectorRef& objects = algo.trigObjects(); - for (const l1t::P2GTCandidateRef& obj : objects) { - if ((triggerType1_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) || - (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) || - (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) { - coll1.push_back(obj); - } - } + const l1t::P2GTAlgoBlockMap& algos = iEvent.get(algoBlockToken_); + + if (algos.count(l1GTAlgoName1_) > 0 && algos.at(l1GTAlgoName1_).decisionBeforeBxMaskAndPrescale()) { + const l1t::P2GTCandidateVectorRef& objects = algos.at(l1GTAlgoName1_).trigObjects(); + for (const l1t::P2GTCandidateRef& obj : objects) { + if ((triggerType1_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) || + (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) || + (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) { + coll1.push_back(obj); } - if (algo.algoName() == l1GTAlgoName2_ && algo.decisionBeforeBxMaskAndPrescale()) { - const l1t::P2GTCandidateVectorRef& objects = algo.trigObjects(); - for (const l1t::P2GTCandidateRef& obj : objects) { - if ((triggerType2_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) || - (triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) || - (triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) { - coll2.push_back(obj); - } - } + } + } + + if (algos.count(l1GTAlgoName2_) > 0 && algos.at(l1GTAlgoName2_).decisionBeforeBxMaskAndPrescale()) { + const l1t::P2GTCandidateVectorRef& objects = algos.at(l1GTAlgoName2_).trigObjects(); + for (const l1t::P2GTCandidateRef& obj : objects) { + if ((triggerType2_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) || + (triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) || + (triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) { + coll2.push_back(obj); } } } diff --git a/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.h b/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.h index 1dcab21e69fe4..e2e672403a327 100644 --- a/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.h +++ b/HLTrigger/HLTfilters/plugins/HLTDoubletDZ.h @@ -57,7 +57,7 @@ class HLTDoubletDZ : public HLTFilter { const edm::EDGetTokenT inputToken2_; const edm::EDGetTokenT electronToken_; const edm::InputTag l1GTAlgoBlockTag_; - const edm::EDGetTokenT> algoBlockToken_; + const edm::EDGetTokenT algoBlockToken_; const std::string l1GTAlgoName1_; const std::string l1GTAlgoName2_; const int triggerType1_; diff --git a/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.cc b/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.cc index 1a4c07aa01b18..1ef02debe0888 100644 --- a/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.cc +++ b/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.cc @@ -29,7 +29,7 @@ HLTMuonTrkL1TkMuFilter::HLTMuonTrkL1TkMuFilter(const edm::ParameterSet& iConfig) m_candsTag = iConfig.getParameter("inputCandCollection"); m_candsToken = consumes(m_candsTag); m_l1GTAlgoBlockTag = iConfig.getParameter("l1GTAlgoBlockTag"); - m_algoBlockToken = consumes>(m_l1GTAlgoBlockTag); + m_algoBlockToken = consumes(m_l1GTAlgoBlockTag); m_l1GTAlgoNames = iConfig.getParameter>("l1GTAlgoNames"); m_minTrkHits = iConfig.getParameter("minTrkHits"); m_minMuonHits = iConfig.getParameter("minMuonHits"); @@ -76,16 +76,14 @@ bool HLTMuonTrkL1TkMuFilter::hltFilter(edm::Event& iEvent, if (m_l1GTAlgoBlockTag == edm::InputTag("") || m_l1GTAlgoNames.empty()) check_l1match = false; if (check_l1match) { - const std::vector& algos = iEvent.get(m_algoBlockToken); - for (const l1t::P2GTAlgoBlock& algo : algos) { - for (auto& algoName : m_l1GTAlgoNames) { - if (algo.algoName() == algoName && algo.decisionBeforeBxMaskAndPrescale()) { - const l1t::P2GTCandidateVectorRef& objects = algo.trigObjects(); - for (const l1t::P2GTCandidateRef& obj : objects) { - if (obj->objectType() == l1t::P2GTCandidate::ObjectType::GMTTkMuons) { - vl1cands.push_back(obj); - LogDebug("HLTMuonTrkL1TkMuFilter") << "Found P2GTCandidate ObjectType::GMTTkMuons" << std::endl; - } + const l1t::P2GTAlgoBlockMap& algos = iEvent.get(m_algoBlockToken); + for (auto& algoName : m_l1GTAlgoNames) { + if (algos.count(algoName) > 0 && algos.at(algoName).decisionBeforeBxMaskAndPrescale()) { + const l1t::P2GTCandidateVectorRef& objects = algos.at(algoName).trigObjects(); + for (const l1t::P2GTCandidateRef& obj : objects) { + if (obj->objectType() == l1t::P2GTCandidate::ObjectType::GMTTkMuons) { + vl1cands.push_back(obj); + LogDebug("HLTMuonTrkL1TkMuFilter") << "Found P2GTCandidate ObjectType::GMTTkMuons" << std::endl; } } } diff --git a/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.h b/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.h index dcd96c300d7c6..c464dd28c4461 100644 --- a/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.h +++ b/HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.h @@ -29,7 +29,7 @@ class HLTMuonTrkL1TkMuFilter : public HLTFilter { edm::InputTag m_candsTag; // input collection of candidates to be referenced edm::EDGetTokenT m_candsToken; // input collection of candidates to be referenced edm::InputTag m_l1GTAlgoBlockTag; - edm::EDGetTokenT> m_algoBlockToken; + edm::EDGetTokenT m_algoBlockToken; std::vector m_l1GTAlgoNames; int m_minTrkHits; int m_minMuonHits;