Skip to content

Commit 2603c31

Browse files
authored
[ITS] Anomalous clusters plots (#2482)
* ITS - Anomalous clusters plots * ITS - Anomalous clusters plots * fix typo in axis title * minor * Fix MacOS build errors * MacOS build failure: defininig constexpr arrays
1 parent ca0a424 commit 2603c31

File tree

2 files changed

+77
-17
lines changed

2 files changed

+77
-17
lines changed

Modules/ITS/include/ITS/ITSClusterTask.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ class ITSClusterTask : public TaskInterface
9292
std::shared_ptr<TH2DRatio> hAverageClusterOccupancySummaryOB[NLayer];
9393
std::shared_ptr<TH2DRatio> hAverageClusterSizeSummaryOB[NLayer];
9494

95-
// Layer synnary
95+
// Layer summary
9696
TH1D* hClusterSizeLayerSummary[NLayer] = { nullptr };
9797
TH1D* hClusterTopologyLayerSummary[NLayer] = { nullptr };
9898
TH1D* hGroupedClusterSizeLayerSummary[NLayer] = { nullptr };
9999

100+
// Anomalies plots
101+
TH2D* hLongClustersPerChip[3] = { nullptr };
102+
TH2D* hMultPerChipWhenLongClusters[3] = { nullptr };
103+
100104
// General
101105
TH2D* hClusterVsBunchCrossing = nullptr;
102106
std::unique_ptr<TH2DRatio> mGeneralOccupancy = nullptr;
@@ -133,13 +137,16 @@ class ITSClusterTask : public TaskInterface
133137
std::string mLaneStatusFlag[NFlags] = { "IB", "ML", "OL", "Total" };
134138
int mDoPublishDetailedSummary = 0;
135139

136-
const int mNStaves[NLayer] = { 12, 16, 20, 24, 30, 42, 48 };
137-
const int mNHicPerStave[NLayer] = { 1, 1, 1, 8, 8, 14, 14 };
138-
const int mNChipsPerHic[NLayer] = { 9, 9, 9, 14, 14, 14, 14 };
139-
const int mNLanePerHic[NLayer] = { 3, 3, 3, 2, 2, 2, 2 };
140-
const int ChipBoundary[NLayer + 1] = { 0, 108, 252, 432, 3120, 6480, 14712, 24120 };
141-
const int StaveBoundary[NLayer + 1] = { 0, 12, 28, 48, 72, 102, 144, 192 };
142-
const float mLength[NLayer] = { 14., 14., 14., 43., 43., 74., 74. };
140+
int minColSpanLongCluster = 128; // driven by o2::itsmft::ClusterPattern::MaxColSpan = 128
141+
int maxRowSpanLongCluster = 29;
142+
143+
static constexpr int mNStaves[NLayer] = { 12, 16, 20, 24, 30, 42, 48 };
144+
static constexpr int mNHicPerStave[NLayer] = { 1, 1, 1, 8, 8, 14, 14 };
145+
static constexpr int mNChipsPerHic[NLayer] = { 9, 9, 9, 14, 14, 14, 14 };
146+
static constexpr int mNLanePerHic[NLayer] = { 3, 3, 3, 2, 2, 2, 2 };
147+
static constexpr int ChipBoundary[NLayer + 1] = { 0, 108, 252, 432, 3120, 6480, 14712, 24120 };
148+
static constexpr int StaveBoundary[NLayer + 1] = { 0, 12, 28, 48, 72, 102, 144, 192 };
149+
static constexpr float mLength[NLayer] = { 14., 14., 14., 43., 43., 74., 74. };
143150
const std::string mYlabels[NLayer * 2] = { "L6B(S24#rightarrow47)", "L5B(S21#rightarrow41)", "L4B(S15#rightarrow29)", "L3B(S12#rightarrow23)", "L2B(S10#rightarrow19)", "L1B(S08#rightarrow15)", "L0B(S06#rightarrow11)", "L0T(S00#rightarrow05)", "L1T(S00#rightarrow07)", "L2T(S00#rightarrow09)", "L3T(S00#rightarrow11)", "L4T(S00#rightarrow14)", "L5T(S00#rightarrow20)", "L6T(S00#rightarrow23)" };
144151

145152
int mEnableLayers[NLayer] = { 0 };

Modules/ITS/src/ITSClusterTask.cxx

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ ITSClusterTask::~ITSClusterTask()
4747
if (!mEnableLayers[iLayer])
4848
continue;
4949

50+
if (iLayer < NLayerIB) {
51+
delete hLongClustersPerChip[iLayer];
52+
delete hMultPerChipWhenLongClusters[iLayer];
53+
}
5054
delete hClusterSizeLayerSummary[iLayer];
5155
delete hClusterTopologyLayerSummary[iLayer];
5256
delete hGroupedClusterSizeLayerSummary[iLayer];
@@ -137,8 +141,6 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx)
137141
auto clusPatternArr = ctx.inputs().get<gsl::span<unsigned char>>("patterns");
138142
auto pattIt = clusPatternArr.begin();
139143

