Skip to content

Commit

Permalink
MFT: patch for wrong quality in summary plots (#2395)
Browse files Browse the repository at this point in the history
* MFT: patch for code errors

* MFT: patch for new ladder checker

* MFT: patch for new ladder checker_v3
  • Loading branch information
Edingrast authored and Barthelemy committed Aug 23, 2024
1 parent aa1cca2 commit c26d762
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 56 deletions.
4 changes: 1 addition & 3 deletions Modules/MFT/include/MFT/QcMFTClusterCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ class QcMFTClusterCheck : public o2::quality_control::checker::CheckInterface
int mLadderThresholdBad;

// ladder checker
bool mIsEmpty;
bool mAdjacentLadders;
bool mAdjacentLaddersEmpty;
int mEmptyCount;
int mAdjacentCount;

// masked chips part
bool mFirstCall;
Expand Down
4 changes: 1 addition & 3 deletions Modules/MFT/include/MFT/QcMFTDigitCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ class QcMFTDigitCheck : public o2::quality_control::checker::CheckInterface
int mLadderThresholdBad;

// ladder checker
bool mIsEmpty;
bool mAdjacentLadders;
bool mAdjacentLaddersEmpty;
int mEmptyCount;
int mAdjacentCount;

// masked chips part
bool mFirstCall;
Expand Down
5 changes: 3 additions & 2 deletions Modules/MFT/mft-clusters.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"dataSource" : [ {
"type" : "Task",
"name" : "Clusters",
"MOs" : ["mClusterOccupancy","mClusterPatternIndex","mClusterSizeSummary", "mGroupedClusterSizeSummary", "mClusterOccupancySummary",
"MOs" : ["mClusterOccupancy","mClusterPatternIndex","mClusterSizeSummary", "mGroupedClusterSizeSummary",
"ChipOccupancyMaps/Half_0/Disk_0/Face_1/mClusterChipOccupancyMap",
"ChipOccupancyMaps/Half_0/Disk_0/Face_0/mClusterChipOccupancyMap",
"ChipOccupancyMaps/Half_0/Disk_1/Face_1/mClusterChipOccupancyMap",
Expand All @@ -81,7 +81,8 @@
"ChipOccupancyMaps/Half_1/Disk_3/Face_1/mClusterChipOccupancyMap",
"ChipOccupancyMaps/Half_1/Disk_3/Face_0/mClusterChipOccupancyMap",
"ChipOccupancyMaps/Half_1/Disk_4/Face_1/mClusterChipOccupancyMap",
"ChipOccupancyMaps/Half_1/Disk_4/Face_0/mClusterChipOccupancyMap"
"ChipOccupancyMaps/Half_1/Disk_4/Face_0/mClusterChipOccupancyMap",
"mClusterOccupancySummary"
]
} ],
"checkParameters" : {
Expand Down
5 changes: 3 additions & 2 deletions Modules/MFT/mft-digits.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"dataSource" : [ {
"type" : "Task",
"name" : "Digits",
"MOs" : ["mDigitChipOccupancy","mDigitOccupancySummary",
"MOs" : ["mDigitChipOccupancy",
"ChipOccupancyMaps/Half_0/Disk_0/Face_1/mDigitChipOccupancyMap",
"ChipOccupancyMaps/Half_0/Disk_0/Face_0/mDigitChipOccupancyMap",
"ChipOccupancyMaps/Half_0/Disk_1/Face_1/mDigitChipOccupancyMap",
Expand All @@ -91,7 +91,8 @@
"ChipOccupancyMaps/Half_1/Disk_3/Face_1/mDigitChipOccupancyMap",
"ChipOccupancyMaps/Half_1/Disk_3/Face_0/mDigitChipOccupancyMap",
"ChipOccupancyMaps/Half_1/Disk_4/Face_1/mDigitChipOccupancyMap",
"ChipOccupancyMaps/Half_1/Disk_4/Face_0/mDigitChipOccupancyMap"
"ChipOccupancyMaps/Half_1/Disk_4/Face_0/mDigitChipOccupancyMap",
"mDigitOccupancySummary"
]
} ]
}
Expand Down
45 changes: 22 additions & 23 deletions Modules/MFT/src/QcMFTClusterCheck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ void QcMFTClusterCheck::configure()

// no call to beautifier yet
mFirstCall = true;
mIsEmpty = true;
mAdjacentLadders = false;

mEmptyCount = 0;
mAdjacentLaddersEmpty = false;
}

Quality QcMFTClusterCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
{
Quality result = Quality::Null;

bool isEmpty = true;
int adjacentCount = 0;

for (auto& [moName, mo] : *moMap) {

(void)moName;
Expand Down Expand Up @@ -127,44 +128,41 @@ Quality QcMFTClusterCheck::check(std::map<std::string, std::shared_ptr<MonitorOb
QcMFTUtilTables MFTTable;
for (int i = 0; i < 20; i++) {
if (mo->getName() == MFTTable.mClusterChipMapNames[i]) {
mAdjacentCount = 0;
adjacentCount = 0;
auto* hClusterChipOccupancyMap = dynamic_cast<TH2F*>(mo->getObject());
if (hClusterChipOccupancyMap == nullptr) {
ILOG(Error, Support) << "Could not cast mClusterChipMap to TH2F." << ENDM;
return Quality::Null;
}
// loop over bins in each chip map
for (int iBinX = 0; iBinX < hClusterChipOccupancyMap->GetNbinsX(); iBinX++) {
mIsEmpty = true;
isEmpty = true;
for (int iBinY = 0; iBinY < hClusterChipOccupancyMap->GetNbinsY(); iBinY++) {
if (hClusterChipOccupancyMap->GetBinContent(iBinX + 1, iBinY + 1) != 0) {
mIsEmpty = false; // if there is an unempty bin, the ladder is not empty
isEmpty = false; // if there is an unempty bin, the ladder is not empty
break;
} else {
// check if empty ladders are masked
for (int i = 0; i < mMaskedChips.size(); i++) {
if (mo->getName().find(mChipMapName[i]) != std::string::npos) {
if (iBinX + 1 == hClusterChipOccupancyMap->GetXaxis()->FindBin(mX[mMaskedChips[i]]) && iBinY + 1 == hClusterChipOccupancyMap->GetYaxis()->FindBin(mY[mMaskedChips[i]])) {
mIsEmpty = false;
isEmpty = false;
} else {
mIsEmpty = true;
isEmpty = true;
}
}
}
}
}
// count empty ladders
if (mIsEmpty) {
if (isEmpty) {
mEmptyCount++;
mAdjacentCount++;
adjacentCount++;
} else {
mAdjacentCount = 0;
adjacentCount = 0;
}
// set bool for adjacent ladders
if (mAdjacentCount >= mLadderThresholdBad) {
if (!mAdjacentLadders) {
mAdjacentLadders = true;
}
if (adjacentCount >= mLadderThresholdBad) {
mAdjacentLaddersEmpty = true;
}
}
}
Expand All @@ -177,15 +175,16 @@ Quality QcMFTClusterCheck::check(std::map<std::string, std::shared_ptr<MonitorOb
return Quality::Null;
}

if (!mAdjacentLadders && mEmptyCount < mLadderThresholdMedium) {
result = Quality::Good;
}
if (!mAdjacentLadders && mEmptyCount >= mLadderThresholdMedium) {
result = Quality::Medium;
}
if (mAdjacentLadders) {
if (mAdjacentLaddersEmpty) {
result = Quality::Bad;
} else if (mEmptyCount >= mLadderThresholdMedium) {
result = Quality::Medium;
} else {
result = Quality::Good;
}
// We rely on 'mClusterOccupancySummary' being run after chip maps in the list of MOs in the config file
mEmptyCount = 0;
mAdjacentLaddersEmpty = false;
}
}
return result;
Expand Down
46 changes: 23 additions & 23 deletions Modules/MFT/src/QcMFTDigitCheck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,23 @@ void QcMFTDigitCheck::configure()

// no call to beautifier yet
mFirstCall = true;
mIsEmpty = true;
mAdjacentLadders = false;

mNCycles = 0;
mNewNoisy = 0;
mDissNoisy = 0;
mTotalNoisy = 0;

mEmptyCount = 0;
mAdjacentLaddersEmpty = false;
}

Quality QcMFTDigitCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
{
Quality result = Quality::Null;

bool isEmpty = true;
int adjacentCount = 0;

for (auto& [moName, mo] : *moMap) {

(void)moName;
Expand Down Expand Up @@ -115,44 +118,42 @@ Quality QcMFTDigitCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
QcMFTUtilTables MFTTable;
for (int i = 0; i < 20; i++) {
if (mo->getName() == MFTTable.mDigitChipMapNames[i]) {
mAdjacentCount = 0;
adjacentCount = 0;
auto* hDigitChipOccupancyMap = dynamic_cast<TH2F*>(mo->getObject());
if (hDigitChipOccupancyMap == nullptr) {
ILOG(Error, Support) << "Could not cast mDigitChipMap to TH2F." << ENDM;
return Quality::Null;
}
// loop over bins in each chip map
for (int iBinX = 0; iBinX < hDigitChipOccupancyMap->GetNbinsX(); iBinX++) {
mIsEmpty = true;
isEmpty = true;
for (int iBinY = 0; iBinY < hDigitChipOccupancyMap->GetNbinsY(); iBinY++) {
if (hDigitChipOccupancyMap->GetBinContent(iBinX + 1, iBinY + 1) != 0) {
mIsEmpty = false; // if there is an unempty bin, the ladder is not empty
isEmpty = false; // if there is an unempty bin, the ladder is not empty
break;
} else {
// check if empty ladders are masked
for (int i = 0; i < mMaskedChips.size(); i++) {
if (mo->getName().find(mChipMapName[i]) != std::string::npos) {
if (iBinX + 1 == hDigitChipOccupancyMap->GetXaxis()->FindBin(mX[mMaskedChips[i]]) && iBinY + 1 == hDigitChipOccupancyMap->GetYaxis()->FindBin(mY[mMaskedChips[i]])) {
mIsEmpty = false;
isEmpty = false;
} else {
mIsEmpty = true;
isEmpty = true;
}
}
}
}
}
// count empty ladders
if (mIsEmpty) {
if (isEmpty) {
mEmptyCount++;
mAdjacentCount++;
adjacentCount++;
} else {
mAdjacentCount = 0;
adjacentCount = 0;
}
// set bool for adjacent ladders
if (mAdjacentCount >= 2) {
if (!mAdjacentLadders) {
mAdjacentLadders = true;
}
if (adjacentCount >= mLadderThresholdBad) {
mAdjacentLaddersEmpty = true;
}
}
}
Expand All @@ -165,20 +166,20 @@ Quality QcMFTDigitCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
return Quality::Null;
}

if (!mAdjacentLadders && mEmptyCount < 1) {
result = Quality::Good;
}
if (!mAdjacentLadders && mEmptyCount >= 1) {
result = Quality::Medium;
}
if (mAdjacentLadders) {
if (mAdjacentLaddersEmpty) {
result = Quality::Bad;
} else if (mEmptyCount >= mLadderThresholdMedium) {
result = Quality::Medium;
} else {
result = Quality::Good;
}
// We rely on 'mDigitOccupancySummary' being run after chip maps in the list of MOs in the config file
mEmptyCount = 0;
mAdjacentLaddersEmpty = false;
}
}
return result;
}

std::string QcMFTDigitCheck::getAcceptedType() { return "TH1"; }

void QcMFTDigitCheck::readMaskedChips(std::shared_ptr<MonitorObject> mo)
Expand Down Expand Up @@ -387,5 +388,4 @@ void QcMFTDigitCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR
}
}
}

} // namespace o2::quality_control_modules::mft

0 comments on commit c26d762

Please sign in to comment.