Skip to content

Commit f6820b5

Browse files
lhusovaLucia Anna Tarasovicova
andauthored
CTP: update of the check class (#2372)
* Checking the change in nSigma instead of percentage * changes requested by Piotr --------- Co-authored-by: Lucia Anna Tarasovicova <lucia.anna.husova@cern.ch>
1 parent 04ad10c commit f6820b5

5 files changed

Lines changed: 100 additions & 49 deletions

File tree

Modules/CTP/include/CTP/RawDataQcTask.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ class CTPRawDataReaderTask final : public TaskInterface
5656
std::unique_ptr<TH1DRatio> mHistoClassRatios = nullptr; // histogram with ctp class ratios to MB
5757
std::unique_ptr<TH1D> mHistoMTVXBC = nullptr; // histogram of BC positions to check LHC filling scheme
5858
int mRunNumber;
59+
int indexTvx = -1;
60+
static const int ninps = o2::ctp::CTP_NINPUTS + 1;
61+
static const int nclasses = o2::ctp::CTP_NCLASSES + 1;
5962
long int mTimestamp;
63+
std::string classNames[nclasses];
6064
int mIndexMBclass = -1; // index for the MB ctp class, which is used as scaling for the ratios
6165
};
6266

Modules/CTP/include/CTP/RawDataReaderCheck.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ class RawDataReaderCheck : public o2::quality_control::checker::CheckInterface
4949
private:
5050
int getRunNumberFromMO(std::shared_ptr<MonitorObject> mo);
5151
int checkChange(TH1D* mHist, TH1D* mHistPrev);
52+
int checkChangeOfRatio(TH1D* mHist, TH1D* mHistPrev, TH1D* mHistAbs);
5253
Quality setQualityResult(std::vector<int>& vBad, std::vector<int>& vMedium);
5354
void clearIndexVectors();
5455
long int mTimestamp;
55-
float mThreshold = -1; // threshold for BCs
56-
float mThresholdRateBad; // threshold for the relative change in ctp input and class rates
57-
float mThresholdRateMedium; // threshold for the relative change in ctp input and class rates
58-
float mThresholdRateRatioBad; // threshold for the relative change in ctp input and class ratios
59-
float mThresholdRateRatioMedium; // threshold for the relative change in ctp input and class ratios
60-
bool mFlagRatio = false; // flag that a ratio plot is checked
61-
bool mFlagInput = false; // flag that an input plot is checked
62-
TH1D* mHistInputPrevious = nullptr; // histogram storing ctp input rates from previous cycle
63-
TH1D* mHistClassesPrevious = nullptr; // histogram storing ctp class rates from previous cycle
64-
TH1D* mHistInputRatioPrevious = nullptr; // histogram storing ctp input ratios to MB from previous cycle
65-
TH1D* mHistClassRatioPrevious = nullptr; // histogram storing ctp class ratios to MB from previous cycle
56+
float mThreshold = -1; // threshold for BCs
57+
float mThresholdRateBad; // threshold for the relative change in ctp input and class rates
58+
float mThresholdRateMedium; // threshold for the relative change in ctp input and class rates
59+
float mThresholdRateRatioBad; // threshold for the relative change in ctp input and class ratios
60+
float mThresholdRateRatioMedium; // threshold for the relative change in ctp input and class ratios
61+
bool mFlagRatio = false; // flag that a ratio plot is checked
62+
bool mFlagInput = false; // flag that an input plot is checked
63+
TH1D* mHistInputPrevious = nullptr; // histogram storing ctp input rates from previous cycle
64+
TH1D* mHistClassesPrevious = nullptr; // histogram storing ctp class rates from previous cycle
65+
TH1D* mHistInputRatioPrevious = nullptr; // histogram storing ctp input ratios to MB from previous cycle
66+
TH1D* mHistClassRatioPrevious = nullptr;
67+
TH1D* mHistAbsolute = nullptr; // histogram storing ctp class ratios to MB from previous cycle
6668
std::vector<int> mVecGoodBC; // vector of good BC positions
6769
std::vector<int> mVecMediumBC; // vector of medium BC positions, we expect a BC at this position, but inputs are below mThreshold
6870
std::vector<int> mVecBadBC; // vector of bad BC positions, we don't expect a BC at this position, but inputs are abow mThreshold

