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