Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-30 02:36:51

0001 #include "DQM/SiStripMonitorClient/interface/SiStripQualityChecker.h"
0002 #include "FWCore/ServiceRegistry/interface/Service.h"
0003 #include "DQMServices/Core/interface/DQMStore.h"
0004 
0005 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0006 
0007 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
0008 
0009 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0010 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0011 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0012 
0013 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0014 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
0015 
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 
0019 #include <iomanip>
0020 
0021 SiStripQualityChecker::SiStripQualityChecker(edm::ParameterSet const& ps) : pSet_{ps} {
0022   edm::LogInfo("SiStripQualityChecker") << " Creating SiStripQualityChecker "
0023                                         << "\n";
0024 
0025   SubDetFolderMap.emplace("TIB", "TIB");
0026   SubDetFolderMap.emplace("TOB", "TOB");
0027   SubDetFolderMap.emplace("TECF", "TEC/PLUS");
0028   SubDetFolderMap.emplace("TECB", "TEC/MINUS");
0029   SubDetFolderMap.emplace("TIDF", "TID/PLUS");
0030   SubDetFolderMap.emplace("TIDB", "TID/MINUS");
0031 }
0032 
0033 SiStripQualityChecker::~SiStripQualityChecker() {
0034   edm::LogInfo("SiStripQualityChecker") << " Deleting SiStripQualityChecker "
0035                                         << "\n";
0036 }
0037 //
0038 // -- create reportSummary MEs
0039 //
0040 void SiStripQualityChecker::bookStatus(DQMStore& dqm_store) {
0041   if (bookedStripStatus_)
0042     return;
0043 
0044   dqm_store.cd();
0045   std::string strip_dir = "";
0046   SiStripUtility::getTopFolderPath(dqm_store, "SiStrip", strip_dir);
0047   if (strip_dir.empty())
0048     strip_dir = "SiStrip";
0049 
0050   // Non Standard Plots and should be put outside EventInfo folder
0051 
0052   dqm_store.setCurrentFolder(strip_dir + "/MechanicalView");
0053 
0054   std::string hname, htitle;
0055   hname = "detFractionReportMap";
0056   htitle = "SiStrip Report for Good Detector Fraction";
0057   DetFractionReportMap = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0058   DetFractionReportMap->setAxisTitle("Sub Detector Type", 1);
0059   DetFractionReportMap->setAxisTitle("Layer/Disc Number", 2);
0060 
0061   hname = "detFractionReportMap_hasBadChan";
0062   htitle = "SiStrip Report for Good Detector Fraction due to bad channels";
0063   DetFractionReportMap_hasBadChan = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0064   DetFractionReportMap_hasBadChan->setAxisTitle("Sub Detector Type", 1);
0065   DetFractionReportMap_hasBadChan->setAxisTitle("Layer/Disc Number", 2);
0066   hname = "detFractionReportMap_hasTooManyDigis";
0067   htitle = "SiStrip Report for Good Detector Fraction due to too many digis";
0068   DetFractionReportMap_hasTooManyDigis = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0069   DetFractionReportMap_hasTooManyDigis->setAxisTitle("Sub Detector Type", 1);
0070   DetFractionReportMap_hasTooManyDigis->setAxisTitle("Layer/Disc Number", 2);
0071   hname = "detFractionReportMap_hasTooManyClu";
0072   htitle = "SiStrip Report for Good Detector Fraction due to too many clusters";
0073   DetFractionReportMap_hasTooManyClu = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0074   DetFractionReportMap_hasTooManyClu->setAxisTitle("Sub Detector Type", 1);
0075   DetFractionReportMap_hasTooManyClu->setAxisTitle("Layer/Disc Number", 2);
0076   hname = "detFractionReportMap_hasExclFed";
0077   htitle = "SiStrip Report for Good Detector Fraction due to excluded FEDs";
0078   DetFractionReportMap_hasExclFed = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0079   DetFractionReportMap_hasExclFed->setAxisTitle("Sub Detector Type", 1);
0080   DetFractionReportMap_hasExclFed->setAxisTitle("Layer/Disc Number", 2);
0081   hname = "detFractionReportMap_hasDcsErr";
0082   htitle = "SiStrip Report for Good Detector Fraction due to DCS errors";
0083   DetFractionReportMap_hasDcsErr = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0084   DetFractionReportMap_hasDcsErr->setAxisTitle("Sub Detector Type", 1);
0085   DetFractionReportMap_hasDcsErr->setAxisTitle("Layer/Disc Number", 2);
0086 
0087   hname = "sToNReportMap";
0088   htitle = "SiStrip Report for Signal-to-Noise";
0089   SToNReportMap = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0090   SToNReportMap->setAxisTitle("Sub Detector Type", 1);
0091   SToNReportMap->setAxisTitle("Layer/Disc Number", 2);
0092 
0093   // this is the main reportSummary 2D plot and should be in EventInfo
0094   dqm_store.setCurrentFolder(strip_dir + "/EventInfo");
0095 
0096   hname = "reportSummaryMap";
0097   htitle = "SiStrip Report Summary Map";
0098   SummaryReportMap = dqm_store.book2D(hname, htitle, 6, 0.5, 6.5, 9, 0.5, 9.5);
0099   SummaryReportMap->setAxisTitle("Sub Detector Type", 1);
0100   SummaryReportMap->setAxisTitle("Layer/Disc Number", 2);
0101 
0102   SummaryReportGlobal = dqm_store.bookFloat("reportSummary");
0103   int ibin = 0;
0104 
0105   dqm_store.setCurrentFolder(strip_dir + "/EventInfo/reportSummaryContents");
0106   for (auto const& [det, label] : SubDetFolderMap) {
0107     ibin++;
0108     DetFractionReportMap->setBinLabel(ibin, label);
0109     DetFractionReportMap_hasBadChan->setBinLabel(ibin, label);
0110     DetFractionReportMap_hasTooManyDigis->setBinLabel(ibin, label);
0111     DetFractionReportMap_hasTooManyClu->setBinLabel(ibin, label);
0112     DetFractionReportMap_hasExclFed->setBinLabel(ibin, label);
0113     DetFractionReportMap_hasDcsErr->setBinLabel(ibin, label);
0114     SToNReportMap->setBinLabel(ibin, label);
0115     SummaryReportMap->setBinLabel(ibin, label);
0116 
0117     SubDetMEs local_mes;
0118 
0119     if (det == "TECF")
0120       local_mes.detectorTag = "TEC+";
0121     else if (det == "TECB")
0122       local_mes.detectorTag = "TEC-";
0123     else if (det == "TIDF")
0124       local_mes.detectorTag = "TID+";
0125     else if (det == "TIDB")
0126       local_mes.detectorTag = "TID-";
0127     else
0128       local_mes.detectorTag = det;
0129 
0130     std::string me_name;
0131     me_name = "SiStrip_" + det;
0132     local_mes.SummaryFlag = dqm_store.bookFloat(me_name);
0133 
0134     me_name = "SiStrip_DetFraction_" + det;
0135     local_mes.DetFraction = dqm_store.bookFloat(me_name);
0136 
0137     me_name = "SiStrip_SToNFlag_" + det;
0138     local_mes.SToNFlag = dqm_store.bookFloat(me_name);
0139     SubDetMEsMap.insert(std::pair<std::string, SubDetMEs>(det, local_mes));
0140   }
0141   bookedStripStatus_ = true;
0142 }
0143 
0144 void SiStripQualityChecker::fillDummyStatus() {
0145   resetStatus();
0146   if (bookedStripStatus_) {
0147     for (auto& pr : SubDetMEsMap) {
0148       auto& local_mes = pr.second;
0149       local_mes.SummaryFlag->Fill(-1.0);
0150       local_mes.DetFraction->Fill(-1.0);
0151       local_mes.SToNFlag->Fill(-1.0);
0152     }
0153 
0154     for (int xbin = 1; xbin < SummaryReportMap->getNbinsX() + 1; xbin++) {
0155       for (int ybin = 1; ybin < SummaryReportMap->getNbinsY() + 1; ybin++) {
0156         SummaryReportMap->Fill(xbin, ybin, -1.0);
0157         DetFractionReportMap->Fill(xbin, ybin, -1.0);
0158         DetFractionReportMap_hasBadChan->Fill(xbin, ybin, -1.0);
0159         DetFractionReportMap_hasTooManyDigis->Fill(xbin, ybin, -1.0);
0160         DetFractionReportMap_hasTooManyClu->Fill(xbin, ybin, -1.0);
0161         DetFractionReportMap_hasExclFed->Fill(xbin, ybin, -1.0);
0162         DetFractionReportMap_hasDcsErr->Fill(xbin, ybin, -1.0);
0163         SToNReportMap->Fill(xbin, ybin, -1.0);
0164       }
0165     }
0166     SummaryReportGlobal->Fill(-1.0);
0167   }
0168 }
0169 //
0170 // -- Reset Status
0171 //
0172 void SiStripQualityChecker::resetStatus() {
0173   if (bookedStripStatus_) {
0174     for (auto& pr : SubDetMEsMap) {
0175       auto& local_mes = pr.second;
0176       local_mes.DetFraction->Reset();
0177       local_mes.SummaryFlag->Reset();
0178       local_mes.SToNFlag->Reset();
0179     }
0180     SummaryReportMap->Reset();
0181     DetFractionReportMap->Reset();
0182     DetFractionReportMap_hasBadChan->Reset();
0183     DetFractionReportMap_hasTooManyDigis->Reset();
0184     DetFractionReportMap_hasTooManyClu->Reset();
0185     DetFractionReportMap_hasExclFed->Reset();
0186     DetFractionReportMap_hasDcsErr->Reset();
0187     SToNReportMap->Reset();
0188 
0189     SummaryReportGlobal->Reset();
0190   }
0191 }
0192 //
0193 // -- Fill Status
0194 //
0195 void SiStripQualityChecker::fillStatus(DQMStore& dqm_store,
0196                                        const SiStripDetCabling* cabling,
0197                                        const TkDetMap* tkDetMap,
0198                                        const TrackerTopology* tTopo) {
0199   if (!bookedStripStatus_)
0200     bookStatus(dqm_store);
0201 
0202   tkDetMap_ = tkDetMap;
0203 
0204   fillDummyStatus();
0205   fillDetectorStatus(dqm_store, cabling);
0206 
0207   int faulty_moduleflag = pSet_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);
0208   if (faulty_moduleflag)
0209     fillFaultyModuleStatus(dqm_store, tTopo);
0210 }
0211 //
0212 // Fill Detector Status
0213 //
0214 void SiStripQualityChecker::fillDetectorStatus(DQMStore& dqm_store, const SiStripDetCabling* cabling) {
0215   unsigned int xbin = 0;
0216   float global_flag = 0;
0217   dqm_store.cd();
0218   std::string mdir = "MechanicalView";
0219   if (!SiStripUtility::goToDir(dqm_store, mdir))
0220     return;
0221   std::string mechanicalview_dir = dqm_store.pwd();
0222 
0223   initialiseBadModuleList();
0224   for (auto& [det, local_mes] : SubDetMEsMap) {
0225     auto cPos = SubDetFolderMap.find(det);
0226     if (cPos == SubDetFolderMap.end())
0227       continue;
0228     std::string dname = mechanicalview_dir + "/" + cPos->second;
0229     if (!dqm_store.dirExists(dname))
0230       continue;
0231     dqm_store.cd(dname);
0232     ++xbin;
0233     float flag = 0;
0234     fillSubDetStatus(dqm_store, cabling, local_mes, xbin, flag);
0235     global_flag += flag;
0236   }
0237   global_flag = global_flag / xbin * 1.0;
0238   if (SummaryReportGlobal)
0239     SummaryReportGlobal->Fill(global_flag);
0240   dqm_store.cd();
0241 }
0242 //
0243 // -- Fill Sub detector Reports
0244 //
0245 void SiStripQualityChecker::fillSubDetStatus(
0246     DQMStore& dqm_store, const SiStripDetCabling* cabling, SubDetMEs& mes, unsigned int xbin, float& gflag) {
0247   int status_flag = pSet_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
0248   if (status_flag < 1)
0249     return;
0250 
0251   auto const subDirVec = dqm_store.getSubdirs();
0252 
0253   unsigned int ybin = 0;
0254   int tot_ndet = 0;
0255   int tot_errdet = 0;
0256   float tot_ston_stat = 0;
0257 
0258   for (auto const& dname : subDirVec) {
0259     if (dname.find("BadModuleList") != std::string::npos)
0260       continue;
0261     if (dname.find("ring") != std::string::npos)
0262       continue;
0263     std::vector<MonitorElement*> meVec;
0264 
0265     ybin++;
0266     dqm_store.cd(dname);
0267     meVec = dqm_store.getContents(dname);
0268     uint16_t ndet = 100;
0269     int errdet = 0;
0270     int errdet_hasBadChan = 0;
0271     int errdet_hasTooManyDigis = 0;
0272     int errdet_hasTooManyClu = 0;
0273     int errdet_hasExclFed = 0;
0274     int errdet_hasDcsErr = 0;
0275 
0276     int ston_stat = 1;
0277     int lnum = atoi(dname.substr(dname.find_last_of('_') + 1).c_str());
0278     ndet = cabling->connectedNumber(mes.detectorTag, lnum);
0279 
0280     getModuleStatus(dqm_store,
0281                     meVec,
0282                     errdet,
0283                     errdet_hasBadChan,
0284                     errdet_hasTooManyDigis,
0285                     errdet_hasTooManyClu,
0286                     errdet_hasExclFed,
0287                     errdet_hasDcsErr);
0288 
0289     for (auto const* me : meVec) {
0290       if (!me)
0291         continue;
0292       std::vector<QReport*> reports = me->getQReports();
0293 
0294       if (reports.empty())
0295         continue;
0296       std::string name = me->getName();
0297 
0298       if (name.find("Summary_ClusterStoNCorr__OnTrack") != std::string::npos) {
0299         int istat = SiStripUtility::getMEStatus(me);
0300         if (reports[0]->getQTresult() == -1) {
0301           ston_stat = -1;
0302         } else {
0303           if (istat == dqm::qstatus::ERROR)
0304             ston_stat = 0;
0305           else if (istat == dqm::qstatus::STATUS_OK)
0306             ston_stat = 1;
0307         }
0308       }
0309     }
0310     if (ndet > 0) {
0311       float eff_fac = 1 - (errdet * 1.0 / ndet);
0312       float eff_fac_hasBadChan = 1 - (errdet_hasBadChan * 1.0 / ndet);
0313       float eff_fac_hasTooManyDigis = 1 - (errdet_hasTooManyDigis * 1.0 / ndet);
0314       float eff_fac_hasTooManyClu = 1 - (errdet_hasTooManyClu * 1.0 / ndet);
0315       float eff_fac_hasExclFed = 1 - (errdet_hasExclFed * 1.0 / ndet);
0316       float eff_fac_hasDcsErr = 1 - (errdet_hasDcsErr * 1.0 / ndet);
0317       fillStatusHistogram(SToNReportMap, xbin, ybin, ston_stat);
0318       fillStatusHistogram(DetFractionReportMap, xbin, ybin, eff_fac);
0319       fillStatusHistogram(DetFractionReportMap_hasBadChan, xbin, ybin, eff_fac_hasBadChan);
0320       fillStatusHistogram(DetFractionReportMap_hasTooManyDigis, xbin, ybin, eff_fac_hasTooManyDigis);
0321       fillStatusHistogram(DetFractionReportMap_hasTooManyClu, xbin, ybin, eff_fac_hasTooManyClu);
0322       fillStatusHistogram(DetFractionReportMap_hasExclFed, xbin, ybin, eff_fac_hasExclFed);
0323       fillStatusHistogram(DetFractionReportMap_hasDcsErr, xbin, ybin, eff_fac_hasDcsErr);
0324       if (ston_stat < 0)
0325         fillStatusHistogram(SummaryReportMap, xbin, ybin, eff_fac);
0326       else
0327         fillStatusHistogram(SummaryReportMap, xbin, ybin, ston_stat * eff_fac);
0328 
0329       tot_ndet += ndet;
0330       tot_errdet += errdet;
0331       tot_ston_stat += ston_stat;
0332     }
0333     dqm_store.cd(dname);
0334   }
0335   if (tot_ndet > 0) {
0336     float tot_eff_fac = 1 - (tot_errdet * 1.0 / tot_ndet);
0337     if (mes.DetFraction)
0338       mes.DetFraction->Fill(tot_eff_fac);
0339     float tot_ston_fac = tot_ston_stat / ybin;
0340     if (mes.SToNFlag)
0341       mes.SToNFlag->Fill(tot_ston_fac);
0342     if (tot_ston_fac < 0) {
0343       gflag = tot_eff_fac;
0344     } else {
0345       gflag = std::min(tot_eff_fac, tot_ston_fac);
0346     }
0347     if (mes.SummaryFlag)
0348       mes.SummaryFlag->Fill(gflag);
0349   }
0350 }
0351 //
0352 // -- Print Status Report
0353 //
0354 void SiStripQualityChecker::printStatusReport() {
0355   std::ostringstream det_summary_str;
0356   for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
0357     std::string det = it->first;
0358     det_summary_str << std::setprecision(4);
0359     det_summary_str << std::setiosflags(std::ios::fixed);
0360 
0361     det_summary_str << " Printing Status for " << det << " : " << std::endl;
0362     SubDetMEs local_mes = it->second;
0363 
0364     std::string sval;
0365     float fval1, fval2, fval3;
0366     fval1 = fval2 = fval3 = -1.0;
0367 
0368     SiStripUtility::getMEValue(local_mes.DetFraction, sval);
0369     if (!sval.empty())
0370       fval1 = atof(sval.c_str());
0371     SiStripUtility::getMEValue(local_mes.SToNFlag, sval);
0372     if (!sval.empty())
0373       fval2 = atof(sval.c_str());
0374     SiStripUtility::getMEValue(local_mes.SummaryFlag, sval);
0375     if (!sval.empty())
0376       fval3 = atof(sval.c_str());
0377 
0378     det_summary_str << std::setw(7) << " % of good detectors " << fval1 << " SToN Flag           " << fval2
0379                     << " Summary Flag        " << fval3 << std::endl;
0380   }
0381 }
0382 //
0383 // -- Get Module Status from Layer Level Histograms
0384 //
0385 void SiStripQualityChecker::getModuleStatus(DQMStore& dqm_store,
0386                                             std::vector<MonitorElement*>& layer_mes,
0387                                             int& errdet,
0388                                             int& errdet_hasBadChan,
0389                                             int& errdet_hasTooManyDigis,
0390                                             int& errdet_hasTooManyClu,
0391                                             int& errdet_hasExclFed,
0392                                             int& errdet_hasDcsErr) {
0393   std::string lname;
0394   std::map<uint32_t, uint16_t> bad_modules;
0395   for (std::vector<MonitorElement*>::const_iterator it = layer_mes.begin(); it != layer_mes.end(); it++) {
0396     MonitorElement* me = (*it);
0397     if (!me)
0398       continue;
0399     std::vector<QReport*> qreports = me->getQReports();
0400     if (qreports.empty())
0401       continue;
0402     std::string name = me->getName();
0403     std::vector<DQMChannel> bad_channels_me;
0404     if (me->kind() == MonitorElement::Kind::TPROFILE) {
0405       bad_channels_me = qreports[0]->getBadChannels();
0406       lname = "";
0407     } else if (me->kind() == MonitorElement::Kind::TPROFILE2D && name.find("TkHMap") != std::string::npos) {
0408       bad_channels_me = qreports[0]->getBadChannels();
0409       lname = name.substr(name.find("TkHMap_") + 7);
0410       lname = lname.substr(lname.find("_T") + 1);
0411     }
0412     for (std::vector<DQMChannel>::iterator it = bad_channels_me.begin(); it != bad_channels_me.end(); it++) {
0413       int xval = (*it).getBinX();
0414       int yval = (*it).getBinY();
0415       uint32_t detId = tkDetMap_->getDetFromBin(lname, xval, yval);
0416       std::map<uint32_t, uint16_t>::iterator iPos = bad_modules.find(detId);
0417       uint16_t flag;
0418       if (iPos != bad_modules.end()) {
0419         flag = iPos->second;
0420         SiStripUtility::setBadModuleFlag(name, flag);
0421         iPos->second = flag;
0422       } else {
0423         //
0424         // if not in the local bad module list, check the BadModuleList dir
0425         //
0426         std::ostringstream detid_str;
0427         detid_str << detId;
0428         // now in the layer/wheel dir
0429         const std::string& currentdir = dqm_store.pwd();
0430         std::string thisMEpath = currentdir.substr(0, currentdir.rfind('/')) + "/BadModuleList/" + detid_str.str();
0431 
0432         MonitorElement* meBadModule = dqm_store.get(thisMEpath);
0433         if (meBadModule) {
0434           std::string val_str;
0435           SiStripUtility::getMEValue(meBadModule, val_str);
0436           flag = atoi(val_str.c_str());
0437         } else
0438           flag = 0;
0439 
0440         SiStripUtility::setBadModuleFlag(name, flag);
0441         bad_modules.insert(std::pair<uint32_t, uint16_t>(detId, flag));
0442       }
0443     }
0444   }
0445   for (std::map<uint32_t, uint16_t>::const_iterator it = bad_modules.begin(); it != bad_modules.end(); it++) {
0446     uint32_t detId = it->first;
0447     uint16_t flag = it->second;
0448     if (((flag >> 0) & 0x1) > 0)
0449       errdet_hasBadChan++;
0450     if (((flag >> 1) & 0x1) > 0)
0451       errdet_hasTooManyDigis++;
0452     if (((flag >> 2) & 0x1) > 0)
0453       errdet_hasTooManyClu++;
0454     if (((flag >> 3) & 0x1) > 0)
0455       errdet_hasExclFed++;
0456     if (((flag >> 4) & 0x1) > 0)
0457       errdet_hasDcsErr++;
0458     std::map<uint32_t, uint16_t>::iterator iPos = badModuleList.find(detId);
0459     if (iPos != badModuleList.end()) {
0460       iPos->second = flag;
0461     } else {
0462       badModuleList.insert(std::pair<uint32_t, uint16_t>(detId, flag));
0463     }
0464   }
0465   errdet = bad_modules.size();
0466 }
0467 //
0468 // -- Fill Report Summary Map
0469 //
0470 void SiStripQualityChecker::fillStatusHistogram(MonitorElement const* me,
0471                                                 int const xbin,
0472                                                 int const ybin,
0473                                                 float const val) {
0474   if (me && me->kind() == MonitorElement::Kind::TH2F) {
0475     auto th2d = me->getTH2F();
0476     th2d->SetBinContent(xbin, ybin, val);
0477   }
0478 }
0479 //
0480 // -- Create Monitor Elements for Modules
0481 //
0482 void SiStripQualityChecker::fillFaultyModuleStatus(DQMStore& dqm_store, const TrackerTopology* tTopo) {
0483   if (badModuleList.empty())
0484     return;
0485 
0486   dqm_store.cd();
0487   std::string mdir = "MechanicalView";
0488   if (!SiStripUtility::goToDir(dqm_store, mdir))
0489     return;
0490   std::string mechanical_dir = dqm_store.pwd();
0491 
0492   SiStripFolderOrganizer folder_organizer;
0493   for (auto const [detId, value] : badModuleList) {
0494     std::string subdet_folder;
0495     folder_organizer.getSubDetFolder(detId, tTopo, subdet_folder);
0496     if (!dqm_store.dirExists(subdet_folder)) {
0497       subdet_folder = mechanical_dir + subdet_folder.substr(subdet_folder.find("MechanicalView") + 14);
0498       if (!dqm_store.dirExists(subdet_folder))
0499         continue;
0500     }
0501     std::string bad_module_folder = subdet_folder + "/" + "BadModuleList";
0502     dqm_store.setCurrentFolder(bad_module_folder);
0503 
0504     std::ostringstream detid_str;
0505     detid_str << detId;
0506     std::string full_path = bad_module_folder + "/" + detid_str.str();
0507     MonitorElement* me = dqm_store.get(full_path);
0508     if (me)
0509       me->Reset();
0510     else
0511       me = dqm_store.bookInt(detid_str.str());
0512     me->Fill(value);
0513   }
0514   dqm_store.cd();
0515 }
0516 
0517 void SiStripQualityChecker::initialiseBadModuleList() {
0518   for (auto& badMod : badModuleList) {
0519     badMod.second = 0;
0520   }
0521 }
0522 
0523 //
0524 // -- Fill Status information and the lumi block
0525 //
0526 void SiStripQualityChecker::fillStatusAtLumi(DQMStore& dqm_store) {
0527   if (!bookedStripStatus_)
0528     bookStatus(dqm_store);
0529   fillDummyStatus();
0530   fillDetectorStatusAtLumi(dqm_store);
0531 }
0532 //
0533 // Fill Detector Status MEs at the Lumi block
0534 //
0535 void SiStripQualityChecker::fillDetectorStatusAtLumi(DQMStore& dqm_store) {
0536   dqm_store.cd();
0537   std::string rdir = "ReadoutView";
0538   if (!SiStripUtility::goToDir(dqm_store, rdir))
0539     return;
0540   std::string fullpath = dqm_store.pwd() + "/PerLumiSection/" + "lumiErrorFraction";
0541   MonitorElement* me = dqm_store.get(fullpath);
0542   if (me && me->kind() == MonitorElement::Kind::TH1F) {
0543     TH1F* th1 = me->getTH1F();
0544     float global_fraction = 0.0;
0545     float dets = 0.0;
0546     for (int ibin = 1; ibin <= th1->GetNbinsX(); ibin++) {
0547       std::string label = th1->GetXaxis()->GetBinLabel(ibin);
0548       std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(label);
0549       if (iPos != SubDetMEsMap.end()) {
0550         float fraction = 1.0 - th1->GetBinContent(ibin);
0551         global_fraction += fraction;
0552         dets++;
0553         iPos->second.DetFraction->Fill(fraction);
0554         iPos->second.SToNFlag->Fill(-1.0);
0555         iPos->second.SummaryFlag->Fill(fraction);
0556       }
0557     }
0558     global_fraction = global_fraction / dets;
0559     if (SummaryReportGlobal)
0560       SummaryReportGlobal->Fill(global_fraction);
0561   }
0562   dqm_store.cd();
0563 }