11#include " L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapShowerProducer.h"
22#include " L1Trigger/L1TMuonEndCap/interface/Common.h"
33
4+ namespace {
5+ template <typename F>
6+ void forEachProcessor (F&& func) {
7+ for (int endcap = emtf::MIN_ENDCAP; endcap <= emtf::MAX_ENDCAP; ++endcap) {
8+ for (int sector = emtf::MIN_TRIGSECTOR; sector <= emtf::MAX_TRIGSECTOR; ++sector) {
9+ const int es = (endcap - emtf::MIN_ENDCAP) * (emtf::MAX_TRIGSECTOR - emtf::MIN_TRIGSECTOR + 1 ) +
10+ (sector - emtf::MIN_TRIGSECTOR);
11+ func (endcap, sector, es);
12+ }
13+ }
14+ }
15+ } // namespace
16+
417L1TMuonEndCapShowerProducer::L1TMuonEndCapShowerProducer (const edm::ParameterSet& iConfig)
5- : config_(iConfig),
6- tokenCSCShower_(consumes<CSCShowerDigiCollection>(iConfig.getParameter<edm::InputTag>(" CSCShowerInput" ))),
18+ : tokenCSCShower_(consumes<CSCShowerDigiCollection>(iConfig.getParameter<edm::InputTag>(" CSCShowerInput" ))),
719 sector_processors_shower_() {
820 // Make output products
921 produces<l1t::RegionalMuonShowerBxCollection>(" EMTF" );
22+
23+ forEachProcessor ([&](const int endcap, const int sector, const int es) {
24+ sector_processors_shower_.at (es).configure (iConfig, endcap, sector);
25+ });
1026}
1127
1228L1TMuonEndCapShowerProducer::~L1TMuonEndCapShowerProducer () {}
@@ -23,16 +39,9 @@ void L1TMuonEndCapShowerProducer::produce(edm::Event& iEvent, const edm::EventSe
2339
2440 // ___________________________________________________________________________
2541 // Run the sector processors
26-
27- for (int endcap = emtf::MIN_ENDCAP; endcap <= emtf::MAX_ENDCAP; ++endcap) {
28- for (int sector = emtf::MIN_TRIGSECTOR; sector <= emtf::MAX_TRIGSECTOR; ++sector) {
29- const int es = (endcap - emtf::MIN_ENDCAP) * (emtf::MAX_TRIGSECTOR - emtf::MIN_TRIGSECTOR + 1 ) +
30- (sector - emtf::MIN_TRIGSECTOR);
31-
32- sector_processors_shower_.at (es).configure (config_, endcap, sector);
33- sector_processors_shower_.at (es).process (showers, *out_showers);
34- }
35- }
42+ forEachProcessor ([&](const int endcap, const int sector, const int es) {
43+ sector_processors_shower_.at (es).process (showers, *out_showers);
44+ });
3645
3746 // Fill the output products
3847 iEvent.put (std::move (out_showers), " EMTF" );
0 commit comments