Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // system include files
0002 #include <memory>
0003 #include <fstream>
0004 
0005 // user include files
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/stream/EDProducer.h"
0010 
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/Utilities/interface/ESGetToken.h"
0016 
0017 #include "DataFormats/L1TMuon/interface/RegionalMuonShower.h"
0018 #include "DataFormats/L1Trigger/interface/MuonShower.h"
0019 
0020 using namespace l1t;
0021 
0022 class L1TMuonShowerProducer : public edm::stream::EDProducer<> {
0023 public:
0024   explicit L1TMuonShowerProducer(const edm::ParameterSet&);
0025   ~L1TMuonShowerProducer() override;
0026 
0027   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028 
0029 private:
0030   void produce(edm::Event&, const edm::EventSetup&) override;
0031 
0032   edm::InputTag showerInputTag_;
0033   edm::EDGetTokenT<l1t::RegionalMuonShowerBxCollection> showerInputToken_;
0034   int bxMin_;
0035   int bxMax_;
0036 };
0037 
0038 L1TMuonShowerProducer::L1TMuonShowerProducer(const edm::ParameterSet& iConfig)
0039     : showerInputTag_(iConfig.getParameter<edm::InputTag>("showerInput")),
0040       showerInputToken_(consumes<l1t::RegionalMuonShowerBxCollection>(showerInputTag_)),
0041       bxMin_(iConfig.getParameter<int>("bxMin")),
0042       bxMax_(iConfig.getParameter<int>("bxMax")) {
0043   produces<MuonShowerBxCollection>();
0044 }
0045 
0046 L1TMuonShowerProducer::~L1TMuonShowerProducer() {}
0047 
0048 // ------------ method called to produce the data  ------------
0049 void L1TMuonShowerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0050   using namespace edm;
0051   std::unique_ptr<MuonShowerBxCollection> outShowers(new MuonShowerBxCollection());
0052 
0053   Handle<l1t::RegionalMuonShowerBxCollection> emtfShowers;
0054   iEvent.getByToken(showerInputToken_, emtfShowers);
0055   outShowers->setBXRange(bxMin_, bxMax_);
0056 
0057   /*
0058     Check each sector for a valid EMTF shower. A valid EMTF shower
0059     for startup Run-3 can either be "one nominal shower" or "one tight shower".
0060     The case  "two loose showers" is under consideration but needs more study.
0061     Showers that arrive out-of-time are also under consideration, but are not
0062     going be to enabled at startup Run-3. So all showers should be in-time.
0063    */
0064   bool isOneNominalInTime{false};
0065   bool isTwoLooseInTime{false};
0066   bool isOneTightInTime{false};
0067   bool isTwoLooseDifferentSectorsInTime{false};
0068 
0069   bool foundOneLoose{false};
0070   for (size_t i = 0; i < emtfShowers->size(0); ++i) {
0071     auto shower = emtfShowers->at(0, i);
0072     if (shower.isValid()) {
0073       // nominal
0074       if (shower.isOneNominalInTime()) {
0075         isOneNominalInTime = true;
0076       }
0077       // two loose
0078       if (shower.isTwoLooseInTime()) {
0079         isTwoLooseInTime = true;
0080       }
0081       // tight
0082       if (shower.isOneTightInTime()) {
0083         isOneTightInTime = true;
0084       }
0085       // two loose in different sectors
0086       if (shower.isOneLooseInTime()) {
0087         if (foundOneLoose) {
0088           isTwoLooseDifferentSectorsInTime = true;
0089         } else {
0090           foundOneLoose = true;
0091         }
0092       }
0093     }
0094   }
0095 
0096   // Check for at least one nominal shower
0097   const bool acceptCondition{isOneNominalInTime or isTwoLooseInTime or isOneTightInTime or
0098                              isTwoLooseDifferentSectorsInTime};
0099 
0100   if (acceptCondition) {
0101     MuonShower outShower(
0102         isOneNominalInTime, false, isTwoLooseInTime, false, isOneTightInTime, false, isTwoLooseDifferentSectorsInTime);
0103     outShowers->push_back(0, outShower);
0104   }
0105   iEvent.put(std::move(outShowers));
0106 }
0107 
0108 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0109 void L1TMuonShowerProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0110   edm::ParameterSetDescription desc;
0111   desc.add<edm::InputTag>("showerInput", edm::InputTag("simEmtfShowers", "EMTF"));
0112   desc.add<int32_t>("bxMin", 0);
0113   desc.add<int32_t>("bxMax", 0);
0114   descriptions.add("simGmtShowerDigisDef", desc);
0115 }
0116 
0117 //define this as a plug-in
0118 DEFINE_FWK_MODULE(L1TMuonShowerProducer);