Skip to content

Commit 9e7d4f2

Browse files
committed
MFT: change of MFT occupancy checker
1 parent 225c0c3 commit 9e7d4f2

File tree

2 files changed

+85
-31
lines changed

2 files changed

+85
-31
lines changed

Modules/MFT/src/QcMFTClusterCheck.cxx

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// \author Katarina Krizkova Gajdosova
1717
/// \author Diana Maria Krupova
1818
/// \author David Grund
19+
/// \author Sara Haidlova
1920
///
2021

2122
// C++
@@ -123,51 +124,77 @@ Quality QcMFTClusterCheck::check(std::map<std::string, std::shared_ptr<MonitorOb
123124
return Quality::Null;
124125
}
125126
}
126-
127127
// checker for empty ladders
128128
QcMFTUtilTables MFTTable;
129129
for (int i = 0; i < 20; i++) {
130130
if (mo->getName() == MFTTable.mClusterChipMapNames[i]) {
131131
adjacentCount = 0;
132132
auto* hClusterChipOccupancyMap = dynamic_cast<TH2F*>(mo->getObject());
133133
if (hClusterChipOccupancyMap == nullptr) {
134-
ILOG(Error, Support) << "Could not cast mClusterChipMap to TH2F." << ENDM;
135134
return Quality::Null;
136135
}
137-
// loop over bins in each chip map
136+
// loop over bins in occupancy maps
138137
for (int iBinX = 0; iBinX < hClusterChipOccupancyMap->GetNbinsX(); iBinX++) {
139-
isEmpty = true;
138+
int emptyValidChips = 0;
139+
bool hasNonEmptyChip = false;
140+
140141
for (int iBinY = 0; iBinY < hClusterChipOccupancyMap->GetNbinsY(); iBinY++) {
142+
// Check if the bin contains data before further checks
141143
if (hClusterChipOccupancyMap->GetBinContent(iBinX + 1, iBinY + 1) != 0) {
142-
isEmpty = false; // if there is an unempty bin, the ladder is not empty
143-
break;
144-
} else {
145-
// check if empty ladders are masked
146-
for (int i = 0; i < mMaskedChips.size(); i++) {
147-
if (mo->getName().find(mChipMapName[i]) != std::string::npos) {
148-
if (iBinX + 1 == hClusterChipOccupancyMap->GetXaxis()->FindBin(mX[mMaskedChips[i]]) && iBinY + 1 == hClusterChipOccupancyMap->GetYaxis()->FindBin(mY[mMaskedChips[i]])) {
149-
isEmpty = false;
150-
} else {
151-
isEmpty = true;
144+
hasNonEmptyChip = true;
145+
break; // Exit early if a non-empty chip is found (most of them should be non-empty)
146+
}
147+
148+
bool isMasked = false;
149+
bool isOutsideAcc = false;
150+
151+
// Check if chip is outside acceptance
152+
for (int k = 0; k < 21; k++) {
153+
if (mo->getName().find(MFTTable.mClusterChipMapNames[i]) != std::string::npos) {
154+
if (iBinX + 1 == MFTTable.mBinX[i][k] && iBinY + 1 == MFTTable.mBinY[i][k]) {
155+
isOutsideAcc = true;
156+
break;
157+
}
158+
}
159+
}
160+
161+
// Check if chip is masked if it is in detector acceptance
162+
if (!isOutsideAcc) {
163+
for (int j = 0; j < mMaskedChips.size(); j++) {
164+
if (mo->getName().find(mChipMapName[j]) != std::string::npos) {
165+
int maskedX = hClusterChipOccupancyMap->GetXaxis()->FindBin(mX[mMaskedChips[j]]);
166+
int maskedY = hClusterChipOccupancyMap->GetYaxis()->FindBin(mY[mMaskedChips[j]]);
167+
if (iBinX + 1 == maskedX && iBinY + 1 == maskedY) {
168+
isMasked = true;
169+
break; // break the loop if you find the bin in the masked list
152170
}
153171
}
154172
}
155173
}
174+
175+
// If chip is not masked and not outside acceptance, count it
176+
if (!isMasked && !isOutsideAcc) {
177+
emptyValidChips++;
178+
}
156179
}
157-
// count empty ladders
180+
181+
// Determine if column is empty
182+
isEmpty = (emptyValidChips > 0 && !hasNonEmptyChip);
183+
158184
if (isEmpty) {
159185
mEmptyCount++;
160186
adjacentCount++;
161187
} else {
162188
adjacentCount = 0;
163189
}
164-
// set bool for adjacent ladders
190+
165191
if (adjacentCount >= mLadderThresholdBad) {
166192
mAdjacentLaddersEmpty = true;
167193
}
168194
}
169195
}
170196
}
197+
171198
if (mo->getName() == "mClusterOccupancySummary") {
172199
auto* hClusterOccupancySummary = dynamic_cast<TH2F*>(mo->getObject());
173200
if (hClusterOccupancySummary == nullptr) {

Modules/MFT/src/QcMFTDigitCheck.cxx

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// \author Katarina Krizkova Gajdosova
1717
/// \author Diana Maria Krupova
1818
/// \author David Grund
19+
/// \author Sara Haidlova
1920
///
2021

2122
// C++
@@ -177,41 +178,67 @@ Quality QcMFTDigitCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
177178
ILOG(Error, Support) << "Could not cast mDigitChipMap to TH2F." << ENDM;
178179
return Quality::Null;
179180
}
180-
// loop over bins in each chip map
181+
// loop over bins in occupancy maps
181182
for (int iBinX = 0; iBinX < hDigitChipOccupancyMap->GetNbinsX(); iBinX++) {
182-
isEmpty = true;
183+
int emptyValidChips = 0;
184+
bool hasNonEmptyChip = false;
185+
183186
for (int iBinY = 0; iBinY < hDigitChipOccupancyMap->GetNbinsY(); iBinY++) {
187+
// Check if the bin contains data before further checks
184188
if (hDigitChipOccupancyMap->GetBinContent(iBinX + 1, iBinY + 1) != 0) {
185-
isEmpty = false; // if there is an unempty bin, the ladder is not empty
186-
break;
187-
} else {
188-
// check if empty ladders are masked
189-
for (int i = 0; i < mMaskedChips.size(); i++) {
190-
if (mo->getName().find(mChipMapName[i]) != std::string::npos) {
191-
if (iBinX + 1 == hDigitChipOccupancyMap->GetXaxis()->FindBin(mX[mMaskedChips[i]]) && iBinY + 1 == hDigitChipOccupancyMap->GetYaxis()->FindBin(mY[mMaskedChips[i]])) {
192-
isEmpty = false;
193-
} else {
194-
isEmpty = true;
189+
hasNonEmptyChip = true;
190+
break; // Exit early if a non-empty chip is found (most of them should be non-empty)
191+
}
192+
193+
bool isMasked = false;
194+
bool isOutsideAcc = false;
195+
196+
// Check if chip is outside acceptance
197+
for (int k = 0; k < 21; k++) {
198+
if (mo->getName().find(MFTTable.mDigitChipMapNames[i]) != std::string::npos) {
199+
if (iBinX + 1 == MFTTable.mBinX[i][k] && iBinY + 1 == MFTTable.mBinY[i][k]) {
200+
isOutsideAcc = true;
201+
break;
202+
}
203+
}
204+
}
205+
206+
// Check if chip is masked if it is in detector acceptance
207+
if (!isOutsideAcc) {
208+
for (int j = 0; j < mMaskedChips.size(); j++) {
209+
if (mo->getName().find(mChipMapName[j]) != std::string::npos) {
210+
int maskedX = hDigitChipOccupancyMap->GetXaxis()->FindBin(mX[mMaskedChips[j]]);
211+
int maskedY = hDigitChipOccupancyMap->GetYaxis()->FindBin(mY[mMaskedChips[j]]);
212+
if (iBinX + 1 == maskedX && iBinY + 1 == maskedY) {
213+
isMasked = true;
214+
break; // break the loop if you find the bin in the masked list
195215
}
196216
}
197217
}
198218
}
219+
220+
// If chip is not masked and not outside acceptance, count it
221+
if (!isMasked && !isOutsideAcc) {
222+
emptyValidChips++;
223+
}
199224
}
200-
// count empty ladders
225+
226+
// Determine if column is empty
227+
isEmpty = (emptyValidChips > 0 && !hasNonEmptyChip);
228+
201229
if (isEmpty) {
202230
mEmptyCount++;
203231
adjacentCount++;
204232
} else {
205233
adjacentCount = 0;
206234
}
207-
// set bool for adjacent ladders
235+
208236
if (adjacentCount >= mLadderThresholdBad) {
209237
mAdjacentLaddersEmpty = true;
210238
}
211239
}
212240
}
213241
}
214-
215242
if (mo->getName() == "mDigitOccupancySummary") {
216243
auto* hDigitOccupancySummary = dynamic_cast<TH2F*>(mo->getObject());
217244
if (hDigitOccupancySummary == nullptr) {

0 commit comments

Comments
 (0)