5 #include "UCTGeometry.hh" 6 #include "UCTLogging.hh" 9 UCTGeometry::UCTGeometry() {
11 for(
unsigned int i = 0;
i < 20;
i++) {
12 twrEtaValues[
i + 1] = 0.0436 +
i * 0.0872;
14 twrEtaValues[21] = 1.785;
15 twrEtaValues[22] = 1.880;
16 twrEtaValues[23] = 1.9865;
17 twrEtaValues[24] = 2.1075;
18 twrEtaValues[25] = 2.247;
19 twrEtaValues[26] = 2.411;
20 twrEtaValues[27] = 2.575;
21 twrEtaValues[28] = 2.825;
24 uint32_t UCTGeometry::getLinkNumber(
bool negativeEta, uint32_t region,
25 uint32_t iEta, uint32_t iPhi) {
26 if(checkRegion(region)) {
27 LOG_ERROR <<
"Invalid region number: region = " << region << std::endl;
30 if(checkEtaIndex(region, iEta)) {
31 LOG_ERROR <<
"Invalid eta index: iEta = " << iEta << std::endl;
34 if(checkPhiIndex(region, iPhi)) {
35 LOG_ERROR <<
"Invalid eta index: iPhi = " << iPhi << std::endl;
38 uint32_t linkNumber = 0xDEADBEEF;
39 if(region < MaxRegionNumber) {
40 if(iEta < NEtaInRegion / 2) {
41 linkNumber = region * 2;
44 linkNumber = region * 2 + 1;
48 linkNumber = NRegionsInCard * 2 + iPhi;
52 linkNumber += NRegionsInCard * 2 + 2;
57 int UCTGeometry::getCaloEtaIndex(
bool negativeSide, uint32_t region, uint32_t iEta) {
59 if(checkRegion(region)) {
60 LOG_ERROR <<
"Invalid region number: region = " << region << std::endl;
63 if(checkEtaIndex(region, iEta)) {
64 LOG_ERROR <<
"Invalid eta index: iEta = " << iEta << std::endl;
68 int caloEtaIndex = region * NEtaInRegion + iEta + 1;
70 caloEtaIndex = (region - 7) * NHFEtaInRegion + iEta + 30;
73 if(negativeSide)
return -caloEtaIndex;
78 int UCTGeometry::getCaloPhiIndex(uint32_t crate, uint32_t card,
79 uint32_t region, uint32_t iPhi) {
80 if(checkCrate(crate)) {
81 LOG_ERROR <<
"Invalid crate number: crate = " << crate << std::endl;
85 LOG_ERROR <<
"Invalid card number: card = " << card << std::endl;
88 if(checkPhiIndex(region, iPhi)) {
89 LOG_ERROR <<
"Invalid phi index: iPhi = " << iPhi << std::endl;
92 int caloPhiIndex = 0xDEADBEEF;
94 caloPhiIndex = 11 + card * 4 + iPhi;
97 caloPhiIndex = 59 + card * 4 + iPhi;
100 caloPhiIndex = 35 + card * 4 + iPhi;
102 if(caloPhiIndex > 72) caloPhiIndex -= 72;
106 uint32_t UCTGeometry::getUCTRegionPhiIndex(uint32_t crate, uint32_t card) {
107 if(checkCrate(crate)) {
108 LOG_ERROR <<
"Invalid crate number: crate = " << crate << std::endl;
111 if(checkCard(card)) {
112 LOG_ERROR <<
"Invalid card number: card = " << card << std::endl;
115 uint32_t uctRegionPhiIndex = 0xDEADBEEF;
117 uctRegionPhiIndex = 3 + card;
119 else if(crate == 1) {
121 uctRegionPhiIndex = 15 + card;
124 uctRegionPhiIndex = card - 3;
127 else if(crate == 2) {
128 uctRegionPhiIndex = 9 + card;
130 return uctRegionPhiIndex;
133 uint32_t UCTGeometry::getCrate(
int caloEta,
int caloPhi) {
134 uint32_t crate = 0xDEADBEEF;
135 if(caloPhi >= 11 && caloPhi <= 34) crate = 0;
136 else if(caloPhi >= 35 && caloPhi <= 58) crate = 2;
137 else if(caloPhi >= 59 && caloPhi <= 72) crate = 1;
138 else if(caloPhi >= 1 && caloPhi <= 10) crate = 1;
142 uint32_t UCTGeometry::getCard(
int caloEta,
int caloPhi) {
143 uint32_t crate = getCrate(caloEta, caloPhi);
144 uint32_t card = 0xDEADBEEF;
146 card = (caloPhi - 11) / 4;
148 else if(crate == 2) {
149 card = (caloPhi - 35) / 4;
151 else if(crate == 1 && caloPhi > 58) {
152 card = (caloPhi - 59) / 4;
154 else if(crate == 1 && caloPhi <= 10) {
155 card = (caloPhi + 13) / 4;
160 uint32_t UCTGeometry::getRegion(
int caloEta,
int caloPhi) {
161 uint32_t absCEta =
std::abs(caloEta);
162 if((absCEta - 1) < (NRegionsInCard * NEtaInRegion))
163 return (absCEta - 1) / NEtaInRegion;
165 return NRegionsInCard + ((absCEta - 2 - (NRegionsInCard * NEtaInRegion)) / NHFEtaInRegion);
168 uint32_t UCTGeometry::getiEta(
int caloEta) {
169 uint32_t absCEta =
std::abs(caloEta);
170 if((absCEta - 1) < (NRegionsInCard * NEtaInRegion))
171 return (absCEta - 1) % NEtaInRegion;
173 return absCEta % NHFEtaInRegion;
176 uint32_t UCTGeometry::getiPhi(
int caloPhi) {
177 return (caloPhi + 1) % NPhiInCard;
180 uint32_t UCTGeometry::getNEta(uint32_t region) {
181 uint32_t
nEta = 0xDEADBEEF;
182 if(region < CaloHFRegionStart) {
186 nEta = NHFEtaInRegion;
191 uint32_t UCTGeometry::getNPhi(uint32_t region) {
195 UCTRegionIndex UCTGeometry::getUCTRegionIndex(
int caloEta,
int caloPhi) {
196 uint32_t regionPhi = getUCTRegionPhiIndex(getCrate(caloEta, caloPhi), getCard(caloEta, caloPhi));
197 int regionEta = getUCTRegionEtaIndex((caloEta < 0), getRegion(caloEta, caloPhi));
198 return UCTRegionIndex(regionEta, regionPhi);
201 UCTRegionIndex UCTGeometry::getUCTRegionIndex(
bool negativeSide, uint32_t crate, uint32_t card, uint32_t region) {
202 uint32_t regionPhi = getUCTRegionPhiIndex(crate, card);
203 int regionEta = getUCTRegionEtaIndex(negativeSide, region);
204 return UCTRegionIndex(regionEta, regionPhi);
207 UCTTowerIndex UCTGeometry::getUCTTowerIndex(UCTRegionIndex region, uint32_t iEta, uint32_t iPhi) {
208 if(iPhi >= NPhiInRegion || iEta >= NEtaInRegion) {
209 return UCTTowerIndex(0, 0);
211 int regionEta = region.first;
212 int absRegionEta =
std::abs(regionEta);
213 int towerEta = (regionEta / absRegionEta) * (absRegionEta * NEtaInRegion + iEta);
214 uint32_t regionPhi = region.second;
215 int towerPhi = regionPhi * NPhiInRegion + iPhi + 1;
216 return UCTTowerIndex(towerEta, towerPhi);
219 double UCTGeometry::getUCTTowerEta(
int caloEta) {
220 static bool first =
true;
221 static double twrEtaValues[42];
224 for(
unsigned int i = 0;
i < 20;
i++) {
225 twrEtaValues[
i + 1] = 0.0436 +
i * 0.0872;
227 twrEtaValues[21] = 1.785;
228 twrEtaValues[22] = 1.880;
229 twrEtaValues[23] = 1.9865;
230 twrEtaValues[24] = 2.1075;
231 twrEtaValues[25] = 2.247;
232 twrEtaValues[26] = 2.411;
233 twrEtaValues[27] = 2.575;
234 twrEtaValues[28] = 2.825;
235 twrEtaValues[29] = 999.;
236 twrEtaValues[30] = (3.15+2.98)/2.;
237 twrEtaValues[31] = (3.33+3.15)/2.;
238 twrEtaValues[32] = (3.50+3.33)/2.;
239 twrEtaValues[33] = (3.68+3.50)/2.;
240 twrEtaValues[34] = (3.68+3.85)/2.;
241 twrEtaValues[35] = (3.85+4.03)/2.;
242 twrEtaValues[36] = (4.03+4.20)/2.;
243 twrEtaValues[37] = (4.20+4.38)/2.;
244 twrEtaValues[38] = (4.74+4.38*3)/4.;
245 twrEtaValues[39] = (4.38+4.74*3)/4.;
246 twrEtaValues[40] = (5.21+4.74*3)/4.;
247 twrEtaValues[41] = (4.74+5.21*3)/4.;
250 uint32_t absCaloEta =
std::abs(caloEta);
251 if(absCaloEta <= 41) {
253 return -twrEtaValues[absCaloEta];
255 return +twrEtaValues[absCaloEta];
260 double UCTGeometry::getUCTTowerPhi(
int caloPhi) {
261 if(caloPhi < 1)
return -999.;
262 else if(caloPhi > 72)
return +999.;
263 uint32_t absCaloPhi =
std::abs(caloPhi) - 1;
265 return (((
double) absCaloPhi + 0.5) * 0.0872);
267 return (-(71.5 - (
double) absCaloPhi) * 0.0872);
Abs< T >::type abs(const T &t)