Belle II Software development
PXDMaskedPixelPar.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 {
24 class PXDMaskedPixelPar: public TObject {
25 public:
27 typedef std::unordered_set< unsigned int> MaskedSinglePixelsSet;
28
33
39 void maskSinglePixel(unsigned short sensorID, unsigned int pixID)
40 {
41 auto mapIterSingles = m_MapSingles.find(sensorID);
42 if (mapIterSingles != m_MapSingles.end()) {
43 // Already some masked single pixels on sensor
44 auto& singles = mapIterSingles->second;
45 // Only add pixel, if it is not already in
46 if (singles.find(pixID) == singles.end())
47 singles.insert(pixID);
48 } else {
49 // Create an empty set of masked single pixels
51 // pixID will be used to generate hash in unordered_set for quick access
52 singles.insert(pixID);
53 m_MapSingles[sensorID] = singles;
54 }
55 }
56
62 bool pixelOK(unsigned short sensorID, unsigned int pixID) const
63 {
64 auto mapIterSingles = m_MapSingles.find(sensorID);
65 if (mapIterSingles != m_MapSingles.end()) {
66 // Found some masked single pixels on sensor
67 auto& singles = mapIterSingles->second;
68 // Look if this is a single masked pixel
69 if (singles.find(pixID) != singles.end())
70 return false;
71 }
72 // Pixel not found in the mask => pixel OK
73 return true;
74 }
75
77 const std::unordered_map<unsigned short, MaskedSinglePixelsSet>& getMaskedPixelMap() const {return m_MapSingles;}
78
79 private:
80
82 std::unordered_map<unsigned short, MaskedSinglePixelsSet> m_MapSingles;
83
85 };
87} // end of namespace Belle2
The payload telling which PXD pixel to mask (ignore)
std::unordered_map< unsigned short, MaskedSinglePixelsSet > m_MapSingles
Structure holding sets of masked single pixels for all sensors by sensor id (unsigned short).
bool pixelOK(unsigned short sensorID, unsigned int pixID) const
Check whether a pixel on a given sensor is OK or not.
const std::unordered_map< unsigned short, MaskedSinglePixelsSet > & getMaskedPixelMap() const
Return unordered_map with all masked single pixels in PXD.
std::unordered_set< unsigned int > MaskedSinglePixelsSet
Structure to hold set of masked single pixels indexed by their unique id (unsigned int),...
void maskSinglePixel(unsigned short sensorID, unsigned int pixID)
Mask single pixel.
PXDMaskedPixelPar()
Default constructor.
ClassDef(PXDMaskedPixelPar, 1)
ClassDef, must be the last term before the closing {}.
Abstract base class for different kinds of events.