Belle II Software  release-06-01-15
BKLMGeometryPar.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/bklm/BKLMGeometryPar.h>
11 
12 /* Belle 2 headers. */
13 #include <framework/gearbox/GearDir.h>
14 #include <framework/logging/Logger.h>
15 
16 using namespace Belle2;
17 using namespace std;
18 
20 {
21  read(content);
22 }
23 
25 {
26 }
27 
28 // Get BKLM geometry parameters from Gearbox (no calculations here)
29 // *** This is a DIVOT ***
30 void BKLMGeometryPar::read(const GearDir& content)
31 {
32  if (!content) {
33  B2FATAL("The GearDir to look for BKLM geometry parameters is not valid.");
34  return;
35  }
36  char name[80] = "";
37  GearDir data(content);
38  data.append("/BKLM");
39  m_DoBeamBackgroundStudy = data.getBool("BeamBackgroundStudy");
40  m_Rotation = data.getAngle("Rotation");
41  m_OffsetZ = data.getLength("OffsetZ");
42  m_Phi = data.getLength("Phi");
43  m_NSector = data.getNumberNodes("Sectors/Forward/Sector");
44  if (m_NSector > BKLMElementNumbers::getMaximalSectorNumber()) { // array-bounds check
45  B2FATAL("BKLMGeometryPar::read(): sectors array size exceeded:"
46  << LogVar("# of sectors", m_NSector)
48  }
49  m_SolenoidOuterRadius = data.getLength("SolenoidOuterRadius");
50  m_OuterRadius = data.getLength("OuterRadius");
51  m_HalfLength = data.getLength("HalfLength");
52  m_NLayer = data.getNumberNodes("Layers/Layer");
53  if (m_NLayer > BKLMElementNumbers::getMaximalLayerNumber()) { // array-bounds check
54  B2FATAL("BKLMGeometryPar::read(): layer array size exceeded:"
55  << LogVar("# of layers", m_NLayer)
57  }
58 
59  m_IronNominalHeight = data.getLength("Layers/IronNominalHeight");
60  m_IronActualHeight = data.getLength("Layers/IronActualHeight");
61  m_Gap1NominalHeight = data.getLength("Layers/Layer[@layer=\"1\"]/GapNominalHeight");
62  m_GapNominalHeight = data.getLength("Layers/GapNominalHeight");
63  m_Gap1InnerRadius = data.getLength("Layers/InnerRadius");
64  m_Gap1IronWidth = data.getLength("Layers/Layer[@layer=\"1\"]/GapIronWidth");
65  m_GapIronWidth = data.getLength("Layers/GapIronWidth");
66  m_GapLength = data.getLength("Layers/GapLength");
67 
68  m_NZStrips = data.getInt("Layers/NZStrips");
69  m_NZStripsChimney = data.getInt("Layers/NZStripsChimney");
70  m_NZScints = data.getInt("Layers/NZScintillators");
71  m_NZScintsChimney = data.getInt("Layers/NZScintillatorsChimney");
72  m_NZScintsChimney = data.getInt("Layers/NZScintillatorsChimney");
73  if (m_NZScints > NZSCINT) { // array-bounds check
74  B2FATAL("BKLMGeometryPar::read(): z-scint array size exceeded:"
75  << LogVar("# of z scintillators", m_NZScints)
76  << LogVar("array size", NZSCINT));
77  }
78  if (m_NZScintsChimney > NZSCINT) { // array-bounds check
79  B2FATAL("BKLMGeometryPar::read(): chimney sector z-scint array size exceeded:"
80  << LogVar("# of z scintillators", m_NZScintsChimney)
81  << LogVar("array size", NZSCINT));
82  }
83 
84  m_ModuleLength = data.getLength("Module/Length");
85  m_ModuleLengthChimney = data.getLength("Module/LengthChimney");
86  m_ModuleCoverHeight = data.getLength("Module/CoverHeight");
87  m_ModuleCopperHeight = data.getLength("Module/CopperHeight");
88  m_ModuleFoamHeight = data.getLength("Module/FoamHeight");
89  m_ModuleMylarHeight = data.getLength("Module/MylarHeight");
90  m_ModuleGlassHeight = data.getLength("Module/GlassHeight");
91  m_ModuleGasHeight = data.getLength("Module/GasHeight");
92  m_ModuleFrameWidth = data.getLength("Module/FrameWidth");
93  m_ModuleFrameThickness = data.getLength("Module/FrameThickness");
94  m_ModuleGasSpacerWidth = data.getLength("Module/SpacerWidth");
95  m_ModulePolystyreneInnerHeight = data.getLength("Module/PolystyreneInnerHeight");
96  m_ModulePolystyreneOuterHeight = data.getLength("Module/PolystyreneOuterHeight");
97  m_ScintWidth = data.getLength("Module/Scintillator/Width");
98  m_ScintHeight = data.getLength("Module/Scintillator/Height");
99  m_ScintBoreRadius = data.getLength("Module/Scintillator/BoreRadius");
100  m_ScintFiberRadius = data.getLength("Module/Scintillator/FiberRadius");
101  m_ScintTiO2ThicknessTop = data.getLength("Module/Scintillator/TiO2ThicknessTop");
102  m_ScintTiO2ThicknessSide = data.getLength("Module/Scintillator/TiO2ThicknessSide");
103 
104  m_ChimneyLength = data.getLength("Chimney/Length");
105  m_ChimneyWidth = data.getLength("Chimney/Width");
106  m_ChimneyCoverThickness = data.getLength("Chimney/CoverThickness");
107  m_ChimneyHousingInnerRadius = data.getLength("Chimney/HousingInnerRadius");
108  m_ChimneyHousingOuterRadius = data.getLength("Chimney/HousingOuterRadius");
109  m_ChimneyShieldInnerRadius = data.getLength("Chimney/ShieldInnerRadius");
110  m_ChimneyShieldOuterRadius = data.getLength("Chimney/ShieldOuterRadius");
111  m_ChimneyPipeInnerRadius = data.getLength("Chimney/PipeInnerRadius");
112  m_ChimneyPipeOuterRadius = data.getLength("Chimney/PipeOuterRadius");
113 
114  m_RibThickness = data.getLength("RibThickness");
115  m_CablesWidth = data.getLength("CablesWidth");
116  m_BraceWidth = data.getLength("BraceWidth");
117  m_BraceWidthChimney = data.getLength("BraceWidthChimney");
118 
119  m_SupportPlateWidth = data.getLength("SupportPlateWidth");
120  m_SupportPlateHeight = data.getLength("SupportPlateHeight");
121  m_SupportPlateLength = data.getLength("SupportPlateLength");
122  m_SupportPlateLengthChimney = data.getLength("SupportPlateLengthChimney");
123 
124  m_BracketWidth = data.getLength("BracketWidth");
125  m_BracketThickness = data.getLength("BracketThickness");
126  m_BracketLength = data.getLength("BracketLength");
127  m_BracketRibWidth = data.getLength("BracketRibWidth");
128  m_BracketRibThickness = data.getLength("BracketRibThickness");
129  m_BracketInnerRadius = data.getLength("BracketInnerRadius");
130  m_BracketInset = data.getLength("BracketInset");
131  m_BracketCutoutDphi = data.getAngle("BracketCutoutDphi");
132 
133  m_NReadoutStation = data.getNumberNodes("Readout/Stations/Station");
134  if (m_NReadoutStation > NSTATION) { // array-bounds check
135  B2FATAL("BKLMGeometryPar::read(): readout stations array size exceeded:"
136  << LogVar("# of readout stations", m_NReadoutStation)
137  << LogVar("array size", NSTATION));
138  }
139  for (int station = 1; station <= m_NReadoutStation; ++station) {
140  sprintf(name, "/Readout/Stations/Station[@station=\"%d\"]", station);
141  GearDir stationContent = data;
142  stationContent.append(name);
143  m_ReadoutStationIsPhi[station - 1] = stationContent.getBool("IsPhi");
144  m_ReadoutStationPosition[station - 1] = stationContent.getLength("Position");
145  }
146  m_ReadoutContainerLength = data.getLength("Readout/Container/Length");
147  m_ReadoutContainerWidth = data.getLength("Readout/Container/Width");
148  m_ReadoutContainerHeight = data.getLength("Readout/Container/Height");
149  m_ReadoutCarrierLength = data.getLength("Readout/Carrier/Length");
150  m_ReadoutCarrierWidth = data.getLength("Readout/Carrier/Width");
151  m_ReadoutCarrierHeight = data.getLength("Readout/Carrier/Height");
152  m_ReadoutPreamplifierLength = data.getLength("Readout/Preamplifier/Length");
153  m_ReadoutPreamplifierWidth = data.getLength("Readout/Preamplifier/Width");
154  m_ReadoutPreamplifierHeight = data.getLength("Readout/Preamplifier/Height");
155  m_ReadoutPreamplifierPosition = data.getArray("Readout/Preamplifier/Position");
156  m_ReadoutConnectorsLength = data.getLength("Readout/Connectors/Length");
157  m_ReadoutConnectorsWidth = data.getLength("Readout/Connectors/Width");
158  m_ReadoutConnectorsHeight = data.getLength("Readout/Connectors/Height");
159  m_ReadoutConnectorsPosition = data.getLength("Readout/Connectors/Position");
160  m_MPPCHousingRadius = data.getLength("Readout/MPPC/Housing/Radius");
161  m_MPPCHousingLength = data.getLength("Readout/MPPC/Housing/Length");
162  m_MPPCLength = data.getLength("Readout/MPPC/Sensor/Length");
163  m_MPPCWidth = data.getLength("Readout/MPPC/Sensor/Width");
164  m_MPPCHeight = data.getLength("Readout/MPPC/Sensor/Height");
165 
166  // by-layer values that are common for all sectors and forward/backward
167  for (int layer = 1; layer <= m_NLayer; ++layer) {
168  sprintf(name, "/Layers/Layer[@layer=\"%d\"]", layer);
169  GearDir layerContent = data;
170  layerContent.append(name);
171  m_HasRPCs[layer - 1] = layerContent.getBool("HasRPCs");
172  m_NPhiStrips[layer - 1] = layerContent.getInt("PhiStrips/NStrips");
173  m_PhiStripWidth[layer - 1] = layerContent.getLength("PhiStrips/Width");
174  m_ZStripWidth[layer - 1] = layerContent.getLength("ZStrips/Width");
175  if (layer <= NSCINTLAYER) {
176  m_ScintEnvelopeOffsetSign[layer - 1] = layerContent.getInt("ScintEnvelopeOffsetSign");
177  m_NPhiScints[layer - 1] = layerContent.getInt("PhiScintillators/NScints", 0);
178  if (m_NPhiScints[layer - 1] > NPHISCINT) { // array-bounds check
179  B2FATAL("BKLMGeometryPar::read(): phi-scint array size exceeded:"
180  << LogVar("in zero-based layer", layer - 1)
181  << LogVar("# of phi scintillators", m_NPhiScints[layer - 1])
182  << LogVar("array size", NPHISCINT));
183  }
184  for (int scint = 1; scint <= m_NZScints; ++scint) {
185  sprintf(name, "/ZScintillators/Scint[@scint=\"%d\"]", scint);
186  GearDir scintContent(layerContent);
187  scintContent.append(name);
188  m_ZScintDLength[layer - 1][scint - 1] = scintContent.getLength("DLength", 0.0);
189  }
190  }
191  }
192 
193  // values that depend on fb/sector/layer
194  for (int section = 0; section <= BKLMElementNumbers::getMaximalSectionNumber(); ++section) {
195  bool isForward = (section == BKLMElementNumbers::c_ForwardSection);
196  for (int sector = 1; sector <= m_NSector; ++sector) {
197  sprintf(name, "/Sectors/%s/Sector[@sector=\"%d\"]", (isForward ? "Forward" : "Backward"), sector);
198  GearDir sectorContent(data);
199  sectorContent.append(name);
200  m_SectorRotation[section][sector - 1] = sectorContent.getAngle("Phi");
201  for (int layer = 1; layer <= m_NLayer; ++layer) {
202  GearDir layerContent(sectorContent);
203  sprintf(name, "/Layer[@layer=\"%d\"]", layer);
204  layerContent.append(name);
205  m_LocalReconstructionShiftX[section][sector - 1][layer - 1] = layerContent.getLength("ReconstructionShift/X");
206  m_LocalReconstructionShiftY[section][sector - 1][layer - 1] = layerContent.getLength("ReconstructionShift/Y");
207  m_LocalReconstructionShiftZ[section][sector - 1][layer - 1] = layerContent.getLength("ReconstructionShift/Z");
208  if (layer <= NSCINTLAYER) {
209  m_IsFlipped[section][sector - 1][layer - 1] = layerContent.getBool("Flip", false);
210  }
211  }
212  }
213  }
214 
215 }
static constexpr int getMaximalLayerNumber()
Get maximal layer number (1-based).
static constexpr int getMaximalSectorNumber()
Get maximal sector number (1-based).
static constexpr int getMaximalSectionNumber()
Get maximal section number (0-based).
BKLMGeometryPar()
Default constructor.
void read(const GearDir &)
Get geometry parameters from Gearbox.
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
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
Definition: Interface.h:299
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
bool getBool(const std::string &path="") const noexcept(false)
Get the parameter path as a bool.
Definition: Interface.cc:80
int getInt(const std::string &path="") const noexcept(false)
Get the parameter path as a int.
Definition: Interface.cc:60
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.