Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MFT: patch for code errors #2395

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading