Skip to content

Commit f208ea8

Browse files
authored
Add Chain to monitor TOF Compressed data V2 (#336)
1 parent cc3d163 commit f208ea8

13 files changed

Lines changed: 749 additions & 134 deletions

Modules/TOF/CMakeLists.txt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22

33
add_library(QcTOF)
44

5-
target_sources(QcTOF PRIVATE src/TOFTask.cxx src/TOFCheckRawsMulti.cxx
6-
src/TOFCheckRawsTime.cxx src/TOFCheckRawsToT.cxx)
5+
target_sources(QcTOF
6+
PRIVATE src/TOFTask.cxx
7+
src/TOFTaskCompressed.cxx
8+
src/TOFDecoderCompressed.cxx
9+
src/TOFCheckDiagnostic.cxx
10+
src/TOFCheckRawsMulti.cxx
11+
src/TOFCheckRawsTime.cxx
12+
src/TOFCheckRawsToT.cxx)
713

814
target_include_directories(
915
QcTOF
1016
PUBLIC $<INSTALL_INTERFACE:include>
1117
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
12-
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
18+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
19+
)
1320

14-
target_link_libraries(QcTOF PUBLIC QualityControl)
21+
target_link_libraries(QcTOF PUBLIC QualityControl
22+
O2::TOFBase
23+
O2::TOFWorkflow
24+
O2::DataFormatsTOF
25+
O2::TOFCompression
26+
O2::TOFReconstruction)
1527

1628
install(TARGETS QcTOF
1729
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -22,6 +34,9 @@ install(TARGETS QcTOF
2234

2335
add_root_dictionary(QcTOF
2436
HEADERS include/TOF/TOFTask.h
37+
include/TOF/TOFTaskCompressed.h
38+
include/TOF/TOFDecoderCompressed.h
39+
include/TOF/TOFCheckDiagnostic.h
2540
include/TOF/TOFCheckRawsMulti.h
2641
include/TOF/TOFCheckRawsTime.h
2742
include/TOF/TOFCheckRawsToT.h
@@ -54,7 +69,7 @@ endforeach()
5469

5570
# ---- Extra scripts ----
5671

57-
install(FILES tof.json DESTINATION etc)
72+
install(FILES tof.json tofcompressed.json DESTINATION etc)
5873

5974
get_property(dirs
6075
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}

Modules/TOF/include/TOF/LinkDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#pragma link off all functions;
55

66
#pragma link C++ class o2::quality_control_modules::tof::TOFTask+;
7+
#pragma link C++ class o2::quality_control_modules::tof::TOFTaskCompressed+;
8+
#pragma link C++ class o2::quality_control_modules::tof::TOFDecoderCompressed+;
9+
#pragma link C++ class o2::quality_control_modules::tof::TOFCheckDiagnostic+;
710
#pragma link C++ class o2::quality_control_modules::tof::TOFCheckRawsMulti+;
811
#pragma link C++ class o2::quality_control_modules::tof::TOFCheckRawsTime+;
912
#pragma link C++ class o2::quality_control_modules::tof::TOFCheckRawsToT+;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 TOFCheckDiagnostic.h
13+
/// \author Nicolo' Jacazio
14+
///
15+
16+
#ifndef QC_MODULE_TOF_TOFCHECKDIAGNOSTIC_H
17+
#define QC_MODULE_TOF_TOFCHECKDIAGNOSTIC_H
18+
19+
#include "QualityControl/CheckInterface.h"
20+
#include "QualityControl/MonitorObject.h"
21+
#include "QualityControl/Quality.h"
22+
23+
namespace o2::quality_control_modules::tof
24+
{
25+
26+
/// \brief Checker for diagnostic histogram of TOF Raw data
27+
///
28+
/// \author Nicolo' Jacazio
29+
class TOFCheckDiagnostic : public o2::quality_control::checker::CheckInterface
30+
{
31+
public:
32+
/// Default constructor
33+
TOFCheckDiagnostic();
34+
/// Destructor
35+
~TOFCheckDiagnostic() override;
36+
37+
// Override interface
38+
void configure(std::string name) override;
39+
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
40+
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult) override;
41+
std::string getAcceptedType() override;
42+
43+
ClassDefOverride(TOFCheckDiagnostic, 1);
44+
};
45+
46+
} // namespace o2::quality_control_modules::tof
47+
48+
#endif // QC_MODULE_TOF_TOFCHECKDIAGNOSTIC_H

Modules/TOF/include/TOF/TOFCheckRawsMulti.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#define QC_MODULE_TOF_TOFCHECKRAWSMULTI_H
1818

1919
#include "QualityControl/CheckInterface.h"
20-
#include "QualityControl/MonitorObject.h"
21-
#include "QualityControl/Quality.h"
2220

2321
namespace o2::quality_control_modules::tof
2422
{
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 TOFDecoderCompressed.h
13+
/// \author Nicolo' Jacazio
14+
///
15+
16+
#ifndef QC_MODULE_TOF_TOFDECODERCOMPRESSED_H
17+
#define QC_MODULE_TOF_TOFDECODERCOMPRESSED_H
18+
19+
#include "TH1.h"
20+
21+
// O2 includes
22+
#include "TOFReconstruction/DecoderBase.h"
23+
#include "DataFormatsTOF/CompressedDataFormat.h"
24+
using namespace o2::tof::compressed;
25+
26+
using namespace o2::quality_control::core;
27+
28+
namespace o2::quality_control_modules::tof
29+
{
30+
31+
/// \brief TOF Quality Control class for Decoding Compressed data for TOF Compressed data QC Task
32+
/// \author Nicolo' Jacazio
33+
class TOFDecoderCompressed /*final*/
34+
: public DecoderBase
35+
// todo add back the "final" when doxygen is fixed
36+
{
37+
public:
38+
/// \brief Constructor
39+
TOFDecoderCompressed() = default;
40+
/// Destructor
41+
~TOFDecoderCompressed() = default;
42+
43+
/// Function to run decoding
44+
void decode();
45+
46+
/// Histograms to fill
47+
std::map<std::string, std::shared_ptr<TH1>> mHistos;
48+
49+
Int_t rdhread = 0; /// Number of times a RDH is read
50+
51+
private:
52+
/** decoding handlers **/
53+
void rdhHandler(const o2::header::RAWDataHeader* rdh) override;
54+
void headerHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit) override;
55+
void frameHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit,
56+
const FrameHeader_t* frameHeader, const PackedHit_t* packedHits) override;
57+
void trailerHandler(const CrateHeader_t* crateHeader, const CrateOrbit_t* crateOrbit,
58+
const CrateTrailer_t* crateTrailer, const Diagnostic_t* diagnostics) override;
59+
};
60+
61+
} // namespace o2::quality_control_modules::tof
62+
63+
#endif // QC_MODULE_TOF_TOFDECODERCOMPRESSED_H
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 TOFTaskCompressed.h
13+
/// \author Nicolo' Jacazio
14+
///
15+
16+
#ifndef QC_MODULE_TOF_TOFTASKCOMPRESSED_H
17+
#define QC_MODULE_TOF_TOFTASKCOMPRESSED_H
18+
19+
// QC includes
20+
#include "QualityControl/TaskInterface.h"
21+
#include "TOF/TOFDecoderCompressed.h"
22+
23+
class TH1F;
24+
class TH2F;
25+
class TH1I;
26+
class TH2I;
27+
28+
using namespace o2::quality_control::core;
29+
30+
namespace o2::quality_control_modules::tof
31+
{
32+
33+
/// \brief TOF Quality Control DPL Task for TOF Compressed data
34+
/// \author Nicolo' Jacazio
35+
class TOFTaskCompressed /*final*/
36+
: public TaskInterface // todo add back the "final" when doxygen is fixed
37+
{
38+
public:
39+
/// \brief Constructor
40+
TOFTaskCompressed();
41+
/// Destructor
42+
~TOFTaskCompressed() override;
43+
44+
// Definition of the methods for the template method pattern
45+
void initialize(o2::framework::InitContext& ctx) override;
46+
void startOfActivity(Activity& activity) override;
47+
void startOfCycle() override;
48+
void monitorData(o2::framework::ProcessingContext& ctx) override;
49+
void endOfCycle() override;
50+
void endOfActivity(Activity& activity) override;
51+
void reset() override;
52+
53+
private:
54+
TOFDecoderCompressed mDecoder; /// Decoder for TOF Compressed data useful for the Task
55+
std::shared_ptr<TH1F> mHits; /// Number of TOF hits
56+
std::shared_ptr<TH1F> mTime; /// Time
57+
std::shared_ptr<TH1F> mTimeBC; /// Time in Bunch Crossing
58+
std::shared_ptr<TH1F> mTOT; /// Time-Over-Threshold
59+
std::shared_ptr<TH1F> mIndexE; /// Index in electronic
60+
std::shared_ptr<TH2F> mSlotEnableMask; /// Enabled slot
61+
std::shared_ptr<TH2F> mDiagnostic; /// Diagnostic histogram
62+
};
63+
64+
} // namespace o2::quality_control_modules::tof
65+
66+
#endif // QC_MODULE_TOF_TOFTASKCOMPRESSED_H
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 TOFCheckDiagnostic.cxx
13+
/// \author Nicolo' Jacazio
14+
///
15+
16+
// QC
17+
#include "TOF/TOFCheckDiagnostic.h"
18+
#include "QualityControl/MonitorObject.h"
19+
#include "QualityControl/Quality.h"
20+
21+
#include <fairlogger/Logger.h>
22+
// ROOT
23+
#include <TH1.h>
24+
#include <TH2.h>
25+
#include <TPaveText.h>
26+
#include <TList.h>
27+
28+
using namespace std;
29+
30+
namespace o2::quality_control_modules::tof
31+
{
32+
33+
TOFCheckDiagnostic::TOFCheckDiagnostic()
34+
{
35+
}
36+
37+
TOFCheckDiagnostic::~TOFCheckDiagnostic() {}
38+
39+
void TOFCheckDiagnostic::configure(std::string) {}
40+
41+
Quality TOFCheckDiagnostic::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
42+
{
43+
44+
Quality result = Quality::Null;
45+
46+
for (auto& [moName, mo] : *moMap) {
47+
(void)moName;
48+
if (mo->getName() == "hDiagnostic") {
49+
auto* h = dynamic_cast<TH2F*>(mo->getObject());
50+
if (h->GetEntries() == 0) {
51+
result = Quality::Medium;
52+
}
53+
}
54+
}
55+
return result;
56+
}
57+
58+
std::string TOFCheckDiagnostic::getAcceptedType() { return "TH2F"; }
59+
60+
void TOFCheckDiagnostic::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
61+
{
62+
if (mo->getName() == "hDiagnostic") {
63+
auto* h = dynamic_cast<TH2F*>(mo->getObject());
64+
TPaveText* msg = new TPaveText(0.5, 0.5, 0.9, 0.75, "NDC");
65+
h->GetListOfFunctions()->Add(msg);
66+
msg->Draw();
67+
msg->SetName(Form("%s_msg", mo->GetName()));
68+
69+
if (checkResult == Quality::Good) {
70+
LOG(INFO) << "Quality::Good, setting to green";
71+
msg->Clear();
72+
msg->AddText("OK!");
73+
msg->SetFillColor(kGreen);
74+
//
75+
h->SetFillColor(kGreen);
76+
} else if (checkResult == Quality::Bad) {
77+
LOG(INFO) << "Quality::Bad, setting to red";
78+
//
79+
msg->Clear();
80+
msg->AddText("No TOF hits for all events.");
81+
msg->AddText("Call TOF on-call.");
82+
msg->SetFillColor(kRed);
83+
//
84+
h->SetFillColor(kRed);
85+
} else if (checkResult == Quality::Medium) {
86+
LOG(INFO) << "Quality::medium, setting to orange";
87+
//
88+
msg->Clear();
89+
msg->AddText("No entries. IF TOF IN RUN");
90+
msg->AddText("check the TOF TWiki");
91+
msg->SetFillColor(kYellow);
92+
//
93+
h->SetFillColor(kOrange);
94+
} else {
95+
LOG(INFO) << "Quality::Null, setting to black background";
96+
msg->SetFillColor(kBlack);
97+
}
98+
} else
99+
LOG(ERROR) << "Did not get correct histo from " << mo->GetName();
100+
}
101+
102+
} // namespace o2::quality_control_modules::tof

0 commit comments

Comments
 (0)