diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index 89c43b699b6a2..0197764722503 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -21,6 +21,14 @@ #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" +//#define MMDEBUG +#ifdef MMDEBUG +#include +#define COUT std::cout << "MM " +#else +#define COUT edm::LogVerbatim("") +#endif + namespace SiPixelPI { // size of the phase-0 pixel detID list @@ -130,8 +138,14 @@ namespace SiPixelPI { } //============================================================================ - void dress_occup_plot( - TCanvas& canv, TH2* h, int lay, int ring = 0, int phase = 0, bool half_shift = true, bool mark_zero = true) { + void dress_occup_plot(TCanvas& canv, + TH2* h, + int lay, + int ring = 0, + int phase = 0, + bool half_shift = true, + bool mark_zero = true, + bool standard_palette = true) { std::string s_title; if (lay > 0) { @@ -143,7 +157,21 @@ namespace SiPixelPI { } gStyle->SetPadRightMargin(0.125); - gStyle->SetPalette(1); + + if (standard_palette) { + gStyle->SetPalette(1); + } else { + // this is the fine gradient palette + const Int_t NRGBs = 5; + const Int_t NCont = 255; + + Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00}; + Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51}; + Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00}; + 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); + } h->SetMarkerSize(0.7); h->Draw("colz"); @@ -626,5 +654,225 @@ namespace SiPixelPI { return ret; } + // overloaded method: mask entire module + /*--------------------------------------------------------------------*/ + std::vector > maskedBarrelRocsToBins(int layer, int ladder, int module) + /*--------------------------------------------------------------------*/ + { + std::vector > rocsToMask; + + int nlad_list[4] = {6, 14, 22, 32}; + int nlad = nlad_list[layer - 1]; + + int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (std::abs(module))) * 8) + 1; + int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (std::abs(ladder))) * 2) + 1; + + int end_x = start_x + 7; + int end_y = start_y + 1; + + COUT << "module: " << module << " start_x:" << start_x << " end_x:" << end_x << std::endl; + COUT << "ladder: " << ladder << " start_y:" << start_y << " end_y:" << end_y << std::endl; + COUT << "==================================================================" << std::endl; + + for (int bin_x = 1; bin_x <= 72; bin_x++) { + for (int bin_y = 1; bin_y <= (nlad * 4 + 2); bin_y++) { + if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) { + rocsToMask.push_back(std::make_pair(bin_x, bin_y)); + } + } + } + return rocsToMask; + } + + // overloaded method: mask single ROCs + /*--------------------------------------------------------------------*/ + std::vector > maskedBarrelRocsToBins( + int layer, int ladder, int module, std::bitset<16> bad_rocs, bool isFlipped) + /*--------------------------------------------------------------------*/ + { + std::vector > rocsToMask; + + int nlad_list[4] = {6, 14, 22, 32}; + int nlad = nlad_list[layer - 1]; + + int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (std::abs(module))) * 8) + 1; + int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (std::abs(ladder))) * 2) + 1; + + int roc0_x = ((layer == 1) || (layer > 1 && module > 0)) ? start_x + 7 : start_x; + int roc0_y = start_y - 1; + + size_t idx = 0; + while (idx < bad_rocs.size()) { + if (bad_rocs.test(idx)) { + ////////////////////////////////////////////////////////////////////////////////////// + // | // + // In BPix Layer1 and 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 // + // | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | // + // if the module is flipped the ordering | if the module is flipped the ordering // + // is reveresed | is reversed // + // | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + ////////////////////////////////////////////////////////////////////////////////////// + + int roc_x(0), roc_y(0); + + if ((layer == 1) || (layer > 1 && module > 0)) { + if (!isFlipped) { + roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; + roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; + } else { + roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; + roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; + } + } else { + if (!isFlipped) { + roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); + roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; + } else { + roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); + roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; + } + } + + COUT << bad_rocs << " : (idx)= " << idx << std::endl; + COUT << " layer: " << layer << std::endl; + COUT << "module: " << module << " roc_x:" << roc_x << std::endl; + COUT << "ladder: " << ladder << " roc_y:" << roc_y << std::endl; + COUT << "==================================================================" << std::endl; + + rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx)); + } + ++idx; + } + return rocsToMask; + } + + // overloaded method: mask entire module + /*--------------------------------------------------------------------*/ + std::vector > maskedForwardRocsToBins(int ring, int blade, int panel, int disk) + /*--------------------------------------------------------------------*/ + { + std::vector > rocsToMask; + + //int nblade_list[2] = {11, 17}; + int nybins_list[2] = {92, 140}; + //int nblade = nblade_list[ring - 1]; + int nybins = nybins_list[ring - 1]; + + int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1; + //int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2; + int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3 + : ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3; + + int end_x = start_x + 7; + int end_y = start_y + 1; + + COUT << "==================================================================" << std::endl; + COUT << "disk: " << disk << " start_x:" << start_x << " end_x:" << end_x << std::endl; + COUT << "blade: " << blade << " start_y:" << start_y << " end_y:" << end_y << std::endl; + + for (int bin_x = 1; bin_x <= 56; bin_x++) { + for (int bin_y = 1; bin_y <= nybins; bin_y++) { + if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) { + rocsToMask.push_back(std::make_pair(bin_x, bin_y)); + } + } + } + return rocsToMask; + } + + // overloaded method: mask single ROCs + /*--------------------------------------------------------------------*/ + std::vector > maskedForwardRocsToBins( + int ring, int blade, int panel, int disk, std::bitset<16> bad_rocs, bool isFlipped) + /*--------------------------------------------------------------------*/ + { + std::vector > rocsToMask; + + //int nblade_list[2] = {11, 17}; + int nybins_list[2] = {92, 140}; + //int nblade = nblade_list[ring - 1]; + int nybins = nybins_list[ring - 1]; + + int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1; + //int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2; + int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3 + : ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3; + + int roc0_x = disk > 0 ? start_x + 7 : start_x; + int roc0_y = start_y - 1; + + size_t idx = 0; + while (idx < bad_rocs.size()) { + if (bad_rocs.test(idx)) { + int roc_x(0), roc_y(0); + + ////////////////////////////////////////////////////////////////////////////////////// + // | // + // 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 // + // | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | // + // if the module is flipped the ordering | if the module is flipped the ordering // + // is reveresed | is reversed // + // | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + // | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // + // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // + ////////////////////////////////////////////////////////////////////////////////////// + + if (disk > 0) { + if (!isFlipped) { + roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; + roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; + } else { + roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; + roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; + } + } else { + if (!isFlipped) { + roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); + roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; + } else { + roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); + roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; + } + } + + COUT << bad_rocs << " : (idx)= " << idx << std::endl; + COUT << " panel: " << panel << " isFlipped: " << isFlipped << std::endl; + COUT << " disk: " << disk << " roc_x:" << roc_x << std::endl; + COUT << " blade: " << blade << " roc_y:" << roc_y << std::endl; + COUT << "===============================" << std::endl; + + rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx)); + } + ++idx; + } + return rocsToMask; + } + }; // namespace SiPixelPI #endif diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index d38a8ebae9512..2100de9ab56f1 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -94,8 +94,7 @@ namespace { h1->SetFillColor(kRed); h1->SetMarkerStyle(20); h1->SetMarkerSize(1); - h1->Draw("HIST"); - h1->Draw("Psame"); + h1->Draw("bar2"); SiPixelPI::makeNicePlotStyle(h1.get()); @@ -186,26 +185,30 @@ namespace { hfirst->SetTitle(""); hfirst->SetFillColor(kRed); - hfirst->SetMarkerStyle(kFullCircle); - hfirst->SetMarkerSize(1.5); - hfirst->SetMarkerColor(kRed); - hfirst->Draw("HIST"); - hfirst->Draw("Psame"); + hfirst->SetBarWidth(0.95); + hfirst->Draw("histbar"); + + //hfirst->SetMarkerStyle(kFullCircle); + //hfirst->SetMarkerSize(1.5); + //hfirst->SetMarkerColor(kRed); + //hfirst->Draw("Psame"); hlast->SetTitle(""); hlast->SetFillColorAlpha(kBlue, 0.20); - hlast->SetMarkerStyle(kOpenCircle); - hlast->SetMarkerSize(1.5); - hlast->SetMarkerColor(kBlue); - hlast->Draw("HISTsame"); - hlast->Draw("Psame"); + hlast->SetBarWidth(0.95); + hlast->Draw("histbarsame"); + + //hlast->SetMarkerStyle(kOpenCircle); + //hlast->SetMarkerSize(1.5); + //hlast->SetMarkerColor(kBlue); + //hlast->Draw("Psame"); SiPixelPI::makeNicePlotStyle(hfirst.get()); SiPixelPI::makeNicePlotStyle(hlast.get()); canvas.Update(); - TLegend legend = TLegend(0.32, 0.86, 0.95, 0.94); + TLegend legend = TLegend(0.30, 0.86, 0.95, 0.94); //legend.SetHeader("#font[22]{SiPixel Lorentz Angle Comparison}", "C"); // option "C" allows to center the header //legend.AddEntry(hfirst.get(), ("IOV: " + std::to_string(std::get<0>(firstiov))).c_str(), "FL"); //legend.AddEntry(hlast.get(), ("IOV: " + std::to_string(std::get<0>(lastiov))).c_str(), "FL"); @@ -217,7 +220,7 @@ namespace { auto ltx = TLatex(); ltx.SetTextFont(62); //ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.05); + ltx.SetTextSize(0.047); ltx.SetTextAlign(11); ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, @@ -372,14 +375,13 @@ namespace { summaryFirst->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str()); // avoid filling the histogram with numerical noise float f_mean = - FirstLA_spectraByRegion[part]->GetMean() > 10.e-6 ? FirstLA_spectraByRegion[part]->GetMean() : 10.e-6; + FirstLA_spectraByRegion[part]->GetMean() > 10.e-6 ? FirstLA_spectraByRegion[part]->GetMean() : 0.; summaryFirst->SetBinContent(bin, f_mean); //summaryFirst->SetBinError(bin,LA_spectraByRegion[hash]->GetRMS()); summaryLast->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str()); // avoid filling the histogram with numerical noise - float l_mean = - LastLA_spectraByRegion[part]->GetMean() > 10.e-6 ? LastLA_spectraByRegion[part]->GetMean() : 10.e-6; + float l_mean = LastLA_spectraByRegion[part]->GetMean() > 10.e-6 ? LastLA_spectraByRegion[part]->GetMean() : 0.; summaryLast->SetBinContent(bin, l_mean); //summaryLast->SetBinError(bin,LA_spectraByRegion[hash]->GetRMS()); bin++; @@ -421,10 +423,8 @@ namespace { summaryFirst->GetYaxis()->SetRangeUser(0., std::max(0., max * 1.40)); - summaryFirst->Draw("bar2"); - summaryFirst->Draw("text90same"); - summaryLast->Draw("bar2,same"); - summaryLast->Draw("text60same"); + summaryFirst->Draw("b text0"); + summaryLast->Draw("b text0 same"); TLegend legend = TLegend(0.52, 0.80, 0.98, 0.9); legend.SetHeader("#mu_{H} value comparison", "C"); // option "C" allows to center the header @@ -459,6 +459,224 @@ namespace { SiPixelLorentzAngleByRegionComparisonTwoTags() : SiPixelLorentzAngleByRegionComparisonBase() { setTwoTags(true); } }; + /************************************************ + occupancy style map BPix + *************************************************/ + + class SiPixelBPixLorentzAngleMap : public cond::payloadInspector::PlotImage { + public: + SiPixelBPixLorentzAngleMap() + : cond::payloadInspector::PlotImage("SiPixelQuality Barrel Pixel Map"), + m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { + setSingleIov(true); + } + + bool fill(const std::vector> &iovs) override { + auto iov = iovs.front(); + std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + + static const int n_layers = 4; + int nlad_list[n_layers] = {6, 14, 22, 32}; + int divide_roc = 1; + + // --------------------- BOOK HISTOGRAMS + std::array h_bpix_LA; + + for (unsigned int lay = 1; lay <= 4; lay++) { + int nlad = nlad_list[lay - 1]; + + std::string name = "occ_LA_Layer_" + std::to_string(lay); + std::string title = "; Module # ; Ladder #"; + h_bpix_LA[lay - 1] = new TH2D(name.c_str(), + title.c_str(), + 72 * divide_roc, + -4.5, + 4.5, + (nlad * 4 + 2) * divide_roc, + -nlad - 0.5, + nlad + 0.5); + } + + std::map LAMap_ = payload->getLorentzAngles(); + + // hard-coded phase-I + std::array minima = {{999., 999., 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)); + auto s_ladder = SiPixelPI::signed_ladder(DetId(element.first), m_trackerTopo, true); + auto s_module = SiPixelPI::signed_module(DetId(element.first), m_trackerTopo, true); + + auto ladder = m_trackerTopo.pxbLadder(DetId(element.first)); + auto module = m_trackerTopo.pxbModule(DetId(element.first)); + COUT << "layer:" << layer << " ladder:" << ladder << " module:" << module << " signed ladder: " << s_ladder + << " signed module: " << s_module << std::endl; + + if (element.second < minima.at(layer - 1)) + minima.at(layer - 1) = element.second; + + auto rocsToMask = SiPixelPI::maskedBarrelRocsToBins(layer, s_ladder, s_module); + for (const auto &bin : rocsToMask) { + h_bpix_LA[layer - 1]->SetBinContent(bin.first, bin.second, element.second); + } + } + } + + gStyle->SetOptStat(0); + //========================= + TCanvas canvas("Summary", "Summary", 1200, 1200); + canvas.Divide(2, 2); + + for (unsigned int lay = 1; lay <= 4; lay++) { + canvas.cd(lay)->SetBottomMargin(0.08); + canvas.cd(lay)->SetLeftMargin(0.1); + canvas.cd(lay)->SetRightMargin(0.13); + + COUT << " layer:" << lay << " max:" << h_bpix_LA[lay - 1]->GetMaximum() << " min: " << minima.at(lay - 1) + << std::endl; + + SiPixelPI::dress_occup_plot(canvas, h_bpix_LA[lay - 1], lay, 0, 1, true, true, false); + h_bpix_LA[lay - 1]->GetZaxis()->SetRangeUser(minima.at(lay - 1) - 0.001, + h_bpix_LA[lay - 1]->GetMaximum() + 0.001); + } + + 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 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 + *************************************************/ + + class SiPixelFPixLorentzAngleMap : public cond::payloadInspector::PlotImage { + public: + SiPixelFPixLorentzAngleMap() + : cond::payloadInspector::PlotImage("SiPixelQuality Forward Pixel Map"), + m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { + setSingleIov(true); + } + + bool fill(const std::vector> &iovs) override { + auto iov = iovs.front(); + std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + + static const int n_rings = 2; + std::array h_fpix_LA; + int divide_roc = 1; + + // --------------------- BOOK HISTOGRAMS + for (unsigned int ring = 1; ring <= n_rings; ring++) { + int n = ring == 1 ? 92 : 140; + float y = ring == 1 ? 11.5 : 17.5; + std::string name = "occ_LA_ring_" + std::to_string(ring); + std::string title = "; Disk # ; Blade/Panel #"; + + h_fpix_LA[ring - 1] = new TH2D(name.c_str(), title.c_str(), 56 * divide_roc, -3.5, 3.5, n * divide_roc, -y, y); + } + + std::map LAMap_ = payload->getLorentzAngles(); + + // 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); + auto s_blade = SiPixelPI::signed_blade(DetId(element.first), m_trackerTopo, true); + auto s_disk = SiPixelPI::signed_disk(DetId(element.first), m_trackerTopo, true); + auto s_blade_panel = SiPixelPI::signed_blade_panel(DetId(element.first), m_trackerTopo, true); + auto panel = m_trackerTopo.pxfPanel(element.first); + + COUT << "ring:" << ring << " blade: " << s_blade << " panel: " << panel + << " signed blade/panel: " << s_blade_panel << " disk: " << s_disk << std::endl; + + if (element.second < minima.at(ring - 1)) + minima.at(ring - 1) = element.second; + + auto rocsToMask = SiPixelPI::maskedForwardRocsToBins(ring, s_blade, panel, s_disk); + for (const auto &bin : rocsToMask) { + h_fpix_LA[ring - 1]->SetBinContent(bin.first, bin.second, element.second); + } + } + } + + gStyle->SetOptStat(0); + //========================= + TCanvas canvas("Summary", "Summary", 1200, 600); + canvas.Divide(2, 1); + + 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); + + COUT << " ringer:" << ring << " max:" << h_fpix_LA[ring - 1]->GetMaximum() << " min: " << minima.at(ring - 1) + << std::endl; + + SiPixelPI::dress_occup_plot(canvas, h_fpix_LA[ring - 1], 0, ring, 1, true, true, false); + 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()); + } + + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); +#ifdef MMDEBUG + canvas.SaveAs("outFPix.root"); +#endif + + return true; + } + + private: + TrackerTopology m_trackerTopo; + }; + } // namespace PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) { @@ -468,4 +686,6 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) { PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValueComparisonTwoTags); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleByRegionComparisonSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleByRegionComparisonTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelBPixLorentzAngleMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelFPixLorentzAngleMap); } diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc index 0ced315fb4822..fbf30d2927bd4 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc @@ -36,14 +36,6 @@ #include "TPave.h" #include "TPaveStats.h" -// #define MMDEBUG -#ifdef MMDEBUG -#include -#define COUT std::cout << "MM " -#else -#define COUT edm::LogVerbatim("") -#endif - namespace { /************************************************ @@ -208,12 +200,12 @@ namespace { << " signed module: " << s_module << std::endl; if (payload->IsModuleBad(mod.DetID)) { - auto rocsToMask = maskedBarrelRocsToBins(layer, s_ladder, s_module); + auto rocsToMask = SiPixelPI::maskedBarrelRocsToBins(layer, s_ladder, s_module); for (const auto& bin : rocsToMask) { h_bpix_occ[layer - 1]->SetBinContent(bin.first, bin.second, 1); } } else { - auto rocsToMask = maskedBarrelRocsToBins(layer, s_ladder, s_module, bad_rocs, isFlipped); + auto rocsToMask = SiPixelPI::maskedBarrelRocsToBins(layer, s_ladder, s_module, bad_rocs, isFlipped); for (const auto& bin : rocsToMask) { h_bpix_occ[layer - 1]->SetBinContent(std::get<0>(bin), std::get<1>(bin), 1); } @@ -241,11 +233,13 @@ namespace { auto ltx = TLatex(); ltx.SetTextFont(62); ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.06); + ltx.SetTextSize(0.055); ltx.SetTextAlign(11); ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, - (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + 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(m_imageFileName); @@ -257,106 +251,6 @@ namespace { return true; } - // #============================================================================ - std::vector > maskedBarrelRocsToBins(int layer, int ladder, int module) { - std::vector > rocsToMask; - - int nlad_list[4] = {6, 14, 22, 32}; - int nlad = nlad_list[layer - 1]; - - int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (std::abs(module))) * 8) + 1; - int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (std::abs(ladder))) * 2) + 1; - - int end_x = start_x + 7; - int end_y = start_y + 1; - - COUT << "module: " << module << " start_x:" << start_x << " end_x:" << end_x << std::endl; - COUT << "ladder: " << ladder << " start_y:" << start_y << " end_y:" << end_y << std::endl; - COUT << "==================================================================" << std::endl; - - for (int bin_x = 1; bin_x <= 72; bin_x++) { - for (int bin_y = 1; bin_y <= (nlad * 4 + 2); bin_y++) { - if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) { - rocsToMask.push_back(std::make_pair(bin_x, bin_y)); - } - } - } - return rocsToMask; - } - - // #============================================================================ - std::vector > maskedBarrelRocsToBins( - int layer, int ladder, int module, std::bitset<16> bad_rocs, bool isFlipped) { - std::vector > rocsToMask; - - int nlad_list[4] = {6, 14, 22, 32}; - int nlad = nlad_list[layer - 1]; - - int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (std::abs(module))) * 8) + 1; - int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (std::abs(ladder))) * 2) + 1; - - int roc0_x = ((layer == 1) || (layer > 1 && module > 0)) ? start_x + 7 : start_x; - int roc0_y = start_y - 1; - - size_t idx = 0; - while (idx < bad_rocs.size()) { - if (bad_rocs.test(idx)) { - ////////////////////////////////////////////////////////////////////////////////////// - // | // - // In BPix Layer1 and 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 // - // | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | // - // if the module is flipped the ordering | if the module is flipped the ordering // - // is reveresed | is reversed // - // | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - ////////////////////////////////////////////////////////////////////////////////////// - - int roc_x(0), roc_y(0); - - if ((layer == 1) || (layer > 1 && module > 0)) { - if (!isFlipped) { - roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; - roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; - } else { - roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; - roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; - } - } else { - if (!isFlipped) { - roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); - roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; - } else { - roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); - roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; - } - } - - COUT << bad_rocs << " : (idx)= " << idx << std::endl; - COUT << " layer: " << layer << std::endl; - COUT << "module: " << module << " roc_x:" << roc_x << std::endl; - COUT << "ladder: " << ladder << " roc_y:" << roc_y << std::endl; - COUT << "==================================================================" << std::endl; - - rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx)); - } - ++idx; - } - return rocsToMask; - } - private: TrackerTopology m_trackerTopo; }; @@ -411,12 +305,12 @@ namespace { << " signed blade/panel: " << s_blade_panel << " disk: " << s_disk << std::endl; if (payload->IsModuleBad(mod.DetID)) { - auto rocsToMask = maskedForwardRocsToBins(ring, s_blade, panel, s_disk); + auto rocsToMask = SiPixelPI::maskedForwardRocsToBins(ring, s_blade, panel, s_disk); for (const auto& bin : rocsToMask) { h_fpix_occ[ring - 1]->SetBinContent(bin.first, bin.second, 1); } } else { - auto rocsToMask = maskedForwardRocsToBins(ring, s_blade, panel, s_disk, bad_rocs, isFlipped); + auto rocsToMask = SiPixelPI::maskedForwardRocsToBins(ring, s_blade, panel, s_disk, bad_rocs, isFlipped); for (const auto& bin : rocsToMask) { h_fpix_occ[ring - 1]->SetBinContent(std::get<0>(bin), std::get<1>(bin), 1); } @@ -444,11 +338,13 @@ namespace { auto ltx = TLatex(); ltx.SetTextFont(62); ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.06); + ltx.SetTextSize(0.050); ltx.SetTextAlign(11); ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, - (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str()); + 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(m_imageFileName); @@ -459,114 +355,6 @@ namespace { return true; } - // #============================================================================ - std::vector > maskedForwardRocsToBins(int ring, int blade, int panel, int disk) { - std::vector > rocsToMask; - - //int nblade_list[2] = {11, 17}; - int nybins_list[2] = {92, 140}; - //int nblade = nblade_list[ring - 1]; - int nybins = nybins_list[ring - 1]; - - int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1; - //int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2; - int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3 - : ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3; - - int end_x = start_x + 7; - int end_y = start_y + 1; - - COUT << "==================================================================" << std::endl; - COUT << "disk: " << disk << " start_x:" << start_x << " end_x:" << end_x << std::endl; - COUT << "blade: " << blade << " start_y:" << start_y << " end_y:" << end_y << std::endl; - - for (int bin_x = 1; bin_x <= 56; bin_x++) { - for (int bin_y = 1; bin_y <= nybins; bin_y++) { - if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) { - rocsToMask.push_back(std::make_pair(bin_x, bin_y)); - } - } - } - return rocsToMask; - } - - // #============================================================================ - std::vector > maskedForwardRocsToBins( - int ring, int blade, int panel, int disk, std::bitset<16> bad_rocs, bool isFlipped) { - std::vector > rocsToMask; - - //int nblade_list[2] = {11, 17}; - int nybins_list[2] = {92, 140}; - //int nblade = nblade_list[ring - 1]; - int nybins = nybins_list[ring - 1]; - - int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1; - //int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2; - int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3 - : ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3; - - int roc0_x = disk > 0 ? start_x + 7 : start_x; - int roc0_y = start_y - 1; - - size_t idx = 0; - while (idx < bad_rocs.size()) { - if (bad_rocs.test(idx)) { - int roc_x(0), roc_y(0); - - ////////////////////////////////////////////////////////////////////////////////////// - // | // - // 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 // - // | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | // - // if the module is flipped the ordering | if the module is flipped the ordering // - // is reveresed | is reversed // - // | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - // | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | // - // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ // - ////////////////////////////////////////////////////////////////////////////////////// - - if (disk > 0) { - if (!isFlipped) { - roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; - roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; - } else { - roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx; - roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; - } - } else { - if (!isFlipped) { - roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); - roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2; - } else { - roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8); - roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1; - } - } - - COUT << bad_rocs << " : (idx)= " << idx << std::endl; - COUT << " panel: " << panel << " isFlipped: " << isFlipped << std::endl; - COUT << " disk: " << disk << " roc_x:" << roc_x << std::endl; - COUT << " blade: " << blade << " roc_y:" << roc_y << std::endl; - COUT << "===============================" << std::endl; - - rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx)); - } - ++idx; - } - return rocsToMask; - } - private: TrackerTopology m_trackerTopo; }; diff --git a/CondCore/SiPixelPlugins/test/BuildFile.xml b/CondCore/SiPixelPlugins/test/BuildFile.xml new file mode 100644 index 0000000000000..5d4692caf043f --- /dev/null +++ b/CondCore/SiPixelPlugins/test/BuildFile.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh b/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh new file mode 100755 index 0000000000000..d9e6c29db7d76 --- /dev/null +++ b/CondCore/SiPixelPlugins/test/testLorentzAngleMap.sh @@ -0,0 +1,17 @@ +#!/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; +export SCRAM_ARCH; +source /afs/cern.ch/cms/cmsset_default.sh; +eval `scram run -sh`; + +getPayloadData.py --plugin pluginSiPixelLorentzAngle_PayloadInspector --plot plot_SiPixelBPixLorentzAngleMap --tag SiPixelLorentzAngle_v11_offline --time_type Run --iovs '{"start_iov": "324245", "end_iov": "324245"}' --db Prod --test ; + +mv *.png $HOME/www/display/BPixPixelLAMap.png + + +getPayloadData.py --plugin pluginSiPixelLorentzAngle_PayloadInspector --plot plot_SiPixelFPixLorentzAngleMap --tag SiPixelLorentzAngle_v11_offline --time_type Run --iovs '{"start_iov": "324245", "end_iov": "324245"}' --db Prod --test ; + +mv *.png $HOME/www/display/FPixPixelLAMap.png diff --git a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh index 88570d69d9108..2392ffdaeb478 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh @@ -65,3 +65,13 @@ getPayloadData.py \ mv *.png $W_DIR/plots_LA/comparisonByRegionPhase0.png +getPayloadData.py \ + --plugin pluginSiPixelLorentzAngle_PayloadInspector \ + --plot plot_SiPixelBPixLorentzAngleMap \ + --tag SiPixelLorentzAngle_v11_offline \ + --time_type Run \ + --iovs '{"start_iov": "324245", "end_iov": "324245"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_LA/SiPixelBPixLorentzAngleMap.png diff --git a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp new file mode 100644 index 0000000000000..e6a9eb073384e --- /dev/null +++ b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp @@ -0,0 +1,81 @@ +#include +#include +#include "CondCore/Utilities/interface/PayloadInspector.h" +#include "CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc" +#include "CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc" +#include "FWCore/PluginManager/interface/PluginManager.h" +#include "FWCore/PluginManager/interface/standard.h" +#include "FWCore/PluginManager/interface/SharedLibrary.h" +#include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" + +int main(int argc, char** argv) { + edmplugin::PluginManager::Config config; + edmplugin::PluginManager::configure(edmplugin::standard::config()); + + std::vector psets; + edm::ParameterSet pSet; + pSet.addParameter("@service_type", std::string("SiteLocalConfigService")); + psets.push_back(pSet); + edm::ServiceToken servToken(edm::ServiceRegistry::createSet(psets)); + edm::ServiceRegistry::Operate operate(servToken); + + std::string connectionString("frontier://FrontierProd/CMS_CONDITIONS"); + + // Lorentz Angle + + std::string tag = "SiPixelLorentzAngle_v11_offline"; + std::string runTimeType = cond::time::timeTypeName(cond::runnumber); + cond::Time_t start = boost::lexical_cast(303790); + cond::Time_t end = boost::lexical_cast(324245); + + std::cout << "## Exercising Lorentz Angle plots " << std::endl; + + SiPixelLorentzAngleValues histo1; + histo1.process(connectionString, tag, runTimeType, start, start); + std::cout << histo1.data() << std::endl; + + SiPixelLorentzAngleValueComparisonSingleTag histo2; + histo2.process(connectionString, tag, runTimeType, start, end); + std::cout << histo2.data() << std::endl; + + SiPixelLorentzAngleByRegionComparisonSingleTag histo3; + histo3.process(connectionString, tag, runTimeType, start, end); + std::cout << histo3.data() << std::endl; + + SiPixelBPixLorentzAngleMap histo4; + histo4.process(connectionString, tag, runTimeType, start, start); + std::cout << histo4.data() << std::endl; + + SiPixelFPixLorentzAngleMap histo5; + histo5.process(connectionString, tag, runTimeType, end, end); + std::cout << histo5.data() << std::endl; + + // 2 tags comparisons + + std::string tag2 = "SiPixelLorentzAngle_2016_ultralegacymc_v2"; + cond::Time_t start2 = boost::lexical_cast(1); + + SiPixelLorentzAngleValueComparisonTwoTags histo6; + histo6.processTwoTags(connectionString, tag, tag2, start, start2); + std::cout << histo6.data() << std::endl; + + SiPixelLorentzAngleByRegionComparisonTwoTags histo7; + histo7.processTwoTags(connectionString, tag, tag2, start, start2); + std::cout << histo7.data() << std::endl; + + // SiPixelQuality + + tag = "SiPixelQuality_forDigitizer_phase1_2018_permanentlyBad"; + start = boost::lexical_cast(1); + end = boost::lexical_cast(1); + + std::cout << "## Exercising SiPixelQuality plots " << std::endl; + + SiPixelBPixQualityMap histo8; + histo8.process(connectionString, tag, runTimeType, start, start); + std::cout << histo8.data() << std::endl; + + SiPixelFPixQualityMap histo9; + histo9.process(connectionString, tag, runTimeType, start, start); + std::cout << histo9.data() << std::endl; +}