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