Skip to content

Commit 760a9de

Browse files
authored
MCH: refactoring of MCH code (#1526)
* [MCH] updated helper functions and classes - added functions to copy and add mergeable TH2 ratios - added helper class to compute histograms from the last QC cycle - added helper class to easily access post-processing configuration parameters - added helper classes for value trending - added reductor for 2D value maps in electronics representation - added helper class to access CCDB objects - added helper class to compute the aggregated quality from the quality flags of the individual detection elements * [MCH] renamed decoding errors task and added post-processing - Added diagnostics for Heart Beat packets and FEC synchronization, and improved checker - Added reference configuration file * [MCH] renamed digits task and added post-processing - Added post-processing and trending - Improved automatic quality checking - Added plots relative to the last QC cycle - Added reference configuration file * [MCH] renamed preclusters task and added post-processing - Added post-processing and trending - Improved automatic quality checking - Added plots relative to the last QC cycle - Added reference configuration file * [MCH] renamed ROFs task * [MCH] added quality aggregator and post-processor * [MCH] updated pedestals task - Added plotting of per-channel statistics - Added plotting of output bad channels table * [MCH] updated tracks plotters - fixed bug in di-muon time difference computation - removed unused chi2 plots for global tracks * [MCH] updated build files * [MCH] removed obsolete files * [MCH] added configurable messages for the quality summary canvas * [MCH] updated how post-processing task name is retrieved * [MCH] replaced std::cout with ILOG calls
1 parent 22302d0 commit 760a9de

99 files changed

Lines changed: 10144 additions & 4855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Modules/MUON/Common/include/MUONCommon/HistPlotter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ class HistPlotter
3737
void reset();
3838

3939
std::vector<HistInfo>& histograms() { return mHistograms; }
40-
4140
const std::vector<HistInfo>& histograms() const { return mHistograms; }
4241

43-
void publish(std::shared_ptr<o2::quality_control::core::ObjectsManager> objectsManager);
42+
virtual void publish(std::shared_ptr<o2::quality_control::core::ObjectsManager> objectsManager);
4443

4544
private:
4645
std::vector<HistInfo> mHistograms;

Modules/MUON/Common/include/MUONCommon/MergeableTH1Ratio.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ class MergeableTH1Ratio : public TH1F, public o2::mergers::MergeInterface
3232
{
3333
public:
3434
MergeableTH1Ratio() = default;
35-
3635
MergeableTH1Ratio(MergeableTH1Ratio const& copymerge);
37-
3836
MergeableTH1Ratio(const char* name, const char* title, int nbinsx, double xmin, double xmax, double scaling = 1.);
39-
4037
MergeableTH1Ratio(const char* name, const char* title, double scaling = 1.);
4138

4239
~MergeableTH1Ratio();

Modules/MUON/Common/include/MUONCommon/MergeableTH2Ratio.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <iostream>
2222
#include <TObject.h>
2323
#include <TH2.h>
24-
#include <TList.h>
2524
#include "Mergers/MergeInterface.h"
2625

2726
using namespace std;
@@ -31,12 +30,9 @@ namespace o2::quality_control_modules::muon
3130
class MergeableTH2Ratio : public TH2F, public o2::mergers::MergeInterface
3231
{
3332
public:
34-
MergeableTH2Ratio() = default;
35-
33+
MergeableTH2Ratio();
3634
MergeableTH2Ratio(MergeableTH2Ratio const& copymerge);
37-
3835
MergeableTH2Ratio(const char* name, const char* title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, bool showZeroBins = false);
39-
4036
MergeableTH2Ratio(const char* name, const char* title, bool showZeroBins = false);
4137

4238
~MergeableTH2Ratio();
@@ -58,11 +54,23 @@ class MergeableTH2Ratio : public TH2F, public o2::mergers::MergeInterface
5854
return mShowZeroBins;
5955
}
6056

57+
void setShowZeroBins(bool showZeroBins)
58+
{
59+
mShowZeroBins = showZeroBins;
60+
}
61+
6162
void update();
6263

6364
void beautify();
6465

66+
// functions inherited from TH2F
6567
void Reset(Option_t* option = "") override;
68+
void Copy(TObject& obj) const override;
69+
Bool_t Add(const TH1* h1, const TH1* h2, Double_t c1 = 1, Double_t c2 = 1) override;
70+
Bool_t Add(const TH1* h1, Double_t c1 = 1) override;
71+
void SetBins(Int_t nx, Double_t xmin, Double_t xmax) override;
72+
void SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax) override;
73+
void SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax, Int_t nz, Double_t zmin, Double_t zmax) override;
6674

