CMS 3D CMS Logo

IntegrityClient.cc
Go to the documentation of this file.
2 
4 
6 
9 
12 
13 namespace ecaldqm {
14  IntegrityClient::IntegrityClient() : DQWorkerClient(), errFractionThreshold_(0.), processedEvents(0) {
15  qualitySummaries_.insert("Quality");
16  qualitySummaries_.insert("QualitySummary");
17  }
18 
20  errFractionThreshold_ = _params.getUntrackedParameter<double>("errFractionThreshold");
21  }
22 
25  }
26 
27  // Check Channel Status Record at every endLumi
28  // Used to fill Channel Status Map MEs
31  }
32 
37 
38  MESet& meQuality(MEs_.at("Quality"));
39  MESet& meQualitySummary(MEs_.at("QualitySummary"));
40  MESet& meChStatus(MEs_.at("ChStatus"));
41 
42  MESet const& sOccupancy(sources_.at("Occupancy"));
43  MESet const& sGain(sources_.at("Gain"));
44  MESet const& sChId(sources_.at("ChId"));
45  MESet const& sGainSwitch(sources_.at("GainSwitch"));
46  MESet const& sTowerId(sources_.at("TowerId"));
47  MESet const& sBlockSize(sources_.at("BlockSize"));
48  MESetNonObject const& sNumEvents(static_cast<MESetNonObject&>(sources_.at("NumEvents")));
49 
50  //Get the no.of events per LS calculated in OccupancyTask
51  int nEv = sNumEvents.getFloatValue();
52  processedEvents += nEv; //Sum it up to get the total processed events for the whole run.
53 
54  //TTID errors nomalized by total no.of events in a run.
55  MESet& meTTIDNorm(MEs_.at("TowerIdNormalized"));
56  MESet::iterator tEnd(meTTIDNorm.end(GetElectronicsMap()));
57  for (MESet::iterator tItr(meTTIDNorm.beginChannel(GetElectronicsMap())); tItr != tEnd;
59  DetId id(tItr->getId());
60  float towerid(sTowerId.getBinContent(getEcalDQMSetupObjects(), id));
61  tItr->setBinContent(towerid / processedEvents);
62  }
63  // Fill Channel Status Map MEs
64  // Record is checked for updates at every endLumi and filled here
65  MESet::iterator chSEnd(meChStatus.end(GetElectronicsMap()));
66  for (MESet::iterator chSItr(meChStatus.beginChannel(GetElectronicsMap())); chSItr != chSEnd;
67  chSItr.toNextChannel(GetElectronicsMap())) {
68  DetId id(chSItr->getId());
69 
71 
72  // Set appropriate channel map (EB or EE)
73  if (id.subdetId() == EcalBarrel) {
74  EBDetId ebid(id);
75  chIt = chStatus->find(ebid);
76  } else {
77  EEDetId eeid(id);
78  chIt = chStatus->find(eeid);
79  }
80 
81  // Get status code and fill ME
82  if (chIt != chStatus->end()) {
83  uint16_t code(chIt->getEncodedStatusCode());
84  chSItr->setBinContent(code);
85  }
86 
87  } // Channel Status Map
88 
89  MESet::iterator qEnd(meQuality.end(GetElectronicsMap()));
90  MESet::const_iterator occItr(GetElectronicsMap(), sOccupancy);
91  for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
93  occItr = qItr;
94 
95  DetId id(qItr->getId());
96 
97  bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
98 
99  float entries(occItr->getBinContent());
100 
101  float gain(sGain.getBinContent(getEcalDQMSetupObjects(), id));
102  float chid(sChId.getBinContent(getEcalDQMSetupObjects(), id));
103  float gainswitch(sGainSwitch.getBinContent(getEcalDQMSetupObjects(), id));
104 
105  float towerid(sTowerId.getBinContent(getEcalDQMSetupObjects(), id));
106  float blocksize(sBlockSize.getBinContent(getEcalDQMSetupObjects(), id));
107 
108  if (entries + gain + chid + gainswitch + towerid + blocksize < 1.) {
109  qItr->setBinContent(doMask ? kMUnknown : kUnknown);
110  meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
111  continue;
112  }
113 
114  float chErr((gain + chid + gainswitch + towerid + blocksize) /
115  (entries + gain + chid + gainswitch + towerid + blocksize));
116 
117  if (chErr > errFractionThreshold_) {
118  qItr->setBinContent(doMask ? kMBad : kBad);
119  meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
120  } else {
121  qItr->setBinContent(doMask ? kMGood : kGood);
122  meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
123  }
124  }
125 
126  // Quality check: set an entire FED to BAD if "any" DCC-SRP or DCC-TCC mismatch errors are detected
127  // Fill mismatch statistics
128  MESet const& sBXSRP(sources_.at("BXSRP"));
129  MESet const& sBXTCC(sources_.at("BXTCC"));
130  std::vector<bool> hasMismatchDCC(nDCC, false);
131  for (unsigned iDCC(0); iDCC < nDCC; ++iDCC) {
132  if (sBXSRP.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50. ||
133  sBXTCC.getBinContent(getEcalDQMSetupObjects(), iDCC + 1) > 50.) // "any" => 50
134  hasMismatchDCC[iDCC] = true;
135  }
136  // Analyze mismatch statistics
137  for (MESet::iterator qsItr(meQualitySummary.beginChannel(GetElectronicsMap()));
138  qsItr != meQualitySummary.end(GetElectronicsMap());
139  qsItr.toNextChannel(GetElectronicsMap())) {
140  DetId id(qsItr->getId());
141  unsigned iDCC(dccId(id, GetElectronicsMap()) - 1);
142  if (hasMismatchDCC[iDCC])
143  meQualitySummary.setBinContent(
145  id,
146  meQualitySummary.maskMatches(id, mask, statusManager_, GetTrigTowerMap()) ? kMBad : kBad);
147  }
148 
149  } // producePlots()
150 
152 } // namespace ecaldqm
edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > chStatusToken
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
void producePlots(ProcessType) override
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
MESet & at(const std::string &key)
Definition: MESet.h:399
static constexpr int kGood
const_iterator & toNextChannel(EcalElectronicsMapping const *electronicsMap)
Definition: MESet.h:320
static constexpr int kMUnknown
static const int TT_SIZE_ERROR
static const int CH_GAIN_SWITCH_ERROR
void setParams(edm::ParameterSet const &) override
static constexpr int kUnknown
static constexpr int kMBad
std::set< std::string > qualitySummaries_
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void setTokens(edm::ConsumesCollector &) override
StatusManager const * statusManager_
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
static constexpr int kBad
const_iterator find(uint32_t rawId) const
MESetCollection sources_
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
static constexpr int nDCC
const EcalChannelStatus * chStatus
static const int CH_GAIN_ZERO_ERROR
std::vector< Item >::const_iterator const_iterator
MESetCollection MEs_
Definition: DQWorker.h:131
static const int TT_ID_ERROR
static constexpr int kMGood
const_iterator end() const
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:155
static const int CH_ID_ERROR