Skip to content

Commit 4c9e420

Browse files
authored
Improve handling of MID histograms per local board (#2351)
1 parent 502e54f commit 4c9e420

6 files changed

Lines changed: 228 additions & 185 deletions

File tree

Modules/MUON/MID/include/MID/DigitsHelper.h

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef QC_MODULE_MID_DIGITSHELPER_H
1616
#define QC_MODULE_MID_DIGITSHELPER_H
1717

18+
#include <array>
1819
#include <memory>
1920
#include <string>
2021
#include <vector>
@@ -50,12 +51,26 @@ class DigitsHelper
5051
/// @return Histogram 2D
5152
TH2F makeStripMapHisto(std::string name, std::string title, int cathode) const;
5253

54+
/// @brief Make 4 histograms with the 2D representation of the fired strips per chamber
55+
/// @param name Base histogram name
56+
/// @param title Base histogram title
57+
/// @param cathode Bending (0) or Non-bending (1) plane
58+
/// @return Array of unique pointer to histograms
59+
std::array<std::unique_ptr<TH2F>, 4> makeStripMapHistos(std::string name, std::string title, int cathode) const;
60+
5361
/// @brief Make the histogram with the 2D representation of the fired boards
5462
/// @param name Histogram name
5563
/// @param title Histogram title
5664
/// @return Histogram 2D
5765
TH2F makeBoardMapHisto(std::string name, std::string title) const;
5866

67+
/// @brief Make 4 histograms with the 2D representation of the fired boards per chamber
68+
/// @param name Base histogram name
69+
/// @param title Base histogram title
70+
/// @param cathode Bending (0) or Non-bending (1) plane
71+
/// @return Array of unique pointer to histograms
72+
std::array<std::unique_ptr<TH2F>, 4> makeBoardMapHistos(std::string name, std::string title) const;
73+
5974
/// @brief Count the number of fired strips
6075
/// @param col Column Data
6176
/// @param cathode Bending (0) or Non-bending (1) plane
@@ -67,48 +82,52 @@ class DigitsHelper
6782
/// @param histo Pointer to the histogram
6883
void fillStripHisto(const o2::mid::ColumnData& col, TH1* histo) const;
6984

70-
/// @brief Fill the 2D representation of the fired strips/boards from the 1D histogram
71-
/// @param stripHisto Input 1D histogram
72-
/// @param stripHistosB Array with the 2D representation of the fired strips in the bending plane per chamber
73-
/// @param stripHistosNB Array with the 2D representation of the fired strips in the non-bending plane per chamber
74-
/// @param boardHistos Array with the 2D representation of the fired boards per chamber. Last histogram is the sum of the previous four
75-
void fillMapHistos(const TH1* stripHisto, std::array<std::unique_ptr<TH2F>, 4>& stripHistosB, std::array<std::unique_ptr<TH2F>, 4>& stripHistosNB, std::array<std::unique_ptr<TH2F>, 5>& boardHistos) const;
85+
/// @brief Fill the 2D representation of the fired boards from the 1D strip histogram
86+
/// @param histo Input 1D histogram with fired strips
87+
/// @param histosB Array with the 2D representation of the fired boards per chamber. Last histogram is the sum of the previous four
88+
void fillBoardMapHistosFromStrips(const TH1* histo, std::array<std::unique_ptr<TH2F>, 4>& histosB, std::array<std::unique_ptr<TH2F>, 4>& histosNB) const;
7689

7790
/// @brief Fill the 2D representation of the fired strips from the 1D histogram
78-
/// @param stripHisto Input 1D histogram
79-
/// @param stripHistosB Array with the 2D representation of the fired strips in the bending plane per chamber
80-
/// @param stripHistosNB Array with the 2D representation of the fired strips in the non-bending plane per chamber
81-
void fillMapHistos(const TH1* stripHisto, std::array<std::unique_ptr<TH2F>, 4>& stripHistosB, std::array<std::unique_ptr<TH2F>, 4>& stripHistosNB) const;
82-
83-
/// @brief Fill the 2D representation of the fired strips/boards from the 1D histogram for a specific chamber
84-
/// @param stripHisto Input 1D histogram
85-
/// @param stripHistosB 2D representation of the fired strips in the bending plane
86-
/// @param stripHistosNB 2D representation of the fired strips in the non-bending plane
87-
/// @param boardHistos 2D representation of the fired boards per chamber
88-
/// @param chamber Selected chamber
89-
void fillMapHistos(const TH1* stripHisto, TH2* stripHistosB, TH2* stripHistosNB, TH2* boardHistos, int chamber) const;
90-
91-
struct StripInfo {
92-
int deId; ///< Detection element ID
93-
int columnId; ///< Column ID
94-
int lineId; ///< Line ID
95-
int stripId; ///< Strip ID
96-
int cathode; ///< Bending (0) or Non-bending (1) plane
97-
int xwidth; ///< Width X
98-
int ywidth; ///< Width y
91+
/// @param histo Input 1D histogram with fired strips
92+
/// @param histosB Array with the 2D representation of the fired strips in the bending plane per chamber
93+
/// @param histosNB Array with the 2D representation of the fired strips in the non-bending plane per chamber
94+
void fillStripMapHistos(const TH1* histo, std::array<std::unique_ptr<TH2F>, 4>& stripHistosB, std::array<std::unique_ptr<TH2F>, 4>& stripHistosNB) const;
95+
96+
struct MapInfo {
97+
int cathode = 0; ///! Cathode
98+
int chamber = 0; ///! Chamber
99+
std::vector<int> bins{}; ///! Bins in the 2D map histograms
99100
};
100101

101102
struct ColumnInfo {
102-
int firstLine; ///< First line in column
103-
int lastLine; ///< Last line in column
104-
int nStripsNB; ///< Number of strips in the NB plane
103+
int firstLine; ///! First line in column
104+
int lastLine; ///! Last line in column
105+
int nStripsNB; ///! Number of strips in the NB plane
105106
};
106107

107108
private:
108-
std::unordered_map<int, int> mStripsMap{}; ///! Map from id to index
109-
std::vector<StripInfo> mStripsInfo; ///! Strips info
109+
std::unordered_map<int, int> mStripsMap{}; ///! Strip id to strip idx
110+
111+
std::vector<MapInfo> mStripIdxToStripMap{}; ///! Strip index to strip map bins
112+
std::vector<MapInfo> mStripIdxToBoardMap{}; ///! Strip index to board map bins
113+
110114
std::array<ColumnInfo, 72 * 7> mColumnInfo; ///! Column info
111-
void fillMapHistos(const StripInfo& info, TH2* stripHistoB, TH2* stripHistoNB, TH2* boardHisto, int wgt) const;
115+
116+
/// @brief Initializes inner maps
117+
void initMaps();
118+
119+
/// @brief Fills one bin in a quick way
120+
/// @param ibin Bin to fill
121+
/// @param wgt Weight
122+
/// @param histo Histogram to fill
123+
void FillBin(TH1* histo, int ibin, double wgt = 1.) const;
124+
125+
/// @brief Fill the 2D map histogram from the 1D histogram
126+
/// @param histo 1D histogram
127+
/// @param histoMapB 2D map histogram for the bending plane
128+
/// @param histoMapNB 2D map histogram for the non-bending plane
129+
/// @param infoMap Correspondence between histogram bins
130+
void fillMapHistos(const TH1* histo, std::array<std::unique_ptr<TH2F>, 4>& histoMapB, std::array<std::unique_ptr<TH2F>, 4>& histoMapNB, const std::vector<MapInfo>& infoMap) const;
112131

113132
inline int getColumnIdx(int columnId, int deId) const { return 7 * deId + columnId; }
114133
};

Modules/MUON/MID/include/MID/DigitsQcTask.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class DigitsQcTask final : public TaskInterface
7373
std::array<std::unique_ptr<TH1F>, 5> mMultHitNB{};
7474
std::unique_ptr<TH1F> mMeanMultiHits;
7575

76-
std::array<std::unique_ptr<TH2F>, 5> mLocalBoardsMap{};
76+
std::array<std::unique_ptr<TH2F>, 4> mLocalBoardsMap{};
77+
std::unique_ptr<TH2F> mLocalBoardsMapTot;
78+
7779
std::unique_ptr<TH1F> mHits;
7880

7981
std::array<std::unique_ptr<TH2F>, 4> mBendHitsMap{};

Modules/MUON/MID/src/CalibMQcTask.cxx

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,46 @@ void CalibMQcTask::initialize(o2::framework::InitContext& /*ctx*/)
4444
mNoise = std::make_unique<TH1F>(mDigitsHelper.makeStripHisto("MNoiseStrips", "Noise strips"));
4545
getObjectsManager()->startPublishing(mNoise.get());
4646

47-
for (int ich = 0; ich < 4; ++ich) {
48-
mBendNoiseMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("MBendNoiseMap{}", chId[ich]), fmt::format("Bending Noise Map MT{}", chId[ich]), 0));
49-
getObjectsManager()->startPublishing(mBendNoiseMap[ich].get());
47+
mBendNoiseMap = mDigitsHelper.makeStripMapHistos("MBendNoiseMap", "Bending Noise Map", 0);
48+
for (auto& histo : mBendNoiseMap) {
49+
getObjectsManager()->startPublishing(histo.get());
50+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
5051
}
5152

