Skip to content

Commit c518497

Browse files
lhusovaLucia Anna Tarasovicova
andauthored
CTP: CB filling scheme check added (#2007)
* CTP: CB filling scheme check added * implementation of comments from Piotr * clang fix * clang fix --------- Co-authored-by: Lucia Anna Tarasovicova <lucia.anna.husova@cern.ch>
1 parent 2165a57 commit c518497

5 files changed

Lines changed: 209 additions & 7 deletions

File tree

Modules/CTP/CMakeLists.txt

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

33
add_library(O2QcCTP)
44

5-
target_sources(O2QcCTP PRIVATE src/CountersQcTask.cxx src/RawDataQcTask.cxx )
5+
target_sources(O2QcCTP PRIVATE src/RawDataReaderCheck.cxx src/CountersQcTask.cxx src/RawDataQcTask.cxx )
66

77
target_include_directories(
88
O2QcCTP
@@ -21,7 +21,8 @@ add_root_dictionary(O2QcCTP
2121
HEADERS
2222
include/CTP/CountersQcTask.h
2323
include/CTP/RawDataQcTask.h
24-
LINKDEF include/CTP/LinkDef.h)
24+
include/CTP/RawDataReaderCheck.h
25+
LINKDEF include/CTP/LinkDef.h)
2526

2627
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CTP
2728
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl")
@@ -42,4 +43,3 @@ foreach(test ${TEST_SRCS})
4243
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
4344
set_tests_properties(${test_name} PROPERTIES TIMEOUT 20)
4445
endforeach()
45-

Modules/CTP/include/CTP/LinkDef.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
#pragma link C++ class o2::quality_control_modules::ctp::CTPRawDataReaderTask + ;
77

8-
#pragma link C++ class o2::quality_control_modules::ctp::CTPCountersTask+;
8+
#pragma link C++ class o2::quality_control_modules::ctp::CTPCountersTask + ;
9+
#pragma link C++ class o2::quality_control_modules::ctp::RawDataReaderCheck + ;
10+
911
#endif
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 RawDataReaderCheck.h
14+
/// \author Lucia Anna Tarasovicova
15+
///
16+
17+
#ifndef QC_MODULE_CTP_CTPRAWDATAREADERCHECK_H
18+
#define QC_MODULE_CTP_CTPRAWDATAREADERCHECK_H
19+
20+
#include "QualityControl/CheckInterface.h"
21+
22+
namespace o2::quality_control_modules::ctp
23+
{
24+
25+
/// \brief This class is checking the expected BC filling scheme
26+
/// \author Lucia Anna Tarasovicova
27+
class RawDataReaderCheck : public o2::quality_control::checker::CheckInterface
28+
{
29+
public:
30+
/// Default constructor
31+
RawDataReaderCheck() = default;
32+
/// Destructor
33+
~RawDataReaderCheck() 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+
41+
ClassDefOverride(RawDataReaderCheck, 2);
42+
43+
private:
44+
int getRunNumberFromMO(std::shared_ptr<MonitorObject> mo);
45+
46+
int mRunNumber;
47+
long int mTimestamp;
48+
};
49+
50+
} // namespace o2::quality_control_modules::ctp
51+
52+
#endif // QC_MODULE_CTP_CTPRAWDATAREADERCHECK_H

Modules/CTP/src/RawDataQcTask.cxx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
///
1313
/// \file RawDataQcTask.cxx
1414
/// \author Marek Bombara
15+
/// \author Lucia Anna Tarasovicova
1516
///
1617

1718
#include <TCanvas.h>
@@ -23,8 +24,11 @@
2324
#include "Headers/RAWDataHeader.h"
2425
#include "DPLUtils/DPLRawParser.h"
2526
#include "DataFormatsCTP/Digits.h"
27+
#include "DataFormatsCTP/Configuration.h"
28+
#include "DataFormatsCTP/RunManager.h"
2629
#include <Framework/InputRecord.h>
2730
#include <Framework/InputRecordWalker.h>
31+
#include "Framework/TimingInfo.h"
2832

2933
namespace o2::quality_control_modules::ctp
3034
{
@@ -70,16 +74,23 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx)
7074
std::vector<o2::framework::InputSpec> filter;
7175
std::vector<o2::ctp::LumiInfo> lumiPointsHBF1;
7276
std::vector<o2::ctp::CTPDigit> outputDigits;
73-
mDecoder.decodeRaw(ctx.inputs(), filter, outputDigits, lumiPointsHBF1);
77+
78+
o2::framework::InputRecord& inputs = ctx.inputs();
79+
mDecoder.decodeRaw(inputs, filter, outputDigits, lumiPointsHBF1);
80+
81+
std::string nameInput = "MTVX";
82+
auto indexTvx = o2::ctp::CTPInputsConfiguration::getInputIndexFromName(nameInput);
7483

7584
for (auto const digit : outputDigits) {
7685
uint16_t bcid = digit.intRecord.bc;
7786
// LOG(info) << "bcid = " << bcid;
78-
mHistoBC->Fill(bcid);
87+
if (digit.CTPInputMask[indexTvx - 1]) {
88+
mHistoBC->Fill(bcid);
89+
}
7990
if (digit.CTPInputMask.count()) {
8091
for (int i = 0; i < o2::ctp::CTP_NINPUTS; i++) {
8192
if (digit.CTPInputMask[i]) {
82-
// LOG(info) << "i of input = " << i;
93+
// LOG(info) << "i of input = " << i;#
8394
mHistoInputs->Fill(i);
8495
}
8596
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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 RawDataReaderCheck.cxx
14+
/// \author Lucia Anna Tarasovicova
15+
///
16+
17+
#include "CTP/RawDataReaderCheck.h"
18+
#include "QualityControl/MonitorObject.h"
19+
#include "QualityControl/Quality.h"
20+
#include "QualityControl/QcInfoLogger.h"
21+
#include "DataFormatsCTP/Configuration.h"
22+
#include "DataFormatsCTP/RunManager.h"
23+
// ROOT
24+
#include <TH1.h>
25+
#include <TLatex.h>
26+
#include "DataFormatsCTP/Configuration.h"
27+
#include "CCDB/BasicCCDBManager.h"
28+
#include "DataFormatsParameters/GRPLHCIFData.h"
29+
30+
#include <DataFormatsQualityControl/FlagReasons.h>
31+
32+
using namespace std;
33+
using namespace o2::quality_control;
34+
using namespace o2::ctp;
35+
36+
namespace o2::quality_control_modules::ctp
37+
{
38+
39+
void RawDataReaderCheck::configure() {}
40+
41+
Quality RawDataReaderCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
42+
{
43+
Quality result = Quality::Null;
44+
45+
// you can get details about the activity via the object mActivity:
46+
ILOG(Debug, Devel) << "Run " << getActivity()->mId << ", type: " << getActivity()->mType << ", beam: " << getActivity()->mBeamType << ENDM;
47+
// and you can get your custom parameters:
48+
ILOG(Debug, Devel) << "custom param physics.pp.myOwnKey1 : " << mCustomParameters.atOrDefaultValue("myOwnKey1", "physics", "pp", "default_value") << ENDM;
49+
50+
mRunNumber = getActivity()->mId;
51+
52+
map<string, string> metadata; // can be empty
53+
auto mo = moMap->begin()->second;
54+
mTimestamp = mo->getValidity().getMin();
55+
auto lhcifdata = UserCodeInterface::retrieveConditionAny<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", metadata, mTimestamp);
56+
auto bfilling = lhcifdata->getBunchFilling();
57+
std::vector<int> bcs = bfilling.getFilledBCs();
58+
o2::ctp::BCMask* bcmask;
59+
std::bitset<o2::constants::lhc::LHCMaxBunches> lhcBC_bitset = bcmask->BCmask;
60+
lhcBC_bitset.reset();
61+
62+
for (auto const& bc : bcs) {
63+
lhcBC_bitset.set(bc, 1);
64+
}
65+
66+
int threshold = 10;
67+
68+
for (auto& [moName, mo] : *moMap) {
69+
70+
(void)moName;
71+
if (mo->getName() == "histobc") {
72+
auto* h = dynamic_cast<TH1F*>(mo->getObject());
73+
74+
result = Quality::Good;
75+
result.addMetadata("BC_id", "good");
76+
for (int i = 0; i < o2::constants::lhc::LHCMaxBunches; i++) {
77+
if (lhcBC_bitset[i] && h->GetBinContent(i + 1) < threshold) {
78+
result = Quality::Bad;
79+
result.updateMetadata(Form("BC_id%d", i + 1), "bad");
80+
result.addReason(quality_control::FlagReasonFactory::Unknown(), "Bunch crossing is expected, but not measured");
81+
break;
82+
}
83+
if (lhcBC_bitset[i] && h->GetBinContent(i + 1) == threshold) {
84+
result = Quality::Medium;
85+
result.updateMetadata(Form("BC_id%d", i + 1), "medium");
86+
result.addReason(quality_control::FlagReasonFactory::Unknown(), "Bunch crossing is expected, at the threshold of background");
87+
}
88+
if (!lhcBC_bitset[i] && h->GetBinContent(i + 1) == threshold) {
89+
result = Quality::Medium;
90+
result.updateMetadata(Form("BC_id%d", i + 1), "medium");
91+
result.addReason(quality_control::FlagReasonFactory::Unknown(), "Bunch crossing not expected, at the threshold of background");
92+
}
93+
if (!lhcBC_bitset[i] && h->GetBinContent(i + 1) > threshold) {
94+
result = Quality::Bad;
95+
result.updateMetadata(Form("BC_id%d", i + 1), "bad");
96+
result.addReason(quality_control::FlagReasonFactory::Unknown(), "Bunch crossing not expected, but measured");
97+
break;
98+
}
99+
}
100+
}
101+
}
102+
return result;
103+
}
104+
105+
std::string RawDataReaderCheck::getAcceptedType() { return "TH1"; }
106+
107+
void RawDataReaderCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
108+
{
109+
std::shared_ptr<TLatex> msg;
110+
if (mo->getName() == "histobc") {
111+
auto* h = dynamic_cast<TH1F*>(mo->getObject());
112+
113+
if (checkResult == Quality::Good) {
114+
h->SetLineColor(kGreen);
115+
} else if (checkResult == Quality::Bad) {
116+
ILOG(Debug, Devel) << "Quality::Bad, setting to red" << ENDM;
117+
msg = std::make_shared<TLatex>(0.15, 0.8, Form("Reason: %s", (std::get<1>(checkResult.getReasons()[0])).c_str()));
118+
msg->SetTextColor(kRed);
119+
msg->SetTextSize(0.06);
120+
msg->SetTextFont(43);
121+
msg->SetNDC();
122+
h->GetListOfFunctions()->Add(msg->Clone());
123+
h->SetLineColor(kRed);
124+
} else if (checkResult == Quality::Medium) {
125+
ILOG(Debug, Devel) << "Quality::medium, setting to orange" << ENDM;
126+
msg = std::make_shared<TLatex>(0.15, 0.8, Form("Reason: %s", (std::get<1>(checkResult.getReasons()[0])).c_str()));
127+
msg->SetTextColor(kOrange);
128+
msg->SetTextSize(0.06);
129+
msg->SetTextFont(43);
130+
msg->SetNDC();
131+
h->GetListOfFunctions()->Add(msg->Clone());
132+
h->SetLineColor(kOrange);
133+
}
134+
}
135+
}
136+
137+
} // namespace o2::quality_control_modules::ctp

0 commit comments

Comments
 (0)