From 5e90eab2ca35cf47a4ab5157fabba8af14019e5f Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 28 Dec 2022 16:39:40 +0100 Subject: [PATCH 1/6] Fix use-after-move in L1MuDTTrackFinder --- L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.cc | 2 +- L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.h | 2 +- L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.cc b/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.cc index 7080ede3e9489..dced9e5cd6a59 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.cc @@ -60,7 +60,7 @@ using namespace std; // Constructors -- //---------------- -L1MuDTEtaProcessor::L1MuDTEtaProcessor(const L1MuDTTrackFinder& tf, int id, edm::ConsumesCollector&& iC) +L1MuDTEtaProcessor::L1MuDTEtaProcessor(const L1MuDTTrackFinder& tf, int id, edm::ConsumesCollector iC) : m_tf(tf), m_epid(id), m_foundPattern(0), diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.h b/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.h index e33809b65cacb..6203629214c33 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.h +++ b/L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.h @@ -58,7 +58,7 @@ class L1MuDTQualPatternLutRcd; class L1MuDTEtaProcessor { public: /// constructor - L1MuDTEtaProcessor(const L1MuDTTrackFinder&, int id, edm::ConsumesCollector&& iC); + L1MuDTEtaProcessor(const L1MuDTTrackFinder&, int id, edm::ConsumesCollector iC); /// destructor virtual ~L1MuDTEtaProcessor(); diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc index 1be2a0016ea4c..db4fbda7a2536 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc @@ -124,7 +124,7 @@ void L1MuDTTrackFinder::setup(edm::ConsumesCollector&& iC) { continue; for (int sc = 0; sc < 12; sc++) { L1MuDTSecProcId tmpspid(wh, sc); - L1MuDTSectorProcessor* sp = new L1MuDTSectorProcessor(*this, tmpspid, std::move(iC)); + L1MuDTSectorProcessor* sp = new L1MuDTSectorProcessor(*this, tmpspid, iC); if (m_config->Debug(2)) cout << "creating " << tmpspid << endl; m_spmap->insert(tmpspid, sp); @@ -133,7 +133,7 @@ void L1MuDTTrackFinder::setup(edm::ConsumesCollector&& iC) { // create new eta processors and wedge sorters for (int sc = 0; sc < 12; sc++) { - L1MuDTEtaProcessor* ep = new L1MuDTEtaProcessor(*this, sc, std::move(iC)); + L1MuDTEtaProcessor* ep = new L1MuDTEtaProcessor(*this, sc, iC); if (m_config->Debug(2)) cout << "creating Eta Processor " << sc << endl; m_epvec.push_back(ep); From 48a98001464c902389ceaaff1caa11a39cbb3fd2 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 28 Dec 2022 16:44:30 +0100 Subject: [PATCH 2/6] Replace owning raw pointers with std::unique_ptr --- .../interface/L1MuDTTrackFinder.h | 14 ++-- .../DTTrackFinder/src/L1MuDTSecProcMap.cc | 15 +--- .../DTTrackFinder/src/L1MuDTSecProcMap.h | 5 +- .../DTTrackFinder/src/L1MuDTTrackFinder.cc | 81 +++++++------------ 4 files changed, 41 insertions(+), 74 deletions(-) diff --git a/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h b/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h index c41d83980e249..105475d22a822 100644 --- a/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h +++ b/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h @@ -79,13 +79,13 @@ class L1MuDTTrackFinder { const L1MuDTSectorProcessor* sp(const L1MuDTSecProcId&) const; /// get a pointer to an Eta Processor, index [0-11] - inline const L1MuDTEtaProcessor* ep(int id) const { return m_epvec[id]; } + inline const L1MuDTEtaProcessor* ep(int id) const { return m_epvec[id].get(); } /// get a pointer to a Wedge Sorter, index [0-11] - inline const L1MuDTWedgeSorter* ws(int id) const { return m_wsvec[id]; } + inline const L1MuDTWedgeSorter* ws(int id) const { return m_wsvec[id].get(); } /// get a pointer to the DT Muon Sorter - inline const L1MuDTMuonSorter* ms() const { return m_ms; } + inline const L1MuDTMuonSorter* ms() const { return m_ms.get(); } /// get number of muon candidates found by the barrel MTTF int numberOfTracks(); @@ -116,10 +116,10 @@ class L1MuDTTrackFinder { private: std::vector _cache0; std::vector _cache; - L1MuDTSecProcMap* m_spmap; ///< Sector Processors - std::vector m_epvec; ///< Eta Processors - std::vector m_wsvec; ///< Wedge Sorters - L1MuDTMuonSorter* m_ms; ///< DT Muon Sorter + std::unique_ptr m_spmap; ///< Sector Processors + std::vector> m_epvec; ///< Eta Processors + std::vector> m_wsvec; ///< Wedge Sorters + std::unique_ptr m_ms; ///< DT Muon Sorter edm::EDGetTokenT m_DTDigiToken; static std::shared_ptr m_config; ///< Track Finder configuration diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc index 874195788ef57..ce66dd16b2029 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc @@ -46,14 +46,7 @@ L1MuDTSecProcMap::L1MuDTSecProcMap() : m_map() {} // Destructor -- //-------------- -L1MuDTSecProcMap::~L1MuDTSecProcMap() { - SPmap_iter iter = m_map.begin(); - while (iter != m_map.end()) { - delete (*iter).second; - iter++; - } - m_map.clear(); -} +L1MuDTSecProcMap::~L1MuDTSecProcMap() = default; //-------------- // Operations -- @@ -68,16 +61,16 @@ L1MuDTSectorProcessor* L1MuDTSecProcMap::sp(const L1MuDTSecProcId& id) const { // cerr << "Error: Sector Processor not in the map" << endl; return nullptr; } - return (*it).second; + return (*it).second.get(); } // // insert Sector Processor into container // -void L1MuDTSecProcMap::insert(const L1MuDTSecProcId& id, L1MuDTSectorProcessor* sp) { +void L1MuDTSecProcMap::insert(const L1MuDTSecProcId& id, std::unique_ptr sp) { //SPmap::const_iterator it = m_map.find(id); // if ( it != m_map.end() ) // cerr << "Error: More than one Sector Processor with same identifier" // << endl; - m_map[id] = sp; + m_map[id] = std::move(sp); } diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h index de323e7ba923e..aec1bb9429b33 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h +++ b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h @@ -19,6 +19,7 @@ //--------------- #include +#include //---------------------- // Base Class Headers -- @@ -37,7 +38,7 @@ class L1MuDTSectorProcessor; class L1MuDTSecProcMap { public: - typedef std::map > SPmap; + typedef std::map> SPmap; typedef SPmap::iterator SPmap_iter; /// constructor @@ -50,7 +51,7 @@ class L1MuDTSecProcMap { L1MuDTSectorProcessor* sp(const L1MuDTSecProcId&) const; /// insert a Sector Processor into the container - void insert(const L1MuDTSecProcId&, L1MuDTSectorProcessor* sp); + void insert(const L1MuDTSecProcId&, std::unique_ptr sp); /// return number of entries present in the container inline int size() const { return m_map.size(); } diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc index db4fbda7a2536..6812bcce5b316 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc @@ -66,10 +66,9 @@ L1MuDTTrackFinder::L1MuDTTrackFinder(const edm::ParameterSet& ps, edm::ConsumesC if (m_config->Debug(1)) cout << endl; - m_spmap = new L1MuDTSecProcMap(); + m_spmap = std::make_unique(); m_epvec.reserve(12); m_wsvec.reserve(12); - m_ms = nullptr; _cache.reserve(4 * 17); _cache0.reserve(144 * 17); @@ -81,25 +80,7 @@ L1MuDTTrackFinder::L1MuDTTrackFinder(const edm::ParameterSet& ps, edm::ConsumesC // Destructor -- //-------------- -L1MuDTTrackFinder::~L1MuDTTrackFinder() { - delete m_spmap; - - vector::iterator it_ep = m_epvec.begin(); - while (it_ep != m_epvec.end()) { - delete (*it_ep); - it_ep++; - } - m_epvec.clear(); - - vector::iterator it_ws = m_wsvec.begin(); - while (it_ws != m_wsvec.end()) { - delete (*it_ws); - it_ws++; - } - m_wsvec.clear(); - - delete m_ms; -} +L1MuDTTrackFinder::~L1MuDTTrackFinder() = default; //-------------- // Operations -- @@ -124,29 +105,29 @@ void L1MuDTTrackFinder::setup(edm::ConsumesCollector&& iC) { continue; for (int sc = 0; sc < 12; sc++) { L1MuDTSecProcId tmpspid(wh, sc); - L1MuDTSectorProcessor* sp = new L1MuDTSectorProcessor(*this, tmpspid, iC); + auto sp = std::make_unique(*this, tmpspid, iC); if (m_config->Debug(2)) cout << "creating " << tmpspid << endl; - m_spmap->insert(tmpspid, sp); + m_spmap->insert(tmpspid, std::move(sp)); } } // create new eta processors and wedge sorters for (int sc = 0; sc < 12; sc++) { - L1MuDTEtaProcessor* ep = new L1MuDTEtaProcessor(*this, sc, iC); + auto ep = std::make_unique(*this, sc, iC); if (m_config->Debug(2)) cout << "creating Eta Processor " << sc << endl; - m_epvec.push_back(ep); - L1MuDTWedgeSorter* ws = new L1MuDTWedgeSorter(*this, sc); + m_epvec.push_back(std::move(ep)); + auto ws = std::make_unique(*this, sc); if (m_config->Debug(2)) cout << "creating Wedge Sorter " << sc << endl; - m_wsvec.push_back(ws); + m_wsvec.push_back(std::move(ws)); } // create new muon sorter if (m_config->Debug(2)) cout << "creating DT Muon Sorter " << endl; - m_ms = new L1MuDTMuonSorter(*this); + m_ms = std::make_unique(*this); } // @@ -193,15 +174,13 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { } // run eta processors - vector::iterator it_ep = m_epvec.begin(); - while (it_ep != m_epvec.end()) { + for (auto& ep : m_epvec) { if (m_config->Debug(2)) - cout << "running Eta Processor " << (*it_ep)->id() << endl; - if (*it_ep) - (*it_ep)->run(bx, e, c); - if (m_config->Debug(2) && *it_ep) - (*it_ep)->print(); - it_ep++; + cout << "running Eta Processor " << ep->id() << endl; + if (ep) + ep->run(bx, e, c); + if (m_config->Debug(2) && ep) + ep->print(); } // read sector processors @@ -227,15 +206,13 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { } // run wedge sorters - vector::iterator it_ws = m_wsvec.begin(); - while (it_ws != m_wsvec.end()) { + for (auto& ws : m_wsvec) { if (m_config->Debug(2)) - cout << "running Wedge Sorter " << (*it_ws)->id() << endl; - if (*it_ws) - (*it_ws)->run(); - if (m_config->Debug(2) && *it_ws) - (*it_ws)->print(); - it_ws++; + cout << "running Wedge Sorter " << ws->id() << endl; + if (ws) + ws->run(); + if (m_config->Debug(2) && ws) + ws->print(); } // run muon sorter @@ -269,18 +246,14 @@ void L1MuDTTrackFinder::reset() { it_sp++; } - vector::iterator it_ep = m_epvec.begin(); - while (it_ep != m_epvec.end()) { - if (*it_ep) - (*it_ep)->reset(); - it_ep++; + for (auto& ep : m_epvec) { + if (ep) + ep->reset(); } - vector::iterator it_ws = m_wsvec.begin(); - while (it_ws != m_wsvec.end()) { - if (*it_ws) - (*it_ws)->reset(); - it_ws++; + for (auto& ws : m_wsvec) { + if (ws) + ws->reset(); } if (m_ms) From 2f862207e4033362490a9a6051ae6485247646c2 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 28 Dec 2022 17:08:44 +0100 Subject: [PATCH 3/6] const function needs to return pointer to const --- L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc | 2 +- L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc index ce66dd16b2029..ffe88260a104c 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.cc @@ -55,7 +55,7 @@ L1MuDTSecProcMap::~L1MuDTSecProcMap() = default; // // return Sector Processor // -L1MuDTSectorProcessor* L1MuDTSecProcMap::sp(const L1MuDTSecProcId& id) const { +const L1MuDTSectorProcessor* L1MuDTSecProcMap::sp(const L1MuDTSecProcId& id) const { SPmap::const_iterator it = m_map.find(id); if (it == m_map.end()) { // cerr << "Error: Sector Processor not in the map" << endl; diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h index aec1bb9429b33..92c2fa3d06097 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h +++ b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h @@ -48,7 +48,7 @@ class L1MuDTSecProcMap { virtual ~L1MuDTSecProcMap(); /// return pointer to Sector Processor - L1MuDTSectorProcessor* sp(const L1MuDTSecProcId&) const; + const L1MuDTSectorProcessor* sp(const L1MuDTSecProcId&) const; /// insert a Sector Processor into the container void insert(const L1MuDTSecProcId&, std::unique_ptr sp); From c52652fe7556813d6ddc1a0ef3de160537a7f921 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 28 Dec 2022 17:12:04 +0100 Subject: [PATCH 4/6] Remove unnecessary virtual function specifiers Also L1MuDTTrackFinder.h::reconstruct() function altogether as it was unused --- L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h | 9 +-------- L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h b/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h index 105475d22a822..0cd9555b08206 100644 --- a/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h +++ b/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h @@ -64,7 +64,7 @@ class L1MuDTTrackFinder { L1MuDTTrackFinder(const edm::ParameterSet& ps, edm::ConsumesCollector&& iC); /// destructor - virtual ~L1MuDTTrackFinder(); + ~L1MuDTTrackFinder(); /// build the structure of the barrel MTTF void setup(edm::ConsumesCollector&& iC); @@ -106,13 +106,6 @@ class L1MuDTTrackFinder { std::vector& getcache() { return _cache; } -private: - /// run Track Finder and store candidates in cache - virtual void reconstruct(const edm::Event& e, const edm::EventSetup& c) { - reset(); - run(e, c); - } - private: std::vector _cache0; std::vector _cache; diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h index 92c2fa3d06097..5e4527a0033d2 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h +++ b/L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h @@ -45,7 +45,7 @@ class L1MuDTSecProcMap { L1MuDTSecProcMap(); /// destructor - virtual ~L1MuDTSecProcMap(); + ~L1MuDTSecProcMap(); /// return pointer to Sector Processor const L1MuDTSectorProcessor* sp(const L1MuDTSecProcId&) const; From d54a8414643a0e7de62c28c97420d0efbb8e02f8 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 28 Dec 2022 17:21:58 +0100 Subject: [PATCH 5/6] Make config() non-static member function Nothing depended on it being static --- L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h | 4 ++-- L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h b/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h index 0cd9555b08206..ed246191452ce 100644 --- a/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h +++ b/L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h @@ -100,7 +100,7 @@ class L1MuDTTrackFinder { int numberOfTracks(int bx); /// return configuration - static L1MuDTTFConfig* config() { return m_config.get(); } + const L1MuDTTFConfig* config() const { return m_config.get(); } std::vector& getcache0() { return _cache0; } @@ -115,7 +115,7 @@ class L1MuDTTrackFinder { std::unique_ptr m_ms; ///< DT Muon Sorter edm::EDGetTokenT m_DTDigiToken; - static std::shared_ptr m_config; ///< Track Finder configuration + std::unique_ptr m_config; ///< Track Finder configuration }; #endif diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc index 6812bcce5b316..58ad249b4da01 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc @@ -53,11 +53,7 @@ using namespace std; L1MuDTTrackFinder::L1MuDTTrackFinder(const edm::ParameterSet& ps, edm::ConsumesCollector&& iC) { // set configuration parameters - if (not m_config) { - auto temp = std::make_shared(ps); - std::shared_ptr empty; - std::atomic_compare_exchange_strong(&m_config, &empty, temp); - } + m_config = std::make_unique(ps); if (m_config->Debug(1)) cout << endl; @@ -291,7 +287,3 @@ int L1MuDTTrackFinder::numberOfTracks(int bx) { return number; } - -// static data members - -std::shared_ptr L1MuDTTrackFinder::m_config; From 3f7b8032e936e372709e7c170a6459fd163f6b2d Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 28 Dec 2022 17:28:07 +0100 Subject: [PATCH 6/6] Use range for loop --- .../DTTrackFinder/src/L1MuDTTrackFinder.cc | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc index 58ad249b4da01..7dd195d816f52 100644 --- a/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc +++ b/L1Trigger/DTTrackFinder/src/L1MuDTTrackFinder.cc @@ -158,15 +158,13 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { reset(); // run sector processors - L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin(); - while (it_sp != m_spmap->end()) { + for (auto& sp : *m_spmap) { if (m_config->Debug(2)) - cout << "running " << (*it_sp).second->id() << endl; - if ((*it_sp).second) - (*it_sp).second->run(bx, e, c); - if (m_config->Debug(2) && (*it_sp).second) - (*it_sp).second->print(); - it_sp++; + cout << "running " << sp.second->id() << endl; + if (sp.second) + sp.second->run(bx, e, c); + if (m_config->Debug(2) && sp.second) + sp.second->print(); } // run eta processors @@ -180,12 +178,11 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { } // read sector processors - it_sp = m_spmap->begin(); - while (it_sp != m_spmap->end()) { + for (auto& sp : *m_spmap) { if (m_config->Debug(2)) - cout << "reading " << (*it_sp).second->id() << endl; + cout << "reading " << sp.second->id() << endl; for (int number = 0; number < 2; number++) { - const L1MuDTTrack* cand = (*it_sp).second->tracK(number); + const L1MuDTTrack* cand = sp.second->tracK(number); if (cand && !cand->empty()) _cache0.push_back(L1MuDTTrackCand(cand->getDataWord(), cand->bx(), @@ -198,7 +195,6 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { cand->address(4), cand->tc())); } - it_sp++; } // run wedge sorters @@ -221,11 +217,9 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { // store found track candidates in container (cache) if (m_ms->numberOfTracks() > 0) { - const vector& mttf_cont = m_ms->tracks(); - vector::const_iterator iter; - for (iter = mttf_cont.begin(); iter != mttf_cont.end(); iter++) { - if (*iter) - _cache.push_back(L1MuRegionalCand((*iter)->getDataWord(), (*iter)->bx())); + for (auto const& mttf : m_ms->tracks()) { + if (mttf) + _cache.push_back(L1MuRegionalCand(mttf->getDataWord(), mttf->bx())); } } } @@ -235,11 +229,9 @@ void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) { // reset MTTF // void L1MuDTTrackFinder::reset() { - L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin(); - while (it_sp != m_spmap->end()) { - if ((*it_sp).second) - (*it_sp).second->reset(); - it_sp++; + for (auto& sp : *m_spmap) { + if (sp.second) + sp.second->reset(); } for (auto& ep : m_epvec) { @@ -280,8 +272,8 @@ void L1MuDTTrackFinder::clear() { // int L1MuDTTrackFinder::numberOfTracks(int bx) { int number = 0; - for (TFtracks_const_iter it = _cache.begin(); it != _cache.end(); it++) { - if ((*it).bx() == bx) + for (auto const& elem : _cache) { + if (elem.bx() == bx) number++; }