CMS 3D CMS Logo

PedestalClient.cc
Go to the documentation of this file.
2 
5 
7 
9 
11 
12 #include <iomanip>
13 
14 namespace ecaldqm {
16  : DQWorkerClient(),
17  gainToME_(),
18  pnGainToME_(),
19  minChannelEntries_(0),
20  expectedMean_(0.),
21  toleranceMean_(0.),
22  toleranceRMSEB_(0),
23  toleranceRMSEE_(0),
24  expectedPNMean_(0.),
25  tolerancePNMean_(0.),
26  tolerancePNRMS_(0) {}
27 
29  minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
30  expectedMean_ = _params.getUntrackedParameter<double>("expectedMean");
31  toleranceMean_ = _params.getUntrackedParameter<double>("toleranceMean");
32  expectedPNMean_ = _params.getUntrackedParameter<double>("expectedPNMean");
33  tolerancePNMean_ = _params.getUntrackedParameter<double>("tolerancePNMean");
34 
35  std::vector<int> MGPAGains(_params.getUntrackedParameter<std::vector<int> >("MGPAGains"));
36  std::vector<int> MGPAGainsPN(_params.getUntrackedParameter<std::vector<int> >("MGPAGainsPN"));
37 
39 
40  MESetMulti const& pedestal(static_cast<MESetMulti const&>(sources_.at("Pedestal")));
41  unsigned nG(MGPAGains.size());
42  for (unsigned iG(0); iG != nG; ++iG) {
43  int gain(MGPAGains[iG]);
44  if (gain != 1 && gain != 6 && gain != 12)
45  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
46  repl["gain"] = std::to_string(gain);
47  gainToME_[gain] = pedestal.getIndex(repl);
48  }
49 
50  repl.clear();
51 
52  MESetMulti const& pnPedestal(static_cast<MESetMulti const&>(sources_.at("PNPedestal")));
53  unsigned nGPN(MGPAGainsPN.size());
54  for (unsigned iG(0); iG != nGPN; ++iG) {
55  int gain(MGPAGainsPN[iG]);
56  if (gain != 1 && gain != 16)
57  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
58  repl["pngain"] = std::to_string(gain);
59  pnGainToME_[gain] = pnPedestal.getIndex(repl);
60  }
61 
62  toleranceRMSEB_.resize(nG);
63  toleranceRMSEE_.resize(nG);
64 
65  std::vector<double> inToleranceRMSEB(_params.getUntrackedParameter<std::vector<double> >("toleranceRMSEB"));
66  std::vector<double> inToleranceRMSEE(_params.getUntrackedParameter<std::vector<double> >("toleranceRMSEE"));
67 
68  for (std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
69  unsigned iME(gainItr->second);
70  unsigned iGain(0);
71  switch (gainItr->first) {
72  case 1:
73  iGain = 0;
74  break;
75  case 6:
76  iGain = 1;
77  break;
78  case 12:
79  iGain = 2;
80  break;
81  }
82 
83  toleranceRMSEB_[iME] = inToleranceRMSEB[iGain];
84  toleranceRMSEE_[iME] = inToleranceRMSEE[iGain];
85  }
86 
87  tolerancePNRMS_.resize(nGPN);
88 
89  std::vector<double> inTolerancePNRMS(_params.getUntrackedParameter<std::vector<double> >("tolerancePNRMS"));
90 
91  for (std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
92  unsigned iME(gainItr->second);
93  unsigned iGain(0);
94  switch (gainItr->first) {
95  case 1:
96  iGain = 0;
97  break;
98  case 16:
99  iGain = 1;
100  break;
101  }
102 
103  tolerancePNRMS_[iME] = inTolerancePNRMS[iGain];
104  }
105 
106  qualitySummaries_.insert("Quality");
107  qualitySummaries_.insert("QualitySummary");
108  qualitySummaries_.insert("PNQualitySummary");
109  }
110 
112  using namespace std;
113 
114  MESetMulti& meQuality(static_cast<MESetMulti&>(MEs_.at("Quality")));
115  MESetMulti& meQualitySummary(static_cast<MESetMulti&>(MEs_.at("QualitySummary")));
116  MESetMulti& meMean(static_cast<MESetMulti&>(MEs_.at("Mean")));
117  MESetMulti& meRMS(static_cast<MESetMulti&>(MEs_.at("RMS")));
118  MESetMulti& mePNQualitySummary(static_cast<MESetMulti&>(MEs_.at("PNQualitySummary")));
119  MESetMulti& mePNRMS(static_cast<MESetMulti&>(MEs_.at("PNRMS")));
120 
121  MESetMulti const& sPedestal(static_cast<MESetMulti const&>(sources_.at("Pedestal")));
122  MESetMulti const& sPNPedestal(static_cast<MESetMulti const&>(sources_.at("PNPedestal")));
123 
124  for (map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
125  meQuality.use(gainItr->second);
126  meQualitySummary.use(gainItr->second);
127  meMean.use(gainItr->second);
128  meRMS.use(gainItr->second);
129 
130  sPedestal.use(gainItr->second);
131 
132  uint32_t mask(0);
133  switch (gainItr->first) {
134  case 1:
137  break;
138  case 6:
141  break;
142  case 12:
145  break;
146  default:
147  break;
148  }
149 
150  MESet::iterator qEnd(meQuality.end());
151  MESet::const_iterator pItr(sPedestal);
152  for (MESet::iterator qItr(meQuality.beginChannel()); qItr != qEnd; qItr.toNextChannel()) {
153  DetId id(qItr->getId());
154 
155  bool doMask(meQuality.maskMatches(id, mask, statusManager_));
156 
157  pItr = qItr;
158 
159  float entries(pItr->getBinEntries());
160 
161  if (entries < minChannelEntries_) {
162  qItr->setBinContent(doMask ? kMUnknown : kUnknown);
163  continue;
164  }
165 
166  float mean(pItr->getBinContent());
167  float rms(pItr->getBinError() * sqrt(entries));
168 
169  meMean.fill(id, mean);
170  meRMS.fill(id, rms);
171 
172  float toleranceRMS_ =
173  (id.subdetId() == EcalBarrel) ? toleranceRMSEB_[gainItr->second] : toleranceRMSEE_[gainItr->second];
174 
175  if (abs(mean - expectedMean_) > toleranceMean_ || rms > toleranceRMS_)
176  qItr->setBinContent(doMask ? kMBad : kBad);
177  else
178  qItr->setBinContent(doMask ? kMGood : kGood);
179  }
180 
181  towerAverage_(meQualitySummary, meQuality, 0.2);
182  }
183 
184  for (map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
185  mePNQualitySummary.use(gainItr->second);
186  mePNRMS.use(gainItr->second);
187 
188  sPNPedestal.use(gainItr->second);
189 
190  uint32_t mask(0);
191  switch (gainItr->first) {
192  case 1:
195  break;
196  case 16:
199  break;
200  default:
201  break;
202  }
203 
204  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
205  if (memDCCIndex(iDCC + 1) == unsigned(-1))
206  continue;
207 
208  for (unsigned iPN(0); iPN < 10; ++iPN) {
209  int subdet(0);
210  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
211  subdet = EcalBarrel;
212  else
213  subdet = EcalEndcap;
214 
215  EcalPnDiodeDetId id(subdet, iDCC + 1, iPN + 1);
216 
217  bool doMask(mePNQualitySummary.maskMatches(id, mask, statusManager_));
218 
219  float entries(sPNPedestal.getBinEntries(id));
220 
221  if (entries < minChannelEntries_) {
222  mePNQualitySummary.setBinContent(id, doMask ? kMUnknown : kUnknown);
223  continue;
224  }
225 
226  float mean(sPNPedestal.getBinContent(id));
227  float rms(sPNPedestal.getBinError(id) * sqrt(entries));
228 
229  mePNRMS.fill(id, rms);
230 
231  if (abs(mean - expectedPNMean_) > tolerancePNMean_ || rms > tolerancePNRMS_[gainItr->second])
232  mePNQualitySummary.setBinContent(id, doMask ? kMBad : kBad);
233  else
234  mePNQualitySummary.setBinContent(id, doMask ? kMGood : kGood);
235  }
236  }
237  }
238  }
239 
241 } // namespace ecaldqm
ecaldqm::MESetMulti::fill
void fill(DetId const &_id, double _xyw=1., double _yw=1., double _w=1.) override
Definition: MESetMulti.h:29
ecaldqm::PedestalClient
Definition: PedestalClient.h:7
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
ecaldqm
Definition: DQWorker.h:24
ecaldqm::PedestalClient::gainToME_
std::map< int, unsigned > gainToME_
Definition: PedestalClient.h:17
ecaldqm::PedestalClient::expectedMean_
float expectedMean_
Definition: PedestalClient.h:21
ecaldqm::MESetMulti::end
const_iterator end() const override
Definition: MESetMulti.h:122
ecaldqm::PedestalClient::toleranceMean_
float toleranceMean_
Definition: PedestalClient.h:22
ecaldqm::PedestalClient::producePlots
void producePlots(ProcessType) override
Definition: PedestalClient.cc:111
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
ecaldqm::PedestalClient::tolerancePNMean_
float tolerancePNMean_
Definition: PedestalClient.h:26
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
ecaldqm::MESetMulti::use
void use(unsigned) const
Definition: MESetMulti.cc:130
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
EcalBarrel
Definition: EcalSubdetector.h:10
EcalDQMStatusHelper.h
ecaldqm::PedestalClient::pnGainToME_
std::map< int, unsigned > pnGainToME_
Definition: PedestalClient.h:18
ecaldqm::PedestalClient::toleranceRMSEE_
std::vector< float > toleranceRMSEE_
Definition: PedestalClient.h:24
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::PedestalClient::tolerancePNRMS_
std::vector< float > tolerancePNRMS_
Definition: PedestalClient.h:27
PedestalClient_cfi.MGPAGainsPN
MGPAGainsPN
Definition: PedestalClient_cfi.py:27
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::MESetMulti::getIndex
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:137
PedestalClient.h
ecaldqm::MESet::iterator::toNextChannel
const_iterator & toNextChannel()
Definition: MESet.h:289
ecaldqm::kEBpHigh
Definition: EcalDQMCommonUtils.h:88
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:78
ecaldqm::DQWorkerClient::kMBad
Definition: DQWorkerClient.h:37
EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR
static const int PEDESTAL_LOW_GAIN_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:17
EcalEndcap
Definition: EcalSubdetector.h:10
ecaldqm::DQWorkerClient::kUnknown
Definition: DQWorkerClient.h:37
ecaldqm::DQWorkerClient::kBad
Definition: DQWorkerClient.h:37
EcalPnDiodeDetId.h
ecaldqm::DQWorkerClient::sources_
MESetCollection sources_
Definition: DQWorkerClient.h:55
ecaldqm::DQWorkerClient::kMGood
Definition: DQWorkerClient.h:37
EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_RMS_ERROR
static const int PEDESTAL_HIGH_GAIN_RMS_ERROR
Definition: EcalDQMStatusHelper.h:22
ecaldqm::MESetMulti::getBinEntries
double getBinEntries(DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:95
edm::ParameterSet
Definition: ParameterSet.h:47
ecaldqm::MESetMulti
Definition: MESetMulti.h:13
ecaldqm::MESetCollection::at
MESet & at(const std::string &key)
Definition: MESet.h:362
ecaldqm::MESet::iterator
Definition: MESet.h:268
ecaldqm::DQWorkerClient::kMUnknown
Definition: DQWorkerClient.h:37
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
PedestalClient_cfi.MGPAGains
MGPAGains
Definition: PedestalClient_cfi.py:26
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
ecaldqm::DQWorkerClient
Definition: DQWorkerClient.h:13
EcalDQMStatusHelper::PEDESTAL_MIDDLE_GAIN_MEAN_ERROR
static const int PEDESTAL_MIDDLE_GAIN_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:18
EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR
static const int PEDESTAL_HIGH_GAIN_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:19
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
ecaldqm::PedestalClient::PedestalClient
PedestalClient()
Definition: PedestalClient.cc:15
std
Definition: JetResolutionObject.h:76
ecaldqm::MESetMulti::setBinContent
void setBinContent(DetId const &_id, double _content) override
Definition: MESetMulti.h:40
ecaldqm::MESet::const_iterator
Definition: MESet.h:245
EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_RMS_ERROR
static const int PEDESTAL_LOW_GAIN_RMS_ERROR
Definition: EcalDQMStatusHelper.h:20
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::PedestalClient::minChannelEntries_
int minChannelEntries_
Definition: PedestalClient.h:20
MESetMulti.h
ecaldqm::PedestalClient::toleranceRMSEB_
std::vector< float > toleranceRMSEB_
Definition: PedestalClient.h:23
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:92
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
EcalDQMStatusHelper::PEDESTAL_MIDDLE_GAIN_RMS_ERROR
static const int PEDESTAL_MIDDLE_GAIN_RMS_ERROR
Definition: EcalDQMStatusHelper.h:21
ecaldqm::PedestalClient::expectedPNMean_
float expectedPNMean_
Definition: PedestalClient.h:25
EcalDQMCommonUtils.h
ecaldqm::PedestalClient::setParams
void setParams(edm::ParameterSet const &) override
Definition: PedestalClient.cc:28