|
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 |
0 commit comments