Belle II Software development
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
14using namespace std;
15
16
39
40
42{
43 static std::unique_ptr<Belle2::PXD::PXDPixelMasker> instance(new Belle2::PXD::PXDPixelMasker());
44 return *instance;
45}
46
47void Belle2::PXD::PXDPixelMasker::setSinglePixelThreshold(Belle2::VxdID id, unsigned int uid, unsigned int vid,
48 unsigned short pixThr)
49{
51 m_pixelThresholds.setSinglePixelThreshold(id.getID(), uid * vCells + vid, pixThr);
52}
53
54void Belle2::PXD::PXDPixelMasker::maskSinglePixel(Belle2::VxdID id, unsigned int uid, unsigned int vid)
55{
57 m_maskedPixels.maskSinglePixel(id.getID(), uid * vCells + vid);
58}
59
60unsigned short Belle2::PXD::PXDPixelMasker::getPixelThreshold(Belle2::VxdID id, unsigned int uid, unsigned int vid) const
61{
63 return m_pixelThresholds.getPixelThreshold(id.getID(), uid * vCells + vid);
64}
65
66bool Belle2::PXD::PXDPixelMasker::pixelOK(Belle2::VxdID id, unsigned int uid, unsigned int vid) const
67{
69 return (m_pixelThresholds.getPixelThreshold(id.getID(), uid * vCells + vid) < 255);
70}
71
72bool Belle2::PXD::PXDPixelMasker::pixelDead(Belle2::VxdID id, unsigned int uid, unsigned int vid) const
73{
74 auto sensorID = id.getID();
75 if (m_deadPixels.isDeadSensor(sensorID))
76 return true;
77
78 if (m_deadPixels.isDeadRow(sensorID, vid))
79 return true;
80
81 if (m_deadPixels.isDeadDrain(sensorID, uid * 4 + vid % 4))
82 return true;
83
85 if (m_deadPixels.isDeadSinglePixel(sensorID, uid * vCells + vid))
86 return true;
87
88 return false;
89}
90
92{
93 auto maskedPixelMap = maskedPixels.getMaskedPixelMap();
94 for (auto maskedSingles = maskedPixelMap.begin(); maskedSingles != maskedPixelMap.end(); maskedSingles++) {
95 const auto& sensorID = maskedSingles->first;
96 const auto& singles = maskedSingles->second;
97 for (const auto& single : singles) {
98 m_pixelThresholds.setSinglePixelThreshold(sensorID, single, 255);
99 }
100 }
101}
102
107
112
117
118
The payload telling which PXD pixel to mask (ignore)
const std::unordered_map< unsigned short, MaskedSinglePixelsSet > & getMaskedPixelMap() const
Return unordered_map with all masked single pixels in PXD.
Singleton class for managing pixel masking for the PXD.
PXDMaskedPixelPar m_maskedPixels
List of masked pixels.
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.
unsigned short getPixelThreshold(VxdID id, unsigned int uid, unsigned int vid) const
Check whether a pixel on a given sensor is OK or not and get threshold.
void maskSinglePixel(VxdID id, unsigned int uid, unsigned int vid)
Mask single pixel.
void setMaskedPixels()
Set masked pixels from DB.
DBObjPtr< PXDMaskedPixelPar > m_maskedPixelsFromDB
Masked pixels retrieved from DB.
void setDeadPixels()
Set dead pixels from DB.
DBObjPtr< PXDPixelThresholdPar > m_pixelThresholdsFromDB
Pixel thresholds from DB.
void setSinglePixelThreshold(VxdID id, unsigned int uid, unsigned int vid, unsigned short pixThr)
Set threshold for single pixel.
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
DBObjPtr< PXDDeadPixelPar > m_deadPixelsFromDB
Dead pixels retrieved from DB.
PXDDeadPixelPar m_deadPixels
List of masked pixels.
void setPixelThresholds()
Set pixel threshold from DB.
PXDPixelThresholdPar m_pixelThresholds
List of pixel threshold.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
Definition GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition GeoCache.cc:214
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:32
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition calibTools.h:60
STL namespace.