Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-04 02:02:46

0001 #ifndef UCTTower_hh
0002 #define UCTTower_hh
0003 
0004 #include "UCTGeometry.hh"
0005 
0006 #include <array>
0007 
0008 namespace l1tcalo {
0009   constexpr uint32_t etInputMax{0xFF};
0010 
0011   constexpr uint32_t etMask{0x000001FF};
0012   constexpr uint32_t erMask{0x00000E00};
0013   constexpr uint32_t erMaxV{7};
0014   constexpr uint32_t erShift{9};
0015   constexpr uint32_t zeroFlagMask{0x00001000};
0016   constexpr uint32_t eohrFlagMask{0x00002000};
0017   constexpr uint32_t hcalFlagMask{0x00004000};
0018   constexpr uint32_t ecalFlagMask{0x00008000};
0019   constexpr uint32_t stg2BitsMask{0x0000FFFF};
0020   constexpr uint32_t miscBitsMask{0x0000F000};
0021   constexpr uint32_t miscShift{12};
0022 
0023   constexpr uint32_t ecalBitsMask{0x00FF0000};
0024   constexpr uint32_t ecalShift{16};
0025   constexpr uint32_t hcalBitsMask{0xFF000000};
0026   constexpr uint32_t hcalShift{24};
0027 }  // namespace l1tcalo
0028 
0029 class UCTLayer1;
0030 
0031 class UCTTower {
0032 public:
0033   UCTTower(uint32_t crt, uint32_t crd, bool ne, uint32_t rgn, uint32_t eta, uint32_t phi, int fwv)
0034       : crate(crt),
0035         card(crd),
0036         region(rgn),
0037         iEta(eta),
0038         iPhi(phi),
0039         negativeEta(ne),
0040         ecalFG(false),
0041         ecalET(0),
0042         hcalET(0),
0043         hcalFB(0),
0044         ecalLUT(nullptr),
0045         hcalLUT(nullptr),
0046         hfLUT(nullptr),
0047         towerData(0),
0048         fwVersion(fwv) {}
0049 
0050   UCTTower(uint16_t location, int fwv);
0051 
0052   // No default constructor is needed
0053 
0054   UCTTower() = delete;
0055 
0056   // No copy constructor is needed
0057 
0058   UCTTower(const UCTTower &) = delete;
0059 
0060   // No equality operator is needed
0061 
0062   const UCTTower &operator=(const UCTTower &) = delete;
0063 
0064   virtual ~UCTTower() { ; }
0065 
0066   bool clearEvent() {
0067     ecalFG = false;
0068     ecalET = 0;
0069     hcalET = 0;
0070     hcalFB = 0;
0071     towerData = 0;
0072     return true;
0073   }
0074 
0075   bool setECALData(bool ecalFG, uint32_t ecalET);
0076   bool setHCALData(uint32_t hcalFB, uint32_t hcalET);
0077   bool setHFData(uint32_t fbIn, uint32_t etIn);
0078 
0079   bool setECALLUT(const std::array<std::array<std::array<uint32_t, 256>, 2>, 28> *l) {
0080     ecalLUT = l;
0081     return true;
0082   }
0083 
0084   bool setHCALLUT(const std::array<std::array<std::array<uint32_t, 256>, 2>, 28> *l) {
0085     hcalLUT = l;
0086     return true;
0087   }
0088 
0089   bool setHFLUT(const std::array<std::array<uint32_t, 256>, 12> *l) {
0090     hfLUT = l;
0091     return true;
0092   }
0093 
0094   bool process();
0095   bool processHFTower();
0096 
0097   // Packed data access
0098 
0099   const uint32_t rawData() const { return towerData; }
0100   const uint16_t location() const;
0101   const uint64_t extendedData() const;
0102   const uint16_t compressedData() const { return (uint16_t)(towerData & l1tcalo::stg2BitsMask); }
0103 
0104   // Access functions for convenience
0105   // Note that the bit fields are limited in hardware
0106 
0107   const uint32_t et() const { return (towerData & l1tcalo::etMask); }
0108   const uint32_t er() const { return ((towerData & l1tcalo::erMask) >> l1tcalo::erShift); }
0109   const uint8_t miscBits() const { return (uint8_t)((towerData & l1tcalo::miscBitsMask) >> l1tcalo::miscShift); }
0110 
0111   const uint32_t getEcalET() const { return ((towerData & l1tcalo::ecalBitsMask) >> l1tcalo::ecalShift); }
0112   const uint32_t getHcalET() const { return ((towerData & l1tcalo::hcalBitsMask) >> l1tcalo::hcalShift); }
0113 
0114   const bool zeroFlag() const { return ((towerData & l1tcalo::zeroFlagMask) == l1tcalo::zeroFlagMask); }
0115   const bool eohrFlag() const { return ((towerData & l1tcalo::eohrFlagMask) == l1tcalo::eohrFlagMask); }
0116   const bool hcalFlag() const { return ((towerData & l1tcalo::hcalFlagMask) == l1tcalo::hcalFlagMask); }
0117   const bool ecalFlag() const { return ((towerData & l1tcalo::ecalFlagMask) == l1tcalo::ecalFlagMask); }
0118 
0119   // More access functions
0120 
0121   const uint32_t getCrate() const { return crate; }
0122   const uint32_t getCard() const { return card; }
0123   const uint32_t getRegion() const { return region; }
0124   const uint32_t getiEta() const { return iEta; }
0125   const uint32_t getiPhi() const { return iPhi; }
0126   const bool isNegativeEta() const { return negativeEta; }
0127 
0128   const int caloEta() const {
0129     UCTGeometry g;
0130     return g.getCaloEtaIndex(negativeEta, region, iEta);
0131   }
0132 
0133   const int caloPhi() const {
0134     UCTGeometry g;
0135     return g.getCaloPhiIndex(crate, card, region, iPhi);
0136   }
0137 
0138   const UCTTowerIndex towerIndex() const { return UCTTowerIndex(caloEta(), caloPhi()); }
0139 
0140   friend std::ostream &operator<<(std::ostream &, const UCTTower &);
0141 
0142 private:
0143   // Tower location definition
0144 
0145   uint32_t crate;
0146   uint32_t card;
0147   uint32_t region;
0148   uint32_t iEta;
0149   uint32_t iPhi;
0150   bool negativeEta;
0151 
0152   // Input data
0153 
0154   bool ecalFG;
0155   uint32_t ecalET;
0156   uint32_t hcalET;
0157   uint32_t hcalFB;
0158 
0159   // Lookup table
0160   // ecal/hcal:  256 pt bins, 2 sides, 28 eta bins (towers)
0161   // hf:  256 pt bins, 12 eta bins (towers)
0162   const std::array<std::array<std::array<uint32_t, 256>, 2>, 28> *ecalLUT;
0163   const std::array<std::array<std::array<uint32_t, 256>, 2>, 28> *hcalLUT;
0164   const std::array<std::array<uint32_t, 256>, 12> *hfLUT;
0165 
0166   // Owned tower level data
0167   // Packed bits -- only bottom 16 bits are used in "prelim" protocol
0168 
0169   uint32_t towerData;
0170 
0171   // Keep track of possible algorithm changes
0172   const int fwVersion;
0173 };
0174 
0175 #endif