Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:26

0001 #ifndef middle_buffer_multififo_regionizer_ref_h
0002 #define middle_buffer_multififo_regionizer_ref_h
0003 
0004 #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h"
0005 #include "L1Trigger/Phase2L1ParticleFlow/interface/dbgPrintf.h"
0006 #include <memory>
0007 #include <deque>
0008 
0009 namespace l1ct {
0010   class MiddleBufferMultififoRegionizerEmulator : public RegionizerEmulator {
0011   public:
0012     MiddleBufferMultififoRegionizerEmulator(unsigned int nclocks,
0013                                             unsigned int nbuffers,
0014                                             unsigned int etabufferDepth,
0015                                             unsigned int ntklinks,
0016                                             unsigned int nHCalLinks,
0017                                             unsigned int nECalLinks,
0018                                             unsigned int ntk,
0019                                             unsigned int ncalo,
0020                                             unsigned int nem,
0021                                             unsigned int nmu,
0022                                             bool streaming,
0023                                             unsigned int outii,
0024                                             unsigned int pauseii,
0025                                             bool useAlsoVtxCoords);
0026     // note: this one will work only in CMSSW
0027     MiddleBufferMultififoRegionizerEmulator(const edm::ParameterSet& iConfig);
0028 
0029     ~MiddleBufferMultififoRegionizerEmulator() override;
0030 
0031     static edm::ParameterSetDescription getParameterSetDescription();
0032 
0033     void initSectorsAndRegions(const RegionizerDecodedInputs& in, const std::vector<PFInputRegion>& out) override;
0034 
0035     void run(const RegionizerDecodedInputs& in, std::vector<PFInputRegion>& out) override;
0036 
0037     // link emulation from decoded inputs (for simulation)
0038     void fillLinks(unsigned int iclock,
0039                    const RegionizerDecodedInputs& in,
0040                    std::vector<l1ct::TkObjEmu>& links,
0041                    std::vector<bool>& valid);
0042     void fillLinks(unsigned int iclock,
0043                    const RegionizerDecodedInputs& in,
0044                    std::vector<l1ct::HadCaloObjEmu>& links,
0045                    std::vector<bool>& valid);
0046     void fillLinks(unsigned int iclock,
0047                    const RegionizerDecodedInputs& in,
0048                    std::vector<l1ct::EmCaloObjEmu>& links,
0049                    std::vector<bool>& valid);
0050     void fillLinks(unsigned int iclock,
0051                    const RegionizerDecodedInputs& in,
0052                    std::vector<l1ct::MuObjEmu>& links,
0053                    std::vector<bool>& valid);
0054     template <typename T>
0055     void fillLinks(unsigned int iclock, const RegionizerDecodedInputs& in, std::vector<T>& links) {
0056       std::vector<bool> unused;
0057       fillLinks(iclock, in, links, unused);
0058     }
0059 
0060     void destream(int iclock,
0061                   const std::vector<l1ct::TkObjEmu>& tk_out,
0062                   const std::vector<l1ct::EmCaloObjEmu>& em_out,
0063                   const std::vector<l1ct::HadCaloObjEmu>& calo_out,
0064                   const std::vector<l1ct::MuObjEmu>& mu_out,
0065                   PFInputRegion& out);
0066 
0067     // clock-cycle emulation
0068     bool step(bool newEvent,
0069               const std::vector<l1ct::TkObjEmu>& links_tk,
0070               const std::vector<l1ct::HadCaloObjEmu>& links_hadCalo,
0071               const std::vector<l1ct::EmCaloObjEmu>& links_emCalo,
0072               const std::vector<l1ct::MuObjEmu>& links_mu,
0073               std::vector<l1ct::TkObjEmu>& out_tk,
0074               std::vector<l1ct::HadCaloObjEmu>& out_hadCalo,
0075               std::vector<l1ct::EmCaloObjEmu>& out_emCalo,
0076               std::vector<l1ct::MuObjEmu>& out_mu,
0077               bool /*unused*/);
0078 
0079     template <typename TEmu, typename TFw>
0080     void toFirmware(const std::vector<TEmu>& emu, TFw fw[]) {
0081       for (unsigned int i = 0, n = emu.size(); i < n; ++i) {
0082         fw[i] = emu[i];
0083       }
0084     }
0085 
0086     void reset();
0087 
0088   protected:
0089     const unsigned int NTK_SECTORS, NCALO_SECTORS;
0090     const unsigned int NTK_LINKS, HCAL_LINKS, ECAL_LINKS, NMU_LINKS;
0091     unsigned int nclocks_, nbuffers_, etabuffer_depth_, ntk_, ncalo_, nem_, nmu_, outii_, pauseii_, nregions_pre_,
0092         nregions_post_;
0093     bool streaming_;
0094     bool init_;
0095     unsigned int iclock_;
0096     std::vector<l1ct::PFRegionEmu> mergedRegions_, outputRegions_;
0097     multififo_regionizer::Regionizer<l1ct::TkObjEmu> tkRegionizerPre_, tkRegionizerPost_;
0098     multififo_regionizer::Regionizer<l1ct::HadCaloObjEmu> hadCaloRegionizerPre_, hadCaloRegionizerPost_;
0099     multififo_regionizer::Regionizer<l1ct::EmCaloObjEmu> emCaloRegionizerPre_, emCaloRegionizerPost_;
0100     multififo_regionizer::Regionizer<l1ct::MuObjEmu> muRegionizerPre_, muRegionizerPost_;
0101     std::vector<l1ct::multififo_regionizer::Route> tkRoutes_, caloRoutes_, emCaloRoutes_, muRoutes_;
0102     std::vector<l1ct::multififo_regionizer::EtaPhiBuffer<l1ct::TkObjEmu>> tkBuffers_;
0103     std::vector<l1ct::multififo_regionizer::EtaPhiBuffer<l1ct::HadCaloObjEmu>> hadCaloBuffers_;
0104     std::vector<l1ct::multififo_regionizer::EtaPhiBuffer<l1ct::EmCaloObjEmu>> emCaloBuffers_;
0105     std::vector<l1ct::multififo_regionizer::EtaPhiBuffer<l1ct::MuObjEmu>> muBuffers_;
0106 
0107     template <typename T>
0108     void fillCaloLinks_(unsigned int iclock,
0109                         const std::vector<DetectorSector<T>>& in,
0110                         std::vector<T>& links,
0111                         std::vector<bool>& valid);
0112 
0113     void fillSharedCaloLinks(unsigned int iclock,
0114                              const std::vector<DetectorSector<l1ct::EmCaloObjEmu>>& em_in,
0115                              const std::vector<DetectorSector<l1ct::HadCaloObjEmu>>& had_in,
0116                              std::vector<l1ct::HadCaloObjEmu>& links,
0117                              std::vector<bool>& valid);
0118 
0119     void encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to);
0120     void encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to);
0121     void decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em);
0122   };
0123 }  // namespace l1ct
0124 
0125 #endif