6775
private:
6876
TH2F* mHistoNum{ nullptr };

Modules/MUON/Common/include/MUONCommon/TrackPlotter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class TrackPlotter : public HistPlotter
8282
std::unique_ptr<TH1F> mTrackBCWidth; ///< BC width associated to the track
8383
std::unique_ptr<TH1> mTrackDT; ///< time difference between MFT/MCH/MID tracks segments
8484
std::array<std::unique_ptr<TH1F>, 3> mNofTracksPerTF; ///< number of tracks per TF
85-
std::array<std::unique_ptr<TH1F>, 3> mTrackChi2OverNDF; ///< chi2/ndf for the track
8685
std::array<std::unique_ptr<TH1F>, 3> mTrackDCA; ///< DCA (cm) of the track
8786
std::array<std::unique_ptr<TH1F>, 3> mTrackEta; ///< eta of the track
8887
std::array<std::unique_ptr<TH1F>, 3> mTrackPDCA; ///< p (GeV/c) x DCA (cm) of the track

Modules/MUON/Common/src/MergeableTH2Ratio.cxx

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
/// \author Piotr Konopka, piotr.jan.konopka@cern.ch, Sebastien Perrin, Andrea Ferrero
1616

1717
#include "MUONCommon/MergeableTH2Ratio.h"
18+
#include "QualityControl/QcInfoLogger.h"
19+
#include <TList.h>
20+
21+
#include <fmt/format.h>
22+
#include <limits>
1823

1924
using namespace std;
2025
namespace o2::quality_control_modules::muon
@@ -60,6 +65,16 @@ MergeableTH2Ratio::MergeableTH2Ratio(const char* name, const char* title, bool s
6065
update();
6166
}
6267

