Belle II Software  release-08-01-10
TransformData Class Reference

Transformation data. More...

#include <TransformData.h>

Inheritance diagram for TransformData:
Collaboration diagram for TransformData:

Public Types

enum  Displacement {
  c_None ,
  c_Displacement ,
  c_Alignment
}
 Source of displacement (alignment) data. More...
 

Public Member Functions

 TransformData (bool global, Displacement displacementType)
 Constructor. More...
 
 TransformData (const TransformData &)=delete
 Copy constructor (disabled).
 
TransformDataoperator= (const TransformData &)=delete
 Operator = (disabled).
 
 ~TransformData ()
 Destructor.
 
const HepGeom::Transform3D * getSectionTransform (int section) const
 Get section transformation. More...
 
const HepGeom::Transform3D * getLayerTransform (int section, int layer) const
 Get layer transformation. More...
 
const HepGeom::Transform3D * getSectorTransform (int section, int layer, int sector) const
 Get sector transformation. More...
 
const HepGeom::Transform3D * getPlaneTransform (int section, int layer, int sector, int plane) const
 Get plane transformation. More...
 
const HepGeom::Transform3D * getPlaneDisplacement (int section, int layer, int sector, int plane) const
 Get additional displacement for plane internal volumes. More...
 
const HepGeom::Transform3D * getSegmentTransform (int section, int layer, int sector, int plane, int segment) const
 Get segment transformation. More...
 
const HepGeom::Transform3D * getStripLocalToGlobal (KLMDigit *hit) const
 Get strip local to global transformation by hit. More...
 
const HepGeom::Transform3D * getStripGlobalToLocal (KLMDigit *hit) const
 Get strip global to local transformation by hit. More...
 
const HepGeom::Transform3D * getStripTransform (int section, int layer, int sector, int plane, int strip) const
 Get strip transformation. More...
 
const HepGeom::Transform3D * getStripGlobalToLocal (int section, int layer, int sector, int plane, int strip) const
 Get strip global to local transformation by hit. More...
 
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. More...
 
int getSectorByPosition (int section, const HepGeom::Point3D< double > &position) const
 Get sector by position. More...
 
int getStripsByIntersection (const HepGeom::Point3D< double > &intersection, int *strip1, int *strip2) const
 Find strips by intersection. More...
 

Private Member Functions

void transformsToGlobal ()
 Make transformations global from local. More...
 

Private Attributes

const EKLMElementNumbersm_ElementNumbers
 Element numbers.
 
const GeometryDatam_GeoDat
 Geometry data.
 
HepGeom::Transform3D * m_Section
 Section transformations.
 
HepGeom::Transform3D ** m_Layer
 Layer transformations.
 
HepGeom::Transform3D *** m_Sector
 Sector transformations.
 
HepGeom::Transform3D **** m_Plane
 Plane transformations.
 
HepGeom::Transform3D **** m_PlaneDisplacement
 Plane internal volumes displacements.
 
HepGeom::Transform3D ***** m_Segment
 Segment transformations.
 
HepGeom::Transform3D ***** m_Strip
 Strip transformations.
 
HepGeom::Transform3D ***** m_StripInverse
 Inverse strip transformations.
 

Detailed Description

Transformation data.

All data and function results are in CLHEP units unless noted otherwise.

Definition at line 35 of file TransformData.h.

Member Enumeration Documentation

◆ Displacement

Source of displacement (alignment) data.

Enumerator
c_None 

Displacement is not used.

c_Displacement 

Use displacement data (for geometry).

c_Alignment 

Use alignment data (for everything else).

Definition at line 42 of file TransformData.h.

42  {
43  c_None,
45  c_Alignment,
46  };
@ c_None
Displacement is not used.
Definition: TransformData.h:43
@ c_Displacement
Use displacement data (for geometry).
Definition: TransformData.h:44
@ c_Alignment
Use alignment data (for everything else).
Definition: TransformData.h:45

Constructor & Destructor Documentation

◆ TransformData()

TransformData ( bool  global,
Displacement  displacementType 
)

Constructor.

Parameters
[in]globalIf true, load global transformations (false - local).
[in]displacementTypeDisplacement type.

