11 #include <top/dbobjects/TOPGeoPMTArray.h>
23 unsigned TOPGeoPMTArray::getPmtID(
unsigned row,
unsigned col)
const
25 if (row == 0 or row > m_numRows)
return 0;
26 if (col == 0 or col > m_numColumns)
return 0;
27 return (row - 1) * m_numColumns + col;
30 unsigned TOPGeoPMTArray::getRow(
unsigned pmtID)
const
32 if (pmtID == 0 or pmtID > getSize())
return 0;
33 return (pmtID - 1) / m_numColumns + 1;
36 unsigned TOPGeoPMTArray::getColumn(
unsigned pmtID)
const
38 if (pmtID == 0 or pmtID > getSize())
return 0;
39 return (pmtID - 1) % m_numColumns + 1;
42 int TOPGeoPMTArray::getPixelID(
double x,
double y,
unsigned pmtID)
const
44 if (pmtID == 0 or pmtID > getSize())
return 0;
47 unsigned col = m_pmt.getPixelColumn(x);
48 if (col == 0)
return 0;
51 unsigned row = m_pmt.getPixelRow(y);
52 if (row == 0)
return 0;
55 col += (pmtID % m_numColumns) * m_pmt.getNumColumns();
56 row += (pmtID / m_numColumns) * m_pmt.getNumRows();
57 return row * m_numColumns * m_pmt.getNumColumns() + col + 1;
60 int TOPGeoPMTArray::getPixelID(
unsigned pmtID,
unsigned pmtPixelID)
const
63 if (pmtID >= getSize())
return 0;
66 if (pmtPixelID >= m_pmt.getNumPixels())
return 0;
68 unsigned col = pmtPixelID % m_pmt.getNumColumns();
69 unsigned row = pmtPixelID / m_pmt.getNumColumns();
71 col += (pmtID % m_numColumns) * m_pmt.getNumColumns();
72 row += (pmtID / m_numColumns) * m_pmt.getNumRows();
73 return row * m_numColumns * m_pmt.getNumColumns() + col + 1;
76 void TOPGeoPMTArray::generateDecoupledPMTs(
double fraction)
78 if (fraction <= 0)
return;
80 for (
unsigned i = 0; i < getSize(); i++) {
81 if (gRandom->Rndm() < fraction) setDecoupledPMT(i + 1);
86 bool TOPGeoPMTArray::isPMTDecoupled(
unsigned pmtID)
const
88 for (
const auto& pmt : m_decoupledPMTs) {
89 if (pmtID == pmt)
return true;
95 bool TOPGeoPMTArray::isConsistent()
const
97 if (m_numRows == 0)
return false;
98 if (m_numColumns == 0)
return false;
99 if (m_dx <= 0)
return false;
100 if (m_dy <= 0)
return false;
101 if (m_material.empty())
return false;
102 if (!m_pmt.isConsistent())
return false;
103 if (m_cookieThickness <= 0)
return false;
104 if (m_cookieMaterial.empty())
return false;
105 if (m_filterThickness <= 0)
return false;
106 if (m_filterMaterial.empty())
return false;
110 void TOPGeoPMTArray::print(
const std::string& title)
const
112 TOPGeoBase::print(title);
113 cout <<
" size: " << getNumColumns() <<
" X " << getNumRows();
114 cout <<
", dimensions: " << getSizeX() <<
" X " << getSizeY() <<
" X " << getSizeZ();
115 cout <<
" " << s_unitName << endl;
116 cout <<
" cell: " << getDx() <<
" X " << getDy() <<
" " << s_unitName << endl;
117 cout <<
" material: " << getMaterial() << endl;
118 if (m_cookieThickness > 0) {
119 cout <<
" silicone cookies: thickness = " << getCookieThickness() <<
" "
120 << s_unitName <<
", material = " << getCookieMaterial() << endl;
121 cout <<
" wavelength filter: thickness = " << getFilterThickness() <<
" "
122 << s_unitName <<
", material = " << getFilterMaterial() << endl;
124 cout <<
" air gap (decoupled PMT's): " << getAirGap() <<
" " << s_unitName << endl;
125 cout <<
" optically decoupled PMT's:";
126 if (m_decoupledPMTs.empty()) {
129 for (
const auto& pmt : m_decoupledPMTs) cout <<
" " << pmt;