Skip to content

Commit

Permalink
[EMCAL-767, EMCAL-846, EMCAL-1143] Additional protection trending (#2314
Browse files Browse the repository at this point in the history
)

- Protection against
  + Missing historam / wrong histogram type
  + Geometry and mapping errors
- Tasks / Reductors:
  + CalibMonitoringTask
  + TimeCalibParamReductor
  + BadChannelMapReductor
  + OccupancyToFECReductor
  • Loading branch information
mfasDa authored May 29, 2024
1 parent 1b26bbb commit bbd44a2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 74 deletions.
102 changes: 57 additions & 45 deletions Modules/EMCAL/src/BadChannelMapReductor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,46 @@ void BadChannelMapReductor::update(TObject* obj)
const std::map<o2::emcal::EMCALSMType, int> channelsSMTYPE = { { o2::emcal::EMCAL_STANDARD, 1152 }, { o2::emcal::EMCAL_THIRD, 384 }, { o2::emcal::DCAL_STANDARD, 768 }, { o2::emcal::DCAL_EXT, 384 } };
constexpr int CHANNELS_TOTAL = 17664, CHANNELS_EMC = 12288, CHANNELS_DCAL = CHANNELS_TOTAL - CHANNELS_EMC;
memset(&mStats, 0, sizeof(mStats));
auto badChannelMap = static_cast<TH2*>(obj);
auto badChannelMap = dynamic_cast<TH2*>(obj);
if (!badChannelMap) {
ILOG(Error, Support) << "Object " << obj->GetName() << " not a proper bad channel histogram, or does not exist. Not possible to analyse" << ENDM;
return;
}
for (int icolumn = 0; icolumn < badChannelMap->GetXaxis()->GetNbins(); icolumn++) {
for (int irow = 0; irow < badChannelMap->GetYaxis()->GetNbins(); irow++) {
if (isPHOSRegion(icolumn, irow)) {
continue;
}
auto status = badChannelMap->GetBinContent(icolumn + 1, irow + 1);
auto [sm, mod, modrow, modcol] = mGeometry->GetCellIndexFromGlobalRowCol(irow, icolumn);
if (status == 1) { // bad channel
mStats.mNonGoodChannelsTotal++;
mStats.mNonGoodChannelsSM[sm]++;
mStats.mBadChannelsTotal++;
mStats.mBadChannelsSM[sm]++;
if (sm < 12) {
mStats.mNonGoodChannelsEMCAL++;
mStats.mBadChannelsEMCAL++;
} else {
mStats.mNonGoodChannelsDCAL++;
mStats.mBadChannelsDCAL++;
}
} else if (status == 2) {
mStats.mNonGoodChannelsTotal++;
mStats.mNonGoodChannelsSM[sm]++;
mStats.mDeadChannelsTotal++;
mStats.mDeadChannelsSM[sm]++;
if (sm < 12) {
mStats.mNonGoodChannelsEMCAL++;
mStats.mDeadChannelsEMCAL++;
} else {
mStats.mNonGoodChannelsDCAL++;
mStats.mDeadChannelsDCAL++;
try {
auto [sm, mod, modrow, modcol] = mGeometry->GetCellIndexFromGlobalRowCol(irow, icolumn);
if (status == 1) { // bad channel
mStats.mNonGoodChannelsTotal++;
mStats.mNonGoodChannelsSM[sm]++;
mStats.mBadChannelsTotal++;
mStats.mBadChannelsSM[sm]++;
if (sm < 12) {
mStats.mNonGoodChannelsEMCAL++;
mStats.mBadChannelsEMCAL++;
} else {
mStats.mNonGoodChannelsDCAL++;
mStats.mBadChannelsDCAL++;
}
} else if (status == 2) {
mStats.mNonGoodChannelsTotal++;
mStats.mNonGoodChannelsSM[sm]++;
mStats.mDeadChannelsTotal++;
mStats.mDeadChannelsSM[sm]++;
if (sm < 12) {
mStats.mNonGoodChannelsEMCAL++;
mStats.mDeadChannelsEMCAL++;
} else {
mStats.mNonGoodChannelsDCAL++;
mStats.mDeadChannelsDCAL++;
}
}
} catch (o2::emcal::RowColException& e) {
ILOG(Error, Support) << e.what() << ENDM;
}
}
}
Expand All @@ -82,26 +90,30 @@ void BadChannelMapReductor::update(TObject* obj)
mStats.mFractionNonGoodDCAL = static_cast<double>(mStats.mNonGoodChannelsDCAL) / static_cast<double>(CHANNELS_DCAL);
int currentbad = -1, currentdead = -1, currentnongood = -1;
for (int ism = 0; ism < 20; ism++) {
auto smtype = mGeometry->GetSMType(ism);
auto nchannels = channelsSMTYPE.find(smtype);
if (nchannels == channelsSMTYPE.end()) {
ILOG(Error, Support) << "Unhandled Supermodule type" << ENDM;
continue;
}
mStats.mFractionDeadSM[ism] = static_cast<double>(mStats.mDeadChannelsSM[ism]) / nchannels->second;
mStats.mFractionBadSM[ism] = static_cast<double>(mStats.mBadChannelsSM[ism]) / static_cast<double>(nchannels->second);
mStats.mFractionNonGoodSM[ism] = static_cast<double>(mStats.mNonGoodChannelsSM[ism]) / static_cast<double>(nchannels->second);
if (mStats.mBadChannelsSM[ism] > currentbad) {
currentbad = mStats.mBadChannelsSM[ism];
mStats.mSupermoduleMaxBad = ism;
}
if (mStats.mDeadChannelsSM[ism] > currentdead) {
currentdead = mStats.mDeadChannelsSM[ism];
mStats.mSupermoduleMaxDead = ism;
}
if (mStats.mNonGoodChannelsSM[ism] > currentnongood) {
currentnongood = mStats.mNonGoodChannelsSM[ism];
mStats.mSupermoduleMaxNonGood = ism;
try {
auto smtype = mGeometry->GetSMType(ism);
auto nchannels = channelsSMTYPE.find(smtype);
if (nchannels == channelsSMTYPE.end()) {
ILOG(Error, Support) << "Unhandled Supermodule type" << ENDM;
continue;
}
mStats.mFractionDeadSM[ism] = static_cast<double>(mStats.mDeadChannelsSM[ism]) / nchannels->second;
mStats.mFractionBadSM[ism] = static_cast<double>(mStats.mBadChannelsSM[ism]) / static_cast<double>(nchannels->second);
mStats.mFractionNonGoodSM[ism] = static_cast<double>(mStats.mNonGoodChannelsSM[ism]) / static_cast<double>(nchannels->second);
if (mStats.mBadChannelsSM[ism] > currentbad) {
currentbad = mStats.mBadChannelsSM[ism];
mStats.mSupermoduleMaxBad = ism;
}
if (mStats.mDeadChannelsSM[ism] > currentdead) {
currentdead = mStats.mDeadChannelsSM[ism];
mStats.mSupermoduleMaxDead = ism;
}
if (mStats.mNonGoodChannelsSM[ism] > currentnongood) {
currentnongood = mStats.mNonGoodChannelsSM[ism];
mStats.mSupermoduleMaxNonGood = ism;
}
} catch (o2::emcal::SupermoduleIndexException& e) {
ILOG(Error, Support) << e.what() << ENDM;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions Modules/EMCAL/src/CalibMonitoringTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ void CalibMonitoringTask::update(Trigger t, framework::ServiceRegistryRef)
for (const auto& obj : mCalibObjects) {
if (obj == "BadChannelMap") {
mBadChannelMap = mCalibDB->readBadChannelMap(o2::ccdb::getCurrentTimestamp(), metadata);
if (!mBadChannelMap)
if (!mBadChannelMap) {
ILOG(Info, Support) << "No Bad Channel Map object " << ENDM;
continue;
}
TH2* hist_temp2 = 0x0;
hist_temp2 = mBadChannelMap->getHistogramRepresentation();
for (Int_t i = 0; i < hist_temp2->GetNbinsX(); i++) {
Expand Down Expand Up @@ -183,8 +185,10 @@ void CalibMonitoringTask::update(Trigger t, framework::ServiceRegistryRef)

if (obj == "TimeCalibParams") {
mTimeCalib = mCalibDB->readTimeCalibParam(o2::ccdb::getCurrentTimestamp(), metadata);
if (!mTimeCalib)
if (!mTimeCalib) {
ILOG(Info, Support) << " No Time Calib object " << ENDM;
continue;
}
TH1* hist_temp = 0x0;
hist_temp = mTimeCalib->getHistogramRepresentation(false); // we monitor for the moment only the high gain
for (Int_t i = 0; i < hist_temp->GetNbinsX(); i++) {
Expand Down
29 changes: 19 additions & 10 deletions Modules/EMCAL/src/OccupancyToFECReductor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include "TH2.h"
#include "EMCALReconstruction/Channel.h"
#include "EMCALBase/Geometry.h"
#include "EMCAL/OccupancyToFECReductor.h"
#include "MathUtils/Utils.h"
#include "EMCAL/OccupancyToFECReductor.h"
#include <QualityControl/QcInfoLogger.h>

using namespace o2::quality_control_modules::emcal;

Expand All @@ -38,22 +39,30 @@ void OccupancyToFECReductor::update(TObject* obj)
memset(mStats.mCountFEC, 0, sizeof(double) * 800);
memset(mStats.mAverageFEC, 0, sizeof(double) * 800);
memset(mStats.mRMSFEC, 0, sizeof(double) * 800);
TH2* digitOccupancyHistogram = dynamic_cast<TH2*>(obj);
if (!digitOccupancyHistogram) {
ILOG(Error, Support) << "Object " << obj->GetName() << " not a proper occupancy histogram, or does not exist. Not possible to analyse" << ENDM;
return;
}
std::array<o2::math_utils::StatAccumulator, 800> statAccumulatorsSM;
TH2* digitOccupancyHistogram = static_cast<TH2*>(obj);
o2::math_utils::StatAccumulator statAccumulatorTotal;
for (int icol = 0; icol < digitOccupancyHistogram->GetXaxis()->GetNbins(); icol++) {
for (int irow = 0; irow < digitOccupancyHistogram->GetYaxis()->GetNbins(); irow++) {
double count = digitOccupancyHistogram->GetBinContent(icol + 1, irow + 1);
if (count) {
statAccumulatorTotal.add(count);
auto [smod, mod, phimod, etamod] = mGeometry->GetCellIndexFromGlobalRowCol(irow, icol);
auto absCellID = mGeometry->GetCellAbsIDFromGlobalRowCol(irow, icol);
auto [ddl, onlinerow, onlinecol] = mGeometry->getOnlineID(absCellID);
auto hwaddress = mMapper.getMappingForDDL(ddl).getHardwareAddress(onlinerow, onlinecol, o2::emcal::ChannelType_t::HIGH_GAIN);
auto localfec = mMapper.getFEEForChannelInDDL(ddl, o2::emcal::Channel::getFecIndexFromHwAddress(hwaddress), o2::emcal::Channel::getBranchIndexFromHwAddress(hwaddress));
auto globalfec = smod * 40 + localfec;
mStats.mCountFEC[globalfec] += count;
statAccumulatorsSM[globalfec].add(count);
try {
auto [smod, mod, phimod, etamod] = mGeometry->GetCellIndexFromGlobalRowCol(irow, icol);
auto absCellID = mGeometry->GetCellAbsIDFromGlobalRowCol(irow, icol);
auto [ddl, onlinerow, onlinecol] = mGeometry->getOnlineID(absCellID);
auto hwaddress = mMapper.getMappingForDDL(ddl).getHardwareAddress(onlinerow, onlinecol, o2::emcal::ChannelType_t::HIGH_GAIN);
auto localfec = mMapper.getFEEForChannelInDDL(ddl, o2::emcal::Channel::getFecIndexFromHwAddress(hwaddress), o2::emcal::Channel::getBranchIndexFromHwAddress(hwaddress));
auto globalfec = smod * 40 + localfec;
mStats.mCountFEC[globalfec] += count;
statAccumulatorsSM[globalfec].add(count);
} catch (std::exception& e) {
ILOG(Error, Support) << e.what() << ENDM;
}
}
}
}
Expand Down
46 changes: 29 additions & 17 deletions Modules/EMCAL/src/TimeCalibParamReductor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,27 @@ void TimeCalibParamReductor::update(TObject* obj)
const std::map<o2::emcal::EMCALSMType, int> channelsSMTYPE = { { o2::emcal::EMCAL_STANDARD, 1152 }, { o2::emcal::EMCAL_THIRD, 384 }, { o2::emcal::DCAL_STANDARD, 768 }, { o2::emcal::DCAL_EXT, 384 } };
constexpr int CHANNELS_TOTAL = 17664, CHANNELS_EMC = 12288, CHANNELS_DCAL = CHANNELS_TOTAL - CHANNELS_EMC;
memset(&mStats, 0, sizeof(mStats));
auto timeCalib = static_cast<TH1*>(obj);
auto timeCalib = dynamic_cast<TH1*>(obj);
if (!timeCalib) {
ILOG(Error, Support) << "Object " << obj->GetName() << " not a proper time calib histogram, or does not exist. Not possible to analyse" << ENDM;
return;
}
std::vector<double> tcpGood;
for (auto itower = 0; itower < timeCalib->GetXaxis()->GetNbins(); itower++) {
auto param = timeCalib->GetBinContent(itower + 1);
if (std::abs(param) > 100) {
// Consider fit failed if the time calibration param is larger than 100
mStats.mFailedParams++;
auto [sm, mod, modphi, modeta] = mGeometry->GetCellIndex(itower);
mStats.mFailedParamSM[sm]++;
if (sm >= 12) {
mStats.mFailedParamsDCAL++;
} else {
mStats.mFailedParamsEMCAL++;
try {
auto [sm, mod, modphi, modeta] = mGeometry->GetCellIndex(itower);
mStats.mFailedParamSM[sm]++;
if (sm >= 12) {
mStats.mFailedParamsDCAL++;
} else {
mStats.mFailedParamsEMCAL++;
}
} catch (o2::emcal::InvalidCellIDException& e) {
ILOG(Error, Support) << e.what() << ENDM;
}
} else {
tcpGood.emplace_back(param);
Expand All @@ -62,16 +70,20 @@ void TimeCalibParamReductor::update(TObject* obj)
mStats.mFractionFailedDCAL = static_cast<double>(mStats.mFailedParamsDCAL) / static_cast<double>(CHANNELS_DCAL);
int currentmax = -1;
for (int ism = 0; ism < 20; ism++) {
auto smtype = mGeometry->GetSMType(ism);
auto nchannels = channelsSMTYPE.find(smtype);
if (nchannels == channelsSMTYPE.end()) {
ILOG(Error, Support) << "Unhandled Supermodule type" << ENDM;
continue;
}
mStats.mFractionFailedSM[ism] = static_cast<double>(mStats.mFailedParamSM[ism]) / static_cast<double>(nchannels->second);
if (mStats.mFailedParamSM[ism] > currentmax) {
currentmax = mStats.mFailedParamSM[ism];
mStats.mSupermoduleMaxFailed = ism;
try {
auto smtype = mGeometry->GetSMType(ism);
auto nchannels = channelsSMTYPE.find(smtype);
if (nchannels == channelsSMTYPE.end()) {
ILOG(Error, Support) << "Unhandled Supermodule type" << ENDM;
continue;
}
mStats.mFractionFailedSM[ism] = static_cast<double>(mStats.mFailedParamSM[ism]) / static_cast<double>(nchannels->second);
if (mStats.mFailedParamSM[ism] > currentmax) {
currentmax = mStats.mFailedParamSM[ism];
mStats.mSupermoduleMaxFailed = ism;
}
} catch (o2::emcal::SupermoduleIndexException& e) {
ILOG(Error, Support) << e.what() << ENDM;
}
}
mStats.mMeanShiftGood = TMath::Mean(tcpGood.begin(), tcpGood.end());
Expand Down

0 comments on commit bbd44a2

Please sign in to comment.