Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 
0002 #include <utility>
0003 
0004 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h"
0005 
0006 using namespace emtf::phase2::data;
0007 
0008 ZoneLut::ZoneLut() {
0009   auto& zone0 = zones_.emplace_back();
0010   zone0.lut_[0] = {4, 26};   // ME1/1
0011   zone0.lut_[3] = {4, 25};   // ME2/1
0012   zone0.lut_[5] = {4, 25};   // ME3/1
0013   zone0.lut_[7] = {4, 25};   // ME4/1
0014   zone0.lut_[9] = {17, 26};  // GE1/1
0015   zone0.lut_[12] = {7, 25};  // GE2/1
0016   zone0.lut_[14] = {4, 25};  // RE3/1
0017   zone0.lut_[16] = {4, 25};  // RE4/1
0018   zone0.lut_[18] = {4, 23};  // ME0
0019 
0020   auto& zone1 = zones_.emplace_back();
0021   zone1.lut_[0] = {24, 53};   // ME1/1
0022   zone1.lut_[1] = {46, 54};   // ME1/2
0023   zone1.lut_[3] = {23, 49};   // ME2/1
0024   zone1.lut_[5] = {23, 41};   // ME3/1
0025   zone1.lut_[6] = {44, 54};   // ME3/2
0026   zone1.lut_[7] = {23, 35};   // ME4/1
0027   zone1.lut_[8] = {38, 54};   // ME4/2
0028   zone1.lut_[9] = {24, 52};   // GE1/1
0029   zone1.lut_[10] = {52, 56};  // RE1/2
0030   zone1.lut_[12] = {23, 46};  // GE2/1
0031   zone1.lut_[14] = {23, 36};  // RE3/1
0032   zone1.lut_[15] = {40, 52};  // RE3/2
0033   zone1.lut_[16] = {23, 31};  // RE4/1
0034   zone1.lut_[17] = {35, 54};  // RE4/2
0035 
0036   auto& zone2 = zones_.emplace_back();
0037   zone2.lut_[1] = {52, 88};   // ME1/2
0038   zone2.lut_[4] = {52, 88};   // ME2/2
0039   zone2.lut_[6] = {50, 88};   // ME3/2
0040   zone2.lut_[8] = {50, 88};   // ME4/2
0041   zone2.lut_[10] = {52, 84};  // RE1/2
0042   zone2.lut_[13] = {52, 88};  // RE2/2
0043   zone2.lut_[15] = {48, 84};  // RE3/2
0044   zone2.lut_[17] = {52, 84};  // RE4/2
0045 }
0046 
0047 ZoneLut::~ZoneLut() {
0048   // Do Nothing
0049 }
0050 
0051 void ZoneLut::update(const edm::Event&, const edm::EventSetup&) {
0052   // Do Nothing
0053 }
0054 
0055 int ZoneLut::getZones(const int& host, const int& theta) const {
0056   int i = 0;
0057   int word = 0;
0058 
0059   for (const auto& zone : zones_) {
0060     bool in_zone = zone.contains(host, theta);
0061 
0062     if (in_zone) {
0063       word |= (1u << i);
0064     }
0065 
0066     ++i;
0067   }
0068 
0069   return word;
0070 }
0071 
0072 int ZoneLut::getZones(const int& host, const int& theta1, const int& theta2) const {
0073   int i = 0;
0074   int word = 0;
0075 
0076   for (const auto& zone : zones_) {
0077     bool in_zone = zone.contains(host, theta1, theta2);
0078 
0079     if (in_zone) {
0080       word |= (1u << i);
0081     }
0082 
0083     ++i;
0084   }
0085 
0086   return word;
0087 }
0088 
0089 bool Zone::contains(const int& host, const int& theta) const {
0090   // Short-Circuit: LUT not found
0091   auto found = lut_.find(host);
0092 
0093   if (found == lut_.end())
0094     return false;
0095 
0096   // Short-Circuit: Must be within theta range
0097   auto& theta_range = found->second;
0098 
0099   if (theta_range.first <= theta && theta <= theta_range.second) {
0100     return true;
0101   }
0102 
0103   return false;
0104 }
0105 
0106 bool Zone::contains(const int& host, const int& theta1, const int& theta2) const {
0107   // Short-Circuit: LUT not found
0108   auto found = lut_.find(host);
0109 
0110   if (found == lut_.end())
0111     return false;
0112 
0113   // Short-Circuit: Must be within theta range
0114   auto& theta_range = found->second;
0115 
0116   if (theta_range.first <= theta1 && theta1 <= theta_range.second) {
0117     return true;
0118   }
0119 
0120   if (theta_range.first <= theta2 && theta2 <= theta_range.second) {
0121     return true;
0122   }
0123 
0124   return false;
0125 }