Belle II Software  release-05-01-25
TOPGeoPMTArray.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <top/dbobjects/TOPGeoPMTArray.h>
12 #include <iostream>
13 #include <TRandom.h>
14 
15 using namespace std;
16 
17 namespace Belle2 {
23  unsigned TOPGeoPMTArray::getPmtID(unsigned row, unsigned col) const
24  {
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;
28  }
29 
30  unsigned TOPGeoPMTArray::getRow(unsigned pmtID) const
31  {
32  if (pmtID == 0 or pmtID > getSize()) return 0;
33  return (pmtID - 1) / m_numColumns + 1;
34  }
35 
36  unsigned TOPGeoPMTArray::getColumn(unsigned pmtID) const
37  {
38  if (pmtID == 0 or pmtID > getSize()) return 0;
39  return (pmtID - 1) % m_numColumns + 1;
40  }
41 
42  int TOPGeoPMTArray::getPixelID(double x, double y, unsigned pmtID) const
43  {
44  if (pmtID == 0 or pmtID > getSize()) return 0;
45  pmtID--;
46 
47  unsigned col = m_pmt.getPixelColumn(x);
48  if (col == 0) return 0;
49  col--;
50 
51  unsigned row = m_pmt.getPixelRow(y);
52  if (row == 0) return 0;
53  row--;
54 
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;
58  }
59 
60  int TOPGeoPMTArray::getPixelID(unsigned pmtID, unsigned pmtPixelID) const
61  {
62  pmtID--;
63  if (pmtID >= getSize()) return 0;
64 
65  pmtPixelID--;
66  if (pmtPixelID >= m_pmt.getNumPixels()) return 0;
67 
68  unsigned col = pmtPixelID % m_pmt.getNumColumns();
69  unsigned row = pmtPixelID / m_pmt.getNumColumns();
70 
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;
74  }
75 
76  void TOPGeoPMTArray::generateDecoupledPMTs(double fraction)
77  {
78  if (fraction <= 0) return;
79 
80  for (unsigned i = 0; i < getSize(); i++) {
81  if (gRandom->Rndm() < fraction) setDecoupledPMT(i + 1);
82  }
83 
84  }
85 
86  bool TOPGeoPMTArray::isPMTDecoupled(unsigned pmtID) const
87  {
88  for (const auto& pmt : m_decoupledPMTs) {
89  if (pmtID == pmt) return true;
90  }
91  return false;
92  }
93 
94 
95  bool TOPGeoPMTArray::isConsistent() const
96  {
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;
107  return true;
108  }
109 
110  void TOPGeoPMTArray::print(const std::string& title) const
111  {
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) { // new version of payload
119  cout << " silicone cookies: thickness = " << getCookieThickness() << " "
120  << s_unitName << ", material = " << getCookieMaterial() << endl;
121  cout << " wavelength filter: thickness = " << getFilterThickness() << " "
122  << s_unitName << ", material = " << getFilterMaterial() << endl;
123  }
124  cout << " air gap (decoupled PMT's): " << getAirGap() << " " << s_unitName << endl;
125  cout << " optically decoupled PMT's:";
126  if (m_decoupledPMTs.empty()) {
127  cout << " None";
128  } else {
129  for (const auto& pmt : m_decoupledPMTs) cout << " " << pmt;
130  }
131  cout << endl;
132  cout << endl;
133  m_pmt.print();
134  }
135 
137 } // end Belle2 namespace
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19