File indexing completed on 2024-04-06 12:07:17
0001 #include "DQM/EcalMonitorClient/interface/SummaryClient.h"
0002
0003 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0004
0005 #include "CondFormats/EcalObjects/interface/EcalDQMStatusHelper.h"
0006
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008
0009 #include <algorithm>
0010
0011 namespace ecaldqm {
0012 SummaryClient::SummaryClient() : DQWorkerClient(), towerBadFraction_(0.), fedBadFraction_(0.) {
0013 qualitySummaries_.insert("QualitySummary");
0014 qualitySummaries_.insert("ReportSummaryMap");
0015 qualitySummaries_.insert("ReportSummaryContents");
0016 qualitySummaries_.insert("ReportSummary");
0017 }
0018
0019 void SummaryClient::setParams(edm::ParameterSet const& _params) {
0020 towerBadFraction_ = _params.getUntrackedParameter<double>("towerBadFraction");
0021 fedBadFraction_ = _params.getUntrackedParameter<double>("fedBadFraction");
0022
0023 std::vector<std::string> sourceList(_params.getUntrackedParameter<std::vector<std::string> >("activeSources"));
0024 if (std::find(sourceList.begin(), sourceList.end(), "Presample") == sourceList.end())
0025 sources_.erase(std::string("Presample"));
0026 if (std::find(sourceList.begin(), sourceList.end(), "Timing") == sourceList.end())
0027 sources_.erase(std::string("Timing"));
0028 if (std::find(sourceList.begin(), sourceList.end(), "TriggerPrimitives") == sourceList.end())
0029 sources_.erase(std::string("TriggerPrimitives"));
0030 if (std::find(sourceList.begin(), sourceList.end(), "HotCell") == sourceList.end())
0031 sources_.erase(std::string("HotCell"));
0032 }
0033
0034 void SummaryClient::resetMEs() {
0035 DQWorkerClient::resetMEs();
0036
0037 MESet& meReportSummaryContents(MEs_.at("ReportSummaryContents"));
0038 MESet& meReportSummary(MEs_.at("ReportSummary"));
0039 MESet& meReportSummaryMap(MEs_.at("ReportSummaryMap"));
0040
0041 for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0042 int dccid(iDCC + 1);
0043 meReportSummaryContents.fill(getEcalDQMSetupObjects(), dccid, -1.);
0044 }
0045
0046 meReportSummary.fill(getEcalDQMSetupObjects(), -1.);
0047
0048 meReportSummaryMap.reset(GetElectronicsMap(), -1.);
0049 }
0050
0051 void SummaryClient::producePlots(ProcessType _pType) {
0052 MESet& meReportSummaryContents(MEs_.at("ReportSummaryContents"));
0053 MESet& meReportSummary(MEs_.at("ReportSummary"));
0054
0055 for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0056 int dccid(iDCC + 1);
0057 meReportSummaryContents.fill(getEcalDQMSetupObjects(), dccid, -1.);
0058 }
0059 meReportSummary.fill(getEcalDQMSetupObjects(), -1.);
0060
0061 MESet const& sIntegrityByLumi(sources_.at("IntegrityByLumi"));
0062 MESet const& sDesyncByLumi(sources_.at("DesyncByLumi"));
0063 MESet const& sFEByLumi(sources_.at("FEByLumi"));
0064 MESet const& sFEStatusErrMapByLumi(sources_.at("FEStatusErrMapByLumi"));
0065
0066 double integrityByLumi[nDCC];
0067 double rawDataByLumi[nDCC];
0068 for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0069 integrityByLumi[iDCC] = sIntegrityByLumi.getBinContent(getEcalDQMSetupObjects(), iDCC + 1);
0070 rawDataByLumi[iDCC] = sDesyncByLumi.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) +
0071 sFEByLumi.getBinContent(getEcalDQMSetupObjects(), iDCC + 1);
0072 }
0073
0074 MESet& meQualitySummary(MEs_.at("QualitySummary"));
0075 MESet& meReportSummaryMap(MEs_.at("ReportSummaryMap"));
0076
0077 MESet const* sIntegrity(using_("Integrity") ? &sources_.at("Integrity") : nullptr);
0078 MESet const& sRawData(sources_.at("RawData"));
0079 MESet const* sPresample(using_("Presample") ? &sources_.at("Presample") : nullptr);
0080 MESet const* sTiming(using_("Timing") ? &sources_.at("Timing") : nullptr);
0081 MESet const* sTriggerPrimitives(using_("TriggerPrimitives") ? &sources_.at("TriggerPrimitives") : nullptr);
0082 MESet const* sHotCell(using_("HotCell") ? &sources_.at("HotCell") : nullptr);
0083
0084 float totalChannels(0.);
0085 float totalGood(0.), totalGoodRaw(0);
0086
0087 double dccChannels[nDCC];
0088 std::fill_n(dccChannels, nDCC, 0.);
0089 double dccGood[nDCC], dccGoodRaw[nDCC];
0090 std::fill_n(dccGood, nDCC, 0.);
0091 std::fill_n(dccGoodRaw, nDCC, 0.);
0092
0093 std::map<uint32_t, int> badChannelsCount;
0094
0095
0096
0097 MESet const& sBXSRP(sources_.at("BXSRP"));
0098 MESet const& sBXTCC(sources_.at("BXTCC"));
0099 std::vector<bool> hasMismatchDCC(nDCC, false);
0100 for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0101 if (sBXSRP.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50. ||
0102 sBXTCC.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50.)
0103 hasMismatchDCC[iDCC] = true;
0104 }
0105
0106
0107 uint32_t mask(1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR);
0108
0109 MESet::iterator qEnd(meQualitySummary.end(GetElectronicsMap()));
0110 for (MESet::iterator qItr(meQualitySummary.beginChannel(GetElectronicsMap())); qItr != qEnd;
0111 qItr.toNextChannel(GetElectronicsMap())) {
0112 DetId id(qItr->getId());
0113 unsigned iDCC(dccId(id, GetElectronicsMap()) - 1);
0114
0115
0116
0117 int integrity(sIntegrity ? (int)sIntegrity->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
0118 int presample(sPresample ? (int)sPresample->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
0119 int hotcell(sHotCell ? (int)sHotCell->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
0120 int timing(sTiming ? (int)sTiming->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
0121 int trigprim(sTriggerPrimitives ? (int)sTriggerPrimitives->getBinContent(getEcalDQMSetupObjects(), id)
0122 : kUnknown);
0123 int rawdata(sRawData.getBinContent(getEcalDQMSetupObjects(), id));
0124
0125 double rawdataLS(sFEStatusErrMapByLumi.getBinContent(getEcalDQMSetupObjects(), id));
0126
0127
0128
0129 if (integrity == kBad && integrityByLumi[iDCC] == 0. && !hasMismatchDCC[iDCC])
0130 integrity = kGood;
0131
0132 if (rawdata == kBad && rawDataByLumi[iDCC] == 0. && rawdataLS == 0.)
0133 rawdata = kGood;
0134
0135
0136 int status(kGood);
0137 if (integrity == kBad || presample == kBad || timing == kBad || rawdata == kBad || trigprim == kBad ||
0138 hotcell == kBad)
0139 status = kBad;
0140 else if (integrity == kUnknown && presample == kUnknown && timing == kUnknown && rawdata == kUnknown &&
0141 trigprim == kUnknown)
0142 status = kUnknown;
0143
0144
0145
0146 if (status != kBad && (integrity == kUnknown || integrity == kMUnknown)) {
0147 qItr->setBinContent(integrity);
0148 if (onlineMode_)
0149 continue;
0150 }
0151 qItr->setBinContent(status);
0152
0153
0154 if (status == kBad) {
0155 if (id.subdetId() == EcalBarrel)
0156 badChannelsCount[EBDetId(id).tower().rawId()] += 1;
0157 if (id.subdetId() == EcalEndcap)
0158 badChannelsCount[EEDetId(id).sc().rawId()] += 1;
0159 } else {
0160 dccGood[iDCC] += 1.;
0161 totalGood += 1.;
0162 }
0163 dccChannels[iDCC] += 1.;
0164 totalChannels += 1.;
0165
0166
0167
0168 bool isMasked(meQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
0169 if (rawdataLS == 0. || isMasked) {
0170 dccGoodRaw[iDCC] += 1.;
0171 totalGoodRaw += 1.;
0172 }
0173
0174 }
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240 double nBad(0.);
0241 for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0242 if (dccChannels[iDCC] < 1.)
0243 continue;
0244
0245 int dccid(iDCC + 1);
0246 float frac(dccGood[iDCC] / dccChannels[iDCC]);
0247 float fracRaw(dccGoodRaw[iDCC] / dccChannels[iDCC]);
0248 meReportSummaryMap.setBinContent(getEcalDQMSetupObjects(), dccid, frac);
0249 float fracLS(onlineMode_ ? frac : fracRaw);
0250 meReportSummaryContents.fill(getEcalDQMSetupObjects(), dccid, fracLS);
0251
0252 if (1. - frac > fedBadFraction_)
0253 nBad += 1.;
0254 }
0255
0256 float totalGoodLS(onlineMode_ ? totalGood : totalGoodRaw);
0257 if (totalChannels > 0.)
0258 meReportSummary.fill(getEcalDQMSetupObjects(), totalGoodLS / totalChannels);
0259
0260 if (onlineMode_) {
0261 if (totalChannels > 0.)
0262 MEs_.at("GlobalSummary").setBinContent(getEcalDQMSetupObjects(), 1, totalGood / totalChannels);
0263 MEs_.at("NBadFEDs").setBinContent(getEcalDQMSetupObjects(), 1, nBad);
0264 }
0265
0266 }
0267
0268 DEFINE_ECALDQM_WORKER(SummaryClient);
0269 }