Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:55

0001 #include "L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapShowerProducer.h"
0002 #include "L1Trigger/L1TMuonEndCap/interface/Common.h"
0003 
0004 namespace {
0005   template <typename F>
0006   void forEachProcessor(F&& func) {
0007     for (int endcap = emtf::MIN_ENDCAP; endcap <= emtf::MAX_ENDCAP; ++endcap) {
0008       for (int sector = emtf::MIN_TRIGSECTOR; sector <= emtf::MAX_TRIGSECTOR; ++sector) {
0009         const int es = (endcap - emtf::MIN_ENDCAP) * (emtf::MAX_TRIGSECTOR - emtf::MIN_TRIGSECTOR + 1) +
0010                        (sector - emtf::MIN_TRIGSECTOR);
0011         func(endcap, sector, es);
0012       }
0013     }
0014   }
0015 }  // namespace
0016 
0017 L1TMuonEndCapShowerProducer::L1TMuonEndCapShowerProducer(const edm::ParameterSet& iConfig)
0018     : tokenCSCShower_(consumes<CSCShowerDigiCollection>(iConfig.getParameter<edm::InputTag>("CSCShowerInput"))),
0019       sector_processors_shower_() {
0020   // Make output products
0021   produces<l1t::RegionalMuonShowerBxCollection>("EMTF");
0022 
0023   forEachProcessor([&](const int endcap, const int sector, const int es) {
0024     sector_processors_shower_.at(es).configure(iConfig, endcap, sector);
0025   });
0026 }
0027 
0028 L1TMuonEndCapShowerProducer::~L1TMuonEndCapShowerProducer() {}
0029 
0030 void L1TMuonEndCapShowerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0031   // Create pointers to output products
0032   auto out_showers = std::make_unique<l1t::RegionalMuonShowerBxCollection>();
0033   out_showers->clear();
0034   out_showers->setBXRange(-2, 2);
0035 
0036   edm::Handle<CSCShowerDigiCollection> showersH;
0037   iEvent.getByToken(tokenCSCShower_, showersH);
0038   const CSCShowerDigiCollection& showers = *showersH.product();
0039 
0040   // ___________________________________________________________________________
0041   // Run the sector processors
0042   forEachProcessor([&](const int endcap, const int sector, const int es) {
0043     sector_processors_shower_.at(es).process(showers, *out_showers);
0044   });
0045 
0046   // Fill the output products
0047   iEvent.put(std::move(out_showers), "EMTF");
0048 }
0049 
0050 void L1TMuonEndCapShowerProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0051   edm::ParameterSetDescription desc;
0052   // these are different shower selections that can be enabled
0053   desc.add<bool>("enableOneLooseShower", true);
0054   desc.add<bool>("enableOneNominalShower", true);
0055   desc.add<bool>("enableOneTightShower", true);
0056   desc.add<bool>("enableTwoLooseShowers", false);
0057   desc.add<edm::InputTag>("CSCShowerInput", edm::InputTag("simCscTriggerPrimitiveDigis"));
0058   descriptions.add("simEmtfShowersDef", desc);
0059   descriptions.setComment("This is the generic cfi file for the EMTF shower producer");
0060 }
0061 
0062 // Define this as a plug-in
0063 DEFINE_FWK_MODULE(L1TMuonEndCapShowerProducer);