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