Skip to content

Commit 1eaf464

Browse files
gtaillepiedgtaillepied
andauthored
Mid (#699)
* MID: added raw data checker * MID: raw data checker in RawQcTask * MID: clang-format * MID: fixed link issue * MID: clang-format Co-authored-by: gtaillepied <g.taillepied@cern.ch>
1 parent 07863c2 commit 1eaf464

5 files changed

Lines changed: 227 additions & 89 deletions

File tree

Modules/MUON/MID/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ target_include_directories(
1313
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
1414
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
1515

16-
target_link_libraries(O2QcMID PUBLIC O2QualityControl O2::MIDRaw)
16+
target_link_libraries(O2QcMID PUBLIC O2QualityControl O2::MIDRaw O2::MIDQC)
1717

1818
install(TARGETS O2QcMID
1919
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -63,3 +63,5 @@ install(
6363
TARGETS ${EXE_NAMES}
6464
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
6565
)
66+
67+
install(FILES mid-raw.json DESTINATION etc)

Modules/MUON/MID/include/MID/RawQcTask.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010

1111
///
1212
/// \file RawQcTask.h
13-
/// \author Bogdan Vulpescu / Xavier Lopez
14-
///
13+
/// \author Bogdan Vulpescu
14+
/// \author Xavier Lopez
15+
/// \author Guillaume Taillepied
1516

1617
#ifndef QC_MODULE_MID_MIDRAWQCTASK_H
1718
#define QC_MODULE_MID_MIDRAWQCTASK_H
1819

1920
#include "QualityControl/TaskInterface.h"
21+
#include "MIDQC/RawDataChecker.h"
22+
#include "MIDRaw/CrateMasks.h"
23+
#include "MIDRaw/Decoder.h"
24+
#include "MIDRaw/ElectronicsDelay.h"
25+
#include "MIDRaw/FEEIdConfig.h"
2026

2127
class TH1F;
2228

@@ -45,7 +51,21 @@ class RawQcTask final : public TaskInterface
4551
void reset() override;
4652

4753
private:
54+
TH1F* mRawDataChecker = nullptr;
4855
TH1F* mDetElemID = nullptr;
56+
57+
std::string mOutFilename;
58+
std::string mFeeIdConfigFilename;
59+
std::string mCrateMasksFilename;
60+
std::string mElectronicsDelaysFilename;
61+
bool mPerGBT;
62+
bool mPerFeeId;
63+
64+
std::unique_ptr<o2::mid::Decoder> mDecoder{ nullptr };
65+
o2::mid::RawDataChecker mChecker;
66+
o2::mid::FEEIdConfig mFeeIdConfig;
67+
o2::mid::ElectronicsDelay mElectronicsDelay;
68+
o2::mid::CrateMasks mCrateMasks;
4969
};
5070

5171
} // namespace o2::quality_control_modules::mid
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
"dataSource": {
3535
"type": "dataSamplingPolicy",
3636
"name": "digits"
37+
},
38+
"taskParameters": {
39+
"feeId-config-file": "",
40+
"crate-masks-file": "",
41+
"electronics-delays-file": "",
42+
"per-gbt": "false",
43+
"per-feeId": "false",
44+
"output-file": "./QCChecker-out.txt"
3745
}
3846
}
3947
},
@@ -57,7 +65,7 @@
5765
"id": "digits",
5866
"active": "true",
5967
"machines": [],
60-
"query": "digits:MID/DATA/0",
68+
"query": "digits:MID/RAWDATA",
6169
"samplingConditions": [
6270
{
6371
"condition": "random",

Modules/MUON/MID/src/RawQcTask.cxx

Lines changed: 192 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,192 @@
1-
// Copyright CERN and copyright holders of ALICE O2. This software is
2-
// distributed under the terms of the GNU General Public License v3 (GPL
3-
// Version 3), copied verbatim in the file "COPYING".
4-
//
5-
// See http://alice-o2.web.cern.ch/license for full licensing information.
6-
//
7-
// In applying this license CERN does not waive the privileges and immunities
8-
// granted to it by virtue of its status as an Intergovernmental Organization
9-
// or submit itself to any jurisdiction.
10-
11-
///
12-
/// \file RawQcTask.cxx
13-
/// \author Bogdan Vulpescu / Xavier Lopez
14-
///
15-
16-
#include <TCanvas.h>
17-
#include <TH1.h>
18-
19-
#include "QualityControl/QcInfoLogger.h"
20-
#include "MID/RawQcTask.h"
21-
#include <Framework/InputRecord.h>
22-
23-
#include "Framework/DataRefUtils.h"
24-
#include "DataFormatsMID/ColumnData.h"
25-
26-
namespace o2::quality_control_modules::mid
27-
{
28-
29-
RawQcTask::~RawQcTask()
30-
{
31-
if (mDetElemID) {
32-
delete mDetElemID;
33-
}
34-
}
35-
36-
void RawQcTask::initialize(o2::framework::InitContext& /*ctx*/)
37-
{
38-
ILOG(Info) << "initialize RawQcTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
39-
mDetElemID = new TH1F("mDetElemID", "Id of detector element", 81, -0.5, 80.5);
40-
getObjectsManager()->startPublishing(mDetElemID);
41-
}
42-
43-
void RawQcTask::startOfActivity(Activity& /*activity*/)
44-
{
45-
ILOG(Info) << "startOfActivity" << ENDM;
46-
mDetElemID->Reset();
47-
}
48-
49-
void RawQcTask::startOfCycle()
50-
{
51-
ILOG(Info) << "startOfCycle" << ENDM;
52-
}
53-
54-
void RawQcTask::monitorData(o2::framework::ProcessingContext& ctx)
55-
{
56-
auto msg = ctx.inputs().get("digits");
57-
gsl::span<const o2::mid::ColumnData> patterns = o2::framework::DataRefUtils::as<const o2::mid::ColumnData>(msg);
58-
59-
// Loop on stripPatterns
60-
for (auto& col : patterns) {
61-
int deIndex = col.deId;
62-
mDetElemID->Fill(deIndex);
63-
}
64-
}
65-
66-
void RawQcTask::endOfCycle()
67-
{
68-
ILOG(Info) << "endOfCycle" << ENDM;
69-
}
70-
71-
void RawQcTask::endOfActivity(Activity& /*activity*/)
72-
{
73-
ILOG(Info) << "endOfActivity" << ENDM;
74-
}
75-
76-
void RawQcTask::reset()
77-
{
78-
// clean all the monitor objects here
79-
80-
ILOG(Info) << "Resetting the histogram" << ENDM;
81-
mDetElemID->Reset();
82-
}
83-
84-
} // namespace o2::quality_control_modules::mid
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
///
12+
/// \file RawQcTask.cxx
13+
/// \author Bogdan Vulpescu
14+
/// \author Xavier Lopez
15+
/// \author Diego Stocco
16+
/// \author Guillaume Taillepied
17+
///
18+
19+
#include <TCanvas.h>
20+
#include <TH1.h>
21+
22+
#include <iostream>
23+
#include <fstream>
24+
#include <sstream>
25+
#include <string>
26+
#include <vector>
27+
28+
#include "QualityControl/QcInfoLogger.h"
29+
#include "MID/RawQcTask.h"
30+
#include <Framework/InputRecord.h>
31+
32+
#include "Framework/DataRefUtils.h"
33+
#include "DataFormatsMID/ColumnData.h"
34+
#include "DataFormatsMID/ROBoard.h"
35+
#include "DataFormatsMID/ROFRecord.h"
36+
#include "DPLUtils/DPLRawParser.h"
37+
#include "MIDQC/RawDataChecker.h"
38+
#include "MIDRaw/CrateMasks.h"
39+
#include "MIDRaw/Decoder.h"
40+
#include "MIDRaw/ElectronicsDelay.h"
41+
#include "MIDRaw/FEEIdConfig.h"
42+
43+
namespace o2::quality_control_modules::mid
44+
{
45+
46+
RawQcTask::~RawQcTask()
47+
{
48+
if (mRawDataChecker)
49+
delete mRawDataChecker;
50+
}
51+
52+
void RawQcTask::initialize(o2::framework::InitContext& /*ctx*/)
53+
{
54+
ILOG(Info) << "initialize RawQcTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
55+
56+
// Retrieve task parameters from the config file
57+
if (auto param = mCustomParameters.find("feeId-config-file"); param != mCustomParameters.end()) {
58+
ILOG(Info) << "Custom parameter - FEE Id config file: " << param->second << ENDM;
59+
mFeeIdConfigFilename = param->second;
60+
}
61+
62+
if (auto param = mCustomParameters.find("crate-masks-file"); param != mCustomParameters.end()) {
63+
ILOG(Info) << "Custom parameter - Crate masks file: " << param->second << ENDM;
64+
mCrateMasksFilename = param->second;
65+
}
66+
67+
if (auto param = mCustomParameters.find("electronics-delays-file"); param != mCustomParameters.end()) {
68+
ILOG(Info) << "Custom parameter - Electronics delays file: " << param->second << ENDM;
69+
mElectronicsDelaysFilename = param->second;
70+
}
71+
72+
if (auto param = mCustomParameters.find("per-gbt"); param != mCustomParameters.end()) {
73+
ILOG(Info) << "Custom parameter - Reading per GBT link: " << param->second << ENDM;
74+
std::istringstream(param->second) >> std::boolalpha >> mPerGBT;
75+
}
76+
77+
if (auto param = mCustomParameters.find("per-feeId"); param != mCustomParameters.end()) {
78+
ILOG(Info) << "Custom parameter - Reading per FEE Id: " << param->second << ENDM;
79+
std::istringstream(param->second) >> std::boolalpha >> mPerFeeId;
80+
}
81+
82+
if (auto param = mCustomParameters.find("output-file"); param != mCustomParameters.end()) {
83+
ILOG(Info) << "Custom parameter - Output file: " << param->second << ENDM;
84+
mOutFilename = param->second;
85+
}
86+
87+
// Decoder configuration inputs
88+
if (!mFeeIdConfigFilename.empty()) {
89+
mFeeIdConfig = o2::mid::FEEIdConfig(mFeeIdConfigFilename.c_str());
90+
}
91+
92+
if (!mElectronicsDelaysFilename.empty()) {
93+
mElectronicsDelay = o2::mid::readElectronicsDelay(mElectronicsDelaysFilename.c_str());
94+
}
95+
96+
if (!mCrateMasksFilename.empty()) {
97+
mCrateMasks = o2::mid::CrateMasks(mCrateMasksFilename.c_str());
98+
}
99+
mChecker.init(mCrateMasks);
100+
101+
// Histograms to be published
102+
mRawDataChecker = new TH1F("mRawDataChecker", "Raw Data Checker", 2, 0, 2);
103+
mRawDataChecker->GetXaxis()->SetBinLabel(1, "Processed");
104+
mRawDataChecker->GetXaxis()->SetBinLabel(2, "Faulty");
105+
106+
getObjectsManager()->startPublishing(mRawDataChecker);
107+
}
108+
109+
void RawQcTask::startOfActivity(Activity& /*activity*/)
110+
{
111+
ILOG(Info) << "startOfActivity" << ENDM;
112+
mDetElemID->Reset();
113+
}
114+
115+
void RawQcTask::startOfCycle()
116+
{
117+
ILOG(Info) << "startOfCycle" << ENDM;
118+
}
119+
120+
void RawQcTask::monitorData(o2::framework::ProcessingContext& ctx)
121+
{
122+
123+
ILOG(Info) << "startOfDataMonitoring" << ENDM;
124+
125+
/* // FIXME
126+
// Old version if called with runMID.cxx through o2-qc-run-mid
127+
// To be included back
128+
129+
auto digits = ctx.inputs().get("digits");
130+
131+
// Get strip patterns and loop over them
132+
gsl::span<const o2::mid::ColumnData> patterns = o2::framework::DataRefUtils::as<const o2::mid::ColumnData>(msg);
133+
134+
// Loop on stripPatterns
135+
for (auto& col : patterns) {
136+
int deIndex = col.deId;
137+
mDetElemID->Fill(deIndex);
138+
}
139+
*/
140+
141+
o2::framework::DPLRawParser parser(ctx.inputs());
142+
143+
std::vector<o2::mid::ROFRecord> dummy;
144+
145+
if (!mDecoder) {
146+
auto const* rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(parser.begin().raw());
147+
mDecoder = createDecoder(*rdhPtr, true, mElectronicsDelay, mCrateMasks, mFeeIdConfig);
148+
ILOG(Info) << "Created decoder" << ENDM;
149+
}
150+
151+
mDecoder->clear();
152+
153+
int count = 0;
154+
for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
155+
auto const* rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(it.raw());
156+
gsl::span<const uint8_t> payload(it.data(), it.size());
157+
mDecoder->process(payload, *rdhPtr);
158+
++count;
159+
}
160+
161+
mChecker.clear();
162+
if (!mChecker.process(mDecoder->getData(), mDecoder->getROFRecords(), dummy)) {
163+
//ILOG(Info) << mChecker.getDebugMessage() << ENDM;
164+
mRawDataChecker->Fill("Faulty", mChecker.getNEventsFaulty());
165+
}
166+
167+
ILOG(Info) << "Number of busy raised: " << mChecker.getNBusyRaised() << ENDM;
168+
ILOG(Info) << "Fraction of faulty events: " << mChecker.getNEventsFaulty() << " / " << mChecker.getNEventsProcessed() << ENDM;
169+
ILOG(Info) << "Counts: " << count << ENDM;
170+
171+
mRawDataChecker->Fill("Processed", mChecker.getNEventsProcessed());
172+
}
173+
174+
void RawQcTask::endOfCycle()
175+
{
176+
ILOG(Info) << "endOfCycle" << ENDM;
177+
}
178+
179+
void RawQcTask::endOfActivity(Activity& /*activity*/)
180+
{
181+
ILOG(Info) << "endOfActivity" << ENDM;
182+
}
183+
184+
void RawQcTask::reset()
185+
{
186+
// clean all the monitor objects here
187+
188+
ILOG(Info) << "Resetting the histogram" << ENDM;
189+
mRawDataChecker->Reset();
190+
}
191+
192+
} // namespace o2::quality_control_modules::mid

Modules/MUON/MID/src/runMID.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ std::string getConfigPath(const ConfigContext& config)
9696
{
9797
// Determine the default config file path and name (based on option no-data-sampling and the QC_ROOT path)
9898
bool noDS = config.options().get<bool>("no-data-sampling");
99-
std::string filename = !noDS ? "raw-mid.json" : "raw-mid-no-sampling.json";
99+
std::string filename = !noDS ? "mid-raw.json" : "raw-mid-no-sampling.json";
100100
std::string defaultConfigPath = getenv("QUALITYCONTROL_ROOT") != nullptr ? std::string(getenv("QUALITYCONTROL_ROOT")) + "/etc/" + filename : "$QUALITYCONTROL_ROOT undefined";
101101
// The the optional one by the user
102102
auto userConfigPath = config.options().get<std::string>("config-path");

0 commit comments

Comments
 (0)