diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc index 3234d132347c8..8fce9fb96b901 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc @@ -22,6 +22,7 @@ #include "DataFormats/DetId/interface/DetId.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DQM/TrackerRemapper/interface/Phase1PixelROCMaps.h" +#include "DQM/TrackerRemapper/interface/Phase1PixelSummaryMap.h" #include #include @@ -448,6 +449,89 @@ namespace { using SiPixelFPixQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase; using SiPixelFullQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase; + /************************************************ + Full Pixel Tracker Map class + *************************************************/ + class SiPixelQualityBadFractionMap : public PlotImage { + public: + SiPixelQualityBadFractionMap() : PlotImage("SiPixelQuality Map") { + label_ = "SiPixelQualityFullPixelMap"; + payloadString = "Quality"; + } + + bool fill() override { + gStyle->SetPalette(1); + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); + auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); + std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); + + if (payload.get()) { + Phase1PixelSummaryMap fullMap( + "", fmt::sprintf("%s", payloadString), fmt::sprintf("bad %s fraction [%%]", payloadString)); + fullMap.createTrackerBaseMap(); + + auto theDisabledModules = payload->getBadComponentList(); + if (this->isPhase0(theDisabledModules)) { + edm::LogError("SiPixelQuality_PayloadInspector") + << "SiPixelQuality maps are not supported for non-Phase1 Pixel geometries !"; + TCanvas canvas("Canv", "Canv", 1200, 1000); + SiPixelPI::displayNotSupported(canvas, 0); + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } + + for (const auto& mod : theDisabledModules) { + std::bitset<16> bad_rocs(mod.BadRocs); + fullMap.fillTrackerMap(mod.DetID, (bad_rocs.count() / 16.) * 100); // 16 ROCs in a Pixel Phase-1 module! + } + + TCanvas canvas("Canv", "Canv", 3000, 2000); + fullMap.printTrackerMap(canvas); + + auto ltx = TLatex(); + ltx.SetTextFont(62); + ltx.SetTextSize(0.025); + ltx.SetTextAlign(11); + ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01, + gPad->GetBottomMargin() + 0.01, + ("#color[4]{" + tag.name + "}, IOV: #color[4]{" + std::to_string(unpacked.first) + "," + + std::to_string(unpacked.second) + " }") + .c_str()); + + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + } + return true; + } + + protected: + std::string payloadString; + std::string label_; + + private: + //_________________________________________________ + bool isPhase0(std::vector mods) { + SiPixelDetInfoFileReader reader = + SiPixelDetInfoFileReader(edm::FileInPath(SiPixelDetInfoFileReader::kPh0DefaultFile).fullPath()); + const auto& p0detIds = reader.getAllDetIds(); + + std::vector ownDetIds; + std::transform(mods.begin(), + mods.end(), + std::back_inserter(ownDetIds), + [](SiPixelQuality::disabledModuleType d) -> uint32_t { return d.DetID; }); + + for (const auto& det : ownDetIds) { + // if found at least one phase-0 detId early return + if (std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) { + return true; + } + } + return false; + } + }; } // namespace // Register the classes as boost python plugin @@ -459,6 +543,7 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelQuality) { PAYLOAD_INSPECTOR_CLASS(SiPixelBPixQualityMap); PAYLOAD_INSPECTOR_CLASS(SiPixelFPixQualityMap); PAYLOAD_INSPECTOR_CLASS(SiPixelFullQualityMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelQualityBadFractionMap); PAYLOAD_INSPECTOR_CLASS(SiPixelBPixQualityMapCompareSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelFPixQualityMapCompareSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelFullQualityMapCompareSingleTag); diff --git a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp index 4b22d7fea4270..9af0fd022b3f9 100644 --- a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp +++ b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp @@ -94,6 +94,10 @@ int main(int argc, char** argv) { histo9.process(connectionString, PI::mk_input(tag, start, end)); edm::LogPrint("testSiPixelPayloadInspector") << histo9.data() << std::endl; + SiPixelQualityBadFractionMap histo9bis; + histo9bis.process(connectionString, PI::mk_input(tag, start, end)); + edm::LogPrint("testSiPixelPayloadInspector") << histo9bis.data() << std::endl; + // SiPixelGainCalibrationOffline tag = "SiPixelGainCalibration_2009runs_express";