Skip to content

Commit 0861511

Browse files
authored
Add module MID (#489)
1 parent 56e8c6b commit 0861511

10 files changed

Lines changed: 554 additions & 0 deletions

File tree

Modules/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ add_subdirectory(TPC)
1111
add_subdirectory(ITS)
1212
add_subdirectory(MFT)
1313
add_subdirectory(PHOS)
14+
add_subdirectory(MID)

Modules/MID/CMakeLists.txt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# ---- Library ----
2+
3+
add_library(QcMID)
4+
5+
target_sources(QcMID PRIVATE src/RawQcCheck.cxx src/RawQcTask.cxx )
6+
7+
target_include_directories(
8+
QcMID
9+
PUBLIC $<INSTALL_INTERFACE:include>
10+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
11+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
12+
13+
target_link_libraries(QcMID PUBLIC QualityControl)
14+
15+
install(TARGETS QcMID
16+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
17+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
18+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
19+
20+
add_root_dictionary(QcMID
21+
HEADERS
22+
include/MID/RawQcCheck.h
23+
include/MID/RawQcTask.h
24+
LINKDEF include/MID/LinkDef.h
25+
BASENAME QcMID)
26+
27+
# ---- Test(s) ----
28+
29+
#set(TEST_SRCS test/testQcMID.cxx)
30+
31+
#foreach(test ${TEST_SRCS})
32+
# get_filename_component(test_name ${test} NAME)
33+
# string(REGEX REPLACE ".cxx" "" test_name ${test_name})
34+
35+
# add_executable(${test_name} ${test})
36+
# target_link_libraries(${test_name}
37+
# PRIVATE QcMID Boost::unit_test_framework)
38+
# add_test(NAME ${test_name} COMMAND ${test_name})
39+
# set_property(TARGET ${test_name}
40+
# PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
41+
# set_tests_properties(${test_name} PROPERTIES TIMEOUT 20)
42+
#endforeach()
43+
44+
# ---- Executables ----
45+
46+
set(EXE_SRCS src/runMID.cxx)
47+
48+
set(EXE_NAMES o2-qc-run-mid)
49+
50+
list(LENGTH EXE_SRCS count)
51+
math(EXPR count "${count}-1")
52+
foreach(i RANGE ${count})
53+
list(GET EXE_SRCS ${i} src)
54+
list(GET EXE_NAMES ${i} name)
55+
add_executable(${name} ${src})
56+
target_link_libraries(${name} PRIVATE QualityControl CURL::libcurl O2::MIDWorkflow O2::DetectorsBase)
57+
endforeach()
58+
59+
install(
60+
TARGETS ${EXE_NAMES}
61+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
62+
)

Modules/MID/include/MID/LinkDef.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifdef __CLING__
2+
#pragma link off all globals;
3+
#pragma link off all classes;
4+
#pragma link off all functions;
5+
6+
#pragma link C++ class o2::quality_control_modules::mid::RawQcTask+;
7+
#pragma link C++ class o2::quality_control_modules::mid::RawQcCheck+;
8+
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 RawQcCheck.h
13+
/// \author Bogdan Vulpescu / Xavier Lopez
14+
///
15+
16+
#ifndef QC_MODULE_MID_MIDRAWQCCHECK_H
17+
#define QC_MODULE_MID_MIDRAWQCCHECK_H
18+
19+
#include "QualityControl/CheckInterface.h"
20+
21+
namespace o2::quality_control_modules::mid
22+
{
23+
24+
/// \brief Count number of digits per detector elements
25+
26+
class RawQcCheck : public o2::quality_control::checker::CheckInterface
27+
{
28+
public:
29+
/// Default constructor
30+
RawQcCheck() = default;
31+
/// Destructor
32+
~RawQcCheck() override = default;
33+
34+
// Override interface
35+
void configure(std::string name) override;
36+
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
37+
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
38+
std::string getAcceptedType() override;
39+
40+
ClassDefOverride(RawQcCheck, 1);
41+
};
42+
43+
} // namespace o2::quality_control_modules::mid
44+
45+
#endif // QC_MODULE_MID_MIDRAWQCCHECK_H
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.h
13+
/// \author Bogdan Vulpescu / Xavier Lopez
14+
///
15+
16+
#ifndef QC_MODULE_MID_MIDRAWQCTASK_H
17+
#define QC_MODULE_MID_MIDRAWQCTASK_H
18+
19+
#include "QualityControl/TaskInterface.h"
20+
21+
class TH1F;
22+
23+
using namespace o2::quality_control::core;
24+
25+
namespace o2::quality_control_modules::mid
26+
{
27+
28+
/// \brief Count number of digits per detector elements
29+
30+
class RawQcTask final : public TaskInterface
31+
{
32+
public:
33+
/// \brief Constructor
34+
RawQcTask() = default;
35+
/// Destructor
36+
~RawQcTask() override;
37+
38+
// Definition of the methods for the template method pattern
39+
void initialize(o2::framework::InitContext& ctx) override;
40+
void startOfActivity(Activity& activity) override;
41+
void startOfCycle() override;
42+
void monitorData(o2::framework::ProcessingContext& ctx) override;
43+
void endOfCycle() override;
44+
void endOfActivity(Activity& activity) override;
45+
void reset() override;
46+
47+
private:
48+
TH1F* mDetElemID = nullptr;
49+
};
50+
51+
} // namespace o2::quality_control_modules::mid
52+
53+
#endif // QC_MODULE_MID_MIDRAWQCTASK_H

Modules/MID/raw-mid.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"qc": {
3+
"config": {
4+
"database": {
5+
"implementation": "CCDB",
6+
"host": "ccdb-test.cern.ch:8080",
7+
"username": "not_applicable",
8+
"password": "not_applicable",
9+
"name": "not_applicable"
10+
},
11+
"Activity": {
12+
"number": "42",
13+
"type": "2"
14+
},
15+
"monitoring": {
16+
"url": "infologger:///debug?qc"
17+
},
18+
"consul": {
19+
"url": "http://consul-test.cern.ch:8500"
20+
},
21+
"conditionDB": {
22+
"url": "ccdb-test.cern.ch:8080"
23+
}
24+
},
25+
"tasks": {
26+
"QcTestMID": {
27+
"active": "true",
28+
"className": "o2::quality_control_modules::mid::RawQcTask",
29+
"moduleName": "QcMID",
30+
"detectorName": "MID",
31+
"cycleDurationSeconds": "10",
32+
"maxNumberCycles": "-1",
33+
"dataSource_comment": "The other type of dataSource is \"direct\", see basic-no-sampling.json.",
34+
"dataSource": {
35+
"type": "dataSamplingPolicy",
36+
"name": "digits"
37+
}
38+
}
39+
},
40+
"checks": {
41+
"QcCheckMID": {
42+
"active": "true",
43+
"dataSource": [{
44+
"type": "Task",
45+
"name": "QcTestMID",
46+
"MOs": ["mDetElemID"]
47+
}],
48+
"className": "o2::quality_control_modules::mid::RawQcCheck",
49+
"moduleName": "QcMID",
50+
"detectorName": "MID",
51+
"policy": "OnAny"
52+
}
53+
}
54+
},
55+
"dataSamplingPolicies": [
56+
{
57+
"id": "digits",
58+
"active": "true",
59+
"machines": [],
60+
"query": "digits:MID/DATA/0",
61+
"samplingConditions": [
62+
{
63+
"condition": "random",
64+
"fraction": "1.0",
65+
"seed": "1234"
66+
}
67+
],
68+
"blocking": "false"
69+
}
70+
]
71+
}

Modules/MID/src/RawQcCheck.cxx

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 RawQcCheck.cxx
13+
/// \author Bogdan Vulpescu / Xavier Lopez
14+
///
15+
16+
#include "MID/RawQcCheck.h"
17+
#include "QualityControl/MonitorObject.h"
18+
#include "QualityControl/Quality.h"
19+
#include "QualityControl/QcInfoLogger.h"
20+
// ROOT
21+
#include <TH1.h>
22+
23+
using namespace std;
24+
25+
namespace o2::quality_control_modules::mid
26+
{
27+
28+
void RawQcCheck::configure(std::string) {}
29+
30+
Quality RawQcCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
31+
{
32+
Quality result = Quality::Null;
33+
int nDigMT11, nDigMT12, nDigMT21, nDigMT22;
34+
35+
for (auto& [moName, mo] : *moMap) {
36+
37+
(void)moName;
38+
if (mo->getName() == "mDetElemID") {
39+
auto* h = dynamic_cast<TH1F*>(mo->getObject());
40+
41+
result = Quality::Good;
42+
43+
nDigMT11 = nDigMT12 = nDigMT21 = nDigMT22 = 0;
44+
// count digits in stations
45+
for (int i = 1; i <= h->GetNbinsX(); i++) {
46+
if (i >= 1 && i <= 18) {
47+
nDigMT11 += h->GetBinContent(i);
48+
} else if (i >= 19 && i <= 36) {
49+
nDigMT12 += h->GetBinContent(i);
50+
} else if (i >= 37 && i <= 54) {
51+
nDigMT21 += h->GetBinContent(i);
52+
}
53+
if (i >= 55 && i <= 72) {
54+
nDigMT22 += h->GetBinContent(i);
55+
}
56+
}
57+
// set check quality
58+
if (nDigMT11 == 0) {
59+
result = Quality::Medium;
60+
if (nDigMT12 == 0) {
61+
result = Quality::Bad;
62+
}
63+
}
64+
if (nDigMT22 == 0) {
65+
result = Quality::Medium;
66+
if (nDigMT21 == 0) {
67+
result = Quality::Bad;
68+
}
69+
}
70+
71+
} // end check mDetElemID
72+
}
73+
return result;
74+
}
75+
76+
std::string RawQcCheck::getAcceptedType() { return "TH1"; }
77+
78+
void RawQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
79+
{
80+
if (mo->getName() == "mDetElemID") {
81+
auto* h = dynamic_cast<TH1F*>(mo->getObject());
82+
83+
if (checkResult == Quality::Good) {
84+
h->SetFillColor(kGreen);
85+
} else if (checkResult == Quality::Bad) {
86+
ILOG(Info) << "Quality::Bad, setting to red";
87+
h->SetFillColor(kRed);
88+
} else if (checkResult == Quality::Medium) {
89+
ILOG(Info) << "Quality::medium, setting to orange";
90+
h->SetFillColor(kOrange);
91+
}
92+
h->SetLineColor(kBlack);
93+
}
94+
}
95+
96+
} // namespace o2::quality_control_modules::mid

0 commit comments

Comments
 (0)