52-
for (int ich = 0; ich < 4; ++ich) {
53-
mNBendNoiseMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("MNBendNoiseMap{}", chId[ich]), fmt::format("Non-Bending Noise Map MT{}", chId[ich]), 1));
54-
getObjectsManager()->startPublishing(mNBendNoiseMap[ich].get());
53+
mNBendNoiseMap = mDigitsHelper.makeStripMapHistos("MNBendNoiseMap", "Non-Bending Noise Map", 1);
54+
for (auto& histo : mNBendNoiseMap) {
55+
getObjectsManager()->startPublishing(histo.get());
56+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
5557
}
5658

5759
mDead = std::make_unique<TH1F>(mDigitsHelper.makeStripHisto("MDeadStrips", "Dead strips"));
5860
getObjectsManager()->startPublishing(mDead.get());
5961

60-
for (int ich = 0; ich < 4; ++ich) {
61-
mBendDeadMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("MBendDeadMap{}", chId[ich]), fmt::format("Bending Dead Map MT{}", chId[ich]), 0));
62-
getObjectsManager()->startPublishing(mBendDeadMap[ich].get());
62+
mBendDeadMap = mDigitsHelper.makeStripMapHistos("MBendDeadMap", "Bending Dead Map", 0);
63+
for (auto& histo : mBendDeadMap) {
64+
getObjectsManager()->startPublishing(histo.get());
65+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
6366
}
6467

