Skip to content

Commit 06226e6

Browse files
authored
Qcdigit task (#558)
* "Creating TRD Digit Task" * fixing indentation * adding the test/ * removed the adc prof ADC * removed a profADC * added InputRecord.h * Changed naming convention * added the superficial check, it's a place holder for now * commented out the digir row and pad: removing unused warning
1 parent 64d01f8 commit 06226e6

9 files changed

Lines changed: 422 additions & 0 deletions

File tree

Modules/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ add_subdirectory(MFT)
1313
add_subdirectory(PHOS)
1414
add_subdirectory(FT0)
1515
add_subdirectory(MID)
16+
add_subdirectory(TRD)

Modules/TRD/CMakeLists.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# ---- Library ----
2+
3+
add_library(QcTRD)
4+
5+
target_sources(QcTRD PRIVATE src/DigitsTask.cxx
6+
src/DigitsCheck.cxx)
7+
8+
target_include_directories(
9+
QcTRD
10+
PUBLIC $<INSTALL_INTERFACE:include>
11+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
12+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
13+
14+
target_link_libraries(QcTRD PUBLIC QualityControl)
15+
16+
install(TARGETS QcTRD
17+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
18+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
19+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
20+
21+
add_root_dictionary(QcTRD
22+
HEADERS
23+
include/TRD/DigitsTask.h
24+
include/TRD/DigitsCheck.h
25+
LINKDEF include/TRD/LinkDef.h
26+
BASENAME QcTRD)
27+
28+
# ---- Test(s) ----
29+
30+
set(TEST_SRCS test/testQcTRD.cxx)
31+
32+
foreach(test ${TEST_SRCS})
33+
34+
get_filename_component(test_name ${test} NAME)
35+
string(REGEX REPLACE ".cxx" "" test_name ${test_name})
36+
37+
add_executable(${test_name} ${test})
38+
target_link_libraries(${test_name}
39+
PRIVATE QcTRD Boost::unit_test_framework)
40+
41+
add_test(NAME ${test_name} COMMAND ${test_name})
42+
set_property(TARGET ${test_name}
43+
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
44+
45+
set_tests_properties(${test_name} PROPERTIES TIMEOUT 20)
46+
endforeach()
47+
48+
49+
# ---- Install ----
50+
51+
install(TARGETS QcTRD ${EXE_NAMES}
52+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
53+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
54+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
55+
56+
# ---- Install config files ----
57+
58+
install(FILES DigitsTask.json
59+
DESTINATION etc)

Modules/TRD/DigitsTask.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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://localhost:8500"
20+
},
21+
"conditionDB": {
22+
"url": "ccdb-test.cern.ch:8080"
23+
}
24+
},
25+
"tasks": {
26+
"QcTask": {
27+
"active": "true",
28+
"className": "o2::quality_control_modules::trd::DigitsTask",
29+
"moduleName": "QcTRD",
30+
"detectorName": "TRD",
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": "tst-raw"
37+
},
38+
"taskParameters": {
39+
"trdDigits": "myOwnValue"
40+
},
41+
"location": "remote"
42+
}
43+
},
44+
"checks": {
45+
"QcCheck": {
46+
"active": "true",
47+
"className": "o2::quality_control_modules::trd::DigitsCheck",
48+
"moduleName": "QcTRD",
49+
"policy": "OnAny",
50+
"detectorName": "TRD",
51+
"dataSource": [{
52+
"type": "Task",
53+
"name": "QcTask",
54+
"MOs": ["mADC"]
55+
}]
56+
}
57+
}
58+
},
59+
"dataSamplingPolicies": [
60+
{
61+
"id": "tst-raw",
62+
"active": "true",
63+
"machines": [],
64+
"query": "random:TRD/DIGITS/0",
65+
"samplingConditions": [
66+
{
67+
"condition": "random",
68+
"fraction": "1",
69+
"seed": "1234"
70+
}
71+
],
72+
"blocking": "false"
73+
}
74+
]
75+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
///
2+
/// \file DigitsCheck.h
3+
/// \author My Name
4+
///
5+
6+
#ifndef QC_MODULE_TRD_DIGITSCHECK_H
7+
#define QC_MODULE_TRD_DIGITSCHECK_H
8+
9+
#include "QualityControl/CheckInterface.h"
10+
#include <TFile.h>
11+
12+
namespace o2::quality_control_modules::trd
13+
{
14+
15+
/// \brief TRD Check
16+
/// \author My Name
17+
class DigitsCheck : public o2::quality_control::checker::CheckInterface
18+
{
19+
public:
20+
/// Default constructor
21+
DigitsCheck() = default;
22+
/// Destructor
23+
~DigitsCheck() override = default;
24+
25+
// Override interface
26+
void configure(std::string name) override;
27+
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
28+
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
29+
std::string getAcceptedType() override;
30+
31+
ClassDefOverride(DigitsCheck, 1);
32+
};
33+
34+
} // namespace o2::quality_control_modules::trd
35+
36+
#endif // QC_MODULE_TRD_DIGITSCHECK_H
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 TRDDigitQcTask.h
13+
/// \author My Name
14+
///
15+
16+
#ifndef QC_MODULE_TRD_DIGITSTASK_H
17+
#define QC_MODULE_TRD_DIGITSTASK_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::trd
26+
{
27+
28+
/// \brief Example Quality Control DPL Task
29+
/// \author My Name
30+
class DigitsTask final : public TaskInterface
31+
{
32+
33+
public:
34+
/// \brief Constructor
35+
DigitsTask() = default;
36+
/// Destructor
37+
~DigitsTask() override;
38+
39+
// Definition of the methods for the template method pattern
40+
void initialize(o2::framework::InitContext& ctx) override;
41+
void startOfActivity(Activity& activity) override;
42+
void startOfCycle() override;
43+
void monitorData(o2::framework::ProcessingContext& ctx) override;
44+
void endOfCycle() override;
45+
void endOfActivity(Activity& activity) override;
46+
void reset() override;
47+
48+
private:
49+
TH1F* mADC = nullptr;
50+
};
51+
52+
} // namespace o2::quality_control_modules::trd
53+
54+
#endif // QC_MODULE_TRD_DIGITSTASK_H

Modules/TRD/include/TRD/LinkDef.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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::trd::DigitsTask+;
7+
#pragma link C++ class o2::quality_control_modules::trd::DigitsCheck+;
8+
9+
#endif

Modules/TRD/src/DigitsCheck.cxx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
///
2+
/// \file DigitsCheck.cxx
3+
/// \author My Name
4+
///
5+
6+
#include "TRD/DigitsCheck.h"
7+
#include "QualityControl/MonitorObject.h"
8+
#include "QualityControl/Quality.h"
9+
#include "QualityControl/QcInfoLogger.h"
10+
// ROOT
11+
#include <TH1.h>
12+
13+
using namespace std;
14+
15+
namespace o2::quality_control_modules::trd
16+
{
17+
18+
void DigitsCheck::configure(std::string) {}
19+
20+
Quality DigitsCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
21+
{
22+
Quality result = Quality::Null;
23+
24+
for (auto& [moName, mo] : *moMap) {
25+
26+
(void)moName;
27+
if (mo->getName() == "trdTask") {
28+
auto* h = dynamic_cast<TH1F*>(mo->getObject());
29+
30+
result = Quality::Good;
31+
32+
for (int i = 0; i < h->GetNbinsX(); i++) {
33+
if (i > 0 && i < 8 && h->GetBinContent(i) == 0) {
34+
result = Quality::Bad;
35+
break;
36+
} else if ((i == 0 || i > 7) && h->GetBinContent(i) > 0) {
37+
result = Quality::Medium;
38+
}
39+
}
40+
}
41+
}
42+
return result;
43+
}
44+
45+
std::string DigitsCheck::getAcceptedType() { return "TH1"; }
46+
47+
void DigitsCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
48+
{
49+
if (mo->getName() == "trdTask") {
50+
auto* h = dynamic_cast<TH1F*>(mo->getObject());
51+
52+
if (checkResult == Quality::Good) {
53+
h->SetFillColor(kGreen);
54+
} else if (checkResult == Quality::Bad) {
55+
ILOG(Info) << "Quality::Bad, setting to red";
56+
h->SetFillColor(kRed);
57+
} else if (checkResult == Quality::Medium) {
58+
ILOG(Info) << "Quality::medium, setting to orange";
59+
h->SetFillColor(kOrange);
60+
}
61+
h->SetLineColor(kBlack);
62+
}
63+
}
64+
65+
} // namespace o2::quality_control_modules::trd

0 commit comments

Comments
 (0)