Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-31 00:08:45

0001 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
0002 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0003 #include "DQM/SiStripCommon/interface/TkHistoMap.h"
0004 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
0005 #include "DQM/SiStripMonitorClient/interface/SiStripConfigParser.h"
0006 #include "DQMServices/Core/interface/DQMStore.h"
0007 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0012 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
0013 
0014 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
0015 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0016 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0017 #include "Geometry/TrackerNumberingBuilder/interface/utils.h"
0018 #include "DQM/SiStripMonitorClient/interface/SiStripTrackerMapCreator.h"
0019 
0020 #include <iostream>
0021 
0022 SiStripTrackerMapCreator::SiStripTrackerMapCreator(const SiStripDetCabling* detCabling,
0023                                                    const TkDetMap* tkDetMap,
0024                                                    const TrackerTopology* tTopo)
0025     : detCabling_(detCabling), tkDetMap_(tkDetMap), tTopo_(tTopo) {}
0026 
0027 //
0028 // -- Create Geometric and Fed Tracker Map
0029 //
0030 void SiStripTrackerMapCreator::create(const edm::ParameterSet& tkmapPset,
0031                                       DQMStore& dqm_store,
0032                                       std::string const& map_type) {
0033   const SiStripFedCabling* fedcabling = detCabling_->fedCabling();
0034 
0035   if (!fedcabling)
0036     return;
0037 
0038   trackerMap_ = std::make_unique<TrackerMap>(tkmapPset, fedcabling, tTopo_);
0039   std::string tmap_title = " Tracker Map from  " + map_type;
0040   trackerMap_->setTitle(tmap_title);
0041 
0042   nDet_ = 0;
0043   tkMapMax_ = 0.0;
0044   tkMapMin_ = 0.0;
0045   meanToMaxFactor_ = 2.5;
0046   stripTopLevelDir_ = "SiStrip";
0047 
0048   if (map_type == "QTestAlarm") {
0049     setTkMapFromAlarm(dqm_store, nullptr);
0050   } else {
0051     trackerMap_->fill_all_blank();
0052     setTkMapFromHistogram(dqm_store, map_type);
0053     setTkMapRange(map_type);
0054   }
0055   trackerMap_->printonline();
0056   trackerMap_.reset();
0057 }
0058 
0059 void SiStripTrackerMapCreator::createForOffline(const edm::ParameterSet& tkmapPset,
0060                                                 DQMStore& dqm_store,
0061                                                 std::string& map_type,
0062                                                 const SiStripQuality* stripQuality) {
0063   // Determine the strip top level dirctory in the DQM file: it is the
0064   // path where MechanicalView is minus one directory
0065   std::string const mdir{"MechanicalView"};
0066   dqm_store.cd();
0067   if (!SiStripUtility::goToDir(dqm_store, mdir)) {
0068     edm::LogError("SiStripTopLevelDirNotFound") << "I cannot find the SiStrip top level directory in the DQM file";
0069   } else {
0070     const std::string& mechanicalview_dir = dqm_store.pwd();
0071     stripTopLevelDir_ = mechanicalview_dir.substr(0, mechanicalview_dir.find_last_of('/'));
0072     edm::LogInfo("SiStripTopLevelDirFound") << "SiStrip top level directory is " << stripTopLevelDir_;
0073   }
0074   dqm_store.cd();
0075 
0076   //
0077   const SiStripFedCabling* fedcabling = detCabling_->fedCabling();
0078 
0079   if (!fedcabling)
0080     return;
0081 
0082   trackerMap_ = std::make_unique<TrackerMap>(tkmapPset, fedcabling, tTopo_);
0083 
0084   meanToMaxFactor_ = tkmapPset.getUntrackedParameter<double>("meanToMaxFact", 2.5);
0085   bool tkMapPSU = tkmapPset.getUntrackedParameter<bool>("psuMap", false);
0086   bool tkMapFED = tkmapPset.getUntrackedParameter<bool>("fedMap", false);
0087   std::string namesuffix = tkmapPset.getUntrackedParameter<std::string>("mapSuffix", "");
0088 
0089   //  std::string tmap_title = " Tracker Map from  " + map_type;
0090   unsigned int runNumber_ = tkmapPset.getUntrackedParameter<unsigned int>("RunNumber", 1);
0091   std::stringstream ss;
0092   ss << runNumber_;
0093   sRunNumber = ss.str();
0094   std::cout << sRunNumber << "\n\n\n\n\n\n";
0095   std::string tmap_title;
0096   if (runNumber_ > 0) {
0097     tmap_title = " Run: " + sRunNumber + ", Tracker Map from " + map_type;
0098   } else {
0099     tmap_title = " Tracker Map from " + map_type;
0100   }
0101   trackerMap_->setTitle(tmap_title);
0102 
0103   if (tkmapPset.exists("TopModules"))
0104     topModules_ = tkmapPset.getUntrackedParameter<bool>("TopModules");
0105   else
0106     topModules_ = false;
0107 
0108   if (tkmapPset.exists("numberTopModules"))
0109     numTopModules_ = tkmapPset.getUntrackedParameter<uint32_t>("numberTopModules");
0110   else
0111     numTopModules_ = 20;
0112 
0113   if (tkmapPset.exists("topModLabel"))
0114     topModLabel_ = tkmapPset.getUntrackedParameter<int32_t>("topModLabel");
0115   else
0116     topModLabel_ = " top Modules " + map_type;
0117 
0118   if (map_type == "QTestAlarm") {
0119     setTkMapFromAlarm(dqm_store, stripQuality);
0120   } else {
0121     setTkMapFromHistogram(dqm_store, map_type);
0122   }
0123   // if not overwitten by manual configuration min=0 and max= mean value * meanToMaxFactor_
0124   setTkMapRangeOffline();
0125 
0126   // check manual setting
0127 
0128   if (tkmapPset.exists("mapMax"))
0129     tkMapMax_ = tkmapPset.getUntrackedParameter<double>("mapMax");
0130   if (tkmapPset.exists("mapMin"))
0131     tkMapMin_ = tkmapPset.getUntrackedParameter<double>("mapMin");
0132 
0133   if (map_type == "ResidualsMean") {
0134     ResidualsRMS_ = false;
0135     setTkMapFromHistogram(dqm_store, map_type);
0136     edm::LogInfo("TkMapToBeSaved") << "Ready to save TkMap " << map_type << namesuffix << " with range set to "
0137                                    << tkMapMin_ << " - " << tkMapMax_;
0138     trackerMap_->save(true, 0.0000000001, 0.005, map_type + namesuffix + ".svg");
0139     trackerMap_->save(true, 0.0000000001, 0.005, map_type + namesuffix + ".png", 4500, 2400);
0140     ResidualsRMS_ = true;
0141     map_type = "ResidualsRMS";
0142     if (runNumber_ > 0) {
0143       tmap_title = " Run: " + sRunNumber + ", Tracker Map from " + map_type;
0144     } else {
0145       tmap_title = " Tracker Map from " + map_type;
0146     }
0147     trackerMap_->setTitle(tmap_title);
0148     setTkMapFromHistogram(dqm_store, map_type);
0149     edm::LogInfo("TkMapToBeSaved") << "Ready to save TkMap " << map_type << namesuffix
0150                                    << " with range set to 0.0 - 1.0";
0151     trackerMap_->save(true, 0.0, 1.0, map_type + namesuffix + ".svg");
0152     trackerMap_->save(true, 0.0, 1.0, map_type + namesuffix + ".png", 4500, 2400);
0153     // reset the map name to ResidualsMean to restore the
0154     // correct behaviour for the summary file creation
0155     map_type = "ResidualsMean";
0156   } else {
0157     edm::LogInfo("TkMapToBeSaved") << "Ready to save TkMap " << map_type << namesuffix << " with range set to "
0158                                    << tkMapMin_ << " - " << tkMapMax_;
0159     trackerMap_->save(true, tkMapMin_, tkMapMax_, map_type + namesuffix + ".svg");
0160     trackerMap_->save(true, tkMapMin_, tkMapMax_, map_type + namesuffix + ".png", 4500, 2400);
0161   }
0162 
0163   if (tkMapPSU) {
0164     edm::LogInfo("PSUMapToBeSaved") << "Ready to save PSU TkMap " << map_type << namesuffix << " with range set to "
0165                                     << tkMapMin_ << " - " << tkMapMax_;
0166     trackerMap_->save_as_psutrackermap(true, tkMapMin_, tkMapMax_, map_type + namesuffix + "_psu.png");
0167   }
0168 
0169   if (tkMapFED) {
0170     edm::LogInfo("FEDMapToBeSaved") << "Ready to save FED TkMap " << map_type << namesuffix << " with range set to "
0171                                     << tkMapMin_ << " - " << tkMapMax_;
0172     trackerMap_->save_as_fedtrackermap(true, tkMapMin_, tkMapMax_, map_type + namesuffix + "_fed.png");
0173   }
0174   trackerMap_.reset();
0175 }
0176 
0177 //
0178 // -- Fill Tracker Map with QTest Alarms and SiStripQuality bad modules
0179 //
0180 void SiStripTrackerMapCreator::setTkMapFromAlarm(DQMStore& dqm_store, const SiStripQuality* stripQuality) {
0181   nDet_ = 0;
0182   tkMapMax_ = 0.0;
0183   tkMapMin_ = 0.0;
0184 
0185   trackerMap_->fillc_all_blank();
0186 
0187   std::map<unsigned int, std::string> badmodmap;
0188 
0189   // used to avoid multiple checks on the same detid since the loop is done on the FED channels
0190   uint32_t detId_save = 0;
0191   // example of loop using SiStripDetCabling
0192   for (auto const& module : detCabling_->getDetCabling()) {
0193     uint32_t detId = module.first;
0194     if (detId == 0 || detId == 0xFFFFFFFF)
0195       continue;
0196     if (detId_save != detId) {
0197       detId_save = detId;
0198       bool isBad = stripQuality && stripQuality->IsModuleBad(detId);
0199       paintTkMapFromAlarm(detId, dqm_store, isBad, badmodmap);
0200     } else {
0201       edm::LogWarning("TwiceTheSameDetId")
0202           << "The detid " << detId << " was found already in the loop on SiStripDetCabling";
0203     }
0204   }
0205   printBadModuleList(badmodmap);
0206 }
0207 //
0208 //
0209 // -- Paint Tracker Map with QTest Alarms
0210 //
0211 void SiStripTrackerMapCreator::paintTkMapFromAlarm(uint32_t const det_id,
0212                                                    DQMStore& dqm_store,
0213                                                    bool const isBad,
0214                                                    std::map<unsigned int, std::string>& badmodmap) {
0215   std::ostringstream comment;
0216   uint16_t flag = 0;
0217   flag = getDetectorFlagAndComment(&dqm_store, det_id, comment);
0218 
0219   int rval, gval, bval;
0220   SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
0221   if (isBad) {
0222     rval = 255;
0223     gval = 255;
0224     bval = 0;
0225     comment << " PCLBadModule ";
0226   }
0227   trackerMap_->setText(det_id, comment.str());
0228   trackerMap_->fillc(det_id, rval, gval, bval);
0229 
0230   if (flag != 0 || isBad) {
0231     uint lay = tTopo_->layer(SiStripDetId(det_id));
0232     std::string layer = " Layer " + std::to_string(lay);
0233     badmodmap[det_id] = comment.str() + layer;
0234   }
0235 
0236   detFlag_[det_id] = flag;
0237 }
0238 
0239 //
0240 // --  Paint Tracker Map from TkHistoMap Histograms
0241 void SiStripTrackerMapCreator::setTkMapFromHistogram(DQMStore& dqm_store, std::string const& htype) {
0242   dqm_store.cd();
0243 
0244   std::string const mdir{"MechanicalView"};
0245   if (!SiStripUtility::goToDir(dqm_store, mdir))
0246     return;
0247   std::string mechanicalview_dir = dqm_store.pwd();
0248 
0249   std::vector<std::string> subdet_folder;
0250   subdet_folder.push_back("TIB");
0251   subdet_folder.push_back("TOB");
0252   subdet_folder.push_back("TEC/MINUS");
0253   subdet_folder.push_back("TEC/PLUS");
0254   subdet_folder.push_back("TID/MINUS");
0255   subdet_folder.push_back("TID/PLUS");
0256 
0257   nDet_ = 0;
0258   tkMapMax_ = 0.0;
0259   tkMapMin_ = 0.0;
0260 
0261   auto topNmodVec = topModules_ ? new std::vector<std::pair<float, uint32_t>>{} : nullptr;
0262   for (auto const& sd : subdet_folder) {
0263     std::string dname = mechanicalview_dir + "/" + sd;
0264     if (!dqm_store.dirExists(dname))
0265       continue;
0266     dqm_store.cd(dname);
0267     std::vector<std::string> layerVec = dqm_store.getSubdirs();
0268     for (auto const& layer : layerVec) {
0269       if (layer.find("BadModuleList") != std::string::npos)
0270         continue;
0271       std::vector<MonitorElement*> meVec = dqm_store.getContents(layer);
0272       MonitorElement* tkhmap_me{nullptr};
0273       std::string name;
0274       for (auto tkh : meVec) {
0275         name = tkh->getName();
0276         if (name.find("TkHMap") == std::string::npos)
0277           continue;
0278         if (htype == "QTestAlarm") {
0279           edm::LogError("ItShouldNotBeHere") << "QTestAlarm map: you should not be here!";
0280           tkhmap_me = tkh;
0281           break;
0282         } else if (name.find(htype) != std::string::npos) {
0283           tkhmap_me = tkh;
0284           break;
0285         }
0286       }
0287       if (tkhmap_me != nullptr) {
0288         paintTkMapFromHistogram(tkhmap_me, htype, topNmodVec);
0289       }
0290     }
0291     dqm_store.cd(mechanicalview_dir);
0292   }
0293   dqm_store.cd();
0294   if (topNmodVec)
0295     printTopModules(*topNmodVec);
0296 }
0297 
0298 void SiStripTrackerMapCreator::paintTkMapFromHistogram(MonitorElement const* me,
0299                                                        std::string const& htype,
0300                                                        std::vector<std::pair<float, uint32_t>>* topNmodVec) {
0301   const std::string& name = me->getName();
0302   std::string lname = name.substr(name.find("TkHMap_") + 7);
0303   lname = lname.substr(lname.find("_T") + 1);
0304   for (DetId det_id : tkDetMap_->getDetsForLayer(TkDetMap::getLayerNum(lname))) {
0305     if (det_id.rawId() <= 0)
0306       continue;
0307     nDet_++;
0308     const TkLayerMap::XYbin& xyval = tkDetMap_->getXY(det_id, cachedDetId_, cachedLayer_, cachedXYbin_);
0309     float fval = 0.0;
0310     if (name.find("Residuals") != std::string::npos) {
0311       if (ResidualsRMS_ == true) {
0312         if (me->kind() == MonitorElement::Kind::TPROFILE2D) {
0313           TProfile2D* tp = me->getTProfile2D();
0314           float fval_prov =
0315               tp->GetBinError(xyval.ix, xyval.iy) * sqrt(tp->GetBinEntries(tp->GetBin(xyval.ix, xyval.iy)));
0316           fval = fval_prov;
0317         }
0318       } else {
0319         float fval_prov = me->getBinContent(xyval.ix, xyval.iy);
0320         fval = std::abs(fval_prov);
0321       }
0322     } else
0323       fval = me->getBinContent(xyval.ix, xyval.iy);
0324     if (htype == "QTestAlarm") {
0325       edm::LogError("ItShouldNotBeHere") << "QTestAlarm map: you should not be here!";
0326     } else {
0327       if (fval == 0.0)
0328         trackerMap_->fillc(det_id, 255, 255, 255);
0329       else {
0330         trackerMap_->fill_current_val(det_id, fval);
0331         if (topNmodVec) {
0332           topNmodVec->emplace_back(fval, det_id);
0333         }
0334       }
0335       tkMapMax_ += fval;
0336     }
0337   }
0338 }
0339 //
0340 // -- Get Flag and status Comment
0341 //
0342 uint16_t SiStripTrackerMapCreator::getDetectorFlagAndComment(DQMStore* const dqm_store,
0343                                                              uint32_t const det_id,
0344                                                              std::ostringstream& comment) {
0345   comment << "Module " << det_id;
0346   uint16_t flag = 0;
0347 
0348   // get FED channels corresponding to the det_id
0349 
0350   comment << " FEDCHs ";
0351   constexpr std::size_t indent_width{7ull};
0352   std::vector<const FedChannelConnection*> conns = detCabling_->getConnections(det_id);
0353   for (auto const conn : conns) {
0354     if (conn) {
0355       comment << std::setw(3) << conn->fedId() << "/" << std::setw(2) << conn->fedCh() << " ";
0356     } else {
0357       comment << std::string(indent_width, ' ');
0358     }
0359   }
0360   if (conns.empty()) {
0361     comment << std::string(indent_width * 3, ' ');
0362   } else if (conns.size() == 1) {
0363     comment << std::string(indent_width * 2, ' ');
0364   } else if (conns.size() == 2) {
0365     comment << std::string(indent_width, ' ');
0366   }
0367 
0368   if (!dqm_store)
0369     return flag;
0370 
0371   SiStripFolderOrganizer folder_organizer;
0372   std::string subdet_folder, badmodule_folder;
0373 
0374   dqm_store->cd();
0375 
0376   folder_organizer.setSiStripFolderName(stripTopLevelDir_);
0377   folder_organizer.getSubDetFolder(det_id, tTopo_, subdet_folder);
0378 
0379   LogDebug("SearchBadModule") << det_id << " " << subdet_folder << " " << stripTopLevelDir_;
0380 
0381   if (dqm_store->dirExists(subdet_folder)) {
0382     badmodule_folder = subdet_folder + "/BadModuleList";
0383     LogDebug("SearchBadModule") << subdet_folder << " exists: " << badmodule_folder;
0384   } else {
0385     edm::LogError("SubDetFolderNotFound") << subdet_folder << " does not exist for detid " << det_id;
0386     return flag;
0387   }
0388   if (!dqm_store->dirExists(badmodule_folder)) {
0389     LogDebug("BadModuleFolderNotFound") << badmodule_folder << " does not exist for detid " << det_id;
0390     return flag;
0391   }
0392   std::ostringstream badmodule_path;
0393   badmodule_path << badmodule_folder << "/" << det_id;
0394   LogDebug("SearchBadModule") << badmodule_folder << " exists: " << badmodule_path.str();
0395 
0396   auto const* bad_module_me = dqm_store->get(badmodule_path.str());
0397   if (bad_module_me && bad_module_me->kind() == MonitorElement::Kind::INT) {
0398     LogDebug("SearchBadModule") << "Monitor Element found";
0399     flag = bad_module_me->getIntValue();
0400     std::string message;
0401     SiStripUtility::getBadModuleStatus(flag, message);
0402     comment << message.c_str();
0403   }
0404   return flag;
0405 }
0406 //
0407 // -- create branches for root file with tracker map values by detId and fill it
0408 //
0409 void SiStripTrackerMapCreator::createInfoFile(std::vector<std::string> const& map_names,
0410                                               TTree* tkinfo_tree,
0411                                               DQMStore& dqm_store,
0412                                               const GeometricDet* geomDet) {
0413   std::map<std::string, float> tkhmap_value;
0414   int qtalarm_flag = 0;
0415   uint32_t det_id = 0;
0416 
0417   if (!tkinfo_tree) {
0418     edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "Tree not found!";
0419   } else {
0420     tkinfo_tree->Branch("DetId", &det_id, "DetId/i");
0421     for (auto const& mapname : map_names) {
0422       if (mapname == "QTestAlarm") {
0423         qtalarm_flag = 0;
0424         tkinfo_tree->Branch(mapname.c_str(), &qtalarm_flag, std::string(mapname + "/I").c_str());
0425       } else {
0426         tkhmap_value[mapname] = -1.0;
0427         tkinfo_tree->Branch(mapname.c_str(), &tkhmap_value[mapname], std::string(mapname + "/F").c_str());
0428       }
0429     }
0430 
0431     std::string dirname = "";
0432 
0433     std::string mdir = "MechanicalView";
0434     dqm_store.cd();
0435     if (!SiStripUtility::goToDir(dqm_store, mdir)) {
0436       edm::LogError("SiStripTrackerMapCreator::createInfoFile")
0437           << "I cannot find the SiStrip top level directory in the DQM file";
0438     } else {
0439       const std::string& mechanicalview_dir = dqm_store.pwd();
0440       dirname = mechanicalview_dir.substr(0, mechanicalview_dir.find_last_of('/'));
0441       edm::LogInfo("SiStripTrackerMapCreator::createInfoFile") << "SiStrip top level directory is " << dirname;
0442     }
0443     dqm_store.cd();
0444 
0445     std::vector<TkHistoMap> tkHMaps;
0446 
0447     uint32_t nHists = map_names.size();
0448 
0449     for (uint32_t ih = 0; ih < nHists; ++ih) {
0450       tkHMaps.emplace_back(tkDetMap_);
0451       if (map_names.at(ih) != "QTestAlarm") {
0452         std::string tkhmap_name = "TkHMap_" + map_names.at(ih);
0453         tkHMaps.at(ih).loadTkHistoMap(dirname, tkhmap_name, true);
0454       }
0455     }
0456 
0457     const auto detidList = TrackerGeometryUtils::getSiStripDetIds(*geomDet);
0458     for (auto const id : detidList) {
0459       det_id = id;
0460       for (uint32_t ih = 0; ih < nHists; ++ih) {
0461         if (map_names.at(ih) == "QTestAlarm") {
0462           qtalarm_flag = getDetectorFlag(id);
0463         } else {
0464           tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih).getValue(id);
0465         }
0466       }
0467       if (!tkinfo_tree) {
0468         edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "Tree not found!";
0469       } else {
0470         tkinfo_tree->Fill();
0471       }
0472     }
0473   }
0474 }
0475 
0476 // DQMStore-explicit usages
0477 
0478 void SiStripTrackerMapCreator::printBadModuleList(std::map<unsigned int, std::string> const& badmodmap) {
0479   // Retrieve tracker topology from geometry
0480   bool tibDone = false, tidSide1Done = false, tidSide2Done = false, tobDone = false, tecSide1Done = false,
0481        tecSide2Done = false;
0482   constexpr unsigned int tibFirst = 369120277 - 1, tidSide1First = 402664197 - 1, tidSide2First = 402672389 - 1,
0483                          tobFirst = 436228134 - 1, tecSide1First = 470044965 - 1, tecSide2First = 470307109 - 1;
0484 
0485   int ntib = 0, ntids1 = 0, ntids2 = 0, ntob = 0, ntecs1 = 0, ntecs2 = 0;
0486 
0487   for (auto const& badmod : badmodmap) {
0488     SiStripDetId ssdetid(badmod.first);
0489     if (ssdetid.subDetector() == SiStripDetId::TIB)
0490       ntib++;
0491     if (ssdetid.subDetector() == SiStripDetId::TID) {
0492       if (tTopo_->tidSide(ssdetid) == 1)
0493         ntids1++;
0494       if (tTopo_->tidSide(ssdetid) == 2)
0495         ntids2++;
0496     }
0497     if (ssdetid.subDetector() == SiStripDetId::TOB)
0498       ntob++;
0499     if (ssdetid.subDetector() == SiStripDetId::TEC) {
0500       if (tTopo_->tecSide(ssdetid) == 1)
0501         ntecs1++;
0502       if (tTopo_->tecSide(ssdetid) == 2)
0503         ntecs2++;
0504     }
0505   }
0506 
0507   edm::LogVerbatim("BadModuleList") << "Run: " << sRunNumber << ", Number of bad modules in total:";
0508   edm::LogVerbatim("BadModuleList") << "--------------------------------------------------------------";
0509   edm::LogVerbatim("BadModuleList") << "TIB: " << ntib;
0510   edm::LogVerbatim("BadModuleList") << "TID/MINUS: " << ntids1;
0511   edm::LogVerbatim("BadModuleList") << "TID/PLUS: " << ntids2;
0512   edm::LogVerbatim("BadModuleList") << "TOB: " << ntob;
0513   edm::LogVerbatim("BadModuleList") << "TEC/MINUS: " << ntecs1;
0514   edm::LogVerbatim("BadModuleList") << "TEC/PLUS: " << ntecs2;
0515   edm::LogVerbatim("BadModuleList") << "-------------------------------";
0516   edm::LogVerbatim("BadModuleList");
0517   edm::LogVerbatim("BadModuleList") << "List of bad modules per partition:";
0518   edm::LogVerbatim("BadModuleList") << "----------------------------------";
0519 
0520   for (auto const& badmod : badmodmap) {
0521     if (!tibDone && badmod.first >= tibFirst) {
0522       tibDone = true;
0523       edm::LogVerbatim("BadModuleList");
0524       edm::LogVerbatim("BadModuleList") << "SubDetector TIB";
0525       edm::LogVerbatim("BadModuleList");
0526     }
0527     if (!tidSide1Done && badmod.first >= tidSide1First) {
0528       tidSide1Done = true;
0529       edm::LogVerbatim("BadModuleList");
0530       edm::LogVerbatim("BadModuleList") << "SubDetector TID/MINUS";
0531       edm::LogVerbatim("BadModuleList");
0532     }
0533     if (!tidSide2Done && badmod.first >= tidSide2First) {
0534       tidSide2Done = true;
0535       edm::LogVerbatim("BadModuleList");
0536       edm::LogVerbatim("BadModuleList") << "SubDetector TID/PLUS";
0537       edm::LogVerbatim("BadModuleList");
0538     }
0539     if (!tobDone && badmod.first >= tobFirst) {
0540       tobDone = true;
0541       edm::LogVerbatim("BadModuleList");
0542       edm::LogVerbatim("BadModuleList") << "SubDetector TOB";
0543       edm::LogVerbatim("BadModuleList");
0544     }
0545     if (!tecSide1Done && badmod.first >= tecSide1First) {
0546       tecSide1Done = true;
0547       edm::LogVerbatim("BadModuleList");
0548       edm::LogVerbatim("BadModuleList") << "SubDetector TEC/MINUS";
0549       edm::LogVerbatim("BadModuleList");
0550     }
0551     if (!tecSide2Done && badmod.first >= tecSide2First) {
0552       tecSide2Done = true;
0553       edm::LogVerbatim("BadModuleList");
0554       edm::LogVerbatim("BadModuleList") << "SubDetector TEC/PLUS";
0555       edm::LogVerbatim("BadModuleList");
0556     }
0557     edm::LogVerbatim("BadModuleList") << badmod.second;
0558   }
0559 }
0560 
0561 void SiStripTrackerMapCreator::printTopModules(std::vector<std::pair<float, uint32_t>>& topNmodVec) {
0562   if (topNmodVec.empty())
0563     return;
0564 
0565   std::sort(topNmodVec.rbegin(), topNmodVec.rend());
0566   if (topNmodVec.size() > numTopModules_)
0567     topNmodVec.resize(numTopModules_);
0568 
0569   edm::LogVerbatim("TopModules") << topModLabel_;
0570   edm::LogVerbatim("TopModules") << "------------------------------------------------------";
0571 
0572   for (auto const& aPair : topNmodVec) {
0573     uint32_t det_id = aPair.second;
0574     std::ostringstream comment;
0575     std::string subdetector;
0576     SiStripDetId ssdetid(aPair.second);
0577     if (ssdetid.subDetector() == SiStripDetId::TIB)
0578       subdetector = "TIB       ";
0579     if (ssdetid.subDetector() == SiStripDetId::TID) {
0580       if (tTopo_->tidSide(ssdetid) == 1)
0581         subdetector = "TID/MINUS ";
0582       if (tTopo_->tidSide(ssdetid) == 2)
0583         subdetector = "TID/PLUS  ";
0584     }
0585     if (ssdetid.subDetector() == SiStripDetId::TOB)
0586       subdetector = "TOB       ";
0587     if (ssdetid.subDetector() == SiStripDetId::TEC) {
0588       if (tTopo_->tecSide(ssdetid) == 1)
0589         subdetector = "TEC/MINUS ";
0590       if (tTopo_->tecSide(ssdetid) == 2)
0591         subdetector = "TEC/PLUS  ";
0592     }
0593     uint16_t flag = getDetectorFlagAndComment(nullptr, det_id, comment);
0594     if (flag == 0)
0595       edm::LogVerbatim("TopModules") << subdetector << comment.str() << " value: " << aPair.first;
0596   }
0597   edm::LogVerbatim("TopModules") << "------------------------------------------------------";
0598 }
0599 
0600 //
0601 // -- Get Tracker Map Fill Range
0602 //
0603 void SiStripTrackerMapCreator::setTkMapRange(std::string const& map_type) {
0604   tkMapMin_ = 0.0;
0605   if (tkMapMax_ == 0.0) {
0606     if (map_type.find("FractionOfBadChannels") != std::string::npos)
0607       tkMapMax_ = 1.0;
0608     else if (map_type.find("NumberOfCluster") != std::string::npos)
0609       tkMapMax_ = 0.01;
0610     else if (map_type.find("NumberOfDigi") != std::string::npos)
0611       tkMapMax_ = 0.6;
0612     else if (map_type.find("NumberOfOffTrackCluster") != std::string::npos)
0613       tkMapMax_ = 100.0;
0614     else if (map_type.find("NumberOfOnTrackCluster") != std::string::npos)
0615       tkMapMax_ = 50.0;
0616     else if (map_type.find("StoNCorrOnTrack") != std::string::npos)
0617       tkMapMax_ = 200.0;
0618   } else {
0619     tkMapMax_ = tkMapMax_ / nDet_ * 1.0;
0620     tkMapMax_ = tkMapMax_ * meanToMaxFactor_;
0621   }
0622   trackerMap_->setRange(tkMapMin_, tkMapMax_);
0623 }
0624 
0625 void SiStripTrackerMapCreator::setTkMapRangeOffline() {
0626   tkMapMin_ = 0.0;
0627   if (tkMapMax_ != 0.0) {
0628     tkMapMax_ = tkMapMax_ / (nDet_ * 1.0);
0629     tkMapMax_ = tkMapMax_ * meanToMaxFactor_;
0630   }
0631 }