Belle II Software development
TOPGeoPMTArray.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 <top/dbobjects/TOPGeoPMTArray.h>
10#include <iostream>
11#include <TRandom.h>
12
13using namespace std;
14
15namespace Belle2 {
21 unsigned TOPGeoPMTArray::getPmtID(unsigned row, unsigned col) const
22 {
23 if (row == 0 or row > m_numRows) return 0;
24 if (col == 0 or col > m_numColumns) return 0;
25 return (row - 1) * m_numColumns + col;
26 }
27
28 unsigned TOPGeoPMTArray::getRow(unsigned pmtID) const
29 {
30 if (pmtID == 0 or pmtID > getSize()) return 0;
31 return (pmtID - 1) / m_numColumns + 1;
32 }
33
34 unsigned TOPGeoPMTArray::getColumn(unsigned pmtID) const
35 {
36 if (pmtID == 0 or pmtID > getSize()) return 0;
37 return (pmtID - 1) % m_numColumns + 1;
38 }
39
40 int TOPGeoPMTArray::getPixelID(double x, double y, unsigned pmtID) const
41 {
42 if (pmtID == 0 or pmtID > getSize()) return 0;
43 pmtID--;
44
45 unsigned col = m_pmt.getPixelColumn(x);
46 if (col == 0) return 0;
47 col--;
48
49 unsigned row = m_pmt.getPixelRow(y);
50 if (row == 0) return 0;
51 row--;
52
53 col += (pmtID % m_numColumns) * m_pmt.getNumColumns();
54 row += (pmtID / m_numColumns) * m_pmt.getNumRows();
55 return row * m_numColumns * m_pmt.getNumColumns() + col + 1;
56 }
57
58 int TOPGeoPMTArray::getPixelID(unsigned pmtID, unsigned pmtPixelID) const
59 {
60 pmtID--;
61 if (pmtID >= getSize()) return 0;
62
63 pmtPixelID--;
64 if (pmtPixelID >= m_pmt.getNumPixels()) return 0;
65
66 unsigned col = pmtPixelID % m_pmt.getNumColumns();
67 unsigned row = pmtPixelID / m_pmt.getNumColumns();
68
69 col += (pmtID % m_numColumns) * m_pmt.getNumColumns();
70 row += (pmtID / m_numColumns) * m_pmt.getNumRows();
71 return row * m_numColumns * m_pmt.getNumColumns() + col + 1;
72 }
73
75 {
76 if (fraction <= 0) return;
77
78 for (unsigned i = 0; i < getSize(); i++) {
79 if (gRandom->Rndm() < fraction) setDecoupledPMT(i + 1);
80 }
81
82 }
83
84 bool TOPGeoPMTArray::isPMTDecoupled(unsigned pmtID) const
85 {
86 for (const auto& pmt : m_decoupledPMTs) {
87 if (pmtID == pmt) return true;
88 }
89 return false;
90 }
91
92
94 {
95 if (m_numRows == 0) return false;
96 if (m_numColumns == 0) return false;
97 if (m_dx <= 0) return false;
98 if (m_dy <= 0) return false;
99 if (m_material.empty()) return false;
100 if (!m_pmt.isConsistent()) return false;
101 if (m_cookieThickness <= 0) return false;
102 if (m_cookieMaterial.empty()) return false;
103 if (m_filterThickness <= 0) return false;
104 if (m_filterMaterial.empty()) return false;
105 return true;
106 }
107
108 void TOPGeoPMTArray::print(const std::string& title) const
109 {
110 TOPGeoBase::print(title);
111 cout << " size: " << getNumColumns() << " X " << getNumRows();
112 cout << ", dimensions: " << getSizeX() << " X " << getSizeY() << " X " << getSizeZ();
113 cout << " " << s_unitName << endl;
114 cout << " cell: " << getDx() << " X " << getDy() << " " << s_unitName << endl;
115 cout << " material: " << getMaterial() << endl;
116 if (m_cookieThickness > 0) { // new version of payload
117 cout << " silicone cookies: thickness = " << getCookieThickness() << " "
118 << s_unitName << ", material = " << getCookieMaterial() << endl;
119 cout << " wavelength filter: thickness = " << getFilterThickness() << " "
120 << s_unitName << ", material = " << getFilterMaterial() << endl;
121 }
122 cout << " air gap (decoupled PMT's): " << getAirGap() << " " << s_unitName << endl;
123 cout << " optically decoupled PMT's:";
124 if (m_decoupledPMTs.empty()) {
125 cout << " None";
126 } else {
127 for (const auto& pmt : m_decoupledPMTs) cout << " " << pmt;
128 }
129 cout << endl;
130 cout << endl;
131 m_pmt.print();
132 }
133
135} // end Belle2 namespace
const std::string & getCookieMaterial() const
Returns silicone cookie material.
double getSizeZ() const
Returns array volume dimension in z.
unsigned getNumColumns() const
Returns number of array columns.
unsigned m_numColumns
number of columns
std::vector< unsigned > m_decoupledPMTs
ID's of decoupled PMT's.
std::string m_cookieMaterial
silicone cookie material
void setDecoupledPMT(unsigned pmtID)
Sets PMT as optically decoupled.
std::string m_material
material name into which PMT's are inserted
double getDx() const
Returns spacing in x (column width)
double getFilterThickness() const
Returns wavelength filter thickness.
float m_dy
spacing in y
std::string m_filterMaterial
wavelength filter material
unsigned m_numRows
number of rows
unsigned getSize() const
Returns array size.
float m_dx
spacing in x
double getDy() const
Returns spacing in y (row height)
double getSizeX() const
Returns array volume dimension in x.
const std::string & getFilterMaterial() const
Returns wavelenght filter material.
double getSizeY() const
Returns array volume dimension in y.
float m_filterThickness
wavelength filter thickness
TOPGeoPMT m_pmt
PMT geometry parameters.
const std::string & getMaterial() const
Returns material name into which PMT's are inserted.
float m_cookieThickness
silicone cookie thickness
unsigned getNumRows() const
Returns number of array rows.
double getCookieThickness() const
Returns silicone cookie thickness.
double getAirGap() const
Returns air gap.
unsigned getNumColumns() const
Returns number of pixel columns.
Definition: TOPGeoPMT.h:183
unsigned getNumPixels() const
Returns number of pixels.
Definition: TOPGeoPMT.h:195
unsigned getNumRows() const
Returns number of pixel rows.
Definition: TOPGeoPMT.h:189
bool isConsistent() const override
Check for consistency of data members.
void generateDecoupledPMTs(double fraction)
Generate randomly a fraction of PMT's to be optically decoupled.
void print(const std::string &title="PMT array geometry parameters") const override
Print the content of the class.
bool isPMTDecoupled(unsigned pmtID) const
Checks if PMT is optically decoupled.
void print(const std::string &title="MCP-PMT geometry parameters") const override
Print the content of the class.
Definition: TOPGeoPMT.cc:85
unsigned getRow(unsigned pmtID) const
Converts PMT ID to row number (1-based)
unsigned getColumn(unsigned pmtID) const
Converts PMT ID to column number (1-based)
virtual void print(const std::string &title) const
Print the content of the class.
Definition: TOPGeoBase.cc:28
unsigned getPixelColumn(double x) const
Converts x-coordinate to pixel column (1-based)
Definition: TOPGeoPMT.cc:21
int getPixelID(double x, double y, unsigned pmtID) const
Converts (digitizes) x, y and PMT ID to pixel ID (1-based)
unsigned getPmtID(unsigned row, unsigned col) const
Converts row and column numbers to PMT ID (1-based)
static std::string s_unitName
conversion unit name
Definition: TOPGeoBase.h:87
unsigned getPixelRow(double y) const
Converts y-coordinate to pixel row (1-based)
Definition: TOPGeoPMT.cc:29
Abstract base class for different kinds of events.
STL namespace.