CMS 3D CMS Logo

SummaryClient.cc
Go to the documentation of this file.
2 
4 
6 
8 
9 #include <algorithm>
10 
11 namespace ecaldqm {
12  SummaryClient::SummaryClient() : DQWorkerClient(), towerBadFraction_(0.), fedBadFraction_(0.) {
13  qualitySummaries_.insert("QualitySummary");
14  qualitySummaries_.insert("ReportSummaryMap");
15  qualitySummaries_.insert("ReportSummaryContents");
16  qualitySummaries_.insert("ReportSummary");
17  }
18 
20  towerBadFraction_ = _params.getUntrackedParameter<double>("towerBadFraction");
21  fedBadFraction_ = _params.getUntrackedParameter<double>("fedBadFraction");
22 
23  std::vector<std::string> sourceList(_params.getUntrackedParameter<std::vector<std::string> >("activeSources"));
24  if (std::find(sourceList.begin(), sourceList.end(), "Presample") == sourceList.end())
25  sources_.erase(std::string("Presample"));
26  if (std::find(sourceList.begin(), sourceList.end(), "Timing") == sourceList.end())
27  sources_.erase(std::string("Timing"));
28  if (std::find(sourceList.begin(), sourceList.end(), "TriggerPrimitives") == sourceList.end())
29  sources_.erase(std::string("TriggerPrimitives"));
30  if (std::find(sourceList.begin(), sourceList.end(), "HotCell") == sourceList.end())
31  sources_.erase(std::string("HotCell"));
32  }
33 
36 
37  MESet& meReportSummaryContents(MEs_.at("ReportSummaryContents"));
38  MESet& meReportSummary(MEs_.at("ReportSummary"));
39  MESet& meReportSummaryMap(MEs_.at("ReportSummaryMap"));
40 
41  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
42  int dccid(iDCC + 1);
43  meReportSummaryContents.fill(getEcalDQMSetupObjects(), dccid, -1.);
44  }
45 
46  meReportSummary.fill(getEcalDQMSetupObjects(), -1.);
47 
48  meReportSummaryMap.reset(GetElectronicsMap(), -1.);
49  }
50 
52  MESet& meReportSummaryContents(MEs_.at("ReportSummaryContents"));
53  MESet& meReportSummary(MEs_.at("ReportSummary"));
54 
55  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
56  int dccid(iDCC + 1);
57  meReportSummaryContents.fill(getEcalDQMSetupObjects(), dccid, -1.);
58  }
59  meReportSummary.fill(getEcalDQMSetupObjects(), -1.);
60 
61  MESet const& sIntegrityByLumi(sources_.at("IntegrityByLumi"));
62  MESet const& sDesyncByLumi(sources_.at("DesyncByLumi"));
63  MESet const& sFEByLumi(sources_.at("FEByLumi")); // Does NOT include FE=Disabled
64  MESet const& sFEStatusErrMapByLumi(sources_.at("FEStatusErrMapByLumi")); // Includes FE=Disabled
65 
66  double integrityByLumi[nDCC];
67  double rawDataByLumi[nDCC];
68  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
69  integrityByLumi[iDCC] = sIntegrityByLumi.getBinContent(getEcalDQMSetupObjects(), iDCC + 1);
70  rawDataByLumi[iDCC] = sDesyncByLumi.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) +
71  sFEByLumi.getBinContent(getEcalDQMSetupObjects(), iDCC + 1);
72  }
73 
74  MESet& meQualitySummary(MEs_.at("QualitySummary"));
75  MESet& meReportSummaryMap(MEs_.at("ReportSummaryMap"));
76 
77  MESet const* sIntegrity(using_("Integrity") ? &sources_.at("Integrity") : nullptr);
78  MESet const& sRawData(sources_.at("RawData"));
79  MESet const* sPresample(using_("Presample") ? &sources_.at("Presample") : nullptr);
80  MESet const* sTiming(using_("Timing") ? &sources_.at("Timing") : nullptr);
81  MESet const* sTriggerPrimitives(using_("TriggerPrimitives") ? &sources_.at("TriggerPrimitives") : nullptr);
82  MESet const* sHotCell(using_("HotCell") ? &sources_.at("HotCell") : nullptr);
83 
84  float totalChannels(0.);
85  float totalGood(0.), totalGoodRaw(0);
86 
87  double dccChannels[nDCC];
88  std::fill_n(dccChannels, nDCC, 0.);
89  double dccGood[nDCC], dccGoodRaw[nDCC];
90  std::fill_n(dccGood, nDCC, 0.);
91  std::fill_n(dccGoodRaw, nDCC, 0.);
92 
93  std::map<uint32_t, int> badChannelsCount;
94 
95  // Override IntegrityByLumi check if any Desync errors present
96  // Used to set an entire FED to BAD
97  MESet const& sBXSRP(sources_.at("BXSRP"));
98  MESet const& sBXTCC(sources_.at("BXTCC"));
99  std::vector<bool> hasMismatchDCC(nDCC, false);
100  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
101  if (sBXSRP.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50. ||
102  sBXTCC.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50.) // "any" = 50
103  hasMismatchDCC[iDCC] = true;
104  }
105 
106  // Get RawData mask
108 
109  MESet::iterator qEnd(meQualitySummary.end(GetElectronicsMap()));
110  for (MESet::iterator qItr(meQualitySummary.beginChannel(GetElectronicsMap())); qItr != qEnd;
112  DetId id(qItr->getId());
113  unsigned iDCC(dccId(id, GetElectronicsMap()) - 1);
114 
115  // Initialize individual Quality Summaries
116  // NOTE: These represent quality over *cumulative* statistics
117  int integrity(sIntegrity ? (int)sIntegrity->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
118  int presample(sPresample ? (int)sPresample->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
119  int hotcell(sHotCell ? (int)sHotCell->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
120  int timing(sTiming ? (int)sTiming->getBinContent(getEcalDQMSetupObjects(), id) : kUnknown);
121  int trigprim(sTriggerPrimitives ? (int)sTriggerPrimitives->getBinContent(getEcalDQMSetupObjects(), id)
122  : kUnknown);
123  int rawdata(sRawData.getBinContent(getEcalDQMSetupObjects(), id));
124 
125  double rawdataLS(sFEStatusErrMapByLumi.getBinContent(getEcalDQMSetupObjects(), id)); // Includes FE=Disabled
126 
127  // If there are no RawData or Integrity errors in this LS, set them back to GOOD
128  //if(integrity == kBad && integrityByLumi[iDCC] == 0.) integrity = kGood;
129  if (integrity == kBad && integrityByLumi[iDCC] == 0. && !hasMismatchDCC[iDCC])
130  integrity = kGood;
131  //if(rawdata == kBad && rawDataByLumi[iDCC] == 0.) rawdata = kGood;
132  if (rawdata == kBad && rawDataByLumi[iDCC] == 0. && rawdataLS == 0.)
133  rawdata = kGood;
134 
135  // Fill Global Quality Summary
136  int status(kGood);
137  if (integrity == kBad || presample == kBad || timing == kBad || rawdata == kBad || trigprim == kBad ||
138  hotcell == kBad)
139  status = kBad;
140  else if (integrity == kUnknown && presample == kUnknown && timing == kUnknown && rawdata == kUnknown &&
141  trigprim == kUnknown)
142  status = kUnknown;
143  // Skip channels with no/low integrity statistics (based on digi occupancy)
144  // Normally, ensures Global Quality and Report Summaries are not filled when stats are still low / channel masked / ECAL not in run
145  // However, problematic FEDs can sometimes drop hits so check that channel is not flagged as BAD elsewhere
146  if (status != kBad && (integrity == kUnknown || integrity == kMUnknown)) {
147  qItr->setBinContent(integrity);
148  if (onlineMode_)
149  continue;
150  }
151  qItr->setBinContent(status);
152 
153  // Keep running count of good/bad channels/towers: Uses cumulative stats.
154  if (status == kBad) {
155  if (id.subdetId() == EcalBarrel)
156  badChannelsCount[EBDetId(id).tower().rawId()] += 1;
157  if (id.subdetId() == EcalEndcap)
158  badChannelsCount[EEDetId(id).sc().rawId()] += 1;
159  } else {
160  dccGood[iDCC] += 1.;
161  totalGood += 1.;
162  }
163  dccChannels[iDCC] += 1.;
164  totalChannels += 1.;
165 
166  // Keep running count of good channels in RawData only: Uses LS stats only.
167  // LS-based reports only use RawData as input to save on having to run other workers
168  bool isMasked(meQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
169  if (rawdataLS == 0. || isMasked) { // channel != kBad in rawdata
170  dccGoodRaw[iDCC] += 1.;
171  totalGoodRaw += 1.;
172  }
173 
174  } // qItr channel loop
175 
176  // search clusters of bad towers
177  /*if(onlineMode_){
178 
179  // EB
180  for(int iz(-1); iz < 2; iz += 2){
181  for(int ieta(0); ieta < 17; ++ieta){
182  if(iz == 1 && ieta == 0) continue;
183  for(int iphi(1); iphi <= 72; ++iphi){
184  EcalTrigTowerDetId ttids[4];
185  unsigned badTowers(0);
186  for(int deta(0); deta < 2; ++deta){
187  int ttz(ieta == 0 && deta == 0 ? -1 : iz);
188  int tteta(ieta == 0 && deta == 0 ? 1 : ieta + deta);
189  for(int dphi(0); dphi < 2; ++dphi){
190  int ttphi(iphi != 72 ? iphi + dphi : 1);
191  EcalTrigTowerDetId ttid(ttz, EcalBarrel, tteta, ttphi);
192  ttids[deta * 2 + dphi] = ttid;
193 
194  if(badChannelsCount[ttid.rawId()] > towerBadFraction_ * 25.)
195  badTowers += 1;
196  } // dphi
197  } // deta
198  if(badTowers > 2){
199  for(unsigned iD(0); iD < 4; ++iD)
200  dccGood[dccId(ttids[iD]) - 1] = 0.;
201  }
202  } // iphi
203  } // ieta
204  } // iz
205 
206  // EE
207  for(int iz(-1); iz <= 1; iz += 2){
208  for(int ix(1); ix < 20; ++ix){
209  for(int iy(1); iy < 20; ++iy){
210  EcalScDetId scids[4];
211  unsigned badTowers(0);
212  for(int dx(0); dx < 2; ++dx){
213  for(int dy(0); dy < 2; ++dy){
214  if(!EcalScDetId::validDetId(ix + dx, iy + dy, iz)){
215  scids[dx * 2 + dy] = EcalScDetId(0);
216  continue;
217  }
218  EcalScDetId scid(ix + dx, iy + dy, iz);
219  scids[dx * 2 + dy] = scid;
220 
221  if(badChannelsCount[scid.rawId()] > towerBadFraction_ * scConstituents(scid).size())
222  badTowers += 1;
223  } // dy
224  } // dx
225  // contiguous towers bad -> [(00)(11)] [(11)(00)] [(01)(01)] [(10)(10)] []=>x ()=>y
226  if(badTowers > 2){
227  for(unsigned iD(0); iD < 4; ++iD){
228  EcalScDetId& scid(scids[iD]);
229  if(scid.null()) continue;
230  dccGood[dccId(scid) - 1] = 0.;
231  }
232  }
233  } // iy
234  } // ix
235  } // iz
236 
237  } // cluster search */
238 
239  // Fill Report Summaries
240  double nBad(0.);
241  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
242  if (dccChannels[iDCC] < 1.)
243  continue;
244 
245  int dccid(iDCC + 1);
246  float frac(dccGood[iDCC] / dccChannels[iDCC]);
247  float fracRaw(dccGoodRaw[iDCC] / dccChannels[iDCC]);
248  meReportSummaryMap.setBinContent(getEcalDQMSetupObjects(), dccid, frac);
249  float fracLS(onlineMode_ ? frac : fracRaw);
250  meReportSummaryContents.fill(getEcalDQMSetupObjects(), dccid, fracLS); // reported by LS
251 
252  if (1. - frac > fedBadFraction_)
253  nBad += 1.;
254  }
255 
256  float totalGoodLS(onlineMode_ ? totalGood : totalGoodRaw);
257  if (totalChannels > 0.)
258  meReportSummary.fill(getEcalDQMSetupObjects(), totalGoodLS / totalChannels); // reported by LS
259 
260  if (onlineMode_) {
261  if (totalChannels > 0.)
262  MEs_.at("GlobalSummary").setBinContent(getEcalDQMSetupObjects(), 1, totalGood / totalChannels);
263  MEs_.at("NBadFEDs").setBinContent(getEcalDQMSetupObjects(), 1, nBad);
264  }
265 
266  } // producePlots()
267 
269 } // namespace ecaldqm
virtual void setBinContent(EcalDQMSetupObjects const, DetId const &, double)
Definition: MESet.h:79
void setParams(edm::ParameterSet const &) override
#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
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static const int STATUS_FLAG_ERROR
void resetMEs() override
virtual double getBinContent(EcalDQMSetupObjects const, DetId const &, int=0) const
Definition: MESet.h:100
void producePlots(ProcessType) override
std::set< std::string > qualitySummaries_
bool using_(std::string const &_name, ProcessType _type=kJob) const
StatusManager const * statusManager_
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
MESetCollection sources_
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MESetCollection MEs_
Definition: DQWorker.h:131
EcalScDetId sc() const
Definition: EEDetId.h:89
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:155
void erase(const std::string &key)
Definition: MESet.h:390