Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:36

0001 ///
0002 /// Description: Firmware headers
0003 ///
0004 /// Implementation:
0005 /// Collects concrete algorithm implmentations.
0006 ///
0007 /// \author: R. Alex Barbieri MIT
0008 ///
0009 
0010 //
0011 // This header file contains the class definitions for all of the concrete
0012 // implementations of the firmware interface. The Stage1Layer2FirmwareFactory
0013 // selects the appropriate implementation based on the firmware version in the
0014 // configuration.
0015 //
0016 
0017 #ifndef L1TCALOSTAGE1ETSUMSALGORITHMIMP_H
0018 #define L1TCALOSTAGE1ETSUMSALGORITHMIMP_H
0019 
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "L1Trigger/L1TCalorimeter/interface/Stage1Layer2EtSumAlgorithm.h"
0022 #include "L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h"
0023 #include "L1Trigger/L1TCalorimeter/interface/CordicXilinx.h"
0024 #include <array>
0025 #include <vector>
0026 
0027 namespace l1t {
0028 
0029   class Stage1Layer2EtSumAlgorithmImpPP : public Stage1Layer2EtSumAlgorithm {
0030   public:
0031     Stage1Layer2EtSumAlgorithmImpPP(CaloParamsHelper const* params);
0032     ~Stage1Layer2EtSumAlgorithmImpPP() override = default;
0033     void processEvent(const std::vector<l1t::CaloRegion>& regions,
0034                       const std::vector<l1t::CaloEmCand>& EMCands,
0035                       const std::vector<l1t::Jet>* jets,
0036                       std::vector<l1t::EtSum>* sums) override;
0037 
0038   private:
0039     CaloParamsHelper const* const params_;
0040 
0041     int DiJetPhi(const std::vector<l1t::Jet>* jets) const;
0042     uint16_t MHToverHT(uint16_t, uint16_t) const;
0043     std::vector<double> sinPhi;
0044     std::vector<double> cosPhi;
0045   };
0046 
0047   class Stage1Layer2EtSumAlgorithmImpHW : public Stage1Layer2EtSumAlgorithm {
0048   public:
0049     Stage1Layer2EtSumAlgorithmImpHW(CaloParamsHelper const* params);
0050     ~Stage1Layer2EtSumAlgorithmImpHW() override = default;
0051     void processEvent(const std::vector<l1t::CaloRegion>& regions,
0052                       const std::vector<l1t::CaloEmCand>& EMCands,
0053                       const std::vector<l1t::Jet>* jets,
0054                       std::vector<l1t::EtSum>* sums) override;
0055 
0056   private:
0057     CaloParamsHelper const* const params_;
0058 
0059     int DiJetPhi(const std::vector<l1t::Jet>* jets) const;
0060     uint16_t MHToverHT(uint16_t, uint16_t) const;
0061 
0062     struct SimpleRegion {
0063       int ieta;
0064       int iphi;
0065       int et;
0066     };
0067     enum class ETSumType { kHadronicSum, kEmSum };
0068     std::tuple<int, int, int> doSumAndMET(const std::vector<SimpleRegion>& regionEt, ETSumType sumType);
0069 
0070     // Converts 3Q16 fixed-point phase from CORDIC
0071     // to 0-71 appropriately
0072     int cordicToMETPhi(int phase);
0073     // Array used in above function
0074     std::array<int, 73> cordicPhiValues;
0075 
0076     CordicXilinx cordic{24, 19};
0077 
0078     // for converting region et to x and y components
0079     std::array<long, 5> cosines;
0080     std::array<long, 5> sines;
0081   };
0082 
0083   class Stage1Layer2EtSumAlgorithmImpHI : public Stage1Layer2EtSumAlgorithm {
0084   public:
0085     Stage1Layer2EtSumAlgorithmImpHI(CaloParamsHelper const* params);
0086     ~Stage1Layer2EtSumAlgorithmImpHI() override = default;
0087     void processEvent(const std::vector<l1t::CaloRegion>& regions,
0088                       const std::vector<l1t::CaloEmCand>& EMCands,
0089                       const std::vector<l1t::Jet>* jets,
0090                       std::vector<l1t::EtSum>* sums) override;
0091 
0092   private:
0093     CaloParamsHelper const* const params_;
0094 
0095     int DiJetPhi(const std::vector<l1t::Jet>* jets) const;
0096     uint16_t MHToverHT(uint16_t, uint16_t) const;
0097 
0098     struct SimpleRegion {
0099       int ieta;
0100       int iphi;
0101       int et;
0102     };
0103     enum class ETSumType { kHadronicSum, kEmSum };
0104     std::tuple<int, int, int> doSumAndMET(const std::vector<SimpleRegion>& regionEt, ETSumType sumType);
0105 
0106     // Converts 3Q16 fixed-point phase from CORDIC
0107     // to 0-71 appropriately
0108     int cordicToMETPhi(int phase);
0109     // Array used in above function
0110     std::array<int, 73> cordicPhiValues;
0111 
0112     CordicXilinx cordic{24, 19};
0113 
0114     // for converting region et to x and y components
0115     std::array<long, 5> cosines;
0116     std::array<long, 5> sines;
0117   };
0118 
0119   /* class Stage1Layer2CentralityAlgorithm : public Stage1Layer2EtSumAlgorithm { */
0120   /* public: */
0121   /*   Stage1Layer2CentralityAlgorithm(CaloParamsHelper* params); */
0122   /*   virtual ~Stage1Layer2CentralityAlgorithm(); */
0123   /*   virtual void processEvent(const std::vector<l1t::CaloRegion> & regions, */
0124   /*                  const std::vector<l1t::CaloEmCand> & EMCands, */
0125   /*                  std::vector<l1t::EtSum> * sums); */
0126   /* private: */
0127   /*   CaloParamsHelper* const params_; */
0128   /* }; */
0129 }  // namespace l1t
0130 
0131 #endif