Belle II Software  release-08-01-10
PXDPixelMasker.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 
10 #include <pxd/reconstruction/PXDPixelMasker.h>
11 #include <vxd/geometry/GeoCache.h>
12 
13 
14 using namespace std;
15 
16 
18 {
19  m_maskedPixelsFromDB = unique_ptr<Belle2::DBObjPtr<Belle2::PXDMaskedPixelPar>>(new Belle2::DBObjPtr<Belle2::PXDMaskedPixelPar>());
20 
21  if ((*m_maskedPixelsFromDB).isValid()) {
22  setMaskedPixels();
23  (*m_maskedPixelsFromDB).addCallback(this, &Belle2::PXD::PXDPixelMasker::setMaskedPixels);
24  }
25 
26  m_deadPixelsFromDB = unique_ptr<Belle2::DBObjPtr<Belle2::PXDDeadPixelPar>>(new Belle2::DBObjPtr<Belle2::PXDDeadPixelPar>());
27 
28  if ((*m_deadPixelsFromDB).isValid()) {
29  setDeadPixels();
30  (*m_deadPixelsFromDB).addCallback(this, &Belle2::PXD::PXDPixelMasker::setDeadPixels);
31  }
32 }
33 
34 
36 {
37  static std::unique_ptr<Belle2::PXD::PXDPixelMasker> instance(new Belle2::PXD::PXDPixelMasker());
38  return *instance;
39 }
40 
41 
42 void Belle2::PXD::PXDPixelMasker::maskSinglePixel(Belle2::VxdID id, unsigned int uid, unsigned int vid)
43 {
44  auto vCells = Belle2::VXD::GeoCache::getInstance().get(id).getVCells();
45  m_maskedPixels.maskSinglePixel(id.getID(), uid * vCells + vid);
46 }
47 
48 
49 
50 bool Belle2::PXD::PXDPixelMasker::pixelOK(Belle2::VxdID id, unsigned int uid, unsigned int vid) const
51 {
52  auto vCells = Belle2::VXD::GeoCache::getInstance().get(id).getVCells();
53  return m_maskedPixels.pixelOK(id.getID(), uid * vCells + vid);
54 }
55 
56 bool Belle2::PXD::PXDPixelMasker::pixelDead(Belle2::VxdID id, unsigned int uid, unsigned int vid) const
57 {
58  auto sensorID = id.getID();
59  if (m_deadPixels.isDeadSensor(sensorID))
60  return true;
61 
62  if (m_deadPixels.isDeadRow(sensorID, vid))
63  return true;
64 
65  if (m_deadPixels.isDeadDrain(sensorID, uid * 4 + vid % 4))
66  return true;
67 
68  auto vCells = Belle2::VXD::GeoCache::getInstance().get(id).getVCells();
69  if (m_deadPixels.isDeadSinglePixel(sensorID, uid * vCells + vid))
70  return true;
71 
72  return false;
73 }
74 
75 
77 {
78  m_maskedPixels = **m_maskedPixelsFromDB;
79 }
80 
82 {
83  m_deadPixels = **m_deadPixelsFromDB;
84 }
85 
86 
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Singleton class for managing pixel masking for the PXD.
bool pixelDead(VxdID id, unsigned int uid, unsigned int vid) const
Check whether a pixel on a given sensor is dead or not.
void initialize()
Initialize the PXDPixelMasker.
bool pixelOK(VxdID id, unsigned int uid, unsigned int vid) const
Check whether a pixel on a given sensor is OK or not.
void maskSinglePixel(VxdID id, unsigned int uid, unsigned int vid)
Mask single pixel.
void setMaskedPixels()
Set masked pixels from DB.
void setDeadPixels()
Set dead pixels from DB.
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
int getVCells() const
Return number of pixel/strips in v direction.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60