Belle II Software development
ARICHGeoDetectorPlane.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#include <arich/dbobjects/ARICHGeoDetectorPlane.h>
10#include <math.h>
11#include <iostream>
12
13using namespace std;
14using namespace Belle2;
15
16void ARICHGeoDetectorPlane::setRingPar(const std::vector<std::pair<double, double>>& ringPar)
17{
18 m_ringPar = ringPar;
19
20 for (auto ring : m_ringPar) {
21 double iPhi = ring.second / 2.;
22 while (iPhi < 2 * M_PI) {
23 m_slotPar.push_back({ring.first, iPhi});
24 iPhi += ring.second;
25 }
26 }
27
28 m_nRings = m_ringPar.size();
29 m_nSlots = m_slotPar.size();
30
31}
32
33unsigned ARICHGeoDetectorPlane::getSlotRing(unsigned slotID) const
34{
35
36 if (slotID > m_nSlots) B2ERROR("ARICHGeoDetectorPlane: invalid module slot ID number!");
37 unsigned iRing = 1;
38 unsigned nSlots = 0;
39 for (auto dphi : m_ringPar) {
40 nSlots += static_cast<int>(2 * M_PI / dphi.second + 0.5);
41 if (slotID < nSlots + 1) return iRing;
42 iRing++;
43 }
44 return 0;
45}
46
47
48unsigned ARICHGeoDetectorPlane::pointSlotID(double x, double y) const
49{
50 double r = sqrt(x * x + y * y);
51 double phi = atan2(y, x);
52 if (phi < 0) phi += 2 * M_PI;
53 if (r < (m_ringPar[0].first - (m_ringPar[1].first - m_ringPar[0].first) / 2.)) return 0;
54
55 if (r > (m_ringPar[m_nRings - 1].first + (m_ringPar[m_nRings - 1].first - m_ringPar[m_nRings - 2].first) / 2.)) return 0;
56
57 unsigned nslot = 0;
58 for (unsigned i = 1; i < m_nRings; i++) {
59 if (r < (m_ringPar[i - 1].first + m_ringPar[i].first) / 2.) {
60 nslot += phi / m_ringPar[i - 1].second;
61 return nslot + 1;
62 }
63 nslot += static_cast<int>(2 * M_PI / m_ringPar[i - 1].second + 0.5);
64 }
65 nslot += phi / m_ringPar[m_nRings - 1].second;
66 return nslot + 1;
67}
68
70{
71 if (m_outerR < m_innerR) return false;
72 if (m_thickness <= 0) return false;
73 if (m_moduleHoleSize < 0) return false;
74 if (m_supportBackWallHeight < 0) return false;
75 if (m_supportBackWallThickness < 0) return false;
76 if (m_supportZPosition < 0) return false;
77 if (m_ringPar.size() == 0 || m_slotPar.size() == 0) return false;
78 return true;
79}
80
81unsigned ARICHGeoDetectorPlane::getSlotIDFromSRF(unsigned sector, unsigned ring, unsigned azimuth) const
82{
83
84 if (azimuth > static_cast<unsigned>(2 * M_PI / m_ringPar[ring - 1].second + 0.5) / 6 || ring > getNRings() || sector > 6)
85 { B2ERROR("ARICHGeoDetectorPlane::getSlotIDFromSRF: invalid slot position parameters!"); return 0;}
86
87 unsigned moduleID = 0;
88 for (unsigned i = 1; i < ring; i++) {
89 moduleID += static_cast<int>(2 * M_PI / m_ringPar[i - 1].second + 0.5);
90 }
91 moduleID += (sector - 1) * static_cast<int>(2 * M_PI / m_ringPar[ring - 1].second + 0.5) / 6 + (azimuth - 1);
92 if (moduleID + 1 > m_nSlots) {B2ERROR("ARICHGeoDetectorPlane::getSlotIDFromSRF: invalid slot position parameters!"); return 0;}
93 return moduleID + 1;
94}
95
96
97void ARICHGeoDetectorPlane::print(const std::string& title) const
98{
100 cout << "Configuration of module slots:" << endl;
101 int i = 0;
102 cout << " There are " << getNRings() << " module rings." << endl;
103 for (auto ring : m_ringPar) {
104 cout << " ring: " << i + 1 << " has " << static_cast<int>(2 * M_PI / ring.second + 0.5) << " module slots, at radius: " <<
105 ring.first << " cm" << endl;
106 i++;
107 }
108
109 cout << " Support plate inner radius: " << getSupportInnerR() << " " << s_unitName << endl;
110 cout << " Support plate outer radius: " << getSupportOuterR() << " " << s_unitName << endl;
111 cout << " Support plate thickness: " << getSupportThickness() << " " << s_unitName << endl;
112 cout << " Support plate Z position: " << getSupportZPosition() << " " << s_unitName << endl;
113 cout << " Support plate backwalls height: " << getSupportBackWallHeight() << " " << s_unitName << endl;
114 cout << " Support plate backwall thickness: " << getSupportBackWallThickness() << " " << s_unitName << endl;
115 cout << " Support plate module hole size: " << getModuleHoleSize() << " X " << getModuleHoleSize() << " " << s_unitName << endl;
116 cout << " Support plate material: " << getSupportMaterial() << endl;
117
118 cout << "Positioning parameters (in local ARICH frame)" << endl;
120
121}
virtual void printPlacement(double x, double y, double z, double rx, double ry, double rz) const
Print volume positioning parameters.
Definition: ARICHGeoBase.cc:25
virtual void print(const std::string &title) const
Print the content of the class.
Definition: ARICHGeoBase.cc:20
static std::string s_unitName
conversion unit name
Definition: ARICHGeoBase.h:84
unsigned getSlotRing(unsigned slotID) const
Get ring number of slot with slot ID.
bool isConsistent() const override
Check if parameters are consistent.
double m_supportZPosition
Z position of support plate (position of center of support tube, with Z length of: support plate thic...
double getSupportBackWallHeight() const
Get height of the aluminum walls between modules on the electronics side of aluminum support plate.
double getSupportBackWallThickness() const
Get thickness of aluminum walls between modules on the electronics side of aluminum support plate.
double m_innerR
inner radius of support plate
double getSupportThickness() const
Get support plate thickness.
unsigned getNRings() const
Get number of module slot rings.
double getSupportOuterR() const
Get support plate outer radius.
void setRingPar(const std::vector< std::pair< double, double > > &ringPar)
Set parameters of module slot rings (r of center of slots in ring, phi (angle) distance between modul...
double m_moduleHoleSize
size of module hole in support plate
unsigned pointSlotID(double x, double y) const
Get slot ID based on x-y coordinates.
double getSupportZPosition() const
Get Z position of support plate (start point in Z).
double m_ry
rotation around y axis
void print(const std::string &title="Detector plane parameters") const override
Print the content of the class.
double m_x
x position in local ARICH volume
double m_thickness
thickness of support plate
double getModuleHoleSize() const
Get size of module hole in support plate.
std::vector< std::pair< double, double > > m_slotPar
parameters of all module slots (radius, phi)
const std::string & getSupportMaterial() const
Get material of support plate.
std::vector< std::pair< double, double > > m_ringPar
parameters of module rings (radius, dPhi)
unsigned m_nSlots
number of HAPD module slots
double m_supportBackWallThickness
< thickness of aluminum walls on the back side (electronics side) of support plate
double m_outerR
outer radius of support plate
double getSupportInnerR() const
Get support plate inner radius.
unsigned m_nRings
number of HAPD module rings
double m_z
z position in local ARICH volume (position of center of detector plane tube, with Z length of: module...
double m_rz
rotation around z axis
double m_y
y position in local ARICH volume
unsigned getSlotIDFromSRF(unsigned sector, unsigned ring, unsigned azimuth) const
Get slot ID based on sector, ring, and azimuth.
double m_rx
rotation around x axis
double m_supportBackWallHeight
height of aluminum walls on the back side (electronics side) of support plate
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.