CMS 3D CMS Logo

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