Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:53:50

0001 #ifndef multififo_regionizer_ref_h
0002 #define multififo_regionizer_ref_h
0003 
0004 #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h"
0005 #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.h"
0006 #include <memory>
0007 
0008 namespace edm {
0009   class ParameterSet;
0010 }
0011 
0012 namespace l1ct {
0013   class EGInputSelectorEmulator;
0014   struct EGInputSelectorEmuConfig;
0015 }  // namespace l1ct
0016 
0017 namespace l1ct {
0018   class MultififoRegionizerEmulator : public RegionizerEmulator {
0019   public:
0020     MultififoRegionizerEmulator(unsigned int nendcaps,
0021                                 unsigned int nclocks,
0022                                 unsigned int ntk,
0023                                 unsigned int ncalo,
0024                                 unsigned int nem,
0025                                 unsigned int nmu,
0026                                 bool streaming,
0027                                 unsigned int outii,
0028                                 bool useAlsoVtxCoords);
0029 
0030     enum class BarrelSetup { Full54, Full27, Central18, Central9, Phi18, Phi9 };
0031     MultififoRegionizerEmulator(BarrelSetup barrelSetup,
0032                                 unsigned int nHCalLinks,
0033                                 unsigned int nECalLinks,
0034                                 unsigned int nclocks,
0035                                 unsigned int ntk,
0036                                 unsigned int ncalo,
0037                                 unsigned int nem,
0038                                 unsigned int nmu,
0039                                 bool streaming,
0040                                 unsigned int outii,
0041                                 unsigned int pauseii,
0042                                 bool useAlsoVtxCoords);
0043 
0044     // note: this one will work only in CMSSW
0045     MultififoRegionizerEmulator(const edm::ParameterSet& iConfig);
0046 
0047     ~MultififoRegionizerEmulator() override;
0048 
0049     void setEgInterceptMode(bool afterFifo, const l1ct::EGInputSelectorEmuConfig& interceptorConfig);
0050     void initSectorsAndRegions(const RegionizerDecodedInputs& in, const std::vector<PFInputRegion>& out) override;
0051 
0052     void run(const RegionizerDecodedInputs& in, std::vector<PFInputRegion>& out) override;
0053 
0054     // clock-cycle emulation
0055     bool step(bool newEvent,
0056               const std::vector<l1ct::TkObjEmu>& links,
0057               std::vector<l1ct::TkObjEmu>& out,
0058               bool mux = true);
0059     bool step(bool newEvent,
0060               const std::vector<l1ct::EmCaloObjEmu>& links,
0061               std::vector<l1ct::EmCaloObjEmu>& out,
0062               bool mux = true);
0063     bool step(bool newEvent,
0064               const std::vector<l1ct::HadCaloObjEmu>& links,
0065               std::vector<l1ct::HadCaloObjEmu>& out,
0066               bool mux = true);
0067     bool step(bool newEvent,
0068               const std::vector<l1ct::MuObjEmu>& links,
0069               std::vector<l1ct::MuObjEmu>& out,
0070               bool mux = true);
0071     bool step(bool newEvent,
0072               const std::vector<l1ct::TkObjEmu>& links_tk,
0073               const std::vector<l1ct::HadCaloObjEmu>& links_hadCalo,
0074               const std::vector<l1ct::EmCaloObjEmu>& links_emCalo,
0075               const std::vector<l1ct::MuObjEmu>& links_mu,
0076               std::vector<l1ct::TkObjEmu>& out_tk,
0077               std::vector<l1ct::HadCaloObjEmu>& out_hadCalo,
0078               std::vector<l1ct::EmCaloObjEmu>& out_emCalo,
0079               std::vector<l1ct::MuObjEmu>& out_mu,
0080               bool mux = true);
0081     void destream(int iclock,
0082                   const std::vector<l1ct::TkObjEmu>& tk_out,
0083                   const std::vector<l1ct::EmCaloObjEmu>& em_out,
0084                   const std::vector<l1ct::HadCaloObjEmu>& calo_out,
0085                   const std::vector<l1ct::MuObjEmu>& mu_out,
0086                   PFInputRegion& out);
0087 
0088     // link emulation from decoded inputs (for simulation)
0089     void fillLinks(unsigned int iclock, const RegionizerDecodedInputs& in, std::vector<l1ct::TkObjEmu>& links);
0090     void fillLinks(unsigned int iclock, const RegionizerDecodedInputs& in, std::vector<l1ct::HadCaloObjEmu>& links);
0091     void fillLinks(unsigned int iclock, const RegionizerDecodedInputs& in, std::vector<l1ct::EmCaloObjEmu>& links);
0092     void fillLinks(unsigned int iclock, const RegionizerDecodedInputs& in, std::vector<l1ct::MuObjEmu>& links);
0093 
0094     // convert links to firmware
0095     void toFirmware(const std::vector<l1ct::TkObjEmu>& emu, TkObj fw[/*NTK_SECTORS*NTK_LINKS*/]);
0096     void toFirmware(const std::vector<l1ct::HadCaloObjEmu>& emu, HadCaloObj fw[/*NCALO_SECTORS*NCALO_LINKS*/]);
0097     void toFirmware(const std::vector<l1ct::EmCaloObjEmu>& emu, EmCaloObj fw[/*NCALO_SECTORS*NCALO_LINKS*/]);
0098     void toFirmware(const std::vector<l1ct::MuObjEmu>& emu, MuObj fw[/*NMU_LINKS*/]);
0099 
0100   private:
0101     const unsigned int NTK_SECTORS, NCALO_SECTORS;  // max objects per sector per clock cycle
0102     const unsigned int NTK_LINKS, NCALO_LINKS, HCAL_LINKS, ECAL_LINKS, NMU_LINKS;
0103     unsigned int nendcaps_, nclocks_, ntk_, ncalo_, nem_, nmu_, outii_, pauseii_, nregions_;
0104     bool streaming_;
0105     enum EmInterceptMode { noIntercept = 0, interceptPreFifo, interceptPostFifo } emInterceptMode_;
0106     std::unique_ptr<EGInputSelectorEmulator> interceptor_;
0107     bool init_;
0108 
0109     multififo_regionizer::Regionizer<l1ct::TkObjEmu> tkRegionizer_;
0110     multififo_regionizer::Regionizer<l1ct::HadCaloObjEmu> hadCaloRegionizer_;
0111     multififo_regionizer::Regionizer<l1ct::EmCaloObjEmu> emCaloRegionizer_;
0112     multififo_regionizer::Regionizer<l1ct::MuObjEmu> muRegionizer_;
0113     std::vector<l1ct::multififo_regionizer::Route> tkRoutes_, caloRoutes_, emCaloRoutes_, muRoutes_;
0114 
0115     template <typename T>
0116     void fillCaloLinks_(unsigned int iclock, const std::vector<DetectorSector<T>>& in, std::vector<T>& links);
0117   };
0118 
0119 }  // namespace l1ct
0120 
0121 #endif