Belle II Software  release-05-01-25
ARICHGeoDetectorPlane.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/ARICHGeoDetectorPlane.h>
12 #include <math.h>
13 #include <iostream>
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 void ARICHGeoDetectorPlane::setRingPar(const std::vector<std::pair<double, double>>& ringPar)
19 {
20  m_ringPar = ringPar;
21 
22  for (auto ring : m_ringPar) {
23  double iPhi = ring.second / 2.;
24  while (iPhi < 2 * M_PI) {
25  m_slotPar.push_back({ring.first, iPhi});
26  iPhi += ring.second;
27  }
28  }
29 
30  m_nRings = m_ringPar.size();
31  m_nSlots = m_slotPar.size();
32 
33 }
34 
35 unsigned ARICHGeoDetectorPlane::getSlotRing(unsigned slotID) const
36 {
37 
38  if (slotID > m_nSlots) B2ERROR("ARICHGeoDetectorPlane: invalid module slot ID number!");
39  unsigned iRing = 1;
40  unsigned nSlots = 0;
41  for (auto dphi : m_ringPar) {
42  nSlots += static_cast<int>(2 * M_PI / dphi.second + 0.5);
43  if (slotID < nSlots + 1) return iRing;
44  iRing++;
45  }
46  return 0;
47 }
48 
49 
50 unsigned ARICHGeoDetectorPlane::pointSlotID(double x, double y) const
51 {
52  double r = sqrt(x * x + y * y);
53  double phi = atan2(y, x);
54  if (phi < 0) phi += 2 * M_PI;
55  if (r < (m_ringPar[0].first - (m_ringPar[1].first - m_ringPar[0].first) / 2.)) return 0;
56 
57  if (r > (m_ringPar[m_nRings - 1].first + (m_ringPar[m_nRings - 1].first - m_ringPar[m_nRings - 2].first) / 2.)) return 0;
58 
59  unsigned nslot = 0;
60  for (unsigned i = 1; i < m_nRings; i++) {
61  if (r < (m_ringPar[i - 1].first + m_ringPar[i].first) / 2.) {
62  nslot += phi / m_ringPar[i - 1].second;
63  return nslot + 1;
64  }
65  nslot += static_cast<int>(2 * M_PI / m_ringPar[i - 1].second + 0.5);
66  }
67  nslot += phi / m_ringPar[m_nRings - 1].second;
68  return nslot + 1;
69 }
70 
71 bool ARICHGeoDetectorPlane::isConsistent() const
72 {
73  if (m_outerR < m_innerR) return false;
74  if (m_thickness <= 0) return false;
75  if (m_moduleHoleSize < 0) return false;
76  if (m_supportBackWallHeight < 0) return false;
77  if (m_supportBackWallThickness < 0) return false;
78  if (m_supportZPosition < 0) return false;
79  if (m_ringPar.size() == 0 || m_slotPar.size() == 0) return false;
80  return true;
81 }
82 
83 unsigned ARICHGeoDetectorPlane::getSlotIDFromSRF(unsigned sector, unsigned ring, unsigned azimuth) const
84 {
85 
86  if (azimuth > static_cast<unsigned>(2 * M_PI / m_ringPar[ring - 1].second + 0.5) / 6 || ring > getNRings() || sector > 6)
87  { B2ERROR("ARICHGeoDetectorPlane::getSlotIDFromSRF: invalid slot position parameters!"); return 0;}
88 
89  unsigned moduleID = 0;
90  for (unsigned i = 1; i < ring; i++) {
91  moduleID += static_cast<int>(2 * M_PI / m_ringPar[i - 1].second + 0.5);
92  }
93  moduleID += (sector - 1) * static_cast<int>(2 * M_PI / m_ringPar[ring - 1].second + 0.5) / 6 + (azimuth - 1);
94  if (moduleID + 1 > m_nSlots) {B2ERROR("ARICHGeoDetectorPlane::getSlotIDFromSRF: invalid slot position parameters!"); return 0;}
95  return moduleID + 1;
96 }
97 
98 
99 void ARICHGeoDetectorPlane::print(const std::string& title) const
100 {
101  ARICHGeoBase::print(title);
102  cout << "Configuration of module slots:" << endl;
103  int i = 0;
104  cout << " There are " << getNRings() << " module rings." << endl;
105  for (auto ring : m_ringPar) {
106  cout << " ring: " << i + 1 << " has " << static_cast<int>(2 * M_PI / ring.second + 0.5) << " module slots, at radius: " <<
107  ring.first << " cm" << endl;
108  i++;
109  }
110 
111  cout << " Support plate inner radius: " << getSupportInnerR() << " " << s_unitName << endl;
112  cout << " Support plate outer radius: " << getSupportOuterR() << " " << s_unitName << endl;
113  cout << " Support plate thickness: " << getSupportThickness() << " " << s_unitName << endl;
114  cout << " Support plate Z position: " << getSupportZPosition() << " " << s_unitName << endl;
115  cout << " Support plate backwalls height: " << getSupportBackWallHeight() << " " << s_unitName << endl;
116  cout << " Support plate backwall thickness: " << getSupportBackWallThickness() << " " << s_unitName << endl;
117  cout << " Support plate module hole size: " << getModuleHoleSize() << " X " << getModuleHoleSize() << " " << s_unitName << endl;
118  cout << " Support plate material: " << getSupportMaterial() << endl;
119 
120  cout << "Positioning parameters (in local ARICH frame)" << endl;
121  ARICHGeoBase::printPlacement(m_x, m_y, m_z, m_rx, m_ry, m_rz);
122 
123 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19