Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-17 23:26:22

0001 #include "DQM/EcalMonitorClient/interface/PresampleClient.h"
0002 
0003 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0004 
0005 #include "CondFormats/EcalObjects/interface/EcalDQMStatusHelper.h"
0006 #include "CondFormats/EcalObjects/interface/EcalChannelStatusCode.h"
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 
0010 #include <cmath>
0011 
0012 namespace ecaldqm {
0013   PresampleClient::PresampleClient()
0014       : DQWorkerClient(),
0015         minChannelEntries_(0),
0016         expectedMean_(0.),
0017         toleranceLow_(0.),
0018         toleranceHigh_(0.),
0019         toleranceRMS_(0.),
0020         toleranceRMSFwd_(0.) {
0021     qualitySummaries_.insert("Quality");
0022     qualitySummaries_.insert("QualitySummary");
0023   }
0024 
0025   void PresampleClient::setParams(edm::ParameterSet const& _params) {
0026     minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
0027     expectedMean_ = _params.getUntrackedParameter<double>("expectedMean");
0028     toleranceLow_ = _params.getUntrackedParameter<double>("toleranceLow");
0029     toleranceHigh_ = _params.getUntrackedParameter<double>("toleranceHigh");
0030     toleranceRMS_ = _params.getUntrackedParameter<double>("toleranceRMS");
0031     toleranceRMSFwd_ = _params.getUntrackedParameter<double>("toleranceRMSFwd");
0032   }
0033 
0034   void PresampleClient::producePlots(ProcessType) {
0035     MESet& meQualitySummary(MEs_.at("QualitySummary"));
0036     MESet& meQuality(MEs_.at("Quality"));
0037     MESet& meErrorsSummary(MEs_.at("ErrorsSummary"));
0038     MESet& meMean(MEs_.at("Mean"));
0039     MESet& meRMS(MEs_.at("RMS"));
0040     MESet& meRMSMap(MEs_.at("RMSMap"));
0041     MESet& meRMSMapAll(MEs_.at("RMSMapAll"));
0042     MESet& meRMSMapAllByLumi(MEs_.at("RMSMapAllByLumi"));
0043 
0044     MESet const& sPedestal(sources_.at("Pedestal"));
0045     MESet const& sPedestalByLS(sources_.at("PedestalByLS"));
0046     MESet const& sChStatus(sources_.at("ChStatus"));
0047 
0048     uint32_t mask(1 << EcalDQMStatusHelper::PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR |
0049                   1 << EcalDQMStatusHelper::PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR);
0050 
0051     MESet::iterator qEnd(meQuality.end(GetElectronicsMap()));
0052 
0053     MESet::const_iterator pItr(GetElectronicsMap(), sPedestal);
0054     MESet::const_iterator pLSItr(GetElectronicsMap(), sPedestalByLS);
0055     double maxEB(0.), minEB(0.), maxEE(0.), minEE(0.);
0056     double rmsMaxEB(0.), rmsMaxEE(0.);
0057     for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
0058          qItr.toNextChannel(GetElectronicsMap())) {
0059       pItr = qItr;
0060       pLSItr = qItr;
0061 
0062       DetId id(qItr->getId());
0063 
0064       bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
0065 
0066       double rmsThresh(toleranceRMS_);
0067 
0068       if (isForward(id))
0069         rmsThresh = toleranceRMSFwd_;
0070 
0071       double entries(pItr->getBinEntries());
0072       double entriesLS(pLSItr->getBinEntries());
0073 
0074       if (entries < minChannelEntries_) {
0075         qItr->setBinContent(doMask ? kMUnknown : kUnknown);
0076         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
0077         meRMSMap.setBinContent(getEcalDQMSetupObjects(), id, -1.);
0078         continue;
0079       }
0080 
0081       double mean(pItr->getBinContent());
0082       double meanLS(pLSItr->getBinContent());
0083       double rms(pItr->getBinError() * std::sqrt(entries));
0084       double rmsLS(pLSItr->getBinError() * std::sqrt(entriesLS));
0085 
0086       int dccid(dccId(id, GetElectronicsMap()));
0087 
0088       meMean.fill(getEcalDQMSetupObjects(), dccid, mean);
0089       meRMS.fill(getEcalDQMSetupObjects(), dccid, rms);
0090       meRMSMap.setBinContent(getEcalDQMSetupObjects(), id, rms);
0091       meRMSMapAllByLumi.setBinContent(getEcalDQMSetupObjects(), id, rmsLS);
0092 
0093       if (((mean > expectedMean_ + toleranceHigh_) || (mean < expectedMean_ - toleranceLow_)) || rms > rmsThresh) {
0094         qItr->setBinContent(doMask ? kMBad : kBad);
0095         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
0096         if (!doMask)
0097           meErrorsSummary.fill(getEcalDQMSetupObjects(), id);
0098       } else {
0099         qItr->setBinContent(doMask ? kMGood : kGood);
0100         meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
0101       }
0102 
0103       // Fill Presample Trend plots:
0104       // Use PedestalByLS which only contains digis from "current" LS
0105       float chStatus(sChStatus.getBinContent(getEcalDQMSetupObjects(), id));
0106       if (entriesLS < minChannelEntries_)
0107         continue;
0108       if (chStatus != EcalChannelStatusCode::kOk)
0109         continue;  // exclude problematic channels
0110 
0111       // Get max/min
0112       // Min is effectively just 0
0113       if (id.subdetId() == EcalBarrel) {
0114         if (meanLS > maxEB)
0115           maxEB = meanLS;
0116         if (meanLS < minEB)
0117           minEB = meanLS;
0118         if (rmsLS > rmsMaxEB)
0119           rmsMaxEB = rmsLS;
0120       } else {
0121         if (meanLS > maxEE)
0122           maxEE = meanLS;
0123         if (meanLS < minEE)
0124           minEE = meanLS;
0125         if (rmsLS > rmsMaxEE)
0126           rmsMaxEE = rmsLS;
0127       }
0128 
0129     }  // qItr
0130 
0131     towerAverage_(meRMSMapAll, meRMSMap, -1.);
0132 
0133     MESet& meTrendMean(MEs_.at("TrendMean"));
0134     MESet& meTrendRMS(MEs_.at("TrendRMS"));
0135     meTrendMean.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), maxEB - minEB);
0136     meTrendMean.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), maxEE - minEE);
0137     meTrendRMS.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), rmsMaxEB);
0138     meTrendRMS.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), rmsMaxEE);
0139   }
0140 
0141   DEFINE_ECALDQM_WORKER(PresampleClient);
0142 }  // namespace ecaldqm