Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:00

0001 #ifndef L1T_OmtfP1_MUONSTUBMAKERBASE_H
0002 #define L1T_OmtfP1_MUONSTUBMAKERBASE_H
0003 
0004 #include "DataFormats/Common/interface/Handle.h"
0005 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0006 #include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h"
0007 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0008 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
0009 #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
0010 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0011 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0012 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Utilities/interface/EDGetToken.h"
0015 #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h"
0016 #include "L1Trigger/L1TMuonOverlapPhase1/interface/RpcClusterization.h"
0017 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h"
0018 #include <cstdint>
0019 #include <memory>
0020 #include <vector>
0021 
0022 class ProcConfigurationBase;
0023 
0024 namespace edm {
0025   class EventSetup;
0026 }
0027 
0028 struct MuStubsInputTokens {
0029   edm::EDGetTokenT<L1MuDTChambPhContainer> inputTokenDtPh;
0030   edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDtTh;
0031   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> inputTokenCSC;
0032   edm::EDGetTokenT<RPCDigiCollection> inputTokenRPC;
0033 };
0034 
0035 class DigiToStubsConverterBase {
0036 public:
0037   virtual ~DigiToStubsConverterBase() {}
0038 
0039   virtual void loadDigis(const edm::Event& event) = 0;
0040 
0041   virtual void makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0042                          unsigned int iProcessor,
0043                          l1t::tftype procTyp,
0044                          int bxFrom,
0045                          int bxTo,
0046                          std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) = 0;
0047 };
0048 
0049 class DtDigiToStubsConverter : public DigiToStubsConverterBase {
0050 public:
0051   DtDigiToStubsConverter(edm::EDGetTokenT<L1MuDTChambPhContainer> inputTokenDtPh,
0052                          edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDtTh)
0053       : inputTokenDtPh(inputTokenDtPh), inputTokenDtTh(inputTokenDtTh) {}
0054 
0055   ~DtDigiToStubsConverter() override {}
0056 
0057   //virtual void initialize(const edm::ParameterSet& edmCfg, const edm::EventSetup& es, const ProcConfigurationBase* procConf) {} //TODO is it needed at all?
0058 
0059   void loadDigis(const edm::Event& event) override;
0060 
0061   void makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0062                  unsigned int iProcessor,
0063                  l1t::tftype procTyp,
0064                  int bxFrom,
0065                  int bxTo,
0066                  std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) override;
0067 
0068   //dtThDigis is provided as argument, because in the OMTF implementation the phi and eta digis are merged (even thought it is artificial)
0069   virtual void addDTphiDigi(MuonStubPtrs2D& muonStubsInLayers,
0070                             const L1MuDTChambPhDigi& digi,
0071                             const L1MuDTChambThContainer* dtThDigis,
0072                             unsigned int iProcessor,
0073                             l1t::tftype procTyp) = 0;
0074 
0075   virtual void addDTetaStubs(MuonStubPtrs2D& muonStubsInLayers,
0076                              const L1MuDTChambThDigi& thetaDigi,
0077                              unsigned int iProcessor,
0078                              l1t::tftype procTyp) = 0;
0079 
0080   virtual bool acceptDigi(const DTChamberId& dTChamberId, unsigned int iProcessor, l1t::tftype procType) {
0081     return true;
0082   }
0083 
0084 protected:
0085   bool mergePhiAndTheta = true;
0086 
0087   edm::EDGetTokenT<L1MuDTChambPhContainer> inputTokenDtPh;
0088   edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDtTh;
0089 
0090   edm::Handle<L1MuDTChambPhContainer> dtPhDigis;
0091   edm::Handle<L1MuDTChambThContainer> dtThDigis;
0092 };
0093 
0094 class CscDigiToStubsConverter : public DigiToStubsConverterBase {
0095 public:
0096   CscDigiToStubsConverter(const ProcConfigurationBase* config,
0097                           edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> inputTokenCsc)
0098       : config(config), inputTokenCsc(inputTokenCsc) {}
0099 
0100   ~CscDigiToStubsConverter() override {}
0101 
0102   //virtual void initialize(const edm::ParameterSet& edmCfg, const edm::EventSetup& es, const ProcConfigurationBase* procConf) {} //TODO is it needed at all?
0103 
0104   void loadDigis(const edm::Event& event) override { event.getByToken(inputTokenCsc, cscDigis); }
0105 
0106   void makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0107                  unsigned int iProcessor,
0108                  l1t::tftype procTyp,
0109                  int bxFrom,
0110                  int bxTo,
0111                  std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) override;
0112 
0113   //can add both phi and eta stubs
0114   virtual void addCSCstubs(MuonStubPtrs2D& muonStubsInLayers,
0115                            unsigned int rawid,
0116                            const CSCCorrelatedLCTDigi& digi,
0117                            unsigned int iProcessor,
0118                            l1t::tftype procTyp) = 0;
0119 
0120   virtual bool acceptDigi(const CSCDetId& cscDetId, unsigned int iProcessor, l1t::tftype procType) { return true; }
0121 
0122 protected:
0123   const ProcConfigurationBase* config;
0124 
0125   bool mergePhiAndTheta = true;
0126 
0127   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> inputTokenCsc;
0128   edm::Handle<CSCCorrelatedLCTDigiCollection> cscDigis;
0129 };
0130 
0131 class RpcDigiToStubsConverter : public DigiToStubsConverterBase {
0132 public:
0133   RpcDigiToStubsConverter(const ProcConfigurationBase* config,
0134                           edm::EDGetTokenT<RPCDigiCollection> inputTokenRpc,
0135                           const RpcClusterization* rpcClusterization)
0136       : config(config), inputTokenRpc(inputTokenRpc), rpcClusterization(rpcClusterization) {}
0137 
0138   ~RpcDigiToStubsConverter() override {}
0139 
0140   //virtual void initialize(const edm::ParameterSet& edmCfg, const edm::EventSetup& es, const ProcConfigurationBase* procConf) {} //TODO is it needed at all?
0141 
0142   void loadDigis(const edm::Event& event) override { event.getByToken(inputTokenRpc, rpcDigis); }
0143 
0144   void makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0145                  unsigned int iProcessor,
0146                  l1t::tftype procTyp,
0147                  int bxFrom,
0148                  int bxTo,
0149                  std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) override;
0150 
0151   virtual void addRPCstub(MuonStubPtrs2D& muonStubsInLayers,
0152                           const RPCDetId& roll,
0153                           const RpcCluster& cluster,
0154                           unsigned int iProcessor,
0155                           l1t::tftype procTyp) = 0;
0156 
0157   virtual bool acceptDigi(const RPCDetId& rpcDetId, unsigned int iProcessor, l1t::tftype procType) { return true; }
0158 
0159 protected:
0160   const ProcConfigurationBase* config;
0161 
0162   bool mergePhiAndTheta = true;
0163 
0164   edm::EDGetTokenT<RPCDigiCollection> inputTokenRpc;
0165   edm::Handle<RPCDigiCollection> rpcDigis;
0166 
0167   const RpcClusterization* rpcClusterization;
0168 };
0169 
0170 //forward declaration - MuonGeometryTokens is defined and used in the AngleConverterBase
0171 struct MuonGeometryTokens;
0172 
0173 class MuonStubMakerBase {
0174 public:
0175   MuonStubMakerBase(const ProcConfigurationBase* procConf);
0176 
0177   virtual ~MuonStubMakerBase();
0178 
0179   virtual void initialize(const edm::ParameterSet& edmCfg,
0180                           const edm::EventSetup& es,
0181                           const MuonGeometryTokens& muonGeometryTokens);
0182 
0183   void loadAndFilterDigis(const edm::Event& event);
0184 
0185   ///Method translating trigger digis into input matrix with global phi coordinates, fills the muonStubsInLayers
0186   void buildInputForProcessor(MuonStubPtrs2D& muonStubsInLayers,
0187                               unsigned int iProcessor,
0188                               l1t::tftype procTyp,
0189                               int bxFrom,
0190                               int bxTo,
0191                               std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers);
0192 
0193 protected:
0194   const ProcConfigurationBase* config = nullptr;
0195 
0196   std::vector<std::unique_ptr<DigiToStubsConverterBase> > digiToStubsConverters;
0197 
0198   RpcClusterization rpcClusterization;
0199 };
0200 
0201 #endif