12 #include <klm/eklm/geometry/AlignmentChecker.h>
15 #include <klm/dbobjects/eklm/EKLMAlignment.h>
16 #include <klm/eklm/geometry/Polygon2D.h>
19 #include <framework/gearbox/Unit.h>
20 #include <framework/logging/Logger.h>
25 m_PrintOverlaps(printOverlaps),
29 int iPlane, iSegmentSupport;
37 0, 0, sectorSupportPosition->
getOuterR() -
46 0, 0, sectorSupportPosition->
getInnerR() +
66 int iPlane, iSegmentSupport;
72 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
73 for (iSegmentSupport = 1; iSegmentSupport <= m_GeoDat->getNSegments() + 1;
75 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1] !=
nullptr)
76 delete m_SegmentSupport[iPlane - 1][iSegmentSupport - 1];
78 delete[] m_SegmentSupport[iPlane - 1];
80 delete[] m_SegmentSupport;
87 int iPlane, iSegmentSupport, iSegment, j;
90 HepGeom::Transform3D t;
93 m_GeoDat->getSegmentSupportGeometry();
95 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
96 for (iSegmentSupport = 1; iSegmentSupport <= m_GeoDat->getNSegments() + 1;
99 m_GeoDat->getSegmentSupportPosition(iPlane, iSegmentSupport);
100 lx = 0.5 * (segmentSupportPos->
getLength() -
104 supportRectangle[0].setX(lx);
105 supportRectangle[0].setY(ly);
106 supportRectangle[0].setZ(0);
107 supportRectangle[1].setX(-lx);
108 supportRectangle[1].setY(ly);
109 supportRectangle[1].setZ(0);
110 supportRectangle[2].setX(-lx);
111 supportRectangle[2].setY(-ly);
112 supportRectangle[2].setZ(0);
113 supportRectangle[3].setX(lx);
114 supportRectangle[3].setY(-ly);
115 supportRectangle[3].setZ(0);
116 t = HepGeom::Translate3D(
119 segmentSupportPos->
getX(), segmentSupportPos->
getY(), 0);
121 t = HepGeom::Rotate3D(180. * CLHEP::deg,
122 HepGeom::Vector3D<double>(1., 1., 0.)) * t;
128 for (j = 0; j < 4; j++)
129 supportRectangle[j] = t * supportRectangle[j];
130 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1] !=
nullptr)
131 delete m_SegmentSupport[iPlane - 1][iSegmentSupport - 1];
132 m_SegmentSupport[iPlane - 1][iSegmentSupport - 1] =
136 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
137 for (iSegmentSupport = 1; iSegmentSupport <= m_GeoDat->getNSegments() + 1;
139 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
142 B2ERROR(
"Segment support overlaps with corner 1."
144 <<
LogVar(
"Sector", sector)
145 <<
LogVar(
"Segment support", iSegmentSupport));
148 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
151 B2ERROR(
"Segment support overlaps with outer arc."
153 <<
LogVar(
"Sector", sector)
154 <<
LogVar(
"Segment support", iSegmentSupport));
157 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
160 B2ERROR(
"Segment support overlaps with line 2-3."
162 <<
LogVar(
"Sector", sector)
163 <<
LogVar(
"Segment support", iSegmentSupport));
166 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
169 B2ERROR(
"Segment support overlaps with inner arc."
171 <<
LogVar(
"Sector", sector)
172 <<
LogVar(
"Segment support", iSegmentSupport));
175 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
178 B2ERROR(
"Segment support overlaps with line 4-1."
180 <<
LogVar(
"Sector", sector)
181 <<
LogVar(
"Segment support", iSegmentSupport));
186 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
187 for (iSegment = 1; iSegment <= m_GeoDat->getNSegments(); iSegment++) {
188 if (!checkSegmentAlignment(section, layer, sector, iPlane, iSegment,
189 sectorAlignment, &segmentAlignment,
true))
200 bool calledFromSectorCheck)
const
207 HepGeom::Transform3D t;
209 m_GeoDat->getStripGeometry();
210 if (!calledFromSectorCheck) {
211 if (!checkSectorAlignment(section, layer, sector, sectorAlignment))
214 ly = 0.5 * stripGeometry->
getWidth();
215 for (i = 1; i <= m_ElementNumbers->getNStripsSegment(); i++) {
216 iStrip = m_ElementNumbers->getNStripsSegment() * (segment - 1) + i;
218 m_GeoDat->getStripPosition(iStrip);
220 stripRectangle[0].setX(lx);
221 stripRectangle[0].setY(ly);
222 stripRectangle[0].setZ(0);
223 stripRectangle[1].setX(-lx);
224 stripRectangle[1].setY(ly);
225 stripRectangle[1].setZ(0);
226 stripRectangle[2].setX(-lx);
227 stripRectangle[2].setY(-ly);
228 stripRectangle[2].setZ(0);
229 stripRectangle[3].setX(lx);
230 stripRectangle[3].setY(-ly);
231 stripRectangle[3].setZ(0);
235 HepGeom::Translate3D(stripPosition->
getX(), stripPosition->
getY(), 0) *
239 t = HepGeom::Rotate3D(180. * CLHEP::deg,
240 HepGeom::Vector3D<double>(1., 1., 0.)) * t;
246 for (j = 0; j < 4; j++)
247 stripRectangle[j] = t * stripRectangle[j];
248 Polygon2D stripPolygon(stripRectangle, 4);
251 B2ERROR(
"Strip overlaps with corner 1."
254 <<
LogVar(
"Strip", iStrip));
259 B2ERROR(
"Strip overlaps with outer arc."
262 <<
LogVar(
"Strip", iStrip));
263 B2ERROR(
"Overlap (section " << section <<
", layer " << layer <<
264 ", sector " << sector <<
", plane " << plane <<
265 "): strip " << iStrip <<
", outer arc.");
270 B2ERROR(
"Strip overlaps with line 2-3."
273 <<
LogVar(
"Strip", iStrip));
278 B2ERROR(
"Strip overlaps with inner arc."
281 <<
LogVar(
"Strip", iStrip));
282 B2ERROR(
"Overlap (section " << section <<
", layer " << layer <<
283 ", sector " << sector <<
", plane " << plane <<
284 "): strip " << iStrip <<
", inner arc.");
289 B2ERROR(
"Strip overlaps with line 4-1."
292 <<
LogVar(
"Strip", iStrip));
295 for (j = 0; j <= m_GeoDat->getNSegments(); j++) {
298 B2ERROR(
"Strip overlaps with segment support."
301 <<
LogVar(
"Strip", iStrip)
302 <<
LogVar(
"Segment support", j + 1));
314 int iSection, iLayer, iSector, iPlane, iSegment, sector, segment;
315 for (iSection = 1; iSection <= m_GeoDat->getNSections(); iSection++) {
316 for (iLayer = 1; iLayer <= m_GeoDat->getNDetectorLayers(iSection);
318 for (iSector = 1; iSector <= m_GeoDat->getNSectors(); iSector++) {
319 sector = m_ElementNumbers->sectorNumber(iSection, iLayer, iSector);
321 alignment->getModuleAlignment(sector);
322 if (sectorAlignment ==
nullptr)
323 B2FATAL(
"Incomplete alignment data.");
324 if (!checkSectorAlignment(iSection, iLayer, iSector, sectorAlignment))
326 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
327 for (iSegment = 1; iSegment <= m_GeoDat->getNSegments(); iSegment++) {
328 segment = m_ElementNumbers->segmentNumber(
329 iSection, iLayer, iSector, iPlane, iSegment);
332 if (segmentAlignment ==
nullptr)
333 B2FATAL(
"Incomplete alignment data.");
334 if (!checkSegmentAlignment(iSection, iLayer, iSector, iPlane,
335 iSegment, sectorAlignment,
336 segmentAlignmentData,
false))