140-
int ChipIDprev = -1;
141-
142144
// Reset this histo to have the latest picture
143145
hEmptyLaneFractionGlobal->Reset("ICES");
144146

@@ -153,34 +155,46 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx)
153155
const auto& ROF = clusRofArr[iROF];
154156
const auto bcdata = ROF.getBCData();
155157
int nClustersForBunchCrossing = 0;
158+
int nLongClusters[ChipBoundary[NLayerIB]] = {};
159+
int nHitsFromClusters[ChipBoundary[NLayerIB]] = {}; // only IB is implemented at the moment
160+
156161
for (int icl = ROF.getFirstEntry(); icl < ROF.getFirstEntry() + ROF.getNEntries(); icl++) {
157162

158163
auto& cluster = clusArr[icl];
159164
auto ChipID = cluster.getSensorID();
160165
int ClusterID = cluster.getPatternID(); // used for normal (frequent) cluster shapes
161166
int lay, sta, ssta, mod, chip, lane;
162167

163-
if (ChipID != ChipIDprev) {
164-
mGeom->getChipId(ChipID, lay, sta, ssta, mod, chip);
165-
mod = mod + (ssta * (mNHicPerStave[lay] / 2));
166-
int chipIdLocal = (ChipID - ChipBoundary[lay]) % (14 * mNHicPerStave[lay]);
167-
lane = (chipIdLocal % (14 * mNHicPerStave[lay])) / (14 / 2);
168-
}
168+
// TODO: avoid call Geom if ChipID is the same as previous cluster
169+
mGeom->getChipId(ChipID, lay, sta, ssta, mod, chip);
170+
mod = mod + (ssta * (mNHicPerStave[lay] / 2));
171+
int chipIdLocal = (ChipID - ChipBoundary[lay]) % (14 * mNHicPerStave[lay]);
172+
lane = (chipIdLocal % (14 * mNHicPerStave[lay])) / (14 / 2);
173+
169174
int npix = -1;
175+
int colspan = -1;
176+
int rowspan = -1;
170177
int isGrouped = -1;
171178

172179
o2::math_utils::Point3D<float> locC; // local coordinates
173180

174181
if (ClusterID != o2::itsmft::CompCluster::InvalidPatternID) { // Normal (frequent) cluster shapes
175182
if (!mDict->isGroup(ClusterID)) {
176183
npix = mDict->getNpixels(ClusterID);
184+
185+
// TODO: is there way other than calling the pattern?
186+
colspan = mDict->getPattern(ClusterID).getColumnSpan();
187+
rowspan = mDict->getPattern(ClusterID).getRowSpan();
188+
177189
if (mDoPublishDetailedSummary == 1) {
178190
locC = mDict->getClusterCoordinates(cluster);
179191
}
180192
isGrouped = 0;
181193
} else {
182194
o2::itsmft::ClusterPattern patt(pattIt);
183195
npix = patt.getNPixels();
196+
colspan = patt.getColumnSpan();
197+
rowspan = patt.getRowSpan();
184198
if (mDoPublishDetailedSummary == 1) {
185199
locC = mDict->getClusterCoordinates(cluster, patt, true);
186200
}
@@ -190,6 +204,8 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx)
190204
} else { // invalid pattern
191205
o2::itsmft::ClusterPattern patt(pattIt);
192206
npix = patt.getNPixels();
207+
colspan = patt.getColumnSpan();
208+
rowspan = patt.getRowSpan();
193209
isGrouped = 0;
194210
if (mDoPublishDetailedSummary == 1) {
195211
locC = mDict->getClusterCoordinates(cluster, patt, false);
@@ -200,6 +216,15 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx)
200216
nClustersForBunchCrossing++;
201217
}
202218

219+
if (lay < NLayerIB) {
220+
nHitsFromClusters[ChipID] += npix;
221+
}
222+
223+
if (lay < NLayerIB && colspan >= minColSpanLongCluster && rowspan <= maxRowSpanLongCluster) {
224+
// definition of long cluster
225+
nLongClusters[ChipID]++;
226+
}
227+
203228
if (lay < NLayerIB) {
204229
hAverageClusterOccupancySummaryIB[lay]->getNum()->Fill(chip, sta);
205230
hAverageClusterSizeSummaryIB[lay]->getNum()->Fill(chip, sta, (double)npix);
@@ -249,6 +274,21 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx)
249274
}
250275
}
251276
hClusterVsBunchCrossing->Fill(bcdata.bc, nClustersForBunchCrossing); // we count only the number of clusters, not their sizes
277+
278+
// filling these anomaly plots once per ROF, ignoring chips w/o long clusters
279+
for (int ichip = 0; ichip < ChipBoundary[NLayerIB]; ichip++) {
280+
281+
int nLong = TMath::Min(nLongClusters[ichip], 21);
282+
if (nLong < 1) {
283+
continue;
284+
}
285+
int ilayer = -1;
286+
while (ichip >= ChipBoundary[ilayer + 1]) {
287+
ilayer++;
288+
}
289+
hLongClustersPerChip[ilayer]->Fill(ichip, nLong);
290+
hMultPerChipWhenLongClusters[ilayer]->Fill(ichip, nHitsFromClusters[ichip]);
291+
}
252292
}
253293

