CMS 3D CMS Logo

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