Skip to content

Commit 975f936

Browse files
lhusovaLucia Anna Tarasovicova
andauthored
CTP:Change in the RawDataQcTask (#2553)
* fix for replay, confing read-out from ctx * fix clang * fix DecodeInps for Consistency Check --------- Co-authored-by: Lucia Anna Tarasovicova <lucia.anna.husova@cern.ch>
1 parent 7e24f46 commit 975f936

File tree

3 files changed

+91
-40
lines changed

3 files changed

+91
-40
lines changed

Modules/CTP/include/CTP/RawDataQcTask.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class CTPRawDataReaderTask final : public TaskInterface
7070
std::string classNames[nclasses];
7171
int mIndexMBclass = -1; // index for the MB ctp class, which is used as scaling for the ratios
7272
bool mConsistCheck = 0;
73+
bool mReadCTPconfigInMonitorData = 0;
74+
const o2::ctp::CTPConfiguration* mCTPconfig = nullptr;
75+
std::string mMBclassName;
76+
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassErrorsA;
7377
};
7478

7579
} // namespace o2::quality_control_modules::ctp

Modules/CTP/src/RawDataQcTask.cxx

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/)
5151
mHistoBCMinBias2 = std::make_unique<TH1D>("bcMinBias2", "BC position MB2", norbits, 0, norbits);
5252
mHistoInputRatios = std::make_unique<TH1DRatio>("inputRatio", "Input Ratio to MTVX; Input; Ratio;", ninps, 0, ninps, true);
5353
mHistoClassRatios = std::make_unique<TH1DRatio>("classRatio", "Class Ratio to MB; Class; Ratio", nclasses, 0, nclasses, true);
54-
mHistoDecodeError = std::make_unique<TH1D>("decodeError", "Errors from decoder", 10, 1, 11);
54+
mHistoDecodeError = std::make_unique<TH1D>("decodeError", "Errors from decoder", nclasses, 0, nclasses);
5555
getObjectsManager()->startPublishing(mHistoInputs.get());
5656
getObjectsManager()->startPublishing(mHistoClasses.get());
5757
getObjectsManager()->startPublishing(mHistoClassRatios.get());
@@ -61,7 +61,6 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/)
6161
getObjectsManager()->startPublishing(mHistoDecodeError.get());
6262

