CMS 3D CMS Logo

LedClient.cc
Go to the documentation of this file.
2 
4 
6 
9 
11 
12 #include <cmath>
13 
14 namespace ecaldqm {
16  : DQWorkerClient(),
17  wlToME_(),
18  minChannelEntries_(0),
19  expectedAmplitude_(0),
20  toleranceAmplitude_(0.),
21  toleranceAmpRMSRatio_(0.),
22  expectedTiming_(0),
23  toleranceTiming_(0.),
24  toleranceTimRMS_(0.),
25  expectedPNAmplitude_(0),
26  tolerancePNAmp_(0.),
27  tolerancePNRMSRatio_(0.),
28  forwardFactor_(0.) {}
29 
31  minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
32  toleranceAmplitude_ = _params.getUntrackedParameter<double>("toleranceAmplitude");
33  toleranceAmpRMSRatio_ = _params.getUntrackedParameter<double>("toleranceAmpRMSRatio");
34  toleranceTiming_ = _params.getUntrackedParameter<double>("toleranceTiming");
35  toleranceTimRMS_ = _params.getUntrackedParameter<double>("toleranceTimRMS");
36  tolerancePNAmp_ = _params.getUntrackedParameter<double>("tolerancePNAmp");
37  tolerancePNRMSRatio_ = _params.getUntrackedParameter<double>("tolerancePNRMSRatio");
38  forwardFactor_ = _params.getUntrackedParameter<double>("forwardFactor");
39 
40  std::vector<int> ledWavelengths(_params.getUntrackedParameter<std::vector<int> >("ledWavelengths"));
41 
42  // wavelengths are not necessarily ordered
43  // create a map wl -> MESet index
44  // using Amplitude here but any multi-wavelength plot is fine
45 
47 
48  MESetMulti const& amplitude(static_cast<MESetMulti const&>(sources_.at("Amplitude")));
49  unsigned nWL(ledWavelengths.size());
50  for (unsigned iWL(0); iWL != nWL; ++iWL) {
51  int wl(ledWavelengths[iWL]);
52  if (wl != 1 && wl != 2)
53  throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
54  repl["wl"] = std::to_string(wl);
55  wlToME_[wl] = amplitude.getIndex(repl);
56  }
57 
58  expectedAmplitude_.resize(nWL);
59  expectedTiming_.resize(nWL);
60  expectedPNAmplitude_.resize(nWL);
61 
62  std::vector<double> inExpectedAmplitude(_params.getUntrackedParameter<std::vector<double> >("expectedAmplitude"));
63  std::vector<double> inExpectedTiming(_params.getUntrackedParameter<std::vector<double> >("expectedTiming"));
64  std::vector<double> inExpectedPNAmplitude(
65  _params.getUntrackedParameter<std::vector<double> >("expectedPNAmplitude"));
66 
67  for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
68  unsigned iME(wlItr->second);
69  int iWL(wlItr->first - 1);
70  expectedAmplitude_[iME] = inExpectedAmplitude[iWL];
71  expectedTiming_[iME] = inExpectedTiming[iWL];
72  expectedPNAmplitude_[iME] = inExpectedPNAmplitude[iWL];
73  }
74 
75  qualitySummaries_.insert("Quality");
76  qualitySummaries_.insert("QualitySummary");
77  qualitySummaries_.insert("PNQualitySummary");
78  }
79 
83 
84  MESetMulti& meQuality(static_cast<MESetMulti&>(MEs_.at("Quality")));
85  MESetMulti& meQualitySummary(static_cast<MESetMulti&>(MEs_.at("QualitySummary")));
86  MESetMulti& meAmplitudeMean(static_cast<MESetMulti&>(MEs_.at("AmplitudeMean")));
87  MESetMulti& meAmplitudeRMS(static_cast<MESetMulti&>(MEs_.at("AmplitudeRMS")));
88  MESetMulti& meTimingMean(static_cast<MESetMulti&>(MEs_.at("TimingMean")));
89  MESetMulti& meTimingRMSMap(static_cast<MESetMulti&>(MEs_.at("TimingRMSMap")));
90  MESetMulti& mePNQualitySummary(static_cast<MESetMulti&>(MEs_.at("PNQualitySummary")));
91 
92  MESetMulti const& sAmplitude(static_cast<MESetMulti const&>(sources_.at("Amplitude")));
93  MESetMulti const& sTiming(static_cast<MESetMulti const&>(sources_.at("Timing")));
94  MESetMulti const& sPNAmplitude(static_cast<MESetMulti const&>(sources_.at("PNAmplitude")));
95  MESet const& sCalibStatus(static_cast<MESet const&>(sources_.at("CalibStatus")));
96 
97  for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
98  meQuality.use(wlItr->second);
99  meQualitySummary.use(wlItr->second);
100  meAmplitudeMean.use(wlItr->second);
101  meAmplitudeRMS.use(wlItr->second);
102  meTimingMean.use(wlItr->second);
103  meTimingRMSMap.use(wlItr->second);
104  mePNQualitySummary.use(wlItr->second);
105 
106  sAmplitude.use(wlItr->second);
107  sTiming.use(wlItr->second);
108  sPNAmplitude.use(wlItr->second);
109 
110  MESet::iterator qEnd(meQuality.end());
111 
112  MESet::const_iterator tItr(sTiming);
113  MESet::const_iterator aItr(sAmplitude);
114 
115  int wl(wlItr->first + 3);
116  bool enabled(wl < 0 ? false : sCalibStatus.getBinContent(wl) > 0 ? true : false);
117  for (MESet::iterator qItr(meQuality.beginChannel()); qItr != qEnd; qItr.toNextChannel()) {
118  DetId id(qItr->getId());
119 
120  bool doMask(meQuality.maskMatches(id, mask, statusManager_));
121 
122  aItr = qItr;
123 
124  float aEntries(aItr->getBinEntries());
125 
126  if (aEntries < minChannelEntries_) {
127  qItr->setBinContent(enabled ? (doMask ? kMUnknown : kUnknown) : kMUnknown);
128  continue;
129  }
130 
131  float aMean(aItr->getBinContent());
132  float aRms(aItr->getBinError() * sqrt(aEntries));
133 
134  meAmplitudeMean.fill(id, aMean);
135  meAmplitudeRMS.setBinContent(id, aRms);
136 
137  tItr = qItr;
138 
139  float tEntries(tItr->getBinEntries());
140 
141  if (tEntries < minChannelEntries_)
142  continue;
143 
144  float tMean(tItr->getBinContent());
145  float tRms(tItr->getBinError() * sqrt(tEntries));
146 
147  meTimingMean.fill(id, tMean);
148  meTimingRMSMap.setBinContent(id, tRms);
149 
150  float intensity(aMean / expectedAmplitude_[wlItr->second]);
151  if (isForward(id))
152  intensity /= forwardFactor_;
153 
154  float aRmsThr(sqrt(pow(aMean * toleranceAmpRMSRatio_, 2) + pow(3., 2)));
155  if (intensity < toleranceAmplitude_ || aRms > aRmsThr ||
156  std::abs(tMean - expectedTiming_[wlItr->second]) > toleranceTiming_ || tRms > toleranceTimRMS_)
157  qItr->setBinContent(doMask ? kMBad : kBad);
158  else
159  qItr->setBinContent(doMask ? kMGood : kGood);
160  }
161 
162  towerAverage_(meQualitySummary, meQuality, 0.2);
163 
164  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
165  if (memDCCIndex(iDCC + 1) == unsigned(-1))
166  continue;
167  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
168  continue;
169 
170  for (unsigned iPN(0); iPN < 10; ++iPN) {
171  EcalPnDiodeDetId id(EcalEndcap, iDCC + 1, iPN + 1);
172 
173  bool doMask(mePNQualitySummary.maskMatches(id, mask, statusManager_));
174 
175  float pEntries(sPNAmplitude.getBinEntries(id));
176 
177  if (pEntries < minChannelEntries_) {
178  mePNQualitySummary.setBinContent(id, doMask ? kMUnknown : kUnknown);
179  continue;
180  }
181 
182  float pMean(sPNAmplitude.getBinContent(id));
183  float pRms(sPNAmplitude.getBinError(id) * sqrt(pEntries));
184  float intensity(pMean / expectedPNAmplitude_[wlItr->second]);
185 
186  if (intensity < tolerancePNAmp_ || pRms > pMean * tolerancePNRMSRatio_)
187  mePNQualitySummary.setBinContent(id, doMask ? kMBad : kBad);
188  else
189  mePNQualitySummary.setBinContent(id, doMask ? kMGood : kGood);
190  }
191  }
192  }
193  }
194 
196 } // namespace ecaldqm
EcalDQMStatusHelper::LED_RMS_ERROR
static const int LED_RMS_ERROR
Definition: EcalDQMStatusHelper.h:40
ecaldqm::MESetMulti::fill
void fill(DetId const &_id, double _xyw=1., double _yw=1., double _w=1.) override
Definition: MESetMulti.h:29
CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
EcalDQMStatusHelper::LED_MEAN_ERROR
static const int LED_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:39
ecaldqm
Definition: DQWorker.h:24
ecaldqm::LedClient::setParams
void setParams(edm::ParameterSet const &) override
Definition: LedClient.cc:30
LaserClient_cfi.wl
wl
Definition: LaserClient_cfi.py:46
ecaldqm::MESetMulti::end
const_iterator end() const override
Definition: MESetMulti.h:122
ecaldqm::LedClient::wlToME_
std::map< int, unsigned > wlToME_
Definition: LedClient.h:17
ecaldqm::LedClient::expectedPNAmplitude_
std::vector< double > expectedPNAmplitude_
Definition: LedClient.h:26
ecaldqm::LedClient::expectedAmplitude_
std::vector< double > expectedAmplitude_
Definition: LedClient.h:20
ecaldqm::MESet::PathReplacements
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
l1extraParticles_cfi._params
_params
Definition: l1extraParticles_cfi.py:29
ecaldqm::memDCCIndex
unsigned memDCCIndex(unsigned)
Definition: EcalDQMCommonUtils.cc:48
ecaldqm::DQWorkerClient::statusManager_
StatusManager const * statusManager_
Definition: DQWorkerClient.h:60
ecaldqm::MESetMulti::getBinError
double getBinError(DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:89
EcalDQMStatusHelper::LED_TIMING_MEAN_ERROR
static const int LED_TIMING_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:41
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
ecaldqm::MESetMulti::use
void use(unsigned) const
Definition: MESetMulti.cc:130
ecaldqm::LedClient::producePlots
void producePlots(ProcessType) override
Definition: LedClient.cc:80
ecaldqm::isForward
bool isForward(DetId const &)
Definition: EcalDQMCommonUtils.cc:243
LedClient.h
EcalDQMStatusHelper.h
ecaldqm::MESetMulti::beginChannel
const_iterator beginChannel() const override
Definition: MESetMulti.h:123
ecaldqm::MESetMulti::getBinContent
double getBinContent(DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:81
DetId
Definition: DetId.h:17
ecaldqm::MESet::getBinContent
virtual double getBinContent(DetId const &, int=0) const
Definition: MESet.h:72
ecaldqm::DQWorkerClient::qualitySummaries_
std::set< std::string > qualitySummaries_
Definition: DQWorkerClient.h:56
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ecaldqm::DQWorkerClient::ProcessType
ProcessType
Definition: DQWorkerClient.h:15
ecaldqm::MESet::iterator::toNextChannel
const_iterator & toNextChannel()
Definition: MESet.h:289
ecaldqm::kEBpHigh
Definition: EcalDQMCommonUtils.h:88
ecaldqm::LedClient::tolerancePNRMSRatio_
double tolerancePNRMSRatio_
Definition: LedClient.h:28
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:78
ecaldqm::DQWorkerClient::kMBad
Definition: DQWorkerClient.h:37
EcalEndcap
Definition: EcalSubdetector.h:10
ecaldqm::DQWorkerClient::kUnknown
Definition: DQWorkerClient.h:37
ecaldqm::DQWorkerClient::kBad
Definition: DQWorkerClient.h:37
EcalPnDiodeDetId.h
funct::true
true
Definition: Factorize.h:173
ecaldqm::DQWorkerClient::sources_
MESetCollection sources_
Definition: DQWorkerClient.h:55
ecaldqm::LedClient::forwardFactor_
float forwardFactor_
Definition: LedClient.h:29
ecaldqm::DQWorkerClient::kMGood
Definition: DQWorkerClient.h:37
ecaldqm::MESetMulti::getBinEntries
double getBinEntries(DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:95
edm::ParameterSet
Definition: ParameterSet.h:36
ecaldqm::MESetMulti
Definition: MESetMulti.h:13
ecaldqm::MESet::iterator
Definition: MESet.h:268
ecaldqm::DQWorkerClient::kMUnknown
Definition: DQWorkerClient.h:37
ecaldqm::LedClient::toleranceTiming_
double toleranceTiming_
Definition: LedClient.h:24
ecaldqm::MESetMulti::maskMatches
bool maskMatches(DetId const &_id, uint32_t _mask, StatusManager const *_statusManager) const override
Definition: MESetMulti.h:106
ecaldqm::kEBmLow
Definition: EcalDQMCommonUtils.h:85
EcalDQMStatusHelper::LED_TIMING_RMS_ERROR
static const int LED_TIMING_RMS_ERROR
Definition: EcalDQMStatusHelper.h:42
CalibrationSummaryClient_cfi.ledWavelengths
ledWavelengths
Definition: CalibrationSummaryClient_cfi.py:16
ecaldqm::DQWorkerClient
Definition: DQWorkerClient.h:13
ecaldqm::LedClient::toleranceTimRMS_
double toleranceTimRMS_
Definition: LedClient.h:25
ecaldqm::MESetMulti::setBinContent
void setBinContent(DetId const &_id, double _content) override
Definition: MESetMulti.h:40
ecaldqm::MESet::const_iterator
Definition: MESet.h:245
ecaldqm::LedClient::minChannelEntries_
int minChannelEntries_
Definition: LedClient.h:19
ecaldqm::LedClient::toleranceAmplitude_
double toleranceAmplitude_
Definition: LedClient.h:21
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ecaldqm::DQWorkerClient::towerAverage_
void towerAverage_(MESet &, MESet const &, float)
Definition: DQWorkerClient.cc:159
ecaldqm::DQWorkerClient::kGood
Definition: DQWorkerClient.h:37
Exception
Definition: hltDiff.cc:246
ecaldqm::LedClient::tolerancePNAmp_
double tolerancePNAmp_
Definition: LedClient.h:27
MESetMulti.h
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:92
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:112
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
ecaldqm::LedClient::LedClient
LedClient()
Definition: LedClient.cc:15
EcalDQMCommonUtils.h
ecaldqm::LedClient::expectedTiming_
std::vector< double > expectedTiming_
Definition: LedClient.h:23
ecaldqm::MESet
Definition: MESet.h:27
pixel_dqm_sourceclient-live_cfg.enabled
enabled
Definition: pixel_dqm_sourceclient-live_cfg.py:131
ecaldqm::LedClient
Definition: LedClient.h:7
ecaldqm::LedClient::toleranceAmpRMSRatio_
double toleranceAmpRMSRatio_
Definition: LedClient.h:22