6 #include "UCTGeometry.hh" 7 #include "UCTLogging.hh" 10 UCTGeometry::UCTGeometry() {
13 uint32_t UCTGeometry::getLinkNumber(
bool negativeEta, uint32_t region,
14 uint32_t iEta, uint32_t iPhi) {
15 if(checkRegion(region)) {
16 LOG_ERROR <<
"Invalid region number: region = " << region << std::endl;
19 if(checkEtaIndex(region, iEta)) {
20 LOG_ERROR <<
"Invalid eta index: iEta = " << iEta << std::endl;
23 if(checkPhiIndex(region, iPhi)) {
24 LOG_ERROR <<
"Invalid eta index: iPhi = " << iPhi << std::endl;
27 uint32_t linkNumber = 0xDEADBEEF;
28 if(region < MaxRegionNumber) {
29 if(iEta < NEtaInRegion / 2) {
30 linkNumber = region * 2;
33 linkNumber = region * 2 + 1;
37 linkNumber = NRegionsInCard * 2 + iPhi;
41 linkNumber += NRegionsInCard * 2 + 2;
46 int UCTGeometry::getCaloEtaIndex(
bool negativeSide, uint32_t region, uint32_t iEta) {
48 if(checkRegion(region)) {
49 LOG_ERROR <<
"Invalid region number: region = " << region << std::endl;
52 if(checkEtaIndex(region, iEta)) {
53 LOG_ERROR <<
"Invalid eta index: iEta = " << iEta << std::endl;
57 int caloEtaIndex = region * NEtaInRegion + iEta + 1;
59 caloEtaIndex = (region - 7) * NHFEtaInRegion + iEta + 30;
62 if(negativeSide)
return -caloEtaIndex;
67 int UCTGeometry::getCaloPhiIndex(uint32_t crate, uint32_t card,
68 uint32_t region, uint32_t iPhi) {
69 if(checkCrate(crate)) {
70 LOG_ERROR <<
"Invalid crate number: crate = " << crate << std::endl;
74 LOG_ERROR <<
"Invalid card number: card = " << card << std::endl;
77 if(checkPhiIndex(region, iPhi)) {
78 LOG_ERROR <<
"Invalid phi index: iPhi = " << iPhi << std::endl;
81 int caloPhiIndex = 0xDEADBEEF;
83 caloPhiIndex = 11 + card * 4 + iPhi;
86 caloPhiIndex = 59 + card * 4 + iPhi;
89 caloPhiIndex = 35 + card * 4 + iPhi;
91 if(caloPhiIndex > 72) caloPhiIndex -= 72;
95 uint32_t UCTGeometry::getUCTRegionPhiIndex(uint32_t crate, uint32_t card) {
96 if(checkCrate(crate)) {
97 LOG_ERROR <<
"Invalid crate number: crate = " << crate << std::endl;
100 if(checkCard(card)) {
101 LOG_ERROR <<
"Invalid card number: card = " << card << std::endl;
104 uint32_t uctRegionPhiIndex = 0xDEADBEEF;
106 uctRegionPhiIndex = 3 + card;
108 else if(crate == 1) {
110 uctRegionPhiIndex = 15 + card;
113 uctRegionPhiIndex = card - 3;
116 else if(crate == 2) {
117 uctRegionPhiIndex = 9 + card;
119 return uctRegionPhiIndex;
122 uint32_t UCTGeometry::getCrate(
int caloEta,
int caloPhi) {
123 uint32_t crate = 0xDEADBEEF;
124 if(caloPhi >= 11 && caloPhi <= 34) crate = 0;
125 else if(caloPhi >= 35 && caloPhi <= 58) crate = 2;
126 else if(caloPhi >= 59 && caloPhi <= 72) crate = 1;
127 else if(caloPhi >= 1 && caloPhi <= 10) crate = 1;
131 uint32_t UCTGeometry::getCard(
int caloEta,
int caloPhi) {
132 uint32_t crate = getCrate(caloEta, caloPhi);
133 uint32_t card = 0xDEADBEEF;
135 card = (caloPhi - 11) / 4;
137 else if(crate == 2) {
138 card = (caloPhi - 35) / 4;
140 else if(crate == 1 && caloPhi > 58) {
141 card = (caloPhi - 59) / 4;
143 else if(crate == 1 && caloPhi <= 10) {
144 card = (caloPhi + 13) / 4;
149 uint32_t UCTGeometry::getRegion(
int caloEta,
int caloPhi) {
150 uint32_t absCEta =
std::abs(caloEta);
151 if((absCEta - 1) < (NRegionsInCard * NEtaInRegion))
152 return (absCEta - 1) / NEtaInRegion;
154 return NRegionsInCard + ((absCEta - 2 - (NRegionsInCard * NEtaInRegion)) / NHFEtaInRegion);
157 uint32_t UCTGeometry::getiEta(
int caloEta) {
158 uint32_t absCEta =
std::abs(caloEta);
159 if((absCEta - 1) < (NRegionsInCard * NEtaInRegion))
160 return (absCEta - 1) % NEtaInRegion;
162 return absCEta % NHFEtaInRegion;
165 uint32_t UCTGeometry::getiPhi(
int caloPhi) {
166 return (caloPhi + 1) % NPhiInCard;
169 uint32_t UCTGeometry::getNEta(uint32_t region) {
170 uint32_t
nEta = 0xDEADBEEF;
171 if(region < CaloHFRegionStart) {
175 nEta = NHFEtaInRegion;
180 uint32_t UCTGeometry::getNPhi(uint32_t region) {
184 UCTRegionIndex UCTGeometry::getUCTRegionIndex(
int caloEta,
int caloPhi) {
185 uint32_t regionPhi = getUCTRegionPhiIndex(getCrate(caloEta, caloPhi), getCard(caloEta, caloPhi));
186 int regionEta = getUCTRegionEtaIndex((caloEta < 0), getRegion(caloEta, caloPhi));
187 return UCTRegionIndex(regionEta, regionPhi);
190 UCTRegionIndex UCTGeometry::getUCTRegionIndex(
bool negativeSide, uint32_t crate, uint32_t card, uint32_t region) {
191 uint32_t regionPhi = getUCTRegionPhiIndex(crate, card);
192 int regionEta = getUCTRegionEtaIndex(negativeSide, region);
193 return UCTRegionIndex(regionEta, regionPhi);
196 UCTTowerIndex UCTGeometry::getUCTTowerIndex(UCTRegionIndex region, uint32_t iEta, uint32_t iPhi) {
197 if(iPhi >= NPhiInRegion || iEta >= NEtaInRegion) {
198 return UCTTowerIndex(0, 0);
200 int regionEta = region.first;
201 int absRegionEta =
std::abs(regionEta);
202 int towerEta = (regionEta / absRegionEta) * (absRegionEta * NEtaInRegion + iEta);
203 uint32_t regionPhi = region.second;
204 int towerPhi = regionPhi * NPhiInRegion + iPhi + 1;
205 return UCTTowerIndex(towerEta, towerPhi);
209 constexpr std::array<double,42> fillTwrEtaValues() {
210 std::array<double, 42> twrEtaValues = {{0}};
212 for(
unsigned int i = 0;
i < 20;
i++) {
213 twrEtaValues[
i + 1] = 0.0436 +
i * 0.0872;
215 twrEtaValues[21] = 1.785;
216 twrEtaValues[22] = 1.880;
217 twrEtaValues[23] = 1.9865;
218 twrEtaValues[24] = 2.1075;
219 twrEtaValues[25] = 2.247;
220 twrEtaValues[26] = 2.411;
221 twrEtaValues[27] = 2.575;
222 twrEtaValues[28] = 2.825;
223 twrEtaValues[29] = 999.;
224 twrEtaValues[30] = (3.15+2.98)/2.;
225 twrEtaValues[31] = (3.33+3.15)/2.;
226 twrEtaValues[32] = (3.50+3.33)/2.;
227 twrEtaValues[33] = (3.68+3.50)/2.;
228 twrEtaValues[34] = (3.68+3.85)/2.;
229 twrEtaValues[35] = (3.85+4.03)/2.;
230 twrEtaValues[36] = (4.03+4.20)/2.;
231 twrEtaValues[37] = (4.20+4.38)/2.;
232 twrEtaValues[38] = (4.74+4.38*3)/4.;
233 twrEtaValues[39] = (4.38+4.74*3)/4.;
234 twrEtaValues[40] = (5.21+4.74*3)/4.;
235 twrEtaValues[41] = (4.74+5.21*3)/4.;
238 constexpr std::array<double,42> twrEtaValues = fillTwrEtaValues();
241 double UCTGeometry::getUCTTowerEta(
int caloEta) {
242 uint32_t absCaloEta =
std::abs(caloEta);
243 if(absCaloEta <= 41) {
245 return -twrEtaValues[absCaloEta];
247 return +twrEtaValues[absCaloEta];
252 double UCTGeometry::getUCTTowerPhi(
int caloPhi) {
253 if(caloPhi < 1)
return -999.;
254 else if(caloPhi > 72)
return +999.;
255 uint32_t absCaloPhi =
std::abs(caloPhi) - 1;
257 return (((
double) absCaloPhi + 0.5) * 0.0872);
259 return (-(71.5 - (
double) absCaloPhi) * 0.0872);
Abs< T >::type abs(const T &t)