Skip to content

Commit 41c4efb

Browse files
authored
CTF size monitoring for synch. reco (#2234)
* Add CTF size monitoring task * Reset histograms only after they have been created
1 parent b34b81c commit 41c4efb

5 files changed

Lines changed: 199 additions & 7 deletions

File tree

Modules/Common/include/Common/Utils.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ namespace o2::quality_control_modules::common
3333
template <typename T>
3434
T getFromConfig(const quality_control::core::CustomParameters& params, const std::string_view name, T retVal = T{})
3535
{
36-
const auto last = params.end();
3736
const auto itParam = params.find(name.data());
38-
39-
if (itParam == last) {
37+
if (itParam == params.end()) {
4038
LOGP(warning, "Missing parameter. Please add '{}': '<value>' to the 'taskParameters'. Using default value {}.", name.data(), retVal);
4139
} else {
4240
const auto& param = itParam->second;
@@ -56,8 +54,6 @@ T getFromConfig(const quality_control::core::CustomParameters& params, const std
5654
} else {
5755
LOG(error) << fmt::format("Please provide a valid boolean value for {}.", name.data()).data();
5856
}
59-
} else if constexpr (std::is_same<std::string, T>::value) {
60-
retVal = param;
6157
} else {
6258
LOG(error) << "Template type not supported";
6359
}

Modules/GLO/CMakeLists.txt

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

33
add_library(O2QcGLO)
44

5-
target_sources(O2QcGLO PRIVATE src/MeanVertexPostProcessing.cxx src/MeanVertexCheck.cxx src/VertexingQcTask.cxx src/ITSTPCMatchingTask.cxx src/DataCompressionQcTask.cxx)
5+
target_sources(O2QcGLO PRIVATE src/MeanVertexPostProcessing.cxx src/MeanVertexCheck.cxx src/VertexingQcTask.cxx src/ITSTPCMatchingTask.cxx src/DataCompressionQcTask.cxx src/CTFSizeTask.cxx)
66

77
target_include_directories(
88
O2QcGLO
@@ -45,6 +45,7 @@ add_root_dictionary(O2QcGLO
4545
include/GLO/VertexingQcTask.h
4646
include/GLO/ITSTPCMatchingTask.h
4747
include/GLO/DataCompressionQcTask.h
48+
include/GLO/CTFSizeTask.h
4849
LINKDEF include/GLO/LinkDef.h)
4950

5051
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/GLO
@@ -66,4 +67,3 @@ foreach(test ${TEST_SRCS})
6667
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
6768
set_tests_properties(${test_name} PROPERTIES TIMEOUT 20)
6869
endforeach()
69-
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 CTFSizeTask.h
14+
/// \author Ole Schmidt
15+
///
16+
17+
#ifndef QC_MODULE_GLO_CTFSIZETASK_H
18+
#define QC_MODULE_GLO_CTFSIZETASK_H
19+
20+
#include "QualityControl/TaskInterface.h"
21+
#include <DetectorsCommonDataFormats/DetID.h>
22+
23+
#include <tuple>
24+
#include <array>
25+
#include <string>
26+
27+
class TH1F;
28+
29+
using namespace o2::quality_control::core;
30+
31+
namespace o2::quality_control_modules::glo
32+
{
33+
34+
class CTFSize final : public TaskInterface
35+
{
36+
public:
37+
/// \brief Constructor
38+
CTFSize() = default;
39+
/// Destructor
40+
~CTFSize() override;
41+
42+
std::tuple<int, float, float> getBinningFromConfig(o2::detectors::DetID::ID iDet, const Activity& activity) const;
43+
44+
// Definition of the methods for the template method pattern
45+
void initialize(o2::framework::InitContext& ctx) override;
46+
void startOfActivity(const Activity& activity) override;
47+
void startOfCycle() override;
48+
void monitorData(o2::framework::ProcessingContext& ctx) override;
49+
void endOfCycle() override;
50+
void endOfActivity(const Activity& activity) override;
51+
void reset() override;
52+
53+
private:
54+
std::array<TH1F*, o2::detectors::DetID::CTP + 1> mHistSizes{ nullptr }; // CTF size per TF for each detector with different binning per detector
55+
std::array<TH1F*, o2::detectors::DetID::CTP + 1> mHistSizesLog{ nullptr }; // CTF size per TF with same axis scale for all detectors
56+
std::array<std::string, o2::detectors::DetID::CTP + 1> mDefaultBinning{ "" }; // default number of bins and limits for mHistSizes (customizable)
57+
bool mPublishingDone{ false };
58+
};
59+
60+
} // namespace o2::quality_control_modules::glo
61+
62+
#endif // QC_MODULE_GLO_CTFSIZETASK_H

Modules/GLO/include/GLO/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
#pragma link C++ class o2::quality_control_modules::glo::MeanVertexPostProcessing + ;
1111

1212
#pragma link C++ class o2::quality_control_modules::glo::MeanVertexCheck + ;
13+
#pragma link C++ class o2::quality_control_modules::glo::CTFSize + ;
1314
#endif

Modules/GLO/src/CTFSizeTask.cxx

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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 CTFSizeTask.cxx
14+
/// \author Ole Schmidt
15+
///
16+
17+
#include <TH1F.h>
18+
#include <TMath.h>
19+
#include "QualityControl/QcInfoLogger.h"
20+
#include "GLO/CTFSizeTask.h"
21+
#include <Framework/InputRecord.h>
22+
23+
using namespace o2::detectors;
24+
25+
namespace o2::quality_control_modules::glo
26+
{
27+
28+
CTFSize::~CTFSize()
29+
{
30+
}
31+
32+
std::tuple<int, float, float> CTFSize::getBinningFromConfig(o2::detectors::DetID::ID iDet, const Activity& activity) const
33+
{
34+
std::string cfKey = "binning";
35+
cfKey += DetID::getName(iDet);
36+
std::string binning = mCustomParameters.atOptional(cfKey, activity).value_or(mDefaultBinning[iDet]);
37+
auto nBins = std::stoi(binning.substr(0, binning.find(",")));
38+
binning.erase(0, binning.find(",") + 1);
39+
auto xMin = std::stof(binning.substr(0, binning.find(",")));
40+
binning.erase(0, binning.find(",") + 1);
41+
auto xMax = std::stof(binning.substr(0, binning.find(",")));
42+
return std::make_tuple(nBins, xMin, xMax);
43+
}
44+
45+
void CTFSize::initialize(o2::framework::InitContext& /*ctx*/)
46+
{
47+
// default lower limit from pp run 549884 and upper limit from PbPb run 543918, each limit with some margin
48+
mDefaultBinning[DetID::ITS] = "1000, 1e2, 1e5";
49+
mDefaultBinning[DetID::TPC] = "1000, 1e3, 1e6";
50+
mDefaultBinning[DetID::TRD] = "1000, 1e2, 1e5";
51+
mDefaultBinning[DetID::TOF] = "1000, 10, 1e4";
52+
mDefaultBinning[DetID::PHS] = "100, 10, 1e3";
53+
mDefaultBinning[DetID::CPV] = "100, 10, 3e4";
54+
mDefaultBinning[DetID::EMC] = "1000, 100, 5e5";
55+
mDefaultBinning[DetID::HMP] = "100, 1, 300";
56+
mDefaultBinning[DetID::MFT] = "1000, 1e2, 1e4";
57+
mDefaultBinning[DetID::MCH] = "100, 1e3, 5e4";
58+
mDefaultBinning[DetID::MID] = "100, 10, 500";
59+
mDefaultBinning[DetID::ZDC] = "100, 1e3, 1e4";
60+
mDefaultBinning[DetID::FT0] = "100, 1, 500";
61+
mDefaultBinning[DetID::FV0] = "100, 1, 400";
62+
mDefaultBinning[DetID::FDD] = "100, 1, 100";
63+
mDefaultBinning[DetID::CTP] = "100, 1, 100";
64+
mDefaultBinning[DetID::TST] = "1, 0, 1";
65+
66+
constexpr int nLogBins = 100;
67+
float xBins[nLogBins + 1];
68+
float xBinLogMin = 0.f;
69+
float xBinLogMax = 11.f;
70+
float logBinWidth = (xBinLogMax - xBinLogMin) / nLogBins;
71+
for (int iBin = 0; iBin <= nLogBins; ++iBin) {
72+
xBins[iBin] = TMath::Power(10, xBinLogMin + iBin * logBinWidth);
73+
}
74+
for (int iDet = 0; iDet < DetID::CTP + 1; ++iDet) {
75+
mHistSizesLog[iDet] = new TH1F(Form("hSizeLog_%s", DetID::getName(iDet)), Form("%s CTF size per TF;Byte;counts", DetID::getName(iDet)), nLogBins, xBins);
76+
getObjectsManager()->startPublishing(mHistSizesLog[iDet]);
77+
getObjectsManager()->setDefaultDrawOptions(mHistSizesLog[iDet]->GetName(), "logx");
78+
}
79+
}
80+
81+
void CTFSize::startOfActivity(const Activity& activity)
82+
{
83+
if (!mPublishingDone) {
84+
for (int iDet = 0; iDet < DetID::CTP + 1; ++iDet) {
85+
auto binning = getBinningFromConfig(iDet, activity);
86+
std::string unit = (iDet == DetID::EMC || iDet == DetID::CPV) ? "B" : "kB";
87+
mHistSizes[iDet] = new TH1F(Form("hSize_%s", DetID::getName(iDet)), Form("%s CTF size per TF;%s;counts", DetID::getName(iDet), unit.c_str()), std::get<0>(binning), std::get<1>(binning), std::get<2>(binning));
88+
getObjectsManager()->startPublishing(mHistSizes[iDet]);
89+
}
90+
mPublishingDone = true;
91+
}
92+
reset();
93+
}
94+
95+
void CTFSize::startOfCycle()
96+
{
97+
// reset();
98+
}
99+
100+
void CTFSize::monitorData(o2::framework::ProcessingContext& ctx)
101+
{
102+
const auto sizes = ctx.inputs().get<std::array<size_t, DetID::CTP + 1>>("ctfSizes");
103+
for (int iDet = 0; iDet <= DetID::CTP; ++iDet) {
104+
std::cout << DetID::getName(iDet) << ": " << sizes[iDet] << std::endl;
105+
float conversion = (iDet == DetID::EMC || iDet == DetID::CPV) ? 1.f : 1024.f; // EMC and CPV can sent <1kB per CTF
106+
mHistSizes[iDet]->Fill(sizes[iDet] / conversion);
107+
mHistSizesLog[iDet]->Fill(sizes[iDet]);
108+
}
109+
}
110+
111+
void CTFSize::endOfCycle()
112+
{
113+
}
114+
115+
void CTFSize::endOfActivity(const Activity& /*activity*/)
116+
{
117+
}
118+
119+
void CTFSize::reset()
120+
{
121+
for (auto h : mHistSizes) {
122+
if (h) {
123+
h->Reset();
124+
}
125+
}
126+
for (auto h : mHistSizesLog) {
127+
if (h) {
128+
h->Reset();
129+
}
130+
}
131+
}
132+
133+
} // namespace o2::quality_control_modules::glo

0 commit comments

Comments
 (0)