Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-02 23:48:43

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