File indexing completed on 2023-03-17 13:02:32
0001 #include "Geometry/CaloTopology/interface/EcalPreshowerTopology.h"
0002 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0003 #include <stdexcept>
0004
0005 ESDetId EcalPreshowerTopology::incrementIy(const ESDetId& id) const {
0006 ESDetId nextPoint(0);
0007 if (id == nextPoint)
0008 return nextPoint;
0009
0010
0011 if (id.plane() == 2) {
0012 if (id.strip() < 32) {
0013
0014 if (ESDetId::validDetId(id.strip() + 1, id.six(), id.siy(), id.plane(), id.zside()))
0015 nextPoint = ESDetId(id.strip() + 1, id.six(), id.siy(), id.plane(), id.zside());
0016 } else {
0017
0018 if (ESDetId::validDetId(1, id.six(), id.siy() + 1, id.plane(), id.zside()))
0019 nextPoint = ESDetId(1, id.six(), id.siy() + 1, id.plane(), id.zside());
0020 }
0021 }
0022
0023 else if (id.plane() == 1) {
0024
0025 if (ESDetId::validDetId(id.strip(), id.six(), id.siy() + 1, id.plane(), id.zside()))
0026 nextPoint = ESDetId(id.strip(), id.six(), id.siy() + 1, id.plane(), id.zside());
0027 }
0028
0029 return nextPoint;
0030 }
0031
0032 ESDetId EcalPreshowerTopology::decrementIy(const ESDetId& id) const {
0033 ESDetId nextPoint(0);
0034 if (id == nextPoint)
0035 return nextPoint;
0036
0037
0038 if (id.plane() == 2) {
0039 if (id.strip() > 1) {
0040
0041 if (ESDetId::validDetId(id.strip() - 1, id.six(), id.siy(), id.plane(), id.zside()))
0042 nextPoint = ESDetId(id.strip() - 1, id.six(), id.siy(), id.plane(), id.zside());
0043 } else {
0044
0045 if (ESDetId::validDetId(32, id.six(), id.siy() - 1, id.plane(), id.zside()))
0046 nextPoint = ESDetId(32, id.six(), id.siy() - 1, id.plane(), id.zside());
0047 }
0048 }
0049
0050 else if (id.plane() == 1) {
0051
0052 if (ESDetId::validDetId(id.strip(), id.six(), id.siy() - 1, id.plane(), id.zside()))
0053 nextPoint = ESDetId(id.strip(), id.six(), id.siy() - 1, id.plane(), id.zside());
0054 }
0055 return nextPoint;
0056 }
0057
0058 ESDetId EcalPreshowerTopology::incrementIx(const ESDetId& id) const {
0059 ESDetId nextPoint(0);
0060 if (id == nextPoint)
0061 return nextPoint;
0062
0063
0064 if (id.plane() == 2) {
0065
0066 if (ESDetId::validDetId(id.strip(), id.six() + 1, id.siy(), id.plane(), id.zside()))
0067 nextPoint = ESDetId(id.strip(), id.six() + 1, id.siy(), id.plane(), id.zside());
0068 }
0069
0070 else if (id.plane() == 1) {
0071 if (id.strip() < 32) {
0072
0073 if (ESDetId::validDetId(id.strip() + 1, id.six(), id.siy(), id.plane(), id.zside()))
0074 nextPoint = ESDetId(id.strip() + 1, id.six(), id.siy(), id.plane(), id.zside());
0075 } else {
0076
0077 if (ESDetId::validDetId(1, id.six() + 1, id.siy(), id.plane(), id.zside()))
0078 nextPoint = ESDetId(1, id.six() + 1, id.siy(), id.plane(), id.zside());
0079 }
0080 }
0081
0082 return nextPoint;
0083 }
0084
0085 ESDetId EcalPreshowerTopology::decrementIx(const ESDetId& id) const {
0086 ESDetId nextPoint(0);
0087 if (id == nextPoint)
0088 return nextPoint;
0089
0090
0091 if (id.plane() == 2) {
0092
0093 if (ESDetId::validDetId(id.strip(), id.six() - 1, id.siy(), id.plane(), id.zside()))
0094 nextPoint = ESDetId(id.strip(), id.six() - 1, id.siy(), id.plane(), id.zside());
0095 }
0096
0097 else if (id.plane() == 1) {
0098 if (id.strip() > 1) {
0099
0100 if (ESDetId::validDetId(id.strip() - 1, id.six(), id.siy(), id.plane(), id.zside()))
0101 nextPoint = ESDetId(id.strip() - 1, id.six(), id.siy(), id.plane(), id.zside());
0102 } else {
0103
0104 if (ESDetId::validDetId(32, id.six() - 1, id.siy(), id.plane(), id.zside()))
0105 nextPoint = ESDetId(32, id.six() - 1, id.siy(), id.plane(), id.zside());
0106 }
0107 }
0108 return nextPoint;
0109 }
0110
0111 ESDetId EcalPreshowerTopology::incrementIz(const ESDetId& id) const {
0112 ESDetId nextPoint(0);
0113 if (id == nextPoint)
0114 return nextPoint;
0115
0116 if (ESDetId::validDetId(id.strip(), id.six(), id.siy(), id.plane() + 1, id.zside()))
0117 nextPoint = ESDetId(id.strip(), id.six(), id.siy(), id.plane() + 1, id.zside());
0118
0119 return nextPoint;
0120 }
0121
0122 ESDetId EcalPreshowerTopology::decrementIz(const ESDetId& id) const {
0123 ESDetId nextPoint(0);
0124 if (id == nextPoint)
0125 return nextPoint;
0126
0127 if (ESDetId::validDetId(id.strip(), id.six(), id.siy(), id.plane() - 1, id.zside()))
0128 nextPoint = ESDetId(id.strip(), id.six(), id.siy(), id.plane() - 1, id.zside());
0129
0130 return nextPoint;
0131 }