Belle II Software  release-08-01-10
PixelPositions.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/reconstruction_cpp/PixelPositions.h>
10 #include <top/geometry/TOPGeometryPar.h>
11 #include <framework/logging/Logger.h>
12 #include <algorithm>
13 
14 namespace Belle2 {
19  namespace TOP {
20 
22  m_moduleID(moduleID)
23  {
24  const auto* geo = TOPGeometryPar::Instance()->getGeometry();
25  if (not geo->isModuleIDValid(moduleID)) {
26  B2FATAL("TOP::PixelPositions: invalid slot number, moduleID = " << moduleID);
27  return;
28  }
29 
30  const auto& module = geo->getModule(moduleID);
31  const auto& pmtArray = module.getPMTArray();
32  m_NRows = pmtArray.getNumPixelRows();
33  m_NColumns = pmtArray.getNumPixelColumns();
34 
35  const auto& prism = module.getPrism();
36  double Ah = prism.getWidth() / 2;
37  double yUp = prism.getThickness() / 2;
38  double yDown = yUp - prism.getExitThickness();
39 
40  const auto& pmtArrayDispl = module.getPMTArrayDisplacement();
41  double x0 = pmtArrayDispl.getX();
42  double y0 = pmtArrayDispl.getY() + (yUp + yDown) / 2;
43 
44  const auto& pmt = pmtArray.getPMT();
45  double a = pmt.getDx();
46  double b = pmt.getDy();
47 
48  std::vector<double> xCenters;
49  for (unsigned aColumn = 1; aColumn <= pmtArray.getNumColumns(); aColumn++) {
50  for (unsigned pmtColumn = 1; pmtColumn <= pmt.getNumColumns(); pmtColumn++) {
51  xCenters.push_back(pmtArray.getX(aColumn) + pmt.getX(pmtColumn) + x0);
52  }
53  }
54 
55  std::vector<double> yCenters;
56  for (unsigned aRow = 1; aRow <= pmtArray.getNumRows(); aRow++) {
57  for (unsigned pmtRow = 1; pmtRow <= pmt.getNumRows(); pmtRow++) {
58  yCenters.push_back(pmtArray.getY(aRow) + pmt.getY(pmtRow) + y0);
59  }
60  }
61 
62  for (auto y : yCenters) {
63  double y1 = std::max(y - b / 2, yDown);
64  double y2 = std::min(y + b / 2, yUp);
65  double Dy = std::max(y2 - y1, 0.0);
66  double yc = (Dy > 0) ? (y1 + y2) / 2 : y;
67  for (auto x : xCenters) {
68  double x1 = std::max(x - a / 2, -Ah);
69  double x2 = std::min(x + a / 2, Ah);
70  double Dx = std::max(x2 - x1, 0.0);
71  double xc = (Dx > 0) ? (x1 + x2) / 2 : x;
72  m_pixels.push_back(PixelData(xc, yc, Dx, Dy));
73  }
74  }
75 
76  const auto& mapper = TOPGeometryPar::Instance()->getChannelMapper();
77  for (size_t i = 0; i < m_pixels.size(); i++) {
78  int pixelID = i + 1;
79  m_pixels[i].ID = pixelID;
80  int pmtID = mapper.getPmtID(pixelID);
81  m_pixels[i].pmtType = TOPGeometryPar::Instance()->getPMTType(moduleID, pmtID);
82  }
83 
84  }
85 
86  } // TOP
88 } // Belle2
std::vector< PixelData > m_pixels
pixel positions and sizes, index = pixelID - 1
int pixelID(unsigned row, unsigned col) const
Transforms pixel row and column to pixel ID Note: for convenience pixel row and column numbering star...
PixelPositions(int moduleID)
Class constructor.
unsigned m_NColumns
number of pixel columns
unsigned m_NRows
number of pixel rows
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
unsigned getPMTType(int moduleID, int pmtID) const
Returns PMT type at a given position.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
const ChannelMapper & getChannelMapper() const
Returns default channel mapper (mapping of channels to pixels)
Abstract base class for different kinds of events.
position and size of a pixel