254294
if ((int)clusRofArr.size() > 0) {
@@ -364,6 +404,8 @@ void ITSClusterTask::reset()
364404
hClusterTopologyLayerSummary[iLayer]->Reset();
365405

366406
if (iLayer < NLayerIB) {
407+
hLongClustersPerChip[iLayer]->Reset();
408+
hMultPerChipWhenLongClusters[iLayer]->Reset();
367409
hAverageClusterOccupancySummaryIB[iLayer]->Reset();
368410
hAverageClusterSizeSummaryIB[iLayer]->Reset();
369411
if (mDoPublish1DSummary == 1) {
@@ -396,7 +438,7 @@ void ITSClusterTask::reset()
396438

397439
void ITSClusterTask::createAllHistos()
398440
{
399-
hClusterVsBunchCrossing = new TH2D("BunchCrossingIDvsClusters", "BunchCrossingIDvsClusters", nBCbins, 0, 4095, 100, 0, 1000);
441+
hClusterVsBunchCrossing = new TH2D("BunchCrossingIDvsClusters", "BunchCrossingIDvsClusters", nBCbins, 0, 4095, 100, 0, 2000);
400442
hClusterVsBunchCrossing->SetTitle("#clusters vs BC id for clusters with npix > 2");
401443
addObject(hClusterVsBunchCrossing);
402444
formatAxes(hClusterVsBunchCrossing, "Bunch Crossing ID", "Number of clusters with npix > 2 in ROF", 1, 1.10);
@@ -419,6 +461,17 @@ void ITSClusterTask::createAllHistos()
419461
if (!mEnableLayers[iLayer])
420462
continue;
421463

464+
if (iLayer < NLayerIB) {
465+
hLongClustersPerChip[iLayer] = new TH2D(Form("Anomalies/Layer%d/LongClusters", iLayer), Form("Layer%d/LongClusters", iLayer), ChipBoundary[iLayer + 1] - ChipBoundary[iLayer], ChipBoundary[iLayer], ChipBoundary[iLayer + 1], 21, 0, 21);
466+
hMultPerChipWhenLongClusters[iLayer] = new TH2D(Form("Anomalies/Layer%d/HitsWhenLongClusters", iLayer), Form("Layer%d/HitsWhenLongClusters", iLayer), ChipBoundary[iLayer + 1] - ChipBoundary[iLayer], ChipBoundary[iLayer], ChipBoundary[iLayer + 1], 200, 0, 20000);
467+
addObject(hLongClustersPerChip[iLayer]);
468+
formatAxes(hLongClustersPerChip[iLayer], "Chip ID", "number of long clusters", 1, 1.10);
469+
hLongClustersPerChip[iLayer]->SetStats(0);
470+
addObject(hMultPerChipWhenLongClusters[iLayer]);
471+
formatAxes(hMultPerChipWhenLongClusters[iLayer], "Chip ID", "Sum of clusters size (events w/ long clus)", 1, 1.10);
472+
hMultPerChipWhenLongClusters[iLayer]->SetStats(0);
473+
}
474+
422475
hClusterSizeLayerSummary[iLayer] = new TH1D(Form("Layer%d/AverageClusterSizeSummary", iLayer), Form("Layer%dAverageClusterSizeSummary", iLayer), 100, 0, 100);
423476
hClusterSizeLayerSummary[iLayer]->SetTitle(Form("Cluster size summary for Layer %d", iLayer));
424477
addObject(hClusterSizeLayerSummary[iLayer]);

0 commit comments

Comments
 (0)