Definition at line 25 of file TransformData.cc.

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++) {
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++) {
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  for (iLayer = 1; iLayer <= nDetectorLayers; iLayer++) {
127  for (iSector = 1; iSector <= nSectors; iSector++) {
128  sector = m_ElementNumbers->sectorNumber(iSection, iLayer, iSector);
129  const KLMAlignmentData* sectorAlignment =
130  alignment->getModuleAlignment(sector);
131  if (sectorAlignment == nullptr)
132  B2FATAL("Incomplete EKLM displacement (alignment) data.");
133  for (iPlane = 1; iPlane <= nPlanes; iPlane++) {
134  /* First plane is rotated. */
135  if (iPlane == 1) {
136  m_PlaneDisplacement[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1] =
137  HepGeom::Translate3D(
138  sectorAlignment->getDeltaV() * CLHEP::cm / Unit::cm,
139  sectorAlignment->getDeltaU() * CLHEP::cm / Unit::cm, 0) *
140  HepGeom::RotateZ3D(-sectorAlignment->getDeltaGamma() *
141  CLHEP::rad / Unit::rad);
142  } else {
143  m_PlaneDisplacement[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1] =
144  HepGeom::Translate3D(
145  sectorAlignment->getDeltaU() * CLHEP::cm / Unit::cm,
146  sectorAlignment->getDeltaV() * CLHEP::cm / Unit::cm, 0) *
147  HepGeom::RotateZ3D(sectorAlignment->getDeltaGamma() *
148  CLHEP::rad / Unit::rad);
149  }
150  for (iSegment = 1; iSegment <= nSegments; iSegment++) {
151  segment = m_ElementNumbers->segmentNumber(
152  iSection, iLayer, iSector, iPlane, iSegment);
153  const KLMAlignmentData* segmentAlignmentData =
154  segmentAlignment->getSegmentAlignment(segment);
155  if (segmentAlignmentData == nullptr)
156  B2FATAL("Incomplete EKLM displacement (alignment) data.");
157  m_Segment[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
158  [iSegment - 1] =
159  HepGeom::Translate3D(
160  segmentAlignmentData->getDeltaU() * CLHEP::cm / Unit::cm,
161  segmentAlignmentData->getDeltaV() * CLHEP::cm / Unit::cm, 0) *
162  m_Segment[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
163  [iSegment - 1] *
164  HepGeom::RotateZ3D(segmentAlignmentData->getDeltaGamma() *
165  CLHEP::rad / Unit::rad);
166  for (iStrip = 1; iStrip <= nStripsSegment; iStrip++) {
167  m_Strip[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
168  [nStripsSegment * (iSegment - 1) + iStrip - 1] =
169  HepGeom::Translate3D(
170  segmentAlignmentData->getDeltaU() * CLHEP::cm / Unit::cm,
171  segmentAlignmentData->getDeltaV() * CLHEP::cm / Unit::cm,
172  0) *
173  m_Strip[iSection - 1][iLayer - 1][iSector - 1][iPlane - 1]
174  [nStripsSegment * (iSegment - 1) + iStrip - 1] *
175  HepGeom::RotateZ3D(segmentAlignmentData->getDeltaGamma() *
176  CLHEP::rad / Unit::rad);
177  }
178  }
179  }
180  }
181  }
182  }
183  }
184  if (global)
186 }
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
static const EKLMElementNumbers & Instance()
Instantiation.
int sectorNumber(int section, int layer, int sector) const
Get sector number.
static constexpr int getNStripsSegment()
Get number of strips in a segment.
int segmentNumber(int section, int layer, int sector, int plane, int segment) const
Get segment number.
int getNPlanes() const
Get number of planes.
int getNSections() const
Get number of sections.
int getNLayers() const
Get number of layers.
int getNDetectorLayers(int section) const
Get number of detector layers.
int getNSegments() const
Get number of segments.
int getNStrips() const
Get number of strips.
int getNSectors() const
Get number of sectors.
void getSectorTransform(HepGeom::Transform3D *t, int n) const
Get sector transformation.
static const GeometryData & Instance(enum DataSource dataSource=c_Database, const GearDir *gearDir=nullptr)
Instantiation.
Definition: GeometryData.cc:33
void getStripTransform(HepGeom::Transform3D *t, int n) const
Get strip transformation.
void getSectionTransform(HepGeom::Transform3D *t, int n) const
Get section transformation.
void getLayerTransform(HepGeom::Transform3D *t, int n) const
Get layer transformation.
void getPlaneTransform(HepGeom::Transform3D *t, int n) const
Get plane transformation.
HepGeom::Transform3D * m_Section
Section transformations.
HepGeom::Transform3D ***** m_Strip
Strip transformations.
HepGeom::Transform3D ** m_Layer
Layer transformations.
HepGeom::Transform3D *** m_Sector
Sector transformations.
void transformsToGlobal()
Make transformations global from local.
HepGeom::Transform3D **** m_Plane
Plane transformations.
HepGeom::Transform3D ***** m_StripInverse
Inverse strip transformations.
const EKLMElementNumbers * m_ElementNumbers
Element numbers.
HepGeom::Transform3D **** m_PlaneDisplacement
Plane internal volumes displacements.
HepGeom::Transform3D ***** m_Segment
Segment transformations.
const GeometryData * m_GeoDat
Geometry data.
KLM Alignment data.
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].
Definition: Unit.h:50
static const double cm
Standard units with the value = 1.
Definition: Unit.h:47

Member Function Documentation

◆ getLayerTransform()

const HepGeom::Transform3D * getLayerTransform ( int  section,
int  layer 
) const

Get layer transformation.

Parameters
[in]sectionSection number.
[in]layerLayer number.

Definition at line 290 of file TransformData.cc.

◆ getPlaneDisplacement()

