Belle II Software  release-08-01-10
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 
13 using namespace std;
14 
15 namespace 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 
74  void TOPGeoPMTArray::generateDecoupledPMTs(double fraction)
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 
93  bool TOPGeoPMTArray::isConsistent() const
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
Abstract base class for different kinds of events.