14 void fillFedBadChannelMap(
const TH2F* th2,
18 std::map<uint32_t, std::set<int>>& detectorMap) {
19 for (uint16_t
i = 1;
i < th2->GetNbinsY() + 1; ++
i) {
20 for (uint16_t
j = 1;
j < th2->GetNbinsX() + 1; ++
j) {
21 if (th2->GetBinContent(
j,
i) >
cutoff * entries) {
22 const uint16_t fId = th2->GetYaxis()->GetBinLowEdge(
i);
24 <<
" [SiStripBadModuleFedErrService::getFedBadChannelList] :: FedId & Channel " << fId <<
" "
25 << th2->GetXaxis()->GetBinLowEdge(
j);
26 const uint16_t fChan = uint16_t(th2->GetXaxis()->GetBinLowEdge(
j)) / 2;
27 if (!((fId == 9999) && (fChan == 9999))) {
29 detectorMap[channel.detId()].insert(channel.apvPairNumber());
43 return me->getEntries();
51 std::map<uint32_t, std::set<int>> detectorMap;
58 TH2F* th2 =
me->getTH2F();
59 float entries = getProcessedEvents(
dqmStore);
61 edm::LogWarning(
"SiStripBadModuleFedErrService") <<
"Normalising to the largest bin";
62 entries = th2->GetBinContent(th2->GetMaximumBin());
64 fillFedBadChannelMap(th2, entries,
cutoff, fedCabling, detectorMap);
66 edm::LogError(
"SiStripBadModuleFedErrService") <<
"Could not find SiStrip/ReadoutView/FedIdVsApvId";
69 edm::LogError(
"SiStripBadModuleFedErrService") <<
"Could not find SiStrip/ReadoutView";
74 TDirectoryFile* checkAndGetSubdir(TDirectoryFile* tdir,
const std::vector<std::string>&
path) {
75 for (
const auto& subName :
path) {
76 tdir = tdir->Get<TDirectoryFile>(subName.c_str());
84 std::map<uint32_t, std::set<int>> getBadChannelDetectorMap(TFile* legacyDQMTDirFile,
88 std::map<uint32_t, std::set<int>> detectorMap;
89 const auto stripROVDir = checkAndGetSubdir(
90 legacyDQMTDirFile, {
"DQMData",
"Run " + std::to_string(
runNumber),
"SiStrip",
"Run summary",
"ReadoutView"});
93 <<
"Could not find SiStrip/ReadoutView directory in " << legacyDQMTDirFile->GetName() <<
" with run number "
96 const auto th2 = stripROVDir->Get<TH2F>(
"FedIdVsApvId");
99 <<
"Could not find SiStrip/ReadoutView/FedIdVsApvId in " << legacyDQMTDirFile->GetName();
102 const auto nActChan = stripROVDir->Get<TH1F>(
"nTotalBadActiveChannels");
104 entries = nActChan->GetEntries();
107 edm::LogWarning(
"SiStripBadModuleFedErrService") <<
"Normalising to the largest bin";
108 entries = th2->GetBinContent(th2->GetMaximumBin());
110 fillFedBadChannelMap(th2, entries,
cutoff, fedCabling, detectorMap);
117 for (
const auto& detElm : detectorMap) {
119 unsigned short firstBadStrip{0};
120 unsigned short fNconsecutiveBadStrips{0};
122 for (
const auto pair : detElm.second) {
123 if (last_pair == -1) {
124 firstBadStrip = pair * 128 * 2;
125 fNconsecutiveBadStrips = 128 * 2;
126 }
else if (pair - last_pair > 1) {
127 theSiStripVector.push_back(
quality->encode(firstBadStrip, fNconsecutiveBadStrips));
128 firstBadStrip = pair * 128 * 2;
129 fNconsecutiveBadStrips = 128 * 2;
131 fNconsecutiveBadStrips += 128 * 2;
135 unsigned int theBadStripRange =
quality->encode(firstBadStrip, fNconsecutiveBadStrips);
136 theSiStripVector.push_back(theBadStripRange);
139 <<
" SiStripBadModuleFedErrService::readBadComponentsFromFed "
140 <<
" detid " << detElm.first <<
" firstBadStrip " << firstBadStrip <<
" NconsecutiveBadStrips "
141 << fNconsecutiveBadStrips <<
" packed integer " << std::hex << theBadStripRange <<
std::dec;
145 <<
"[SiStripBadModuleFedErrService::readBadComponentsFromFed] detid already exists";
157 auto quality = std::make_unique<SiStripQuality>(detInfo);
158 auto detectorMap = getBadChannelDetectorMap(
dqmStore, fedCabling,
cutoff);
159 if (!detectorMap.empty()) {
160 fillQuality(
quality.get(), detectorMap);
163 edm::LogWarning(
"SiStripBadModuleFedErrService") <<
"Empty bad channel map from FED errors";
174 auto quality = std::make_unique<SiStripQuality>(detInfo);
175 auto tdirFile = TFile::Open(
fileName.c_str());
176 auto detectorMap = getBadChannelDetectorMap(tdirFile,
runNumber, fedCabling,
cutoff);
177 if (!detectorMap.empty()) {
178 fillQuality(
quality.get(), detectorMap);
181 edm::LogWarning(
"SiStripBadModuleFedErrService") <<
"Empty bad channel map from FED errors";
205 std::unique_ptr<SiStripQuality> fedErrQuality{};
207 edm::LogInfo(
"SiStripQuality") <<
"Adding bad components from FED errors in DQM store";
210 edm::LogInfo(
"SiStripQuality") <<
"Adding bad components from FED errors in legacy DQM file "