Belle II Software development
PXDPixelThresholdPar.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
13namespace Belle2 {
18
21
22 class PXDPixelThresholdPar: public TObject {
23 public:
27 typedef std::unordered_map<unsigned int, unsigned short> SinglePixelThresholdsSet;
28
30 PXDPixelThresholdPar(unsigned short defaultThr = 7) : m_defaultThreshold(defaultThr), m_MapSingleThresholds() {}
31
34
41 void setSinglePixelThreshold(unsigned short sensorID, unsigned int pixID, unsigned short pixThr = 255)
42 {
43 auto mapIterSingles = m_MapSingleThresholds.find(sensorID);
44 if (mapIterSingles != m_MapSingleThresholds.end()) {
45 // Already some single pixel thresholds on sensor
46 auto& singles = mapIterSingles->second;
47 singles.insert(std::pair <unsigned int, unsigned short>(pixID, pixThr));
48 } else {
49 // Create an empty set of thresholds for single pixels
51 // pixID will be used to generate hash in unordered_map for quick access
52 singleThresholds.insert(std::pair <unsigned int, unsigned short>(pixID, pixThr));
53 m_MapSingleThresholds[sensorID] = singleThresholds;
54 }
55 }
56
62 unsigned short getPixelThreshold(unsigned short sensorID, unsigned int pixID) const
63 {
64 auto singleSensorThresholds = m_MapSingleThresholds.find(sensorID);
65 if (singleSensorThresholds != m_MapSingleThresholds.end()) {
66 // Found some masked single pixels on sensor
67 auto& singleThresholds = singleSensorThresholds->second;
68 // Look if this is a single masked pixel
69 auto singleThr = singleThresholds.find(pixID);
70 if (singleThr != singleThresholds.end()) {
71 return singleThr->second;
72 }
73 }
74 // Pixel not found in the threshold map
75 return m_defaultThreshold;
76 }
77
79 const std::unordered_map<unsigned short, SinglePixelThresholdsSet>& getPixelThresholdMap() const {return m_MapSingleThresholds;}
80
81 private:
82
84 unsigned short m_defaultThreshold;
85
87 std::unordered_map<unsigned short, SinglePixelThresholdsSet> m_MapSingleThresholds;
88
90 };
91
92} // end of namespace Belle2
unsigned short m_defaultThreshold
Default value for charge threshold.
void setSinglePixelThreshold(unsigned short sensorID, unsigned int pixID, unsigned short pixThr=255)
Set threshold for single pixel.
unsigned short getPixelThreshold(unsigned short sensorID, unsigned int pixID) const
Check whether a pixel on a given sensor is OK or not and get threshold.
PXDPixelThresholdPar(unsigned short defaultThr=7)
Default constructor.
std::unordered_map< unsigned int, unsigned short > SinglePixelThresholdsSet
Structure to hold set of single pixels indexed by their unique id (unsigned int), stored in hash tabl...
std::unordered_map< unsigned short, SinglePixelThresholdsSet > m_MapSingleThresholds
Structure holding sets of masked single pixels for all sensors by sensor id (unsigned short).
const std::unordered_map< unsigned short, SinglePixelThresholdsSet > & getPixelThresholdMap() const
Return unordered_map with all masked single pixels in PXD.
ClassDef(PXDPixelThresholdPar, 1)
ClassDef.
Abstract base class for different kinds of events.