File indexing completed on 2024-04-06 12:07:16
0001 #include "DQM/EcalMonitorClient/interface/LaserClient.h"
0002
0003 #include "DataFormats/EcalDetId/interface/EcalPnDiodeDetId.h"
0004
0005 #include "CondFormats/EcalObjects/interface/EcalDQMStatusHelper.h"
0006
0007 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0008 #include "DQM/EcalCommon/interface/MESetMulti.h"
0009
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011
0012 #include <cmath>
0013
0014 namespace ecaldqm {
0015 LaserClient::LaserClient()
0016 : DQWorkerClient(),
0017 wlToME_(),
0018 minChannelEntries_(0),
0019 expectedAmplitude_(0),
0020 toleranceAmplitudeLo_(0.),
0021 toleranceAmplitudeFwdLo_(0.),
0022 toleranceAmplitudeHi_(0.),
0023 toleranceAmpRMSRatio_(0.),
0024 expectedTiming_(0),
0025 toleranceTiming_(0.),
0026 toleranceTimRMS_(0.),
0027 expectedPNAmplitude_(0),
0028 tolerancePNAmp_(0.),
0029 tolerancePNRMSRatio_(0.),
0030 forwardFactor_(0.) {}
0031
0032 void LaserClient::setParams(edm::ParameterSet const& _params) {
0033 minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
0034 toleranceAmplitudeLo_ = _params.getUntrackedParameter<double>("toleranceAmplitudeLo");
0035 toleranceAmplitudeFwdLo_ = _params.getUntrackedParameter<double>("toleranceAmplitudeFwdLo");
0036 toleranceAmplitudeHi_ = _params.getUntrackedParameter<double>("toleranceAmplitudeHi");
0037 toleranceAmpRMSRatio_ = _params.getUntrackedParameter<double>("toleranceAmpRMSRatio");
0038 toleranceTiming_ = _params.getUntrackedParameter<double>("toleranceTiming");
0039 toleranceTimRMS_ = _params.getUntrackedParameter<double>("toleranceTimRMS");
0040 tolerancePNAmp_ = _params.getUntrackedParameter<double>("tolerancePNAmp");
0041 tolerancePNRMSRatio_ = _params.getUntrackedParameter<double>("tolerancePNRMSRatio");
0042 forwardFactor_ = _params.getUntrackedParameter<double>("forwardFactor");
0043
0044 std::vector<int> laserWavelengths(_params.getUntrackedParameter<std::vector<int> >("laserWavelengths"));
0045
0046
0047
0048
0049
0050 MESet::PathReplacements repl;
0051
0052 MESetMulti const& amplitude(static_cast<MESetMulti const&>(sources_.at("Amplitude")));
0053 unsigned nWL(laserWavelengths.size());
0054 for (unsigned iWL(0); iWL != nWL; ++iWL) {
0055 int wl(laserWavelengths[iWL]);
0056 if (wl <= 0 || wl >= 5)
0057 throw cms::Exception("InvalidConfiguration") << "Laser Wavelength";
0058 repl["wl"] = std::to_string(wl);
0059 wlToME_[wl] = amplitude.getIndex(repl);
0060 }
0061
0062 expectedAmplitude_.resize(nWL);
0063 expectedTiming_.resize(nWL);
0064 expectedPNAmplitude_.resize(nWL);
0065
0066 std::vector<double> inExpectedAmplitude(_params.getUntrackedParameter<std::vector<double> >("expectedAmplitude"));
0067 std::vector<double> inExpectedTiming(_params.getUntrackedParameter<std::vector<double> >("expectedTiming"));
0068 std::vector<double> inExpectedPNAmplitude(
0069 _params.getUntrackedParameter<std::vector<double> >("expectedPNAmplitude"));
0070
0071 for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
0072 unsigned iME(wlItr->second);
0073 int iWL(wlItr->first - 1);
0074 expectedAmplitude_[iME] = inExpectedAmplitude[iWL];
0075 expectedTiming_[iME] = inExpectedTiming[iWL];
0076 expectedPNAmplitude_[iME] = inExpectedPNAmplitude[iWL];
0077 }
0078
0079 qualitySummaries_.insert("Quality");
0080 qualitySummaries_.insert("QualitySummary");
0081 qualitySummaries_.insert("PNQualitySummary");
0082 }
0083
0084 void LaserClient::producePlots(ProcessType) {
0085 uint32_t mask(1 << EcalDQMStatusHelper::LASER_MEAN_ERROR | 1 << EcalDQMStatusHelper::LASER_RMS_ERROR |
0086 1 << EcalDQMStatusHelper::LASER_TIMING_MEAN_ERROR | 1 << EcalDQMStatusHelper::LASER_TIMING_RMS_ERROR);
0087
0088 MESetMulti& meQuality(static_cast<MESetMulti&>(MEs_.at("Quality")));
0089 MESetMulti& meQualitySummary(static_cast<MESetMulti&>(MEs_.at("QualitySummary")));
0090 MESetMulti& meAmplitudeMean(static_cast<MESetMulti&>(MEs_.at("AmplitudeMean")));
0091 MESetMulti& meAmplitudeRMS(static_cast<MESetMulti&>(MEs_.at("AmplitudeRMS")));
0092 MESetMulti& meTimingMean(static_cast<MESetMulti&>(MEs_.at("TimingMean")));
0093 MESetMulti& meTimingRMSMap(static_cast<MESetMulti&>(MEs_.at("TimingRMSMap")));
0094 MESetMulti& meTimingRMS(static_cast<MESetMulti&>(MEs_.at("TimingRMS")));
0095 MESetMulti& mePNQualitySummary(static_cast<MESetMulti&>(MEs_.at("PNQualitySummary")));
0096
0097 MESetMulti const& sAmplitude(static_cast<MESetMulti const&>(sources_.at("Amplitude")));
0098 MESetMulti const& sTiming(static_cast<MESetMulti const&>(sources_.at("Timing")));
0099 MESetMulti const& sPNAmplitude(static_cast<MESetMulti const&>(sources_.at("PNAmplitude")));
0100 MESet const& sCalibStatus(static_cast<MESet const&>(sources_.at("CalibStatus")));
0101
0102 for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
0103 meQuality.use(wlItr->second);
0104 meQualitySummary.use(wlItr->second);
0105 meAmplitudeMean.use(wlItr->second);
0106 meAmplitudeRMS.use(wlItr->second);
0107 meTimingMean.use(wlItr->second);
0108 meTimingRMSMap.use(wlItr->second);
0109 meTimingRMS.use(wlItr->second);
0110 mePNQualitySummary.use(wlItr->second);
0111
0112 sAmplitude.use(wlItr->second);
0113 sTiming.use(wlItr->second);
0114 sPNAmplitude.use(wlItr->second);
0115
0116 MESet::iterator qEnd(meQuality.end(GetElectronicsMap()));
0117
0118 MESet::const_iterator tItr(GetElectronicsMap(), sTiming);
0119 MESet::const_iterator aItr(GetElectronicsMap(), sAmplitude);
0120
0121 int wl(wlItr->first - 1);
0122 bool enabled(wl < 0 ? false : sCalibStatus.getBinContent(getEcalDQMSetupObjects(), wl) > 0 ? true : false);
0123 for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
0124 qItr.toNextChannel(GetElectronicsMap())) {
0125 DetId id(qItr->getId());
0126
0127 bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
0128
0129 aItr = qItr;
0130
0131 float aEntries(aItr->getBinEntries());
0132
0133 if (aEntries < minChannelEntries_) {
0134 qItr->setBinContent(enabled ? (doMask ? kMUnknown : kUnknown) : kMUnknown);
0135 continue;
0136 }
0137
0138 float aMean(aItr->getBinContent());
0139 float aRms(aItr->getBinError() * sqrt(aEntries));
0140
0141 meAmplitudeMean.fill(getEcalDQMSetupObjects(), id, aMean);
0142 meAmplitudeRMS.setBinContent(getEcalDQMSetupObjects(), id, aRms);
0143
0144 tItr = qItr;
0145
0146 float tEntries(tItr->getBinEntries());
0147
0148 if (tEntries < minChannelEntries_)
0149 continue;
0150
0151 float tMean(tItr->getBinContent());
0152 float tRms(tItr->getBinError() * sqrt(tEntries));
0153 float threshAmplitudeLo_;
0154
0155 meTimingMean.fill(getEcalDQMSetupObjects(), id, tMean);
0156 meTimingRMS.fill(getEcalDQMSetupObjects(), id, tRms);
0157 meTimingRMSMap.setBinContent(getEcalDQMSetupObjects(), id, tRms);
0158
0159 float intensity(aMean / expectedAmplitude_[wlItr->second]);
0160 if (isForward(id)) {
0161 intensity /= forwardFactor_;
0162 threshAmplitudeLo_ = toleranceAmplitudeFwdLo_;
0163 } else
0164 threshAmplitudeLo_ = toleranceAmplitudeLo_;
0165
0166 if (intensity < threshAmplitudeLo_ || intensity > toleranceAmplitudeHi_ ||
0167 aRms > aMean * toleranceAmpRMSRatio_ ||
0168 std::abs(tMean - expectedTiming_[wlItr->second]) > toleranceTiming_ )
0169 qItr->setBinContent(doMask ? kMBad : kBad);
0170 else
0171 qItr->setBinContent(doMask ? kMGood : kGood);
0172 }
0173
0174 towerAverage_(meQualitySummary, meQuality, 0.2);
0175
0176 for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
0177 if (memDCCIndex(iDCC + 1) == unsigned(-1))
0178 continue;
0179 int subdet(0);
0180 if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
0181 subdet = EcalBarrel;
0182 else
0183 subdet = EcalEndcap;
0184
0185 for (unsigned iPN(0); iPN < 10; ++iPN) {
0186 EcalPnDiodeDetId id(subdet, iDCC + 1, iPN + 1);
0187
0188 bool doMask(mePNQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
0189
0190 float pEntries(sPNAmplitude.getBinEntries(getEcalDQMSetupObjects(), id));
0191
0192 if (pEntries < minChannelEntries_) {
0193 mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
0194 continue;
0195 }
0196
0197 float pMean(sPNAmplitude.getBinContent(getEcalDQMSetupObjects(), id));
0198 float pRms(sPNAmplitude.getBinError(getEcalDQMSetupObjects(), id) * sqrt(pEntries));
0199 float intensity(pMean / expectedPNAmplitude_[wlItr->second]);
0200
0201 if (intensity < tolerancePNAmp_ || pRms > pMean * tolerancePNRMSRatio_)
0202 mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
0203 else
0204 mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
0205 }
0206 }
0207 }
0208 }
0209
0210 DEFINE_ECALDQM_WORKER(LaserClient);
0211 }