Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-01 06:11:54

0001 #ifndef UCTRegion_hh
0002 #define UCTRegion_hh
0003 
0004 #include <vector>
0005 #include <iostream>
0006 #include <memory>
0007 
0008 #include "UCTTower.hh"
0009 
0010 namespace l1tcalo {
0011   constexpr uint32_t RegionETMask{0x000003FF};
0012   constexpr uint32_t RegionEGVeto{0x00000400};
0013   constexpr uint32_t RegionTauVeto{0x00000800};
0014   constexpr uint32_t HitTowerBits{0x0000F000};
0015   constexpr uint32_t RegionNoBits{0x000F0000};
0016   constexpr uint32_t CardNoBits{0x00700000};
0017   constexpr uint32_t CrateNoBits{0x01800000};
0018   constexpr uint32_t NegEtaBit{0x80000000};
0019   constexpr uint32_t LocationBits{0xFFFFF000};
0020   constexpr uint32_t LocationShift{12};
0021   constexpr uint32_t RegionNoShift{16};
0022   constexpr uint32_t CardNoShift{20};
0023   constexpr uint32_t CrateNoShift{23};
0024 }  // namespace l1tcalo
0025 
0026 class UCTRegion {
0027 public:
0028   UCTRegion(uint32_t crt, uint32_t crd, bool ne, uint32_t rgn, int fwv);
0029 
0030   // No default constructor is needed
0031 
0032   UCTRegion() = delete;
0033 
0034   //copy constructor helps gettting around some memory leakage
0035   // and ownership problems in the summary card emulation
0036   UCTRegion(const UCTRegion&);
0037 
0038   // No equality operator is needed
0039 
0040   const UCTRegion& operator=(const UCTRegion&) = delete;
0041 
0042   virtual ~UCTRegion() = default;
0043 
0044   // To setData for towers before processing
0045 
0046   const std::vector<std::shared_ptr<UCTTower>>& getTowers() { return towers; }
0047 
0048   // To process event
0049 
0050   bool clearEvent();
0051   bool setECALData(UCTTowerIndex t, bool ecalFG, uint32_t ecalET);
0052   bool setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET);
0053   bool setRegionSummary(
0054       uint16_t regionData);  // Use when the region collection is available and no direct access to TPGs
0055   bool process();
0056 
0057   // Packed data access
0058 
0059   const uint32_t rawData() const { return regionSummary; }
0060   const uint32_t location() const { return ((regionSummary & l1tcalo::LocationBits) >> l1tcalo::LocationShift); }
0061 
0062   const int hitCaloEta() const {
0063     uint32_t hitTowerLocation = (location() & 0xF);
0064     return towers[hitTowerLocation]->caloEta();
0065   }
0066 
0067   const int hitCaloPhi() const {
0068     uint32_t hitTowerLocation = (location() & 0xF);
0069     return towers[hitTowerLocation]->caloPhi();
0070   }
0071 
0072   const UCTTowerIndex hitTowerIndex() const { return UCTTowerIndex(hitCaloEta(), hitCaloPhi()); }
0073 
0074   const UCTRegionIndex regionIndex() const {
0075     UCTGeometry g;
0076     return UCTRegionIndex(g.getUCTRegionEtaIndex(negativeEta, region), g.getUCTRegionPhiIndex(crate, card));
0077   }
0078 
0079   const uint32_t compressedData() const { return regionSummary; }
0080 
0081   // Access functions for convenience
0082   // Note that the bit fields are limited in hardware
0083 
0084   const uint32_t et() const { return (l1tcalo::RegionETMask & regionSummary); }
0085   const bool isEGammaLike() const { return !((l1tcalo::RegionEGVeto & regionSummary) == l1tcalo::RegionEGVeto); }
0086   const bool isTauLike() const { return !((l1tcalo::RegionTauVeto & regionSummary) == l1tcalo::RegionTauVeto); }
0087 
0088   // More access functions
0089 
0090   const uint32_t getCrate() const { return crate; }
0091   const uint32_t getCard() const { return card; }
0092   const uint32_t getRegion() const { return region; }
0093 
0094   const bool isNegativeEta() const { return negativeEta; }
0095 
0096   const std::shared_ptr<UCTTower> getTower(UCTTowerIndex t) const { return getTower(t.first, t.second); }
0097 
0098   friend std::ostream& operator<<(std::ostream&, const UCTRegion&);
0099 
0100 protected:
0101   // Helper functions
0102 
0103   const std::shared_ptr<UCTTower> getTower(uint32_t caloEta, uint32_t caloPhi) const;
0104 
0105   // Region location definition
0106 
0107   uint32_t crate;
0108   uint32_t card;
0109   uint32_t region;
0110   bool negativeEta;
0111 
0112   // Owned region level data
0113 
0114   std::vector<std::shared_ptr<UCTTower>> towers;
0115 
0116   uint32_t regionSummary;
0117 
0118   const int fwVersion;
0119 };
0120 
0121 #endif