65-
for (int ich = 0; ich < 4; ++ich) {
66-
mNBendDeadMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("MNBendDeadMap{}", chId[ich]), fmt::format("Non-Bending Dead Map MT{}", chId[ich]), 1));
67-
getObjectsManager()->startPublishing(mNBendDeadMap[ich].get());
68+
mNBendDeadMap = mDigitsHelper.makeStripMapHistos("MNBendDeadMap", "Non-Bending Dead Map", 1);
69+
for (auto& histo : mNBendDeadMap) {
70+
getObjectsManager()->startPublishing(histo.get());
71+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
6872
}
6973

7074
mBad = std::make_unique<TH1F>(mDigitsHelper.makeStripHisto("MBadStrips", "Bad strips"));
7175
getObjectsManager()->startPublishing(mBad.get());
7276

73-
for (int ich = 0; ich < 4; ++ich) {
74-
mBendBadMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("MBendBadMap{}", chId[ich]), fmt::format("Bending Bad Map MT{}", chId[ich]), 0));
75-
getObjectsManager()->startPublishing(mBendBadMap[ich].get());
77+
mBendBadMap = mDigitsHelper.makeStripMapHistos("MBendBadMap", "Bending Bad Map", 0);
78+
for (auto& histo : mBendBadMap) {
79+
getObjectsManager()->startPublishing(histo.get());
80+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
7681
}
7782

78-
for (int ich = 0; ich < 4; ++ich) {
79-
mNBendBadMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("MNBendBadMap{}", chId[ich]), fmt::format("Non-Bending Bad Map MT{}", chId[ich]), 1));
80-
getObjectsManager()->startPublishing(mNBendBadMap[ich].get());
83+
mNBendBadMap = mDigitsHelper.makeStripMapHistos("MNBendBadMap", "Non-Bending Bad Map", 1);
84+
for (auto& histo : mNBendBadMap) {
85+
getObjectsManager()->startPublishing(histo.get());
86+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
8187
}
8288
}
8389

@@ -116,9 +122,9 @@ void CalibMQcTask::endOfCycle()
116122
resetDisplayHistos();
117123

118124
// Then fill from the strip histogram
119-
mDigitsHelper.fillMapHistos(mNoise.get(), mBendNoiseMap, mNBendNoiseMap);
120-
mDigitsHelper.fillMapHistos(mDead.get(), mBendDeadMap, mNBendDeadMap);
121-
mDigitsHelper.fillMapHistos(mBad.get(), mBendBadMap, mNBendBadMap);
125+
mDigitsHelper.fillStripMapHistos(mNoise.get(), mBendNoiseMap, mNBendNoiseMap);
126+
mDigitsHelper.fillStripMapHistos(mDead.get(), mBendDeadMap, mNBendDeadMap);
127+
mDigitsHelper.fillStripMapHistos(mBad.get(), mBendBadMap, mNBendBadMap);
122128
}
123129

