14#ifndef ALICEO2_ITSMFT_NOISEMAP_H
15#define ALICEO2_ITSMFT_NOISEMAP_H
43 NoiseMap(std::vector<std::map<int, int>>& noise) { mNoisyPixels.swap(noise); }
50 mNoisyPixels.assign(nchips, std::map<int, int>());
58 assert(chip < (
int)mNoisyPixels.size());
59 const auto keyIt = mNoisyPixels[chip].find(
getKey(
row,
col));
60 if (keyIt != mNoisyPixels[chip].
end()) {
68 assert(chip < (
int)mNoisyPixels.size());
74 assert(chip < (
int)mNoisyPixels.size());
75 auto& ch = mNoisyPixels[chip];
76 for (
const auto k : rowcolKey) {
84 auto chipID = mNoisyPixels.size();
86 const auto& map = mNoisyPixels[chipID];
87 for (
const auto& pair : map) {
88 if (pair.second <= t) {
92 auto key = pair.first;
95 std::cout <<
"chip, row, col, noise: " << chipID <<
' ' <<
row <<
' ' <<
col <<
' ' << pair.second <<
'\n';
105 void applyProbThreshold(
float t,
long int n,
float relErr = 0.2f,
int minChipID = 0,
int maxChipID = 24119)
110 LOGP(alarm,
"Cannot apply threshold with {} ROFs scanned",
n);
115 float minFiredForErr = 0.f;
117 minFiredForErr = relErr * relErr - 1. /
n;
118 if (minFiredForErr <= 0.f) {
119 LOGP(alarm,
"Noise threshold {} with relative error {} is not reachable with {} ROFs processed, mask all permanently fired pixels", t, relErr,
n);
122 minFiredForErr = 1. / minFiredForErr;
125 int minFired = std::ceil(std::max(t * mNumOfStrobes, minFiredForErr));
128 mProbThreshold = float(minFired) /
n;
129 LOGP(alarm,
"Requested relative error {} with prob.threshold {} needs > {} ROFs, {} provided: pixels with noise >{} will be masked", relErr, t, req,
n, mProbThreshold);
133 for (
auto& map : mNoisyPixels) {
134 if (currChipID < minChipID || currChipID > maxChipID) {
138 for (
auto it = map.begin(); it != map.end();) {
139 if (it->second < minFired) {
153 assert(chip < (
int)mNoisyPixels.size());
154 return (mNoisyPixels[chip].find(
getKey(
row,
col)) != mNoisyPixels[chip].
end());
159 assert(chip < (
int)mNoisyPixels.size());
165 assert(chip < (
int)mNoisyPixels.size());
166 return !mNoisyPixels[chip].empty();
171 void fill(
const gsl::span<const CompClusterExt>
data);
173 const std::map<int, int>*
getChipMap(
int chip)
const {
return chip < (
int)mNoisyPixels.size() ? &mNoisyPixels[chip] :
nullptr; }
175 std::map<int, int>&
getChip(
int chip) {
return mNoisyPixels[chip]; }
176 const std::map<int, int>&
getChip(
int chip)
const {
return mNoisyPixels[chip]; }
180 if (cleanNoisyPixels) {
193 assert(chip < (
int)mNoisyPixels.size());
194 mNoisyPixels[chip].clear();
200 relErr = relErr >= 0.f ? relErr : 0.1;
201 t = t >= 0.f ? t : 1e-6;
202 return std::ceil((1. + 1. / t) / (relErr * relErr));
208 for (
size_t i = 0;
i < (
int)mNoisyPixels.size(); ++
i) {
209 for (
const auto& prev_np : prev->mNoisyPixels[
i]) {
210 if (mNoisyPixels[
i].find(prev_np.first) == mNoisyPixels[
i].end()) {
211 mNoisyPixels[
i][prev_np.first] = prev_np.second;
216 return (mNoisyPixels);
219 size_t size()
const {
return mNoisyPixels.size(); }
228 static constexpr int SHIFT = 10, MASK = (0x1 << SHIFT) - 1;
229 std::vector<std::map<int, int>> mNoisyPixels;
230 long int mNumOfStrobes = 0;
231 float mProbThreshold = 0;
NoiseMap class for the ITS and MFT.
float getProbThreshold() const
bool isNoisy(int chip) const
long getNumberOfStrobes() const
NoiseMap merge(const NoiseMap *prev)
static int getKey(int row, int col)
int dumpAboveProbThreshold(float p=1e-7) const
bool isFullChipMasked(int chip) const
void increaseNoiseCount(int chip, int row, int col)
const std::map< int, int > * getChipMap(int chip) const
static int key2Col(int key)
void maskFullChip(int chip, bool cleanNoisyPixels=false)
static int key2Row(int key)
NoiseMap()=default
Constructor.
std::map< int, int > & getChip(int chip)
NoiseMap(std::vector< std::map< int, int > > &noise)
Constructor, initializing values for position, charge and readout frame.
void fill(const gsl::span< const CompClusterExt > data)
bool isNoisyOrFullyMasked(int chip, int row, int col) const
void applyProbThreshold(float t, long int n, float relErr=0.2f, int minChipID=0, int maxChipID=24119)
int dumpAboveThreshold(int t=3) const
const std::map< int, int > & getChip(int chip) const
void setNumOfStrobes(long n)
void increaseNoiseCount(int chip, const std::vector< int > &rowcolKey)
long int getNumOfStrobes() const
static long getMinROFs(float t, float relErr)
NoiseMap(int nchips)
Constructor.
float getNoiseLevel(int chip, int row, int col) const
Get the noise level for this pixels.
bool isNoisy(int chip, int row, int col) const
~NoiseMap()=default
Destructor.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...