File indexing completed on 2024-04-06 12:11:11
0001 #include "FastSimulation/CaloGeometryTools/interface/CaloDirectionOperations.h"
0002
0003 CaloDirection CaloDirectionOperations::add2d(const CaloDirection& dir1, const CaloDirection& dir2) {
0004
0005
0006 constexpr CaloDirection tab[4][4] = {{NORTH, NORTHEAST, NONE, NORTHWEST},
0007 {NORTHEAST, EAST, SOUTHEAST, NONE},
0008 {NONE, SOUTHEAST, SOUTH, SOUTHWEST},
0009 {NORTHWEST, NONE, SOUTHWEST, WEST}};
0010 return tab[Side(dir1)][Side(dir2)];
0011 }
0012
0013 CaloDirection CaloDirectionOperations::Side(unsigned i) {
0014 constexpr CaloDirection sides[6] = {NORTH, EAST, SOUTH, WEST, UP, DOWN};
0015
0016 return sides[i];
0017 }
0018
0019 unsigned CaloDirectionOperations::neighbourDirection(const CaloDirection& side) {
0020 unsigned result;
0021 switch (side) {
0022 case NORTH:
0023 result = 0;
0024 break;
0025 case EAST:
0026 result = 1;
0027 break;
0028 case SOUTH:
0029 result = 2;
0030 break;
0031 case WEST:
0032 result = 3;
0033 break;
0034 case NORTHEAST:
0035 result = 4;
0036 break;
0037 case SOUTHEAST:
0038 result = 5;
0039 break;
0040 case SOUTHWEST:
0041 result = 6;
0042 break;
0043 case NORTHWEST:
0044 result = 7;
0045 break;
0046 default:
0047 result = 999;
0048 }
0049 return result;
0050 }
0051
0052
0053 CaloDirection CaloDirectionOperations::neighbourDirection(unsigned i) {
0054 constexpr CaloDirection sides[8] = {NORTH, EAST, SOUTH, WEST, NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST};
0055
0056 return sides[i];
0057 }
0058
0059 unsigned CaloDirectionOperations::Side(const CaloDirection& side) {
0060 unsigned result;
0061 switch (side) {
0062 case NORTH:
0063 result = 0;
0064 break;
0065 case EAST:
0066 result = 1;
0067 break;
0068 case SOUTH:
0069 result = 2;
0070 break;
0071 case WEST:
0072 result = 3;
0073 break;
0074 case UP:
0075 result = 4;
0076 break;
0077 case DOWN:
0078 result = 5;
0079 break;
0080 default:
0081 result = 999;
0082 }
0083 return result;
0084 }
0085
0086 CaloDirection CaloDirectionOperations::oppositeSide(const CaloDirection& side) {
0087 CaloDirection result;
0088 switch (side) {
0089 case UP:
0090 result = DOWN;
0091 break;
0092 case DOWN:
0093 result = UP;
0094 break;
0095 case EAST:
0096 result = WEST;
0097 break;
0098 case WEST:
0099 result = EAST;
0100 break;
0101 case NORTH:
0102 result = SOUTH;
0103 break;
0104 case SOUTH:
0105 result = NORTH;
0106 break;
0107 case NORTHEAST:
0108 result = SOUTHWEST;
0109 break;
0110 case NORTHWEST:
0111 result = SOUTHEAST;
0112 break;
0113 case SOUTHEAST:
0114 result = NORTHWEST;
0115 break;
0116 case SOUTHWEST:
0117 result = NORTHEAST;
0118 break;
0119
0120 default:
0121 result = NONE;
0122 }
0123 return result;
0124 }
0125
0126 unsigned CaloDirectionOperations::oppositeDirection(unsigned iside) {
0127 constexpr unsigned od[8] = {2, 3, 0, 1, 6, 7, 4, 5};
0128 return od[iside];
0129
0130
0131 }