6363
mDecoder.setDoLumi(1);
64-
mDecoder.setDecodeInps(1);
6564
mDecoder.setDoDigits(1);
6665
for (size_t i = 0; i < nclasses; i++) {
6766
classNames[i] = "";
@@ -84,7 +83,12 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
8483
mRunNumber = activity.mId;
8584
mTimestamp = activity.mValidity.getMin();
8685

87-
auto MBclassName = getFromExtendedConfig<string>(activity, mCustomParameters, "MBclassName", "CMTVX-B-NOPF");
86+
std::string readCTPConfig = getFromExtendedConfig<string>(activity, mCustomParameters, "readCTPconfigInMonitorData", "false");
87+
if (readCTPConfig == "true") {
88+
mReadCTPconfigInMonitorData = true;
89+
}
90+
91+
mMBclassName = getFromExtendedConfig<string>(activity, mCustomParameters, "MBclassName", "CMTVX-B-NOPF");
8892

8993
std::string run = std::to_string(mRunNumber);
9094
std::string ccdbName = mCustomParameters["ccdbName"];
@@ -93,40 +97,42 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
9397
}
9498
/// the ccdb reading to be futher discussed
9599
// o2::ctp::CTPRunManager::setCCDBHost(ccdbName);
96-
bool ok;
97-
// o2::ctp::CTPConfiguration CTPconfig = o2::ctp::CTPRunManager::getConfigFromCCDB(mTimestamp, run, ok);
98-
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
99-
mgr.setURL(ccdbName);
100-
map<string, string> metadata; // can be empty
101-
metadata["runNumber"] = run;
102-
auto ctpconfigdb = mgr.getSpecific<o2::ctp::CTPConfiguration>(o2::ctp::CCDBPathCTPConfig, mTimestamp, metadata);
103-
if (ctpconfigdb == nullptr) {
104-
LOG(info) << "CTP config not in database, timestamp:" << mTimestamp;
105-
ok = 0;
106-
} else {
107-
// ctpconfigdb->printStream(std::cout);
108-
LOG(info) << "CTP config found. Run:" << run;
109-
ok = 1;
110-
}
111-
if (ok) {
112-
// get the index of the MB reference class
113-
ILOG(Info, Support) << "CTP config found, run:" << run << ENDM;
114-
std::vector<o2::ctp::CTPClass> ctpcls = ctpconfigdb->getCTPClasses();
115-
for (size_t i = 0; i < ctpcls.size(); i++) {
116-
classNames[i] = ctpcls[i].name.c_str();
117-
if (ctpcls[i].name.find(MBclassName) != std::string::npos) {
118-
mIndexMBclass = ctpcls[i].getIndex() + 1;
119-
break;
100+
if (!mReadCTPconfigInMonitorData) {
101+
bool ok;
102+
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
103+
mgr.setURL(ccdbName);
104+
map<string, string> metadata; // can be empty
105+
metadata["runNumber"] = run;
106+
auto ctpconfigdb = mgr.getSpecific<o2::ctp::CTPConfiguration>(o2::ctp::CCDBPathCTPConfig, mTimestamp, metadata);
107+
if (ctpconfigdb == nullptr) {
108+
LOG(info) << "CTP config not in database, timestamp:" << mTimestamp;
109+
ok = 0;
110+
} else {
111+
LOG(info) << "CTP config found. Run:" << run;
112+
ok = 1;
113+
}
114+
if (ok) {
115+
// get the index of the MB reference class
116+
ILOG(Info, Support) << "CTP config found, run:" << run << ENDM;
117+
std::vector<o2::ctp::CTPClass> ctpcls = ctpconfigdb->getCTPClasses();
118+
for (size_t i = 0; i < ctpcls.size(); i++) {
119+
classNames[i] = ctpcls[i].name.c_str();
120+
if (ctpcls[i].name.find(mMBclassName) != std::string::npos) {
121+
mIndexMBclass = ctpcls[i].getIndex() + 1;
122+
break;
123+
}
120124
}
125+
mDecoder.setCTPConfig(*ctpconfigdb);
126+
} else {
127+
ILOG(Warning, Support) << "CTP config not found, run:" << run << ENDM;
121128
}
122-
mDecoder.setCTPConfig(*ctpconfigdb);
123-
} else {
124-
ILOG(Warning, Support) << "CTP config not found, run:" << run << ENDM;
125-
}
126-
if (mIndexMBclass == -1) {
127-
MBclassName = "CMBV0 (default)";
128-
mIndexMBclass = 1;
129+
if (mIndexMBclass == -1) {
130+
mMBclassName = "CMBV0 (default)";
131+
mIndexMBclass = 1;
132+
}
133+
mHistoClassRatios->SetTitle(Form("Class Ratio to %s", mMBclassName.c_str()));
129134
}
135+
130136
std::string nameInput1 = getFromExtendedConfig<string>(activity, mCustomParameters, "MB1inputName", "MTVX");
131137
std::string nameInput2 = getFromExtendedConfig<string>(activity, mCustomParameters, "MB2inputName", "MT0A");
132138

@@ -201,12 +207,12 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
201207
titleX2 += Form(" - %d", mShiftInput2);
202208
}
203209
mHistoBCMinBias2->SetTitle(Form("%s; %s; %s", title2.Data(), titleX2.Data(), titley2.Data()));
204-
mHistoClassRatios->SetTitle(Form("Class Ratio to %s", MBclassName.c_str()));
205210
mHistoInputRatios->SetTitle(Form("Input Ratio to %s", nameInput1.c_str()));
206211

207212
std::string performConsistencyCheck = getFromExtendedConfig<string>(activity, mCustomParameters, "consistencyCheck", "true");
208213
if (performConsistencyCheck == "true") {
209214
mDecoder.setCheckConsistency(1);
215+
mDecoder.setDecodeInps(1);
210216
} else {
211217
mDecoder.setCheckConsistency(0);
212218
}
@@ -226,10 +232,47 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx)
226232
std::vector<o2::ctp::LumiInfo> lumiPointsHBF1;
227233
std::vector<o2::ctp::CTPDigit> outputDigits;
228234

235+
if (mReadCTPconfigInMonitorData) {
236+
if (mCTPconfig == nullptr) {
237+
mCTPconfig = ctx.inputs().get<o2::ctp::CTPConfiguration*>("ctp-config").get();
238+
// mCTPconfig = ctpConfigPtr.get();
239+
if (mCTPconfig != nullptr) {
240+
ILOG(Info, Support) << "CTP config found" << ENDM;
241+
std::vector<o2::ctp::CTPClass> ctpcls = mCTPconfig->getCTPClasses();
242+
for (size_t i = 0; i < ctpcls.size(); i++) {
243+
classNames[i] = ctpcls[i].name.c_str();
244+
if (ctpcls[i].name.find(mMBclassName) != std::string::npos) {
245+
mIndexMBclass = ctpcls[i].getIndex() + 1;
246+
break;
247+
}
248+
}
249+
mDecoder.setCTPConfig(*mCTPconfig);
250+
}
251+
}
252+
for (int i = 0; i < nclasses; i++) {
253+
if (classNames[i] == "") {
254+
mHistoClasses.get()->GetXaxis()->SetBinLabel(i + 1, Form("%i", i + 1));
255+
mHistoClassRatios.get()->GetXaxis()->SetBinLabel(i + 1, Form("%i", i + 1));
256+
} else {
257+
mHistoClasses.get()->GetXaxis()->SetBinLabel(i + 1, Form("%s", classNames[i].c_str()));
258+
mHistoClassRatios.get()->GetXaxis()->SetBinLabel(i + 1, Form("%s", classNames[i].c_str()));
259+
}
260+
}
261+
262+
if (mIndexMBclass == -1) {
263+
mMBclassName = "CMBV0 (default)";
264+
mIndexMBclass = 1;
265+
}
266+
mHistoClassRatios->SetTitle(Form("Class Ratio to %s", mMBclassName.c_str()));
267+
}
268+
229269
o2::framework::InputRecord& inputs = ctx.inputs();
230270
int ret = mDecoder.decodeRaw(inputs, filter, outputDigits, lumiPointsHBF1);
231-
if (ret > 0) {
232-
mHistoDecodeError->Fill(log2(ret) + 1.5);
271+
mClassErrorsA = mDecoder.getClassErrorsA();
272+
for (size_t i = 0; i < o2::ctp::CTP_NCLASSES; i++) {
273+
if (mClassErrorsA[i] > 0) {
274+
mHistoDecodeError->Fill(i, mClassErrorsA[i]);
275+
}
233276
}
234277

235278
// reading the ctp inputs and ctp classes

Modules/CTP/src/qc-ctp.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,22 @@
3838
"detectorName": "CTP",
3939
"cycleDurationSeconds": "60",
4040
"resetAfterCycles": "1",
41-
"dataSource": {
41+
"dataSources": [{
4242
"type": "dataSamplingPolicy",
4343
"name": "ctp-raw"
44-
},
44+
},{
45+
"type": "direct",
46+
"query": "ctp-config:CTP/CONFIG/0?lifetime=condition&ccdb-path=CTP/Config/Config&ccdb-run-dependent=1s"
47+
}],
4548
"extendedTaskParameters": {
4649
"default": {
4750
"default": {
4851
"ccdbName": "https://alice-ccdb.cern.ch",
4952
"MBclassName" : "CMTVX-B-NOPF",
5053
"MB1inputName" : "MTVX",
5154
"MB2inputName" : "MVBA",
52-
"consistencyCheck" : "false"
55+
"consistencyCheck" : "true",
56+
"readCTPconfigInMonitorData": "true"
5357
}
5458
},
5559
"PHYSICS": {

0 commit comments

Comments
 (0)