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};
0011 zone0.lut_[3] = {4, 25};
0012 zone0.lut_[5] = {4, 25};
0013 zone0.lut_[7] = {4, 25};
0014 zone0.lut_[9] = {17, 26};
0015 zone0.lut_[12] = {7, 25};
0016 zone0.lut_[14] = {4, 25};
0017 zone0.lut_[16] = {4, 25};
0018 zone0.lut_[18] = {4, 23};
0019
0020 auto& zone1 = zones_.emplace_back();
0021 zone1.lut_[0] = {24, 53};
0022 zone1.lut_[1] = {46, 54};
0023 zone1.lut_[3] = {23, 49};
0024 zone1.lut_[5] = {23, 41};
0025 zone1.lut_[6] = {44, 54};
0026 zone1.lut_[7] = {23, 35};
0027 zone1.lut_[8] = {38, 54};
0028 zone1.lut_[9] = {24, 52};
0029 zone1.lut_[10] = {52, 56};
0030 zone1.lut_[12] = {23, 46};
0031 zone1.lut_[14] = {23, 36};
0032 zone1.lut_[15] = {40, 52};
0033 zone1.lut_[16] = {23, 31};
0034 zone1.lut_[17] = {35, 54};
0035
0036 auto& zone2 = zones_.emplace_back();
0037 zone2.lut_[1] = {52, 88};
0038 zone2.lut_[4] = {52, 88};
0039 zone2.lut_[6] = {50, 88};
0040 zone2.lut_[8] = {50, 88};
0041 zone2.lut_[10] = {52, 84};
0042 zone2.lut_[13] = {52, 88};
0043 zone2.lut_[15] = {48, 84};
0044 zone2.lut_[17] = {52, 84};
0045 }
0046
0047 ZoneLut::~ZoneLut() {
0048
0049 }
0050
0051 void ZoneLut::update(const edm::Event&, const edm::EventSetup&) {
0052
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
0091 auto found = lut_.find(host);
0092
0093 if (found == lut_.end())
0094 return false;
0095
0096
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
0108 auto found = lut_.find(host);
0109
0110 if (found == lut_.end())
0111 return false;
0112
0113
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 }