diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index b1444f88055f3..e6aa1225d15f6 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -38,6 +38,7 @@ namespace gainCalibHelper { namespace gainCalibPI { enum type { t_gain = 0, t_pedestal = 1, t_correlation = 2 }; + std::array t_titles = {{"gain", "pedestal", "correlation"}}; //=========================================================================== // helper method to fill the ratio and diff distributions @@ -1351,11 +1352,11 @@ namespace gainCalibHelper { /************************************************ occupancy style map BPix *************************************************/ - template - class SiPixelGainCalibrationBPIXMap + template + class SiPixelGainCalibrationMap : public cond::payloadInspector::PlotImage { public: - SiPixelGainCalibrationBPIXMap() + SiPixelGainCalibrationMap() : cond::payloadInspector::PlotImage( Form("SiPixelGainCalibration %s Barrel Pixel Map", TypeName[myType])), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( @@ -1370,13 +1371,17 @@ namespace gainCalibHelper { }; bool fill() override { + TGaxis::SetMaxDigits(2); + auto tag = cond::payloadInspector::PlotBase::getTag<0>(); + auto tagname = tag.name; auto iov = tag.iovs.front(); std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); - Phase1PixelROCMaps theBPixGainsMap(""); - static constexpr int n_layers = 4; + std::string ztitle = + fmt::sprintf("average per %s %s", isForHLT_ ? "column" : "pixel", gainCalibPI::t_titles[myType]); + Phase1PixelROCMaps theGainsMap("", ztitle); std::map GainCalibMap_; gainCalibPI::fillThePerModuleMap(payload, GainCalibMap_, myType); @@ -1390,163 +1395,93 @@ namespace gainCalibHelper { } // hard-coded phase-I - std::array minima = {{999., 999., 999., 999.}}; + std::array b_minima = {{999., 999., 999., 999.}}; + std::array f_minima = {{999., 999.}}; for (const auto& element : GainCalibMap_) { int subid = DetId(element.first).subdetId(); if (subid == PixelSubdetector::PixelBarrel) { auto layer = m_trackerTopo.pxbLayer(DetId(element.first)); - - if (element.second < minima.at(layer - 1)) - minima.at(layer - 1) = element.second; - - theBPixGainsMap.fillWholeModule(element.first, element.second); + if (element.second < b_minima.at(layer - 1)) { + b_minima.at(layer - 1) = element.second; + } + theGainsMap.fillWholeModule(element.first, element.second); + } else if (subid == PixelSubdetector::PixelEndcap) { + auto ring = SiPixelPI::ring(DetId(element.first), m_trackerTopo, true); + if (element.second < f_minima.at(ring - 1)) { + f_minima.at(ring - 1) = element.second; + } + theGainsMap.fillWholeModule(element.first, element.second); } } gStyle->SetOptStat(0); //========================= - TCanvas canvas("Summary", "Summary", 1200, 1200); - theBPixGainsMap.drawBarrelMaps(canvas); - - for (unsigned int lay = 1; lay <= n_layers; lay++) { - SiPixelPI::adjustCanvasMargins(canvas.cd(lay), -1, 0.08, 0.1, 0.13); - - auto h_bpix_Gains = theBPixGainsMap.getLayerMaps(); - - COUT << " layer:" << lay << " max:" << h_bpix_Gains[lay - 1]->GetMaximum() << " min: " << minima.at(lay - 1) - << std::endl; - - h_bpix_Gains[lay - 1]->GetZaxis()->SetRangeUser(minima.at(lay - 1) - 0.001, - h_bpix_Gains[lay - 1]->GetMaximum() + 0.001); - } + TCanvas canvas("Summary", "Summary", 1200, k_height[myDetType]); + canvas.cd(); auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); - for (unsigned int lay = 1; lay <= n_layers; lay++) { - canvas.cd(lay); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.055); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (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; - } - - private: - TrackerTopology m_trackerTopo; - - protected: - bool isForHLT_; - std::string label_; - }; - - /************************************************ - occupancy style map FPix - *************************************************/ - - template - class SiPixelGainCalibrationFPIXMap - : public cond::payloadInspector::PlotImage { - public: - SiPixelGainCalibrationFPIXMap() - : cond::payloadInspector::PlotImage( - Form("SiPixelGainCalibration %s Forward Pixel Map", TypeName[myType])), - m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( - edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { - if constexpr (std::is_same_v) { - isForHLT_ = false; - label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; - } else { - isForHLT_ = true; - label_ = "SiPixelGainCalibrationForHLT_PayloadInspector"; - } - } - - bool fill() override { - auto tag = cond::payloadInspector::PlotBase::getTag<0>(); - auto iov = tag.iovs.front(); - std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); + std::string IOVstring = (unpacked.first == 0) + ? std::to_string(unpacked.second) + : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)); - Phase1PixelROCMaps theFPixGainsMap(""); - static constexpr int n_rings = 2; + const auto headerText = fmt::sprintf("#color[4]{%s}, IOV: #color[4]{%s}", tagname, IOVstring); - std::map GainCalibMap_; - gainCalibPI::fillThePerModuleMap(payload, GainCalibMap_, myType); - if (GainCalibMap_.size() != SiPixelPI::phase1size) { - edm::LogError(label_) << "SiPixelGainCalibration maps are not supported for non-Phase1 Pixel geometries !"; - TCanvas canvas("Canv", "Canv", 1200, 1000); - SiPixelPI::displayNotSupported(canvas, GainCalibMap_.size()); - std::string fileName(this->m_imageFileName); - canvas.SaveAs(fileName.c_str()); - return false; + switch (myDetType) { + case SiPixelPI::t_barrel: + theGainsMap.drawBarrelMaps(canvas, headerText); + break; + case SiPixelPI::t_forward: + theGainsMap.drawForwardMaps(canvas, headerText); + break; + case SiPixelPI::t_all: + theGainsMap.drawMaps(canvas, headerText); + break; + default: + throw cms::Exception("SiPixelGainCalibrationMap") + << "\nERROR: unrecognized Pixel Detector part " << std::endl; } - // hardcoded phase-I - std::array minima = {{999., 999.}}; + if (myDetType == SiPixelPI::t_barrel || myDetType == SiPixelPI::t_all) { + for (unsigned int lay = 1; lay <= n_layers; lay++) { + //SiPixelPI::adjustCanvasMargins(canvas.cd(lay), -1, 0.08, 0.1, 0.13); - for (const auto& element : GainCalibMap_) { - int subid = DetId(element.first).subdetId(); - if (subid == PixelSubdetector::PixelEndcap) { - auto ring = SiPixelPI::ring(DetId(element.first), m_trackerTopo, true); + auto h_bpix_Gains = theGainsMap.getLayerMaps(); - if (element.second < minima.at(ring - 1)) - minima.at(ring - 1) = element.second; + COUT << " layer:" << lay << " max:" << h_bpix_Gains[lay - 1]->GetMaximum() << " min: " << b_minima.at(lay - 1) + << std::endl; - theFPixGainsMap.fillWholeModule(element.first, element.second); + h_bpix_Gains[lay - 1]->GetZaxis()->SetRangeUser(b_minima.at(lay - 1) - 0.001, + h_bpix_Gains[lay - 1]->GetMaximum() + 0.001); } } - gStyle->SetOptStat(0); - //========================= - TCanvas canvas("Summary", "Summary", 1200, 600); - theFPixGainsMap.drawForwardMaps(canvas); + if (myDetType == SiPixelPI::t_forward || myDetType == SiPixelPI::t_all) { + for (unsigned int ring = 1; ring <= n_rings; ring++) { + //SiPixelPI::adjustCanvasMargins(canvas.cd(ring), -1, 0.08, 0.1, 0.13); - for (unsigned int ring = 1; ring <= n_rings; ring++) { - SiPixelPI::adjustCanvasMargins(canvas.cd(ring), -1, 0.08, 0.1, 0.13); + auto h_fpix_Gains = theGainsMap.getRingMaps(); - auto h_fpix_Gains = theFPixGainsMap.getRingMaps(); + COUT << " ring:" << ring << " max:" << h_fpix_Gains[ring - 1]->GetMaximum() + << " min: " << f_minima.at(ring - 1) << std::endl; - COUT << " ring:" << ring << " max:" << h_fpix_Gains[ring - 1]->GetMaximum() << " min: " << minima.at(ring - 1) - << std::endl; - - h_fpix_Gains[ring - 1]->GetZaxis()->SetRangeUser(minima.at(ring - 1) - 0.001, - h_fpix_Gains[ring - 1]->GetMaximum() + 0.001); - } - - auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); - - for (unsigned int ring = 1; ring <= n_rings; ring++) { - canvas.cd(ring); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.05); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + h_fpix_Gains[ring - 1]->GetZaxis()->SetRangeUser(f_minima.at(ring - 1) - 0.001, + h_fpix_Gains[ring - 1]->GetMaximum() + 0.001); + } } std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); + return true; } private: TrackerTopology m_trackerTopo; + static constexpr std::array k_height = {{1200, 600, 1600}}; + static constexpr int n_layers = 4; + static constexpr int n_rings = 2; protected: bool isForHLT_; diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index 26449903518cb..e37d5a04c96b2 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -572,6 +572,7 @@ namespace SiPixelPI { } enum DetType { t_barrel = 0, t_forward = 1, t_all = 2 }; + const std::array DetNames = {{"Barrel", "End Caps", "Whole"}}; enum regions { BPixL1o, //0 Barrel Pixel Layer 1 outer diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelFEDChannelContainer_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelFEDChannelContainer_PayloadInspector.cc index c1cccb1a411b7..fd440af137345 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelFEDChannelContainer_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelFEDChannelContainer_PayloadInspector.cc @@ -58,9 +58,10 @@ namespace { 1d histogram of SiPixelFEDChannelContainer of 1 IOV *************************************************/ - class SiPixelFEDChannelContainerTest : public PlotImage { + template + class SiPixelFEDChannelContainerMap : public PlotImage { public: - SiPixelFEDChannelContainerTest() + SiPixelFEDChannelContainerMap() : PlotImage("SiPixelFEDChannelContainer scenarios count"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { @@ -99,6 +100,7 @@ namespace { Phase1PixelROCMaps theROCMap(""); auto tag = PlotBase::getTag<0>(); + auto tagname = tag.name; auto iov = tag.iovs.front(); // open db session for the cabling map @@ -217,37 +219,29 @@ namespace { gStyle->SetOptStat(0); //========================= - TCanvas canvas("Summary", "Summary", 1200, 1600); - theROCMap.drawMaps(canvas); + TCanvas canvas("Summary", "Summary", 1200, k_height[myType]); + canvas.cd(); auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); - for (unsigned int lay = 1; lay <= n_layers; lay++) { - canvas.cd(lay); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.055); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); - } - - for (unsigned int ring = 1; ring <= n_rings; ring++) { - canvas.cd(n_layers + ring); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.050); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + std::string IOVstring = (unpacked.first == 0) + ? std::to_string(unpacked.second) + : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)); + + const auto headerText = fmt::sprintf("#color[4]{%s}, IOV: #color[4]{%s}", tagname, IOVstring); + + switch (myType) { + case SiPixelPI::t_barrel: + theROCMap.drawBarrelMaps(canvas, headerText); + break; + case SiPixelPI::t_forward: + theROCMap.drawForwardMaps(canvas, headerText); + break; + case SiPixelPI::t_all: + theROCMap.drawMaps(canvas, headerText); + break; + default: + throw cms::Exception("SiPixelQualityMap") << "\nERROR: unrecognized Pixel Detector part " << std::endl; } std::string fileName(m_imageFileName); @@ -285,6 +279,9 @@ namespace { static constexpr int n_rings = 2; static constexpr int n_layers = 4; + // graphics + static constexpr std::array k_height = {{1200, 600, 1600}}; + TrackerTopology m_trackerTopo; edm::ParameterSet m_connectionPset; cond::persistency::ConnectionPool m_connectionPool; @@ -292,6 +289,10 @@ namespace { std::string m_condDbCabling; }; + using SiPixelBPixFEDChannelContainerMap = SiPixelFEDChannelContainerMap; + using SiPixelFPixFEDChannelContainerMap = SiPixelFEDChannelContainerMap; + using SiPixelFullFEDChannelContainerMap = SiPixelFEDChannelContainerMap; + /************************************************ 1d histogram of SiPixelFEDChannelContainer of 1 IOV *************************************************/ @@ -387,6 +388,8 @@ namespace { // Register the classes as boost python plugin PAYLOAD_INSPECTOR_MODULE(SiPixelFEDChannelContainer) { - PAYLOAD_INSPECTOR_CLASS(SiPixelFEDChannelContainerTest); + PAYLOAD_INSPECTOR_CLASS(SiPixelBPixFEDChannelContainerMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelFPixFEDChannelContainerMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelFullFEDChannelContainerMap); PAYLOAD_INSPECTOR_CLASS(SiPixelFEDChannelContainerScenarios); } diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc index 8fdbc690da376..4b2a470cfae3d 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc @@ -101,14 +101,14 @@ namespace { SiPixelGainCalibrationForHLT>; using SiPixelGainCalibForHLTGainsBPIXMap = - SiPixelGainCalibrationBPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibForHLTPedestalsBPIXMap = - SiPixelGainCalibrationBPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibForHLTGainsFPIXMap = - SiPixelGainCalibrationFPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibForHLTPedestalsFPIXMap = - SiPixelGainCalibrationFPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibForHLTGainByRegionComparisonSingleTag = SiPixelGainCalibrationByRegionComparisonBase; using SiPixelGainCalibOfflineGainsBPIXMap = - SiPixelGainCalibrationBPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibOfflinePedestalsBPIXMap = - SiPixelGainCalibrationBPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibOfflineGainsFPIXMap = - SiPixelGainCalibrationFPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibOfflinePedestalsFPIXMap = - SiPixelGainCalibrationFPIXMap; + SiPixelGainCalibrationMap; using SiPixelGainCalibOfflineGainByRegionComparisonSingleTag = SiPixelGainCalibrationByRegionComparisonBase; /************************************************ - occupancy style map BPix + occupancy style map Pixel LA *************************************************/ - class SiPixelBPixLorentzAngleMap : public PlotImage { + template + class SiPixelLorentzAngleMap : public PlotImage { public: - SiPixelBPixLorentzAngleMap() - : PlotImage("SiPixelLorentzAngle Barrel Pixel Map"), + SiPixelLorentzAngleMap() + : PlotImage("SiPixelLorentzAngle Pixel Map"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} bool fill() override { auto tag = PlotBase::getTag<0>(); auto iov = tag.iovs.front(); + auto tagname = tag.name; std::shared_ptr payload = fetchPayload(std::get<1>(iov)); - Phase1PixelROCMaps theBPixLAMap(""); - static constexpr int n_layers = 4; + Phase1PixelROCMaps thePixLAMap(""); std::map LAMap_ = payload->getLorentzAngles(); if (LAMap_.size() != SiPixelPI::phase1size) { @@ -770,152 +771,82 @@ namespace { } // hard-coded phase-I - std::array minima = {{999., 999., 999., 999.}}; + std::array b_minima = {{999., 999., 999., 999.}}; + std::array f_minima = {{999., 999.}}; for (const auto &element : LAMap_) { int subid = DetId(element.first).subdetId(); if (subid == PixelSubdetector::PixelBarrel) { auto layer = m_trackerTopo.pxbLayer(DetId(element.first)); - - if (element.second < minima.at(layer - 1)) - minima.at(layer - 1) = element.second; - - theBPixLAMap.fillWholeModule(element.first, element.second); + if (element.second < b_minima.at(layer - 1)) { + b_minima.at(layer - 1) = element.second; + } + } else if (subid == PixelSubdetector::PixelEndcap) { + auto ring = SiPixelPI::ring(DetId(element.first), m_trackerTopo, true); + if (element.second < f_minima.at(ring - 1)) { + f_minima.at(ring - 1) = element.second; + } } + thePixLAMap.fillWholeModule(element.first, element.second); } gStyle->SetOptStat(0); //========================= - TCanvas canvas("Summary", "Summary", 1200, 1200); - theBPixLAMap.drawBarrelMaps(canvas); - - for (unsigned int lay = 1; lay <= n_layers; lay++) { - canvas.cd(lay)->SetBottomMargin(0.08); - canvas.cd(lay)->SetLeftMargin(0.1); - canvas.cd(lay)->SetRightMargin(0.13); - - auto h_bpix_LA = theBPixLAMap.getLayerMaps(); - - COUT << " layer:" << lay << " max:" << h_bpix_LA[lay - 1]->GetMaximum() << " min: " << minima.at(lay - 1) - << std::endl; - - h_bpix_LA[lay - 1]->GetZaxis()->SetRangeUser(minima.at(lay - 1) - 0.001, - h_bpix_LA[lay - 1]->GetMaximum() + 0.001); - } + TCanvas canvas("Summary", "Summary", 1200, k_height[myType]); + canvas.cd(); auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); - for (unsigned int lay = 1; lay <= n_layers; lay++) { - canvas.cd(lay); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.055); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + std::string IOVstring = (unpacked.first == 0) + ? std::to_string(unpacked.second) + : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)); + + const auto headerText = fmt::sprintf("#color[4]{%s}, IOV: #color[4]{%s}", tagname, IOVstring); + + switch (myType) { + case SiPixelPI::t_barrel: + thePixLAMap.drawBarrelMaps(canvas, headerText); + break; + case SiPixelPI::t_forward: + thePixLAMap.drawForwardMaps(canvas, headerText); + break; + case SiPixelPI::t_all: + thePixLAMap.drawMaps(canvas, headerText); + break; + default: + throw cms::Exception("SiPixelLorentzAngleMap") << "\nERROR: unrecognized Pixel Detector part " << std::endl; } - std::string fileName(m_imageFileName); - canvas.SaveAs(fileName.c_str()); -#ifdef MMDEBUG - canvas.SaveAs("outBPix.root"); -#endif - - return true; - } - - private: - TrackerTopology m_trackerTopo; - }; - - /************************************************ - occupancy style map FPix - *************************************************/ + if (myType == SiPixelPI::t_barrel || myType == SiPixelPI::t_all) { + // set the minima and maxima of the barrel + for (unsigned int lay = 1; lay <= n_layers; lay++) { + auto h_bpix_LA = thePixLAMap.getLayerMaps(); - class SiPixelFPixLorentzAngleMap : public PlotImage { - public: - SiPixelFPixLorentzAngleMap() - : PlotImage("SiPixelLorentzAngle Forward Pixel Map"), - m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( - edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} + COUT << " layer:" << lay << " max:" << h_bpix_LA[lay - 1]->GetMaximum() << " min: " << b_minima.at(lay - 1) + << std::endl; - bool fill() override { - auto tag = PlotBase::getTag<0>(); - auto iov = tag.iovs.front(); - std::shared_ptr payload = fetchPayload(std::get<1>(iov)); - - Phase1PixelROCMaps theFPixLAMap(""); - static constexpr int n_rings = 2; - - std::map LAMap_ = payload->getLorentzAngles(); - if (LAMap_.size() != SiPixelPI::phase1size) { - edm::LogError("SiPixelLorentzAngle_PayloadInspector") - << "SiPixelLorentzAngle maps are not supported for non-Phase1 Pixel geometries !"; - TCanvas canvas("Canv", "Canv", 1200, 1000); - SiPixelPI::displayNotSupported(canvas, LAMap_.size()); - std::string fileName(m_imageFileName); - canvas.SaveAs(fileName.c_str()); - return false; - } - - // hardcoded phase-I - std::array minima = {{999., 999.}}; - - for (const auto &element : LAMap_) { - int subid = DetId(element.first).subdetId(); - if (subid == PixelSubdetector::PixelEndcap) { - auto ring = SiPixelPI::ring(DetId(element.first), m_trackerTopo, true); - - if (element.second < minima.at(ring - 1)) - minima.at(ring - 1) = element.second; - - theFPixLAMap.fillWholeModule(element.first, element.second); + h_bpix_LA[lay - 1]->GetZaxis()->SetRangeUser(b_minima.at(lay - 1) - 0.001, + h_bpix_LA[lay - 1]->GetMaximum() + 0.001); } } - gStyle->SetOptStat(0); - //========================= - TCanvas canvas("Summary", "Summary", 1200, 600); - theFPixLAMap.drawForwardMaps(canvas); - - for (unsigned int ring = 1; ring <= n_rings; ring++) { - canvas.cd(ring)->SetBottomMargin(0.08); - canvas.cd(ring)->SetLeftMargin(0.1); - canvas.cd(ring)->SetRightMargin(0.13); + if (myType == SiPixelPI::t_forward || myType == SiPixelPI::t_all) { + // set the minima and maxima of the endcaps + for (unsigned int ring = 1; ring <= n_rings; ring++) { + auto h_fpix_LA = thePixLAMap.getRingMaps(); - auto h_fpix_LA = theFPixLAMap.getRingMaps(); + COUT << " ringer:" << ring << " max:" << h_fpix_LA[ring - 1]->GetMaximum() + << " min: " << f_minima.at(ring - 1) << std::endl; - COUT << " ringer:" << ring << " max:" << h_fpix_LA[ring - 1]->GetMaximum() << " min: " << minima.at(ring - 1) - << std::endl; - - h_fpix_LA[ring - 1]->GetZaxis()->SetRangeUser(minima.at(ring - 1) - 0.001, - h_fpix_LA[ring - 1]->GetMaximum() + 0.001); - } - - auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); - - for (unsigned int ring = 1; ring <= n_rings; ring++) { - canvas.cd(ring); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.05); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + h_fpix_LA[ring - 1]->GetZaxis()->SetRangeUser(f_minima.at(ring - 1) - 0.001, + h_fpix_LA[ring - 1]->GetMaximum() + 0.001); + } } std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); #ifdef MMDEBUG - canvas.SaveAs("outFPix.root"); + canvas.SaveAs("outPixLA.root"); #endif return true; @@ -923,8 +854,15 @@ namespace { private: TrackerTopology m_trackerTopo; + static constexpr std::array k_height = {{1200, 600, 1600}}; + static constexpr int n_layers = 4; + static constexpr int n_rings = 2; }; + using SiPixelBPixLorentzAngleMap = SiPixelLorentzAngleMap; + using SiPixelFPixLorentzAngleMap = SiPixelLorentzAngleMap; + using SiPixelFullLorentzAngleMapByROC = SiPixelLorentzAngleMap; + /************************************************ Full Pixel Tracker Map class *************************************************/ @@ -1009,5 +947,6 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) { PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleByRegionComparisonTwoTags); PAYLOAD_INSPECTOR_CLASS(SiPixelBPixLorentzAngleMap); PAYLOAD_INSPECTOR_CLASS(SiPixelFPixLorentzAngleMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelFullLorentzAngleMapByROC); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleFullPixelMap); } diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc index 2dfed132eb296..8962db87e1d30 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc @@ -39,6 +39,8 @@ namespace { + //using namespace cond::payloadInspector; + /************************************************ test class *************************************************/ @@ -144,138 +146,217 @@ namespace { }; /************************************************ - occupancy style map BPix + occupancy style map whole Pixel *************************************************/ - - class SiPixelBPixQualityMap + template + class SiPixelQualityMap : public cond::payloadInspector::PlotImage { public: - SiPixelBPixQualityMap() + SiPixelQualityMap() : cond::payloadInspector::PlotImage( - "SiPixelQuality Barrel Pixel Map"), + "SiPixelQuality Pixel Map"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} bool fill() override { auto tag = PlotBase::getTag<0>(); auto iov = tag.iovs.front(); + auto tagname = tag.name; std::shared_ptr payload = fetchPayload(std::get<1>(iov)); - Phase1PixelROCMaps theBPixMap(""); + Phase1PixelROCMaps theMap(""); auto theDisabledModules = payload->getBadComponentList(); for (const auto& mod : theDisabledModules) { int subid = DetId(mod.DetID).subdetId(); - std::bitset<16> bad_rocs(mod.BadRocs); - if (subid == PixelSubdetector::PixelBarrel) { + + if ((subid == PixelSubdetector::PixelBarrel && myType == SiPixelPI::t_barrel) || + (subid == PixelSubdetector::PixelEndcap && myType == SiPixelPI::t_forward) || + (myType == SiPixelPI::t_all)) { + std::bitset<16> bad_rocs(mod.BadRocs); if (payload->IsModuleBad(mod.DetID)) { - theBPixMap.fillWholeModule(mod.DetID, 1.); + theMap.fillWholeModule(mod.DetID, 1.); } else { - theBPixMap.fillSelectedRocs(mod.DetID, bad_rocs, 1.); + theMap.fillSelectedRocs(mod.DetID, bad_rocs, 1.); } } } gStyle->SetOptStat(0); //========================= - TCanvas canvas("Summary", "Summary", 1200, 1200); - theBPixMap.drawBarrelMaps(canvas); + TCanvas canvas("Summary", "Summary", 1200, k_height[myType]); + canvas.cd(); auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); - for (unsigned int lay = 1; lay <= 4; lay++) { - canvas.cd(lay); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.055); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + std::string IOVstring = (unpacked.first == 0) + ? std::to_string(unpacked.second) + : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)); + + const auto headerText = fmt::sprintf("#color[4]{%s}, IOV: #color[4]{%s}", tagname, IOVstring); + + switch (myType) { + case SiPixelPI::t_barrel: + theMap.drawBarrelMaps(canvas, headerText); + break; + case SiPixelPI::t_forward: + theMap.drawForwardMaps(canvas, headerText); + break; + case SiPixelPI::t_all: + theMap.drawMaps(canvas, headerText); + break; + default: + throw cms::Exception("SiPixelQualityMap") << "\nERROR: unrecognized Pixel Detector part " << std::endl; } std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); #ifdef MMDEBUG - canvas.SaveAs("outBPix.root"); + canvas.SaveAs("outAll.root"); #endif return true; } private: + static constexpr std::array k_height = {{1200, 600, 1600}}; TrackerTopology m_trackerTopo; }; + using SiPixelBPixQualityMap = SiPixelQualityMap; + using SiPixelFPixQualityMap = SiPixelQualityMap; + using SiPixelFullQualityMap = SiPixelQualityMap; + /************************************************ - occupancy style map FPix + occupancy style map whole Pixel, difference of payloads *************************************************/ - - class SiPixelFPixQualityMap - : public cond::payloadInspector::PlotImage { + template + class SiPixelQualityMapComparisonBase : public cond::payloadInspector::PlotImage { public: - SiPixelFPixQualityMap() - : cond::payloadInspector::PlotImage( - "SiPixelQuality Forward Pixel Map"), + SiPixelQualityMapComparisonBase() + : cond::payloadInspector::PlotImage( + Form("SiPixelQuality %s Pixel Map", SiPixelPI::DetNames[myType].c_str())), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} bool fill() override { - auto tag = PlotBase::getTag<0>(); - auto iov = tag.iovs.front(); - std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + // trick to deal with the multi-ioved tag and two tag case at the same time + auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs; + auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name; + std::string l_tagname = ""; + auto firstiov = theIOVs.front(); + std::tuple lastiov; + + // we don't support (yet) comparison with more than 2 tags + assert(this->m_plotAnnotations.ntags < 3); + + if (this->m_plotAnnotations.ntags == 2) { + auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs; + l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name; + lastiov = tag2iovs.front(); + } else { + lastiov = theIOVs.back(); + } - Phase1PixelROCMaps theFPixMap(""); + std::shared_ptr last_payload = this->fetchPayload(std::get<1>(lastiov)); + std::shared_ptr first_payload = this->fetchPayload(std::get<1>(firstiov)); - auto theDisabledModules = payload->getBadComponentList(); - for (const auto& mod : theDisabledModules) { - int subid = DetId(mod.DetID).subdetId(); - std::bitset<16> bad_rocs(mod.BadRocs); - if (subid == PixelSubdetector::PixelEndcap) { - if (payload->IsModuleBad(mod.DetID)) { - theFPixMap.fillWholeModule(mod.DetID, 1.); - } else { - theFPixMap.fillSelectedRocs(mod.DetID, bad_rocs, 1.); - } - } // if it's endcap - } // loop on disable moduels + Phase1PixelROCMaps theMap("", "#Delta payload A - payload B"); + + // first loop on the first payload (newest) + fillTheMapFromPayload(theMap, first_payload, false); + + // then loop on the second payload (oldest) + fillTheMapFromPayload(theMap, last_payload, true); // true will subtract gStyle->SetOptStat(0); //========================= - TCanvas canvas("Summary", "Summary", 1200, 600); - theFPixMap.drawForwardMaps(canvas); + TCanvas canvas("Summary", "Summary", 1200, k_height[myType]); + canvas.cd(); - auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); + auto f_unpacked = SiPixelPI::unpack(std::get<0>(firstiov)); + auto l_unpacked = SiPixelPI::unpack(std::get<0>(lastiov)); + + std::string f_IOVstring = (f_unpacked.first == 0) + ? std::to_string(f_unpacked.second) + : (std::to_string(f_unpacked.first) + "," + std::to_string(f_unpacked.second)); + + std::string l_IOVstring = (l_unpacked.first == 0) + ? std::to_string(l_unpacked.second) + : (std::to_string(l_unpacked.first) + "," + std::to_string(l_unpacked.second)); + + std::string headerText; - for (unsigned int ring = 1; ring <= 2; ring++) { - canvas.cd(ring); - auto ltx = TLatex(); - ltx.SetTextFont(62); - ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.050); - ltx.SetTextAlign(11); - ltx.DrawLatexNDC(gPad->GetLeftMargin(), - 1 - gPad->GetTopMargin() + 0.01, - unpacked.first == 0 - ? ("IOV:" + std::to_string(unpacked.second)).c_str() - : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + if (this->m_plotAnnotations.ntags == 2) { + headerText = fmt::sprintf( + "#Delta #color[2]{A: %s, %s} - #color[4]{B: %s, %s}", f_tagname, f_IOVstring, l_tagname, l_IOVstring); + } else { + headerText = + fmt::sprintf("%s, #Delta IOV #color[2]{A: %s} - #color[4]{B: %s} ", f_tagname, f_IOVstring, l_IOVstring); } - std::string fileName(m_imageFileName); + switch (myType) { + case SiPixelPI::t_barrel: + theMap.drawBarrelMaps(canvas, headerText); + break; + case SiPixelPI::t_forward: + theMap.drawForwardMaps(canvas, headerText); + break; + case SiPixelPI::t_all: + theMap.drawMaps(canvas, headerText); + break; + default: + throw cms::Exception("SiPixelQualityMapComparison") + << "\nERROR: unrecognized Pixel Detector part " << std::endl; + } + + std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); #ifdef MMDEBUG - canvas.SaveAs("outFPix.root"); + canvas.SaveAs("outAll.root"); #endif + return true; } private: + static constexpr std::array k_height = {{1200, 600, 1600}}; TrackerTopology m_trackerTopo; + + //____________________________________________________________________________________________ + void fillTheMapFromPayload(Phase1PixelROCMaps& theMap, + const std::shared_ptr& payload, + bool subtract) { + const auto theDisabledModules = payload->getBadComponentList(); + for (const auto& mod : theDisabledModules) { + int subid = DetId(mod.DetID).subdetId(); + if ((subid == PixelSubdetector::PixelBarrel && myType == SiPixelPI::t_barrel) || + (subid == PixelSubdetector::PixelEndcap && myType == SiPixelPI::t_forward) || + (myType == SiPixelPI::t_all)) { + std::bitset<16> bad_rocs(mod.BadRocs); + if (payload->IsModuleBad(mod.DetID)) { + theMap.fillWholeModule(mod.DetID, (subtract ? -1. : 1.)); + } else { + theMap.fillSelectedRocs(mod.DetID, bad_rocs, (subtract ? -1. : 1.)); + } + } + } + } }; + using SiPixelBPixQualityMapCompareSingleTag = + SiPixelQualityMapComparisonBase; + using SiPixelFPixQualityMapCompareSingleTag = + SiPixelQualityMapComparisonBase; + using SiPixelFullQualityMapCompareSingleTag = + SiPixelQualityMapComparisonBase; + using SiPixelBPixQualityMapCompareTwoTags = + SiPixelQualityMapComparisonBase; + using SiPixelFPixQualityMapCompareTwoTags = + SiPixelQualityMapComparisonBase; + using SiPixelFullQualityMapCompareTwoTags = + SiPixelQualityMapComparisonBase; + } // namespace // Register the classes as boost python plugin @@ -285,4 +366,11 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelQuality) { PAYLOAD_INSPECTOR_CLASS(SiPixelQualityBadRocsTimeHistory); PAYLOAD_INSPECTOR_CLASS(SiPixelBPixQualityMap); PAYLOAD_INSPECTOR_CLASS(SiPixelFPixQualityMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelFullQualityMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelBPixQualityMapCompareSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelFPixQualityMapCompareSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelFullQualityMapCompareSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelBPixQualityMapCompareTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelFPixQualityMapCompareTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelFullQualityMapCompareTwoTags); } diff --git a/CondCore/SiPixelPlugins/test/SiPixelGainCalibrationComparator_DB.sh b/CondCore/SiPixelPlugins/test/SiPixelGainCalibrationComparator_DB.sh index ba4c38f79a80a..feb7fe8195f41 100755 --- a/CondCore/SiPixelPlugins/test/SiPixelGainCalibrationComparator_DB.sh +++ b/CondCore/SiPixelPlugins/test/SiPixelGainCalibrationComparator_DB.sh @@ -1,14 +1,14 @@ -#!/bin/bash -# Save current working dir so img can be outputted there later +#!/bin/bash +# Save current working dir so img can be outputted there later W_DIR=$(pwd); -# Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +# Set SCRAM architecture var +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; -# Go back to original working directory +# Go back to original working directory cd $W_DIR; -# Run get payload data script +# Run get payload data script if [ -f *.png ]; then rm *.png fi diff --git a/CondCore/SiPixelPlugins/test/test.sh b/CondCore/SiPixelPlugins/test/test.sh old mode 100644 new mode 100755 index 4aac8a63c5a3a..3541c17917347 --- a/CondCore/SiPixelPlugins/test/test.sh +++ b/CondCore/SiPixelPlugins/test/test.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh b/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh index 74020cb2c0dd0..0a8dff1b88006 100755 --- a/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh +++ b/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; @@ -37,6 +37,17 @@ getPayloadData.py \ mv *.png $W_DIR/plots_LAMap/FPixPixelLAMap.png +getPayloadData.py \ + --plugin pluginSiPixelLorentzAngle_PayloadInspector \ + --plot plot_SiPixelFullLorentzAngleMapByROC \ + --tag SiPixelLorentzAngle_v11_offline \ + --time_type Run \ + --iovs '{"start_iov": "324245", "end_iov": "324245"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_LAMap/PixelLAMap.png + getPayloadData.py \ --plugin pluginSiPixelLorentzAngle_PayloadInspector \ --plot plot_SiPixelLorentzAngleFullPixelMap \ diff --git a/CondCore/SiPixelPlugins/test/testMiscellanea.sh b/CondCore/SiPixelPlugins/test/testMiscellanea.sh index 27a2971b8bf91..2ae5130a845e6 100755 --- a/CondCore/SiPixelPlugins/test/testMiscellanea.sh +++ b/CondCore/SiPixelPlugins/test/testMiscellanea.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationForHLT.sh b/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationForHLT.sh index 9add35686d19b..4375a45c7f673 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationForHLT.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationForHLT.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationOffline.sh b/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationOffline.sh index 7f63b1110dcb9..b3a6bb0750bfa 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationOffline.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelGainCalibrationOffline.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh index bf42ab32b7fc5..0d23aaad8c61d 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testSiPixelQuality.sh b/CondCore/SiPixelPlugins/test/testSiPixelQuality.sh index 1d65b45f7fecf..29af0675f28bc 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelQuality.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelQuality.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testSiPixelQualityMap.sh b/CondCore/SiPixelPlugins/test/testSiPixelQualityMap.sh index a3920b12ab000..66bd22fb5f34e 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelQualityMap.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelQualityMap.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh index 24c9454c293c8..e87dea0971781 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh @@ -2,7 +2,7 @@ # Save current working dir so img can be outputted there later W_DIR=$(pwd); # Set SCRAM architecture var -SCRAM_ARCH=slc6_amd64_gcc630; +SCRAM_ARCH=slc7_amd64_gcc900; export SCRAM_ARCH; source /afs/cern.ch/cms/cmsset_default.sh; eval `scram run -sh`; diff --git a/DQM/TrackerRemapper/interface/Phase1PixelROCMaps.h b/DQM/TrackerRemapper/interface/Phase1PixelROCMaps.h index e4b97c1f73a33..c985b3f20aa73 100644 --- a/DQM/TrackerRemapper/interface/Phase1PixelROCMaps.h +++ b/DQM/TrackerRemapper/interface/Phase1PixelROCMaps.h @@ -32,7 +32,7 @@ namespace PixelROCMapHelper { void draw_line(double x1, double x2, double y1, double y2, int width, int style, int color); void dress_plot( - TCanvas& canv, TH2* h, int lay, int ring, int phase, bool half_shift, bool mark_zero, bool standard_palette); + TPad*& canv, TH2* h, int lay, int ring, int phase, bool half_shift, bool mark_zero, bool standard_palette); } // namespace PixelROCMapHelper /*-------------------------------------------------------------------- @@ -79,8 +79,9 @@ struct DetCoordinates { /--------------------------------------------------------------------*/ class Phase1PixelROCMaps { public: - Phase1PixelROCMaps(const char* option) + Phase1PixelROCMaps(const char* option, const std::string& zAxisTitle = "") : m_option{option}, + m_zAxisTitle{zAxisTitle}, m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { // --------------------- BOOK HISTOGRAMS @@ -90,6 +91,11 @@ class Phase1PixelROCMaps { std::string name = "occ_Layer_" + std::to_string(lay); std::string title = "; Module # ; Ladder #"; + // if a z-axis title is specified, add the z-axis title + if (!m_zAxisTitle.empty()) { + title += fmt::sprintf(" ;%s", m_zAxisTitle.c_str()); + } + h_bpix_maps[lay - 1] = std::make_shared( name.c_str(), title.c_str(), 72, -n_layers - 0.5, n_layers + 0.5, (nlad * 4 + 2), -nlad - 0.5, nlad + 0.5); } @@ -101,6 +107,11 @@ class Phase1PixelROCMaps { std::string name = "occ_ring_" + std::to_string(ring); std::string title = "; Disk # ; Blade/Panel #"; + // if a z-axis title is specified, add the z-axis title + if (!m_zAxisTitle.empty()) { + title += fmt::sprintf(" ;%s", m_zAxisTitle.c_str()); + } + h_fpix_maps[ring - 1] = std::make_shared(name.c_str(), title.c_str(), 56, -n_rings - 1.5, n_rings + 1.5, n, -y, y); } @@ -111,15 +122,16 @@ class Phase1PixelROCMaps { // Forward declarations void fillWholeModule(const uint32_t& detid, double value); void fillSelectedRocs(const uint32_t& detid, const std::bitset<16>& theROCs, double value); - void drawBarrelMaps(TCanvas& canvas); - void drawForwardMaps(TCanvas& canvas); - void drawMaps(TCanvas& canvas); + void drawBarrelMaps(TCanvas& canvas, const std::string& text = ""); + void drawForwardMaps(TCanvas& canvas, const std::string& text = ""); + void drawMaps(TCanvas& canvas, const std::string& text = ""); inline std::array, 4> getLayerMaps() { return h_bpix_maps; } inline std::array, 2> getRingMaps() { return h_fpix_maps; } private: Option_t* m_option; + std::string m_zAxisTitle; TrackerTopology m_trackerTopo; // tough luck, we can only do phase-1... @@ -151,7 +163,7 @@ class Phase1PixelROCMaps { //============================================================================ // Taken from pixel naming classes // BmO (-z-x) = 1, BmI (-z+x) = 2 , BpO (+z-x) = 3 , BpI (+z+x) = 4 - int quadrant(const DetId& detid, bool phase_) { + inline int quadrant(const DetId& detid, bool phase_) { if (detid.subdetId() == PixelSubdetector::PixelBarrel) { return PixelBarrelName(detid, &m_trackerTopo, phase_).shell(); } else { @@ -162,7 +174,7 @@ class Phase1PixelROCMaps { //============================================================================ // Online ladder convention taken from pixel naming class for barrel // Apply sign convention (- sign for BmO and BpO) - int signed_ladder(const DetId& detid, bool phase_) { + inline int signed_ladder(const DetId& detid, bool phase_) { if (detid.subdetId() != PixelSubdetector::PixelBarrel) return -9999; int signed_ladder = PixelBarrelName(detid, &m_trackerTopo, phase_).ladderName(); @@ -174,7 +186,7 @@ class Phase1PixelROCMaps { //============================================================================ // Online mdoule convention taken from pixel naming class for barrel // Apply sign convention (- sign for BmO and BmI) - int signed_module(const DetId& detid, bool phase_) { + inline int signed_module(const DetId& detid, bool phase_) { if (detid.subdetId() != PixelSubdetector::PixelBarrel) return -9999; int signed_module = PixelBarrelName(detid, &m_trackerTopo, phase_).moduleName(); @@ -190,7 +202,7 @@ class Phase1PixelROCMaps { // Panel 1 plq 1-2, Panel 2, plq 1 = Ring 1 // Panel 1 plq 3-4, Panel 2, plq 2-3 = Ring 2 // Phase 1: Using pixel naming class for endcap - int ring(const DetId& detid, bool phase_) { + inline int ring(const DetId& detid, bool phase_) { if (detid.subdetId() != PixelSubdetector::PixelEndcap) return -9999; int ring = -9999; @@ -205,7 +217,7 @@ class Phase1PixelROCMaps { //============================================================================ // Online blade convention taken from pixel naming class for endcap // Apply sign convention (- sign for BmO and BpO) - int signed_blade(const DetId& detid, bool phase_) { + inline int signed_blade(const DetId& detid, bool phase_) { if (detid.subdetId() != PixelSubdetector::PixelEndcap) return -9999; int signed_blade = PixelEndcapName(detid, &m_trackerTopo, phase_).bladeName(); @@ -215,7 +227,7 @@ class Phase1PixelROCMaps { } //============================================================================ - int signed_blade_panel(const DetId& detid, bool phase_) { + inline int signed_blade_panel(const DetId& detid, bool phase_) { if (detid.subdetId() != PixelSubdetector::PixelEndcap) return -9999; int signed_blade_panel = signed_blade(detid, phase_) + (m_trackerTopo.pxfPanel(detid) - 1); @@ -225,7 +237,7 @@ class Phase1PixelROCMaps { //============================================================================ // Online disk convention // Apply sign convention (- sign for BmO and BmI) - int signed_disk(const DetId& detid, bool phase_) { + inline int signed_disk(const DetId& detid, bool phase_) { if (detid.subdetId() != PixelSubdetector::PixelEndcap) return -9999; int signed_disk = m_trackerTopo.pxfDisk(DetId(detid)); @@ -236,7 +248,7 @@ class Phase1PixelROCMaps { //============================================================================ // Determines if the BPix ldder is inner or outer - bool isBPixOuterLadder(const DetId& detid, bool isPhase0) { + inline bool isBPixOuterLadder(const DetId& detid, bool isPhase0) { bool isOuter = false; int layer = m_trackerTopo.pxbLayer(detid.rawId()); bool odd_ladder = m_trackerTopo.pxbLadder(detid.rawId()) % 2; diff --git a/DQM/TrackerRemapper/src/Phase1PixelROCMaps.cc b/DQM/TrackerRemapper/src/Phase1PixelROCMaps.cc index 8692e1cbb01ff..f1354b62de69f 100644 --- a/DQM/TrackerRemapper/src/Phase1PixelROCMaps.cc +++ b/DQM/TrackerRemapper/src/Phase1PixelROCMaps.cc @@ -88,10 +88,10 @@ rocBins Phase1PixelROCMaps::maskedBarrelRocsToBins(DetCoordinates coord, std::bi if (myRocs.test(idx)) { ////////////////////////////////////////////////////////////////////////////////////// // | // - // In BPix Layer1 and module>0 in L2,3,4 | In BPix Layer 2,3,4 module > 0 // + // In BPix Layer1 & module > 0 in L2,3,4 | In BPix Layer 2,3,4 module < 0 // // | // // ROCs are ordered in the following | ROCs are ordered in the following // - // fashion for unplipped modules | fashion for unplipped modules // + // fashion for unflipped modules | fashion for unflipped modules // // | // // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // @@ -185,7 +185,7 @@ rocBins Phase1PixelROCMaps::maskedForwardRocsToBins(DetCoordinates coord, std::b // In FPix + (Disk 1,2,3) | In FPix - (Disk -1,-2,-3) // // | // // ROCs are ordered in the following | ROCs are ordered in the following // - // fashion for unplipped modules | fashion for unplipped modules // + // fashion for unflipped modules | fashion for unflipped modules // // | // // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // @@ -290,35 +290,54 @@ void PixelROCMapHelper::draw_line( } /*--------------------------------------------------------------------*/ -void PixelROCMapHelper::dress_plot(TCanvas& canv, +void PixelROCMapHelper::dress_plot(TPad*& canv, TH2* h, int lay, int ring = 0, int phase = 0, + bool standard_palette = true, bool half_shift = true, - bool mark_zero = true, - bool standard_palette = true) + bool mark_zero = true) /*--------------------------------------------------------------------*/ { std::string s_title; + const auto zAxisTitle = fmt::sprintf("%s", h->GetZaxis()->GetTitle()); if (lay > 0) { - canv.cd(lay); + canv->cd(lay); + canv->cd(lay)->SetTopMargin(0.05); + canv->cd(lay)->SetBottomMargin(0.07); + canv->cd(lay)->SetLeftMargin(0.1); + if (!zAxisTitle.empty()) { + h->GetZaxis()->SetTitleOffset(1.3); + h->GetZaxis()->CenterTitle(true); + canv->cd(lay)->SetRightMargin(0.14); + } else { + canv->cd(lay)->SetRightMargin(0.11); + } s_title = "Barrel Pixel Layer " + std::to_string(lay); } else { - canv.cd(ring); + canv->cd(ring); + canv->cd(ring)->SetTopMargin(0.05); + canv->cd(ring)->SetBottomMargin(0.07); + canv->cd(ring)->SetLeftMargin(0.1); + if (!zAxisTitle.empty()) { + h->GetZaxis()->SetTitleOffset(1.3); + h->GetZaxis()->CenterTitle(true); + canv->cd(ring)->SetRightMargin(0.14); + } else { + canv->cd(ring)->SetRightMargin(0.11); + } if (ring > 4) { ring = ring - 4; } s_title = "Forward Pixel Ring " + std::to_string(ring); } - gStyle->SetPadRightMargin(0.125); - if (standard_palette) { gStyle->SetPalette(1); } else { - // this is the fine gradient palette + /* const Int_t NRGBs = 5; const Int_t NCont = 255; @@ -328,6 +347,22 @@ void PixelROCMapHelper::dress_plot(TCanvas& canv, Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00}; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); + */ + + // this is the fine gradient palette (blue to red) + double max = h->GetMaximum(); + double min = h->GetMinimum(); + double val_white = 0.; + double per_white = (val_white - min) / (max - min); + + const int Number = 3; + double Red[Number] = {0., 1., 1.}; + double Green[Number] = {0., 1., 0.}; + double Blue[Number] = {1., 1., 0.}; + double Stops[Number] = {0., per_white, 1.}; + int nb = 256; + h->SetContour(nb); + TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, nb); } h->SetMarkerSize(0.7); @@ -581,53 +616,105 @@ void PixelROCMapHelper::dress_plot(TCanvas& canv, } /*--------------------------------------------------------------------*/ -void Phase1PixelROCMaps::drawBarrelMaps(TCanvas& canvas) +void Phase1PixelROCMaps::drawBarrelMaps(TCanvas& canvas, const std::string& text) /*--------------------------------------------------------------------*/ { - canvas.Divide(2, 2); - canvas.SetBottomMargin(0.11); - canvas.SetLeftMargin(0.13); - canvas.SetRightMargin(0.05); + canvas.cd(); canvas.Modified(); + + auto topPad = new TPad("pad1", "upper pad", 0.005, 0.96, 0.995, 0.995); + topPad->Draw(); + topPad->cd(); + auto ltx = TLatex(); + ltx.SetTextFont(62); + + std::size_t found = text.find("Delta"); + if (found != std::string::npos) { + ltx.SetTextSize(0.7); + } else { + ltx.SetTextSize(1.); + } + ltx.DrawLatexNDC(0.02, 0.3, text.c_str()); + + canvas.cd(); + auto bottomPad = new TPad("pad2", "lower pad", 0.005, 0.005, 0.995, 0.955); + bottomPad->Draw(); + bottomPad->cd(); + bottomPad->Divide(2, 2); for (unsigned int lay = 1; lay <= n_layers; lay++) { - PixelROCMapHelper::dress_plot(canvas, h_bpix_maps[lay - 1].get(), lay, 0, 1); + PixelROCMapHelper::dress_plot(bottomPad, h_bpix_maps[lay - 1].get(), lay, 0, 1, found == std::string::npos); } } /*--------------------------------------------------------------------*/ -void Phase1PixelROCMaps::drawForwardMaps(TCanvas& canvas) +void Phase1PixelROCMaps::drawForwardMaps(TCanvas& canvas, const std::string& text) /*--------------------------------------------------------------------*/ { - canvas.Divide(2, 1); - canvas.SetBottomMargin(0.11); - canvas.SetLeftMargin(0.13); - canvas.SetRightMargin(0.05); + canvas.cd(); canvas.Modified(); + + auto topPad = new TPad("pad1", "upper pad", 0.005, 0.94, 0.995, 0.995); + topPad->Draw(); + topPad->cd(); + auto ltx = TLatex(); + ltx.SetTextFont(62); + + std::size_t found = text.find("Delta"); + if (found != std::string::npos) { + ltx.SetTextSize(0.7); + } else { + ltx.SetTextSize(1.); + } + ltx.DrawLatexNDC(0.02, 0.3, text.c_str()); + + canvas.cd(); + auto bottomPad = new TPad("pad2", "lower pad", 0.005, 0.005, 0.995, 0.935); + bottomPad->Draw(); + bottomPad->cd(); + bottomPad->Divide(2, 1); for (unsigned int ring = 1; ring <= n_rings; ring++) { - PixelROCMapHelper::dress_plot(canvas, h_fpix_maps[ring - 1].get(), 0, ring, 1); + PixelROCMapHelper::dress_plot(bottomPad, h_fpix_maps[ring - 1].get(), 0, ring, 1, found == std::string::npos); } } /*--------------------------------------------------------------------*/ -void Phase1PixelROCMaps::drawMaps(TCanvas& canvas) +void Phase1PixelROCMaps::drawMaps(TCanvas& canvas, const std::string& text) /*--------------------------------------------------------------------*/ { - canvas.Divide(2, 3); - canvas.SetBottomMargin(0.11); - canvas.SetLeftMargin(0.13); - canvas.SetRightMargin(0.05); + canvas.cd(); canvas.Modified(); + auto topPad = new TPad("pad1", "upper pad", 0.005, 0.97, 0.995, 0.995); + topPad->Draw(); + topPad->cd(); + auto ltx = TLatex(); + ltx.SetTextFont(62); + + std::size_t found = text.find("Delta"); + if (found != std::string::npos) { + ltx.SetTextSize(0.7); + } else { + ltx.SetTextSize(1.); + } + ltx.DrawLatexNDC(0.02, 0.2, text.c_str()); + + canvas.cd(); + auto bottomPad = new TPad("pad2", "lower pad", 0.005, 0.005, 0.995, 0.97); + bottomPad->Draw(); + bottomPad->cd(); + bottomPad->Divide(2, 3); + // dress the plots for (unsigned int lay = 1; lay <= n_layers; lay++) { - PixelROCMapHelper::dress_plot(canvas, h_bpix_maps[lay - 1].get(), lay, 0, 1); + PixelROCMapHelper::dress_plot(bottomPad, h_bpix_maps[lay - 1].get(), lay, 0, 1, found == std::string::npos); } - canvas.Update(); - canvas.Modified(); - canvas.cd(); + bottomPad->Update(); + bottomPad->Modified(); + bottomPad->cd(); for (unsigned int ring = 1; ring <= n_rings; ring++) { - PixelROCMapHelper::dress_plot(canvas, h_fpix_maps[ring - 1].get(), 0, n_layers + ring, 1); + PixelROCMapHelper::dress_plot( + bottomPad, h_fpix_maps[ring - 1].get(), 0, n_layers + ring, 1, found == std::string::npos); } }