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