Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:01

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 #include "DQM/EcalCommon/interface/MESetNonObject.h"
0012 
0013 namespace ecaldqm {
0014   IntegrityClient::IntegrityClient() : DQWorkerClient(), errFractionThreshold_(0.), processedEvents(0) {
0015     qualitySummaries_.insert("Quality");
0016     qualitySummaries_.insert("QualitySummary");
0017   }
0018 
0019   void IntegrityClient::setParams(edm::ParameterSet const& _params) {
0020     errFractionThreshold_ = _params.getUntrackedParameter<double>("errFractionThreshold");
0021   }
0022 
0023   void IntegrityClient::setTokens(edm::ConsumesCollector& _collector) {
0024     chStatusToken = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
0025   }
0026 
0027   // Check Channel Status Record at every endLumi
0028   // Used to fill Channel Status Map MEs
0029   void IntegrityClient::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const& _es) {
0030     chStatus = &_es.getData(chStatusToken);
0031   }
0032 
0033   void IntegrityClient::producePlots(ProcessType) {
0034     uint32_t mask(1 << EcalDQMStatusHelper::CH_ID_ERROR | 1 << EcalDQMStatusHelper::CH_GAIN_ZERO_ERROR |
0035                   1 << EcalDQMStatusHelper::CH_GAIN_SWITCH_ERROR | 1 << EcalDQMStatusHelper::TT_ID_ERROR |
0036                   1 << EcalDQMStatusHelper::TT_SIZE_ERROR);
0037 
0038     MESet& meQuality(MEs_.at("Quality"));
0039     MESet& meQualitySummary(MEs_.at("QualitySummary"));
0040     MESet& meChStatus(MEs_.at("ChStatus"));
0041 
0042     MESet const& sOccupancy(sources_.at("Occupancy"));
0043     MESet const& sGain(sources_.at("Gain"));
0044     MESet const& sChId(sources_.at("ChId"));
0045     MESet const& sGainSwitch(sources_.at("GainSwitch"));
0046     MESet const& sTowerId(sources_.at("TowerId"));
0047     MESet const& sBlockSize(sources_.at("BlockSize"));
0048     MESetNonObject const& sNumEvents(static_cast<MESetNonObject&>(sources_.at("NumEvents")));
0049 
0050     //Get the no.of events per LS calculated in OccupancyTask
0051     int nEv = sNumEvents.getFloatValue();
0052     processedEvents += nEv;  //Sum it up to get the total processed events for the whole run.
0053 
0054     //TTID errors nomalized by total no.of events in a run.
0055     MESet& meTTIDNorm(MEs_.at("TowerIdNormalized"));
0056     MESet::iterator tEnd(meTTIDNorm.end(GetElectronicsMap()));
0057     for (MESet::iterator tItr(meTTIDNorm.beginChannel(GetElectronicsMap())); tItr != tEnd;
0058          tItr.toNextChannel(GetElectronicsMap())) {
0059       DetId id(tItr->getId());
0060       float towerid(sTowerId.getBinContent(getEcalDQMSetupObjects(), id));
0061       tItr->setBinContent(towerid / processedEvents);
0062     }
0063     // Fill Channel Status Map MEs
0064     // Record is checked for updates at every endLumi and filled here
0065     MESet::iterator chSEnd(meChStatus.end(GetElectronicsMap()));
0066     for (MESet::iterator chSItr(meChStatus.beginChannel(GetElectronicsMap())); chSItr != chSEnd;
0067          chSItr.toNextChannel(GetElectronicsMap())) {
0068       DetId id(chSItr->getId());
0069 
0070       EcalChannelStatusMap::const_iterator chIt(nullptr);
0071 
0072       // Set appropriate channel map (EB or EE)
0073       if (id.subdetId() == EcalBarrel) {
0074         EBDetId ebid(id);
0075         chIt = chStatus->find(ebid);
0076       } else {
0077         EEDetId eeid(id);
0078         chIt = chStatus->find(eeid);
0079       }
0080 
0081       // Get status code and fill ME
0082       if (chIt != chStatus->end()) {
0083         uint16_t code(chIt->getEncodedStatusCode());
0084         chSItr->setBinContent(code);
0085       }
0086 
0087     }  // Channel Status Map
0088 
0089     MESet::iterator qEnd(meQuality.end(GetElectronicsMap()));
0090     MESet::const_iterator occItr(GetElectronicsMap(), sOccupancy);
0091     for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
0092          qItr.toNextChannel(GetElectronicsMap())) {
0093       occItr = qItr;
0094 
0095       DetId id(qItr->getId());
0096 
0097       bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
0098 
0099       float entries(occItr->getBinContent());
0100 
0101       float gain(sGain.getBinContent(getEcalDQMSetupObjects(), id));
0102       float chid(sChId.getBinContent(getEcalDQMSetupObjects(), id));
0103       float gainswitch(sGainSwitch.getBinContent(getEcalDQMSetupObjects(), id));
0104 
0105       float towerid(sTowerId.getBinContent(getEcalDQMSetupObjects(), id));
0106       float blocksize(sBlockSize.getBinContent(getEcalDQMSetupObjects(), id));
0107 
0108       if (entries + gain + chid + gainswitch + towerid + blocksize < 1.) {
0109         qItr->setBinContent(doMask ? kMUnknown : kUnknown);
0110         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
0111         continue;
0112       }
0113 
0114       float chErr((gain + chid + gainswitch + towerid + blocksize) /
0115                   (entries + gain + chid + gainswitch + towerid + blocksize));
0116 
0117       if (chErr > errFractionThreshold_) {
0118         qItr->setBinContent(doMask ? kMBad : kBad);
0119         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
0120       } else {
0121         qItr->setBinContent(doMask ? kMGood : kGood);
0122         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
0123       }
0124     }
0125 
0126     // Quality check: set an entire FED to BAD if "any" DCC-SRP or DCC-TCC mismatch errors are detected AND the number of events affected by the DCC-SRP or DCC-TCC mismatch errors is more than 1% of the events analyzed in the run
0127     // Fill mismatch statistics
0128     MESet const& sBXSRP(sources_.at("BXSRP"));
0129     MESet const& sBXTCC(sources_.at("BXTCC"));
0130     std::vector<bool> hasMismatchDCC(nDCC, false);
0131     for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0132       int nBXSRPdesync = sBXSRP.getBinContent(getEcalDQMSetupObjects(), iDCC + 1);
0133       int nBXTCCdesync = sBXTCC.getBinContent(getEcalDQMSetupObjects(), iDCC + 1);
0134 
0135       if (nBXSRPdesync > 50. || nBXTCCdesync > 50.) {  // "any" => 50
0136         if (nBXSRPdesync > int(0.01 * processedEvents) ||
0137             nBXTCCdesync >
0138                 int(0.01 *
0139                     processedEvents)) {  // check if the events with DCC-SRP or DCC-TCC desyncs for the given DCC is more than 1% of the events analyzed
0140           hasMismatchDCC[iDCC] = true;
0141         }
0142       }
0143     }
0144     // Analyze mismatch statistics
0145     for (MESet::iterator qsItr(meQualitySummary.beginChannel(GetElectronicsMap()));
0146          qsItr != meQualitySummary.end(GetElectronicsMap());
0147          qsItr.toNextChannel(GetElectronicsMap())) {
0148       DetId id(qsItr->getId());
0149       unsigned iDCC(dccId(id, GetElectronicsMap()) - 1);
0150       if (hasMismatchDCC[iDCC])
0151         meQualitySummary.setBinContent(
0152             getEcalDQMSetupObjects(),
0153             id,
0154             meQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()) ? kMBad : kBad);
0155     }
0156 
0157   }  // producePlots()
0158 
0159   DEFINE_ECALDQM_WORKER(IntegrityClient);
0160 }  // namespace ecaldqm