Skip to content

Commit 25573c0

Browse files
stefan-zugravelStefan Cristi Zugravel
andauthored
[ZDC] Qc additions (#2510)
* [ZDC] bug fix and plot addition * Removed two comments to please clang-format * Added ZDCRecBeautifyPlots method, BCalignmentPlot RAW and configurable central event function * Modification ZDC Raw QC BC shift plot * Added check for BCalignmentPlot * ADDED configurability from json BCalignmentPlot * Fixed check string hBCAlignPlot * Performed clang-format * modificationfor clang-format * modification for clang-format 2 * fix for code guidelines --------- Co-authored-by: Stefan Cristi Zugravel <stefan@Stefans-MacBook-Pro.local>
1 parent a201282 commit 25573c0

File tree

10 files changed

+393
-24
lines changed

10 files changed

+393
-24
lines changed

Modules/ZDC/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
add_library(O2QcZDC)
44

5-
target_sources(O2QcZDC PRIVATE src/ZDCRecDataCheck.cxx src/ZDCRecDataTask.cxx src/ZDCRecDataPostProcessing.cxx src/PostProcessingConfigZDC.cxx src/ZDCRawDataCheck.cxx src/ZDCRawDataTask.cxx )
5+
target_sources(O2QcZDC PRIVATE src/ZDCRecBeautifyPlots.cxx src/ZDCRecDataCheck.cxx src/ZDCRecDataTask.cxx src/ZDCRecDataPostProcessing.cxx src/PostProcessingConfigZDC.cxx src/ZDCRawDataCheck.cxx src/ZDCRawDataTask.cxx )
66

77
target_include_directories(
88
O2QcZDC
@@ -19,6 +19,7 @@ install(TARGETS O2QcZDC
1919

2020
add_root_dictionary(O2QcZDC
2121
HEADERS
22+
include/ZDC/ZDCRecBeautifyPlots.h
2223
include/ZDC/ZDCRecDataCheck.h
2324
include/ZDC/ZDCRecDataTask.h
2425
include/ZDC/ZDCRecDataPostProcessing.h

Modules/ZDC/include/ZDC/LinkDef.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
#pragma link off all classes;
44
#pragma link off all functions;
55

6-
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataTask+;
7-
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataCheck+;
8-
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataTask+;
9-
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataCheck+;
10-
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataPostProcessing+;
6+
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataTask + ;
7+
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataCheck + ;
8+
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataTask + ;
9+
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataCheck + ;
10+
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataPostProcessing + ;
11+
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecBeautifyPlots + ;
1112
#endif

Modules/ZDC/include/ZDC/ZDCRawDataCheck.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ class ZDCRawDataCheck : public o2::quality_control::checker::CheckInterface
7575
private:
7676
std::vector<sHistoCheck> mVectHistoCheck;
7777
std::vector<std::string> mVectch;
78+
float NOISE_LEVEL_LOW = 0.0;
79+
float NOISE_LEVEL_HIGH = 2.0;
80+
bool COMPARATOR_ARRAY[12];
81+
int REFERENCE_BIN = 7;
7882

7983
// std::string mStringW = "List channels Warning Quality: ";
8084
// std::string mStringE = "List channels Bad Quality: ";

Modules/ZDC/include/ZDC/ZDCRawDataTask.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class ZDCRawDataTask final : public TaskInterface
156156
TH2* fSummaryAlignShift;
157157
TH2* fSummaryError;
158158
TH1* fOverBc;
159+
// Begin Stefan addition
160+
TH2* fBCalignment;
161+
// End Stefan addition
159162

160163
std::vector<std::string> fNameHisto;
161164
std::map<std::string, int> fMapBinNameIdSummaryHisto;
@@ -173,6 +176,9 @@ class ZDCRawDataTask final : public TaskInterface
173176
int fAlignCycle = 1; // param
174177
int fErrorCycle = 1; // param
175178
int fAlignNumEntries = 2000;
179+
// Begin Stefan addition
180+
int FirstEventBC = 0;
181+
// End Stefan addition
176182

177183
sAlignment fMatrixAlign[o2::zdc::NModules][o2::zdc::NChPerModule];
178184
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
12+
///
13+
/// \file ZDCRecBeautifyPlots.h
14+
/// \author Stefan Cristi Zugravel
15+
///
16+
17+
#ifndef QC_MODULE_ZDC_ZDCZDCRECBEAUTIFYPLOTS_H
18+
#define QC_MODULE_ZDC_ZDCZDCRECBEAUTIFYPLOTS_H
19+
20+
#include "QualityControl/CheckInterface.h"
21+
22+
namespace o2::quality_control_modules::zdc
23+
{
24+
25+
/// \brief ZDC Beautify for centroids plots
26+
/// \author Stefan Cristi Zugravel
27+
class ZDCRecBeautifyPlots : public o2::quality_control::checker::CheckInterface
28+
{
29+
public:
30+
/// Default constructor
31+
ZDCRecBeautifyPlots() = default;
32+
/// Destructor
33+
~ZDCRecBeautifyPlots() override = default;
34+
35+
// Override interface
36+
void configure() override;
37+
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
38+
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
39+
std::string getAcceptedType() override;
40+
void reset() override;
41+
void startOfActivity(const Activity& activity) override;
42+
void endOfActivity(const Activity& activity) override;
43+
44+
private:
45+
std::shared_ptr<Activity> mActivity;
46+
47+
ClassDefOverride(ZDCRecBeautifyPlots, 3);
48+
};
49+
50+
} // namespace o2::quality_control_modules::zdc
51+
52+
#endif // QC_MODULE_ZDC_ZDCZDCRECBEAUTIFYPLOTS_H

Modules/ZDC/include/ZDC/ZDCRecDataTask.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ class ZDCRecDataTask final : public TaskInterface
101101
int process(const gsl::span<const o2::zdc::BCRecData>& RecBC, const gsl::span<const o2::zdc::ZDCEnergy>& Energy, const gsl::span<const o2::zdc::ZDCTDCData>& TDCData, const gsl::span<const uint16_t>& Info);
102102
bool FillTDCValueHisto();
103103
std::vector<std::string> tokenLine(std::string Line, std::string Delimiter);
104+
// Begin Stefan addition
105+
bool IsEventCentral();
106+
void SetConfigCentralEvent(float tdcLimit, int centraleventconfigvalue);
107+
void settdcLimit(float tdcv) { ftdcLimit = tdcv; };
108+
void setcentraleventconfigvalue(int centrentcfg) { fcentraleventconfigvalue = centrentcfg; };
109+
float gettdcLimit() { return ftdcLimit; };
110+
int getcentraleventconfigvalue() { return fcentraleventconfigvalue; };
111+
// End Stefan addition
104112

105113
private:
106114
std::vector<std::string> mVecCh;
@@ -127,6 +135,10 @@ class ZDCRecDataTask final : public TaskInterface
127135
int fNumBinY = 0;
128136
double fMinBinY = 0;
129137
double fMaxBinY = 0;
138+
// Begin Stefan addition
139+
float ftdcLimit = 0;
140+
int fcentraleventconfigvalue = 0;
141+
// End Stefan addition
130142
// TH1F* mHistogram = nullptr;
131143
};
132144

Modules/ZDC/src/ZDCRawDataCheck.cxx

Lines changed: 102 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
5656
(void)moName;
5757
// For -> Histo to check
5858
for (int ih = 0; ih < (int)mVectHistoCheck.size(); ih++) {
59-
mVectHistoCheck.at(ih).numE = 0;
60-
mVectHistoCheck.at(ih).numW = 0;
61-
mVectHistoCheck.at(ih).stringW = "";
62-
mVectHistoCheck.at(ih).stringE = "";
6359
if (mo->getName() == mVectHistoCheck.at(ih).nameHisto) {
6460
if ((mo->getName() == "hpedSummary")) {
61+
mVectHistoCheck.at(ih).numE = 0;
62+
mVectHistoCheck.at(ih).numW = 0;
63+
mVectHistoCheck.at(ih).stringW = "";
64+
mVectHistoCheck.at(ih).stringE = "";
6565
auto* h = dynamic_cast<TH1*>(mo->getObject());
6666
if (h == nullptr) {
6767
ILOG(Error, Support) << "could not cast hpedSummary to TH1*" << ENDM;
@@ -87,6 +87,10 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
8787
}
8888

8989
if ((mo->getName() == "hAlignPlot") || (mo->getName() == "hAlignPlotShift")) {
90+
mVectHistoCheck.at(ih).numE = 0;
91+
mVectHistoCheck.at(ih).numW = 0;
92+
mVectHistoCheck.at(ih).stringW = "";
93+
mVectHistoCheck.at(ih).stringE = "";
9094
int flag_ch_empty = 1;
9195
int flag_all_ch_empty = 1;
9296
auto* h = dynamic_cast<TH2*>(mo->getObject());
@@ -128,6 +132,10 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
128132
}
129133

130134
if (mo->getName() == "herrorSummary") {
135+
mVectHistoCheck.at(ih).numE = 0;
136+
mVectHistoCheck.at(ih).numW = 0;
137+
mVectHistoCheck.at(ih).stringW = "";
138+
mVectHistoCheck.at(ih).stringE = "";
131139
int flag_ch_empty = 1;
132140
auto* h = dynamic_cast<TH2*>(mo->getObject());
133141
if (h == nullptr) {
@@ -161,6 +169,36 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
161169
flag_ch_empty = 1;
162170
}
163171
}
172+
if (mo->getName() == "hBCAlignPlot") {
173+
mVectHistoCheck.at(ih).numE = 0;
174+
mVectHistoCheck.at(ih).numW = 0;
175+
mVectHistoCheck.at(ih).stringW = "";
176+
mVectHistoCheck.at(ih).stringE = "";
177+
bool ratio_array[12];
178+
float ratio = 0.0;
179+
auto* h = dynamic_cast<TH2*>(mo->getObject());
180+
if (h == nullptr) {
181+
ILOG(Error, Support) << "could not cast herrorSummary to TH2*" << ENDM;
182+
return Quality::Null;
183+
}
184+
if ((int)h->GetNbinsX() != (int)mVectHistoCheck.at(ih).paramch.size()) {
185+
return Quality::Null;
186+
}
187+
for (int x = 0; x < h->GetNbinsX(); x++) {
188+
for (int y = 0; y < h->GetNbinsY(); y++) {
189+
ratio = (h->GetBinContent(x + 1, y + 1)) / (h->GetBinContent(x + 1, REFERENCE_BIN));
190+
if ((ratio > NOISE_LEVEL_LOW) && (ratio < NOISE_LEVEL_HIGH)) {
191+
ratio_array[y] = true;
192+
} else {
193+
ratio_array[y] = false;
194+
}
195+
}
196+
if (!std::equal(std::begin(ratio_array), std::end(ratio_array), std::begin(COMPARATOR_ARRAY))) {
197+
mVectHistoCheck.at(ih).numE += 1;
198+
mVectHistoCheck.at(ih).stringE = mVectHistoCheck.at(ih).stringE + mVectHistoCheck.at(ih).paramch.at(x).ch + " ";
199+
}
200+
}
201+
}
164202
// check result check
165203
if (mVectHistoCheck.at(ih).numW == 0 && mVectHistoCheck.at(ih).numE == 0) {
166204
result = Quality::Good;
@@ -175,7 +213,7 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
175213
if (mVectHistoCheck.at(ih).numE > 0) {
176214
result = Quality::Bad;
177215
result.addFlag(FlagTypeFactory::Unknown(),
178-
"It is bad because " + std::to_string(mVectHistoCheck.at(ih).numW) + " channels:" + mVectHistoCheck.at(ih).stringE + "have a value in the bad range");
216+
"It is bad because " + std::to_string(mVectHistoCheck.at(ih).numE) + " channels:" + mVectHistoCheck.at(ih).stringE + "have a value in the bad range");
179217
mVectHistoCheck.at(ih).quality = 3;
180218
}
181219
}
@@ -188,8 +226,6 @@ std::string ZDCRawDataCheck::getAcceptedType() { return "TH1"; }
188226

189227
void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
190228
{
191-
// dumpStruct();
192-
193229
for (int ih = 0; ih < (int)mVectHistoCheck.size(); ih++) {
194230

195231
if (mo->getName() == mVectHistoCheck.at(ih).nameHisto) {
@@ -198,6 +234,25 @@ void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR
198234
ILOG(Error, Support) << "could not cast '" << mo->getName() << "' to TH1*" << ENDM;
199235
return;
200236
}
237+
if (mo->getName() == "hBCAlignPlot") {
238+
float ratio = 0.0;
239+
for (int x = 0; x < h->GetNbinsX(); x++) {
240+
for (int y = 0; y < h->GetNbinsY(); y++) {
241+
ratio = (h->GetBinContent(x + 1, y + 1)) / (h->GetBinContent(x + 1, REFERENCE_BIN));
242+
float xpos = h->GetXaxis()->GetBinCenter(x + 1);
243+
float ypos = h->GetYaxis()->GetBinCenter(y + 1);
244+
std::string strValue = std::format("{:.2f}", ratio);
245+
TLatex* msgr = new TLatex(xpos - 0.35, ypos - 0.15, strValue.c_str());
246+
msgr->SetTextSize(9);
247+
if ((ratio > NOISE_LEVEL_LOW) && (ratio < NOISE_LEVEL_HIGH)) {
248+
msgr->SetTextColor(kGreen);
249+
} else {
250+
msgr->SetTextColor(kRed);
251+
}
252+
h->GetListOfFunctions()->Add(msgr);
253+
}
254+
}
255+
}
201256
if (mVectHistoCheck.at(ih).quality == 1) {
202257
std::string errorSt = getCurrentDataTime() + " Ok";
203258
TLatex* msg = new TLatex(mVectHistoCheck.at(ih).posMsgX, mVectHistoCheck.at(ih).posMsgY, errorSt.c_str());
@@ -209,7 +264,7 @@ void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR
209264
h->SetFillColor(kGreen);
210265
msg->Draw();
211266
} else if (mVectHistoCheck.at(ih).quality == 3) {
212-
std::string errorSt = getCurrentDataTime() + " Errors --> Call the expert." + mVectHistoCheck.at(ih).stringE;
267+
std::string errorSt = getCurrentDataTime() + " Errors --> Call the expert. " + mVectHistoCheck.at(ih).stringE;
213268
TLatex* msg = new TLatex(mVectHistoCheck.at(ih).posMsgX, mVectHistoCheck.at(ih).posMsgY, errorSt.c_str());
214269
msg->SetNDC();
215270
msg->SetTextSize(16);
@@ -267,7 +322,45 @@ void ZDCRawDataCheck::init(const Activity& activity)
267322
setChCheck("hpedSummary", "TH1F", "PED", "PED_POS_MSG_X", "PED_POS_MSG_Y", activity);
268323
setChCheck("hAlignPlotShift", "TH2F", "ALIGN", "ALIGN_POS_MSG_X", "ALIGN_POS_MSG_Y", activity);
269324
setChCheck("herrorSummary", "TH2F", "ERROR", "ERROR_POS_MSG_X", "ERROR_POS_MSG_Y", activity);
270-
// dumpStruct();
325+
setChCheck("hBCAlignPlot", "TH2F", "PED", "PED_POS_MSG_X", "PED_POS_MSG_Y", activity);
326+
327+
std::vector<std::string> tokenString;
328+
if (auto param = mCustomParameters.find("REFERENCE_BIN"); param != mCustomParameters.end()) {
329+
ILOG(Debug, Devel) << "Custom parameter - REFERENCE_BIN: " << param->second << ENDM;
330+
tokenString = tokenLine(param->second, ";");
331+
REFERENCE_BIN = atoi(param->second.c_str());
332+
} else {
333+
REFERENCE_BIN = 7;
334+
}
335+
if (auto param = mCustomParameters.find("NOISE_LEVEL_LOW"); param != mCustomParameters.end()) {
336+
ILOG(Debug, Devel) << "Custom parameter - NOISE_LEVEL_LOW: " << param->second << ENDM;
337+
tokenString = tokenLine(param->second, ";");
338+
NOISE_LEVEL_LOW = atof(param->second.c_str());
339+
} else {
340+
NOISE_LEVEL_LOW = 0.0;
341+
}
342+
if (auto param = mCustomParameters.find("NOISE_LEVEL_HIGH"); param != mCustomParameters.end()) {
343+
ILOG(Debug, Devel) << "Custom parameter - NOISE_LEVEL_HIGH: " << param->second << ENDM;
344+
tokenString = tokenLine(param->second, ";");
345+
NOISE_LEVEL_HIGH = atof(param->second.c_str());
346+
} else {
347+
NOISE_LEVEL_HIGH = 2.0;
348+
}
349+
if (auto param = mCustomParameters.find("COMPARATOR_ARRAY"); param != mCustomParameters.end()) {
350+
ILOG(Debug, Devel) << "Custom parameter - COMPARATOR_ARRAY: " << param->second << ENDM;
351+
tokenString = tokenLine(param->second, ";");
352+
for (int i = 0; i < 12; i++) {
353+
if (atoi(tokenString.at(i).c_str()) == 1) {
354+
COMPARATOR_ARRAY[i] = true;
355+
} else {
356+
COMPARATOR_ARRAY[i] = false;
357+
}
358+
}
359+
} else {
360+
for (int i = 0; i < 12; i++) {
361+
COMPARATOR_ARRAY[i] = false;
362+
}
363+
}
271364
}
272365

273366
void ZDCRawDataCheck::setChName(std::string channel)

0 commit comments

Comments
 (0)