Belle II Software  release-05-01-25
PXDDeadPixelPar.h
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 #pragma once
11 
12 #include <TObject.h>
13 #include <unordered_map>
14 #include <unordered_set>
15 
16 
17 namespace Belle2 {
35  class PXDDeadPixelPar: public TObject {
36  public:
38  typedef std::unordered_set< unsigned int> DeadChannelSet;
39 
42 
47  void maskSensor(unsigned short sensorID)
48  {
49  auto mapIter = m_MapSensors.find(sensorID);
50  if (mapIter == m_MapSensors.end()) {
51  // Sensor not already masked as dead. Mask it.
52  m_MapSensors.insert(sensorID);
53  }
54  }
55 
61  void maskDrain(unsigned short sensorID, unsigned int drainID)
62  {
63  auto mapIter = m_MapDrains.find(sensorID);
64  if (mapIter != m_MapDrains.end()) {
65  // Already some masked drain on sensor
66  auto& drains = mapIter->second;
67  // Only add drain, if it is not already in
68  if (drains.find(drainID) == drains.end())
69  drains.insert(drainID);
70  } else {
71  // Create an empty set of masked drains
73  // drainID will be used to generate hash in unordered_set for quick access
74  drains.insert(drainID);
75  m_MapDrains[sensorID] = drains;
76  }
77  }
78 
84  void maskRow(unsigned short sensorID, unsigned int vCellID)
85  {
86  auto mapIter = m_MapRows.find(sensorID);
87  if (mapIter != m_MapRows.end()) {
88  // Already some masked rows on sensor
89  auto& rows = mapIter->second;
90  // Only add row, if it is not already in
91  if (rows.find(vCellID) == rows.end())
92  rows.insert(vCellID);
93  } else {
94  // Create an empty set of masked rows
96  // vCellID will be used to generate hash in unordered_set for quick access
97  rows.insert(vCellID);
98  m_MapRows[sensorID] = rows;
99  }
100  }
101 
107  void maskSinglePixel(unsigned short sensorID, unsigned int pixID)
108  {
109  auto mapIter = m_MapSingles.find(sensorID);
110  if (mapIter != m_MapSingles.end()) {
111  // Already some masked single pixels on sensor
112  auto& singles = mapIter->second;
113  // Only add pixel, if it is not already in
114  if (singles.find(pixID) == singles.end())
115  singles.insert(pixID);
116  } else {
117  // Create an empty set of masked single pixels
119  // pixID will be used to generate hash in unordered_set for quick access
120  singles.insert(pixID);
121  m_MapSingles[sensorID] = singles;
122  }
123  }
124 
129  bool isDeadSensor(unsigned short sensorID) const
130  {
131  if (m_MapSensors.find(sensorID) == m_MapSensors.end()) {
132  return false;
133  }
134  return true;
135  }
136 
142  bool isDeadRow(unsigned short sensorID, unsigned int vCellID) const
143  {
144  auto mapIter = m_MapRows.find(sensorID);
145  if (mapIter != m_MapRows.end()) {
146  // Found some dead rows
147  auto& deadRows = mapIter->second;
148  // Look if this row is dead
149  if (deadRows.find(vCellID) != deadRows.end())
150  return true;
151  }
152  return false;
153  }
154 
160  bool isDeadDrain(unsigned short sensorID, unsigned int drainID) const
161  {
162  auto mapIter = m_MapDrains.find(sensorID);
163  if (mapIter != m_MapDrains.end()) {
164  // Found some dead drains
165  auto& deadDrains = mapIter->second;
166  // Look if this drain is dead
167  if (deadDrains.find(drainID) != deadDrains.end())
168  return true;
169  }
170  return false;
171  }
172 
178  bool isDeadSinglePixel(unsigned short sensorID, unsigned int pixID) const
179  {
180  auto mapIter = m_MapSingles.find(sensorID);
181  if (mapIter != m_MapSingles.end()) {
182  // Found some dead singles
183  auto& deadSingles = mapIter->second;
184  // Look if this single is dead
185  if (deadSingles.find(pixID) != deadSingles.end())
186  return true;
187  }
188  return false;
189  }
190 
192  const std::unordered_map<unsigned short, DeadChannelSet>& getDeadSinglePixelMap() const {return m_MapSingles;}
193 
195  const std::unordered_map<unsigned short, DeadChannelSet>& getDeadDrainMap() const {return m_MapDrains;}
196 
198  const std::unordered_map<unsigned short, DeadChannelSet>& getDeadRowMap() const {return m_MapRows;}
199 
201  const std::unordered_set< unsigned int>& getDeadSensorMap() const {return m_MapSensors;}
202 
203  private:
204 
206  std::unordered_map<unsigned short, DeadChannelSet> m_MapSingles;
207 
209  std::unordered_map<unsigned short, DeadChannelSet> m_MapRows;
210 
212  std::unordered_map<unsigned short, DeadChannelSet> m_MapDrains;
213 
215  std::unordered_set< unsigned int> m_MapSensors;
216 
218  };
220 } // end of namespace Belle2
Belle2::PXDDeadPixelPar::m_MapDrains
std::unordered_map< unsigned short, DeadChannelSet > m_MapDrains
Structure holding sets of dead drains for all sensors by sensor id (unsigned short).
Definition: PXDDeadPixelPar.h:220
Belle2::PXDDeadPixelPar::maskDrain
void maskDrain(unsigned short sensorID, unsigned int drainID)
Mask single drain.
Definition: PXDDeadPixelPar.h:69
Belle2::PXDDeadPixelPar::isDeadSensor
bool isDeadSensor(unsigned short sensorID) const
Check whether a sensor is dead.
Definition: PXDDeadPixelPar.h:137
Belle2::PXDDeadPixelPar::ClassDef
ClassDef(PXDDeadPixelPar, 2)
ClassDef, must be the last term before the closing {}.
Belle2::PXDDeadPixelPar::DeadChannelSet
std::unordered_set< unsigned int > DeadChannelSet
Structure to hold set of dead channel indexed by their unique id (unsigned int), stored in hash table...
Definition: PXDDeadPixelPar.h:46
Belle2::PXDDeadPixelPar::isDeadRow
bool isDeadRow(unsigned short sensorID, unsigned int vCellID) const
Check whether a row is dead.
Definition: PXDDeadPixelPar.h:150
Belle2::PXDDeadPixelPar::m_MapSingles
std::unordered_map< unsigned short, DeadChannelSet > m_MapSingles
Structure holding sets of dead single pixels for all sensors by sensor id (unsigned short).
Definition: PXDDeadPixelPar.h:214
Belle2::PXDDeadPixelPar::m_MapRows
std::unordered_map< unsigned short, DeadChannelSet > m_MapRows
Structure holding sets of dead rows for all sensors by sensor id (unsigned short).
Definition: PXDDeadPixelPar.h:217
Belle2::PXDDeadPixelPar::isDeadSinglePixel
bool isDeadSinglePixel(unsigned short sensorID, unsigned int pixID) const
Check whether a single pixel is dead.
Definition: PXDDeadPixelPar.h:186
Belle2::PXDDeadPixelPar::maskSensor
void maskSensor(unsigned short sensorID)
Mask sensor.
Definition: PXDDeadPixelPar.h:55
Belle2::PXDDeadPixelPar::PXDDeadPixelPar
PXDDeadPixelPar()
Default constructor.
Definition: PXDDeadPixelPar.h:49
Belle2::PXDDeadPixelPar
The payload telling which PXD pixel is dead (=Readout system does not receive signals)
Definition: PXDDeadPixelPar.h:43
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PXDDeadPixelPar::maskSinglePixel
void maskSinglePixel(unsigned short sensorID, unsigned int pixID)
Mask single pixel.
Definition: PXDDeadPixelPar.h:115
Belle2::PXDDeadPixelPar::m_MapSensors
std::unordered_set< unsigned int > m_MapSensors
Structure holding dead sensors by sensor id.
Definition: PXDDeadPixelPar.h:223
Belle2::PXDDeadPixelPar::getDeadDrainMap
const std::unordered_map< unsigned short, DeadChannelSet > & getDeadDrainMap() const
Return unordered_map with all dead rows in PXD.
Definition: PXDDeadPixelPar.h:203
Belle2::PXDDeadPixelPar::getDeadSinglePixelMap
const std::unordered_map< unsigned short, DeadChannelSet > & getDeadSinglePixelMap() const
Return unordered_map with all dead single pixels in PXD.
Definition: PXDDeadPixelPar.h:200
Belle2::PXDDeadPixelPar::isDeadDrain
bool isDeadDrain(unsigned short sensorID, unsigned int drainID) const
Check whether a drain is dead.
Definition: PXDDeadPixelPar.h:168
Belle2::PXDDeadPixelPar::getDeadSensorMap
const std::unordered_set< unsigned int > & getDeadSensorMap() const
Return unordered_set with all dead sensors in PXD.
Definition: PXDDeadPixelPar.h:209
Belle2::PXDDeadPixelPar::getDeadRowMap
const std::unordered_map< unsigned short, DeadChannelSet > & getDeadRowMap() const
Return unordered_map with all dead drains in PXD.
Definition: PXDDeadPixelPar.h:206
Belle2::PXDDeadPixelPar::maskRow
void maskRow(unsigned short sensorID, unsigned int vCellID)
Mask single row.
Definition: PXDDeadPixelPar.h:92