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