Belle II Software development
TransformData.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/* Own header. */
10#include <klm/eklm/geometry/TransformData.h>
11
12/* KLM headers. */
13#include <klm/dbobjects/eklm/EKLMAlignment.h>
14#include <klm/dbobjects/eklm/EKLMSegmentAlignment.h>
15#include <klm/eklm/geometry/AlignmentChecker.h>
16#include <klm/eklm/geometry/GeometryData.h>
17
18/* Basf2 headers. */
19#include <framework/database/DBObjPtr.h>
20#include <framework/logging/Logger.h>
21#include <framework/gearbox/Unit.h>
22
23using namespace Belle2;
24
26{
27 /* cppcheck-suppress variableScope */
28 int iSection, iLayer, iSector, iPlane, iSegment, iStrip, sector, segment;
29 int nSections, nLayers, nSectors, nPlanes, nStrips, nSegments, nStripsSegment;
30 int nDetectorLayers;
31 AlignmentChecker alignmentChecker(true);
34 nSections = m_GeoDat->getNSections();
35 nSectors = m_GeoDat->getNSectors();
36 nLayers = m_GeoDat->getNLayers();
37 nPlanes = m_GeoDat->getNPlanes();
38 nStrips = m_GeoDat->getNStrips();
39 nSegments = m_GeoDat->getNSegments();
40 nStripsSegment = m_ElementNumbers->getNStripsSegment();
41 m_Section = new HepGeom::Transform3D[nSections];
42 m_Layer = new HepGeom::Transform3D*[nSections];
43 m_Sector = new HepGeom::Transform3D** [nSections];
44 m_Plane = new HepGeom::Transform3D** *[nSections];
45 m_PlaneDisplacement = new HepGeom::Transform3D** *[nSections];
46 m_Segment = new HepGeom::Transform3D**** [nSections];
47 m_Strip = new HepGeom::Transform3D**** [nSections];
48 m_StripInverse = new HepGeom::Transform3D**** [nSections];
49 for (iSection = 0; iSection < nSections; iSection++) {
50 m_GeoDat->getSectionTransform(&m_Section[iSection], iSection);
51 nDetectorLayers = m_GeoDat->getNDetectorLayers(iSection + 1);
52 m_Layer[iSection] = new HepGeom::Transform3D[nLayers];
53 m_Sector[iSection] = new HepGeom::Transform3D*[nLayers];
54 m_Plane[iSection] = new HepGeom::Transform3D** [nLayers];
55 m_PlaneDisplacement[iSection] = new HepGeom::Transform3D** [nLayers];
56 m_Segment[iSection] = new HepGeom::Transform3D** *[nLayers];
57 m_Strip[iSection] = new HepGeom::Transform3D** *[nLayers];
58 m_StripInverse[iSection] = new HepGeom::Transform3D** *[nLayers];
59 for (iLayer = 0; iLayer < nLayers; iLayer++) {
60 m_GeoDat->getLayerTransform(&m_Layer[iSection][iLayer], iLayer);
61 m_Sector[iSection][iLayer] = new HepGeom::Transform3D[nSectors];
62 if (iLayer < nDetectorLayers) {
63 m_Plane[iSection][iLayer] = new HepGeom::Transform3D*[nSectors];
64 m_PlaneDisplacement[iSection][iLayer] =
65 new HepGeom::Transform3D*[nSectors];
66 m_Segment[iSection][iLayer] = new HepGeom::Transform3D** [nSectors];
67 m_Strip[iSection][iLayer] = new HepGeom::Transform3D** [nSectors];
68 m_StripInverse[iSection][iLayer] = new HepGeom::Transform3D** [nSectors];
69 }
70 for (iSector = 0; iSector < nSectors; iSector++) {
71 m_GeoDat->getSectorTransform(&m_Sector[iSection][iLayer][iSector],
72 iSector);
73 if (iLayer >= nDetectorLayers)
74 continue;
75 m_Plane[iSection][iLayer][iSector] = new HepGeom::Transform3D[nPlanes];
76 m_PlaneDisplacement[iSection][iLayer][iSector] =
77 new HepGeom::Transform3D[nPlanes];
78 m_Segment[iSection][iLayer][iSector] =
79 new HepGeom::Transform3D*[nPlanes];
80 m_Strip[iSection][iLayer][iSector] = new HepGeom::Transform3D*[nPlanes];
81 m_StripInverse[iSection][iLayer][iSector] =
82 new HepGeom::Transform3D*[nPlanes];
83 for (iPlane = 0; iPlane < nPlanes; iPlane++) {
84 m_GeoDat->getPlaneTransform(
85 &m_Plane[iSection][iLayer][iSector][iPlane], iPlane);
86 m_PlaneDisplacement[iSection][iLayer][iSector][iPlane] =
87 HepGeom::Translate3D(0, 0, 0);
88 m_Segment[iSection][iLayer][iSector][iPlane] =
89 new HepGeom::Transform3D[nSegments];
90 for (iSegment = 0; iSegment < nSegments; iSegment++) {
91 m_Segment[iSection][iLayer][iSector][iPlane][iSegment] =
92 HepGeom::Translate3D(0, 0, 0);
93 }
94 m_Strip[iSection][iLayer][iSector][iPlane] =
95 new HepGeom::Transform3D[nStrips];
96 m_StripInverse[iSection][iLayer][iSector][iPlane] =
97 new HepGeom::Transform3D[nStrips];
98 for (iStrip = 0; iStrip < nStrips; iStrip++) {
99 m_GeoDat->getStripTransform(
100 &m_Strip[iSection][iLayer][iSector][iPlane][iStrip], iStrip);
101 }
102 }
103 }
104 }
105 }
106 /* Read alignment data from the database and modify transformations. */
107 if (displacementType != c_None) {
108 std::string payload, segmentPayload;
109 if (displacementType == c_Displacement) {
110 payload = "EKLMDisplacement";
111 segmentPayload = "EKLMSegmentDisplacement";
112 } else {
113 payload = "EKLMAlignment";
114 segmentPayload = "EKLMSegmentAlignment";
115 }
116 DBObjPtr<EKLMAlignment> alignment(payload);
117 DBObjPtr<EKLMSegmentAlignment> segmentAlignment(segmentPayload);
118 if (!alignment.isValid())
119 B2FATAL("No EKLM displacement (alignment) data.");
120 if (displacementType == c_Displacement) {
121 if (!alignmentChecker.checkAlignment(&(*alignment), &(*segmentAlignment)))
122 B2FATAL("EKLM displacement data are incorrect, overlaps exist.");
123 }
124 for (iSection = 1; iSection <= nSections; iSection++) {
125 nDetectorLayers = m_GeoDat->getNDetectorLayers(iSection);
126 assert(nDetectorLayers <= nLayers);
127 for (iLayer = 1; iLayer <= nDetectorLayers; iLayer++) {
128 for (iSector = 1; iSector <= nSectors; iSector++) {
129 sector = m_ElementNumbers->sectorNumber(iSection, iLayer, iSector);
130 const KLMAlignmentData* sectorAlignment =
131 alignment->getModuleAlignment(sector);
132 if (sectorAlignment == nullptr)
133 B2FATAL("Incomplete EKLM displacement (alignment) data.");
134 for (iPlane = 1; iPlane <= nPlanes; iPlane++) {
135 /* First plane is rotated. */
136 if (iPlane == 1) {
137 [[clang::suppress]]
138 m_PlaneDisplacement[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1] =
139 HepGeom::Translate3D(
140 sectorAlignment->getDeltaV() * CLHEP::cm / Unit::cm,
141 sectorAlignment->getDeltaU() * CLHEP::cm / Unit::cm, 0) *
142 HepGeom::RotateZ3D(-sectorAlignment->getDeltaGamma() *
143 CLHEP::rad / Unit::rad);
144 } else {
145 m_PlaneDisplacement[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1] =
146 HepGeom::Translate3D(
147 sectorAlignment->getDeltaU() * CLHEP::cm / Unit::cm,
148 sectorAlignment->getDeltaV() * CLHEP::cm / Unit::cm, 0) *
149 HepGeom::RotateZ3D(sectorAlignment->getDeltaGamma() *
150 CLHEP::rad / Unit::rad);
151 }
152 for (iSegment = 1; iSegment <= nSegments; iSegment++) {
153 segment = m_ElementNumbers->segmentNumber(
154 iSection, iLayer, iSector, iPlane, iSegment);
155 const KLMAlignmentData* segmentAlignmentData =
156 segmentAlignment->getSegmentAlignment(segment);
157 if (segmentAlignmentData == nullptr)
158 B2FATAL("Incomplete EKLM displacement (alignment) data.");
159 m_Segment[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
160 [iSegment - 1] =
161 HepGeom::Translate3D(
162 segmentAlignmentData->getDeltaU() * CLHEP::cm / Unit::cm,
163 segmentAlignmentData->getDeltaV() * CLHEP::cm / Unit::cm, 0) *
164 m_Segment[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
165 [iSegment - 1] *
166 HepGeom::RotateZ3D(segmentAlignmentData->getDeltaGamma() *
167 CLHEP::rad / Unit::rad);
168 for (iStrip = 1; iStrip <= nStripsSegment; iStrip++) {
169 m_Strip[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
170 [nStripsSegment * (iSegment - 1) + iStrip - 1] =
171 HepGeom::Translate3D(
172 segmentAlignmentData->getDeltaU() * CLHEP::cm / Unit::cm,
173 segmentAlignmentData->getDeltaV() * CLHEP::cm / Unit::cm,
174 0) *
175 m_Strip[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
176 [nStripsSegment * (iSegment - 1) + iStrip - 1] *
177 HepGeom::RotateZ3D(segmentAlignmentData->getDeltaGamma() *
178 CLHEP::rad / Unit::rad);
179 }
180 }
181 }
182 }
183 }
184 }
185 }
186 if (global)
188}
189
191{
192 int iSection, iLayer, iSector, iPlane;
193 /* cppcheck-suppress variableScope */
194 int nSections, nLayers, nDetectorLayers, nSectors, nPlanes;
195 nSections = m_GeoDat->getNSections();
196 nLayers = m_GeoDat->getNLayers();
197 nSectors = m_GeoDat->getNSectors();
198 nPlanes = m_GeoDat->getNPlanes();
199 for (iSection = 0; iSection < nSections; iSection++) {
200 nDetectorLayers = m_GeoDat->getNDetectorLayers(iSection + 1);
201 for (iLayer = 0; iLayer < nLayers; iLayer++) {
202 delete[] m_Sector[iSection][iLayer];
203 if (iLayer >= nDetectorLayers)
204 continue;
205 for (iSector = 0; iSector < nSectors; iSector++) {
206 for (iPlane = 0; iPlane < nPlanes; iPlane++) {
207 delete[] m_Segment[iSection][iLayer][iSector][iPlane];
208 delete[] m_Strip[iSection][iLayer][iSector][iPlane];
209 delete[] m_StripInverse[iSection][iLayer][iSector][iPlane];
210 }
211 delete[] m_Plane[iSection][iLayer][iSector];
212 delete[] m_PlaneDisplacement[iSection][iLayer][iSector];
213 delete[] m_Segment[iSection][iLayer][iSector];
214 delete[] m_Strip[iSection][iLayer][iSector];
215 delete[] m_StripInverse[iSection][iLayer][iSector];
216 }
217 delete[] m_Plane[iSection][iLayer];
218 delete[] m_PlaneDisplacement[iSection][iLayer];
219 delete[] m_Segment[iSection][iLayer];
220 delete[] m_Strip[iSection][iLayer];
221 delete[] m_StripInverse[iSection][iLayer];
222 }
223 delete[] m_Layer[iSection];
224 delete[] m_Sector[iSection];
225 delete[] m_PlaneDisplacement[iSection];
226 delete[] m_Plane[iSection];
227 delete[] m_Segment[iSection];
228 delete[] m_Strip[iSection];
229 delete[] m_StripInverse[iSection];
230 }
231 delete[] m_Section;
232 delete[] m_Layer;
233 delete[] m_Sector;
234 delete[] m_PlaneDisplacement;
235 delete[] m_Plane;
236 delete[] m_Segment;
237 delete[] m_Strip;
238 delete[] m_StripInverse;
239}
240
242{
243 int iSection, iLayer, iSector, iPlane, iSegment, iStrip;
244 /* cppcheck-suppress variableScope */
245 int nSections, nLayers, nDetectorLayers, nSectors, nPlanes, nSegments, nStrips;
246 nSections = m_GeoDat->getNSections();
247 nLayers = m_GeoDat->getNLayers();
248 nSectors = m_GeoDat->getNSectors();
249 nPlanes = m_GeoDat->getNPlanes();
250 nSegments = m_GeoDat->getNSegments();
251 nStrips = m_GeoDat->getNStrips();
252 for (iSection = 0; iSection < nSections; iSection++) {
253 nDetectorLayers = m_GeoDat->getNDetectorLayers(iSection + 1);
254 for (iLayer = 0; iLayer < nLayers; iLayer++) {
255 m_Layer[iSection][iLayer] = m_Section[iSection] * m_Layer[iSection][iLayer];
256 for (iSector = 0; iSector < nSectors; iSector++) {
257 m_Sector[iSection][iLayer][iSector] =
258 m_Layer[iSection][iLayer] * m_Sector[iSection][iLayer][iSector];
259 if (iLayer >= nDetectorLayers)
260 continue;
261 for (iPlane = 0; iPlane < nPlanes; iPlane++) {
262 [[clang::suppress]]
263 m_Plane[iSection][iLayer][iSector][iPlane] =
264 m_Sector[iSection][iLayer][iSector] *
265 m_Plane[iSection][iLayer][iSector][iPlane];
266 for (iSegment = 0; iSegment < nSegments; iSegment++) {
267 m_Segment[iSection][iLayer][iSector][iPlane][iSegment] =
268 m_Plane[iSection][iLayer][iSector][iPlane] *
269 m_PlaneDisplacement[iSection][iLayer][iSector][iPlane] *
270 m_Segment[iSection][iLayer][iSector][iPlane][iSegment];
271 }
272 for (iStrip = 0; iStrip < nStrips; iStrip++) {
273 m_Strip[iSection][iLayer][iSector][iPlane][iStrip] =
274 m_Plane[iSection][iLayer][iSector][iPlane] *
275 m_PlaneDisplacement[iSection][iLayer][iSector][iPlane] *
276 m_Strip[iSection][iLayer][iSector][iPlane][iStrip];
277 m_StripInverse[iSection][iLayer][iSector][iPlane][iStrip] =
278 m_Strip[iSection][iLayer][iSector][iPlane][iStrip].inverse();
279 }
280 }
281 }
282 }
283 }
284}
285
286const HepGeom::Transform3D*
288{
289 return &m_Section[section - 1];
290}
291
292const HepGeom::Transform3D*
293EKLM::TransformData::getLayerTransform(int section, int layer) const
294{
295 return &m_Layer[section - 1][layer - 1];
296}
297
298const HepGeom::Transform3D* EKLM::TransformData::
299getSectorTransform(int section, int layer, int sector) const
300{
301 return &m_Sector[section - 1][layer - 1][sector - 1];
302}
303
304const HepGeom::Transform3D* EKLM::TransformData::
305getPlaneTransform(int section, int layer, int sector, int plane) const
306{
307 return &m_Plane[section - 1][layer - 1][sector - 1][plane - 1];
308}
309
310const HepGeom::Transform3D* EKLM::TransformData::
311getPlaneDisplacement(int section, int layer, int sector, int plane) const
312{
313 return &m_PlaneDisplacement[section - 1][layer - 1][sector - 1][plane - 1];
314}
315
316const HepGeom::Transform3D* EKLM::TransformData::
317getSegmentTransform(int section, int layer, int sector, int plane,
318 int segment) const
319{
320 return &m_Segment[section - 1][layer - 1][sector - 1][plane - 1][segment - 1];
321}
322
323const HepGeom::Transform3D* EKLM::TransformData::
324getStripTransform(int section, int layer, int sector, int plane, int strip) const
325{
326 return &m_Strip[section - 1][layer - 1][sector - 1][plane - 1][strip - 1];
327}
328
329const HepGeom::Transform3D*
331{
332 return &(m_Strip[hit->getSection() - 1][hit->getLayer() - 1]
333 [hit->getSector() - 1][hit->getPlane() - 1][hit->getStrip() - 1]);
334}
335
336const HepGeom::Transform3D*
338{
339 return &(m_StripInverse[hit->getSection() - 1][hit->getLayer() - 1]
340 [hit->getSector() - 1][hit->getPlane() - 1][hit->getStrip() - 1]);
341}
342
343const HepGeom::Transform3D*
344EKLM::TransformData::getStripGlobalToLocal(int section, int layer, int sector,
345 int plane, int strip) const
346{
347 return &(m_StripInverse[section - 1][layer - 1][sector - 1][plane - 1]
348 [strip - 1]);
349}
350
353 double* d1, double* d2, double* sd,
354 bool segments) const
355{
356 /* Hits must be from the same sector, */
357 if (hit1->getSection() != hit2->getSection())
358 return false;
359 if (hit1->getLayer() != hit2->getLayer())
360 return false;
361 if (hit1->getSector() != hit2->getSector())
362 return false;
363 /* but different planes. */
364 if (hit1->getPlane() == hit2->getPlane())
365 return false;
366 /* Coordinates of strip 1 ends. */
367 double l1 = m_GeoDat->getStripLength(hit1->getStrip());
368 HepGeom::Point3D<double> s1_1(-0.5 * l1, 0.0, 0.0);
369 HepGeom::Point3D<double> s1_2(0.5 * l1, 0.0, 0.0);
370 const HepGeom::Transform3D* tr1 = getStripLocalToGlobal(hit1);
371 HepGeom::Point3D<double> s1_1g = (*tr1) * s1_1;
372 HepGeom::Point3D<double> s1_2g = (*tr1) * s1_2;
373 /* Coordinates of strip 2 ends. */
374 double l2 = m_GeoDat->getStripLength(hit2->getStrip());
375 HepGeom::Point3D<double> s2_1(-0.5 * l2, 0.0, 0.0);
376 HepGeom::Point3D<double> s2_2(0.5 * l2, 0.0, 0.0);
377 const HepGeom::Transform3D* tr2 = getStripLocalToGlobal(hit2);
378 HepGeom::Point3D<double> s2_1g = (*tr2) * s2_1;
379 HepGeom::Point3D<double> s2_2g = (*tr2) * s2_2;
389 HepGeom::Vector3D<double> v1 = s1_2g - s1_1g;
390 HepGeom::Vector3D<double> v2 = s2_2g - s2_1g;
391 HepGeom::Vector3D<double> d = s1_1g - s2_1g;
392 double v1sq = v1.mag2();
393 double v2sq = v2.mag2();
394 double v1dv2 = v1.dot(v2);
395 double ddv1 = d.dot(v1);
396 double ddv2 = d.dot(v2);
397 double den = v1sq * v2sq - v1dv2 * v1dv2;
398 double t1 = (v1dv2 * ddv2 - v2sq * ddv1) / den;
399 double t2 = (- v1dv2 * ddv1 + v1sq * ddv2) / den;
400 /* Segments do not intersect. */
401 if (segments) {
402 if (t1 < 0.0 || t1 > 1.0)
403 return false;
404 if (t2 < 0.0 || t2 > 1.0)
405 return false;
406 }
407 /* Segments intersect, set return values. */
408 HepGeom::Point3D<double> s1_cg = s1_1g + v1 * t1;
409 HepGeom::Point3D<double> s2_cg = s2_1g + v2 * t2;
410 *d1 = s1_2g.distance(s1_cg) / CLHEP::mm * Unit::mm;
411 *d2 = s2_2g.distance(s2_cg) / CLHEP::mm * Unit::mm;
412 *cross = 0.5 * (s1_cg + s2_cg) / CLHEP::mm * Unit::mm;
413 *sd = s1_cg.distance(s2_cg) / CLHEP::mm * Unit::mm;
414 if (s2_cg.mag2() < s1_cg.mag2())
415 *sd = - *sd;
416 return true;
417}
418
420 int section, const HepGeom::Point3D<double>& position) const
421{
422 int sector;
423 double x;
424 if (section == 1) {
425 x = position.x();
426 } else {
427 x = -position.x();
428 }
429 if (position.y() > 0) {
430 if (x > 0)
431 sector = 1;
432 else
433 sector = 2;
434 } else {
435 if (x > 0)
436 sector = 4;
437 else
438 sector = 3;
439 }
440 return sector;
441}
442
444 const HepGeom::Point3D<double>& intersection, int* strip1, int* strip2) const
445{
446 /* cppcheck-suppress variableScope */
447 int section, layer, sector, plane, segment, strip, stripSegment, stripGlobal;
448 /* cppcheck-suppress variableScope */
449 int nLayers, nPlanes, nSegments, nStripsSegment, minDistanceSegment;
450 double solenoidCenter, firstLayerCenter, layerShift;
451 /* cppcheck-suppress variableScope */
452 double x, y, z, l, minY, maxY;
453 double minDistance = 0, minDistanceNew, stripWidth;
454 HepGeom::Point3D<double> intersectionClhep, intersectionLocal;
455 intersectionClhep = intersection * CLHEP::cm / Unit::cm;
456 solenoidCenter = m_GeoDat->getSolenoidZ() / CLHEP::cm * Unit::cm;
457 if (intersection.z() < solenoidCenter)
458 section = 1;
459 else
460 section = 2;
461 firstLayerCenter =
462 (m_GeoDat->getSectionPosition()->getZ()
463 - 0.5 * m_GeoDat->getSectionPosition()->getLength()
464 + m_GeoDat->getLayerShiftZ()
465 - 0.5 * m_GeoDat->getLayerPosition()->getLength()) /
466 CLHEP::cm * Unit::cm;
467 layerShift = m_GeoDat->getLayerShiftZ() / CLHEP::cm * Unit::cm;
468 z = fabs(intersection.z() - solenoidCenter);
469 layer = round((z - firstLayerCenter) / layerShift) + 1;
470 if (layer <= 0)
471 layer = 1;
472 nLayers = m_GeoDat->getNDetectorLayers(section);
473 if (layer > nLayers)
474 layer = nLayers;
475 sector = getSectorByPosition(section, intersection);
476 nPlanes = m_GeoDat->getNPlanes();
477 nSegments = m_GeoDat->getNSegments();
478 nStripsSegment = m_ElementNumbers->getNStripsSegment();
479 stripWidth = m_GeoDat->getStripGeometry()->getWidth() / CLHEP::cm * Unit::cm;
480 minY = -stripWidth / 2;
481 maxY = (double(nStripsSegment) - 0.5) * stripWidth;
482 for (plane = 1; plane <= nPlanes; plane++) {
483 minDistanceSegment = 1;
484 for (segment = 1; segment <= nSegments; segment++) {
485 strip = (segment - 1) * nStripsSegment;
486 intersectionLocal = m_StripInverse[section - 1][layer - 1]
487 [sector - 1][plane - 1][strip] * intersectionClhep;
488 y = intersectionLocal.y() / CLHEP::cm * Unit::cm;
489 if (y < minY) {
490 minDistanceNew = minY - y;
491 } else if (y > maxY) {
492 minDistanceNew = y - maxY;
493 } else {
494 minDistance = 0;
495 minDistanceSegment = segment;
496 break;
497 }
498 if (segment == 1) {
499 minDistance = minDistanceNew;
500 } else if (minDistanceNew < minDistance) {
501 minDistance = minDistanceNew;
502 minDistanceSegment = segment;
503 }
504 }
505 /*
506 * The intersection is required to be strictly within a segment,
507 * this condition might be adjusted later.
508 */
509 if (minDistance > 0)
510 return -1;
511 strip = (minDistanceSegment - 1) * nStripsSegment;
512 intersectionLocal = m_StripInverse[section - 1][layer - 1]
513 [sector - 1][plane - 1][strip] * intersectionClhep;
514 y = intersectionLocal.y() / CLHEP::cm * Unit::cm;
515 stripSegment = ceil((y - 0.5 * stripWidth) / stripWidth);
516 if (stripSegment <= 0)
517 stripSegment = 1;
518 else if (stripSegment > nStripsSegment)
519 stripSegment = nStripsSegment;
520 strip = stripSegment + (minDistanceSegment - 1) * nStripsSegment;
521 intersectionLocal = m_StripInverse[section - 1][layer - 1]
522 [sector - 1][plane - 1][strip - 1] * intersectionClhep;
523 x = intersectionLocal.x();
524 l = m_GeoDat->getStripLength(strip);
525 /*
526 * The intersection is required to be strictly within the strip length,
527 * this condition might be adjusted later.
528 */
529 if (fabs(x) > 0.5 * l)
530 return -1;
531 stripGlobal = m_ElementNumbers->stripNumber(
532 section, layer, sector, plane, strip);
533 if (plane == 1)
534 *strip1 = stripGlobal;
535 else
536 *strip2 = stripGlobal;
537 }
538 return 0;
539}
Class for accessing objects in the database.
Definition DBObjPtr.h:21
static const EKLMElementNumbers & Instance()
Instantiation.
Class for EKLM alignment checking.
bool checkAlignment(const EKLMAlignment *alignment, const EKLMSegmentAlignment *segmentAlignment) const
Check alignment.
static const GeometryData & Instance(enum DataSource dataSource=c_Database, const GearDir *gearDir=nullptr)
Instantiation.
const HepGeom::Transform3D * getStripTransform(int section, int layer, int sector, int plane, int strip) const
Get strip transformation.
Displacement
Source of displacement (alignment) data.
@ c_None
Displacement is not used.
@ c_Displacement
Use displacement data (for geometry).
TransformData(bool global, Displacement displacementType)
Constructor.
HepGeom::Transform3D * m_Section
Section transformations.
const HepGeom::Transform3D * getPlaneDisplacement(int section, int layer, int sector, int plane) const
Get additional displacement for plane internal volumes.
HepGeom::Transform3D ***** m_Strip
Strip transformations.
const HepGeom::Transform3D * getPlaneTransform(int section, int layer, int sector, int plane) const
Get plane transformation.
HepGeom::Transform3D ** m_Layer
Layer transformations.
HepGeom::Transform3D *** m_Sector
Sector transformations.
void transformsToGlobal()
Make transformations global from local.
const HepGeom::Transform3D * getSegmentTransform(int section, int layer, int sector, int plane, int segment) const
Get segment transformation.
int getStripsByIntersection(const HepGeom::Point3D< double > &intersection, int *strip1, int *strip2) const
Find strips by intersection.
const HepGeom::Transform3D * getLayerTransform(int section, int layer) const
Get layer transformation.
HepGeom::Transform3D **** m_Plane
Plane transformations.
HepGeom::Transform3D ***** m_StripInverse
Inverse strip transformations.
int getSectorByPosition(int section, const HepGeom::Point3D< double > &position) const
Get sector by position.
const EKLMElementNumbers * m_ElementNumbers
Element numbers.
const HepGeom::Transform3D * getStripLocalToGlobal(KLMDigit *hit) const
Get strip local to global transformation by hit.
const HepGeom::Transform3D * getStripGlobalToLocal(KLMDigit *hit) const
Get strip global to local transformation by hit.
const HepGeom::Transform3D * getSectorTransform(int section, int layer, int sector) const
Get sector transformation.
HepGeom::Transform3D **** m_PlaneDisplacement
Plane internal volumes displacements.
HepGeom::Transform3D ***** m_Segment
Segment transformations.
const GeometryData * m_GeoDat
Geometry data.
bool intersection(KLMDigit *hit1, KLMDigit *hit2, HepGeom::Point3D< double > *cross, double *d1, double *d2, double *sd, bool segments=true) const
Check if strips intersect, and find intersection point if yes.
const HepGeom::Transform3D * getSectionTransform(int section) const
Get section transformation.
KLM Alignment data.
float getDeltaU() const
Get shift in U.
float getDeltaV() const
Get shift in V.
float getDeltaGamma() const
Get rotation in alpha.
KLM digit (class representing a digitized hit in RPCs or scintillators).
Definition KLMDigit.h:29
int getLayer() const
Get layer number.
Definition KLMDigit.h:126
int getSection() const
Get section number.
Definition KLMDigit.h:90
int getPlane() const
Get plane number.
Definition KLMDigit.h:144
int getStrip() const
Get strip number.
Definition KLMDigit.h:162
int getSector() const
Get sector number.
Definition KLMDigit.h:108
static const double mm
[millimeters]
Definition Unit.h:70
static const double rad
Standard of [angle].
Definition Unit.h:50
static const double cm
Standard units with the value = 1.
Definition Unit.h:47
Abstract base class for different kinds of events.