CMS 3D CMS Logo

TestPulseClient.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  amplitudeThreshold_(0),
21  toleranceRMS_(0),
22  PNAmplitudeThreshold_(0),
23  tolerancePNRMS_(0) {}
24 
26  minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
27 
28  std::vector<int> MGPAGains(_params.getUntrackedParameter<std::vector<int> >("MGPAGains"));
29  std::vector<int> MGPAGainsPN(_params.getUntrackedParameter<std::vector<int> >("MGPAGainsPN"));
30 
32 
33  MESetMulti const& amplitude(static_cast<MESetMulti const&>(sources_.at("Amplitude")));
34  unsigned nG(MGPAGains.size());
35  for (unsigned iG(0); iG != nG; ++iG) {
36  int gain(MGPAGains[iG]);
37  if (gain != 1 && gain != 6 && gain != 12)
38  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
39  repl["gain"] = std::to_string(gain);
40  gainToME_[gain] = amplitude.getIndex(repl);
41  }
42 
43  repl.clear();
44 
45  MESetMulti const& pnAmplitude(static_cast<MESetMulti const&>(sources_.at("PNAmplitude")));
46  unsigned nGPN(MGPAGainsPN.size());
47  for (unsigned iG(0); iG != nGPN; ++iG) {
48  int gain(MGPAGainsPN[iG]);
49  if (gain != 1 && gain != 16)
50  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
51  repl["pngain"] = std::to_string(gain);
52  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
53  }
54 
55  amplitudeThreshold_.resize(nG);
56  toleranceRMS_.resize(nG);
57 
58  std::vector<double> inAmplitudeThreshold(_params.getUntrackedParameter<std::vector<double> >("amplitudeThreshold"));
59  std::vector<double> inToleranceRMS(_params.getUntrackedParameter<std::vector<double> >("toleranceRMS"));
60 
61  for (std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
62  unsigned iME(gainItr->second);
63  unsigned iGain(0);
64  switch (gainItr->first) {
65  case 1:
66  iGain = 0;
67  break;
68  case 6:
69  iGain = 1;
70  break;
71  case 12:
72  iGain = 2;
73  break;
74  }
75 
76  amplitudeThreshold_[iME] = inAmplitudeThreshold[iGain];
77  toleranceRMS_[iME] = inToleranceRMS[iGain];
78  }
79 
80  PNAmplitudeThreshold_.resize(nGPN);
81  tolerancePNRMS_.resize(nGPN);
82 
83  std::vector<double> inPNAmplitudeThreshold(
84  _params.getUntrackedParameter<std::vector<double> >("PNAmplitudeThreshold"));
85  std::vector<double> inTolerancePNRMS(_params.getUntrackedParameter<std::vector<double> >("tolerancePNRMS"));
86 
87  for (std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
88  unsigned iME(gainItr->second);
89  unsigned iGain(0);
90  switch (gainItr->first) {
91  case 1:
92  iGain = 0;
93  break;
94  case 16:
95  iGain = 1;
96  break;
97  }
98 
99  PNAmplitudeThreshold_[iME] = inPNAmplitudeThreshold[iGain];
100  tolerancePNRMS_[iME] = inTolerancePNRMS[iGain];
101  }
102 
103  qualitySummaries_.insert("Quality");
104  qualitySummaries_.insert("QualitySummary");
105  qualitySummaries_.insert("PNQualitySummary");
106  }
107 
109  using namespace std;
110 
111  MESetMulti& meQuality(static_cast<MESetMulti&>(MEs_.at("Quality")));
112  MESetMulti& meAmplitudeRMS(static_cast<MESetMulti&>(MEs_.at("AmplitudeRMS")));
113  MESetMulti& meQualitySummary(static_cast<MESetMulti&>(MEs_.at("QualitySummary")));
114  MESetMulti& mePNQualitySummary(static_cast<MESetMulti&>(MEs_.at("PNQualitySummary")));
115 
116  MESetMulti const& sAmplitude(static_cast<MESetMulti const&>(sources_.at("Amplitude")));
117  MESetMulti const& sPNAmplitude(static_cast<MESetMulti const&>(sources_.at("PNAmplitude")));
118 
119  for (map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
120  meQuality.use(gainItr->second);
121  meQualitySummary.use(gainItr->second);
122  meAmplitudeRMS.use(gainItr->second);
123 
124  sAmplitude.use(gainItr->second);
125 
126  uint32_t mask(0);
127  switch (gainItr->first) {
128  case 1:
131  break;
132  case 6:
135  break;
136  case 12:
139  break;
140  default:
141  break;
142  }
143 
144  MESet::iterator qEnd(meQuality.end());
145  MESet::iterator rItr(meAmplitudeRMS);
146  MESet::const_iterator aItr(sAmplitude);
147  for (MESet::iterator qItr(meQuality.beginChannel()); qItr != qEnd; qItr.toNextChannel()) {
148  DetId id(qItr->getId());
149 
150  bool doMask(meQuality.maskMatches(id, mask, statusManager_));
151 
152  aItr = qItr;
153  rItr = qItr;
154 
155  float entries(aItr->getBinEntries());
156 
157  if (entries < minChannelEntries_) {
158  qItr->setBinContent(doMask ? kMUnknown : kUnknown);
159  continue;
160  }
161 
162  float amp(aItr->getBinContent());
163  float rms(aItr->getBinError() * sqrt(entries));
164 
165  rItr->setBinContent(rms);
166 
167  if (amp < amplitudeThreshold_[gainItr->second] || rms > toleranceRMS_[gainItr->second])
168  qItr->setBinContent(doMask ? kMBad : kBad);
169  else
170  qItr->setBinContent(doMask ? kMGood : kGood);
171  }
172 
173  towerAverage_(meQualitySummary, meQuality, 0.2);
174  }
175 
176  for (map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
177  mePNQualitySummary.use(gainItr->second);
178 
179  sPNAmplitude.use(gainItr->second);
180 
181  uint32_t mask(0);
182  switch (gainItr->first) {
183  case 1:
186  break;
187  case 16:
190  break;
191  default:
192  break;
193  }
194 
195  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
196  if (memDCCIndex(iDCC + 1) == unsigned(-1))
197  continue;
198 
199  for (unsigned iPN(0); iPN < 10; ++iPN) {
200  int subdet(0);
201  if (iDCC >= kEBmLow && iDCC <= kEBpHigh)
202  subdet = EcalBarrel;
203  else
204  subdet = EcalEndcap;
205 
206  EcalPnDiodeDetId id(subdet, iDCC + 1, iPN + 1);
207 
208  bool doMask(mePNQualitySummary.maskMatches(id, mask, statusManager_));
209 
210  float amp(sPNAmplitude.getBinContent(id));
211  float entries(sPNAmplitude.getBinEntries(id));
212  float rms(sPNAmplitude.getBinError(id) * sqrt(entries));
213 
214  if (entries < minChannelEntries_) {
215  mePNQualitySummary.setBinContent(id, doMask ? kMUnknown : kUnknown);
216  continue;
217  }
218 
219  if (amp < PNAmplitudeThreshold_[gainItr->second] || rms > tolerancePNRMS_[gainItr->second])
220  mePNQualitySummary.setBinContent(id, doMask ? kMBad : kBad);
221  else
222  mePNQualitySummary.setBinContent(id, doMask ? kMGood : kGood);
223  }
224  }
225  }
226  }
227 
229 } // namespace ecaldqm
ecaldqm::TestPulseClient::minChannelEntries_
int minChannelEntries_
Definition: TestPulseClient.h:20
ecaldqm::TestPulseClient::tolerancePNRMS_
std::vector< float > tolerancePNRMS_
Definition: TestPulseClient.h:24
CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
ecaldqm
Definition: DQWorker.h:24
ecaldqm::TestPulseClient::toleranceRMS_
std::vector< float > toleranceRMS_
Definition: TestPulseClient.h:22
ecaldqm::MESetMulti::end
const_iterator end() const override
Definition: MESetMulti.h:122
EcalDQMStatusHelper::TESTPULSE_LOW_GAIN_RMS_ERROR
static const int TESTPULSE_LOW_GAIN_RMS_ERROR
Definition: EcalDQMStatusHelper.h:30
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::TestPulseClient::TestPulseClient
TestPulseClient()
Definition: TestPulseClient.cc:15
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
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
ecaldqm::TestPulseClient::producePlots
void producePlots(ProcessType) override
Definition: TestPulseClient.cc:108
ecaldqm::MESetMulti::use
void use(unsigned) const
Definition: MESetMulti.cc:130
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
EcalBarrel
Definition: EcalSubdetector.h:10
EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR
static const int TESTPULSE_HIGH_GAIN_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:29
EcalDQMStatusHelper.h
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
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
EcalDQMStatusHelper::TESTPULSE_MIDDLE_GAIN_RMS_ERROR
static const int TESTPULSE_MIDDLE_GAIN_RMS_ERROR
Definition: EcalDQMStatusHelper.h:31
ecaldqm::DQWorkerClient::ProcessType
ProcessType
Definition: DQWorkerClient.h:15
ecaldqm::MESetMulti::getIndex
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:137
ecaldqm::TestPulseClient::amplitudeThreshold_
std::vector< float > amplitudeThreshold_
Definition: TestPulseClient.h:21
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
EcalEndcap
Definition: EcalSubdetector.h:10
ecaldqm::DQWorkerClient::kUnknown
Definition: DQWorkerClient.h:37
ecaldqm::DQWorkerClient::kBad
Definition: DQWorkerClient.h:37
EcalPnDiodeDetId.h
EcalDQMStatusHelper::TESTPULSE_MIDDLE_GAIN_MEAN_ERROR
static const int TESTPULSE_MIDDLE_GAIN_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:28
ecaldqm::DQWorkerClient::sources_
MESetCollection sources_
Definition: DQWorkerClient.h:55
ecaldqm::DQWorkerClient::kMGood
Definition: DQWorkerClient.h:37
ecaldqm::MESetMulti::getBinEntries
double getBinEntries(DetId const &_id, int _bin=0) const override
Definition: MESetMulti.h:95
edm::ParameterSet
Definition: ParameterSet.h:36
ecaldqm::TestPulseClient
Definition: TestPulseClient.h:7
ecaldqm::TestPulseClient::gainToME_
std::map< int, unsigned > gainToME_
Definition: TestPulseClient.h:17
ecaldqm::MESetMulti
Definition: MESetMulti.h:13
ecaldqm::MESet::iterator
Definition: MESet.h:268
ecaldqm::DQWorkerClient::kMUnknown
Definition: DQWorkerClient.h:37
EcalDQMStatusHelper::TESTPULSE_LOW_GAIN_MEAN_ERROR
static const int TESTPULSE_LOW_GAIN_MEAN_ERROR
Definition: EcalDQMStatusHelper.h:27
ecaldqm::MESetMulti::maskMatches
bool maskMatches(DetId const &_id, uint32_t _mask, StatusManager const *_statusManager) const override
Definition: MESetMulti.h:106
ecaldqm::TestPulseClient::PNAmplitudeThreshold_
std::vector< float > PNAmplitudeThreshold_
Definition: TestPulseClient.h:23
ecaldqm::kEBmLow
Definition: EcalDQMCommonUtils.h:85
PedestalClient_cfi.MGPAGains
MGPAGains
Definition: PedestalClient_cfi.py:26
ecaldqm::DQWorkerClient
Definition: DQWorkerClient.h:13
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
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
ecaldqm::TestPulseClient::pnGainToME_
std::map< int, unsigned > pnGainToME_
Definition: TestPulseClient.h:18
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
TestPulseClient.h
ecaldqm::TestPulseClient::setParams
void setParams(edm::ParameterSet const &) override
Definition: TestPulseClient.cc:25
MESetMulti.h
EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_RMS_ERROR
static const int TESTPULSE_HIGH_GAIN_RMS_ERROR
Definition: EcalDQMStatusHelper.h:32
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:92
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:112
ParameterSet.h
EcalDQMCommonUtils.h