Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:15

0001 #include <cstdint>
0002 #include <cstdlib>
0003 #include <iostream>
0004 
0005 #include "UCTGeometryExtended.hh"
0006 using namespace l1tcalo;
0007 
0008 UCTRegionIndex UCTGeometryExtended::getUCTRegionNorth(UCTRegionIndex center) {
0009   int eta = center.first;
0010   uint32_t phi = center.second;
0011   phi += 1;
0012   if (phi == MaxUCTRegionsPhi)
0013     phi = 0;
0014   else if (phi > MaxUCTRegionsPhi)
0015     phi = 0xDEADBEEF;
0016   return UCTRegionIndex(eta, phi);
0017 }
0018 
0019 UCTRegionIndex UCTGeometryExtended::getUCTRegionSouth(UCTRegionIndex center) {
0020   int eta = center.first;
0021   uint32_t phi = center.second;
0022   if (phi == 0)
0023     phi = MaxUCTRegionsPhi - 1;
0024   else if (phi < MaxUCTRegionsPhi)
0025     phi -= 1;
0026   else
0027     phi = 0xDEADBEEF;
0028   return UCTRegionIndex(eta, phi);
0029 }
0030 
0031 UCTRegionIndex UCTGeometryExtended::getUCTRegionEast(UCTRegionIndex center) {
0032   int eta = center.first;
0033   uint32_t phi = center.second;
0034   eta += 1;
0035   if (eta == 0)
0036     eta = 1;  // eta = 0 is illegal, go one above
0037   int etaMax = MaxUCTRegionsEta;
0038   if (eta > etaMax)
0039     eta = 0;  // beyond high Eta edge - should not be used
0040   return UCTRegionIndex(eta, phi);
0041 }
0042 
0043 UCTRegionIndex UCTGeometryExtended::getUCTRegionWest(UCTRegionIndex center) {
0044   int eta = center.first;
0045   uint32_t phi = center.second;
0046   eta -= 1;
0047   if (eta == 0)
0048     eta = -1;  // eta = 0 is illegal, go one below
0049   int etaMin = -MaxUCTRegionsEta;
0050   if (eta < etaMin)
0051     eta = 0;  // beyond high Eta edge - should not be used
0052   return UCTRegionIndex(eta, phi);
0053 }
0054 
0055 UCTRegionIndex UCTGeometryExtended::getUCTRegionNE(UCTRegionIndex center) {
0056   int eta = center.first;
0057   uint32_t phi = center.second;
0058   phi += 1;
0059   if (phi == MaxUCTRegionsPhi)
0060     phi = 0;
0061   else if (phi > MaxUCTRegionsPhi)
0062     phi = 0xDEADBEEF;
0063   eta += 1;
0064   if (eta == 0)
0065     eta = 1;  // eta = 0 is illegal, go one above
0066   int etaMax = MaxUCTRegionsEta;
0067   if (eta > etaMax)
0068     eta = 0;  // beyond high Eta edge - should not be used
0069   return UCTRegionIndex(eta, phi);
0070 }
0071 
0072 UCTRegionIndex UCTGeometryExtended::getUCTRegionNW(UCTRegionIndex center) {
0073   int eta = center.first;
0074   uint32_t phi = center.second;
0075   phi += 1;
0076   if (phi == MaxUCTRegionsPhi)
0077     phi = 0;
0078   else if (phi > MaxUCTRegionsPhi)
0079     phi = 0xDEADBEEF;
0080   eta -= 1;
0081   if (eta == 0)
0082     eta = -1;  // eta = 0 is illegal, go one below
0083   int etaMin = -MaxUCTRegionsEta;
0084   if (eta < etaMin)
0085     eta = 0;  // beyond high Eta edge - should not be used
0086   return UCTRegionIndex(eta, phi);
0087 }
0088 
0089 UCTRegionIndex UCTGeometryExtended::getUCTRegionSE(UCTRegionIndex center) {
0090   int eta = center.first;
0091   uint32_t phi = center.second;
0092   if (phi == 0)
0093     phi = MaxUCTRegionsPhi - 1;
0094   else if (phi < MaxUCTRegionsPhi)
0095     phi -= 1;
0096   else
0097     phi = 0xDEADBEEF;
0098   eta += 1;
0099   if (eta == 0)
0100     eta = 1;  // eta = 0 is illegal, go one above
0101   int etaMax = MaxUCTRegionsEta;
0102   if (eta > etaMax)
0103     eta = 0;  // beyond high Eta edge - should not be used
0104   return UCTRegionIndex(eta, phi);
0105 }
0106 
0107 UCTRegionIndex UCTGeometryExtended::getUCTRegionSW(UCTRegionIndex center) {
0108   int eta = center.first;
0109   uint32_t phi = center.second;
0110   if (phi == 0)
0111     phi = MaxUCTRegionsPhi - 1;
0112   else if (phi < MaxUCTRegionsPhi)
0113     phi -= 1;
0114   else
0115     phi = 0xDEADBEEF;
0116   eta -= 1;
0117   if (eta == 0)
0118     eta = -1;  // eta = 0 is illegal, go one below
0119   int etaMin = -MaxUCTRegionsEta;
0120   if (eta < etaMin)
0121     eta = 0;  // beyond high Eta edge - should not be used
0122   return UCTRegionIndex(eta, phi);
0123 }
0124 
0125 bool UCTGeometryExtended::areNeighbors(UCTTowerIndex a, UCTTowerIndex b) {
0126   int diffEta = std::abs(a.first - b.first);                // Note eta values run -28 to +28, 0 excluded
0127   int diffPhi = std::abs(((int)a.second - (int)b.second));  // Note phi values run 1-72, with 72 & 1 as neighbors
0128   if ((diffEta <= 1 || (a.first == -1 && b.first == 1) || (a.first == 1 && b.first == -1)) &&
0129       (diffPhi <= 1 || diffPhi == 71))
0130     return true;
0131   return false;
0132 }
0133 
0134 bool UCTGeometryExtended::isEdgeTower(UCTTowerIndex a) {
0135   int eta = a.first;
0136   int etaMin = -MaxUCTRegionsEta;
0137   int etaMax = MaxUCTRegionsEta;
0138   if (eta == etaMin || eta == etaMax)
0139     return true;
0140   return false;
0141 }