Modules/CTP/src/RawDataQcTask.cxx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ CTPRawDataReaderTask::~CTPRawDataReaderTask()
3838
void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/)
3939
{
4040
ILOG(Debug, Devel) << "initialize CTPRawDataReaderTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
41-
int ninps = o2::ctp::CTP_NINPUTS + 1;
42-
int nclasses = o2::ctp::CTP_NCLASSES + 1;
4341
int norbits = o2::constants::lhc::LHCMaxBunches;
4442
mHistoInputs = std::make_unique<TH1DRatio>("inputs", "Input Rates; Input ; Rate [kHz]", ninps, 0, ninps, true);
45-
mHistoClasses = std::make_unique<TH1DRatio>("classes", "Class Rates; Index; Rate [kHz]", nclasses, 0, nclasses, true);
43+
mHistoClasses = std::make_unique<TH1DRatio>("classes", "Class Rates; Class; Rate [kHz]", nclasses, 0, nclasses, true);
4644
mHistoInputs->SetStats(0);
4745
mHistoClasses->SetStats(0);
4846
mHistoMTVXBC = std::make_unique<TH1D>("bcMTVX", "BC position of MTVX", norbits, 0, norbits);
4947
mHistoInputRatios = std::make_unique<TH1DRatio>("inputRatio", "Input Ratio to MTVX; Input; Ratio;", ninps, 0, ninps, true);
50-
mHistoClassRatios = std::make_unique<TH1DRatio>("classRatio", "Class Ratio to MB; Index; Ratio", nclasses, 0, nclasses, true);
48+
mHistoClassRatios = std::make_unique<TH1DRatio>("classRatio", "Class Ratio to MB; Class; Ratio", nclasses, 0, nclasses, true);
5149
getObjectsManager()->startPublishing(mHistoInputs.get());
5250
getObjectsManager()->startPublishing(mHistoClasses.get());
5351
getObjectsManager()->startPublishing(mHistoClassRatios.get());
@@ -56,6 +54,11 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/)
5654

5755
mDecoder.setDoLumi(1);
5856
mDecoder.setDoDigits(1);
57+
for (size_t i = 0; i < nclasses; i++) {
58+
classNames[i] = "";
59+
}
60+
mHistoClassRatios.get()->GetXaxis()->CenterLabels(true);
61+
mHistoClasses.get()->GetXaxis()->CenterLabels(true);
5962
}
6063

