CMS 3D CMS Logo

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