Skip to content

Commit 11f73b6

Browse files
authored
Add postprocessing to show TOF diagnostic output per crate (#512)
- include minor fixes to counter class
1 parent 79ea4ef commit 11f73b6

6 files changed

Lines changed: 228 additions & 1 deletion

File tree

Modules/TOF/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ target_sources(QcTOF
1313
src/CheckRawMultiplicity.cxx
1414
src/CheckRawTime.cxx
1515
src/CheckRawToT.cxx
16+
# PostProcessing
17+
src/PostProcessDiagnosticPerCrate.cxx
1618
# Utilities
1719
)
1820

@@ -48,6 +50,8 @@ add_root_dictionary(QcTOF
4850
include/TOF/CheckRawMultiplicity.h
4951
include/TOF/CheckRawTime.h
5052
include/TOF/CheckRawToT.h
53+
# PostProcessing
54+
include/TOF/PostProcessDiagnosticPerCrate.h
5155
# Utilities
5256
include/Base/Counter.h
5357
LINKDEF include/TOF/LinkDef.h
@@ -82,6 +86,7 @@ set_tests_properties(testQcTOF PROPERTIES TIMEOUT 20)
8286
install(FILES tof.json
8387
tofcompressed.json
8488
tofdiagnostics.json
89+
tofpostprocessdiagnosticpercrate.json
8590
DESTINATION etc)
8691

8792
get_property(dirs

Modules/TOF/include/Base/Counter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Counter
131131
LOG(FATAL) << "Filling histogram " << h->GetName() << " at position " << binx << " i.e. past its size (" << nbinsx << ")!";
132132
}
133133
if (!Tc::names[i].EqualTo(h->GetXaxis()->GetBinLabel(binx))) {
134-
LOG(FATAL) << "Bin" << binx << " does not have the expected label '" << h->GetXaxis()->GetBinLabel(binx) << "' vs '" << Tc::names[i] << "'";
134+
LOG(FATAL) << "Bin " << binx << " does not have the expected label '" << h->GetXaxis()->GetBinLabel(binx) << "' vs '" << Tc::names[i] << "'";
135135
}
136136
if (biny > 0) {
137137
if (binz > 0) {

Modules/TOF/include/TOF/LinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313
#pragma link C++ class o2::quality_control_modules::tof::CheckRawMultiplicity+;
1414
#pragma link C++ class o2::quality_control_modules::tof::CheckRawTime+;
1515
#pragma link C++ class o2::quality_control_modules::tof::CheckRawToT+;
16+
// PostProcessing
17+
#pragma link C++ class o2::quality_control_modules::tof::PostProcessDiagnosticPerCrate+;
1618
// Utilities
1719
#endif
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 PostProcessDiagnosticPerCrate.h
13+
/// \brief Post processing to rearrange TOF information at the level of the crate (maybe we should do the opposite..)
14+
/// \author Nicolo' Jacazio and Francesca Ercolessi
15+
/// \since 11/09/2020
16+
///
17+
18+
#ifndef QUALITYCONTROL_POSTPROCESSDIAGNOSTICPERCRATE_H
19+
#define QUALITYCONTROL_POSTPROCESSDIAGNOSTICPERCRATE_H
20+
21+
// QC includes
22+
#include "QualityControl/PostProcessingInterface.h"
23+
#include "QualityControl/DatabaseInterface.h"
24+
25+
#include <array>
26+
#include <memory>
27+
#include <string>
28+
29+
class TH1F;
30+
class TH2F;
31+
32+
namespace o2::quality_control_modules::tof
33+
{
34+
35+
/// \brief Post processing to rearrange TOF information at the level of the crate (maybe we should do the opposite..)
36+
/// \author Nicolo' Jacazio and Francesca Ercolessi
37+
class PostProcessDiagnosticPerCrate final : public quality_control::postprocessing::PostProcessingInterface
38+
{
39+
public:
40+
/// \brief Constructor
41+
PostProcessDiagnosticPerCrate() = default;
42+
/// \brief Destructor
43+
~PostProcessDiagnosticPerCrate() override;
44+
45+
/// \brief Initialization of a post-processing task.
46+
/// Initialization of a post-processing task. User receives a Trigger which caused the initialization and a service
47+
/// registry with singleton interfaces.
48+
/// \param trigger Trigger which caused the initialization, for example Trigger::SOR
49+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
50+
void initialize(quality_control::postprocessing::Trigger, framework::ServiceRegistry&) override;
51+
/// \brief Update of a post-processing task.
52+
/// Update of a post-processing task. User receives a Trigger which caused the update and a service
53+
/// registry with singleton interfaces.
54+
/// \param trigger Trigger which caused the initialization, for example Trigger::Period
55+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
56+
void update(quality_control::postprocessing::Trigger, framework::ServiceRegistry&) override;
57+
/// \brief Finalization of a post-processing task.
58+
/// Finalization of a post-processing task. User receives a Trigger which caused the finalization and a service
59+
/// registry with singleton interfaces.
60+
/// \param trigger Trigger which caused the initialization, for example Trigger::EOR
61+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
62+
void finalize(quality_control::postprocessing::Trigger, framework::ServiceRegistry&) override;
63+
64+
private:
65+
static const int mNWords;
66+
static const int mNSlots;
67+
68+
std::array<std::shared_ptr<TH2F>, 72> mCrates;
69+
o2::quality_control::repository::DatabaseInterface* mDatabase = nullptr;
70+
static const std::string mCCDBPath;
71+
};
72+
73+
} // namespace o2::quality_control_modules::tof
74+
75+
#endif //QUALITYCONTROL_POSTPROCESSDIAGNOSTICPERCRATE_H
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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 PostProcessDiagnosticPerCrate.cxx
13+
/// \brief Post processing to rearrange TOF information at the level of the crate (maybe we should do the opposite..)
14+
/// \author Nicolo' Jacazio and Francesca Ercolessi
15+
/// \since 11/09/2020
16+
///
17+
18+
// QC includes
19+
#include "TOF/PostProcessDiagnosticPerCrate.h"
20+
#include "QualityControl/MonitorObject.h"
21+
#include "QualityControl/QcInfoLogger.h"
22+
23+
// ROOT includes
24+
#include <TH2F.h>
25+
#include <TCanvas.h>
26+
27+
using namespace o2::quality_control::postprocessing;
28+
29+
namespace o2::quality_control_modules::tof
30+
{
31+
32+
const std::string PostProcessDiagnosticPerCrate::mCCDBPath = "qc/TOF/MO/TaskDiagnostics/";
33+
const int PostProcessDiagnosticPerCrate::mNWords = 32;
34+
const int PostProcessDiagnosticPerCrate::mNSlots = 14;
35+
36+
PostProcessDiagnosticPerCrate::~PostProcessDiagnosticPerCrate()
37+
{
38+
}
39+
40+
void PostProcessDiagnosticPerCrate::initialize(Trigger, framework::ServiceRegistry& services)
41+
{
42+
int counter = 0;
43+
for (auto& i : mCrates) {
44+
i.reset(new TH2F(Form("hCrate%i", counter),
45+
Form("Crate%i;Word;Slot", counter),
46+
mNWords, 0, mNWords, mNSlots, 0, mNSlots));
47+
counter++;
48+
}
49+
50+
// Setting up services
51+
mDatabase = &services.get<o2::quality_control::repository::DatabaseInterface>();
52+
}
53+
54+
void PostProcessDiagnosticPerCrate::update(Trigger, framework::ServiceRegistry&)
55+
{
56+
ILOG(Info) << "UPDATING !" << ENDM;
57+
for (int slot = 0; slot < mNSlots; slot++) { // Loop over slots
58+
std::string moName = "DRMCounter";
59+
if (slot == 1) {
60+
moName = "LTMCounter";
61+
} else if (slot > 1) {
62+
moName = Form("TRMCounterSlot%i", slot);
63+
}
64+
ILOG(Info) << "Processing slot " << slot << " from " << moName << ENDM;
65+
auto mo = mDatabase->retrieveMO(mCCDBPath, moName);
66+
TH2F* moH = static_cast<TH2F*>(mo ? mo->getObject() : nullptr);
67+
if (moH) {
68+
for (int crate = 0; crate < moH->GetNbinsY(); crate++) { // Loop over crates
69+
ILOG(Info) << "Processing crate " << crate << ENDM;
70+
if (static_cast<unsigned int>(crate) > mCrates.size()) {
71+
ILOG(Fatal) << "Crate counter is too large " << ENDM;
72+
}
73+
for (int word = 0; word < moH->GetNbinsX(); word++) { // Loop over words
74+
ILOG(Info) << "Processing word " << word << ENDM;
75+
if (crate > mNWords) {
76+
ILOG(Fatal) << "Word counter is too large " << ENDM;
77+
}
78+
mCrates[crate]->SetBinContent(word + 1, slot + 1, moH->GetBinContent(word + 1, crate + 1));
79+
}
80+
}
81+
}
82+
}
83+
ILOG(Info) << "DONE UPDATING !" << ENDM;
84+
}
85+
86+
void PostProcessDiagnosticPerCrate::finalize(Trigger, framework::ServiceRegistry&)
87+
{
88+
ILOG(Info) << "FINALIZING !" << ENDM;
89+
90+
for (auto& i : mCrates) {
91+
TCanvas* c = new TCanvas(i->GetName(), i->GetName());
92+
i->Draw();
93+
auto mo = std::make_shared<o2::quality_control::core::MonitorObject>(c, "PostProcessDiagnosticPerCrate", "TOF");
94+
mo->setIsOwner(false);
95+
mDatabase->storeMO(mo);
96+
97+
// It should delete everything inside. Confirmed by trying to delete histo after and getting a segfault.
98+
delete c;
99+
}
100+
ILOG(Info) << "DONE FINALIZING !" << ENDM;
101+
}
102+
103+
} // namespace o2::quality_control_modules::tof
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
"postprocessing": {
26+
"PostProcessDiagnosticPerCrate": {
27+
"active": "true",
28+
"className": "o2::quality_control_modules::tof::PostProcessDiagnosticPerCrate",
29+
"moduleName": "QualityControl",
30+
"detectorName": "TOF",
31+
"dataSources": [
32+
],
33+
"plots": [
34+
],
35+
"initTrigger": [ "once" ],
36+
"updateTrigger": [ "5 seconds" ],
37+
"stopTrigger": ["10 seconds"]
38+
}
39+
}
40+
}
41+
}
42+

0 commit comments

Comments
 (0)