CMS 3D CMS Logo

SiStripQualityHelpers.cc
Go to the documentation of this file.
5 
7 
10 
11 namespace {
12 
13  float getProcessedEvents(DQMStore::IGetter& dqmStore) {
14  dqmStore.cd();
15 
16  const std::string dname{"SiStrip/ReadoutView"};
17  const std::string hpath{dname + "/nTotalBadActiveChannels"};
18  if (dqmStore.dirExists(dname)) {
19  MonitorElement* me = dqmStore.get(hpath);
20  if (me)
21  return me->getEntries();
22  }
23  return 0;
24  }
25 
26  std::vector<std::pair<uint16_t, uint16_t>> getFedBadChannelList(DQMStore::IGetter& dqmStore,
27  const MonitorElement* me,
28  float cutoff) {
29  std::vector<std::pair<uint16_t, uint16_t>> ret;
30  if (me->kind() == MonitorElement::Kind::TH2F) {
31  TH2F* th2 = me->getTH2F();
32  float entries = getProcessedEvents(dqmStore);
33  if (!entries)
34  entries = th2->GetBinContent(th2->GetMaximumBin());
35  for (uint16_t i = 1; i < th2->GetNbinsY() + 1; ++i) {
36  for (uint16_t j = 1; j < th2->GetNbinsX() + 1; ++j) {
37  if (th2->GetBinContent(j, i) > cutoff * entries) {
38  edm::LogInfo("SiStripBadModuleFedErrService")
39  << " [SiStripBadModuleFedErrService::getFedBadChannelList] :: FedId & Channel "
40  << th2->GetYaxis()->GetBinLowEdge(i) << " " << th2->GetXaxis()->GetBinLowEdge(j);
41  ret.push_back(
42  std::pair<uint16_t, uint16_t>(th2->GetYaxis()->GetBinLowEdge(i), th2->GetXaxis()->GetBinLowEdge(j)));
43  }
44  }
45  }
46  }
47  return ret;
48  }
49 
50 } // namespace
51 
52 std::unique_ptr<SiStripQuality> sistrip::badStripFromFedErr(DQMStore::IGetter& dqmStore,
53  const SiStripFedCabling& fedCabling,
54  float cutoff) {
55  auto quality = std::make_unique<SiStripQuality>();
56  dqmStore.cd();
57  const std::string dname{"SiStrip/ReadoutView"};
58  const std::string hpath{dname + "/FedIdVsApvId"};
59  if (dqmStore.dirExists(dname)) {
60  MonitorElement* me = dqmStore.get(hpath);
61  if (me) {
62  std::map<uint32_t, std::set<int>> detectorMap;
63  for (const auto& elm : getFedBadChannelList(dqmStore, me, cutoff)) {
64  const uint16_t fId = elm.first;
65  const uint16_t fChan = elm.second / 2;
66  if ((fId == 9999) && (fChan == 9999))
67  continue;
68 
69  FedChannelConnection channel = fedCabling.fedConnection(fId, fChan);
70  detectorMap[channel.detId()].insert(channel.apvPairNumber());
71  }
72 
73  for (const auto& detElm : detectorMap) { // pair(detId, pairs)
74  SiStripQuality::InputVector theSiStripVector;
75  unsigned short firstBadStrip{0};
76  unsigned short fNconsecutiveBadStrips{0};
77  int last_pair = -1;
78  for (const auto pair : detElm.second) {
79  if (last_pair == -1) {
80  firstBadStrip = pair * 128 * 2;
81  fNconsecutiveBadStrips = 128 * 2;
82  } else if (pair - last_pair > 1) {
83  theSiStripVector.push_back(quality->encode(firstBadStrip, fNconsecutiveBadStrips));
84  firstBadStrip = pair * 128 * 2;
85  fNconsecutiveBadStrips = 128 * 2;
86  } else {
87  fNconsecutiveBadStrips += 128 * 2;
88  }
89  last_pair = pair;
90  }
91  unsigned int theBadStripRange = quality->encode(firstBadStrip, fNconsecutiveBadStrips);
92  theSiStripVector.push_back(theBadStripRange);
93 
94  edm::LogInfo("SiStripBadModuleFedErrService")
95  << " SiStripBadModuleFedErrService::readBadComponentsFromFed "
96  << " detid " << detElm.first << " firstBadStrip " << firstBadStrip << " NconsecutiveBadStrips "
97  << fNconsecutiveBadStrips << " packed integer " << std::hex << theBadStripRange << std::dec;
98 
99  if (!quality->put(detElm.first, SiStripBadStrip::Range{theSiStripVector.begin(), theSiStripVector.end()})) {
100  edm::LogError("SiStripBadModuleFedErrService")
101  << "[SiStripBadModuleFedErrService::readBadComponentsFromFed] detid already exists";
102  }
103  }
104  quality->cleanUp();
105  }
106  }
107  return quality;
108 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
sistrip::badStripFromFedErr
std::unique_ptr< SiStripQuality > badStripFromFedErr(dqm::harvesting::DQMStore::IGetter &dqmStore, const SiStripFedCabling &fedCabling, float cutoff)
Definition: SiStripQualityHelpers.cc:52
SiStripFedCabling.h
SiStripFedCabling::fedConnection
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
Definition: SiStripFedCabling.cc:171
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
dqm::harvesting::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: DQMStore.h:739
MonitorElementData::Kind::TH2F
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
L1TBPTX_cfi.dqmStore
dqmStore
Definition: L1TBPTX_cfi.py:6
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FedChannelConnection
Class containning control, module, detector and connection information, at the level of a FED channel...
Definition: FedChannelConnection.h:26
FedChannelConnection::detId
const uint32_t & detId() const
Definition: FedChannelConnection.h:213
SiStripBadStrip::InputVector
Container InputVector
Definition: SiStripBadStrip.h:56
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripQualityHelpers.h
EcalSCDynamicDPhiParametersESProducer_cfi.cutoff
cutoff
Definition: EcalSCDynamicDPhiParametersESProducer_cfi.py:15
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
dqm::implementation::IGetter
Definition: DQMStore.h:484
SiStripQuality.h
RefreshWebPage.dname
dname
Definition: RefreshWebPage.py:56
FedChannelConnection::apvPairNumber
uint16_t apvPairNumber() const
Definition: FedChannelConnection.h:230
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
dqm::harvesting::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: MonitorElement.h:516
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143