Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-01 23:54:08

0001 #include <memory>
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/stream/EDProducer.h"
0004 
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Utilities/interface/StreamID.h"
0010 
0011 #include "L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTEndcapStubProcessor.h"
0012 #include "L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTBarrelStubProcessor.h"
0013 
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/ConsumesCollector.h"
0016 #include "FWCore/Framework/interface/ESProducts.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 //
0019 // class declaration
0020 //
0021 
0022 class Phase2L1TGMTStubProducer : public edm::stream::EDProducer<> {
0023 public:
0024   explicit Phase2L1TGMTStubProducer(const edm::ParameterSet&);
0025   ~Phase2L1TGMTStubProducer() override;
0026 
0027   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028 
0029 private:
0030   void beginStream(edm::StreamID) override;
0031   void produce(edm::Event&, const edm::EventSetup&) override;
0032   void endStream() override;
0033 
0034   edm::EDGetTokenT<MuonDigiCollection<CSCDetId, CSCCorrelatedLCTDigi>> srcCSC_;
0035   edm::EDGetTokenT<L1Phase2MuDTPhContainer> srcDT_;
0036   edm::EDGetTokenT<L1MuDTChambThContainer> srcDTTheta_;
0037   edm::EDGetTokenT<RPCDigiCollection> srcRPC_;
0038 
0039   L1TPhase2GMTEndcapStubProcessor* procEndcap_;
0040   L1TPhase2GMTBarrelStubProcessor* procBarrel_;
0041   L1TMuon::GeometryTranslator* translator_;
0042   int verbose_;
0043 };
0044 
0045 Phase2L1TGMTStubProducer::Phase2L1TGMTStubProducer(const edm::ParameterSet& iConfig)
0046     : srcCSC_(
0047           consumes<MuonDigiCollection<CSCDetId, CSCCorrelatedLCTDigi>>(iConfig.getParameter<edm::InputTag>("srcCSC"))),
0048       srcDT_(consumes<L1Phase2MuDTPhContainer>(iConfig.getParameter<edm::InputTag>("srcDT"))),
0049       srcDTTheta_(consumes<L1MuDTChambThContainer>(iConfig.getParameter<edm::InputTag>("srcDTTheta"))),
0050       srcRPC_(consumes<RPCDigiCollection>(iConfig.getParameter<edm::InputTag>("srcRPC"))),
0051       procEndcap_(new L1TPhase2GMTEndcapStubProcessor(iConfig.getParameter<edm::ParameterSet>("Endcap"))),
0052       procBarrel_(new L1TPhase2GMTBarrelStubProcessor(iConfig.getParameter<edm::ParameterSet>("Barrel"))),
0053       verbose_(iConfig.getParameter<int>("verbose")) {
0054   produces<l1t::MuonStubCollection>();
0055   edm::ConsumesCollector consumesColl(consumesCollector());
0056   translator_ = new L1TMuon::GeometryTranslator(consumesColl);
0057 }
0058 
0059 Phase2L1TGMTStubProducer::~Phase2L1TGMTStubProducer() {
0060   // do anything here that needs to be done at destruction time
0061   // (e.g. close files, deallocate resources etc.)
0062   if (procEndcap_ != nullptr)
0063     delete procEndcap_;
0064   if (procBarrel_ != nullptr)
0065     delete procBarrel_;
0066   if (translator_ != nullptr)
0067     delete translator_;
0068 }
0069 
0070 //
0071 // member functions
0072 //
0073 
0074 // ------------ method called to produce the data  ------------
0075 void Phase2L1TGMTStubProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0076   using namespace edm;
0077   translator_->checkAndUpdateGeometry(iSetup);
0078 
0079   Handle<MuonDigiCollection<CSCDetId, CSCCorrelatedLCTDigi>> cscDigis;
0080   iEvent.getByToken(srcCSC_, cscDigis);
0081 
0082   Handle<RPCDigiCollection> rpcDigis;
0083   iEvent.getByToken(srcRPC_, rpcDigis);
0084 
0085   Handle<L1Phase2MuDTPhContainer> dtDigis;
0086   iEvent.getByToken(srcDT_, dtDigis);
0087 
0088   Handle<L1MuDTChambThContainer> dtThetaDigis;
0089   iEvent.getByToken(srcDTTheta_, dtThetaDigis);
0090 
0091   //Generate a unique stub ID
0092   l1t::MuonStubCollection stubs;
0093 
0094   uint count0 = 0;
0095   uint count1 = 0;
0096   uint count2 = 0;
0097   uint count3 = 0;
0098   uint count4 = 0;
0099 
0100   l1t::MuonStubCollection stubsEndcap = procEndcap_->makeStubs(*cscDigis, *rpcDigis, translator_, iSetup);
0101   for (auto& stub : stubsEndcap) {
0102     if (stub.tfLayer() == 0) {
0103       stub.setID(count0);
0104       count0++;
0105     } else if (stub.tfLayer() == 1) {
0106       stub.setID(count1);
0107       count1++;
0108     } else if (stub.tfLayer() == 2) {
0109       stub.setID(count2);
0110       count2++;
0111     } else if (stub.tfLayer() == 3) {
0112       stub.setID(count3);
0113       count3++;
0114     } else {
0115       stub.setID(count4);
0116       count4++;
0117     }
0118     stubs.push_back(stub);
0119   }
0120   l1t::MuonStubCollection stubsBarrel = procBarrel_->makeStubs(dtDigis.product(), dtThetaDigis.product());
0121   for (auto& stub : stubsBarrel) {
0122     if (stub.tfLayer() == 0) {
0123       stub.setID(count0);
0124       count0++;
0125     } else if (stub.tfLayer() == 1) {
0126       stub.setID(count1);
0127       count1++;
0128     } else if (stub.tfLayer() == 2) {
0129       stub.setID(count2);
0130       count2++;
0131     } else if (stub.tfLayer() == 3) {
0132       stub.setID(count3);
0133       count3++;
0134     } else {
0135       stub.setID(count4);
0136       count4++;
0137     }
0138     stubs.push_back(stub);
0139   }
0140 
0141   iEvent.put(std::make_unique<l1t::MuonStubCollection>(stubs));
0142 }
0143 
0144 // ------------ method called once each stream before processing any runs, lumis or events  ------------
0145 void Phase2L1TGMTStubProducer::beginStream(edm::StreamID) {}
0146 
0147 // ------------ method called once each stream after processing all runs, lumis and events  ------------
0148 void Phase2L1TGMTStubProducer::endStream() {}
0149 
0150 void Phase2L1TGMTStubProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0151   // gmtStubs
0152   edm::ParameterSetDescription desc;
0153   desc.add<int>("verbose", 0);
0154   desc.add<edm::InputTag>("srcCSC", edm::InputTag("simCscTriggerPrimitiveDigis"));
0155   desc.add<edm::InputTag>("srcDT", edm::InputTag("dtTriggerPhase2PrimitiveDigis"));
0156   desc.add<edm::InputTag>("srcDTTheta", edm::InputTag("simDtTriggerPrimitiveDigis"));
0157   desc.add<edm::InputTag>("srcRPC", edm::InputTag("simMuonRPCDigis"));
0158   {
0159     edm::ParameterSetDescription psd0;
0160     psd0.add<unsigned int>("verbose", 0);
0161     psd0.add<int>("minBX", 0);
0162     psd0.add<int>("maxBX", 0);
0163     psd0.add<double>("coord1LSB", 0.02453124992);
0164     psd0.add<double>("eta1LSB", 0.024586688);
0165     psd0.add<double>("coord2LSB", 0.02453124992);
0166     psd0.add<double>("eta2LSB", 0.024586688);
0167     psd0.add<double>("phiMatch", 0.05);
0168     psd0.add<double>("etaMatch", 0.1);
0169     desc.add<edm::ParameterSetDescription>("Endcap", psd0);
0170   }
0171   {
0172     edm::ParameterSetDescription psd0;
0173     psd0.add<int>("verbose", 0);
0174     psd0.add<int>("minPhiQuality", 0);
0175     psd0.add<int>("minThetaQuality", 0);
0176     psd0.add<int>("minBX", 0);
0177     psd0.add<int>("maxBX", 0);
0178     psd0.add<double>("phiLSB", 0.02453124992);
0179     psd0.add<int>("phiBDivider", 16);
0180     psd0.add<double>("etaLSB", 0.024586688);
0181     psd0.add<std::vector<int>>(
0182         "eta_1",
0183         {
0184             -46, -45, -43, -41, -39, -37, -35, -30, -28, -26, -23, -20, -18, -15, -9, -6, -3, -1,
0185             1,   3,   6,   9,   15,  18,  20,  23,  26,  28,  30,  35,  37,  39,  41, 43, 45, 1503,
0186         });
0187     psd0.add<std::vector<int>>(
0188         "eta_2",
0189         {
0190             -41, -39, -38, -36, -34, -32, -30, -26, -24, -22, -20, -18, -15, -13, -8, -5, -3, -1,
0191             1,   3,   5,   8,   13,  15,  18,  20,  22,  24,  26,  30,  32,  34,  36, 38, 39, 1334,
0192         });
0193     psd0.add<std::vector<int>>(
0194         "eta_3",
0195         {
0196             -35, -34, -32, -31, -29, -27, -26, -22, -20, -19, -17, -15, -13, -11, -6, -4, -2, -1,
0197             1,   2,   4,   6,   11,  13,  15,  17,  19,  20,  22,  26,  27,  29,  31, 32, 34, 1148,
0198         });
0199     psd0.add<std::vector<int>>("coarseEta_1",
0200                                {
0201                                    0,
0202                                    23,
0203                                    41,
0204                                });
0205     psd0.add<std::vector<int>>("coarseEta_2",
0206                                {
0207                                    0,
0208                                    20,
0209                                    36,
0210                                });
0211     psd0.add<std::vector<int>>("coarseEta_3",
0212                                {
0213                                    0,
0214                                    17,
0215                                    31,
0216                                });
0217     psd0.add<std::vector<int>>("coarseEta_4",
0218                                {
0219                                    0,
0220                                    14,
0221                                    27,
0222                                });
0223     psd0.add<std::vector<int>>("phiOffset",
0224                                {
0225                                    1,
0226                                    0,
0227                                    0,
0228                                    0,
0229                                });
0230     desc.add<edm::ParameterSetDescription>("Barrel", psd0);
0231   }
0232   descriptions.add("gmtStubs", desc);
0233 }
0234 
0235 //define this as a plug-in
0236 DEFINE_FWK_MODULE(Phase2L1TGMTStubProducer);