6164
void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
@@ -99,9 +102,9 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
99102
if (ok) {
100103
// get the index of the MB reference class
101104
ILOG(Info, Support) << "CTP config found, run:" << run << ENDM;
102-
// std::vector<o2::ctp::CTPClass> ctpcls = CTPconfig.getCTPClasses();
103105
std::vector<o2::ctp::CTPClass> ctpcls = ctpconfigdb->getCTPClasses();
104106
for (size_t i = 0; i < ctpcls.size(); i++) {
107+
classNames[i] = ctpcls[i].name.c_str();
105108
if (ctpcls[i].name.find(MBclassName) != std::string::npos) {
106109
mIndexMBclass = ctpcls[i].getIndex() + 1;
107110
break;
@@ -113,6 +116,27 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
113116
if (mIndexMBclass == -1) {
114117
mIndexMBclass = 1;
115118
}
119+
std::string nameInput = mCustomParameters["MBinputName"];
120+
if (nameInput.empty()) {
121+
nameInput = "MTVX";
122+
}
123+
indexTvx = o2::ctp::CTPInputsConfiguration::getInputIndexFromName(nameInput);
124+
if (indexTvx == -1) {
125+
indexTvx = 3; // 3 is the MTVX index
126+
}
127+
for (int i = 0; i < nclasses; i++) {
128+
if (classNames[i] == "") {
129+
mHistoClasses.get()->GetXaxis()->SetBinLabel(i + 1, Form("%i", i + 1));
130+
mHistoClassRatios.get()->GetXaxis()->SetBinLabel(i + 1, Form("%i", i + 1));
131+
} else {
132+
mHistoClasses.get()->GetXaxis()->SetBinLabel(i + 1, Form("%s", classNames[i].c_str()));
133+
mHistoClassRatios.get()->GetXaxis()->SetBinLabel(i + 1, Form("%s", classNames[i].c_str()));
134+
}
135+
}
136+
mHistoClasses.get()->GetXaxis()->SetLabelSize(0.025);
137+
mHistoClasses.get()->GetXaxis()->LabelsOption("v");
138+
mHistoClassRatios.get()->GetXaxis()->SetLabelSize(0.025);
139+
mHistoClassRatios.get()->GetXaxis()->LabelsOption("v");
116140
}
117141

118142
void CTPRawDataReaderTask::startOfCycle()
@@ -132,9 +156,7 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx)
132156
o2::framework::InputRecord& inputs = ctx.inputs();
133157
mDecoder.decodeRaw(inputs, filter, outputDigits, lumiPointsHBF1);
134158

135-
//reading the ctp inputs and ctp classes
136-
std::string nameInput = "MTVX";
137-
auto indexTvx = o2::ctp::CTPInputsConfiguration::getInputIndexFromName(nameInput);
159+
// reading the ctp inputs and ctp classes
138160
for (auto const digit : outputDigits) {
139161
uint16_t bcid = digit.intRecord.bc;
140162
if (digit.CTPInputMask.count()) {

Modules/CTP/src/RawDataReaderCheck.cxx

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// ROOT
2424
#include <TH1.h>
2525
#include <TLatex.h>
26+
#include <TMath.h>
2627
#include <DataFormatsParameters/GRPLHCIFData.h>
2728
#include <DataFormatsQualityControl/FlagType.h>
2829
#include <DetectorsBase/GRPGeomHelper.h>
@@ -38,27 +39,28 @@ void RawDataReaderCheck::configure()
3839
{
3940
// reading the parameters from the config.json
4041
// if not available, setting a default value
41-
std::string param = mCustomParameters.atOrDefaultValue("thresholdRateBad", "0.15");
42+
// the threshold values are nSigma
43+
std::string param = mCustomParameters.atOrDefaultValue("thresholdRateBad", "3");
4244
mThresholdRateBad = std::stof(param);
43-
if (mThresholdRateBad > 1 || mThresholdRateBad < 0) {
44-
mThresholdRateBad = 0.15;
45+
if (mThresholdRateBad > 4 || mThresholdRateBad < 0) {
46+
mThresholdRateBad = 3;
4547
}
4648

47-
param = mCustomParameters.atOrDefaultValue("thresholdRateMedium", "0.1");
49+
param = mCustomParameters.atOrDefaultValue("thresholdRateMedium", "2");
4850
mThresholdRateMedium = std::stof(param);
49-
if (mThresholdRateMedium > 1 || mThresholdRateMedium < 0) {
50-
mThresholdRateMedium = 0.1;
51+
if (mThresholdRateMedium > 4 || mThresholdRateMedium < 0) {
52+
mThresholdRateMedium = 2;
5153
}
5254

53-
param = mCustomParameters.atOrDefaultValue("thresholdRateRatioBad", "0.1");
55+
param = mCustomParameters.atOrDefaultValue("thresholdRateRatioBad", "3");
5456
mThresholdRateRatioBad = std::stof(param);
55-
if (mThresholdRateRatioBad > 1 || mThresholdRateRatioBad < 0) {
56-
mThresholdRateRatioBad = 0.1;
57+
if (mThresholdRateRatioBad > 4 || mThresholdRateRatioBad < 0) {
58+
mThresholdRateRatioBad = 3;
5759
}
58-
param = mCustomParameters.atOrDefaultValue("thresholdRateRatioMedium", "0.05");
59-
mThresholdRateRatioBad = std::stof(param);
60-
if (mThresholdRateRatioMedium > 1 || mThresholdRateRatioMedium < 0) {
61-
mThresholdRateRatioMedium = 0.05;
60+
param = mCustomParameters.atOrDefaultValue("thresholdRateRatioMedium", "2");
61+
mThresholdRateRatioMedium = std::stof(param);
62+
if (mThresholdRateRatioMedium > 4 || mThresholdRateRatioMedium < 0) {
63+
mThresholdRateRatioMedium = 2;
6264
}
6365
}
6466

@@ -104,10 +106,11 @@ Quality RawDataReaderCheck::check(std::map<std::string, std::shared_ptr<MonitorO
104106
delete mHistInputPrevious;
105107
result.set(setQualityResult(mVecIndexBad, mVecIndexMedium));
106108
}
109+
mHistAbsolute = (TH1D*)h->Clone();
107110
mHistInputPrevious = (TH1D*)h->Clone();
108111
} else if (mo->getName() == "inputRatio") {
109112
if (mHistInputRatioPrevious) {
110-
checkChange(h, mHistInputRatioPrevious);
113+
checkChangeOfRatio(h, mHistInputRatioPrevious, mHistAbsolute);
111114
delete mHistInputRatioPrevious;
112115
result.set(setQualityResult(mVecIndexBad, mVecIndexMedium));
113116
}
@@ -118,10 +121,11 @@ Quality RawDataReaderCheck::check(std::map<std::string, std::shared_ptr<MonitorO
118121
delete mHistClassesPrevious;
119122
result.set(setQualityResult(mVecIndexBad, mVecIndexMedium));
120123
}
124+
mHistAbsolute = (TH1D*)h->Clone();
121125
mHistClassesPrevious = (TH1D*)h->Clone();
122126
} else if (mo->getName() == "classRatio") {
123127
if (mHistClassRatioPrevious) {
124-
checkChange(h, mHistClassRatioPrevious);
128+
checkChangeOfRatio(h, mHistClassRatioPrevious, mHistAbsolute);
125129
delete mHistClassRatioPrevious;
126130
result.set(setQualityResult(mVecIndexBad, mVecIndexMedium));
127131
}
@@ -139,14 +143,34 @@ int RawDataReaderCheck::checkChange(TH1D* mHist, TH1D* mHistPrev)
139143
/// this function check how much the rates differ from previous cycle
140144
float thrBad = mThresholdRateBad;
141145
float thrMedium = mThresholdRateMedium;
142-
if (mFlagRatio) {
143-
thrBad = mThresholdRateRatioBad;
144-
thrMedium = mThresholdRateRatioMedium;
146+
for (size_t i = 1; i < mHist->GetXaxis()->GetNbins() + 1; i++) { // Check how many inputs/classes changed more than a threshold value
147+
double val = mHist->GetBinContent(i);
148+
double valPrev = mHistPrev->GetBinContent(i);
149+
double relDiff = (valPrev != 0 || val != 0) ? (val - valPrev) / TMath::Sqrt(val) : 0;
150+
if (TMath::Abs(relDiff) > thrBad) {
151+
mVecIndexBad.push_back(i - 1);
152+
} else if (TMath::Abs(relDiff) > thrMedium) {
153+
mVecIndexMedium.push_back(i - 1);
154+
}
155+
}
156+
return 0;
157+
}
158+
int RawDataReaderCheck::checkChangeOfRatio(TH1D* mHist, TH1D* mHistPrev, TH1D* mHistAbs)
159+
{
160+
/// this function check how much the rates differ from previous cycle
161+
float thrBad = mThresholdRateRatioBad;
162+
float thrMedium = mThresholdRateRatioMedium;
163+
int binMB;
164+
for (int i = 1; i < mHist->GetXaxis()->GetNbins() + 1; i++) {
165+
if (mHist->GetBinContent(i) == mHistPrev->GetBinContent(i) && mHist->GetBinContent(i) == 1) {
166+
binMB = i;
167+
break;
168+
}
145169
}
146170
for (size_t i = 1; i < mHist->GetXaxis()->GetNbins() + 1; i++) { // Check how many inputs/classes changed more than a threshold value
147171
double val = mHist->GetBinContent(i);
148172
double valPrev = mHistPrev->GetBinContent(i);
149-
double relDiff = (valPrev != 0) ? (val - valPrev) / valPrev : 0;
173+
double relDiff = (val != 0 || mHistAbs->GetBinContent(i) != 0) ? (val - valPrev) / (val * TMath::Sqrt(1 / mHistAbs->GetBinContent(binMB) + 1 / mHistAbs->GetBinContent(i))) : 0;
150174
if (TMath::Abs(relDiff) > thrBad) {
151175
mVecIndexBad.push_back(i - 1);
152176
} else if (TMath::Abs(relDiff) > thrMedium) {
@@ -242,20 +266,21 @@ void RawDataReaderCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality che
242266
}
243267
h->GetXaxis()->SetLabelSize(0.045);
244268
h->GetXaxis()->LabelsOption("v");
269+
h->GetXaxis()->CenterLabels(true);
245270
}
246271
if (checkResult == Quality::Bad) {
247272
msg->SetTextColor(kRed);
248273
msg->SetNDC();
249274
h->GetListOfFunctions()->Add(msg->Clone());
250-
msg = std::make_shared<TLatex>(0.45, 0.75, Form("Number of %s with big %s rate change: %lu", groupName.c_str(), relativeness.c_str(), mVecIndexBad.size()));
275+
msg = std::make_shared<TLatex>(0.45, 0.70, Form("Number of %s with big %s rate change: %lu", groupName.c_str(), relativeness.c_str(), mVecIndexBad.size()));
251276
msg->SetTextSize(0.03);
252277
msg->SetNDC();
253278
h->GetListOfFunctions()->Add(msg->Clone());
254279
for (size_t i = 0; i < mVecIndexBad.size(); i++) {
255280
if (mFlagInput) {
256-
msg = std::make_shared<TLatex>(0.45, 0.7 - i * 0.05, Form("Check %s %s", ctpinputs[mVecIndexBad[i]], groupName.c_str()));
281+
msg = std::make_shared<TLatex>(0.45, 0.65 - i * 0.05, Form("Check %s %s", ctpinputs[mVecIndexBad[i]], groupName.c_str()));
257282
} else {
258-
msg = std::make_shared<TLatex>(0.45, 0.7 - i * 0.05, Form("Check %s with Index: %d", groupName.c_str(), mVecIndexBad[i]));
283+
msg = std::make_shared<TLatex>(0.45, 0.65 - i * 0.05, Form("Check %s %s", groupName.c_str(), h->GetXaxis()->GetBinLabel(mVecIndexBad[i] + 1)));
259284
}
260285
msg->SetTextSize(0.03);
261286
msg->SetNDC();

0 commit comments

Comments
 (0)