Belle II Software development
EKLMGeometry.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/dbobjects/eklm/EKLMGeometry.h>
11
12/* Basf2 headers. */
13#include <framework/logging/Logger.h>
14
15using namespace Belle2;
16
17/* Class EKLMGeometry::EndcapStructureGeometry. */
18
20{
21}
22
24{
25}
26
27/* Class EKLMGeometry::ElementPosition. */
28
30{
31}
32
33/* Class EKLMGeometry::SectorSupportGeometry. */
34
36{
37}
38
39/* Class EKLMGeometry::PlasticSheetGeometry. */
40
42{
43}
44
45/* Class EKLMGeometry::SegmentSupportGeometry. */
46
48{
49}
50
51/* Class EKLMGeometry::SegmentSupportPosition. */
52
54{
55}
56
57/* Class EKLMGeometry::StripGeometry. */
58
60{
61}
62
63/* Class EKLMGeometry::Point. */
64
65EKLMGeometry::Point::Point()
66{
67}
68
69/* Class EKLMGeometry::ShieldDetailGeometry. */
70
72{
73}
74
76 const ShieldDetailGeometry& geometry) : TObject(geometry)
77{
78 /* cppcheck-suppress variableScope */
79 int i;
80 m_LengthX = geometry.getLengthX();
81 m_LengthY = geometry.getLengthY();
82 m_NPoints = geometry.getNPoints();
83 if (m_NPoints > 0) {
85 for (i = 0; i < m_NPoints; i++)
86 m_Points[i] = *geometry.getPoint(i);
87 } else
88 m_Points = nullptr;
89}
90
93 const ShieldDetailGeometry& geometry)
94{
95 /* cppcheck-suppress variableScope */
96 int i;
97 if (&geometry == this)
98 return *this;
99 m_LengthX = geometry.getLengthX();
100 m_LengthY = geometry.getLengthY();
101 m_NPoints = geometry.getNPoints();
102 if (m_Points != nullptr)
103 delete[] m_Points;
104 if (m_NPoints > 0) {
105 m_Points = new Point[m_NPoints];
106 for (i = 0; i < m_NPoints; i++)
107 m_Points[i] = *geometry.getPoint(i);
108 } else
109 m_Points = nullptr;
110 return *this;
111}
112
114{
115 if (m_Points != nullptr)
116 delete[] m_Points;
117}
118
120{
121 if (nPoints < 0)
122 B2FATAL("Number of points must be nonnegative.");
123 m_NPoints = nPoints;
124 if (m_Points != nullptr)
125 delete[] m_Points;
126 if (m_NPoints > 0)
127 m_Points = new Point[m_NPoints];
128 else
129 m_Points = nullptr;
130}
131
134{
135 if (i < 0 || i >= m_NPoints)
136 B2FATAL("Number of point must be from 0 to " << m_NPoints - 1 << ".");
137 return &m_Points[i];
138}
139
141{
142 if (i < 0 || i >= m_NPoints)
143 B2FATAL("Number of point must be from 0 to " << m_NPoints - 1 << ".");
144 m_Points[i] = point;
145}
146
147/* Class EKLMGeometry::ShieldGeometry. */
148
150{
151}
152
154{
155 m_DetailACenter.setX(x);
156 m_DetailACenter.setY(y);
157}
158
160{
161 m_DetailBCenter.setX(x);
162 m_DetailBCenter.setY(y);
163}
164
166{
167 m_DetailCCenter.setX(x);
168 m_DetailCCenter.setY(y);
169}
170
171/* Class EKLMGeometry. */
172
174 m_ElementNumbers(&(EKLMElementNumbers::Instance())),
175 m_NSections(0),
176 m_NLayers(0),
177 m_NDetectorLayers(nullptr),
178 m_NSectors(0),
179 m_NPlanes(0),
180 m_NSegments(0),
182 m_NStrips(0),
183 m_SolenoidZ(0),
184 m_LayerShiftZ(0),
186 m_StripPosition(nullptr)
187{
188}
189
191 TObject(geometry),
192 m_ElementNumbers(&(EKLMElementNumbers::Instance())),
193 m_EndcapStructureGeometry(*geometry.getEndcapStructureGeometry()),
194 m_SectionPosition(*geometry.getSectionPosition()),
195 m_LayerPosition(*geometry.getLayerPosition()),
196 m_SectorPosition(*geometry.getSectorPosition()),
197 m_SectorSupportPosition(*geometry.getSectorSupportPosition()),
198 m_SectorSupportGeometry(*geometry.getSectorSupportGeometry()),
199 m_PlanePosition(*geometry.getPlanePosition()),
200 m_PlasticSheetGeometry(*geometry.getPlasticSheetGeometry()),
201 m_SegmentSupportGeometry(*geometry.getSegmentSupportGeometry()),
202 m_StripGeometry(*geometry.getStripGeometry()),
203 m_ShieldGeometry(*geometry.getShieldGeometry())
204{
205 int i, j;
206 m_NSections = geometry.getNSections();
207 m_NLayers = geometry.getNLayers();
209 m_NDetectorLayers[0] = geometry.getNDetectorLayers(1);
210 if (m_NSections == 2)
211 m_NDetectorLayers[1] = geometry.getNDetectorLayers(2);
212 m_NSectors = geometry.getNSectors();
213 m_NPlanes = geometry.getNPlanes();
214 m_NSegments = geometry.getNSegments();
215 m_NSegmentSupportElementsSector = geometry.getNSegmentSupportElementsSector();
216 m_NStrips = geometry.getNStrips();
217 m_SolenoidZ = geometry.getSolenoidZ();
218 m_LayerShiftZ = geometry.getLayerShiftZ();
221 for (i = 0; i < m_NPlanes; i++) {
222 for (j = 0; j <= m_NSegments; j++) {
224 *geometry.getSegmentSupportPosition(i + 1, j + 1);
225 }
226 }
228 for (i = 0; i < m_NStrips; i++)
229 m_StripPosition[i] = *geometry.getStripPosition(i + 1);
230}
231
233{
234 if (m_NDetectorLayers != nullptr)
235 delete[] m_NDetectorLayers;
236 if (m_SegmentSupportPosition != nullptr)
238 if (m_StripPosition != nullptr)
239 delete[] m_StripPosition;
240}
241
243{
244 int i, j;
245 if (&geometry == this)
246 return *this;
247 m_NSections = geometry.getNSections();
248 m_NLayers = geometry.getNLayers();
249 if (m_NDetectorLayers != nullptr)
250 delete[] m_NDetectorLayers;
252 m_NDetectorLayers[0] = geometry.getNDetectorLayers(1);
253 if (m_NSections == 2)
254 m_NDetectorLayers[1] = geometry.getNDetectorLayers(2);
255 m_NSectors = geometry.getNSectors();
256 m_NPlanes = geometry.getNPlanes();
257 m_NSegments = geometry.getNSegments();
258 m_NSegmentSupportElementsSector = geometry.getNSegmentSupportElementsSector();
259 m_NStrips = geometry.getNStrips();
260 m_SolenoidZ = geometry.getSolenoidZ();
261 m_EndcapStructureGeometry = *geometry.getEndcapStructureGeometry();
262 m_SectionPosition = *geometry.getSectionPosition();
263 m_LayerPosition = *geometry.getLayerPosition();
264 m_LayerShiftZ = geometry.getLayerShiftZ();
265 m_SectorPosition = *geometry.getSectorPosition();
266 m_SectorSupportPosition = *geometry.getSectorSupportPosition();
267 m_SectorSupportGeometry = *geometry.getSectorSupportGeometry();
268 m_PlanePosition = *geometry.getPlanePosition();
269 m_PlasticSheetGeometry = *geometry.getPlasticSheetGeometry();
270 m_SegmentSupportGeometry = *geometry.getSegmentSupportGeometry();
271 if (m_SegmentSupportPosition != nullptr)
275 for (i = 0; i < m_NPlanes; i++) {
276 for (j = 0; j <= m_NSegments; j++) {
278 *geometry.getSegmentSupportPosition(i + 1, j + 1);
279 }
280 }
281 m_StripGeometry = *geometry.getStripGeometry();
282 if (m_StripPosition != nullptr)
283 delete[] m_StripPosition;
285 for (i = 0; i < m_NStrips; i++)
286 m_StripPosition[i] = *geometry.getStripPosition(i + 1);
287 m_ShieldGeometry = *geometry.getShieldGeometry();
288 return *this;
289}
290
291/* Numbers of geometry elements. */
292
294{
296 return m_NDetectorLayers[section - 1];
297}
298
299/* Element number checks. */
300
301void EKLMGeometry::checkDetectorLayerNumber(int section, int layer) const
302{
303 /* cppcheck-suppress variableScope */
304 const char* sectionName[2] = {"backward", "forward"};
305 if (layer < 0 || layer > m_NLayers ||
307 B2FATAL("Number of detector layers in the " << sectionName[section - 1] <<
308 " section must be from 0 to the number of layers ( " <<
309 m_NLayers << ").");
310}
311
312void EKLMGeometry::checkDetectorLayer(int section, int layer) const
313{
314 /* cppcheck-suppress variableScope */
315 const char* sectionName[2] = {"backward", "forward"};
316 if (layer < 0 || layer > m_NDetectorLayers[section - 1])
317 B2FATAL("Number of layer must be less from 1 to the number of "
318 "detector layers in the " << sectionName[section - 1] << " section ("
319 << m_NDetectorLayers[section - 1] << ").");
320}
321
323{
324 if (support <= 0 || support > m_ElementNumbers->getMaximalSegmentNumber() + 1)
325 B2FATAL("Number of segment support element must be from 1 to " <<
327}
328
330{
331 if (strip <= 0 || strip > m_ElementNumbers->getNStripsSegment())
332 B2FATAL("Number of strip in a segment must be from 1 to " <<
334}
335
336/* Positions, coordinates, sizes. */
337
339EKLMGeometry::getSegmentSupportPosition(int plane, int support) const
340{
342 checkSegmentSupport(support);
343 return &m_SegmentSupportPosition[(plane - 1) * (m_NSegments + 1) +
344 support - 1];
345}
346
349{
351 return &m_StripPosition[strip - 1];
352}
EKLM element numbers.
int getMaximalDetectorLayerNumber(int section) const
Get maximal detector layer number.
bool checkPlane(int plane, bool fatalError=true) const
Check if plane number is correct (fatal error if not).
bool checkStrip(int strip, bool fatalError=true) const
Check if strip number is correct (fatal error if not).
static constexpr int getNStripsSegment()
Get number of strips in a segment.
bool checkSection(int section, bool fatalError=true) const
Check if section number is correct.
static constexpr int getMaximalSegmentNumber()
Get maximal segment number.
Position information for the elements of detector.
Definition: EKLMGeometry.h:100
Shield layer detail geometry data.
void setPoint(int i, const Point &point)
Set point.
const Point * getPoint(int i) const
Get point.
ShieldDetailGeometry & operator=(const ShieldDetailGeometry &geometry)
Operator =.
Definition: EKLMGeometry.cc:92
void setNPoints(int nPoints)
Set number of points.
void setDetailACenter(double x, double y)
Set detail A center.
void setDetailCCenter(double x, double y)
Set detail C center.
void setDetailBCenter(double x, double y)
Set detail B center.
Class to store EKLM geometry data in the database.
Definition: EKLMGeometry.h:29
int m_NSegments
Number of segments in one plane.
EKLMGeometry()
Constructor.
ShieldGeometry m_ShieldGeometry
Shield layer details geometry data.
int m_NLayers
Number of layers in one section.
const SegmentSupportPosition * getSegmentSupportPosition(int plane, int support) const
Get position data for segment support structure.
SectorSupportGeometry m_SectorSupportGeometry
Sector support geometry data.
void checkDetectorLayer(int section, int layer) const
Check if detector layer number is correct (fatal error if not).
const ElementPosition * getStripPosition(int strip) const
Get position data for strips.
ElementPosition m_SectionPosition
Position data for sections.
int m_NPlanes
Number of planes in one sector.
ElementPosition m_SectorSupportPosition
Position data for sector support structure.
int getNDetectorLayers(int section) const
Get number of detector layers.
void checkSegmentSupport(int support) const
Check if segment support number is correct (fatal error if not).
double m_SolenoidZ
Solenoid center Z coordinate.
ElementPosition m_PlanePosition
Position data for planes.
ElementPosition m_LayerPosition
Position data for layers.
int m_NStrips
Number of strips in one plane.
double m_LayerShiftZ
Z distance between two layers.
int m_NSectors
Number of sectors in one layer.
const EKLMElementNumbers * m_ElementNumbers
Element numbers.
int * m_NDetectorLayers
Number of detector layers.
int m_NSections
Number of sections.
~EKLMGeometry()
Destructor.
PlasticSheetGeometry m_PlasticSheetGeometry
Plastic sheet geometry data.
ElementPosition m_SectorPosition
Position data for sectors.
SegmentSupportPosition * m_SegmentSupportPosition
Position data for segment support structure.
ElementPosition * m_StripPosition
Position data for strips.
StripGeometry m_StripGeometry
Strip geometry data.
EndcapStructureGeometry m_EndcapStructureGeometry
Section structure geometry data.
EKLMGeometry & operator=(const EKLMGeometry &geometry)
Operator =.
SegmentSupportGeometry m_SegmentSupportGeometry
Segment support geometry data.
void checkStripSegment(int strip) const
Check if number of strip in a segment is correct (fatal error if not).
void checkDetectorLayerNumber(int section, int layer) const
Check if number of detector layers is correct (fatal error if not).
int m_NSegmentSupportElementsSector
Number of segment support elements in one sector.
Abstract base class for different kinds of events.