Project
Loading...
Searching...
No Matches
Diagnostic.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
16#include <iostream>
17#include "Framework/Logger.h"
18
19using namespace o2::tof;
20
22
23uint32_t Diagnostic::fill(ULong64_t pattern)
24{
25 uint32_t frequency = 1;
26
27 auto pairC = mVector.find(pattern);
28
29 if (pairC != mVector.end()) {
30 frequency = (pairC->second)++;
31 } else {
32 mVector.emplace(std::make_pair(pattern, 1));
33 }
34
35 return frequency;
36}
37
38uint32_t Diagnostic::fill(ULong64_t pattern, uint32_t frequency)
39{
40 auto pairC = mVector.find(pattern);
41
42 if (pairC != mVector.end()) {
43 (pairC->second) += frequency;
44 frequency = (pairC->second);
45 } else {
46 mVector.emplace(std::make_pair(pattern, frequency));
47 }
48
49 return frequency;
50}
51
52uint32_t Diagnostic::getFrequency(ULong64_t pattern) const
53{
54 auto pairC = mVector.find(pattern);
55 if (pairC != mVector.end()) {
56 return (pairC->second);
57 }
58
59 return 0;
60}
61
62void Diagnostic::print(bool longFormat) const
63{
64 LOG(info) << "Diagnostic patterns, entries = " << mVector.size();
65
66 if (!longFormat) {
67 return;
68 }
69
70 for (const auto& [key, value] : mVector) {
71 std::cout << key << " = " << value << "; ";
72 }
73 std::cout << std::endl;
74}
75
76ULong64_t Diagnostic::getEmptyCrateKey(int crate)
77{
78 ULong64_t key = (ULong64_t(13) << 32) + (ULong64_t(crate) << 36); // slot=13 means empty crate
79 return key;
80}
81
82ULong64_t Diagnostic::getNoisyChannelKey(int channel)
83{
84 ULong64_t key = (ULong64_t(14) << 32) + channel; // slot=14 means noisy channels
85 return key;
86}
87
88ULong64_t Diagnostic::getTRMKey(int crate, int trm)
89{
90 ULong64_t key = (ULong64_t(trm) << 32) + (ULong64_t(crate) << 36);
91 return key;
92}
93
95{
96 LOG(debug) << "Filling diagnostic word";
97 for (auto const& el : diag.mVector) {
98 LOG(debug) << "Filling diagnostic pattern " << el.first << " adding " << el.second << " to " << getFrequency(el.first) << " --> " << el.second + getFrequency(el.first);
99 fill(el.first, el.second);
100 }
101}
102
104{
105 LOG(debug) << "Merging diagnostic words";
106 for (auto const& el : prev->mVector) {
107 fill(el.first, el.second);
108 }
109}
110
112{
113 // set true in output channel array
114 for (auto pair : mVector) {
115 auto key = pair.first;
116 int slot = getSlot(key);
117
118 if (slot != 14) {
119 continue;
120 }
121
123 }
124}
125
126void Diagnostic::getNoisyMap(Bool_t* output, int noisyThr) const
127{
128 // set true in output channel array
129 for (auto pair : mVector) {
130 auto key = pair.first;
131 int slot = getSlot(key);
132
133 if (slot != 14) {
134 continue;
135 }
136
137 if (getNoisyLevel(key) >= noisyThr) {
138 output[getChannel(key)] = true;
139 }
140 }
141}
142
143bool Diagnostic::isNoisyChannel(int channel, int thr) const
144{
145 static const ULong64_t addMask[3] = {0, 1 << 19, 3 << 19};
146 ULong64_t mask = getNoisyChannelKey(channel);
147 for (int i = thr; i <= 2; i++) {
148 if (getFrequency(mask + addMask[i])) {
149 return true;
150 }
151 }
152
153 return false;
154}
ClassImp(Diagnostic)
Definition of the TOF cluster.
int32_t i
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
std::ostringstream debug
StringRef key
Diagnostic class for TOF.
Definition Diagnostic.h:32
void print(bool longFormat=false) const
void merge(const Diagnostic *prev)
static ULong64_t getTRMKey(int crate, int trm)
void getNoisyMap(Bool_t *output, int noisyThr=1) const
uint32_t fill(ULong64_t pattern)
static int getChannel(ULong64_t pattern)
Definition Diagnostic.h:67
uint32_t getFrequency(ULong64_t pattern) const
void getNoisyLevelMap(Char_t *output) const
static int getNoisyLevel(ULong64_t pattern)
Definition Diagnostic.h:74
static ULong64_t getNoisyChannelKey(int channel)
static ULong64_t getEmptyCrateKey(int crate)
bool isNoisyChannel(int channel, int thr=0) const
static int getSlot(ULong64_t pattern)
Definition Diagnostic.h:65
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLuint mask
Definition glcorearb.h:291
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::array< uint16_t, 5 > pattern