CMS 3D CMS Logo

ZoneLut.cc
Go to the documentation of this file.
1 
2 #include <utility>
3 
5 
6 using namespace emtf::phase2::data;
7 
9  auto& zone0 = zones_.emplace_back();
10  zone0.lut_[0] = {4, 26}; // ME1/1
11  zone0.lut_[3] = {4, 25}; // ME2/1
12  zone0.lut_[5] = {4, 25}; // ME3/1
13  zone0.lut_[7] = {4, 25}; // ME4/1
14  zone0.lut_[9] = {17, 26}; // GE1/1
15  zone0.lut_[12] = {7, 25}; // GE2/1
16  zone0.lut_[14] = {4, 25}; // RE3/1
17  zone0.lut_[16] = {4, 25}; // RE4/1
18  zone0.lut_[18] = {4, 23}; // ME0
19 
20  auto& zone1 = zones_.emplace_back();
21  zone1.lut_[0] = {24, 53}; // ME1/1
22  zone1.lut_[1] = {46, 54}; // ME1/2
23  zone1.lut_[3] = {23, 49}; // ME2/1
24  zone1.lut_[5] = {23, 41}; // ME3/1
25  zone1.lut_[6] = {44, 54}; // ME3/2
26  zone1.lut_[7] = {23, 35}; // ME4/1
27  zone1.lut_[8] = {38, 54}; // ME4/2
28  zone1.lut_[9] = {24, 52}; // GE1/1
29  zone1.lut_[10] = {52, 56}; // RE1/2
30  zone1.lut_[12] = {23, 46}; // GE2/1
31  zone1.lut_[14] = {23, 36}; // RE3/1
32  zone1.lut_[15] = {40, 52}; // RE3/2
33  zone1.lut_[16] = {23, 31}; // RE4/1
34  zone1.lut_[17] = {35, 54}; // RE4/2
35 
36  auto& zone2 = zones_.emplace_back();
37  zone2.lut_[1] = {52, 88}; // ME1/2
38  zone2.lut_[4] = {52, 88}; // ME2/2
39  zone2.lut_[6] = {50, 88}; // ME3/2
40  zone2.lut_[8] = {50, 88}; // ME4/2
41  zone2.lut_[10] = {52, 84}; // RE1/2
42  zone2.lut_[13] = {52, 88}; // RE2/2
43  zone2.lut_[15] = {48, 84}; // RE3/2
44  zone2.lut_[17] = {52, 84}; // RE4/2
45 }
46 
48  // Do Nothing
49 }
50 
52  // Do Nothing
53 }
54 
55 int ZoneLut::getZones(const int& host, const int& theta) const {
56  int i = 0;
57  int word = 0;
58 
59  for (const auto& zone : zones_) {
60  bool in_zone = zone.contains(host, theta);
61 
62  if (in_zone) {
63  word |= (1u << i);
64  }
65 
66  ++i;
67  }
68 
69  return word;
70 }
71 
72 int ZoneLut::getZones(const int& host, const int& theta1, const int& theta2) const {
73  int i = 0;
74  int word = 0;
75 
76  for (const auto& zone : zones_) {
77  bool in_zone = zone.contains(host, theta1, theta2);
78 
79  if (in_zone) {
80  word |= (1u << i);
81  }
82 
83  ++i;
84  }
85 
86  return word;
87 }
88 
89 bool Zone::contains(const int& host, const int& theta) const {
90  // Short-Circuit: LUT not found
91  auto found = lut_.find(host);
92 
93  if (found == lut_.end())
94  return false;
95 
96  // Short-Circuit: Must be within theta range
97  auto& theta_range = found->second;
98 
99  if (theta_range.first <= theta && theta <= theta_range.second) {
100  return true;
101  }
102 
103  return false;
104 }
105 
106 bool Zone::contains(const int& host, const int& theta1, const int& theta2) const {
107  // Short-Circuit: LUT not found
108  auto found = lut_.find(host);
109 
110  if (found == lut_.end())
111  return false;
112 
113  // Short-Circuit: Must be within theta range
114  auto& theta_range = found->second;
115 
116  if (theta_range.first <= theta1 && theta1 <= theta_range.second) {
117  return true;
118  }
119 
120  if (theta_range.first <= theta2 && theta2 <= theta_range.second) {
121  return true;
122  }
123 
124  return false;
125 }
string host
Definition: query.py:115
void update(const edm::Event &, const edm::EventSetup &)
Definition: ZoneLut.cc:51
uint64_t word
std::map< int, std::pair< int, int > > lut_
Definition: ZoneLut.h:47
int getZones(const int &, const int &) const
Definition: ZoneLut.cc:55
std::vector< Zone > zones_
Definition: ZoneLut.h:29
bool contains(const int &, const int &) const
Definition: ZoneLut.cc:89
Geom::Theta< T > theta() const