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