Belle II Software  release-05-01-25
ARICHGeoAerogelPlane.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luka Santelj *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <arich/dbobjects/ARICHGeoAerogelPlane.h>
12 #include <math.h>
13 #include <iostream>
14 #include <iomanip>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 bool ARICHGeoAerogelPlane::isConsistent() const
20 {
21 
22  if (m_layers.size() == 0 || m_r.size() == 0 || m_dPhi.size() == 0) return false;
23  if (m_tileGap < 0 || m_innerR < 0) return false;
24  if (m_innerR > m_outerR) return false;
25  if (m_thickness < 0 || m_wallThickness < 0 || m_wallHeight < 0) return false;
26 
27  if (abs(getWallHeight() - getLayerThickness(1) - getLayerThickness(2)) > 1.0e-10) {
28  cout << "getWallHeight() = " << getWallHeight() << endl
29  << "getLayerThickness(1) = " << getLayerThickness(1) << endl
30  << "getLayerThickness(2) = " << getLayerThickness(2) << endl;
31  cout << "getWallHeight() - getLayerThickness(1) - getLayerThickness(2) = "
32  << getWallHeight() - getLayerThickness(1) - getLayerThickness(2) << endl;
33  B2ERROR("Data of the ARICHGeoAerogelPlane is inconsisten : --> abs (getWallHeight() - getLayerThickness(1) - getLayerThickness(2)) > 1.0e-10");
34  }
35 
36  if (getFullAerogelMaterialDescriptionKey() == 1) {
37  const int nn = 10;// Please note it can be any number bigger than number of aero ringth (now it is 4)
38  int nAeroSlotsPerRing[nn];
39  // Define the array with zeros
40  for (int i = 0; i < nn; i++)
41  nAeroSlotsPerRing[i] = 0;
42  for (unsigned i = 0; i < m_tiles.size(); i++)
43  if (m_tiles.at(i).layer == 0)
44  nAeroSlotsPerRing[m_tiles.at(i).ring - 1] += 1;
45  //Check is number of aerogel slots is consistent with number of entries for tiles properties.
46  for (unsigned i = 0; i < getNAeroSlotsIndividualRing().size(); i++) {
47  //cout<<"getNAeroSlotsIndividualRing().at(i) = "<<getNAeroSlotsIndividualRing().at(i)<<endl
48  // <<"nAeroSlotsPerRing[i] = "<<nAeroSlotsPerRing[i]<<endl;
49  B2ASSERT("Data of the ARICHGeoAerogelPlane is inconsisten : --> getNAeroSlotsIndividualRing().at(i) != nAeroSlotsPerRing[i]",
50  getNAeroSlotsIndividualRing().at(i) == nAeroSlotsPerRing[i]);
51  }
52  }
53 
54  return true;
55 }
56 
57 void ARICHGeoAerogelPlane::print(const std::string& title) const
58 {
59  ARICHGeoBase::print(title);
60 
61  cout << "Full aerogel material description key : " << getFullAerogelMaterialDescriptionKey() << endl;
62 
63  cout << "Nume of aerogel rings and number of aerogel slots in individual ring " << endl;
64 
65  cout << setw(5) << "Ring"
66  << setw(15) << "Aerogel slots" << endl;
67  for (unsigned i = 0; i < getNAeroSlotsIndividualRing().size(); i++) {
68  cout << setw(5) << i + 1
69  << setw(15) << getNAeroSlotsIndividualRing().at(i) << endl;
70  }
71 
72  cout << "Imaginary tube thikness just after aerogel layers : " << getImgTubeThickness() << endl;
73  cout << "Minimum thickness of the compensation volume with ARICH air : " << getCompensationARICHairVolumeThick_min() << endl;
74 
75  cout << "Aerogel layers " << endl;
76 
77  int nLayer = getNLayers();
78  for (int iLayer = 1; iLayer < nLayer + 1; iLayer++) {
79  cout << " layer " << iLayer << endl;
80  cout << " thickness: " << getLayerThickness(iLayer) << " " << s_unitName << ", ref. index: " << getLayerRefIndex(
81  iLayer) << ", transm. length: " << getLayerTrLength(iLayer) << " " << s_unitName << ", material: " << getLayerMaterial(
82  iLayer) << endl;
83  }
84  if (getFullAerogelMaterialDescriptionKey() == 1) {
85  cout << " Please note full aerogel material description key is set to 1 " << endl;
86  cout << " The name of each particular tile have this form : Aero1_serA090_rin4_col26 " << endl;
87  cout << " serialID = A090; ring = 4; column = 26; layer = up; " << endl;
88  cout << " The name of each particular tile have this form : Aero2_serB162_rin4_col14 " << endl;
89  cout << " serialID = B162; ring = 4 column = 15; layer = down; " << endl;
90  }
91 
92  int nRing = getNRings();
93  cout << " Aluminum walls between tiles parameters" << endl;
94  cout << " thickness: " << getWallThickness() << " " << s_unitName << endl;
95  cout << " height: " << getWallHeight() << " " << s_unitName << endl;
96  for (int iRing = 1; iRing < nRing + 1; iRing++) {
97 
98  if (iRing < nRing) cout << " ring: " << iRing << " has inner radius of " << getRingRadius(iRing) << " " << s_unitName << " and "
99  << static_cast<int>(2 * M_PI / getRingDPhi(iRing) + 0.5) << " aerogel tile slots." << endl;
100  else cout << " ring: " << iRing << " has inner radius of " << getRingRadius(iRing) << " " << s_unitName <<
101  " (this is the outer ring)" << endl;
102  }
103 
104  cout << " gap between tile and aluminum wall: " << getTileGap() << " " << s_unitName << endl;
105  cout << " inner radius of support plate: " << getSupportInnerR() << " " << s_unitName << endl;
106  cout << " outer radius of support plate: " << getSupportOuterR() << " " << s_unitName << endl;
107  cout << " thickness of support plate: " << getSupportThickness() << " " << s_unitName << endl;
108  cout << " material of support plate: " << getSupportMaterial() << endl;
109 
110  cout << "Positioning parameters (in local ARICH frame)" << endl;
111  ARICHGeoBase::printPlacement(m_x, m_y, m_z, m_rx, m_ry, m_rz);
112 
113  if (isSimple()) {
114  cout << endl << "Simple aerogel configuration is set!" << endl;
115  cout << " Parameters:" << endl;
116  cout << " xSize: " << m_simpleParams.at(0) << ", ySize: " << m_simpleParams.at(1) << ", xPos: " << m_simpleParams.at(
117  2) << ", xPos: " << m_simpleParams.at(3) << ", zRot: " << m_simpleParams.at(4) << endl;
118  }
119 
120 }
121 
122 unsigned ARICHGeoAerogelPlane::getAerogelTileID(double x, double y) const
123 {
124 
125  double r = sqrt(x * x + y * y);
126 
127  int nTile = 0;
128  for (unsigned iRing = 0; iRing < getNRings(); iRing++) {
129  if (r > m_r[iRing] + m_wallThickness + m_tileGap) {
130  if (iRing == 0) continue;
131  nTile += static_cast<int>(2 * M_PI / m_dPhi[iRing - 1] + 0.5);
132  } else {
133  if (iRing == 0) return 0;
134  if (r > m_r[iRing] - m_tileGap) return 0;
135  double phi = atan2(y, x);
136  if (phi < 0) phi += 2 * M_PI;
137  int nphi = static_cast<int>(phi / m_dPhi[iRing - 1]);
138  double gapPhi = (m_tileGap + m_wallThickness / 2.) / m_r[iRing];
139  if (phi < nphi * m_dPhi[iRing - 1] + gapPhi || phi > (nphi + 1)* m_dPhi[iRing - 1] - gapPhi) return 0;
140  nTile += nphi;
141  return nTile + 1;
142  }
143 
144  }
145  return 0;
146 }
147 
148 unsigned ARICHGeoAerogelPlane::getTileParameters(int ring, int column, int layerN, double& n, double& transmL, double& thick,
149  std::string& material) const
150 {
151  n = 0.0;
152  transmL = 0.0;
153  thick = 0.0;
154  material = (char*)"NULL";
155  for (unsigned i = 0; i < m_tiles.size(); i++) {
156  if (m_tiles.at(i).ring == ring) {
157  if (m_tiles.at(i).column == column) {
158  if (m_tiles.at(i).layer == layerN) {
159  n = m_tiles.at(i).n;
160  transmL = m_tiles.at(i).transmL;
161  thick = m_tiles.at(i).thick;
162  material = m_tiles.at(i).material;
163  return i;
164  }
165  }
166  }
167  }
168  B2WARNING("ARICHGeoAerogelPlane::getTileParameters --> tile position does not exist " << endl
169  << "ring = " << ring << endl
170  << "column = " << column << endl
171  << "layerN = " << layerN << endl);
172  B2ASSERT("ARICHGeoAerogelPlane::getTileParameters --> tile position does not exist", false);
173  return 0;
174 }
175 
176 double ARICHGeoAerogelPlane::getTileThickness(int ring, int column, int layerN) const
177 {
178  for (unsigned i = 0; i < m_tiles.size(); i++)
179  if (m_tiles.at(i).ring == ring)
180  if (m_tiles.at(i).column == column)
181  if (m_tiles.at(i).layer == layerN)
182  return m_tiles.at(i).thick;
183  B2WARNING("ARICHGeoAerogelPlane::getTileThickness --> tile position does not exist " << endl
184  << "ring = " << ring << endl
185  << "column = " << column << endl
186  << "layerN = " << layerN << endl);
187  B2ASSERT("ARICHGeoAerogelPlane::getTileParameters --> tile position does not exist", false);
188  return 0;
189 }
190 
191 std::string ARICHGeoAerogelPlane::getTileMaterialName(int ring, int column, int layerN) const
192 {
193  for (unsigned i = 0; i < m_tiles.size(); i++)
194  if (m_tiles.at(i).ring == ring)
195  if (m_tiles.at(i).column == column)
196  if (m_tiles.at(i).layer == layerN)
197  return m_tiles.at(i).material;
198  B2WARNING("ARICHGeoAerogelPlane::getTileThickness --> tile position does not exist " << endl
199  << "ring = " << ring << endl
200  << "column = " << column << endl
201  << "layerN = " << layerN << endl);
202  B2ASSERT("ARICHGeoAerogelPlane::getTileParameters --> tile position does not exist", false);
203  return NULL;
204 }
205 
206 double ARICHGeoAerogelPlane::getTotalTileThickness(int ring, int column) const
207 {
208  double n;
209  double transmL;
210  double thickUp;
211  double thickDown;
212  std::string materialName;
213  getTileParameters(ring, column, 0, n, transmL, thickUp, materialName);
214  getTileParameters(ring, column, 1, n, transmL, thickDown, materialName);
215  //cout << setw(5) << "QWER"
216  // << setw(10) << ring
217  // << setw(10) << column
218  // << setw(10) << thickUp
219  // << setw(10) << thickDown <<endl;
220  return thickUp + thickDown;
221 }
222 
223 double ARICHGeoAerogelPlane::getMaximumTotalTileThickness() const
224 {
225  double maxThick = 0.0;
226  // ring ID (range : [ 1, 2, 3, 4])
227  // column ID (range : [1;22] [1;28] [1;34] [1;40])
228  for (unsigned iR = 0; iR < getNAeroSlotsIndividualRing().size(); iR++) {
229  int iRi = iR;
230  for (int iS = 0; iS < getNAeroSlotsIndividualRing().at(iR); iS++) {
231  double athick = getTotalTileThickness(iRi + 1, iS + 1);
232  if (maxThick < athick)
233  maxThick = athick;
234  }
235  }
236  return maxThick;
237 }
238 
239 void ARICHGeoAerogelPlane::printTileParameters(const std::string& title) const
240 {
241  ARICHGeoBase::print(title);
242  cout << setw(5) << "i"
243  << setw(10) << "ring"
244  << setw(10) << "column"
245  << setw(10) << "layer"
246  << setw(12) << "n"
247  << setw(12) << "transmL"
248  << setw(12) << "thick"
249  << setw(30) << "material" << endl;
250  for (unsigned i = 0; i < m_tiles.size(); i++) {
251  cout << setw(5) << i
252  << setw(10) << m_tiles.at(i).ring
253  << setw(10) << m_tiles.at(i).column
254  << setw(10) << m_tiles.at(i).layer
255  << setw(12) << m_tiles.at(i).n
256  << setw(12) << m_tiles.at(i).transmL
257  << setw(12) << m_tiles.at(i).thick
258  << setw(30) << m_tiles.at(i).material << endl;
259  }
260 }
261 
262 void ARICHGeoAerogelPlane::printSingleTileParameters(unsigned i) const
263 {
264  cout << "ARICHGeoAerogelPlane::printSingleTileParameters" << endl;
265  B2ASSERT("Aerogel tile property entry does not exist i >= m_tiles.size() ", i < m_tiles.size());
266  cout << setw(5) << "i"
267  << setw(10) << "ring"
268  << setw(10) << "column"
269  << setw(10) << "layer"
270  << setw(12) << "n"
271  << setw(12) << "transmL"
272  << setw(12) << "thick"
273  << setw(30) << "material" << endl;
274  cout << setw(5) << i
275  << setw(10) << m_tiles.at(i).ring
276  << setw(10) << m_tiles.at(i).column
277  << setw(10) << m_tiles.at(i).layer
278  << setw(12) << m_tiles.at(i).n
279  << setw(12) << m_tiles.at(i).transmL
280  << setw(12) << m_tiles.at(i).thick
281  << setw(30) << m_tiles.at(i).material << endl;
282 }
283 
284 void ARICHGeoAerogelPlane::testGetTileParametersFunction() const
285 {
286  int ring = 1;
287  int column = 1;
288  int layerN = 0;
289  double n;
290  double transmL;
291  double thick;
292  std::string materialName;
293  printSingleTileParameters(getTileParameters(ring, column, layerN, n, transmL, thick, materialName));
294  ring = 1;
295  column = 1;
296  layerN = 1;
297  printSingleTileParameters(getTileParameters(ring, column, layerN, n, transmL, thick, materialName));
298  ring = 3;
299  column = 20;
300  layerN = 0;
301  printSingleTileParameters(getTileParameters(ring, column, layerN, n, transmL, thick, materialName));
302  ring = 3;
303  column = 20;
304  layerN = 1;
305  printSingleTileParameters(getTileParameters(ring, column, layerN, n, transmL, thick, materialName));
306  ring = -3;
307  column = 20;
308  layerN = 1;
309  printSingleTileParameters(getTileParameters(ring, column, layerN, n, transmL, thick, materialName));
310 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19