CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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(GetElectronicsMap()));
111 
112  MESet::const_iterator tItr(GetElectronicsMap(), sTiming);
113  MESet::const_iterator aItr(GetElectronicsMap(), sAmplitude);
114 
115  int wl(wlItr->first + 3);
116  bool enabled(wl < 0 ? false : sCalibStatus.getBinContent(getEcalDQMSetupObjects(), wl) > 0 ? true : false);
117  for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
119  DetId id(qItr->getId());
120 
121  bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
122 
123  aItr = qItr;
124 
125  float aEntries(aItr->getBinEntries());
126 
127  if (aEntries < minChannelEntries_) {
128  qItr->setBinContent(enabled ? (doMask ? kMUnknown : kUnknown) : kMUnknown);
129  continue;
130  }
131 
132  float aMean(aItr->getBinContent());
133  float aRms(aItr->getBinError() * sqrt(aEntries));
134 
135  meAmplitudeMean.fill(getEcalDQMSetupObjects(), id, aMean);
136  meAmplitudeRMS.setBinContent(getEcalDQMSetupObjects(), id, aRms);
137 
138  tItr = qItr;
139 
140  float tEntries(tItr->getBinEntries());
141 
142  if (tEntries < minChannelEntries_)
143  continue;
144 
145  float tMean(tItr->getBinContent());
146  float tRms(tItr->getBinError() * sqrt(tEntries));
147 
148  meTimingMean.fill(getEcalDQMSetupObjects(), id, tMean);
149  meTimingRMSMap.setBinContent(getEcalDQMSetupObjects(), id, tRms);
150 
151  float intensity(aMean / expectedAmplitude_[wlItr->second]);
152  if (isForward(id))
153  intensity /= forwardFactor_;
154 
155  float aRmsThr(sqrt(pow(aMean * toleranceAmpRMSRatio_, 2) + pow(3., 2)));
156  if (intensity < toleranceAmplitude_ || aRms > aRmsThr ||
157  std::abs(tMean - expectedTiming_[wlItr->second]) > toleranceTiming_ || tRms > toleranceTimRMS_)
158  qItr->setBinContent(doMask ? kMBad : kBad);
159  else
160  qItr->setBinContent(doMask ? kMGood : kGood);
161  }
162 
163  towerAverage_(meQualitySummary, meQuality, 0.2);
164 
165  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
166  if (memDCCIndex(iDCC + 1) == unsigned(-1))
167  continue;
168  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
169  continue;
170 
171  for (unsigned iPN(0); iPN < 10; ++iPN) {
172  EcalPnDiodeDetId id(EcalEndcap, iDCC + 1, iPN + 1);
173 
174  bool doMask(mePNQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
175 
176  float pEntries(sPNAmplitude.getBinEntries(getEcalDQMSetupObjects(), id));
177 
178  if (pEntries < minChannelEntries_) {
179  mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
180  continue;
181  }
182 
183  float pMean(sPNAmplitude.getBinContent(getEcalDQMSetupObjects(), id));
184  float pRms(sPNAmplitude.getBinError(getEcalDQMSetupObjects(), id) * sqrt(pEntries));
185  float intensity(pMean / expectedPNAmplitude_[wlItr->second]);
186 
187  if (intensity < tolerancePNAmp_ || pRms > pMean * tolerancePNRMSRatio_)
188  mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
189  else
190  mePNQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
191  }
192  }
193  }
194  }
195 
197 } // namespace ecaldqm
static const int LED_MEAN_ERROR
unsigned memDCCIndex(unsigned)
T getUntrackedParameter(std::string const &, T const &) const
void setParams(edm::ParameterSet const &) override
Definition: LedClient.cc:30
void towerAverage_(MESet &, MESet const &, float)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:162
uint16_t *__restrict__ id
virtual double getBinContent(EcalDQMSetupObjects const, DetId const &, int=0) const
Definition: MESet.h:100
MESet & at(const std::string &key)
Definition: MESet.h:399
const_iterator & toNextChannel(EcalElectronicsMapping const *electronicsMap)
Definition: MESet.h:320
double toleranceAmplitude_
Definition: LedClient.h:21
double getBinContent(EcalDQMSetupObjects const edso, DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:111
bool isForward(DetId const &)
float forwardFactor_
Definition: LedClient.h:29
const_iterator beginChannel(EcalElectronicsMapping const *electronicsMap) const override
Definition: MESetMulti.h:168
std::map< int, unsigned > wlToME_
Definition: LedClient.h:17
void fill(EcalDQMSetupObjects const edso, DetId const &_id, double _xyw=1., double _yw=1., double _w=1.) override
Definition: MESetMulti.h:29
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:124
void use(unsigned) const
Definition: MESetMulti.cc:135
std::set< std::string > qualitySummaries_
std::vector< double > expectedTiming_
Definition: LedClient.h:23
T sqrt(T t)
Definition: SSEVec.h:19
StatusManager const * statusManager_
void setBinContent(EcalDQMSetupObjects const edso, DetId const &_id, double _content) override
Definition: MESetMulti.h:48
std::vector< double > expectedAmplitude_
Definition: LedClient.h:20
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > expectedPNAmplitude_
Definition: LedClient.h:26
static const int LED_TIMING_MEAN_ERROR
double toleranceAmpRMSRatio_
Definition: LedClient.h:22
MESetCollection sources_
double getBinError(EcalDQMSetupObjects const edso, DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:121
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:142
Definition: DetId.h:17
double getBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:131
static const int LED_TIMING_RMS_ERROR
MESetCollection MEs_
Definition: DQWorker.h:125
double toleranceTimRMS_
Definition: LedClient.h:25
double toleranceTiming_
Definition: LedClient.h:24
void producePlots(ProcessType) override
Definition: LedClient.cc:80
double tolerancePNAmp_
Definition: LedClient.h:27
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:118
static const int LED_RMS_ERROR
bool maskMatches(DetId const &_id, uint32_t _mask, StatusManager const *_statusManager, EcalTrigTowerConstituentsMap const *trigTowerMap) const override
Definition: MESetMulti.h:144
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:46
const_iterator end(EcalElectronicsMapping const *electronicsMap) const override
Definition: MESetMulti.h:165
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:142
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double tolerancePNRMSRatio_
Definition: LedClient.h:28