CMS 3D CMS Logo

HGCalGeomRotation.cc
Go to the documentation of this file.
4 
6  int& moduleU,
7  int& moduleV,
8  unsigned sector) const {
9  if (sector == 0) {
10  return;
11  }
12 
14  uvMappingFrom60DegreeSector0(waferCentring, moduleU, moduleV, sector);
16  uvMappingFrom120DegreeSector0(waferCentring, moduleU, moduleV, sector);
17  }
18 }
19 
20 unsigned HGCalGeomRotation::uvMappingToSector0(WaferCentring waferCentring, int& moduleU, int& moduleV) const {
21  unsigned sector = 0;
22 
24  sector = uvMappingTo60DegreeSector0(waferCentring, moduleU, moduleV);
26  sector = uvMappingTo120DegreeSector0(waferCentring, moduleU, moduleV);
27  }
28 
29  return sector;
30 }
31 
33  int& moduleU,
34  int& moduleV,
35  unsigned sector) const {
36  if (waferCentring != WaferCentring::WaferCentred) {
37  edm::LogError("HGCalGeomRotation")
38  << "HGCalGeomRotation: 60 degree sector defintion selected, but not WaferCentred centring. This is "
39  "incompatible, assuming WaferCentred centring";
40  }
41 
42  if (sector > 5) {
43  throw cms::Exception("RotationException") << "HGCalGeomRotation: desired sector must be either 0, 1, 2, 3, 4, or 5";
44  }
45  for (unsigned rot = 0; rot < sector; rot++) {
46  RotateModule60DegreesAnticlockwise(moduleU, moduleV);
47  }
48 }
49 
51  int& moduleU,
52  int& moduleV,
53  unsigned sector) const {
54  int offset;
55 
56  if (waferCentring == WaferCentring::WaferCentred) {
57  offset = 0;
58  } else if (waferCentring == WaferCentring::CornerCentredY) {
59  offset = -1;
60  } else if (waferCentring == WaferCentring::CornerCentredMercedes) {
61  offset = 1;
62  } else {
63  throw cms::Exception("RotationException")
64  << "HGCalGeomRotation: WaferCentring must be one of: WaferCentred, CornerCentredY or CornerCentredMercedes";
65  }
66 
67  if (sector > 2) {
68  edm::LogError("RotationException") << "HGCalGeomRotation: desired sector must be either 0, 1 or 2";
69  return;
70  }
71  for (unsigned rot = 0; rot < sector; rot++) {
73  }
74 }
75 
76 unsigned HGCalGeomRotation::uvMappingTo120DegreeSector0(WaferCentring waferCentring, int& moduleU, int& moduleV) const {
77  unsigned sector = 0;
78  int offset;
79 
80  if (waferCentring == WaferCentring::WaferCentred) {
81  if (moduleU > 0 && moduleV >= 0)
82  return sector;
83 
84  offset = 0;
85  if (moduleU >= moduleV && moduleV < 0)
86  sector = 2;
87  else
88  sector = 1;
89 
90  } else if (waferCentring == WaferCentring::CornerCentredY) {
91  if (moduleU >= 0 && moduleV >= 0)
92  return sector;
93 
94  offset = -1;
95  if (moduleU > moduleV && moduleV < 0)
96  sector = 2;
97  else
98  sector = 1;
99 
100  } else if (waferCentring == WaferCentring::CornerCentredMercedes) {
101  if (moduleU >= 1 && moduleV >= 1)
102  return sector;
103 
104  offset = 1;
105  if (moduleU >= moduleV && moduleV < 1)
106  sector = 2;
107  else
108  sector = 1;
109  } else {
110  throw cms::Exception("RotationException")
111  << "HGCalGeomRotation: WaferCentring must be one of: WaferCentred, CornerCentredY or CornerCentredMercedes";
112  }
113 
114  for (unsigned rot = 0; rot < sector; rot++) {
115  RotateModule120DegreesClockwise(moduleU, moduleV, offset);
116  }
117 
118  return sector;
119 }
120 
121 unsigned HGCalGeomRotation::uvMappingTo60DegreeSector0(WaferCentring waferCentring, int& moduleU, int& moduleV) const {
122  unsigned sector = 0;
123 
124  if (waferCentring != WaferCentring::WaferCentred) {
125  edm::LogError("HGCalGeomRotation")
126  << "HGCalGeomRotation: 60 degree sector defintion selected, but not WaferCentred centring. This is "
127  "incompatible, assuming WaferCentred centring";
128  }
129 
130  if (moduleU > 0 && moduleV >= 0) {
131  if (moduleV <= moduleU) {
132  return sector;
133  } else {
134  sector = 1;
135  }
136  } else if (moduleU >= moduleV && moduleV < 0) {
137  if (moduleU >= 0) {
138  sector = 5;
139  } else {
140  sector = 4;
141  }
142  } else {
143  if (moduleV > 0) {
144  sector = 2;
145  } else {
146  sector = 3;
147  }
148  }
149 
150  for (unsigned rot = 0; rot < sector; rot++) {
151  RotateModule60DegreesClockwise(moduleU, moduleV);
152  }
153 
154  return sector;
155 }
156 
157 void HGCalGeomRotation::RotateModule60DegreesAnticlockwise(int& moduleU, int& moduleV) const {
158  int moduleURotated, moduleVRotated;
159  moduleURotated = moduleU - moduleV;
160  moduleVRotated = moduleU;
161 
162  moduleU = moduleURotated;
163  moduleV = moduleVRotated;
164 }
165 
166 void HGCalGeomRotation::RotateModule60DegreesClockwise(int& moduleU, int& moduleV) const {
167  int moduleURotated, moduleVRotated;
168  moduleURotated = moduleV;
169  moduleVRotated = moduleV - moduleU;
170 
171  moduleU = moduleURotated;
172  moduleV = moduleVRotated;
173 }
174 
175 void HGCalGeomRotation::RotateModule120DegreesAnticlockwise(int& moduleU, int& moduleV, int offset) const {
176  int moduleURotated, moduleVRotated;
177 
178  moduleURotated = -moduleV + offset;
179  moduleVRotated = moduleU - moduleV + offset;
180 
181  moduleU = moduleURotated;
182  moduleV = moduleVRotated;
183 }
184 
185 void HGCalGeomRotation::RotateModule120DegreesClockwise(int& moduleU, int& moduleV, int offset) const {
186  int moduleURotated, moduleVRotated;
187 
188  moduleURotated = moduleV - moduleU;
189  moduleVRotated = -moduleU + offset;
190 
191  moduleU = moduleURotated;
192  moduleV = moduleVRotated;
193 }
void RotateModule60DegreesClockwise(int &moduleU, int &moduleV) const
void RotateModule120DegreesClockwise(int &moduleU, int &moduleV, int offset) const
void uvMappingFromSector0(WaferCentring waferCentring, int &moduleU, int &moduleV, unsigned sector) const
unsigned uvMappingTo60DegreeSector0(WaferCentring waferCentring, int &moduleU, int &moduleV) const
Log< level::Error, false > LogError
void RotateModule60DegreesAnticlockwise(int &moduleU, int &moduleV) const
void uvMappingFrom120DegreeSector0(WaferCentring waferCentring, int &moduleU, int &moduleV, unsigned sector) const
void uvMappingFrom60DegreeSector0(WaferCentring waferCentring, int &moduleU, int &moduleV, unsigned sector) const
unsigned uvMappingTo120DegreeSector0(WaferCentring waferCentring, int &moduleU, int &moduleV) const
void RotateModule120DegreesAnticlockwise(int &moduleU, int &moduleV, int offset) const
unsigned uvMappingToSector0(WaferCentring waferCentring, int &moduleU, int &moduleV) const