Belle II Software development
CDCGeometry.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#include <cdc/dbobjects/CDCGeometry.h>
10#include <framework/gearbox/GearDir.h>
11#include <boost/format.hpp>
12
13using namespace Belle2;
14using namespace std;
15
16void CDCGeometry::MotherVolume::appendNode(double rmin, double rmax, double z)
17{
18 m_rmin.push_back(rmin);
19 m_rmax.push_back(rmax);
20 m_z.push_back(z);
21}
22
23
25{
26 read(content);
27}
28
30{
31}
32
33void CDCGeometry::read(const GearDir& content)
34{
35 // Global.
36 m_globalOffsetX = content.getLength("OffsetX");
37 m_globalOffsetY = content.getLength("OffsetY");
38 m_globalOffsetZ = content.getLength("OffsetZ");
39 m_globalPhiRotation = content.getAngle("GlobalPhiRotation");
40 m_globalOffsetA = content.getAngle("OffsetA");
41 m_globalOffsetB = content.getAngle("OffsetB");
42 m_globalOffsetC = content.getAngle("OffsetC");
43
44 m_maxNSenseLayers = content.getInt("MaxNSenseLayers");
45 m_maxNFieldLayers = content.getInt("MaxNFieldLayers");
46 m_maxNSuperLayers = content.getInt("SuperLayers");
47 m_firstLayerOffset = content.getInt("FirstLayerOffset");
48 m_firstSuperLayerOffset = content.getInt("SuperLayerOffset");
49 m_maxNCellsPerLayer = content.getInt("MaxNCells");
50
51 // Mother volume.
52 const int nBound = content.getNumberNodes("MomVol/ZBound");
53 for (int iBound = 0; iBound < nBound; iBound++) {
54 const double rmin = content.getLength((boost::format("MomVol/ZBound[%1%]/Rmin") % (iBound + 1)).str()) / Unit::mm;
55 const double rmax = content.getLength((boost::format("MomVol/ZBound[%1%]/Rmax") % (iBound + 1)).str()) / Unit::mm;
56 const double z = content.getLength((boost::format("MomVol/ZBound[%1%]/Z") % (iBound + 1)).str()) / Unit::mm;
57 m_mother.appendNode(rmin, rmax, z);
58 }
59
60
61 // Sense layer.
62 const int nSLayer = content.getNumberNodes("SLayers/SLayer");
63
64 for (int iSLayer = 0; iSLayer < nSLayer; ++iSLayer) {
65 GearDir layerContent(content);
66 layerContent.append((boost::format("/SLayers/SLayer[%1%]/") % (iSLayer + 1)).str());
67 const double r = layerContent.getLength("Radius");
68 const double zfwd = layerContent.getLength("ForwardZ");
69 const double zbwd = layerContent.getLength("BackwardZ");
70 const double dzfwd = layerContent.getLength("FwdDeltaZ");
71 const double dzbwd = layerContent.getLength("BwdDeltaZ");
72 const double offset = atof((layerContent.getString("Offset")).c_str());
73 const int nWires = atoi((layerContent.getString("NHoles")).c_str()) / 2;
74 const double nShifts = atof((layerContent.getString("NShift")).c_str());
75
76 SenseLayer sense(iSLayer + m_firstLayerOffset, r, zfwd, zbwd,
77 dzfwd, dzbwd, offset, nWires, nShifts);
78
79 m_senseLayers.push_back(sense);
80 }
81
82 // Field layer.
83 const int nFLayer = content.getNumberNodes("FLayers/FLayer");
84
85 for (int iFLayer = 0; iFLayer < nFLayer; ++iFLayer) {
86 GearDir layerContent(content);
87 layerContent.append((boost::format("/FLayers/FLayer[%1%]/") % (iFLayer + 1)).str());
88 const double r = layerContent.getLength("Radius");
89 const double zfwd = layerContent.getLength("ForwardZ");
90 const double zbwd = layerContent.getLength("BackwardZ");
91 FieldLayer field(iFLayer + m_firstLayerOffset, r, zfwd, zbwd);
92 m_fieldLayers.push_back(field);
93 }
94
95 // Endplate.
96 const int nEndplates = content.getNumberNodes("Endplates/Endplate");
97 for (int i = 0; i < nEndplates; ++i) {
98
99 EndPlate ep(i);
100
101 GearDir epContent(content);
102 epContent.append((boost::format("/Endplates/Endplate[%1%]/") % (i + 1)).str());
103 const int nEPLayer = epContent.getNumberNodes("EndplateLayer");
104
105 for (int iEPLayer = 0; iEPLayer < nEPLayer; ++iEPLayer) {
106 GearDir epLayerContent(epContent);
107 epLayerContent.append((boost::format("/EndplateLayer[%1%]/") % (iEPLayer + 1)).str());
108 string epName = epLayerContent.getString("Name");
109 double rmin = epLayerContent.getLength("InnerR");
110 double rmax = epLayerContent.getLength("OuterR");
111 double zfwd = epLayerContent.getLength("ForwardZ");
112 double zbwd = epLayerContent.getLength("BackwardZ");
113 std::string name = "Layer" + to_string(i + m_firstLayerOffset) + epName + to_string(iEPLayer);
114
115 ep.appendNew(name, iEPLayer, rmin, rmax, zfwd, zbwd);
116 }
117 m_endplates.push_back(ep);
118 }
119
120 // Inner wall.
121 const int nInnerWall = content.getNumberNodes("InnerWalls/InnerWall");
122 for (int i = 0; i < nInnerWall; ++i) {
123 GearDir innerWallContent(content);
124 innerWallContent.append((boost::format("/InnerWalls/InnerWall[%1%]/") % (i + 1)).str());
125
126 string sInnerWallID = innerWallContent.getString("@id");
127 const string name = "InnerWall_" + sInnerWallID + "_" + innerWallContent.getString("Name");
128 const double rmin = innerWallContent.getLength("InnerR");
129 const double rmax = innerWallContent.getLength("OuterR");
130 const double zfwd = innerWallContent.getLength("ForwardZ");
131 const double zbwd = innerWallContent.getLength("BackwardZ");
132 const InnerWall wall(name, i, rmin, rmax, zfwd, zbwd);
133 m_innerWalls.push_back(wall);
134 if (innerWallContent.getString("Name") == "Shield") {
135 m_fiducialRmin = rmax;
136 }
137 }
138
139
140 // Outer wall.
141 const int nOuterWall = content.getNumberNodes("OuterWalls/OuterWall");
142 for (int i = 0; i < nOuterWall; ++i) {
143 GearDir outerWallContent(content);
144 outerWallContent.append((boost::format("/OuterWalls/OuterWall[%1%]/") % (i + 1)).str());
145
146 string sOuterWallID = outerWallContent.getString("@id");
147 const string name = "OuterWall_" + sOuterWallID + "_" + outerWallContent.getString("Name");
148 const double rmin = outerWallContent.getLength("InnerR");
149 const double rmax = outerWallContent.getLength("OuterR");
150 const double zfwd = outerWallContent.getLength("ForwardZ");
151 const double zbwd = outerWallContent.getLength("BackwardZ");
152 const OuterWall wall(name, i, rmin, rmax, zfwd, zbwd);
153 m_outerWalls.push_back(wall);
154 if (outerWallContent.getString("Name") == "Shield") {
155 m_fiducialRmax = rmin;
156 }
157 }
158
159
160 // Electronics board.
161 const int nEB = content.getNumberNodes("ElectronicsBoards/ElectronicsBoard");
162 for (int iEB = 0; iEB < nEB; ++iEB) {
163 GearDir ebContent(content);
164 ebContent.append((boost::format("/ElectronicsBoards/ElectronicsBoard[%1%]/") % (iEB + 1)).str());
165
166 const double rmin = ebContent.getLength("EBInnerR");
167 const double rmax = ebContent.getLength("EBOuterR");
168 const double zfwd = ebContent.getLength("EBForwardZ");
169 const double zbwd = ebContent.getLength("EBBackwardZ");
170 Frontend frontend(iEB, rmin, rmax, zfwd, zbwd);
171 m_frontends.push_back(frontend);
172 }
173
174 // Neutron shield.
175 const int nShields = content.getNumberNodes("Shields/Shield");
176 for (int i = 0; i < nShields; ++i) {
177 GearDir neuContent(content);
178 neuContent.append((boost::format("/Shields/Shield[%1%]/") % (i + 1)).str());
179
180 const double rmin1 = neuContent.getLength("InnerR1");
181 const double rmin2 = neuContent.getLength("InnerR2");
182 const double rmax1 = neuContent.getLength("OuterR1");
183 const double rmax2 = neuContent.getLength("OuterR2");
184 const double thick = neuContent.getLength("Thickness");
185 const double z = neuContent.getLength("PosZ");
186 NeutronShield shield(i, rmin1, rmin2, rmax1, rmax2, thick, z);
187 m_neutronShields.push_back(shield);
188 }
189
190 // Support structure.
191 const int nCovers = content.getNumberNodes("Covers/Cover");
192 for (int i = 0; i < nCovers; ++i) {
193 GearDir coverContent(content);
194 coverContent.append((boost::format("/Covers/Cover[%1%]/") % (i + 1)).str());
195
196 const int coverID = atoi((coverContent.getString("@id")).c_str());
197 const double rmin1 = coverContent.getLength("InnerR1");
198 const double rmin2 = coverContent.getLength("InnerR2");
199 const double rmax1 = coverContent.getLength("OuterR1");
200 const double rmax2 = coverContent.getLength("OuterR2");
201 const double thick = coverContent.getLength("Thickness");
202 const double z = coverContent.getLength("PosZ");
203 Cover cover(coverID, rmin1, rmin2, rmax1, rmax2, thick, z);
204 m_covers.push_back(cover);
205 }
206
207 const int nCover2s = content.getNumberNodes("Covers/Cover2");
208 for (int i = 0; i < nCover2s; ++i) {
209 GearDir cover2Content(content);
210 cover2Content.append((boost::format("/Covers/Cover2[%1%]/") % (i + 1)).str());
211
212 const int cover2ID = atoi((cover2Content.getString("@id")).c_str());
213 const double rmin = cover2Content.getLength("InnerR");
214 const double rmax = cover2Content.getLength("OuterR");
215 const double phis = cover2Content.getLength("StartPhi");
216 const double dphi = cover2Content.getLength("DeltaPhi");
217 const double thick = cover2Content.getLength("Thickness");
218 const double z = cover2Content.getLength("PosZ");
219 Cover2 cover2(cover2ID, rmin, rmax, phis, dphi, thick, z);
220 m_cover2s.push_back(cover2);
221 }
222
223 const int nRibs = content.getNumberNodes("Covers/Rib");
224 for (int i = 0; i < nRibs; ++i) {
225 GearDir ribContent(content);
226 ribContent.append((boost::format("/Covers/Rib[%1%]/") % (i + 1)).str());
227
228 const int ribID = atoi((ribContent.getString("@id")).c_str());
229 const double length = ribContent.getLength("Length");
230 const double width = ribContent.getLength("Width");
231 const double thick = ribContent.getLength("Thickness");
232 const double rotx = ribContent.getLength("RotX");
233 const double roty = ribContent.getLength("RotY");
234 const double rotz = ribContent.getLength("RotZ");
235 const double x = ribContent.getLength("PosX");
236 const double y = ribContent.getLength("PosY");
237 const double z = ribContent.getLength("PosZ");
238 const int offset = atoi((ribContent.getString("Offset")).c_str());
239 const int ndiv = atoi((ribContent.getString("NDiv")).c_str());
240 Rib rib(ribID, length, width, thick, rotx, roty, rotz, x, y, z, offset, ndiv);
241 m_ribs.push_back(rib);
242 }
243
244 const int nRib2s = content.getNumberNodes("Covers/Rib2");
245 for (int i = 0; i < nRib2s; ++i) {
246 GearDir rib2Content(content);
247 rib2Content.append((boost::format("/Covers/Rib2[%1%]/") % (i + 1)).str());
248
249 const int rib2ID = atoi((rib2Content.getString("@id")).c_str());
250 const double length = rib2Content.getLength("Length");
251 const double width = rib2Content.getLength("Width");
252 const double thick = rib2Content.getLength("Thickness");
253 const double width2 = rib2Content.getLength("Width2");
254 const double thick2 = rib2Content.getLength("Thickness2");
255 const double rotx = rib2Content.getLength("RotX");
256 const double roty = rib2Content.getLength("RotY");
257 const double rotz = rib2Content.getLength("RotZ");
258 const double x = rib2Content.getLength("PosX");
259 const double y = rib2Content.getLength("PosY");
260 const double z = rib2Content.getLength("PosZ");
261 const int ndiv = atoi((rib2Content.getString("NDiv")).c_str());
262 Rib2 rib2(rib2ID, length, width, thick, width2, thick2, rotx, roty, rotz,
263 x, y, z, ndiv);
264 m_rib2s.push_back(rib2);
265 }
266
267 const int nRib3s = content.getNumberNodes("Covers/Rib3");
268 for (int i = 0; i < nRib3s; ++i) {
269 GearDir rib3Content(content);
270 rib3Content.append((boost::format("/Covers/Rib3[%1%]/") % (i + 1)).str());
271
272 const int rib3ID = atoi((rib3Content.getString("@id")).c_str());
273 const double length = rib3Content.getLength("Length");
274 const double width = rib3Content.getLength("Width");
275 const double thick = rib3Content.getLength("Thickness");
276 const double r = rib3Content.getLength("HoleR");
277 const double x = rib3Content.getLength("PosX");
278 const double y = rib3Content.getLength("PosY");
279 const double z = rib3Content.getLength("PosZ");
280 const double rx = rib3Content.getLength("HoleX");
281 const double ry = rib3Content.getLength("HoleY");
282 const double rz = rib3Content.getLength("HoleZ");
283 const int offset = atoi((rib3Content.getString("Offset")).c_str());
284 const int ndiv = atoi((rib3Content.getString("NDiv")).c_str());
285 Rib3 rib3(rib3ID, length, width, thick, r, x, y, z, rx, ry, rz, offset, ndiv);
286 m_rib3s.push_back(rib3);
287 }
288
289 const int nRib4s = content.getNumberNodes("Covers/Rib4");
290 for (int i = 0; i < nRib4s; ++i) {
291 GearDir rib4Content(content);
292 rib4Content.append((boost::format("/Covers/Rib4[%1%]/") % (i + 1)).str());
293
294 const int rib4ID = atoi((rib4Content.getString("@id")).c_str());
295 const double length = rib4Content.getLength("Length");
296 const double width = rib4Content.getLength("Width");
297 const double thick = rib4Content.getLength("Thickness");
298 const double length2 = rib4Content.getLength("Length2");
299 const double width2 = rib4Content.getLength("Width2");
300 const double thick2 = rib4Content.getLength("Thickness2");
301 const double x = rib4Content.getLength("PosX");
302 const double y = rib4Content.getLength("PosY");
303 const double z = rib4Content.getLength("PosZ");
304 const double x2 = rib4Content.getLength("HoleX");
305 const double y2 = rib4Content.getLength("HoleY");
306 const double z2 = rib4Content.getLength("HoleZ");
307 const int offset = atoi((rib4Content.getString("Offset")).c_str());
308 const int ndiv = atoi((rib4Content.getString("NDiv")).c_str());
309 Rib4 rib4(rib4ID, length, width, thick, length2, width2, thick2, x, y, z, x2, y2, z2, offset, ndiv);
310 m_rib4s.push_back(rib4);
311 }
312
313 const int nRib5s = content.getNumberNodes("Covers/Rib5");
314 for (int i = 0; i < nRib5s; ++i) {
315 GearDir rib5Content(content);
316 rib5Content.append((boost::format("/Covers/Rib5[%1%]/") % (i + 1)).str());
317
318 const int rib5ID = atoi((rib5Content.getString("@id")).c_str());
319 const double dr = rib5Content.getLength("DR");
320 const double dz = rib5Content.getLength("DZ");
321 const double width = rib5Content.getLength("Width");
322 const double thick = rib5Content.getLength("Thickness");
323 const double rin = rib5Content.getLength("Rin");
324 const double x = rib5Content.getLength("PosX");
325 const double y = rib5Content.getLength("PosY");
326 const double z = rib5Content.getLength("PosZ");
327 const double rotx = rib5Content.getLength("RotX");
328 const double roty = rib5Content.getLength("RotY");
329 const double rotz = rib5Content.getLength("RotZ");
330 const int offset = atoi((rib5Content.getString("Offset")).c_str());
331 const int ndiv = atoi((rib5Content.getString("NDiv")).c_str());
332 Rib5 rib5(rib5ID, dr, dz, width, thick, rin, x, y, z,
333 rotx, roty, rotz, offset, ndiv);
334 m_rib5s.push_back(rib5);
335 }
336
337
338 // Sense wire.
339 GearDir senseWire(content);
340 senseWire.append("/SenseWire/");
341 m_senseWireDiameter = senseWire.getLength("Diameter");
342 // B2INFO("m_senseWireDiameter= " << m_senseWireDiameter);
343 m_senseWireNumbers = atoi((senseWire.getString("Number")).c_str());
344
345 // Field wire.
346 GearDir fieldWire(content);
347 fieldWire.append("/FieldWire/");
348 m_fieldWireDiameter = fieldWire.getLength("Diameter");
349 // B2INFO("m_fieldWireDiameter= " << m_fieldWireDiameter);
350 m_fieldWireNumbers = atoi((fieldWire.getString("Number")).c_str());
351
352
353 // Feedthrough.
354 m_feedThroughLength = content.getLength("/FeedThrough/Length");
355 // B2INFO("m_feedThroughLength= " << m_feedThroughLength);
356
357 // Get control switch for gas and wire material definition
358 m_clockFrequency = content.getDouble("ClockFrequencyForTDC");
359 m_nominalSpaceResolution = content.getLength("SenseWire/SpaceResol");
360
361}
Cover2 structure geometry parameters.
Definition: CDCGeometry.h:694
Cover structure geometry parameters.
Definition: CDCGeometry.h:616
Endplate geometry parameters.
Definition: CDCGeometry.h:1351
void appendNew(const std::string &name, int ilay, double rmin, double rmax, double zfwd, double zbwd)
Add new endplate layer.
Definition: CDCGeometry.h:1372
Field layer geometry parameters.
Definition: CDCGeometry.h:1080
Frontend layer geometry parameters.
Definition: CDCGeometry.h:850
Inner wall geometry parameters.
Definition: CDCGeometry.h:1209
std::vector< double > m_z
Z-cordinates list of the mother volume.
Definition: CDCGeometry.h:950
std::vector< double > m_rmin
Rmin list of the mother volume.
Definition: CDCGeometry.h:948
std::vector< double > m_rmax
Rmax list of the mother volume.
Definition: CDCGeometry.h:949
void appendNode(double rmin, double rmax, double z)
Append a new node.
Definition: CDCGeometry.cc:16
Neutron shield geometry parameters.
Definition: CDCGeometry.h:772
Outer wall geometry parameters.
Definition: CDCGeometry.h:1138
Rib2 structure geometry parameters.
Definition: CDCGeometry.h:141
Rib3 structure geometry parameters.
Definition: CDCGeometry.h:257
Rib4 structure geometry parameters.
Definition: CDCGeometry.h:370
Rib5 structure geometry parameters.
Definition: CDCGeometry.h:497
Rib structure geometry parameters.
Definition: CDCGeometry.h:35
Sense layer geometry parameters.
Definition: CDCGeometry.h:959
double m_globalOffsetB
Offset angle b of the whole cdc wrt B2 coord system (rad).
Definition: CDCGeometry.h:1671
ushort m_maxNSuperLayers
Maximum number of Super Layers.
Definition: CDCGeometry.h:1702
MotherVolume m_mother
CDC mother volume.
Definition: CDCGeometry.h:1675
double m_globalPhiRotation
Global rotation in phi (rad).
Definition: CDCGeometry.h:1666
int m_senseWireNumbers
Number of sense wires.
Definition: CDCGeometry.h:1692
std::vector< Rib5 > m_rib5s
Rib5s.
Definition: CDCGeometry.h:1689
double m_globalOffsetZ
Offset z of the whole cdc wrt B2 coord system (cm).
Definition: CDCGeometry.h:1669
int m_fieldWireNumbers
Number of field wires.
Definition: CDCGeometry.h:1695
~CDCGeometry()
Destructor.
Definition: CDCGeometry.cc:29
std::vector< NeutronShield > m_neutronShields
Neutron shields.
Definition: CDCGeometry.h:1682
double m_globalOffsetX
Offset x of the whole cdc wrt B2 coord system (cm).
Definition: CDCGeometry.h:1667
CDCGeometry()
Default constructor.
Definition: CDCGeometry.h:1408
double m_feedThroughLength
Feedthrough length (cm).
Definition: CDCGeometry.h:1696
ushort m_maxNSenseLayers
Maximum number of Sense Wire Layers.
Definition: CDCGeometry.h:1700
std::vector< Cover2 > m_cover2s
Cover2s.
Definition: CDCGeometry.h:1684
double m_senseWireDiameter
Sense wire diameter (cm).
Definition: CDCGeometry.h:1691
double m_clockFrequency
Clock frequency.
Definition: CDCGeometry.h:1697
std::vector< Cover > m_covers
Covers.
Definition: CDCGeometry.h:1683
double m_globalOffsetY
Offset y of the whole cdc wrt B2 coord system (cm).
Definition: CDCGeometry.h:1668
std::vector< EndPlate > m_endplates
Endplate.
Definition: CDCGeometry.h:1680
ushort m_firstSuperLayerOffset
Offset of the first super layer (for reduced CDC studies)
Definition: CDCGeometry.h:1704
std::vector< InnerWall > m_innerWalls
Inner wall.
Definition: CDCGeometry.h:1678
double m_fiducialRmin
Minimum radius of the CDC fiducial volume.
Definition: CDCGeometry.h:1673
double m_fieldWireDiameter
Field wire diameter (cm).
Definition: CDCGeometry.h:1694
std::vector< OuterWall > m_outerWalls
Outer wall.
Definition: CDCGeometry.h:1679
std::vector< Frontend > m_frontends
Electronics board.
Definition: CDCGeometry.h:1681
double m_globalOffsetC
Offset angle c of the whole cdc wrt B2 coord system (rad).
Definition: CDCGeometry.h:1672
std::vector< SenseLayer > m_senseLayers
Sense layer.
Definition: CDCGeometry.h:1676
double m_fiducialRmax
Maximum radius of the CDC fiducial volume.
Definition: CDCGeometry.h:1674
std::vector< FieldLayer > m_fieldLayers
Field layer.
Definition: CDCGeometry.h:1677
ushort m_maxNCellsPerLayer
Maximum number wires within a layer.
Definition: CDCGeometry.h:1705
std::vector< Rib > m_ribs
Ribs.
Definition: CDCGeometry.h:1685
ushort m_maxNFieldLayers
Maximum number of Field Wire Layers.
Definition: CDCGeometry.h:1701
void read(const GearDir &)
Get geometry parameters from Gearbox.
Definition: CDCGeometry.cc:33
std::vector< Rib4 > m_rib4s
Rib4s.
Definition: CDCGeometry.h:1688
double m_globalOffsetA
Offset angle a of the whole cdc wrt B2 coord system (rad).
Definition: CDCGeometry.h:1670
ushort m_firstLayerOffset
Offset of the first layer (for reduced CDC studies)
Definition: CDCGeometry.h:1703
double m_nominalSpaceResolution
Nominal space resolution.
Definition: CDCGeometry.h:1698
std::vector< Rib2 > m_rib2s
Rib2s.
Definition: CDCGeometry.h:1686
std::vector< Rib3 > m_rib3s
Rib3s.
Definition: CDCGeometry.h:1687
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
void append(const std::string &path)
Append something to the current path, modifying the GearDir in place.
Definition: GearDir.h:52
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
Definition: GearDir.h:58
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: GearDir.h:69
static const double mm
[millimeters]
Definition: Unit.h:70
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
Definition: Interface.h:259
Abstract base class for different kinds of events.
STL namespace.