10#include <klm/eklm/geometry/AlignmentChecker.h>
13#include <klm/dbobjects/eklm/EKLMAlignment.h>
14#include <klm/eklm/geometry/Polygon2D.h>
17#include <framework/gearbox/Unit.h>
18#include <framework/logging/Logger.h>
23 m_PrintOverlaps(printOverlaps),
27 int iPlane, iSegmentSupport;
35 0, 0, sectorSupportPosition->
getOuterR() -
44 0, 0, sectorSupportPosition->
getInnerR() +
64 int iPlane, iSegmentSupport;
70 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
71 for (iSegmentSupport = 1; iSegmentSupport <= m_GeoDat->getNSegments() + 1;
73 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1] !=
nullptr)
74 delete m_SegmentSupport[iPlane - 1][iSegmentSupport - 1];
76 delete[] m_SegmentSupport[iPlane - 1];
78 delete[] m_SegmentSupport;
85 int iPlane, iSegmentSupport, iSegment, j;
88 HepGeom::Transform3D t;
91 m_GeoDat->getSegmentSupportGeometry();
93 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
94 for (iSegmentSupport = 1; iSegmentSupport <= m_GeoDat->getNSegments() + 1;
97 m_GeoDat->getSegmentSupportPosition(iPlane, iSegmentSupport);
98 lx = 0.5 * (segmentSupportPos->
getLength() -
102 supportRectangle[0].setX(lx);
103 supportRectangle[0].setY(ly);
104 supportRectangle[0].setZ(0);
105 supportRectangle[1].setX(-lx);
106 supportRectangle[1].setY(ly);
107 supportRectangle[1].setZ(0);
108 supportRectangle[2].setX(-lx);
109 supportRectangle[2].setY(-ly);
110 supportRectangle[2].setZ(0);
111 supportRectangle[3].setX(lx);
112 supportRectangle[3].setY(-ly);
113 supportRectangle[3].setZ(0);
114 t = HepGeom::Translate3D(
117 segmentSupportPos->
getX(), segmentSupportPos->
getY(), 0);
119 t = HepGeom::Rotate3D(180. * CLHEP::deg,
120 HepGeom::Vector3D<double>(1., 1., 0.)) * t;
126 for (j = 0; j < 4; j++)
127 supportRectangle[j] = t * supportRectangle[j];
128 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1] !=
nullptr)
129 delete m_SegmentSupport[iPlane - 1][iSegmentSupport - 1];
130 m_SegmentSupport[iPlane - 1][iSegmentSupport - 1] =
134 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
135 for (iSegmentSupport = 1; iSegmentSupport <= m_GeoDat->getNSegments() + 1;
137 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
140 B2ERROR(
"Segment support overlaps with corner 1."
142 <<
LogVar(
"Sector", sector)
143 <<
LogVar(
"Segment support", iSegmentSupport));
146 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
149 B2ERROR(
"Segment support overlaps with outer arc."
151 <<
LogVar(
"Sector", sector)
152 <<
LogVar(
"Segment support", iSegmentSupport));
155 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
158 B2ERROR(
"Segment support overlaps with line 2-3."
160 <<
LogVar(
"Sector", sector)
161 <<
LogVar(
"Segment support", iSegmentSupport));
164 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
167 B2ERROR(
"Segment support overlaps with inner arc."
169 <<
LogVar(
"Sector", sector)
170 <<
LogVar(
"Segment support", iSegmentSupport));
173 if (m_SegmentSupport[iPlane - 1][iSegmentSupport - 1]->hasIntersection(
176 B2ERROR(
"Segment support overlaps with line 4-1."
178 <<
LogVar(
"Sector", sector)
179 <<
LogVar(
"Segment support", iSegmentSupport));
184 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
185 for (iSegment = 1; iSegment <= m_GeoDat->getNSegments(); iSegment++) {
186 if (!checkSegmentAlignment(section, layer, sector, iPlane, iSegment,
187 sectorAlignment, &segmentAlignment,
true))
198 bool calledFromSectorCheck)
const
205 HepGeom::Transform3D t;
207 m_GeoDat->getStripGeometry();
208 if (!calledFromSectorCheck) {
209 if (!checkSectorAlignment(section, layer, sector, sectorAlignment))
212 ly = 0.5 * stripGeometry->
getWidth();
213 for (i = 1; i <= m_ElementNumbers->getNStripsSegment(); i++) {
214 iStrip = m_ElementNumbers->getNStripsSegment() * (segment - 1) + i;
216 m_GeoDat->getStripPosition(iStrip);
218 stripRectangle[0].setX(lx);
219 stripRectangle[0].setY(ly);
220 stripRectangle[0].setZ(0);
221 stripRectangle[1].setX(-lx);
222 stripRectangle[1].setY(ly);
223 stripRectangle[1].setZ(0);
224 stripRectangle[2].setX(-lx);
225 stripRectangle[2].setY(-ly);
226 stripRectangle[2].setZ(0);
227 stripRectangle[3].setX(lx);
228 stripRectangle[3].setY(-ly);
229 stripRectangle[3].setZ(0);
233 HepGeom::Translate3D(stripPosition->
getX(), stripPosition->
getY(), 0) *
237 t = HepGeom::Rotate3D(180. * CLHEP::deg,
238 HepGeom::Vector3D<double>(1., 1., 0.)) * t;
244 for (j = 0; j < 4; j++)
245 stripRectangle[j] = t * stripRectangle[j];
246 Polygon2D stripPolygon(stripRectangle, 4);
249 B2ERROR(
"Strip overlaps with corner 1."
252 <<
LogVar(
"Strip", iStrip));
257 B2ERROR(
"Strip overlaps with outer arc."
260 <<
LogVar(
"Strip", iStrip));
261 B2ERROR(
"Overlap (section " << section <<
", layer " << layer <<
262 ", sector " << sector <<
", plane " << plane <<
263 "): strip " << iStrip <<
", outer arc.");
268 B2ERROR(
"Strip overlaps with line 2-3."
271 <<
LogVar(
"Strip", iStrip));
276 B2ERROR(
"Strip overlaps with inner arc."
279 <<
LogVar(
"Strip", iStrip));
280 B2ERROR(
"Overlap (section " << section <<
", layer " << layer <<
281 ", sector " << sector <<
", plane " << plane <<
282 "): strip " << iStrip <<
", inner arc.");
287 B2ERROR(
"Strip overlaps with line 4-1."
290 <<
LogVar(
"Strip", iStrip));
293 for (j = 0; j <= m_GeoDat->getNSegments(); j++) {
296 B2ERROR(
"Strip overlaps with segment support."
299 <<
LogVar(
"Strip", iStrip)
300 <<
LogVar(
"Segment support", j + 1));
312 int iSection, iLayer, iSector, iPlane, iSegment, sector, segment;
313 for (iSection = 1; iSection <= m_GeoDat->getNSections(); iSection++) {
314 for (iLayer = 1; iLayer <= m_GeoDat->getNDetectorLayers(iSection);
316 for (iSector = 1; iSector <= m_GeoDat->getNSectors(); iSector++) {
317 sector = m_ElementNumbers->sectorNumber(iSection, iLayer, iSector);
319 alignment->getModuleAlignment(sector);
320 if (sectorAlignment ==
nullptr)
321 B2FATAL(
"Incomplete alignment data.");
322 if (!checkSectorAlignment(iSection, iLayer, iSector, sectorAlignment))
324 for (iPlane = 1; iPlane <= m_GeoDat->getNPlanes(); iPlane++) {
325 for (iSegment = 1; iSegment <= m_GeoDat->getNSegments(); iSegment++) {
326 segment = m_ElementNumbers->segmentNumber(
327 iSection, iLayer, iSector, iPlane, iSegment);
330 if (segmentAlignment ==
nullptr)
331 B2FATAL(
"Incomplete alignment data.");
332 if (!checkSegmentAlignment(iSection, iLayer, iSector, iPlane,
333 iSegment, sectorAlignment,
334 segmentAlignmentData,
false))
Class to store EKLM alignment data in the database.
Position information for the elements of detector.
double getX() const
Get X coordinate.
double getOuterR() const
Get outer radius.
double getInnerR() const
Get inner radius.
double getY() const
Get Y coordinate.
double getLength() const
Get length.
Sector support geometry data.
const HepGeom::Point3D< double > & getCorner3Inner() const
Get corner 3 coordinates (inner side).
const HepGeom::Point3D< double > & getCorner4Inner() const
Get corner 4 coordinates (inner side).
double getThickness() const
Get thickness.
const HepGeom::Point3D< double > & getCorner1BInner() const
Get corner 1B coordinates (inner side).
const HepGeom::Point3D< double > & getCorner1AInner() const
Get corner 1A coordinates (inner side).
const HepGeom::Point3D< double > & getCorner2Inner() const
Get corner 2 coordinates (inner side).
Segment support geometry data.
double getMiddleWidth() const
Get middle part width.
Segment support position.
double getX() const
Get X coordinate.
double getY() const
Get Y coordinate.
double getDeltaLRight() const
Get right Delta L.
double getDeltaLLeft() const
Get left Delta L.
double getLength() const
Get length.
double getWidth() const
Get width.
int getNPlanes() const
Get number of planes.
const SectorSupportGeometry * getSectorSupportGeometry() const
Get sector support geometry data.
int getNSegments() const
Get number of segments.
const ElementPosition * getSectorSupportPosition() const
Get position data for sector support structure.
Class to store EKLM alignment data in the database.
const KLMAlignmentData * getSegmentAlignment(EKLMSegmentNumber segment) const
Get segment alignment data.
bool checkAlignment(const EKLMAlignment *alignment, const EKLMSegmentAlignment *segmentAlignment) const
Check alignment.
LineSegment2D * m_Line23
Sector support edge: line between corners 2 and 3.
bool checkSectorAlignment(int section, int layer, int sector, const KLMAlignmentData *sectorAlignment) const
Check sector alignment.
Arc2D * m_ArcOuter
Sector support edge: outer arc.
bool checkSegmentAlignment(int section, int layer, int sector, int plane, int segment, const KLMAlignmentData *sectorAlignment, const KLMAlignmentData *segmentAlignment, bool calledFromSectorCheck) const
Check segment alignment.
LineSegment2D * m_Line41
Sector support edge: line between corners 4 and 1.
~AlignmentChecker()
Destructor.
AlignmentChecker(bool printOverlaps)
Constructor.
Polygon2D *** m_SegmentSupport
Segment support.
LineSegment2D * m_LineCorner1
Sector support edge: corner 1 line.
Arc2D * m_ArcInner
Sector support edge: inner arc.
const GeometryData * m_GeoDat
Geometry data.
bool hasIntersection(const LineSegment2D &lineSegment) const
Check whether polygon has an intersection with a line segment or this line segment is fully inside th...
float getDeltaU() const
Get shift in U.
float getDeltaV() const
Get shift in V.
float getDeltaGamma() const
Get rotation in alpha.
static const double rad
Standard of [angle].
static const double cm
Standard units with the value = 1.
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.