6 #include "UCTGeometry.hh"
7 #include "UCTLogging.hh"
8 using namespace l1tcalo;
10 UCTGeometry::UCTGeometry() {}
12 uint32_t UCTGeometry::getLinkNumber(
bool negativeEta, uint32_t
region, uint32_t
iEta, uint32_t iPhi) {
18 LOG_ERROR <<
"Invalid eta index: iEta = " <<
iEta << std::endl;
21 if (checkPhiIndex(
region, iPhi)) {
22 LOG_ERROR <<
"Invalid eta index: iPhi = " << iPhi << std::endl;
25 uint32_t linkNumber = 0xDEADBEEF;
26 if (
region < MaxRegionNumber) {
27 if (
iEta < NEtaInRegion / 2) {
30 linkNumber =
region * 2 + 1;
33 linkNumber = NRegionsInCard * 2 + iPhi;
37 linkNumber += NRegionsInCard * 2 + 2;
48 LOG_ERROR <<
"Invalid eta index: iEta = " <<
iEta << std::endl;
52 int caloEtaIndex =
region * NEtaInRegion +
iEta + 1;
54 caloEtaIndex = (
region - 7) * NHFEtaInRegion +
iEta + 30;
62 int UCTGeometry::getCaloPhiIndex(uint32_t crate, uint32_t card, uint32_t
region, uint32_t iPhi) {
63 if (checkCrate(crate)) {
64 LOG_ERROR <<
"Invalid crate number: crate = " << crate << std::endl;
67 if (checkCard(card)) {
68 LOG_ERROR <<
"Invalid card number: card = " << card << std::endl;
71 if (checkPhiIndex(
region, iPhi)) {
72 LOG_ERROR <<
"Invalid phi index: iPhi = " << iPhi << std::endl;
75 int caloPhiIndex = 0xDEADBEEF;
77 caloPhiIndex = 11 + card * 4 + iPhi;
78 }
else if (crate == 1) {
79 caloPhiIndex = 59 + card * 4 + iPhi;
80 }
else if (crate == 2) {
81 caloPhiIndex = 35 + card * 4 + iPhi;
83 if (caloPhiIndex > 72)
88 uint32_t UCTGeometry::getUCTRegionPhiIndex(uint32_t crate, uint32_t card) {
89 if (checkCrate(crate)) {
90 LOG_ERROR <<
"Invalid crate number: crate = " << crate << std::endl;
93 if (checkCard(card)) {
94 LOG_ERROR <<
"Invalid card number: card = " << card << std::endl;
97 uint32_t uctRegionPhiIndex = 0xDEADBEEF;
99 uctRegionPhiIndex = 3 + card;
100 }
else if (crate == 1) {
102 uctRegionPhiIndex = 15 + card;
104 uctRegionPhiIndex = card - 3;
106 }
else if (crate == 2) {
107 uctRegionPhiIndex = 9 + card;
109 return uctRegionPhiIndex;
112 uint32_t UCTGeometry::getCrate(
int caloEta,
int caloPhi) {
113 uint32_t crate = 0xDEADBEEF;
114 if (caloPhi >= 11 && caloPhi <= 34)
116 else if (caloPhi >= 35 && caloPhi <= 58)
118 else if (caloPhi >= 59 && caloPhi <= 72)
120 else if (caloPhi >= 1 && caloPhi <= 10)
125 uint32_t UCTGeometry::getCard(
int caloEta,
int caloPhi) {
126 uint32_t crate = getCrate(caloEta, caloPhi);
127 uint32_t card = 0xDEADBEEF;
129 card = (caloPhi - 11) / 4;
130 }
else if (crate == 2) {
131 card = (caloPhi - 35) / 4;
132 }
else if (crate == 1 && caloPhi > 58) {
133 card = (caloPhi - 59) / 4;
134 }
else if (crate == 1 && caloPhi <= 10) {
135 card = (caloPhi + 13) / 4;
140 uint32_t UCTGeometry::getRegion(
int caloEta,
int caloPhi) {
141 uint32_t absCEta =
std::abs(caloEta);
142 if ((absCEta - 1) < (NRegionsInCard * NEtaInRegion))
143 return (absCEta - 1) / NEtaInRegion;
145 return NRegionsInCard + ((absCEta - 2 - (NRegionsInCard * NEtaInRegion)) / NHFEtaInRegion);
148 uint32_t UCTGeometry::getiEta(
int caloEta) {
149 uint32_t absCEta =
std::abs(caloEta);
150 if ((absCEta - 1) < (NRegionsInCard * NEtaInRegion))
151 return (absCEta - 1) % NEtaInRegion;
153 return absCEta % NHFEtaInRegion;
156 uint32_t UCTGeometry::getiPhi(
int caloPhi) {
return (caloPhi + 1) % NPhiInCard; }
158 uint32_t UCTGeometry::getNEta(uint32_t
region) {
159 uint32_t
nEta = 0xDEADBEEF;
160 if (
region < CaloHFRegionStart) {
163 nEta = NHFEtaInRegion;
168 uint32_t UCTGeometry::getNPhi(uint32_t
region) {
return NPhiInRegion; }
170 UCTRegionIndex UCTGeometry::getUCTRegionIndex(
int caloEta,
int caloPhi) {
171 uint32_t regionPhi = getUCTRegionPhiIndex(getCrate(caloEta, caloPhi), getCard(caloEta, caloPhi));
172 int regionEta = getUCTRegionEtaIndex((caloEta < 0), getRegion(caloEta, caloPhi));
173 return UCTRegionIndex(regionEta, regionPhi);
176 UCTRegionIndex UCTGeometry::getUCTRegionIndex(
bool negativeSide, uint32_t crate, uint32_t card, uint32_t
region) {
177 uint32_t regionPhi = getUCTRegionPhiIndex(crate, card);
179 return UCTRegionIndex(regionEta, regionPhi);
182 UCTTowerIndex UCTGeometry::getUCTTowerIndex(UCTRegionIndex
region, uint32_t
iEta, uint32_t iPhi) {
183 if (iPhi >= NPhiInRegion ||
iEta >= NEtaInRegion) {
184 return UCTTowerIndex(0, 0);
186 int regionEta =
region.first;
187 int absRegionEta =
std::abs(regionEta);
188 int towerEta = (regionEta / absRegionEta) * (absRegionEta * NEtaInRegion +
iEta);
189 uint32_t regionPhi =
region.second;
190 int towerPhi = regionPhi * NPhiInRegion + iPhi + 1;
191 return UCTTowerIndex(towerEta, towerPhi);
195 constexpr std::array<double, 42> fillTwrEtaValues() {
196 std::array<double, 42> twrEtaValues = {{0}};
198 for (
unsigned int i = 0;
i < 20;
i++) {
199 twrEtaValues[
i + 1] = 0.0436 +
i * 0.0872;
201 twrEtaValues[21] = 1.785;
202 twrEtaValues[22] = 1.880;
203 twrEtaValues[23] = 1.9865;
204 twrEtaValues[24] = 2.1075;
205 twrEtaValues[25] = 2.247;
206 twrEtaValues[26] = 2.411;
207 twrEtaValues[27] = 2.575;
208 twrEtaValues[28] = 2.825;
209 twrEtaValues[29] = 999.;
210 twrEtaValues[30] = (3.15 + 2.98) / 2.;
211 twrEtaValues[31] = (3.33 + 3.15) / 2.;
212 twrEtaValues[32] = (3.50 + 3.33) / 2.;
213 twrEtaValues[33] = (3.68 + 3.50) / 2.;
214 twrEtaValues[34] = (3.68 + 3.85) / 2.;
215 twrEtaValues[35] = (3.85 + 4.03) / 2.;
216 twrEtaValues[36] = (4.03 + 4.20) / 2.;
217 twrEtaValues[37] = (4.20 + 4.38) / 2.;
218 twrEtaValues[38] = (4.74 + 4.38 * 3) / 4.;
219 twrEtaValues[39] = (4.38 + 4.74 * 3) / 4.;
220 twrEtaValues[40] = (5.21 + 4.74 * 3) / 4.;
221 twrEtaValues[41] = (4.74 + 5.21 * 3) / 4.;
224 constexpr std::array<double, 42> twrEtaValues = fillTwrEtaValues();
227 double UCTGeometry::getUCTTowerEta(
int caloEta) {
228 uint32_t absCaloEta =
std::abs(caloEta);
229 if (absCaloEta <= 41) {
231 return -twrEtaValues[absCaloEta];
233 return +twrEtaValues[absCaloEta];
238 double UCTGeometry::getUCTTowerPhi(
int caloPhi) {
241 else if (caloPhi > 72)
243 uint32_t absCaloPhi =
std::abs(caloPhi) - 1;
245 return (((
double)absCaloPhi + 0.5) * 0.0872);
247 return (-(71.5 - (
double)absCaloPhi) * 0.0872);