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