File indexing completed on 2023-03-17 10:57:02
0001 #include "DQM/SiStripMonitorSummary/interface/SiStripQualityDQM.h"
0002 #include "DQMServices/Core/interface/DQMStore.h"
0003 #include "TCanvas.h"
0004
0005 SiStripQualityDQM::SiStripQualityDQM(edm::ESGetToken<SiStripQuality, SiStripQualityRcd> token,
0006 edm::RunNumber_t iRun,
0007 edm::ParameterSet const &hPSet,
0008 edm::ParameterSet const &fPSet,
0009 const TrackerTopology *tTopo,
0010 const TkDetMap *tkDetMap)
0011 : SiStripBaseCondObjDQMGet<SiStripQuality, SiStripQualityRcd>{token, iRun, hPSet, fPSet, tTopo} {
0012 if (HistoMaps_On_) {
0013 Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "Quality_TkMap", 0.);
0014 }
0015 }
0016
0017 SiStripQualityDQM::~SiStripQualityDQM() {}
0018
0019 void SiStripQualityDQM::getActiveDetIds(const edm::EventSetup &eSetup) {
0020 getConditionObject(eSetup);
0021 condObj_->getDetIds(activeDetIds);
0022 }
0023
0024 void SiStripQualityDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
0025 ModMEs CondObj_ME;
0026 for (const auto det : selectedDetIds) {
0027 fillMEsForDet(CondObj_ME, det);
0028 }
0029 }
0030
0031 void SiStripQualityDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
0032 ModMEs selModME_ = _selModME_;
0033 getModMEs(selModME_, selDetId_);
0034
0035 const auto qualityRange = condObj_->getRange(selDetId_);
0036 int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
0037
0038 for (int istrip = 0; istrip < nStrip; ++istrip) {
0039 selModME_.ProfileDistr->Fill(istrip + 1, condObj_->IsStripBad(qualityRange, istrip) ? 0. : 1.);
0040
0041 }
0042 }
0043
0044 void SiStripQualityDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
0045 for (const auto det : selectedDetIds) {
0046 fillMEsForLayer( det);
0047 }
0048
0049 for (const auto &itm : SummaryMEsMap_) {
0050 ModMEs selME;
0051 selME = itm.second;
0052
0053 if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") &&
0054 fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
0055 TCanvas c1("c1");
0056 selME.SummaryDistr->getTH1()->Draw();
0057 std::string name(selME.SummaryDistr->getTitle());
0058 name += ".png";
0059 c1.Print(name.c_str());
0060 }
0061 }
0062 }
0063
0064 void SiStripQualityDQM::fillMEsForLayer(
0065 uint32_t selDetId_) {
0066 float numberOfBadStrips = 0;
0067
0068 SiStripHistoId hidmanager;
0069
0070 if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
0071 std::string hSummary_description;
0072 hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
0073
0074 std::string hSummary_name;
0075
0076
0077 int subDetId_ = ((selDetId_ >> 25) & 0x7);
0078
0079 if (subDetId_ < 3 || subDetId_ > 6) {
0080 edm::LogError("SiStripQualityDQM") << "[SiStripQualityDQM::fillMEsForLayer] WRONG INPUT : no such "
0081 "subdetector type : "
0082 << subDetId_ << " no folder set!" << std::endl;
0083 return;
0084 }
0085
0086
0087 hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
0088
0089 const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
0090
0091 ModMEs selME_;
0092 if (selMEsMapIter_ != SummaryMEsMap_.end())
0093 selME_ = selMEsMapIter_->second;
0094
0095 getSummaryMEs(selME_, selDetId_);
0096
0097 std::vector<uint32_t> sameLayerDetIds_;
0098 sameLayerDetIds_.clear();
0099 sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
0100
0101
0102
0103
0104
0105
0106 if (std::binary_search(alreadyFilledLayers.begin(), alreadyFilledLayers.end(), sameLayerDetIds_[0]))
0107 return;
0108 alreadyFilledLayers.push_back(sameLayerDetIds_[0]);
0109 sort(alreadyFilledLayers.begin(), alreadyFilledLayers.end());
0110
0111
0112 for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
0113 const auto qualityRange = condObj_->getRange(sameLayerDetIds_[i]);
0114 int nStrip = detInfo_.getNumberOfApvsAndStripLength(sameLayerDetIds_[i]).first * 128;
0115
0116 numberOfBadStrips = 0;
0117
0118 for (int istrip = 0; istrip < nStrip; ++istrip) {
0119 if (condObj_->IsStripBad(qualityRange, istrip)) {
0120 numberOfBadStrips++;
0121 }
0122 }
0123
0124 float fr = 100 * float(numberOfBadStrips) / nStrip;
0125 selME_.SummaryDistr->Fill(i + 1, fr);
0126 if (fr > 20) {
0127 char c[9];
0128 sprintf(c, "%d", sameLayerDetIds_[i]);
0129 selME_.SummaryDistr->setBinLabel(i + 1, c);
0130 }
0131
0132
0133 if (HistoMaps_On_)
0134 Tk_HM_->setBinContent(sameLayerDetIds_[i], fr);
0135
0136
0137 if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
0138 fillTkMap(sameLayerDetIds_[i], fr);
0139 }
0140 }
0141 }
0142 }
0143
0144 void SiStripQualityDQM::fillGrandSummaryMEs() {
0145 std::string hSummary_BadObjects_xTitle = hPSet_.getParameter<std::string>("Summary_BadObjects_histo_xTitle");
0146
0147 std::string hSummary_BadModules_name = hPSet_.getParameter<std::string>("Summary_BadModules_histo_name");
0148 std::string hSummary_BadModules_yTitle = hPSet_.getParameter<std::string>("Summary_BadModules_histo_yTitle");
0149
0150 std::string hSummary_BadFibers_name = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_name");
0151 std::string hSummary_BadFibers_yTitle = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_yTitle");
0152
0153 std::string hSummary_BadApvs_name = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_name");
0154 std::string hSummary_BadApvs_yTitle = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_yTitle");
0155
0156 std::string hSummary_BadStrips_name = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_name");
0157 std::string hSummary_BadStrips_yTitle = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_yTitle");
0158
0159 int NchX = 34;
0160 double LowX = 0.5;
0161 double HighX = 34.5;
0162
0163 MonitorElement *ME[4];
0164
0165 DQMStore *dqmStore_ = edm::Service<DQMStore>().operator->();
0166
0167 std::string FolderName = fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
0168
0169 dqmStore_->setCurrentFolder(FolderName);
0170
0171 ME[0] = dqmStore_->book1D(hSummary_BadModules_name, hSummary_BadModules_name, NchX, LowX, HighX);
0172 ME[0]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
0173 ME[0]->setAxisTitle(hSummary_BadModules_yTitle, 2);
0174
0175 ME[1] = dqmStore_->book1D(hSummary_BadFibers_name, hSummary_BadFibers_name, NchX, LowX, HighX);
0176 ME[1]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
0177 ME[1]->setAxisTitle(hSummary_BadFibers_yTitle, 2);
0178
0179 ME[2] = dqmStore_->book1D(hSummary_BadApvs_name, hSummary_BadApvs_name, NchX, LowX, HighX);
0180 ME[2]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
0181 ME[2]->setAxisTitle(hSummary_BadApvs_yTitle, 2);
0182
0183 ME[3] = dqmStore_->book1D(hSummary_BadStrips_name, hSummary_BadStrips_name, NchX, LowX, HighX);
0184 ME[3]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
0185 ME[3]->setAxisTitle(hSummary_BadStrips_yTitle, 2);
0186
0187
0188
0189 for (int i = 0; i < 4; ++i) {
0190 NTkBadComponent[i] = 0;
0191 for (int j = 0; j < 19; ++j) {
0192 ssV[i][j].str("");
0193 for (int k = 0; k < 4; ++k)
0194 NBadComponent[i][j][k] = 0;
0195 }
0196 }
0197
0198 std::stringstream ss;
0199 ss.str("");
0200 for (const auto det : detInfo_.getAllDetIds()) {
0201 ss << "detid " << det << " IsModuleUsable " << condObj_->IsModuleUsable(det) << "\n";
0202 }
0203 LogDebug("SiStripQualityDQM") << ss.str() << std::endl;
0204
0205 std::vector<SiStripQuality::BadComponent> BC = condObj_->getBadComponentList();
0206
0207 for (size_t i = 0; i < BC.size(); ++i) {
0208
0209
0210
0211
0212 if (BC[i].BadModule)
0213 NTkBadComponent[0]++;
0214 if (BC[i].BadFibers)
0215 NTkBadComponent[1] += ((BC[i].BadFibers >> 2) & 0x1) + ((BC[i].BadFibers >> 1) & 0x1) + ((BC[i].BadFibers) & 0x1);
0216 if (BC[i].BadApvs)
0217 NTkBadComponent[2] += ((BC[i].BadApvs >> 5) & 0x1) + ((BC[i].BadApvs >> 4) & 0x1) + ((BC[i].BadApvs >> 3) & 0x1) +
0218 ((BC[i].BadApvs >> 2) & 0x1) + ((BC[i].BadApvs >> 1) & 0x1) + ((BC[i].BadApvs) & 0x1);
0219
0220
0221
0222
0223
0224 int component;
0225 SiStripDetId a(BC[i].detid);
0226 if (a.subdetId() == SiStripDetId::TIB) {
0227
0228
0229
0230
0231 component = tTopo_->tibLayer(BC[i].detid);
0232 SetBadComponents(0, component, BC[i]);
0233
0234 } else if (a.subdetId() == SiStripDetId::TID) {
0235
0236
0237
0238
0239 component = tTopo_->tidSide(BC[i].detid) == 2 ? tTopo_->tidWheel(BC[i].detid) : tTopo_->tidWheel(BC[i].detid) + 3;
0240 SetBadComponents(1, component, BC[i]);
0241
0242 } else if (a.subdetId() == SiStripDetId::TOB) {
0243
0244
0245
0246
0247 component = tTopo_->tobLayer(BC[i].detid);
0248 SetBadComponents(2, component, BC[i]);
0249
0250 } else if (a.subdetId() == SiStripDetId::TEC) {
0251
0252
0253
0254
0255 component = tTopo_->tecSide(BC[i].detid) == 2 ? tTopo_->tecWheel(BC[i].detid) : tTopo_->tecWheel(BC[i].detid) + 9;
0256 SetBadComponents(3, component, BC[i]);
0257 }
0258 }
0259
0260
0261
0262
0263
0264 SiStripQuality::RegistryIterator rbegin = condObj_->getRegistryVectorBegin();
0265 SiStripQuality::RegistryIterator rend = condObj_->getRegistryVectorEnd();
0266
0267 for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
0268 uint32_t detid = rp->detid;
0269
0270 int subdet = 0;
0271 int component = 0;
0272 SiStripDetId a(detid);
0273 if (a.subdetId() == 3) {
0274 subdet = 0;
0275 component = tTopo_->tibLayer(detid);
0276 } else if (a.subdetId() == 4) {
0277 subdet = 1;
0278 component = tTopo_->tidSide(detid) == 2 ? tTopo_->tidWheel(detid) : tTopo_->tidWheel(detid) + 3;
0279 } else if (a.subdetId() == 5) {
0280 subdet = 2;
0281 component = tTopo_->tobLayer(detid);
0282 } else if (a.subdetId() == 6) {
0283 subdet = 3;
0284 component = tTopo_->tecSide(detid) == 2 ? tTopo_->tecWheel(detid) : tTopo_->tecWheel(detid) + 9;
0285 }
0286
0287 SiStripQuality::Range sqrange =
0288 SiStripQuality::Range(condObj_->getDataVectorBegin() + rp->ibegin, condObj_->getDataVectorBegin() + rp->iend);
0289
0290 for (int it = 0; it < sqrange.second - sqrange.first; it++) {
0291 unsigned int range = condObj_->decode(*(sqrange.first + it)).range;
0292 NTkBadComponent[3] += range;
0293 NBadComponent[subdet][0][3] += range;
0294 NBadComponent[subdet][component][3] += range;
0295 }
0296 }
0297
0298
0299
0300
0301
0302 ss.str("");
0303 ss << "\n-----------------\nGlobal Info\n-----------------";
0304 ss << "\nBadComponent \t Modules \tFibers "
0305 "\tApvs\tStrips\n------------------------------------------------------"
0306 "----------";
0307 ss << "\nTracker:\t\t" << NTkBadComponent[0] << "\t" << NTkBadComponent[1] << "\t" << NTkBadComponent[2] << "\t"
0308 << NTkBadComponent[3];
0309 ss << "\n";
0310 ss << "\nTIB:\t\t\t" << NBadComponent[0][0][0] << "\t" << NBadComponent[0][0][1] << "\t" << NBadComponent[0][0][2]
0311 << "\t" << NBadComponent[0][0][3];
0312 ss << "\nTID:\t\t\t" << NBadComponent[1][0][0] << "\t" << NBadComponent[1][0][1] << "\t" << NBadComponent[1][0][2]
0313 << "\t" << NBadComponent[1][0][3];
0314 ss << "\nTOB:\t\t\t" << NBadComponent[2][0][0] << "\t" << NBadComponent[2][0][1] << "\t" << NBadComponent[2][0][2]
0315 << "\t" << NBadComponent[2][0][3];
0316 ss << "\nTEC:\t\t\t" << NBadComponent[3][0][0] << "\t" << NBadComponent[3][0][1] << "\t" << NBadComponent[3][0][2]
0317 << "\t" << NBadComponent[3][0][3];
0318 ss << "\n";
0319
0320 for (int i = 1; i < 5; ++i) {
0321 ss << "\nTIB Layer " << i << " :\t\t" << NBadComponent[0][i][0] << "\t" << NBadComponent[0][i][1] << "\t"
0322 << NBadComponent[0][i][2] << "\t" << NBadComponent[0][i][3];
0323 std::stringstream binlabel;
0324 binlabel << "TIB L " << i;
0325
0326 for (int j = 0; j < 4; j++) {
0327 ME[j]->Fill(i, NBadComponent[0][i][j]);
0328 ME[j]->setBinLabel(i, binlabel.str());
0329 }
0330 }
0331 ss << "\n";
0332 for (int i = 1; i < 4; ++i) {
0333 ss << "\nTID+ Disk " << i << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
0334 << NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
0335 std::stringstream binlabel;
0336 binlabel << "TID+ D " << i;
0337
0338 for (int j = 0; j < 4; j++) {
0339 ME[j]->Fill(i + 4, NBadComponent[1][i][j]);
0340 ME[j]->setBinLabel(i + 4, binlabel.str());
0341 }
0342 }
0343 for (int i = 4; i < 7; ++i) {
0344 ss << "\nTID- Disk " << i - 3 << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
0345 << NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
0346 std::stringstream binlabel;
0347 binlabel << "TID- D " << i - 3;
0348
0349 for (int j = 0; j < 4; j++) {
0350 ME[j]->Fill(i + 4, NBadComponent[1][i][j]);
0351 ME[j]->setBinLabel(i + 4, binlabel.str());
0352 }
0353 }
0354 ss << "\n";
0355 for (int i = 1; i < 7; ++i) {
0356 ss << "\nTOB Layer " << i << " :\t\t" << NBadComponent[2][i][0] << "\t" << NBadComponent[2][i][1] << "\t"
0357 << NBadComponent[2][i][2] << "\t" << NBadComponent[2][i][3];
0358 std::stringstream binlabel;
0359 binlabel << "TOB L " << i;
0360
0361 for (int j = 0; j < 4; j++) {
0362 ME[j]->Fill(i + 10, NBadComponent[2][i][j]);
0363 ME[j]->setBinLabel(i + 10, binlabel.str());
0364 }
0365 }
0366 ss << "\n";
0367 for (int i = 1; i < 10; ++i) {
0368 ss << "\nTEC+ Disk " << i << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
0369 << NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
0370 std::stringstream binlabel;
0371 binlabel << "TEC+ D " << i;
0372
0373 for (int j = 0; j < 4; j++) {
0374 ME[j]->Fill(i + 16, NBadComponent[3][i][j]);
0375 ME[j]->setBinLabel(i + 16, binlabel.str());
0376 }
0377 }
0378 for (int i = 10; i < 19; ++i) {
0379 ss << "\nTEC- Disk " << i - 9 << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
0380 << NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
0381 std::stringstream binlabel;
0382 binlabel << "TEC- D " << i - 9;
0383
0384 for (int j = 0; j < 4; j++) {
0385 ME[j]->Fill(i + 16, NBadComponent[3][i][j]);
0386 ME[j]->setBinLabel(i + 16, binlabel.str());
0387 }
0388 }
0389 ss << "\n";
0390
0391 ss << "\n----------------------------------------------------------------"
0392 "\n\t\t Detid \tModules Fibers "
0393 "Apvs\n---------------------------------------------------------------"
0394 "-";
0395 for (int i = 1; i < 5; ++i)
0396 ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
0397 ss << "\n";
0398 for (int i = 1; i < 4; ++i)
0399 ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
0400 for (int i = 4; i < 7; ++i)
0401 ss << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
0402 ss << "\n";
0403 for (int i = 1; i < 7; ++i)
0404 ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
0405 ss << "\n";
0406 for (int i = 1; i < 10; ++i)
0407 ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
0408 for (int i = 10; i < 19; ++i)
0409 ss << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
0410
0411 edm::LogInfo("SiStripQualityDQM") << ss.str() << std::endl;
0412
0413 for (int i = 0; i < 4; i++) {
0414 TCanvas c1("c1");
0415 ME[i]->getTH1()->Draw();
0416 std::string name(ME[i]->getTitle());
0417 name += ".png";
0418 c1.Print(name.c_str());
0419 }
0420 }
0421
0422 void SiStripQualityDQM::SetBadComponents(int i, int component, SiStripQuality::BadComponent &BC) {
0423 int napv = detInfo_.getNumberOfApvsAndStripLength(BC.detid).first;
0424
0425 ssV[i][component] << "\n\t\t " << BC.detid << " \t " << BC.BadModule << " \t " << ((BC.BadFibers) & 0x1) << " ";
0426 if (napv == 4)
0427 ssV[i][component] << "x " << ((BC.BadFibers >> 1) & 0x1);
0428
0429 if (napv == 6)
0430 ssV[i][component] << ((BC.BadFibers >> 1) & 0x1) << " " << ((BC.BadFibers >> 2) & 0x1);
0431 ssV[i][component] << " \t " << ((BC.BadApvs) & 0x1) << " " << ((BC.BadApvs >> 1) & 0x1) << " ";
0432 if (napv == 4)
0433 ssV[i][component] << "x x " << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1);
0434 if (napv == 6)
0435 ssV[i][component] << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1) << " "
0436 << ((BC.BadApvs >> 4) & 0x1) << " " << ((BC.BadApvs >> 5) & 0x1) << " ";
0437
0438 if (BC.BadApvs) {
0439 NBadComponent[i][0][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) + ((BC.BadApvs >> 3) & 0x1) +
0440 ((BC.BadApvs >> 2) & 0x1) + ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
0441 NBadComponent[i][component][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) +
0442 ((BC.BadApvs >> 3) & 0x1) + ((BC.BadApvs >> 2) & 0x1) +
0443 ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
0444
0445 }
0446 if (BC.BadFibers) {
0447 NBadComponent[i][0][1] += ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
0448 NBadComponent[i][component][1] +=
0449 ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
0450
0451 }
0452 if (BC.BadModule) {
0453 NBadComponent[i][0][0]++;
0454 NBadComponent[i][component][0]++;
0455
0456 }
0457 }