68+
MergeableTH2Ratio::MergeableTH2Ratio() : TH2F(), o2::mergers::MergeInterface(), mShowZeroBins(false)
69+
{
70+
Bool_t bStatus = TH1::AddDirectoryStatus();
71+
TH1::AddDirectory(kFALSE);
72+
mHistoNum = new TH2F("num", "num", 10, 0, 10, 10, 0, 10);
73+
mHistoDen = new TH2F("den", "den", 10, 0, 10, 10, 0, 10);
74+
TH1::AddDirectory(bStatus);
75+
update();
76+
}
77+
6378
MergeableTH2Ratio::~MergeableTH2Ratio()
6479
{
6580
if (mHistoNum) {
@@ -111,7 +126,7 @@ void MergeableTH2Ratio::update()
111126
for (int binx = 1; binx <= mHistoNum->GetXaxis()->GetNbins(); binx++) {
112127
for (int biny = 1; biny <= mHistoNum->GetYaxis()->GetNbins(); biny++) {
113128
if (mHistoNum->GetBinContent(binx, biny) == 0 && mHistoDen->GetBinContent(binx, biny) != 0) {
114-
SetBinContent(binx, biny, 0.000001);
129+
SetBinContent(binx, biny, std::numeric_limits<float>::min());
115130
SetBinError(binx, biny, 1);
116131
}
117132
}
@@ -147,4 +162,80 @@ void MergeableTH2Ratio::Reset(Option_t* option)
147162
TH2F::Reset(option);
148163
}
149164

165+
void MergeableTH2Ratio::Copy(TObject& obj) const
166+
{
167+
auto dest = dynamic_cast<MergeableTH2Ratio*>(&obj);
168+
if (!dest) {
169+
return;
170+
}
171+
172+
getNum()->Copy(*(dest->getNum()));
173+
getDen()->Copy(*(dest->getDen()));
174+
dest->setShowZeroBins(getShowZeroBins());
175+
TH2F::Copy(obj);
176+
177+
dest->update();
178+
}
179+
180+
Bool_t MergeableTH2Ratio::Add(const TH1* h1, const TH1* h2, Double_t c1, Double_t c2)
181+
{
182+
auto m1 = dynamic_cast<const MergeableTH2Ratio*>(h1);
183+
if (!m1) {
184+
return kFALSE;
185+
}
186+
187+
auto m2 = dynamic_cast<const MergeableTH2Ratio*>(h2);
188+
if (!m2) {
189+
return kFALSE;
190+
}
191+
192+
if (!getNum()->Add(m1->getNum(), m2->getNum(), c1, c2)) {
193+
return kFALSE;
194+
}
195+
if (!getDen()->Add(m1->getDen(), m2->getDen(), c1, c2)) {
196+
return kFALSE;
197+
}
198+
199+
update();
200+
return kTRUE;
201+
}
202+
203+
Bool_t MergeableTH2Ratio::Add(const TH1* h1, Double_t c1)
204+
{
205+
auto m1 = dynamic_cast<const MergeableTH2Ratio*>(h1);
206+
if (!m1) {
207+
return kFALSE;
208+
}
209+
210+
if (!getNum()->Add(m1->getNum(), c1)) {
211+
return kFALSE;
212+
}
213+
if (!getDen()->Add(m1->getDen(), c1)) {
214+
return kFALSE;
215+
}
216+
217+
update();
218+
return kTRUE;
219+
}
220+
221+
void MergeableTH2Ratio::SetBins(Int_t nx, Double_t xmin, Double_t xmax)
222+
{
223+
ILOG(Debug, Devel) << "SetBins(Int_t nx, Double_t xmin, Double_t xmax) not valid for MergeableTH2Ratio" << ENDM;
224+
}
225+
226+
void MergeableTH2Ratio::SetBins(Int_t nx, Double_t xmin, Double_t xmax,
227+
Int_t ny, Double_t ymin, Double_t ymax)
228+
{
229+
getNum()->SetBins(nx, xmin, xmax, ny, ymin, ymax);
230+
getDen()->SetBins(nx, xmin, xmax, ny, ymin, ymax);
231+
TH2F::SetBins(nx, xmin, xmax, ny, ymin, ymax);
232+
}
233+
234+
void MergeableTH2Ratio::SetBins(Int_t nx, Double_t xmin, Double_t xmax,
235+
Int_t ny, Double_t ymin, Double_t ymax,
236+
Int_t nz, Double_t zmin, Double_t zmax)
237+
{
238+
ILOG(Debug, Devel) << "SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax, Int_t nz, Double_t zmin, Double_t zmax) not valid for MergeableTH2Ratio" << ENDM;
239+
}
240+
150241
} // namespace o2::quality_control_modules::muon

Modules/MUON/Common/src/TrackPlotter.cxx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ void TrackPlotter::createTrackHistos(int maxTracksPerTF)
7575
mTrackRAbs[1] = createHisto<TH1F>(TString::Format("%sNegative/TrackRAbs", mPath.c_str()), "Track R_{abs} (-);R_{abs} (cm)", 1000, 0, 100);
7676
mTrackRAbs[2] = createHisto<TH1F>(TString::Format("%sTrackRAbs", mPath.c_str()), "Track R_{abs};R_{abs} (cm)", 1000, 0, 100);
7777

78-
mTrackChi2OverNDF[0] = createHisto<TH1F>(TString::Format("%sPositive/TrackChi2OverNDF", mPath.c_str()), "Track #chi^{2}/ndf (+);#chi^{2}/ndf", 500, 0, 50);
79-
mTrackChi2OverNDF[1] = createHisto<TH1F>(TString::Format("%sNegative/TrackChi2OverNDF", mPath.c_str()), "Track #chi^{2}/ndf (-);#chi^{2}/ndf", 500, 0, 50);
80-
mTrackChi2OverNDF[2] = createHisto<TH1F>(TString::Format("%sTrackChi2OverNDF", mPath.c_str()), "Track #chi^{2}/ndf;#chi^{2}/ndf", 500, 0, 50);
81-
8278
mTrackBC = createHisto<TH1F>(TString::Format("%sTrackBC", mPath.c_str()), "Track BC;BC", o2::constants::lhc::LHCMaxBunches, 0, o2::constants::lhc::LHCMaxBunches);
8379
mTrackBCWidth = createHisto<TH1F>(TString::Format("%sTrackBCWidth", mPath.c_str()), "Track BCWidth;BC Width", 400, 0, 400);
8480

@@ -114,7 +110,7 @@ void TrackPlotter::fillTrackPairHistos(gsl::span<const MuonTrack> tracks)
114110
if (tracks[i].getSign() == tracks[j].getSign()) {
115111
continue;
116112
}
117-
auto dt = (tracks[i].getIR() - tracks[j].getIR()).bc2ns();
113+
auto dt = tracks[j].getIR().differenceInBCNS(tracks[i].getIR());
118114
if (std::abs(dt) > 1000) {
119115
continue;
120116
}

Modules/MUON/MCH/CMakeLists.txt

Lines changed: 92 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,89 @@ set(MODULE_NAME "O2QcMuonChambers")
33
# ---- Files ----
44

55
set(SRCS
6-
src/ErrorTask.cxx
6+
src/Helpers.cxx
7+
src/TH2ElecMapReductor.cxx
8+
src/ClusterChargeReductor.cxx
9+
src/ClusterSizeReductor.cxx
710
src/GlobalHistogram.cxx
11+
src/DecodingErrorsPlotter.cxx
12+
src/HeartBeatPacketsPlotter.cxx
13+
src/FECSyncStatusPlotter.cxx
14+
src/RatesPlotter.cxx
15+
src/RatesTrendsPlotter.cxx
16+
src/OrbitsPlotter.cxx
17+
src/EfficiencyPlotter.cxx
18+
src/EfficiencyTrendsPlotter.cxx
19+
src/ClusterChargePlotter.cxx
20+
src/ClusterChargeTrendsPlotter.cxx
21+
src/ClusterSizePlotter.cxx
22+
src/ClusterSizeTrendsPlotter.cxx
823
src/PedestalsTask.cxx
9-
src/PhysicsTaskDigits.cxx
10-
src/PhysicsTaskRofs.cxx
11-
src/PhysicsTaskPreclusters.cxx
12-
src/DecodingErrorsTask.cxx
24+
src/DigitsTask.cxx
25+
src/RofsTask.cxx
26+
src/PreclustersTask.cxx
27+
src/DecodingTask.cxx
28+
src/ErrorTask.cxx
1329
src/PedestalsCheck.cxx
14-
src/DecodingErrorsCheck.cxx
15-
src/PhysicsCheck.cxx
16-
src/PhysicsOccupancyCheck.cxx
17-
src/PhysicsPreclustersCheck.cxx
18-
src/TH1MCHReductor.cxx
30+
src/DecodingCheck.cxx
31+
src/DigitsCheck.cxx
32+
src/PreclustersCheck.cxx
1933
src/TracksTask.cxx
20-
src/TrendingConfigMCH.cxx
21-
src/TrendingFECHistRatio.cxx
34+
src/DecodingPostProcessing.cxx
35+
src/DigitsPostProcessing.cxx
36+
src/PreclustersPostProcessing.cxx
37+
src/PostProcessingConfigMCH.cxx
2238
src/TrendingTracks.cxx
39+
src/MCHAggregator.cxx
40+
src/QualityPostProcessing.cxx
41+
src/QualityCheck.cxx
2342
)
2443

2544
set(HEADERS
26-
include/MCH/ErrorTask.h
45+
include/MCH/Helpers.h
46+
include/MCH/HistoOnCycle.h
47+
include/MCH/TH2ElecMapReductor.h
48+
include/MCH/ClusterChargeReductor.h
49+
include/MCH/ClusterSizeReductor.h
2750
include/MCH/GlobalHistogram.h
51+
include/MCH/DecodingErrorsPlotter.h
52+
include/MCH/HeartBeatPacketsPlotter.h
53+
include/MCH/FECSyncStatusPlotter.h
54+
include/MCH/RatesPlotter.h
55+
include/MCH/RatesTrendsPlotter.h
56+
include/MCH/OrbitsPlotter.h
57+
include/MCH/EfficiencyPlotter.h
58+
include/MCH/EfficiencyTrendsPlotter.h
59+
include/MCH/ClusterChargePlotter.h
60+
include/MCH/ClusterChargeTrendsPlotter.h
61+
include/MCH/ClusterSizePlotter.h
62+
include/MCH/ClusterSizeTrendsPlotter.h
2863
include/MCH/PedestalsTask.h
64+
include/MCH/DigitsTask.h
2965
include/MCH/PhysicsTaskDigits.h
30-
include/MCH/PhysicsTaskRofs.h
66+
include/MCH/RofsTask.h
67+
include/MCH/PreclustersTask.h
3168
include/MCH/PhysicsTaskPreclusters.h
32-
include/MCH/DecodingErrorsTask.h
69+
include/MCH/DecodingTask.h
70+
include/MCH/ErrorTask.h
3371
include/MCH/PedestalsCheck.h
34-
include/MCH/DecodingErrorsCheck.h
35-
include/MCH/PhysicsCheck.h
36-
include/MCH/PhysicsOccupancyCheck.h
37-
include/MCH/PhysicsPreclustersCheck.h
38-
include/MCH/TH1MCHReductor.h
39-
include/MCH/MergeableTH1PseudoEfficiencyPerDE.h
40-
include/MCH/MergeableTH1PseudoEfficiencyPerDECycle.h
41-
include/MCH/MergeableTH1MPVPerDECycle.h
72+
include/MCH/DecodingCheck.h
73+
include/MCH/DigitsCheck.h
74+
include/MCH/PreclustersCheck.h
4275
include/MCH/TracksTask.h
43-
include/MCH/TrendingConfigMCH.h
44-
include/MCH/TrendingFECHistRatio.h
76+
include/MCH/DedodingPostProcessing.h
77+
include/MCH/DigitsPostProcessing.h
78+
include/MCH/PreclustersPostProcessing.h
79+
include/MCH/PostProcessingConfigMCH.h
4580
include/MCH/TrendingTracks.h
81+
include/MCH/MCHAggregator.h
82+
include/MCH/QualityPostProcessing.h
83+
include/MCH/QualityCheck.h
84+
85+
# legacy tasks
86+
include/MCH/PhysicsTaskDigits.h
87+
include/MCH/PhysicsTaskRofs.h
88+
include/MCH/PhysicsTaskPreclusters.h
4689
)
4790

4891
# ---- Library ----
@@ -55,7 +98,7 @@ target_include_directories(
5598
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
5699
)
57100

58-
target_link_libraries(${MODULE_NAME} PUBLIC O2QualityControl O2QcMUONCommon O2::CommonDataFormat O2::GPUCommon
101+
target_link_libraries(${MODULE_NAME} PUBLIC O2QualityControl O2QcMUONCommon O2::CommonDataFormat O2::GPUCommon O2::MCHGlobalMapping
59102
$<TARGET_NAME_IF_EXISTS:O2::MCHMappingFactory> O2::MCHMappingImpl4 O2::MCHMappingSegContour O2::MCHBase O2::DataFormatsMCH O2::MCHRawDecoder O2::MCHCalibration O2::MCHDigitFiltering O2::MCHPreClustering O2::MCHTracking O2::MCHConstants)
60103

61104
target_compile_definitions(${MODULE_NAME} PRIVATE $<$<TARGET_EXISTS:O2::MCHMappingFactory>:MCH_HAS_MAPPING_FACTORY>)
@@ -85,27 +128,35 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/MCH
85128
# ---- ROOT dictionary ----
86129

87130
add_root_dictionary(${MODULE_NAME}
88-
HEADERS include/MCH/ErrorTask.h
131+
HEADERS
132+
include/MCH/TH2ElecMapReductor.h
133+
include/MCH/ClusterChargeReductor.h
89134
include/MCH/GlobalHistogram.h
90135
include/MCH/PedestalsTask.h
91-
include/MCH/PhysicsTaskDigits.h
92-
include/MCH/PhysicsTaskRofs.h
93-
include/MCH/PhysicsTaskPreclusters.h
94-
include/MCH/PhysicsCheck.h
95-
include/MCH/PhysicsOccupancyCheck.h
96-
include/MCH/PhysicsPreclustersCheck.h
97-
include/MCH/DecodingErrorsTask.h
98-
include/MCH/DecodingErrorsCheck.h
136+
include/MCH/DigitsTask.h
137+
include/MCH/RofsTask.h
138+
include/MCH/PreclustersTask.h
139+
include/MCH/DigitsCheck.h
140+
include/MCH/PreclustersCheck.h
141+
include/MCH/DecodingTask.h
142+
include/MCH/DecodingCheck.h
143+
include/MCH/ErrorTask.h
99144
include/MCH/PedestalsCheck.h
100-
include/MCH/TH1MCHReductor.h
101145
include/MCH/sampa_header.h
102-
include/MCH/MergeableTH1PseudoEfficiencyPerDE.h
103-
include/MCH/MergeableTH1PseudoEfficiencyPerDECycle.h
104-
include/MCH/MergeableTH1MPVPerDECycle.h
105146
include/MCH/TracksTask.h
106-
include/MCH/TrendingConfigMCH.h
107-
include/MCH/TrendingFECHistRatio.h
147+
include/MCH/DecodingPostProcessing.h
148+
include/MCH/DigitsPostProcessing.h
149+
include/MCH/PreclustersPostProcessing.h
150+
include/MCH/PostProcessingConfigMCH.h
108151
include/MCH/TrendingTracks.h
152+
include/MCH/MCHAggregator.h
153+
include/MCH/QualityPostProcessing.h
154+
include/MCH/QualityCheck.h
155+
156+
# legacy tasks
157+
include/MCH/PhysicsTaskDigits.h
158+
include/MCH/PhysicsTaskRofs.h
159+
include/MCH/PhysicsTaskPreclusters.h
109160
LINKDEF include/MCH/LinkDef.h)
110161

111162
# ---- Tests ----

0 commit comments

Comments
 (0)