124130
void CalibMQcTask::endOfActivity(const Activity& /*activity*/)

Modules/MUON/MID/src/CalibQcTask.cxx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@ void CalibQcTask::initialize(o2::framework::InitContext& /*ctx*/)
5858
mNoise = std::make_unique<TH1F>(mDigitsHelper.makeStripHisto("NoiseStrips", "Noise strips"));
5959
getObjectsManager()->startPublishing(mNoise.get());
6060

61-
for (int ich = 0; ich < 4; ++ich) {
62-
mBendNoiseMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("BendNoiseMap{}", chId[ich]), fmt::format("Bending Noise Map MT{}", chId[ich]), 0));
63-
getObjectsManager()->startPublishing(mBendNoiseMap[ich].get());
61+
mBendNoiseMap = mDigitsHelper.makeStripMapHistos("BendNoiseMap", "Bending Noise Map", 0);
62+
for (auto& histo : mBendNoiseMap) {
63+
getObjectsManager()->startPublishing(histo.get());
64+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
6465
}
6566

66-
for (int ich = 0; ich < 4; ++ich) {
67-
mNBendNoiseMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("NBendNoiseMap{}", chId[ich]), fmt::format("Non-Bending Noise Map MT{}", chId[ich]), 1));
68-
getObjectsManager()->startPublishing(mNBendNoiseMap[ich].get());
67+
mNBendNoiseMap = mDigitsHelper.makeStripMapHistos("NBendNoiseMap", "Non-Bending Noise Map", 1);
68+
for (auto& histo : mNBendNoiseMap) {
69+
getObjectsManager()->startPublishing(histo.get());
70+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
6971
}
7072

71-
// Dead strips Histograms ::
7273
for (int ich = 0; ich < 4; ++ich) {
7374
mMultDeadB[ich] = std::make_unique<TH1F>(fmt::format("MultDeadMT{}B", chId[ich]).c_str(), fmt::format("Multiplicity Dead strips - MT{} bending plane", chId[ich]).c_str(), 300, 0, 300);
7475
getObjectsManager()->startPublishing(mMultDeadB[ich].get());
@@ -79,14 +80,16 @@ void CalibQcTask::initialize(o2::framework::InitContext& /*ctx*/)
7980
mDead = std::make_unique<TH1F>(mDigitsHelper.makeStripHisto("DeadStrips", "Dead strips"));
8081
getObjectsManager()->startPublishing(mDead.get());
8182

82-
for (int ich = 0; ich < 4; ++ich) {
83-
mBendDeadMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("BendDeadMap{}", chId[ich]), fmt::format("Bending Dead Map MT{}", chId[ich]), 0));
84-
getObjectsManager()->startPublishing(mBendDeadMap[ich].get());
83+
mBendDeadMap = mDigitsHelper.makeStripMapHistos("BendDeadMap", "Bending Dead Map", 0);
84+
for (auto& histo : mBendDeadMap) {
85+
getObjectsManager()->startPublishing(histo.get());
86+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
8587
}
8688

87-
for (int ich = 0; ich < 4; ++ich) {
88-
mNBendDeadMap[ich] = std::make_unique<TH2F>(mDigitsHelper.makeStripMapHisto(fmt::format("NBendDeadMap{}", chId[ich]), fmt::format("Non-Bending Dead Map MT{}", chId[ich]), 1));
89-
getObjectsManager()->startPublishing(mNBendDeadMap[ich].get());
89+
mNBendDeadMap = mDigitsHelper.makeStripMapHistos("NBendDeadMap", "Non-Bending Dead Map", 1);
90+
for (auto& histo : mNBendDeadMap) {
91+
getObjectsManager()->startPublishing(histo.get());
92+
getObjectsManager()->setDefaultDrawOptions(histo.get(), "COLZ");
9093
}
9194
}
9295

@@ -153,8 +156,8 @@ void CalibQcTask::endOfCycle()
153156
resetDisplayHistos();
154157

155158
// Then fill from the strip histogram
156-
mDigitsHelper.fillMapHistos(mNoise.get(), mBendNoiseMap, mNBendNoiseMap);
157-
mDigitsHelper.fillMapHistos(mDead.get(), mBendDeadMap, mNBendDeadMap);
159+
mDigitsHelper.fillStripMapHistos(mNoise.get(), mBendNoiseMap, mNBendNoiseMap);
160+
mDigitsHelper.fillStripMapHistos(mDead.get(), mBendDeadMap, mNBendDeadMap);
158161
}
159162

160163
void CalibQcTask::endOfActivity(const Activity& /*activity*/)

0 commit comments

Comments
 (0)