Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-29 01:21:18

0001 #include "DQM/EcalMonitorClient/interface/IntegrityClient.h"
0002 
0003 #include "CondFormats/EcalObjects/interface/EcalDQMStatusHelper.h"
0004 
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0008 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0009 
0010 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0011 
0012 namespace ecaldqm {
0013   IntegrityClient::IntegrityClient() : DQWorkerClient(), errFractionThreshold_(0.) {
0014     qualitySummaries_.insert("Quality");
0015     qualitySummaries_.insert("QualitySummary");
0016   }
0017 
0018   void IntegrityClient::setParams(edm::ParameterSet const& _params) {
0019     errFractionThreshold_ = _params.getUntrackedParameter<double>("errFractionThreshold");
0020   }
0021 
0022   void IntegrityClient::setTokens(edm::ConsumesCollector& _collector) {
0023     chStatusToken = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
0024   }
0025 
0026   // Check Channel Status Record at every endLumi
0027   // Used to fill Channel Status Map MEs
0028   void IntegrityClient::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const& _es) {
0029     chStatus = &_es.getData(chStatusToken);
0030   }
0031 
0032   void IntegrityClient::producePlots(ProcessType) {
0033     uint32_t mask(1 << EcalDQMStatusHelper::CH_ID_ERROR | 1 << EcalDQMStatusHelper::CH_GAIN_ZERO_ERROR |
0034                   1 << EcalDQMStatusHelper::CH_GAIN_SWITCH_ERROR | 1 << EcalDQMStatusHelper::TT_ID_ERROR |
0035                   1 << EcalDQMStatusHelper::TT_SIZE_ERROR);
0036 
0037     MESet& meQuality(MEs_.at("Quality"));
0038     MESet& meQualitySummary(MEs_.at("QualitySummary"));
0039     MESet& meChStatus(MEs_.at("ChStatus"));
0040 
0041     MESet const& sOccupancy(sources_.at("Occupancy"));
0042     MESet const& sGain(sources_.at("Gain"));
0043     MESet const& sChId(sources_.at("ChId"));
0044     MESet const& sGainSwitch(sources_.at("GainSwitch"));
0045     MESet const& sTowerId(sources_.at("TowerId"));
0046     MESet const& sBlockSize(sources_.at("BlockSize"));
0047 
0048     // Fill Channel Status Map MEs
0049     // Record is checked for updates at every endLumi and filled here
0050     MESet::iterator chSEnd(meChStatus.end(GetElectronicsMap()));
0051     for (MESet::iterator chSItr(meChStatus.beginChannel(GetElectronicsMap())); chSItr != chSEnd;
0052          chSItr.toNextChannel(GetElectronicsMap())) {
0053       DetId id(chSItr->getId());
0054 
0055       EcalChannelStatusMap::const_iterator chIt(nullptr);
0056 
0057       // Set appropriate channel map (EB or EE)
0058       if (id.subdetId() == EcalBarrel) {
0059         EBDetId ebid(id);
0060         chIt = chStatus->find(ebid);
0061       } else {
0062         EEDetId eeid(id);
0063         chIt = chStatus->find(eeid);
0064       }
0065 
0066       // Get status code and fill ME
0067       if (chIt != chStatus->end()) {
0068         uint16_t code(chIt->getEncodedStatusCode());
0069         chSItr->setBinContent(code);
0070       }
0071 
0072     }  // Channel Status Map
0073 
0074     MESet::iterator qEnd(meQuality.end(GetElectronicsMap()));
0075     MESet::const_iterator occItr(GetElectronicsMap(), sOccupancy);
0076     for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
0077          qItr.toNextChannel(GetElectronicsMap())) {
0078       occItr = qItr;
0079 
0080       DetId id(qItr->getId());
0081 
0082       bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
0083 
0084       float entries(occItr->getBinContent());
0085 
0086       float gain(sGain.getBinContent(getEcalDQMSetupObjects(), id));
0087       float chid(sChId.getBinContent(getEcalDQMSetupObjects(), id));
0088       float gainswitch(sGainSwitch.getBinContent(getEcalDQMSetupObjects(), id));
0089 
0090       float towerid(sTowerId.getBinContent(getEcalDQMSetupObjects(), id));
0091       float blocksize(sBlockSize.getBinContent(getEcalDQMSetupObjects(), id));
0092 
0093       if (entries + gain + chid + gainswitch + towerid + blocksize < 1.) {
0094         qItr->setBinContent(doMask ? kMUnknown : kUnknown);
0095         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
0096         continue;
0097       }
0098 
0099       float chErr((gain + chid + gainswitch + towerid + blocksize) /
0100                   (entries + gain + chid + gainswitch + towerid + blocksize));
0101 
0102       if (chErr > errFractionThreshold_) {
0103         qItr->setBinContent(doMask ? kMBad : kBad);
0104         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
0105       } else {
0106         qItr->setBinContent(doMask ? kMGood : kGood);
0107         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
0108       }
0109     }
0110 
0111     // Quality check: set an entire FED to BAD if "any" DCC-SRP or DCC-TCC mismatch errors are detected
0112     // Fill mismatch statistics
0113     MESet const& sBXSRP(sources_.at("BXSRP"));
0114     MESet const& sBXTCC(sources_.at("BXTCC"));
0115     std::vector<bool> hasMismatchDCC(nDCC, false);
0116     for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0117       if (sBXSRP.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50. ||
0118           sBXTCC.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50.)  // "any" => 50
0119         hasMismatchDCC[iDCC] = true;
0120     }
0121     // Analyze mismatch statistics
0122     for (MESet::iterator qsItr(meQualitySummary.beginChannel(GetElectronicsMap()));
0123          qsItr != meQualitySummary.end(GetElectronicsMap());
0124          qsItr.toNextChannel(GetElectronicsMap())) {
0125       DetId id(qsItr->getId());
0126       unsigned iDCC(dccId(id, GetElectronicsMap()) - 1);
0127       if (hasMismatchDCC[iDCC])
0128         meQualitySummary.setBinContent(
0129             getEcalDQMSetupObjects(),
0130             id,
0131             meQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()) ? kMBad : kBad);
0132     }
0133 
0134   }  // producePlots()
0135 
0136   DEFINE_ECALDQM_WORKER(IntegrityClient);
0137 }  // namespace ecaldqm