Belle II Software development
PXDDeadPixelPar.h
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#pragma once
9
10#include <TObject.h>
11#include <unordered_map>
12#include <unordered_set>
13
14
15namespace Belle2 {
33 class PXDDeadPixelPar: public TObject {
34 public:
36 typedef std::unordered_set< unsigned int> DeadChannelSet;
37
40
45 void maskSensor(unsigned short sensorID)
46 {
47 auto mapIter = m_MapSensors.find(sensorID);
48 if (mapIter == m_MapSensors.end()) {
49 // Sensor not already masked as dead. Mask it.
50 m_MapSensors.insert(sensorID);
51 }
52 }
53
59 void maskDrain(unsigned short sensorID, unsigned int drainID)
60 {
61 auto mapIter = m_MapDrains.find(sensorID);
62 if (mapIter != m_MapDrains.end()) {
63 // Already some masked drain on sensor
64 auto& drains = mapIter->second;
65 // Only add drain, if it is not already in
66 if (drains.find(drainID) == drains.end())
67 drains.insert(drainID);
68 } else {
69 // Create an empty set of masked drains
71 // drainID will be used to generate hash in unordered_set for quick access
72 drains.insert(drainID);
73 m_MapDrains[sensorID] = drains;
74 }
75 }
76
82 void maskRow(unsigned short sensorID, unsigned int vCellID)
83 {
84 auto mapIter = m_MapRows.find(sensorID);
85 if (mapIter != m_MapRows.end()) {
86 // Already some masked rows on sensor
87 auto& rows = mapIter->second;
88 // Only add row, if it is not already in
89 if (rows.find(vCellID) == rows.end())
90 rows.insert(vCellID);
91 } else {
92 // Create an empty set of masked rows
94 // vCellID will be used to generate hash in unordered_set for quick access
95 rows.insert(vCellID);
96 m_MapRows[sensorID] = rows;
97 }
98 }
99
105 void maskSinglePixel(unsigned short sensorID, unsigned int pixID)
106 {
107 auto mapIter = m_MapSingles.find(sensorID);
108 if (mapIter != m_MapSingles.end()) {
109 // Already some masked single pixels on sensor
110 auto& singles = mapIter->second;
111 // Only add pixel, if it is not already in
112 if (singles.find(pixID) == singles.end())
113 singles.insert(pixID);
114 } else {
115 // Create an empty set of masked single pixels
117 // pixID will be used to generate hash in unordered_set for quick access
118 singles.insert(pixID);
119 m_MapSingles[sensorID] = singles;
120 }
121 }
122
127 bool isDeadSensor(unsigned short sensorID) const
128 {
129 if (m_MapSensors.find(sensorID) == m_MapSensors.end()) {
130 return false;
131 }
132 return true;
133 }
134
140 bool isDeadRow(unsigned short sensorID, unsigned int vCellID) const
141 {
142 auto mapIter = m_MapRows.find(sensorID);
143 if (mapIter != m_MapRows.end()) {
144 // Found some dead rows
145 auto& deadRows = mapIter->second;
146 // Look if this row is dead
147 if (deadRows.find(vCellID) != deadRows.end())
148 return true;
149 }
150 return false;
151 }
152
158 bool isDeadDrain(unsigned short sensorID, unsigned int drainID) const
159 {
160 auto mapIter = m_MapDrains.find(sensorID);
161 if (mapIter != m_MapDrains.end()) {
162 // Found some dead drains
163 auto& deadDrains = mapIter->second;
164 // Look if this drain is dead
165 if (deadDrains.find(drainID) != deadDrains.end())
166 return true;
167 }
168 return false;
169 }
170
176 bool isDeadSinglePixel(unsigned short sensorID, unsigned int pixID) const
177 {
178 auto mapIter = m_MapSingles.find(sensorID);
179 if (mapIter != m_MapSingles.end()) {
180 // Found some dead singles
181 auto& deadSingles = mapIter->second;
182 // Look if this single is dead
183 if (deadSingles.find(pixID) != deadSingles.end())
184 return true;
185 }
186 return false;
187 }
188
190 const std::unordered_map<unsigned short, DeadChannelSet>& getDeadSinglePixelMap() const {return m_MapSingles;}
191
193 const std::unordered_map<unsigned short, DeadChannelSet>& getDeadDrainMap() const {return m_MapDrains;}
194
196 const std::unordered_map<unsigned short, DeadChannelSet>& getDeadRowMap() const {return m_MapRows;}
197
199 const std::unordered_set< unsigned int>& getDeadSensorMap() const {return m_MapSensors;}
200
201 private:
202
204 std::unordered_map<unsigned short, DeadChannelSet> m_MapSingles;
205
207 std::unordered_map<unsigned short, DeadChannelSet> m_MapRows;
208
210 std::unordered_map<unsigned short, DeadChannelSet> m_MapDrains;
211
213 std::unordered_set< unsigned int> m_MapSensors;
214
216 };
218} // end of namespace Belle2
The payload telling which PXD pixel is dead (=Readout system does not receive signals)
void maskSensor(unsigned short sensorID)
Mask sensor.
const std::unordered_map< unsigned short, DeadChannelSet > & getDeadSinglePixelMap() const
Return unordered_map with all dead single pixels in PXD.
const std::unordered_map< unsigned short, DeadChannelSet > & getDeadRowMap() const
Return unordered_map with all dead drains in PXD.
std::unordered_map< unsigned short, DeadChannelSet > m_MapRows
Structure holding sets of dead rows for all sensors by sensor id (unsigned short).
void maskRow(unsigned short sensorID, unsigned int vCellID)
Mask single row.
const std::unordered_map< unsigned short, DeadChannelSet > & getDeadDrainMap() const
Return unordered_map with all dead rows in PXD.
std::unordered_map< unsigned short, DeadChannelSet > m_MapDrains
Structure holding sets of dead drains for all sensors by sensor id (unsigned short).
std::unordered_set< unsigned int > m_MapSensors
Structure holding dead sensors by sensor id.
bool isDeadSensor(unsigned short sensorID) const
Check whether a sensor is dead.
std::unordered_set< unsigned int > DeadChannelSet
Structure to hold set of dead channel indexed by their unique id (unsigned int), stored in hash table...
ClassDef(PXDDeadPixelPar, 2)
ClassDef, must be the last term before the closing {}.
void maskSinglePixel(unsigned short sensorID, unsigned int pixID)
Mask single pixel.
void maskDrain(unsigned short sensorID, unsigned int drainID)
Mask single drain.
bool isDeadSinglePixel(unsigned short sensorID, unsigned int pixID) const
Check whether a single pixel is dead.
std::unordered_map< unsigned short, DeadChannelSet > m_MapSingles
Structure holding sets of dead single pixels for all sensors by sensor id (unsigned short).
bool isDeadDrain(unsigned short sensorID, unsigned int drainID) const
Check whether a drain is dead.
PXDDeadPixelPar()
Default constructor.
const std::unordered_set< unsigned int > & getDeadSensorMap() const
Return unordered_set with all dead sensors in PXD.
bool isDeadRow(unsigned short sensorID, unsigned int vCellID) const
Check whether a row is dead.
Abstract base class for different kinds of events.