-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathITSDecodingErrorTask.cxx
More file actions
254 lines (224 loc) · 9.6 KB
/
ITSDecodingErrorTask.cxx
File metadata and controls
254 lines (224 loc) · 9.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file ITSDecodingErrorTask.cxx
/// \author Zhen Zhang
///
#include "ITS/ITSDecodingErrorTask.h"
#include "ITSMFTReconstruction/DecodingStat.h"
#include "QualityControl/QcInfoLogger.h"
#include <Framework/InputRecord.h>
#include "Common/TH1Ratio.h"
#include "Common/Utils.h"
using namespace o2::framework;
using namespace o2::itsmft;
using namespace o2::header;
namespace o2::quality_control_modules::its
{
ITSDecodingErrorTask::ITSDecodingErrorTask()
: TaskInterface()
{
}
ITSDecodingErrorTask::~ITSDecodingErrorTask()
{
delete mLinkErrorPlots;
delete mChipErrorPlots;
delete mLinkErrorVsFeeid;
delete mChipErrorVsFeeid;
for (int ilayer = 0; ilayer < NLayer; ilayer++) {
delete mChipErrorVsChipid[ilayer];
}
}
void ITSDecodingErrorTask::initialize(o2::framework::InitContext& /*ctx*/)
{
ILOG(Debug, Devel) << "initializing the ITSDecodingErrorTask" << ENDM;
getParameters();
createDecodingPlots();
setPlotsFormat();
for (int iFEE = 0; iFEE < NFees; iFEE++) {
DecErr_lastCycle[iFEE] = std::vector<int>(o2::itsmft::GBTLinkDecodingStat::NErrorsDefined, 0);
}
}
void ITSDecodingErrorTask::createDecodingPlots()
{
mLinkErrorVsFeeid = new TH2D("General/LinkErrorVsFeeid", "GBTLink errors per FeeId", NFees, 0, NFees, o2::itsmft::GBTLinkDecodingStat::NErrorsDefined, 0.5, (float)o2::itsmft::GBTLinkDecodingStat::NErrorsDefined + 0.5);
mLinkErrorVsFeeid->SetMinimum(0);
mLinkErrorVsFeeid->SetStats(0);
getObjectsManager()->startPublishing(mLinkErrorVsFeeid);
for (int ilayer = 0; ilayer < 7; ilayer++) {
mChipErrorVsChipid[ilayer] = new TH2D(Form("General/Layer%dChipErrorVsChipid", ilayer), Form("Layer%d Chip errors per FeeId", ilayer), ChipBoundary[ilayer + 1] - ChipBoundary[ilayer], 0, ChipBoundary[ilayer + 1] - ChipBoundary[ilayer], o2::itsmft::ChipStat::NErrorsDefined, 0.5, (float)o2::itsmft::ChipStat::NErrorsDefined + 0.5);
mChipErrorVsChipid[ilayer]->SetMinimum(0);
mChipErrorVsChipid[ilayer]->SetStats(0);
getObjectsManager()->startPublishing(mChipErrorVsChipid[ilayer]);
}
mChipErrorVsFeeid = new TH2D("General/ChipErrorVsFeeid", "Chip decoding errors per FeeId", NFees, 0, NFees, o2::itsmft::ChipStat::NErrorsDefined, 0.5, (float)o2::itsmft::ChipStat::NErrorsDefined + 0.5);
mChipErrorVsFeeid->SetMinimum(0);
mChipErrorVsFeeid->SetStats(0);
getObjectsManager()->startPublishing(mChipErrorVsFeeid);
mLinkErrorPlots = new TH1D("General/LinkErrorPlots", "GBTLink decoding Errors", o2::itsmft::GBTLinkDecodingStat::NErrorsDefined, 0.5, (float)o2::itsmft::GBTLinkDecodingStat::NErrorsDefined + 0.5);
mLinkErrorPlots->SetMinimum(0);
mLinkErrorPlots->SetStats(0);
mLinkErrorPlots->SetFillColor(kOrange);
getObjectsManager()->startPublishing(mLinkErrorPlots); // mLinkErrorPlots
mChipErrorPlots = new TH1D("General/ChipErrorPlots", "Chip Decoding Errors", o2::itsmft::ChipStat::NErrorsDefined, 0.5, (float)o2::itsmft::ChipStat::NErrorsDefined + 0.5);
mChipErrorPlots->SetMinimum(0);
mChipErrorPlots->SetStats(0);
mChipErrorPlots->SetFillColor(kOrange);
getObjectsManager()->startPublishing(mChipErrorPlots); // mChipErrorPlots
hAlwaysBusy = new TH1D("AlwaysBusyChips", "Number of Chips always in BUSY state", 11, 0, 11);
setAxisTitle(hAlwaysBusy, "Layer", "Counts");
getObjectsManager()->startPublishing(hAlwaysBusy);
hBusyFraction = std::make_unique<TH1FRatio>("FractionOfBusyChips", "Fraction of chips in BUSY, excluding permanent", 11, 0, 11, false);
setAxisTitle(hBusyFraction.get(), "Layer", "BusyViolations / TF / NChips");
getObjectsManager()->startPublishing(hBusyFraction.get());
for (int iBin = 1; iBin <= 11; iBin++) {
hAlwaysBusy->GetXaxis()->SetBinLabel(iBin, LayerBinLabels[iBin - 1]);
hBusyFraction->GetXaxis()->SetBinLabel(iBin, LayerBinLabels[iBin - 1]);
}
}
void ITSDecodingErrorTask::setAxisTitle(TH1* object, const char* xTitle, const char* yTitle)
{
object->GetXaxis()->SetTitle(xTitle);
object->GetYaxis()->SetTitle(yTitle);
}
void ITSDecodingErrorTask::setPlotsFormat()
{
if (mLinkErrorVsFeeid) {
setAxisTitle(mLinkErrorVsFeeid, "FeeID", "Error ID");
}
if (mChipErrorVsFeeid) {
setAxisTitle(mChipErrorVsFeeid, "FeeID", "Error ID");
}
for (int ilayer = 0; ilayer < 7; ilayer++) {
if (mChipErrorVsChipid[ilayer]) {
setAxisTitle(mChipErrorVsChipid[ilayer], "ChipID", "Error ID");
}
}
if (mLinkErrorPlots) {
setAxisTitle(mLinkErrorPlots, "LinkError ID", "Counts");
}
if (mChipErrorPlots) {
setAxisTitle(mChipErrorPlots, "ChipError ID", "Counts");
}
}
void ITSDecodingErrorTask::startOfActivity(const Activity& activity)
{
ILOG(Debug, Devel) << "startOfActivity : " << activity.mId << ENDM;
}
void ITSDecodingErrorTask::startOfCycle()
{
ILOG(Debug, Devel) << "startOfCycle" << ENDM;
}
void ITSDecodingErrorTask::monitorData(o2::framework::ProcessingContext& ctx)
{
auto linkErrors = ctx.inputs().get<gsl::span<o2::itsmft::GBTLinkDecodingStat>>("linkerrors");
auto decErrors = ctx.inputs().get<gsl::span<o2::itsmft::ChipError>>("decerrors");
// multiply Error distributions before re-filling
for (const auto& le : linkErrors) {
int istave = (int)(le.feeID & 0x00ff);
int ilink = (int)((le.feeID & 0x0f00) >> 8);
int ilayer = (int)((le.feeID & 0xf000) >> 12);
int ifee = 3 * StaveBoundary[ilayer] - (StaveBoundary[ilayer] - StaveBoundary[NLayerIB]) * (ilayer >= NLayerIB) + istave * (3 - (ilayer >= NLayerIB)) + ilink;
for (int ierror = 0; ierror < o2::itsmft::GBTLinkDecodingStat::NErrorsDefined; ierror++) {
if (le.errorCounts[ierror] <= 0) {
continue;
}
if (isDoLinkErrorReset)
mLinkErrorVsFeeid->SetBinContent(ifee + 1, ierror + 1, le.errorCounts[ierror] - DecErr_lastCycle[ifee][ierror]);
else
mLinkErrorVsFeeid->SetBinContent(ifee + 1, ierror + 1, le.errorCounts[ierror]);
}
}
for (const auto& de : decErrors) {
int istave = (int)(de.getFEEID() & 0x00ff);
int ilink = (int)((de.getFEEID() & 0x0f00) >> 8);
int ilayer = (int)((de.getFEEID() & 0xf000) >> 12);
int ifee = 3 * StaveBoundary[ilayer] - (StaveBoundary[ilayer] - StaveBoundary[NLayerIB]) * (ilayer >= NLayerIB) + istave * (3 - (ilayer >= NLayerIB)) + ilink;
int ichip = de.getChipID() - ChipBoundary[ilayer];
for (int ierror = 0; ierror < o2::itsmft::ChipStat::NErrorsDefined; ierror++) {
if ((de.errors >> ierror) % 2) {
if (de.getChipID() == -1) {
continue;
}
mChipErrorVsFeeid->Fill(ifee, ierror + 1);
mChipErrorVsChipid[ilayer]->Fill(ichip, ierror + 1);
}
}
}
for (int ierror = 0; ierror < o2::itsmft::GBTLinkDecodingStat::NErrorsDefined; ierror++) {
int feeLinkError = mLinkErrorVsFeeid->Integral(1, mLinkErrorVsFeeid->GetXaxis()->GetNbins(), ierror + 1, ierror + 1);
mLinkErrorPlots->SetBinContent(ierror + 1, feeLinkError);
}
for (int ierror = 0; ierror < o2::itsmft::ChipStat::NErrorsDefined; ierror++) {
int feeChipError = mChipErrorVsFeeid->Integral(1, mChipErrorVsFeeid->GetXaxis()->GetNbins(), ierror + 1, ierror + 1);
mChipErrorPlots->SetBinContent(ierror + 1, feeChipError);
}
mTFCount++;
}
void ITSDecodingErrorTask::getParameters()
{
mBusyViolationLimit = o2::quality_control_modules::common::getFromConfig<float>(mCustomParameters, "mBusyViolationLimit", mBusyViolationLimit);
isDoLinkErrorReset = (bool)o2::quality_control_modules::common::getFromConfig<int>(mCustomParameters, "isDoLinkErrorReset", isDoLinkErrorReset);
}
void ITSDecodingErrorTask::endOfCycle()
{
ILOG(Debug, Devel) << "endOfCycle" << ENDM;
hBusyFraction->Reset();
hAlwaysBusy->Reset();
int binIterator = 0;
for (int iLayer = 0; iLayer < NLayer; iLayer++) {
for (int iChip = 1; iChip <= nChipsPerLayer[iLayer]; iChip++) {
if (iLayer > 2 && iChip == nChipsPerLayer[iLayer] / 2)
binIterator++; // to account for bot/top barrel
int nBusyViolations = mChipErrorVsChipid[iLayer]->GetBinContent(iChip, 1);
if (1. * nBusyViolations / mTFCount > mBusyViolationLimit) {
hAlwaysBusy->Fill(binIterator);
continue;
}
if (nBusyViolations > 0) {
hBusyFraction->getNum()->Fill(binIterator, nBusyViolations);
}
}
hBusyFraction->getDen()->SetBinContent(binIterator + 1, mTFCount * nChipsPerLayer[iLayer]);
binIterator++;
}
hBusyFraction->update();
}
void ITSDecodingErrorTask::endOfActivity(const Activity& /*activity*/)
{
ILOG(Debug, Devel) << "endOfActivity" << ENDM;
}
void ITSDecodingErrorTask::resetGeneralPlots()
{
mTFCount++;
mChipErrorPlots->Reset();
if (isDoLinkErrorReset) {
for (int iFEE = 1; iFEE <= mLinkErrorVsFeeid->GetNbinsY(); iFEE++) {
for (int iError = 1; iError <= mLinkErrorVsFeeid->GetNbinsX(); iError++) {
DecErr_lastCycle[iFEE - 1][iError - 1] += mLinkErrorVsFeeid->GetBinContent(iFEE, iError);
}
}
}
mLinkErrorVsFeeid->Reset();
mLinkErrorPlots->Reset();
for (int ilayer = 0; ilayer < 7; ilayer++) {
mChipErrorVsChipid[ilayer]->Reset();
}
mTFCount = 0;
hBusyFraction->Reset();
hAlwaysBusy->Reset();
}
void ITSDecodingErrorTask::reset()
{
resetGeneralPlots();
ILOG(Debug, Devel) << "Reset" << ENDM;
}
} // namespace o2::quality_control_modules::its