const HepGeom::Transform3D * getPlaneDisplacement ( int  section,
int  layer,
int  sector,
int  plane 
) const

Get additional displacement for plane internal volumes.

Parameters
[in]sectionSection number.
[in]layerLayer number.
[in]sectorSector number.
[in]planePlane number.

Definition at line 307 of file TransformData.cc.

◆ getPlaneTransform()

const HepGeom::Transform3D * getPlaneTransform ( int  section,
int  layer,
int  sector,
int  plane 
) const

Get plane transformation.

Parameters
[in]sectionSection number.
[in]layerLayer number.
[in]sectorSector number.
[in]planePlane number.

Definition at line 301 of file TransformData.cc.

◆ getSectionTransform()

const HepGeom::Transform3D * getSectionTransform ( int  section) const

Get section transformation.

Parameters
[in]sectionSection number.

Definition at line 284 of file TransformData.cc.

◆ getSectorByPosition()

int getSectorByPosition ( int  section,
const HepGeom::Point3D< double > &  position 
) const

Get sector by position.

Parameters
[in]sectionSection number.
[in]positionPosition.

Definition at line 416 of file TransformData.cc.

◆ getSectorTransform()

const HepGeom::Transform3D * getSectorTransform ( int  section,
int  layer,
int  sector 
) const

Get sector transformation.

Parameters
[in]sectionSection number.
[in]layerLayer number.
[in]sectorSector number.

Definition at line 295 of file TransformData.cc.

◆ getSegmentTransform()

const HepGeom::Transform3D * getSegmentTransform ( int  section,
int  layer,
int  sector,
int  plane,
int  segment 
) const

Get segment transformation.

Parameters
[in]sectionSection number.
[in]layerLayer number.
[in]sectorSector number.
[in]planePlane number.
[in]segmentSegment number.

Definition at line 313 of file TransformData.cc.

◆ getStripGlobalToLocal() [1/2]

const HepGeom::Transform3D * getStripGlobalToLocal ( int  section,
int  layer,
int  sector,
int  plane,
int  strip 
) const

Get strip global to local transformation by hit.

Parameters
[in]sectionSection number.
[in]layerLayer number.
[in]sectorSector number.
[in]planePlane number.
[in]stripStrip number.
Returns
Transformation.

Definition at line 341 of file TransformData.cc.

◆ getStripGlobalToLocal() [2/2]

const HepGeom::Transform3D * getStripGlobalToLocal ( KLMDigit hit) const

Get strip global to local transformation by hit.

Parameters
[in]hitHit.
Returns
Transformation.

Definition at line 334 of file TransformData.cc.

◆ getStripLocalToGlobal()

const HepGeom::Transform3D * getStripLocalToGlobal ( KLMDigit hit) const

Get strip local to global transformation by hit.

Parameters
[in]hitHit.
Returns
Transformation.

Definition at line 327 of file TransformData.cc.

◆ getStripsByIntersection()

int getStripsByIntersection ( const HepGeom::Point3D< double > &  intersection,
int *  strip1,
int *  strip2 
) const

Find strips by intersection.

Parameters
[in]intersectionIntersection point.
[out]strip1Strip 1 global number.
[out]strip2Strip 2 global number.
Returns
0 on success, -1 on error.

Definition at line 440 of file TransformData.cc.

◆ getStripTransform()

const HepGeom::Transform3D * getStripTransform ( int  section,
int  layer,
int  sector,
int  plane,
int  strip 
) const

Get strip transformation.

Parameters
[in]sectionSection number.
[in]layerLayer number.
[in]sectorSector number.
[in]planePlane number.
[in]stripStrip number.

Definition at line 320 of file TransformData.cc.

◆ intersection()

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.

Parameters
[in]hit1First hit.
[in]hit2Second hit.
[out]crossCrossing point (coordinate unit is cm).
[out]d1Distance from hit to SiPM of strip 1, cm.
[out]d2Distance from hit to SiPM of strip 2, cm.
[out]sdShortest distance between strips, cm. Or if second strip is closer to interaction point, then (- shortest distance).
[in]segmentsCheck if segments intersect (may need to turn this check off for debugging).
Returns
True if strips intersect.

Line parametric equations: (s1_1g) + (s1_2g - s1_1g) * t1 = a1 + v1 * t1, (s2_1g) + (s2_2g - s2_1g) * t2 = a2 + v2 * t2. Points of closest approach: t1 = ((v1,v2)*(d,v2) - v2^2*(d,v1)) / (v1^2*v2^2 - (v1,v2)^2) t2 = - ((v1,v2)*(d,v1) - v1^2*(d,v2)) / (v1^2*v2^2 - (v1,v2)^2) where d = a1 - a2.

Definition at line 348 of file TransformData.cc.

◆ transformsToGlobal()

void transformsToGlobal ( )
private

Make transformations global from local.

Parameters
[in,out]datTransformation data.

Definition at line 239 of file TransformData.cc.


The documentation for this class was generated from the following files: