CMS 3D CMS Logo

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