From 721461e66752bb16930f537743b7f0e36c424fc0 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 16 Apr 2020 21:12:21 +0200 Subject: [PATCH 01/32] testing --- CondCore/SiPixelPlugins/plugins/BuildFile.xml | 9 ++ .../SiPixelQuality_PayloadInspector.cc | 2 +- ...iPixelTemplateDBObject_PayloadInspector.cc | 88 +++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc diff --git a/CondCore/SiPixelPlugins/plugins/BuildFile.xml b/CondCore/SiPixelPlugins/plugins/BuildFile.xml index 1525fdc22cff4..b645ea6df98ab 100644 --- a/CondCore/SiPixelPlugins/plugins/BuildFile.xml +++ b/CondCore/SiPixelPlugins/plugins/BuildFile.xml @@ -29,3 +29,12 @@ + + + + + + + + + diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc index fbf30d2927bd4..b93f17014b866 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc @@ -1,5 +1,5 @@ /*! - \file SiPixelQulity_PayloadInspector + \file SiPixelQuality_PayloadInspector \Payload Inspector Plugin for SiPixelQuality \author M. Musich \version $Revision: 1.0 $ diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc new file mode 100644 index 0000000000000..307935b56ca8e --- /dev/null +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -0,0 +1,88 @@ +/*! + \file SiPixelTemplateDBObject_PayloadInspector + \Payload Inspector Plugin for SiPixelTemplateDBObject + \author M. Musich + \version $Revision: 1.0 $ + \date $Date: 2020/04/16 18:00:00 $ +*/ + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondCore/Utilities/interface/PayloadInspectorModule.h" +#include "CondCore/Utilities/interface/PayloadInspector.h" +#include "CondCore/CondDB/interface/Time.h" +#include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h" + +// the data format of the condition to be inspected +#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" +#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include +#include +#include + +// include ROOT +#include "TH2F.h" +#include "TLegend.h" +#include "TCanvas.h" +#include "TLine.h" +#include "TGraph.h" +#include "TStyle.h" +#include "TLatex.h" +#include "TPave.h" +#include "TPaveStats.h" + +namespace { + + /************************************************ + test class + *************************************************/ + + class SiPixelTemplateDBObjectTest : public cond::payloadInspector::Histogram1D { + public: + SiPixelTemplateDBObjectTest() + : cond::payloadInspector::Histogram1D( + "SiPixelTemplateDBObject test", "SiPixelTemplateDBObject test", 10, 0.0, 100.) { + Base::setSingleIov(true); + } + + bool fill(const std::vector >& iovs) override { + for (auto const& iov : iovs) { + std::vector thePixelTemp_; + + std::shared_ptr payload = Base::fetchPayload(std::get<1>(iov)); + if (payload.get()) { + if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { + throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; + } + + SiPixelTemplate templ(thePixelTemp_); + + std::map templMap = payload->getTemplateIDs(); + for (auto const& entry : templMap) { + std::cout << "DetID: " << entry.first << " template ID: " << entry.second << std::endl; + templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f); + + std::cout << "\t lorywidth " << templ.lorywidth() << " lorxwidth: " << templ.lorxwidth() << " lorybias " + << templ.lorybias() << " lorxbias: " << templ.lorxbias() << "\n" + << std::endl; + } + + fillWithValue(1.); + + } // payload + } // iovs + return true; + } // fill + }; +} // namespace + +// Register the classes as boost python plugin +PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) { PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest); } From 4dba88aec176fda592b2443eb8219947f536fb93 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 17 Apr 2020 16:40:26 +0200 Subject: [PATCH 02/32] TH2Poly maps WIP --- .../interface/Phase1PixelMaps.h | 231 ++++++++++++++++++ .../interface/SiPixelPayloadInspectorHelper.h | 85 ++++++- ...iPixelTemplateDBObject_PayloadInspector.cc | 204 +++++++++++++++- .../test/testSiPixelTemplateDBObject.sh | 38 +++ 4 files changed, 546 insertions(+), 12 deletions(-) create mode 100644 CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h create mode 100644 CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh diff --git a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h new file mode 100644 index 0000000000000..b58a18fe367ac --- /dev/null +++ b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h @@ -0,0 +1,231 @@ +#ifndef CONDCORE_SIPIXELPLUGINS_PHASE1PIXELMAPS_H +#define CONDCORE_SIPIXELPLUGINS_PHASE1PIXELMAPS_H + +#include "TH2Poly.h" +#include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h" +#include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h" + +/*-------------------------------------------------------------------- +/ Ancillary class to build pixel phase-1 tracker maps +/--------------------------------------------------------------------*/ +class Phase1PixelMaps { +public: + Phase1PixelMaps(const char* option) : + m_option{option}, + m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} + { + // store the file in path for the corners (BPIX) + for (unsigned int i = 1; i <= 4; i++) { + m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i))); + } + + // store the file in path for the corners (BPIX) + for (int j : {-3, -2, -1, 1, 2, 3}) { + m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j))); + } + } + + ~Phase1PixelMaps(){} + + //============================================================================ + void bookBarrelHistograms(const std::string& currentHistoName) { + std::string histName; + TH2Poly* th2p; + + for (unsigned i = 0; i < 4; ++i) { + histName = "barrel_layer_"; + + th2p = new TH2Poly( + (histName + std::to_string(i + 1)).c_str(), Form("PXBMap - Layer %i", i + 1), -15.0, 15.0, 0.0, 5.0); + + th2p->SetFloat(); + + th2p->GetXaxis()->SetTitle("z [cm]"); + th2p->GetYaxis()->SetTitle("ladder"); + th2p->SetStats(false); + th2p->SetOption(m_option); + th2PolyBarrel[currentHistoName].push_back(th2p); + } + + th2p = new TH2Poly("barrel_summary", "PXBMap", -5.0, 5.0, 0.0, 5.0); + th2p->SetFloat(); + + th2p->GetXaxis()->SetTitle(""); + th2p->GetYaxis()->SetTitle("~ladder"); + th2p->SetStats(false); + th2p->SetOption(m_option); + th2PolyBarrelSummary[currentHistoName] = th2p; + } + + //============================================================================ + void bookForwardHistograms(const std::string& currentHistoName) { + std::string histName; + TH2Poly* th2p; + + for (unsigned side = 1; side <= 2; ++side) { + for (unsigned disk = 1; disk <= 3; ++disk) { + histName = "forward_disk_"; + + th2p = new TH2Poly((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), + Form("PXFMap - Side %i Disk %i", side, disk), + -15.0, + 15.0, + -15.0, + 15.0); + th2p->SetFloat(); + th2p->GetXaxis()->SetTitle("x [cm]"); + th2p->GetYaxis()->SetTitle("y [cm]"); + th2p->SetStats(false); + th2p->SetOption(m_option); + pxfTh2PolyForward[currentHistoName].push_back(th2p); + } + } + + th2p = new TH2Poly("forward_summary", "PXFMap", -40.0, 50.0, -20.0, 90.0); + th2p->SetFloat(); + + th2p->GetXaxis()->SetTitle(""); + th2p->GetYaxis()->SetTitle(""); + th2p->SetStats(false); + th2p->SetOption(m_option); + pxfTh2PolyForwardSummary[currentHistoName] = th2p; + } + + //============================================================================ + void bookBarrelBins(const std::string& currentHistoName) { + + auto theIndexedCorners = SiPixelPI::retrieveCorners(m_cornersBPIX, 4); + + for (const auto& entry : theIndexedCorners) { + auto id = entry.first; + auto detid = DetId(id); + if (detid.subdetId() != PixelSubdetector::PixelBarrel) + continue; + + int layer = m_trackerTopo.pxbLayer(detid); + int ladder = m_trackerTopo.pxbLadder(detid); + + auto theVectX = entry.second.first; + auto theVectY = entry.second.second; + + float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]}; + float vertY[] = {(ladder - 1.0f), (ladder - 1.0f), (float)ladder, (float)ladder, (ladder - 1.0f)}; + + bins[id] = new TGraph(5, vertX, vertY); + bins[id]->SetName(TString::Format("%u", id)); + + // Summary plot + for (unsigned k = 0; k < 5; ++k) { + vertX[k] += ((layer == 2 || layer == 3) ? 0.0f : -60.0f); + vertY[k] += ((layer > 2) ? 30.0f : 0.0f); + } + + binsSummary[id] = new TGraph(5, vertX, vertY); + binsSummary[id]->SetName(TString::Format("%u", id)); + + th2PolyBarrel[currentHistoName][layer - 1]->AddBin(bins[id]->Clone()); + th2PolyBarrelSummary[currentHistoName]->AddBin(binsSummary[id]->Clone()); + } + } + + //============================================================================ + void bookForwardBins(const std::string& currentHistoName) { + + auto theIndexedCorners = SiPixelPI::retrieveCorners(m_cornersFPIX, 3); + + for (const auto& entry : theIndexedCorners) { + auto id = entry.first; + auto detid = DetId(id); + if (detid.subdetId() != PixelSubdetector::PixelEndcap) + continue; + + int disk = m_trackerTopo.pxfDisk(detid); + int side = m_trackerTopo.pxfSide(detid); + + unsigned mapIdx = disk + (side - 1) * 3 - 1; + + auto theVectX = entry.second.first; + auto theVectY = entry.second.second; + + float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]}; + float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]}; + + bins[id] = new TGraph(4, vertX, vertY); + bins[id]->SetName(TString::Format("%u", id)); + + // Summary plot + for (unsigned k = 0; k < 4; ++k) { + vertX[k] += (float(side) - 1.5f) * 40.0f; + vertY[k] += (disk - 1) * 35.0f; + } + + binsSummary[id] = new TGraph(4, vertX, vertY); + binsSummary[id]->SetName(TString::Format("%u", id)); + + pxfTh2PolyForward[currentHistoName][mapIdx]->AddBin(bins[id]->Clone()); + pxfTh2PolyForwardSummary[currentHistoName]->AddBin(binsSummary[id]->Clone()); + } + } + + //============================================================================ + template + void fillBarrelBin(const std::string& currentHistoName, + unsigned int id, + type value){ + int layer = m_trackerTopo.pxbLayer(id); + th2PolyBarrel[currentHistoName][layer - 1]->Fill(TString::Format("%u", id), value); + } + + //============================================================================ + template + void fillEndcapBin(const std::string& currentHistoName, + unsigned int id, + type value){ + int disk = m_trackerTopo.pxfDisk(id); + int side = m_trackerTopo.pxfSide(id); + unsigned mapIdx = disk + (side - 1) * 3 - 1; + pxfTh2PolyForward[currentHistoName][mapIdx]->Fill(TString::Format("%u", id), value); + } + + //============================================================================ + void DrawBarrelMaps(const std::string& currentHistoName, + TCanvas &canvas){ + canvas.Divide(2, 2); + for (int i = 1; i <= 4; i++) { + canvas.cd(i); + if( strcmp(m_option, "text") == 0){ + th2PolyBarrel[currentHistoName].at(i-1)->SetMarkerColor(kRed); + } + th2PolyBarrel[currentHistoName].at(i-1)->Draw(); + } + } + + //============================================================================ + void DrawEndcapMaps(const std::string& currentHistoName, + TCanvas &canvas){ + canvas.Divide(3, 2); + for (int i = 1; i <= 6; i++) { + canvas.cd(i); + if( strcmp(m_option, "text") == 0){ + pxfTh2PolyForward[currentHistoName].at(i-1)->SetMarkerColor(kRed); + } + pxfTh2PolyForward[currentHistoName].at(i-1)->Draw(); + } + } + +private: + Option_t* m_option; + TrackerTopology m_trackerTopo; + + std::map bins, binsSummary; + std::map> th2PolyBarrel; + std::map th2PolyBarrelSummary; + std::map> pxfTh2PolyForward; + std::map pxfTh2PolyForwardSummary; + + std::vector m_cornersBPIX; + std::vector m_cornersFPIX; +}; + + +#endif diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index cd9c4abf51d28..b88c9e1c4559d 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -4,6 +4,9 @@ #include #include #include +#include +#include + #include "TGraph.h" #include "TH1.h" #include "TH2.h" @@ -14,8 +17,10 @@ #include "TPaveText.h" #include "TStyle.h" #include "TCanvas.h" + #include "CondCore/CondDB/interface/Time.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" @@ -186,7 +191,7 @@ namespace SiPixelPI { // Draw Lines around modules if (lay > 0) { - std::vector > nladder = {{10, 16, 22}, {6, 14, 22, 32}}; + std::vector> nladder = {{10, 16, 22}, {6, 14, 22, 32}}; int nlad = nladder[phase][lay - 1]; for (int xsign = -1; xsign <= 1; xsign += 2) for (int ysign = -1; ysign <= 1; ysign += 2) { @@ -688,10 +693,10 @@ namespace SiPixelPI { // overloaded method: mask entire module /*--------------------------------------------------------------------*/ - std::vector > maskedBarrelRocsToBins(int layer, int ladder, int module) + std::vector> maskedBarrelRocsToBins(int layer, int ladder, int module) /*--------------------------------------------------------------------*/ { - std::vector > rocsToMask; + std::vector> rocsToMask; int nlad_list[4] = {6, 14, 22, 32}; int nlad = nlad_list[layer - 1]; @@ -718,11 +723,11 @@ namespace SiPixelPI { // overloaded method: mask single ROCs /*--------------------------------------------------------------------*/ - std::vector > maskedBarrelRocsToBins( + std::vector> maskedBarrelRocsToBins( int layer, int ladder, int module, std::bitset<16> bad_rocs, bool isFlipped) /*--------------------------------------------------------------------*/ { - std::vector > rocsToMask; + std::vector> rocsToMask; int nlad_list[4] = {6, 14, 22, 32}; int nlad = nlad_list[layer - 1]; @@ -794,10 +799,10 @@ namespace SiPixelPI { // overloaded method: mask entire module /*--------------------------------------------------------------------*/ - std::vector > maskedForwardRocsToBins(int ring, int blade, int panel, int disk) + std::vector> maskedForwardRocsToBins(int ring, int blade, int panel, int disk) /*--------------------------------------------------------------------*/ { - std::vector > rocsToMask; + std::vector> rocsToMask; //int nblade_list[2] = {11, 17}; int nybins_list[2] = {92, 140}; @@ -828,11 +833,11 @@ namespace SiPixelPI { // overloaded method: mask single ROCs /*--------------------------------------------------------------------*/ - std::vector > maskedForwardRocsToBins( + std::vector> maskedForwardRocsToBins( int ring, int blade, int panel, int disk, std::bitset<16> bad_rocs, bool isFlipped) /*--------------------------------------------------------------------*/ { - std::vector > rocsToMask; + std::vector> rocsToMask; //int nblade_list[2] = {11, 17}; int nybins_list[2] = {92, 140}; @@ -906,5 +911,67 @@ namespace SiPixelPI { return rocsToMask; } + using indexedCorners = std::map, std::vector>>; + + /*--------------------------------------------------------------------*/ + const indexedCorners retrieveCorners(const std::vector& cornerFiles, const unsigned int reads) + /*--------------------------------------------------------------------*/ + { + indexedCorners theOutMap; + + for (const auto& file : cornerFiles) { + auto cornerFileName = file.fullPath(); + std::ifstream cornerFile(cornerFileName.c_str()); + if (!cornerFile.good()) { + throw cms::Exception("FileError") << "Problem opening corner file: " << cornerFileName; + } + std::string line; + while (std::getline(cornerFile, line)) { + if (!line.empty()) { + std::istringstream iss(line); + unsigned int id; + std::string name; + std::vector corners(reads, ""); + std::vector xP, yP; + + iss >> id >> name; + for (unsigned int i = 0; i < reads; ++i) { + iss >> corners.at(i); + } + + COUT << id << " : "; + for (unsigned int i = 0; i < reads; i++) { + // remove the leading and trailing " signs in the corners list + (corners[i]).erase(std::remove(corners[i].begin(), corners[i].end(), '"'), corners[i].end()); + COUT << corners.at(i) << " "; + typedef boost::tokenizer> tokenizer; + boost::char_separator sep{","}; + tokenizer tok{corners.at(i), sep}; + for (const auto& t : tok | boost::adaptors::indexed(0)) { + if (t.index() == 0) { + xP.push_back(atof((t.value()).c_str())); + } else if (t.index() == 1) { + yP.push_back(atof((t.value()).c_str())); + } else { + edm::LogError("LogicError") << "There should not be any token with index " << t.index() << std::endl; + } + } + } + COUT << std::endl; + + xP.push_back(xP.front()); + yP.push_back(yP.front()); + + for (unsigned int i = 0; i < xP.size(); i++) { + COUT << "x[" << i << "]=" << xP[i] << " y[" << i << "]" << yP[i] << std::endl; + } + + theOutMap[id] = std::make_pair(xP, yP); + + } // if line is empty + } // loop on lines + } // loop on files + return theOutMap; + } }; // namespace SiPixelPI #endif diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 307935b56ca8e..afbd58b1eae9c 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -12,7 +12,8 @@ #include "CondCore/Utilities/interface/PayloadInspector.h" #include "CondCore/CondDB/interface/Time.h" #include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h" + #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h" // the data format of the condition to be inspected @@ -23,10 +24,16 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include +#include #include #include +#include // include ROOT +#include "TH2.h" +#include "TProfile2D.h" +#include "TH2Poly.h" +#include "TGraph.h" #include "TH2F.h" #include "TLegend.h" #include "TCanvas.h" @@ -51,7 +58,7 @@ namespace { Base::setSingleIov(true); } - bool fill(const std::vector >& iovs) override { + bool fill(const std::vector>& iovs) override { for (auto const& iov : iovs) { std::vector thePixelTemp_; @@ -65,6 +72,23 @@ namespace { SiPixelTemplate templ(thePixelTemp_); + for (const auto& theTemp : thePixelTemp_) { + std::cout << "\n\n" + << "Template ID = " << theTemp.head.ID << ", Template Version " << theTemp.head.templ_version + << ", Bfield = " << theTemp.head.Bfield << ", NTy = " << theTemp.head.NTy + << ", NTyx = " << theTemp.head.NTyx << ", NTxx = " << theTemp.head.NTxx + << ", Dtype = " << theTemp.head.Dtype << ", Bias voltage " << theTemp.head.Vbias + << ", temperature " << theTemp.head.temperature << ", fluence " << theTemp.head.fluence + << ", Q-scaling factor " << theTemp.head.qscale << ", 1/2 multi dcol threshold " + << theTemp.head.s50 << ", 1/2 single dcol threshold " << theTemp.head.ss50 << ", y Lorentz Width " + << theTemp.head.lorywidth << ", y Lorentz Bias " << theTemp.head.lorybias << ", x Lorentz width " + << theTemp.head.lorxwidth << ", x Lorentz Bias " << theTemp.head.lorxbias + << ", Q/Q_avg fractions for Qbin defs " << theTemp.head.fbin[0] << ", " << theTemp.head.fbin[1] + << ", " << theTemp.head.fbin[2] << ", pixel x-size " << theTemp.head.xsize << ", y-size " + << theTemp.head.ysize << ", zsize " << theTemp.head.zsize << "\n" + << std::endl; + } + std::map templMap = payload->getTemplateIDs(); for (auto const& entry : templMap) { std::cout << "DetID: " << entry.first << " template ID: " << entry.second << std::endl; @@ -82,7 +106,181 @@ namespace { return true; } // fill }; + + /************************************************ + // testing TH2Poly classes for plotting + *************************************************/ + class SiPixelTemplateLA : public cond::payloadInspector::PlotImage { + + struct header_info{ + int ID; //!< template ID number + float lorywidth; //!< estimate of y-lorentz width for optimal resolution + float lorxwidth; //!< estimate of x-lorentz width for optimal resolution + float lorybias; //!< estimate of y-lorentz bias + float lorxbias; //!< estimate of x-lorentz bias + float Vbias; //!< detector bias potential in Volts + float temperature; //!< detector temperature in deg K + int templ_version; //!< Version number of the template to ensure code compatibility + float Bfield; //!< Bfield in Tesla + float xsize; //!< pixel size (for future use in upgraded geometry) + float ysize; //!< pixel size (for future use in upgraded geometry) + float zsize; //!< pixel size (for future use in upgraded geometry) + }; + + public: + SiPixelTemplateLA() + : cond::payloadInspector::PlotImage("SiPixelTemplate assumed value of uH"){ + setSingleIov(true); + } + + bool fill(const std::vector>& iovs) override { + auto iov = iovs.front(); + + std::vector thePixelTemp_; + std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + + if (payload.get()) { + if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { + throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; + } + + // store the map of ID / interesting quantities + SiPixelTemplate templ(thePixelTemp_); + std::map theInfos; + for (const auto& theTemp : thePixelTemp_) { + header_info info; + info.ID = theTemp.head.ID; + info.lorywidth = theTemp.head.lorywidth; + info.lorxwidth = theTemp.head.lorxwidth; + info.lorybias = theTemp.head.lorybias; + info.lorxbias = theTemp.head.lorxbias; + info.Vbias = theTemp.head.Vbias; + info.temperature = theTemp.head.temperature; + info.templ_version = theTemp.head.templ_version; + info.Bfield = theTemp.head.Bfield; + info.xsize = theTemp.head.xsize; + info.ysize = theTemp.head.ysize; + info.zsize = theTemp.head.zsize; + + theInfos[theTemp.head.ID]=info; + } + + // Book the TH2Poly + Phase1PixelMaps theMaps("COLZ L"); + theMaps.bookBarrelHistograms("templateLABarrel"); + theMaps.bookBarrelBins("templateLABarrel"); + theMaps.bookForwardHistograms("templateLAForward"); + theMaps.bookForwardBins("templateLAForward"); + + std::map templMap = payload->getTemplateIDs(); + for (auto const& entry : templMap) { + + templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f); + + //mu_H = lorentz width / sensor thickness / B field + float uH = templ.lorxwidth() / theInfos[entry.second].zsize / theInfos[entry.second].Bfield; + COUT << "uH: " << uH + << " lor x width:" << templ.lorxwidth() + << " z size: " << theInfos[entry.second].zsize + << " B-field: " << theInfos[entry.second].Bfield + << std::endl; + + auto detid = DetId(entry.first); + if (detid.subdetId() == PixelSubdetector::PixelBarrel) { + theMaps.fillBarrelBin("templateLABarrel",entry.first,uH); + } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { + theMaps.fillEndcapBin("templateLAForward",entry.first,uH); + } + } + + /* + TCanvas canvas("Canv", "Canv", 1200, 1000); + std::cout << "draw canvas" << std::endl; + theMaps.DrawBarrelMaps("templateLABarrel",canvas); + */ + + TCanvas canvas("Canv", "Canv", 1500, 1000); + std::cout << "draw canvas" << std::endl; + theMaps.DrawEndcapMaps("templateLAForward",canvas); + + canvas.cd(); + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + + } + return true; + } // fill + }; + + /************************************************ + // testing TH2Poly classes for plotting + *************************************************/ + class SiPixelTemplateIDs : public cond::payloadInspector::PlotImage { + public: + SiPixelTemplateIDs() + : cond::payloadInspector::PlotImage("SiPixelTemplate ID Values"){ + setSingleIov(true); + } + + bool fill(const std::vector>& iovs) override { + auto iov = iovs.front(); + std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + + if (payload.get()) { + // Book the TH2Poly + Phase1PixelMaps theMaps("COLZ L"); + theMaps.bookBarrelHistograms("templateIDsBarrel"); + theMaps.bookForwardHistograms("templateIDsForward"); + + std::map templMap = payload->getTemplateIDs(); + + /* + std::vector detids; + std::transform(templMap.begin(), + templMap.end(), + std::back_inserter(detids), + [](const std::map::value_type& pair) { return pair.first; }); + */ + + // book the barrel bins of the TH2Poly + theMaps.bookBarrelBins("templateIDsBarrel"); + + // book the forward bins of the TH2Poly + theMaps.bookForwardBins("templateIDsForward"); + + for (auto const& entry : templMap) { + COUT << "DetID: " << entry.first << " template ID: " << entry.second << std::endl; + auto detid = DetId(entry.first); + if (detid.subdetId() == PixelSubdetector::PixelBarrel) { + theMaps.fillBarrelBin("templateIDsBarrel",entry.first,entry.second); + } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { + theMaps.fillBarrelBin("templateIDsBarrel",entry.first,entry.second); + } + } + + TCanvas canvas("Canv", "Canv", 1200, 1000); + theMaps.DrawBarrelMaps("templateIDsBarrel",canvas); + + /* + TCanvas canvas("Canv", "Canv", 1500, 1000); + theMaps.DrawEndcapMaps("templateIDsForward",canvas); + */ + + canvas.cd(); + + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + } + return true; + } + }; } // namespace // Register the classes as boost python plugin -PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) { PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest); } +PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) { + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDs); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLA); +} diff --git a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh new file mode 100644 index 0000000000000..a81b449cb3c88 --- /dev/null +++ b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh @@ -0,0 +1,38 @@ +#!/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`; +# Go back to original working directory +cd $W_DIR; +# Run get payload data script +if [ -d $W_DIR/plots_Template ]; then + rm -fr $W_DIR/plots_Template +fi + +mkdir $W_DIR/plots_Template + +getPayloadData.py \ + --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ + --plot plot_SiPixelTemplateDBObjectTest \ + --tag SiPixelTemplateDBObject38Tv3_express \ + --time_type Run \ + --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_Template/Test.png + +getPayloadData.py \ + --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ + --plot plot_SiPixelTemplateIDs \ + --tag SiPixelTemplateDBObject38Tv3_express \ + --time_type Run \ + --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_Template/Test.png From 1d9ac23ded5a4b3768971e7773aaffc15a9073bd Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 20 Apr 2020 17:42:32 +0200 Subject: [PATCH 03/32] finalize the phase1pixelmaps and use it in the SiPixelTemplate Payload Inspector --- .../interface/Phase1PixelMaps.h | 177 +++++++------- .../interface/SiPixelPayloadInspectorHelper.h | 2 +- ...iPixelTemplateDBObject_PayloadInspector.cc | 219 +++++++++--------- .../test/testSiPixelTemplateDBObject.sh | 37 ++- 4 files changed, 240 insertions(+), 195 deletions(-) mode change 100644 => 100755 CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh diff --git a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h index b58a18fe367ac..22224559d42b2 100644 --- a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h +++ b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h @@ -9,144 +9,142 @@ / Ancillary class to build pixel phase-1 tracker maps /--------------------------------------------------------------------*/ class Phase1PixelMaps { -public: - Phase1PixelMaps(const char* option) : - m_option{option}, - m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} - { +public: + Phase1PixelMaps(const char* option) + : m_option{option}, + m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { // store the file in path for the corners (BPIX) for (unsigned int i = 1; i <= 4; i++) { m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i))); } - + // store the file in path for the corners (BPIX) for (int j : {-3, -2, -1, 1, 2, 3}) { m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j))); } } - - ~Phase1PixelMaps(){} - + + ~Phase1PixelMaps() {} + //============================================================================ void bookBarrelHistograms(const std::string& currentHistoName) { std::string histName; TH2Poly* th2p; - + for (unsigned i = 0; i < 4; ++i) { histName = "barrel_layer_"; - + th2p = new TH2Poly( - (histName + std::to_string(i + 1)).c_str(), Form("PXBMap - Layer %i", i + 1), -15.0, 15.0, 0.0, 5.0); - + (histName + std::to_string(i + 1)).c_str(), Form("PXBMap - Layer %i", i + 1), -15.0, 15.0, 0.0, 5.0); + th2p->SetFloat(); - + th2p->GetXaxis()->SetTitle("z [cm]"); th2p->GetYaxis()->SetTitle("ladder"); th2p->SetStats(false); th2p->SetOption(m_option); - th2PolyBarrel[currentHistoName].push_back(th2p); + pxbTh2PolyBarrel[currentHistoName].push_back(th2p); } - + th2p = new TH2Poly("barrel_summary", "PXBMap", -5.0, 5.0, 0.0, 5.0); th2p->SetFloat(); - + th2p->GetXaxis()->SetTitle(""); th2p->GetYaxis()->SetTitle("~ladder"); th2p->SetStats(false); th2p->SetOption(m_option); - th2PolyBarrelSummary[currentHistoName] = th2p; + pxbTh2PolyBarrelSummary[currentHistoName] = th2p; } - + //============================================================================ void bookForwardHistograms(const std::string& currentHistoName) { std::string histName; TH2Poly* th2p; - + for (unsigned side = 1; side <= 2; ++side) { for (unsigned disk = 1; disk <= 3; ++disk) { - histName = "forward_disk_"; - - th2p = new TH2Poly((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), - Form("PXFMap - Side %i Disk %i", side, disk), - -15.0, - 15.0, - -15.0, - 15.0); - th2p->SetFloat(); - th2p->GetXaxis()->SetTitle("x [cm]"); - th2p->GetYaxis()->SetTitle("y [cm]"); - th2p->SetStats(false); - th2p->SetOption(m_option); - pxfTh2PolyForward[currentHistoName].push_back(th2p); + histName = "forward_disk_"; + + th2p = new TH2Poly((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), + Form("PXFMap - Side %i Disk %i", side, disk), + -15.0, + 15.0, + -15.0, + 15.0); + th2p->SetFloat(); + th2p->GetXaxis()->SetTitle("x [cm]"); + th2p->GetYaxis()->SetTitle("y [cm]"); + th2p->SetStats(false); + th2p->SetOption(m_option); + pxfTh2PolyForward[currentHistoName].push_back(th2p); } } th2p = new TH2Poly("forward_summary", "PXFMap", -40.0, 50.0, -20.0, 90.0); th2p->SetFloat(); - + th2p->GetXaxis()->SetTitle(""); th2p->GetYaxis()->SetTitle(""); th2p->SetStats(false); th2p->SetOption(m_option); pxfTh2PolyForwardSummary[currentHistoName] = th2p; } - + //============================================================================ void bookBarrelBins(const std::string& currentHistoName) { - auto theIndexedCorners = SiPixelPI::retrieveCorners(m_cornersBPIX, 4); - + for (const auto& entry : theIndexedCorners) { auto id = entry.first; auto detid = DetId(id); if (detid.subdetId() != PixelSubdetector::PixelBarrel) - continue; - + continue; + int layer = m_trackerTopo.pxbLayer(detid); int ladder = m_trackerTopo.pxbLadder(detid); - + auto theVectX = entry.second.first; auto theVectY = entry.second.second; - + float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]}; float vertY[] = {(ladder - 1.0f), (ladder - 1.0f), (float)ladder, (float)ladder, (ladder - 1.0f)}; - + bins[id] = new TGraph(5, vertX, vertY); bins[id]->SetName(TString::Format("%u", id)); // Summary plot for (unsigned k = 0; k < 5; ++k) { - vertX[k] += ((layer == 2 || layer == 3) ? 0.0f : -60.0f); - vertY[k] += ((layer > 2) ? 30.0f : 0.0f); + vertX[k] += ((layer == 2 || layer == 3) ? 0.0f : -60.0f); + vertY[k] += ((layer > 2) ? 30.0f : 0.0f); } - + binsSummary[id] = new TGraph(5, vertX, vertY); binsSummary[id]->SetName(TString::Format("%u", id)); - - th2PolyBarrel[currentHistoName][layer - 1]->AddBin(bins[id]->Clone()); - th2PolyBarrelSummary[currentHistoName]->AddBin(binsSummary[id]->Clone()); + + pxbTh2PolyBarrel[currentHistoName][layer - 1]->AddBin(bins[id]->Clone()); + pxbTh2PolyBarrelSummary[currentHistoName]->AddBin(binsSummary[id]->Clone()); } } - + //============================================================================ void bookForwardBins(const std::string& currentHistoName) { - auto theIndexedCorners = SiPixelPI::retrieveCorners(m_cornersFPIX, 3); - + for (const auto& entry : theIndexedCorners) { auto id = entry.first; auto detid = DetId(id); if (detid.subdetId() != PixelSubdetector::PixelEndcap) - continue; - + continue; + int disk = m_trackerTopo.pxfDisk(detid); int side = m_trackerTopo.pxfSide(detid); - + unsigned mapIdx = disk + (side - 1) * 3 - 1; - + auto theVectX = entry.second.first; auto theVectY = entry.second.second; - + float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]}; float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]}; @@ -155,77 +153,82 @@ class Phase1PixelMaps { // Summary plot for (unsigned k = 0; k < 4; ++k) { - vertX[k] += (float(side) - 1.5f) * 40.0f; - vertY[k] += (disk - 1) * 35.0f; + vertX[k] += (float(side) - 1.5f) * 40.0f; + vertY[k] += (disk - 1) * 35.0f; } - + binsSummary[id] = new TGraph(4, vertX, vertY); binsSummary[id]->SetName(TString::Format("%u", id)); - + pxfTh2PolyForward[currentHistoName][mapIdx]->AddBin(bins[id]->Clone()); pxfTh2PolyForwardSummary[currentHistoName]->AddBin(binsSummary[id]->Clone()); } } - + //============================================================================ template - void fillBarrelBin(const std::string& currentHistoName, - unsigned int id, - type value){ + void fillBarrelBin(const std::string& currentHistoName, unsigned int id, type value) { + auto detid = DetId(id); + if (detid.subdetId() != PixelSubdetector::PixelBarrel) { + edm::LogError("Phase1PixelMaps") << "fillBarrelBin() The following detid " << id << " is not Pixel Barrel!" + << std::endl; + return; + } int layer = m_trackerTopo.pxbLayer(id); - th2PolyBarrel[currentHistoName][layer - 1]->Fill(TString::Format("%u", id), value); + pxbTh2PolyBarrel[currentHistoName][layer - 1]->Fill(TString::Format("%u", id), value); } - + //============================================================================ template - void fillEndcapBin(const std::string& currentHistoName, - unsigned int id, - type value){ + void fillForwardBin(const std::string& currentHistoName, unsigned int id, type value) { + auto detid = DetId(id); + if (detid.subdetId() != PixelSubdetector::PixelEndcap) { + edm::LogError("Phase1PixelMaps") << "fillForwardBin() The following detid " << id << " is not Pixel Forward!" + << std::endl; + return; + } int disk = m_trackerTopo.pxfDisk(id); int side = m_trackerTopo.pxfSide(id); unsigned mapIdx = disk + (side - 1) * 3 - 1; pxfTh2PolyForward[currentHistoName][mapIdx]->Fill(TString::Format("%u", id), value); } - + //============================================================================ - void DrawBarrelMaps(const std::string& currentHistoName, - TCanvas &canvas){ + void DrawBarrelMaps(const std::string& currentHistoName, TCanvas& canvas) { canvas.Divide(2, 2); for (int i = 1; i <= 4; i++) { canvas.cd(i); - if( strcmp(m_option, "text") == 0){ - th2PolyBarrel[currentHistoName].at(i-1)->SetMarkerColor(kRed); + if (strcmp(m_option, "text") == 0) { + pxbTh2PolyBarrel[currentHistoName].at(i - 1)->SetMarkerColor(kRed); } - th2PolyBarrel[currentHistoName].at(i-1)->Draw(); + pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw(); } } - + //============================================================================ - void DrawEndcapMaps(const std::string& currentHistoName, - TCanvas &canvas){ + void DrawForwardMaps(const std::string& currentHistoName, TCanvas& canvas) { canvas.Divide(3, 2); for (int i = 1; i <= 6; i++) { canvas.cd(i); - if( strcmp(m_option, "text") == 0){ - pxfTh2PolyForward[currentHistoName].at(i-1)->SetMarkerColor(kRed); + if (strcmp(m_option, "text") == 0) { + pxfTh2PolyForward[currentHistoName].at(i - 1)->SetMarkerColor(kRed); } - pxfTh2PolyForward[currentHistoName].at(i-1)->Draw(); + pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw(); } } private: Option_t* m_option; TrackerTopology m_trackerTopo; - + std::map bins, binsSummary; - std::map> th2PolyBarrel; - std::map th2PolyBarrelSummary; + std::map> pxbTh2PolyBarrel; + std::map pxbTh2PolyBarrelSummary; std::map> pxfTh2PolyForward; std::map pxfTh2PolyForwardSummary; - + std::vector m_cornersBPIX; std::vector m_cornersFPIX; }; - #endif diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index b88c9e1c4559d..54b9d4a9db4a2 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -953,7 +953,7 @@ namespace SiPixelPI { } else if (t.index() == 1) { yP.push_back(atof((t.value()).c_str())); } else { - edm::LogError("LogicError") << "There should not be any token with index " << t.index() << std::endl; + edm::LogError("LogicError") << "There should not be any token with index " << t.index() << std::endl; } } } diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index afbd58b1eae9c..aba99ed02263e 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -46,6 +46,8 @@ namespace { + enum MapType { t_barrel = 0, t_forward = 1 }; + /************************************************ test class *************************************************/ @@ -110,133 +112,141 @@ namespace { /************************************************ // testing TH2Poly classes for plotting *************************************************/ + template class SiPixelTemplateLA : public cond::payloadInspector::PlotImage { - - struct header_info{ - int ID; //!< template ID number - float lorywidth; //!< estimate of y-lorentz width for optimal resolution - float lorxwidth; //!< estimate of x-lorentz width for optimal resolution - float lorybias; //!< estimate of y-lorentz bias - float lorxbias; //!< estimate of x-lorentz bias - float Vbias; //!< detector bias potential in Volts - float temperature; //!< detector temperature in deg K - int templ_version; //!< Version number of the template to ensure code compatibility - float Bfield; //!< Bfield in Tesla - float xsize; //!< pixel size (for future use in upgraded geometry) - float ysize; //!< pixel size (for future use in upgraded geometry) - float zsize; //!< pixel size (for future use in upgraded geometry) + struct header_info { + int ID; //!< template ID number + float lorywidth; //!< estimate of y-lorentz width for optimal resolution + float lorxwidth; //!< estimate of x-lorentz width for optimal resolution + float lorybias; //!< estimate of y-lorentz bias + float lorxbias; //!< estimate of x-lorentz bias + float Vbias; //!< detector bias potential in Volts + float temperature; //!< detector temperature in deg K + int templ_version; //!< Version number of the template to ensure code compatibility + float Bfield; //!< Bfield in Tesla + float xsize; //!< pixel size (for future use in upgraded geometry) + float ysize; //!< pixel size (for future use in upgraded geometry) + float zsize; //!< pixel size (for future use in upgraded geometry) }; public: SiPixelTemplateLA() - : cond::payloadInspector::PlotImage("SiPixelTemplate assumed value of uH"){ + : cond::payloadInspector::PlotImage("SiPixelTemplate assumed value of uH") { setSingleIov(true); } bool fill(const std::vector>& iovs) override { + //gStyle->SetPalette(kRainBow); auto iov = iovs.front(); std::vector thePixelTemp_; std::shared_ptr payload = fetchPayload(std::get<1>(iov)); if (payload.get()) { - if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { - throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " - "SiPixelTemplateDBObject version " - << payload->version() << "\n\n"; - } - - // store the map of ID / interesting quantities - SiPixelTemplate templ(thePixelTemp_); - std::map theInfos; - for (const auto& theTemp : thePixelTemp_) { - header_info info; - info.ID = theTemp.head.ID; - info.lorywidth = theTemp.head.lorywidth; - info.lorxwidth = theTemp.head.lorxwidth; - info.lorybias = theTemp.head.lorybias; - info.lorxbias = theTemp.head.lorxbias; - info.Vbias = theTemp.head.Vbias; - info.temperature = theTemp.head.temperature; - info.templ_version = theTemp.head.templ_version; - info.Bfield = theTemp.head.Bfield; - info.xsize = theTemp.head.xsize; - info.ysize = theTemp.head.ysize; - info.zsize = theTemp.head.zsize; - - theInfos[theTemp.head.ID]=info; - } + if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { + throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; + } + + // store the map of ID / interesting quantities + SiPixelTemplate templ(thePixelTemp_); + std::map theInfos; + for (const auto& theTemp : thePixelTemp_) { + header_info info; + info.ID = theTemp.head.ID; + info.lorywidth = theTemp.head.lorywidth; + info.lorxwidth = theTemp.head.lorxwidth; + info.lorybias = theTemp.head.lorybias; + info.lorxbias = theTemp.head.lorxbias; + info.Vbias = theTemp.head.Vbias; + info.temperature = theTemp.head.temperature; + info.templ_version = theTemp.head.templ_version; + info.Bfield = theTemp.head.Bfield; + info.xsize = theTemp.head.xsize; + info.ysize = theTemp.head.ysize; + info.zsize = theTemp.head.zsize; + + theInfos[theTemp.head.ID] = info; + } // Book the TH2Poly - Phase1PixelMaps theMaps("COLZ L"); - theMaps.bookBarrelHistograms("templateLABarrel"); - theMaps.bookBarrelBins("templateLABarrel"); - theMaps.bookForwardHistograms("templateLAForward"); - theMaps.bookForwardBins("templateLAForward"); + Phase1PixelMaps theMaps("COLZ L"); + + if (myType == t_barrel) { + theMaps.bookBarrelHistograms("templateLABarrel"); + theMaps.bookBarrelBins("templateLABarrel"); + } else if (myType == t_forward) { + theMaps.bookForwardHistograms("templateLAForward"); + theMaps.bookForwardBins("templateLAForward"); + } std::map templMap = payload->getTemplateIDs(); - for (auto const& entry : templMap) { - - templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f); - - //mu_H = lorentz width / sensor thickness / B field - float uH = templ.lorxwidth() / theInfos[entry.second].zsize / theInfos[entry.second].Bfield; - COUT << "uH: " << uH - << " lor x width:" << templ.lorxwidth() - << " z size: " << theInfos[entry.second].zsize - << " B-field: " << theInfos[entry.second].Bfield - << std::endl; - - auto detid = DetId(entry.first); - if (detid.subdetId() == PixelSubdetector::PixelBarrel) { - theMaps.fillBarrelBin("templateLABarrel",entry.first,uH); - } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { - theMaps.fillEndcapBin("templateLAForward",entry.first,uH); - } - } - - /* - TCanvas canvas("Canv", "Canv", 1200, 1000); - std::cout << "draw canvas" << std::endl; - theMaps.DrawBarrelMaps("templateLABarrel",canvas); - */ - - TCanvas canvas("Canv", "Canv", 1500, 1000); - std::cout << "draw canvas" << std::endl; - theMaps.DrawEndcapMaps("templateLAForward",canvas); - - canvas.cd(); - std::string fileName(m_imageFileName); - canvas.SaveAs(fileName.c_str()); + for (auto const& entry : templMap) { + templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f); + + //mu_H = lorentz width / sensor thickness / B field + float uH = templ.lorxwidth() / theInfos[entry.second].zsize / theInfos[entry.second].Bfield; + COUT << "uH: " << uH << " lor x width:" << templ.lorxwidth() << " z size: " << theInfos[entry.second].zsize + << " B-field: " << theInfos[entry.second].Bfield << std::endl; + + auto detid = DetId(entry.first); + if ((detid.subdetId() == PixelSubdetector::PixelBarrel) && (myType == t_barrel)) { + theMaps.fillBarrelBin("templateLABarrel", entry.first, uH); + } else if ((detid.subdetId() == PixelSubdetector::PixelEndcap) && (myType == t_forward)) { + theMaps.fillForwardBin("templateLAForward", entry.first, uH); + } + } + + TCanvas canvas("Canv", "Canv", (myType == t_barrel) ? 1200 : 1500, 1000); + if (myType == t_barrel) { + theMaps.DrawBarrelMaps("templateLABarrel", canvas); + } else if (myType == t_forward) { + theMaps.DrawForwardMaps("templateLAForward", canvas); + } + canvas.cd(); + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); } return true; - } // fill + } // fill }; + using SiPixelTemplateLABPixMap = SiPixelTemplateLA; + using SiPixelTemplateLAFPixMap = SiPixelTemplateLA; + /************************************************ // testing TH2Poly classes for plotting *************************************************/ + template class SiPixelTemplateIDs : public cond::payloadInspector::PlotImage { public: - SiPixelTemplateIDs() - : cond::payloadInspector::PlotImage("SiPixelTemplate ID Values"){ + SiPixelTemplateIDs() : cond::payloadInspector::PlotImage("SiPixelTemplate ID Values") { setSingleIov(true); } bool fill(const std::vector>& iovs) override { + gStyle->SetPalette(kRainBow); auto iov = iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); if (payload.get()) { // Book the TH2Poly - Phase1PixelMaps theMaps("COLZ L"); - theMaps.bookBarrelHistograms("templateIDsBarrel"); - theMaps.bookForwardHistograms("templateIDsForward"); + Phase1PixelMaps theMaps("text"); + if (myType == t_barrel) { + theMaps.bookBarrelHistograms("templateIDsBarrel"); + // book the barrel bins of the TH2Poly + theMaps.bookBarrelBins("templateIDsBarrel"); + } else if (myType == t_forward) { + theMaps.bookForwardHistograms("templateIDsForward"); + // book the forward bins of the TH2Poly + theMaps.bookForwardBins("templateIDsForward"); + } std::map templMap = payload->getTemplateIDs(); - /* + /* std::vector detids; std::transform(templMap.begin(), templMap.end(), @@ -244,29 +254,22 @@ namespace { [](const std::map::value_type& pair) { return pair.first; }); */ - // book the barrel bins of the TH2Poly - theMaps.bookBarrelBins("templateIDsBarrel"); - - // book the forward bins of the TH2Poly - theMaps.bookForwardBins("templateIDsForward"); - for (auto const& entry : templMap) { COUT << "DetID: " << entry.first << " template ID: " << entry.second << std::endl; auto detid = DetId(entry.first); - if (detid.subdetId() == PixelSubdetector::PixelBarrel) { - theMaps.fillBarrelBin("templateIDsBarrel",entry.first,entry.second); - } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { - theMaps.fillBarrelBin("templateIDsBarrel",entry.first,entry.second); + if ((detid.subdetId() == PixelSubdetector::PixelBarrel) && (myType == t_barrel)) { + theMaps.fillBarrelBin("templateIDsBarrel", entry.first, entry.second); + } else if ((detid.subdetId() == PixelSubdetector::PixelEndcap) && (myType == t_forward)) { + theMaps.fillForwardBin("templateIDsForward", entry.first, entry.second); } } - TCanvas canvas("Canv", "Canv", 1200, 1000); - theMaps.DrawBarrelMaps("templateIDsBarrel",canvas); - - /* - TCanvas canvas("Canv", "Canv", 1500, 1000); - theMaps.DrawEndcapMaps("templateIDsForward",canvas); - */ + TCanvas canvas("Canv", "Canv", (myType == t_barrel) ? 1200 : 1500, 1000); + if (myType == t_barrel) { + theMaps.DrawBarrelMaps("templateIDsBarrel", canvas); + } else if (myType == t_forward) { + theMaps.DrawForwardMaps("templateIDsForward", canvas); + } canvas.cd(); @@ -276,11 +279,17 @@ namespace { return true; } }; + + using SiPixelTemplateIDsBPixMap = SiPixelTemplateIDs; + using SiPixelTemplateIDsFPixMap = SiPixelTemplateIDs; + } // namespace // Register the classes as boost python plugin PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) { PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest); - PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDs); - PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLA); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsBPixMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFPixMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLABPixMap); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLAFPixMap); } diff --git a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh old mode 100644 new mode 100755 index a81b449cb3c88..c1a2d7cf58414 --- a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh @@ -28,11 +28,44 @@ mv *.png $W_DIR/plots_Template/Test.png getPayloadData.py \ --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ - --plot plot_SiPixelTemplateIDs \ + --plot plot_SiPixelTemplateIDsBPixMap \ --tag SiPixelTemplateDBObject38Tv3_express \ --time_type Run \ --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ --db Prod \ --test ; -mv *.png $W_DIR/plots_Template/Test.png +mv *.png $W_DIR/plots_Template/IDsBPixMap.png + +getPayloadData.py \ + --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ + --plot plot_SiPixelTemplateIDsFPixMap \ + --tag SiPixelTemplateDBObject38Tv3_express \ + --time_type Run \ + --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_Template/IDsFPixMap.png + +getPayloadData.py \ + --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ + --plot plot_SiPixelTemplateLABPixMap \ + --tag SiPixelTemplateDBObject38Tv3_express \ + --time_type Run \ + --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_Template/LABPixMap.png + +getPayloadData.py \ + --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ + --plot plot_SiPixelTemplateLAFPixMap \ + --tag SiPixelTemplateDBObject38Tv3_express \ + --time_type Run \ + --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_Template/LAFPixMap.png From 41fd43233357d2f74eb6075d4ab474b691093a14 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 21 Apr 2020 13:48:38 +0200 Subject: [PATCH 04/32] further improvements to SiPixelTemplateDBObject Payload Inspector --- .../interface/Phase1PixelMaps.h | 15 ++++++++ .../interface/SiPixelPayloadInspectorHelper.h | 1 + ...iPixelTemplateDBObject_PayloadInspector.cc | 37 +++++++++++++++++++ CondCore/SiPixelPlugins/test/BuildFile.xml | 1 + .../test/testSiPixelPayloadInspector.cpp | 17 +++++++++ 5 files changed, 71 insertions(+) diff --git a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h index 22224559d42b2..e732393520d9e 100644 --- a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h +++ b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h @@ -193,6 +193,21 @@ class Phase1PixelMaps { pxfTh2PolyForward[currentHistoName][mapIdx]->Fill(TString::Format("%u", id), value); } + //============================================================================ + void beautifyAllHistograms() { + for (const auto& vec : pxbTh2PolyBarrel) { + for (const auto& plot : vec.second) { + SiPixelPI::makeNicePlotStyle(plot); + } + } + + for (const auto& vec : pxfTh2PolyForward) { + for (const auto& plot : vec.second) { + SiPixelPI::makeNicePlotStyle(plot); + } + } + } + //============================================================================ void DrawBarrelMaps(const std::string& currentHistoName, TCanvas& canvas) { canvas.Divide(2, 2); diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index 54b9d4a9db4a2..3e1d60261e5e3 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -38,6 +38,7 @@ namespace SiPixelPI { // size of the phase-0 pixel detID list static const unsigned int phase0size = 1440; + static const unsigned int phase1size = 1856; //============================================================================ std::pair unpack(cond::Time_t since) { diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index aba99ed02263e..a201ecc9d69c3 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -182,6 +182,23 @@ namespace { } std::map templMap = payload->getTemplateIDs(); + if (templMap.size() != SiPixelPI::phase1size) { + edm::LogError("SiPixelTemplateDBObject_PayloadInspector") + << "SiPixelTempateLA maps are not supported for non-Phase1 Pixel geometries !"; + std::string phase = (templMap.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; + TCanvas canvas("Canv", "Canv", 1200, 1000); + canvas.cd(); + TLatex t2; + t2.SetTextAlign(21); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextColor(kRed); + t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } + for (auto const& entry : templMap) { templ.interpolate(entry.second, 0.f, 0.f, 1.f, 1.f); @@ -198,6 +215,8 @@ namespace { } } + theMaps.beautifyAllHistograms(); + TCanvas canvas("Canv", "Canv", (myType == t_barrel) ? 1200 : 1500, 1000); if (myType == t_barrel) { theMaps.DrawBarrelMaps("templateLABarrel", canvas); @@ -245,6 +264,22 @@ namespace { } std::map templMap = payload->getTemplateIDs(); + if (templMap.size() != SiPixelPI::phase1size) { + edm::LogError("SiPixelTemplateDBObject_PayloadInspector") + << "SiPixelTempateIDs maps are not supported for non-Phase1 Pixel geometries !"; + std::string phase = (templMap.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; + TCanvas canvas("Canv", "Canv", 1200, 1000); + canvas.cd(); + TLatex t2; + t2.SetTextAlign(21); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextColor(kRed); + t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } /* std::vector detids; @@ -264,6 +299,8 @@ namespace { } } + theMaps.beautifyAllHistograms(); + TCanvas canvas("Canv", "Canv", (myType == t_barrel) ? 1200 : 1500, 1000); if (myType == t_barrel) { theMaps.DrawBarrelMaps("templateIDsBarrel", canvas); diff --git a/CondCore/SiPixelPlugins/test/BuildFile.xml b/CondCore/SiPixelPlugins/test/BuildFile.xml index 3fb9b7f509968..6b42a53e387a4 100644 --- a/CondCore/SiPixelPlugins/test/BuildFile.xml +++ b/CondCore/SiPixelPlugins/test/BuildFile.xml @@ -4,5 +4,6 @@ + diff --git a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp index 8019472b8bb38..6cc83cf854dba 100644 --- a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp +++ b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp @@ -4,6 +4,7 @@ #include "CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc" #include "CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc" #include "CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc" +#include "CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc" #include "FWCore/PluginManager/interface/PluginManager.h" #include "FWCore/PluginManager/interface/standard.h" #include "FWCore/PluginManager/interface/SharedLibrary.h" @@ -119,5 +120,21 @@ int main(int argc, char** argv) { histo16.process(connectionString, PI::mk_input(tag, end, end)); std::cout << histo16.data() << std::endl; + // SiPixelTemplates + + tag = "SiPixelTemplateDBObject38Tv3_express"; + start = boost::lexical_cast(326083); + end = boost::lexical_cast(326083); + + std::cout << "## Exercising SiPixelTemplates plots " << std::endl; + + SiPixelTemplateIDsBPixMap histo17; + histo17.process(connectionString, PI::mk_input(tag, end, end)); + std::cout << histo17.data() << std::endl; + + SiPixelTemplateLAFPixMap histo18; + histo18.process(connectionString, PI::mk_input(tag, end, end)); + std::cout << histo18.data() << std::endl; + Py_Finalize(); } From 53a7589ab1827950985739a63bf235fda1e86e34 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 22 Apr 2020 13:38:51 +0200 Subject: [PATCH 05/32] refinements of the Template plots --- .../interface/Phase1PixelMaps.h | 28 +++++++++++++++---- ...iPixelTemplateDBObject_PayloadInspector.cc | 15 ++++++---- .../test/testSiPixelTemplateDBObject.sh | 2 -- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h index e732393520d9e..6a2d0ab9da338 100644 --- a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h +++ b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h @@ -28,20 +28,26 @@ class Phase1PixelMaps { ~Phase1PixelMaps() {} //============================================================================ - void bookBarrelHistograms(const std::string& currentHistoName) { + void bookBarrelHistograms(const std::string& currentHistoName, const char* what) { std::string histName; TH2Poly* th2p; for (unsigned i = 0; i < 4; ++i) { histName = "barrel_layer_"; - th2p = new TH2Poly( - (histName + std::to_string(i + 1)).c_str(), Form("PXBMap - Layer %i", i + 1), -15.0, 15.0, 0.0, 5.0); + th2p = new TH2Poly((histName + std::to_string(i + 1)).c_str(), + Form("PXBMap of %s - Layer %i", what, i + 1), + -15.0, + 15.0, + 0.0, + 5.0); th2p->SetFloat(); th2p->GetXaxis()->SetTitle("z [cm]"); th2p->GetYaxis()->SetTitle("ladder"); + //th2p->GetXaxis()->SetTitleOffset(0.09); + //th2p->GetYaxis()->SetTitleOffset(0.09); th2p->SetStats(false); th2p->SetOption(m_option); pxbTh2PolyBarrel[currentHistoName].push_back(th2p); @@ -58,7 +64,7 @@ class Phase1PixelMaps { } //============================================================================ - void bookForwardHistograms(const std::string& currentHistoName) { + void bookForwardHistograms(const std::string& currentHistoName, const char* what) { std::string histName; TH2Poly* th2p; @@ -67,7 +73,7 @@ class Phase1PixelMaps { histName = "forward_disk_"; th2p = new TH2Poly((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), - Form("PXFMap - Side %i Disk %i", side, disk), + Form("PXFMap of %s - Side %i Disk %i", what, side, disk), -15.0, 15.0, -15.0, @@ -75,6 +81,8 @@ class Phase1PixelMaps { th2p->SetFloat(); th2p->GetXaxis()->SetTitle("x [cm]"); th2p->GetYaxis()->SetTitle("y [cm]"); + //th2p->GetXaxis()->SetTitleOffset(0.09); + //th2p->GetYaxis()->SetTitleOffset(0.09); th2p->SetStats(false); th2p->SetOption(m_option); pxfTh2PolyForward[currentHistoName].push_back(th2p); @@ -198,12 +206,16 @@ class Phase1PixelMaps { for (const auto& vec : pxbTh2PolyBarrel) { for (const auto& plot : vec.second) { SiPixelPI::makeNicePlotStyle(plot); + plot->GetXaxis()->SetTitleOffset(0.9); + plot->GetYaxis()->SetTitleOffset(0.9); } } for (const auto& vec : pxfTh2PolyForward) { for (const auto& plot : vec.second) { SiPixelPI::makeNicePlotStyle(plot); + plot->GetXaxis()->SetTitleOffset(0.9); + plot->GetYaxis()->SetTitleOffset(0.9); } } } @@ -214,7 +226,10 @@ class Phase1PixelMaps { for (int i = 1; i <= 4; i++) { canvas.cd(i); if (strcmp(m_option, "text") == 0) { + canvas.cd(i)->SetRightMargin(0.02); pxbTh2PolyBarrel[currentHistoName].at(i - 1)->SetMarkerColor(kRed); + } else { + SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.14); } pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw(); } @@ -226,7 +241,10 @@ class Phase1PixelMaps { for (int i = 1; i <= 6; i++) { canvas.cd(i); if (strcmp(m_option, "text") == 0) { + canvas.cd(i)->SetRightMargin(0.02); pxfTh2PolyForward[currentHistoName].at(i - 1)->SetMarkerColor(kRed); + } else { + SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.16); } pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw(); } diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index a201ecc9d69c3..1a9d91668ee46 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -43,6 +43,7 @@ #include "TLatex.h" #include "TPave.h" #include "TPaveStats.h" +#include "TGaxis.h" namespace { @@ -136,7 +137,9 @@ namespace { } bool fill(const std::vector>& iovs) override { - //gStyle->SetPalette(kRainBow); + gStyle->SetPalette(kBlackBody); + TGaxis::SetMaxDigits(2); + auto iov = iovs.front(); std::vector thePixelTemp_; @@ -174,10 +177,10 @@ namespace { Phase1PixelMaps theMaps("COLZ L"); if (myType == t_barrel) { - theMaps.bookBarrelHistograms("templateLABarrel"); + theMaps.bookBarrelHistograms("templateLABarrel", "#muH"); theMaps.bookBarrelBins("templateLABarrel"); } else if (myType == t_forward) { - theMaps.bookForwardHistograms("templateLAForward"); + theMaps.bookForwardHistograms("templateLAForward", "#muH"); theMaps.bookForwardBins("templateLAForward"); } @@ -217,7 +220,7 @@ namespace { theMaps.beautifyAllHistograms(); - TCanvas canvas("Canv", "Canv", (myType == t_barrel) ? 1200 : 1500, 1000); + TCanvas canvas("Canv", "Canv", (myType == t_barrel) ? 1200 : 1600, 1000); if (myType == t_barrel) { theMaps.DrawBarrelMaps("templateLABarrel", canvas); } else if (myType == t_forward) { @@ -254,11 +257,11 @@ namespace { // Book the TH2Poly Phase1PixelMaps theMaps("text"); if (myType == t_barrel) { - theMaps.bookBarrelHistograms("templateIDsBarrel"); + theMaps.bookBarrelHistograms("templateIDsBarrel", "IDs"); // book the barrel bins of the TH2Poly theMaps.bookBarrelBins("templateIDsBarrel"); } else if (myType == t_forward) { - theMaps.bookForwardHistograms("templateIDsForward"); + theMaps.bookForwardHistograms("templateIDsForward", "IDs"); // book the forward bins of the TH2Poly theMaps.bookForwardBins("templateIDsForward"); } diff --git a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh index c1a2d7cf58414..8a7ec0034efc3 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh @@ -24,8 +24,6 @@ getPayloadData.py \ --db Prod \ --test ; -mv *.png $W_DIR/plots_Template/Test.png - getPayloadData.py \ --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ --plot plot_SiPixelTemplateIDsBPixMap \ From 239e342c108404dfa4af01d28a9b458c9d784ae4 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 22 Apr 2020 17:51:48 +0200 Subject: [PATCH 06/32] add not supported caption for not supported geometries --- .../interface/SiPixelGainCalibHelper.h | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 84bab25bbb4b6..164ab1c02c57a 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -784,6 +784,21 @@ namespace gainCalibHelper { 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 !"; + std::string phase = (GainCalibMap_.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; + TCanvas canvas("Canv", "Canv", 1200, 1000); + canvas.cd(); + TLatex t2; + t2.SetTextAlign(21); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextColor(kRed); + t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } // hard-coded phase-I std::array minima = {{999., 999., 999., 999.}}; @@ -899,6 +914,21 @@ namespace gainCalibHelper { 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 !"; + std::string phase = (GainCalibMap_.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; + TCanvas canvas("Canv", "Canv", 1200, 1000); + canvas.cd(); + TLatex t2; + t2.SetTextAlign(21); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextColor(kRed); + t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } // hardcoded phase-I std::array minima = {{999., 999.}}; From a36e959240e480bc4cca157d57dfacc86f58754a Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 26 Apr 2020 20:34:25 +0200 Subject: [PATCH 07/32] several improvements to the Payload Inspector --- .../interface/SiPixelGainCalibHelper.h | 18 +----- .../interface/SiPixelPayloadInspectorHelper.h | 28 ++++++++++ .../SiPixelLorentzAngle_PayloadInspector.cc | 56 +++++++++++++------ ...iPixelTemplateDBObject_PayloadInspector.cc | 18 +----- 4 files changed, 70 insertions(+), 50 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 164ab1c02c57a..19da098b22c3a 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -786,15 +786,8 @@ namespace gainCalibHelper { gainCalibPI::fillThePerModuleMap(payload, GainCalibMap_, myType); if (GainCalibMap_.size() != SiPixelPI::phase1size) { edm::LogError(label_) << "SiPixelGainCalibration maps are not supported for non-Phase1 Pixel geometries !"; - std::string phase = (GainCalibMap_.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; TCanvas canvas("Canv", "Canv", 1200, 1000); - canvas.cd(); - TLatex t2; - t2.SetTextAlign(21); - t2.SetTextSize(0.1); - t2.SetTextAngle(45); - t2.SetTextColor(kRed); - t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + SiPixelPI::displayNotSupported(canvas, GainCalibMap_.size()); std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); return false; @@ -916,15 +909,8 @@ namespace gainCalibHelper { gainCalibPI::fillThePerModuleMap(payload, GainCalibMap_, myType); if (GainCalibMap_.size() != SiPixelPI::phase1size) { edm::LogError(label_) << "SiPixelGainCalibration maps are not supported for non-Phase1 Pixel geometries !"; - std::string phase = (GainCalibMap_.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; TCanvas canvas("Canv", "Canv", 1200, 1000); - canvas.cd(); - TLatex t2; - t2.SetTextAlign(21); - t2.SetTextSize(0.1); - t2.SetTextAngle(45); - t2.SetTextColor(kRed); - t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + SiPixelPI::displayNotSupported(canvas, GainCalibMap_.size()); std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); return false; diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index 3e1d60261e5e3..273ca33dd7aac 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -974,5 +974,33 @@ namespace SiPixelPI { } // loop on files return theOutMap; } + + /*--------------------------------------------------------------------*/ + void displayNotSupported(TCanvas& canv, const unsigned int size) + /*--------------------------------------------------------------------*/ + { + std::string phase = (size < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; + canv.cd(); + TLatex t2; + t2.SetTextAlign(21); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextColor(kRed); + t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + } + + /*--------------------------------------------------------------------*/ + template + std::pair findMinMaxInMap(const std::map& theMap) + /*--------------------------------------------------------------------*/ + { + using pairtype = std::pair; + auto max = *std::max_element( + theMap.begin(), theMap.end(), [](const pairtype& p1, const pairtype& p2) { return p1.second < p2.second; }); + auto min = *std::min_element( + theMap.begin(), theMap.end(), [](const pairtype& p1, const pairtype& p2) { return p1.second < p2.second; }); + return std::make_pair(min.second, max.second); + } + }; // namespace SiPixelPI #endif diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 2a7849ac6aa2c..b52565de14beb 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -74,16 +74,18 @@ namespace { auto iov = iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); std::map LAMap_ = payload->getLorentzAngles(); + auto extrema = SiPixelPI::findMinMaxInMap(LAMap_); TCanvas canvas("Canv", "Canv", 1200, 1000); canvas.cd(); - auto h1 = std::unique_ptr(new TH1F( - "value", "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", 50, 0.051, 0.15)); + auto h1 = std::unique_ptr( + new TH1F("value", + "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", + 50, + extrema.first*0.9, + extrema.second*1.1)); - canvas.SetTopMargin(0.06); - canvas.SetBottomMargin(0.12); - canvas.SetLeftMargin(0.12); - canvas.SetRightMargin(0.05); + SiPixelPI::adjustCanvasMargins(canvas.cd(), 0.06, 0.12, 0.12, 0.05); canvas.Modified(); for (const auto &element : LAMap_) { @@ -112,10 +114,7 @@ namespace { TPaveStats *st = (TPaveStats *)h1->FindObject("stats"); st->SetTextSize(0.03); - st->SetX1NDC(0.15); //new x start position - st->SetY1NDC(0.83); //new y start position - st->SetX2NDC(0.39); //new x end position - st->SetY2NDC(0.93); //new y end position + SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); auto ltx = TLatex(); ltx.SetTextFont(62); @@ -152,8 +151,14 @@ namespace { std::shared_ptr last_payload = fetchPayload(std::get<1>(lastiov)); std::map l_LAMap_ = last_payload->getLorentzAngles(); + auto l_extrema = SiPixelPI::findMinMaxInMap(l_LAMap_); + std::shared_ptr first_payload = fetchPayload(std::get<1>(firstiov)); std::map f_LAMap_ = first_payload->getLorentzAngles(); + auto f_extrema = SiPixelPI::findMinMaxInMap(f_LAMap_); + + auto max = (l_extrema.second > f_extrema.second) ? l_extrema.second : f_extrema.second; + auto min = (l_extrema.first < f_extrema.first) ? l_extrema.first : f_extrema.first; std::string lastIOVsince = std::to_string(std::get<0>(lastiov)); std::string firstIOVsince = std::to_string(std::get<0>(firstiov)); @@ -164,22 +169,19 @@ namespace { new TH1F("value_first", "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", 50, - 0.051, - 0.15)); + min*0.9, + max*1.1)); hfirst->SetStats(false); auto hlast = std::unique_ptr( new TH1F("value_last", "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", 50, - 0.051, - 0.15)); + min*0.9, + max*1.1)); hlast->SetStats(false); - canvas.SetTopMargin(0.06); - canvas.SetBottomMargin(0.12); - canvas.SetLeftMargin(0.12); - canvas.SetRightMargin(0.05); + SiPixelPI::adjustCanvasMargins(canvas.cd(), 0.06, 0.12, 0.12, 0.05); canvas.Modified(); for (const auto &element : f_LAMap_) { @@ -509,6 +511,15 @@ namespace { } 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; + } // hard-coded phase-I std::array minima = {{999., 999., 999., 999.}}; @@ -614,6 +625,15 @@ namespace { } 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.}}; diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 1a9d91668ee46..836bf444bd49a 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -188,15 +188,8 @@ namespace { if (templMap.size() != SiPixelPI::phase1size) { edm::LogError("SiPixelTemplateDBObject_PayloadInspector") << "SiPixelTempateLA maps are not supported for non-Phase1 Pixel geometries !"; - std::string phase = (templMap.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; TCanvas canvas("Canv", "Canv", 1200, 1000); - canvas.cd(); - TLatex t2; - t2.SetTextAlign(21); - t2.SetTextSize(0.1); - t2.SetTextAngle(45); - t2.SetTextColor(kRed); - t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + SiPixelPI::displayNotSupported(canvas, templMap.size()); std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); return false; @@ -270,15 +263,8 @@ namespace { if (templMap.size() != SiPixelPI::phase1size) { edm::LogError("SiPixelTemplateDBObject_PayloadInspector") << "SiPixelTempateIDs maps are not supported for non-Phase1 Pixel geometries !"; - std::string phase = (templMap.size() < SiPixelPI::phase1size) ? "Phase-0" : "Phase-2"; TCanvas canvas("Canv", "Canv", 1200, 1000); - canvas.cd(); - TLatex t2; - t2.SetTextAlign(21); - t2.SetTextSize(0.1); - t2.SetTextAngle(45); - t2.SetTextColor(kRed); - t2.DrawLatexNDC(0.6, 0.50, Form("%s NOT SUPPORTED!", phase.c_str())); + SiPixelPI::displayNotSupported(canvas, templMap.size()); std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); return false; From 909682b5a2628f537ddd5ba5d450ea842d753b27 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 27 Apr 2020 17:21:49 +0200 Subject: [PATCH 08/32] add PixelRegionContainers class --- .../interface/PixelRegionContainers.h | 166 ++++++++++++++++++ .../SiPixelLorentzAngle_PayloadInspector.cc | 1 + 2 files changed, 167 insertions(+) create mode 100644 CondCore/SiPixelPlugins/interface/PixelRegionContainers.h diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h new file mode 100644 index 0000000000000..c13faa07fc161 --- /dev/null +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -0,0 +1,166 @@ +#ifndef CONDCORE_SIPIXELPLUGINS_PIXELREGIONCONTAINERS_H +#define CONDCORE_SIPIXELPLUGINS_PIXELREGIONCONTAINERS_H + +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" +#include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" + +#include "TH1.h" + +namespace PixelRegions{ + + // "PixelId" + // BPix: 1000*(subdetId=1) + 100*(layer=1,2,3,4) + // FPix: 1000*(subdetId=2) + 100*(side=1,2) + 10*(disk=1,2,3) + 1*(ring=1,2) + enum PixelId { + L1=1100, L2=1200, L3=1300, L4=1400, // BPix + Rm1l=2111, Rm1u=2112, Rm2l=2121, Rm2u=2122, Rm3l=2131, Rm3u=2132, // FPix minus + Rp1l=2211, Rp1u=2212, Rp2l=2221, Rp2u=2222, Rp3l=2231, Rp3u=2232, // FPix plus + End=99999 + }; + + const std::vector PixelIDs = {PixelId::L1,PixelId::L2,PixelId::L3,PixelId::L4, // BPix + PixelId::Rm1l,PixelId::Rm1u,PixelId::Rm2l,PixelId::Rm2u,PixelId::Rm3l,PixelId::Rm3u, // FPix minus + PixelId::Rp1l,PixelId::Rp1u,PixelId::Rp2l,PixelId::Rp2u,PixelId::Rp3l,PixelId::Rp3u, // FPix plus + PixelId::End}; + + static const PixelId calculateBPixID(const unsigned int layer){ + // BPix: 1000*(subdetId=1) + 100*(layer=1,2,3,4) + PixelId bpixLayer = static_cast(1000+100*layer); + return bpixLayer; + } + + static const PixelId calculateFPixID(const unsigned int side, const unsigned int disk, const unsigned int ring){ + // FPix: 1000*(subdetId=2) + 100*(side=1,2) + 10*(disk=1,2,3) + 1*(ring=1,2) + PixelId fpixRing = static_cast(2000+100*side+10*disk+ring); + return fpixRing; + } + + static const int getPixelSubDetector(const unsigned int pixid){ //SiPixelVCalDB::PixelId + // subdetId: BPix=1, FPix=2 + return (pixid/1000)%10; + } + + static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology* trackTopo, const bool phase1){ + DetId detId = DetId(detid); + unsigned int subid = detId.subdetId(); + unsigned int pixid = 0; + if (subid==PixelSubdetector::PixelBarrel){ + PixelBarrelName bpix(detId,trackTopo,phase1); + int layer = bpix.layerName(); + pixid = calculateBPixID(layer); + } + else if (subid==PixelSubdetector::PixelEndcap){ + PixelEndcapName fpix(detId,trackTopo,phase1); + int side = trackTopo->pxfSide(detId); // 1 (-z), 2 for (+z) + int disk = fpix.diskName(); //trackTopo->pxfDisk(detId); // 1, 2, 3 + int ring = fpix.ringName(); // 1 (lower), 2 (upper) + pixid = calculateFPixID(side,disk,ring); + } + PixelId pixID = static_cast(pixid); + return pixID; + } + + class PixelRegionContainers { + public: + PixelRegionContainers(const TrackerTopology*& t_topo, const bool isPhase1): + m_trackerTopo(t_topo), + m_isPhase1(isPhase1) {} + + ~PixelRegionContainers(){} + + void bookAll(std::string x_label,std::string y_label,const int nbins, const float xmin, const float xmax){ + + for (int i = PixelId::L1; i < PixelId::End; i++ ){ + switch(i) + { + case PixelId::L1: + m_theMap.at(PixelId::L1) = std::make_shared(Form("Barrel Pixel L1 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::L2: + m_theMap.at(PixelId::L2) = std::make_shared(Form("Barrel Pixel L2 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::L3: + m_theMap.at(PixelId::L3) = std::make_shared(Form("Barrel Pixel L3 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::L4: + m_theMap.at(PixelId::L4) = std::make_shared(Form("Barrel Pixel L4 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rm1l: + m_theMap.at(PixelId::Rm1l) = std::make_shared(Form("FPIX(-) Disk 1 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rm1u: + m_theMap.at(PixelId::Rm1u) = std::make_shared(Form("FPIX(-) Disk 1 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rm2l: + m_theMap.at(PixelId::Rm2l) = std::make_shared(Form("FPIX(-) Disk 2 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rm2u: + m_theMap.at(PixelId::Rm2u) = std::make_shared(Form("FPIX(-) Disk 2 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rm3l: + m_theMap.at(PixelId::Rm3l) = std::make_shared(Form("FPIX(-) Disk 3 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rm3u: + m_theMap.at(PixelId::Rm3u) = std::make_shared(Form("FPIX(-) Disk 3 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rp1l: + m_theMap.at(PixelId::Rp1l) = std::make_shared(Form("FPIX(+) Disk 1 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rp1u: + m_theMap.at(PixelId::Rp1u) = std::make_shared(Form("FPIX(+) Disk 1 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rp2l: + m_theMap.at(PixelId::Rp2l) = std::make_shared(Form("FPIX(+) Disk 2 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rp2u: + m_theMap.at(PixelId::Rp2u) = std::make_shared(Form("FPIX(+) Disk 2 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rp3l: + m_theMap.at(PixelId::Rp3l) = std::make_shared(Form("FPIX(+) Disk 3 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + case PixelId::Rp3u: + m_theMap.at(PixelId::Rp3u) = std::make_shared(Form("FPIX(+) Disk 3 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); + break; + default: + /* Found an invalid enum entry; ignore it */ + break; + } + } + } + + void fill(const unsigned int detid,const float value){ + // convert from detid to pixelid + PixelRegions::PixelId myId = PixelRegions::detIdToPixelId(detid,m_trackerTopo,m_isPhase1); + m_theMap.at(myId)->Fill(value); + } + + void draw(TCanvas &canv,bool isBarrel){ + + if(isBarrel){ + for(int j = 1; j<=4;j++){ + canv.cd(j); + m_theMap.at(PixelIDs[j-1])->Draw(); + } + } else { // forward + for(int j = 1; j<=12;j++){ + canv.cd(j); + m_theMap.at(PixelIDs[j+3])->Draw(); + } + } + + } + + private: + const TrackerTopology* m_trackerTopo; + bool m_isPhase1; + + std::map> m_theMap; + int m_nbins; + float m_xim, m_xmax; + bool m_isLog; + + }; +} +#endif diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index b52565de14beb..079a6e6b170f7 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -13,6 +13,7 @@ #include "FWCore/ParameterSet/interface/FileInPath.h" #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h" #include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h" +#include "CondCore/SiPixelPlugins/interface/PixelRegionContainers.h" #include #include From ab1f69d4a49f4b246e8c3ba1db4499e13a6ac85e Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 30 Apr 2020 16:55:06 +0200 Subject: [PATCH 09/32] make us of PixelRegionContainers inside the LorentzAngle Payload Inspector --- .../interface/PixelRegionContainers.h | 358 ++++++++++++------ .../SiPixelLorentzAngle_PayloadInspector.cc | 105 ++++- 2 files changed, 347 insertions(+), 116 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index c13faa07fc161..972332fedb198 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -7,56 +7,105 @@ #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" #include "TH1.h" +#include -namespace PixelRegions{ +namespace PixelRegions { + + std::string itoa(int i) { + char temp[20]; + sprintf(temp, "%d", i); + return ((std::string)temp); + } // "PixelId" // BPix: 1000*(subdetId=1) + 100*(layer=1,2,3,4) // FPix: 1000*(subdetId=2) + 100*(side=1,2) + 10*(disk=1,2,3) + 1*(ring=1,2) enum PixelId { - L1=1100, L2=1200, L3=1300, L4=1400, // BPix - Rm1l=2111, Rm1u=2112, Rm2l=2121, Rm2u=2122, Rm3l=2131, Rm3u=2132, // FPix minus - Rp1l=2211, Rp1u=2212, Rp2l=2221, Rp2u=2222, Rp3l=2231, Rp3u=2232, // FPix plus - End=99999 + L1 = 1100, + L2 = 1200, + L3 = 1300, + L4 = 1400, // BPix + Rm1l = 2111, + Rm1u = 2112, + Rm2l = 2121, + Rm2u = 2122, + Rm3l = 2131, + Rm3u = 2132, // FPix minus + Rp1l = 2211, + Rp1u = 2212, + Rp2l = 2221, + Rp2u = 2222, + Rp3l = 2231, + Rp3u = 2232, // FPix plus + End = 99999 }; - - const std::vector PixelIDs = {PixelId::L1,PixelId::L2,PixelId::L3,PixelId::L4, // BPix - PixelId::Rm1l,PixelId::Rm1u,PixelId::Rm2l,PixelId::Rm2u,PixelId::Rm3l,PixelId::Rm3u, // FPix minus - PixelId::Rp1l,PixelId::Rp1u,PixelId::Rp2l,PixelId::Rp2u,PixelId::Rp3l,PixelId::Rp3u, // FPix plus - PixelId::End}; - - static const PixelId calculateBPixID(const unsigned int layer){ + + const std::vector PixelIDs = {PixelId::L1, + PixelId::L2, + PixelId::L3, + PixelId::L4, // BPix + PixelId::Rm1l, + PixelId::Rm1u, + PixelId::Rm2l, + PixelId::Rm2u, + PixelId::Rm3l, + PixelId::Rm3u, // FPix minus + PixelId::Rp1l, + PixelId::Rp1u, + PixelId::Rp2l, + PixelId::Rp2u, + PixelId::Rp3l, + PixelId::Rp3u, // FPix plus + PixelId::End}; + + const std::vector IDlabels = {"Barrel Pixel L1", + "Barrel Pixel L2", + "Barrel Pixel L3", + "Barrel Pixel L4", + "FPIX(-) Disk 1 inner ring", + "FPIX(-) Disk 1 outer ring", + "FPIX(-) Disk 2 inner ring", + "FPIX(-) Disk 2 outer ring", + "FPIX(-) Disk 3 inner ring", + "FPIX(-) Disk 3 outer ring", + "FPIX(+) Disk 1 inner ring", + "FPIX(+) Disk 1 outer ring", + "FPIX(+) Disk 2 inner ring", + "FPIX(+) Disk 2 outer ring", + "FPIX(+) Disk 3 inner ring", + "FPIX(+) Disk 3 outer ring"}; + + static const PixelId calculateBPixID(const unsigned int layer) { // BPix: 1000*(subdetId=1) + 100*(layer=1,2,3,4) - PixelId bpixLayer = static_cast(1000+100*layer); + PixelId bpixLayer = static_cast(1000 + 100 * layer); return bpixLayer; } - - static const PixelId calculateFPixID(const unsigned int side, const unsigned int disk, const unsigned int ring){ + + static const PixelId calculateFPixID(const unsigned int side, const unsigned int disk, const unsigned int ring) { // FPix: 1000*(subdetId=2) + 100*(side=1,2) + 10*(disk=1,2,3) + 1*(ring=1,2) - PixelId fpixRing = static_cast(2000+100*side+10*disk+ring); + PixelId fpixRing = static_cast(2000 + 100 * side + 10 * disk + ring); return fpixRing; } - - static const int getPixelSubDetector(const unsigned int pixid){ //SiPixelVCalDB::PixelId + + static const int getPixelSubDetector(const unsigned int pixid) { // subdetId: BPix=1, FPix=2 - return (pixid/1000)%10; + return (pixid / 1000) % 10; } - - static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology* trackTopo, const bool phase1){ + + static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology* trackTopo, const bool phase1) { DetId detId = DetId(detid); unsigned int subid = detId.subdetId(); unsigned int pixid = 0; - if (subid==PixelSubdetector::PixelBarrel){ - PixelBarrelName bpix(detId,trackTopo,phase1); + if (subid == PixelSubdetector::PixelBarrel) { + PixelBarrelName bpix(detId, trackTopo, phase1); int layer = bpix.layerName(); pixid = calculateBPixID(layer); - } - else if (subid==PixelSubdetector::PixelEndcap){ - PixelEndcapName fpix(detId,trackTopo,phase1); - int side = trackTopo->pxfSide(detId); // 1 (-z), 2 for (+z) - int disk = fpix.diskName(); //trackTopo->pxfDisk(detId); // 1, 2, 3 - int ring = fpix.ringName(); // 1 (lower), 2 (upper) - pixid = calculateFPixID(side,disk,ring); + } else if (subid == PixelSubdetector::PixelEndcap) { + PixelEndcapName fpix(detId, trackTopo, phase1); + int side = trackTopo->pxfSide(detId); // 1 (-z), 2 for (+z) + int disk = fpix.diskName(); //trackTopo->pxfDisk(detId); // 1, 2, 3 + int ring = fpix.ringName(); // 1 (lower), 2 (upper) + pixid = calculateFPixID(side, disk, ring); } PixelId pixID = static_cast(pixid); return pixID; @@ -64,103 +113,192 @@ namespace PixelRegions{ class PixelRegionContainers { public: - PixelRegionContainers(const TrackerTopology*& t_topo, const bool isPhase1): - m_trackerTopo(t_topo), - m_isPhase1(isPhase1) {} - - ~PixelRegionContainers(){} - - void bookAll(std::string x_label,std::string y_label,const int nbins, const float xmin, const float xmax){ - - for (int i = PixelId::L1; i < PixelId::End; i++ ){ - switch(i) - { - case PixelId::L1: - m_theMap.at(PixelId::L1) = std::make_shared(Form("Barrel Pixel L1 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::L2: - m_theMap.at(PixelId::L2) = std::make_shared(Form("Barrel Pixel L2 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::L3: - m_theMap.at(PixelId::L3) = std::make_shared(Form("Barrel Pixel L3 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::L4: - m_theMap.at(PixelId::L4) = std::make_shared(Form("Barrel Pixel L4 %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rm1l: - m_theMap.at(PixelId::Rm1l) = std::make_shared(Form("FPIX(-) Disk 1 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rm1u: - m_theMap.at(PixelId::Rm1u) = std::make_shared(Form("FPIX(-) Disk 1 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rm2l: - m_theMap.at(PixelId::Rm2l) = std::make_shared(Form("FPIX(-) Disk 2 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rm2u: - m_theMap.at(PixelId::Rm2u) = std::make_shared(Form("FPIX(-) Disk 2 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rm3l: - m_theMap.at(PixelId::Rm3l) = std::make_shared(Form("FPIX(-) Disk 3 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rm3u: - m_theMap.at(PixelId::Rm3u) = std::make_shared(Form("FPIX(-) Disk 3 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rp1l: - m_theMap.at(PixelId::Rp1l) = std::make_shared(Form("FPIX(+) Disk 1 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rp1u: - m_theMap.at(PixelId::Rp1u) = std::make_shared(Form("FPIX(+) Disk 1 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rp2l: - m_theMap.at(PixelId::Rp2l) = std::make_shared(Form("FPIX(+) Disk 2 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rp2u: - m_theMap.at(PixelId::Rp2u) = std::make_shared(Form("FPIX(+) Disk 2 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rp3l: - m_theMap.at(PixelId::Rp3l) = std::make_shared(Form("FPIX(+) Disk 3 inner ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - case PixelId::Rp3u: - m_theMap.at(PixelId::Rp3u) = std::make_shared(Form("FPIX(+) Disk 3 outer ring %s",x_label.c_str()),Form("%s;%s",x_label.c_str(),y_label.c_str()),nbins,xmin,xmax); - break; - default: + PixelRegionContainers(const TrackerTopology* t_topo, const bool isPhase1) + : m_trackerTopo(t_topo), m_isPhase1(isPhase1) {} + + ~PixelRegionContainers() {} + + void bookAll(std::string title_label, + std::string x_label, + std::string y_label, + const int nbins, + const float xmin, + const float xmax) { + for (int i = PixelId::L1; i < PixelId::End; i++) { + switch (i) { + case PixelId::L1: + m_theMap[PixelId::L1] = std::make_shared( + itoa(i).c_str(), + Form("Barrel Pixel L1 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::L2: + m_theMap[PixelId::L2] = std::make_shared( + itoa(i).c_str(), + Form("Barrel Pixel L2 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::L3: + m_theMap[PixelId::L3] = std::make_shared( + itoa(i).c_str(), + Form("Barrel Pixel L3 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::L4: + m_theMap[PixelId::L4] = std::make_shared( + itoa(i).c_str(), + Form("Barrel Pixel L4 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rm1l: + m_theMap[PixelId::Rm1l] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(-) Disk 1 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rm1u: + m_theMap[PixelId::Rm1u] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(-) Disk 1 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rm2l: + m_theMap[PixelId::Rm2l] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(-) Disk 2 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rm2u: + m_theMap[PixelId::Rm2u] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(-) Disk 2 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rm3l: + m_theMap[PixelId::Rm3l] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(-) Disk 3 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rm3u: + m_theMap[PixelId::Rm3u] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(-) Disk 3 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rp1l: + m_theMap[PixelId::Rp1l] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(+) Disk 1 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rp1u: + m_theMap[PixelId::Rp1u] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(+) Disk 1 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rp2l: + m_theMap[PixelId::Rp2l] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(+) Disk 2 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rp2u: + m_theMap[PixelId::Rp2u] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(+) Disk 2 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rp3l: + m_theMap[PixelId::Rp3l] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(+) Disk 3 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + case PixelId::Rp3u: + m_theMap[PixelId::Rp3u] = std::make_shared( + itoa(i).c_str(), + Form("FPIX(+) Disk 3 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), + nbins, + xmin, + xmax); + break; + default: /* Found an invalid enum entry; ignore it */ - break; - } + break; + } } } - void fill(const unsigned int detid,const float value){ + void fill(const unsigned int detid, const float value) { // convert from detid to pixelid - PixelRegions::PixelId myId = PixelRegions::detIdToPixelId(detid,m_trackerTopo,m_isPhase1); - m_theMap.at(myId)->Fill(value); + PixelRegions::PixelId myId = PixelRegions::detIdToPixelId(detid, m_trackerTopo, m_isPhase1); + m_theMap[myId]->Fill(value); } - void draw(TCanvas &canv,bool isBarrel){ - - if(isBarrel){ - for(int j = 1; j<=4;j++){ - canv.cd(j); - m_theMap.at(PixelIDs[j-1])->Draw(); - } - } else { // forward - for(int j = 1; j<=12;j++){ - canv.cd(j); - m_theMap.at(PixelIDs[j+3])->Draw(); - } + void draw(TCanvas& canv, bool isBarrel) { + if (isBarrel) { + for (int j = 1; j <= 4; j++) { + canv.cd(j); + m_theMap.at(PixelIDs[j - 1])->Draw("bar2"); + } + } else { // forward + for (int j = 1; j <= 12; j++) { + canv.cd(j); + m_theMap.at(PixelIDs[j + 3])->Draw("bar2"); + } } + } + void beautify() { + for (const auto& plot : m_theMap) { + plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30); + plot.second->SetFillColor(kRed); + plot.second->SetMarkerStyle(20); + plot.second->SetMarkerSize(1); + SiPixelPI::makeNicePlotStyle(plot.second.get()); + } } private: const TrackerTopology* m_trackerTopo; bool m_isPhase1; - std::map> m_theMap; + std::map> m_theMap; int m_nbins; float m_xim, m_xmax; bool m_isLog; - }; -} +} // namespace PixelRegions #endif diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 079a6e6b170f7..61d74214e2965 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -83,8 +83,8 @@ namespace { new TH1F("value", "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", 50, - extrema.first*0.9, - extrema.second*1.1)); + extrema.first * 0.9, + extrema.second * 1.1)); SiPixelPI::adjustCanvasMargins(canvas.cd(), 0.06, 0.12, 0.12, 0.05); canvas.Modified(); @@ -133,6 +133,97 @@ namespace { } }; + /************************************************ + 1d histogram of SiPixelLorentzAngle of 1 IOV per region + *************************************************/ + template + class SiPixelLorentzAngleValuesPerRegion : public cond::payloadInspector::PlotImage { + public: + SiPixelLorentzAngleValuesPerRegion() + : cond::payloadInspector::PlotImage("SiPixelLorentzAngle Values per region") { + setSingleIov(true); + } + + bool fill(const std::vector> &iovs) override { + gStyle->SetOptStat("emr"); + + auto iov = iovs.front(); + std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + std::map LAMap_ = payload->getLorentzAngles(); + auto extrema = SiPixelPI::findMinMaxInMap(LAMap_); + + TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); + canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); + canvas.cd(); + + const char *path_toTopologyXML = (LAMap_.size() == SiPixelPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + TrackerTopology tTopo = + StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); + + auto myPlots = PixelRegions::PixelRegionContainers(&tTopo, true); + myPlots.bookAll("SiPixel LA", + "SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T]", + "#modules", + 50, + extrema.first * 0.9, + extrema.second * 1.1); + + canvas.Modified(); + + for (const auto &element : LAMap_) { + myPlots.fill(element.first, element.second); + } + + //h1->SetStats(true); + + myPlots.beautify(); + myPlots.draw(canvas, isBarrel); + + TLegend legend = TLegend(0.30, 0.88, 0.85, 0.90); + legend.SetHeader(("Payload hash: #bf{" + (std::get<1>(iov)) + "}").c_str(), + "C"); // option "C" allows to center the header + //legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL"); + legend.SetTextSize(0.025); + legend.SetLineColor(10); + + unsigned int maxPads = isBarrel ? 4 : 12; + for (unsigned int c = 1; c <= maxPads; c++) { + canvas.cd(c); + SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.07, 0.11, 0.12, 0.03); + legend.Draw("same"); + } + + /* + TPaveStats *st = (TPaveStats *)h1->FindObject("stats"); + st->SetTextSize(0.03); + SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); + */ + + /* + canvas.cd(1); + + 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, + ("SiPixel Lorentz Angle IOV:" + std::to_string(std::get<0>(iov))).c_str()); + */ + + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + + return true; + } + }; + + using SiPixelLorentzAngleValuesBarrel = SiPixelLorentzAngleValuesPerRegion; + using SiPixelLorentzAngleValuesEndcap = SiPixelLorentzAngleValuesPerRegion; + /************************************************ 1d histogram of SiPixelLorentzAngle of 1 IOV *************************************************/ @@ -170,16 +261,16 @@ namespace { new TH1F("value_first", "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", 50, - min*0.9, - max*1.1)); + min * 0.9, + max * 1.1)); hfirst->SetStats(false); auto hlast = std::unique_ptr( new TH1F("value_last", "SiPixel LA value;SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T];# modules", 50, - min*0.9, - max*1.1)); + min * 0.9, + max * 1.1)); hlast->SetStats(false); SiPixelPI::adjustCanvasMargins(canvas.cd(), 0.06, 0.12, 0.12, 0.05); @@ -713,6 +804,8 @@ namespace { PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) { PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValue); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValues); + PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesBarrel); + PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesEndcap); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValueComparisonSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValueComparisonTwoTags); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleByRegionComparisonSingleTag); From 1b12449e1d90690bde85ff39de19a1d68fae4c4e Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 30 Apr 2020 17:01:57 +0200 Subject: [PATCH 10/32] update LorentzAngle Payload Inspector test --- .../test/testSiPixelLorentzAngle.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh index 2392ffdaeb478..23c6ad3f91e9c 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh @@ -75,3 +75,25 @@ getPayloadData.py \ --test ; mv *.png $W_DIR/plots_LA/SiPixelBPixLorentzAngleMap.png + +getPayloadData.py \ + --plugin pluginSiPixelLorentzAngle_PayloadInspector \ + --plot plot_SiPixelLorentzAngleValuesEndcap \ + --tag SiPixelLorentzAngle_forWidth_phase1_mc_v1 \ + --time_type Run \ + --iovs '{"start_iov": "1", "end_iov": "1"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_LA/SiPixelBPixLorentzAngleEndcapPlots.png + +getPayloadData.py \ + --plugin pluginSiPixelLorentzAngle_PayloadInspector \ + --plot plot_SiPixelLorentzAngleValuesBarrel \ + --tag SiPixelLorentzAngle_forWidth_phase1_mc_v1 \ + --time_type Run \ + --iovs '{"start_iov": "1", "end_iov": "1"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_LA/SiPixelBPixLorentzAngleBarrel.png From 41e4d2587bc0a67b4014b7e277415f77d5de389e Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 3 May 2020 17:52:06 +0200 Subject: [PATCH 11/32] more work on the Lorentz Angle Payload inspector --- .../interface/PixelRegionContainers.h | 21 +++++++++++- .../SiPixelLorentzAngle_PayloadInspector.cc | 34 ++++++++----------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index 972332fedb198..9982ef6dd555f 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -105,6 +105,8 @@ namespace PixelRegions { int side = trackTopo->pxfSide(detId); // 1 (-z), 2 for (+z) int disk = fpix.diskName(); //trackTopo->pxfDisk(detId); // 1, 2, 3 int ring = fpix.ringName(); // 1 (lower), 2 (upper) + // ### FIXME ### + // ring numbering for phase-0 needs to be adjusted pixid = calculateFPixID(side, disk, ring); } PixelId pixID = static_cast(pixid); @@ -264,7 +266,12 @@ namespace PixelRegions { void fill(const unsigned int detid, const float value) { // convert from detid to pixelid PixelRegions::PixelId myId = PixelRegions::detIdToPixelId(detid, m_trackerTopo, m_isPhase1); - m_theMap[myId]->Fill(value); + if (m_theMap.find(myId) != m_theMap.end()) { + m_theMap[myId]->Fill(value); + } else { + edm::LogError("PixelRegionContainers") + << detid << " :=> " << myId << " is not a recongnized PixelId enumerator!" << std::endl; + } } void draw(TCanvas& canv, bool isBarrel) { @@ -283,11 +290,23 @@ namespace PixelRegions { void beautify() { for (const auto& plot : m_theMap) { + plot.second->SetTitle(""); plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30); plot.second->SetFillColor(kRed); plot.second->SetMarkerStyle(20); plot.second->SetMarkerSize(1); SiPixelPI::makeNicePlotStyle(plot.second.get()); + plot.second->SetStats(true); + } + } + + void stats() { + for (const auto& plot : m_theMap) { + TPaveStats* st = (TPaveStats*)plot.second->FindObject("stats"); + if (st) { + st->SetTextSize(0.03); + SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); + } } } diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 61d74214e2965..5f7d6cf7ad90b 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -162,7 +162,7 @@ namespace { TrackerTopology tTopo = StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); - auto myPlots = PixelRegions::PixelRegionContainers(&tTopo, true); + auto myPlots = PixelRegions::PixelRegionContainers(&tTopo, (LAMap_.size() == SiPixelPI::phase1size)); myPlots.bookAll("SiPixel LA", "SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T]", "#modules", @@ -176,13 +176,11 @@ namespace { myPlots.fill(element.first, element.second); } - //h1->SetStats(true); - myPlots.beautify(); myPlots.draw(canvas, isBarrel); - TLegend legend = TLegend(0.30, 0.88, 0.85, 0.90); - legend.SetHeader(("Payload hash: #bf{" + (std::get<1>(iov)) + "}").c_str(), + TLegend legend = TLegend(0.40, 0.88, 0.93, 0.90); + legend.SetHeader(("Hash: #bf{" + (std::get<1>(iov)) + "}").c_str(), "C"); // option "C" allows to center the header //legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL"); legend.SetTextSize(0.025); @@ -191,28 +189,26 @@ namespace { unsigned int maxPads = isBarrel ? 4 : 12; for (unsigned int c = 1; c <= maxPads; c++) { canvas.cd(c); - SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.07, 0.11, 0.12, 0.03); + SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.07, 0.12, 0.12, 0.05); legend.Draw("same"); + canvas.cd(c)->Update(); } - /* - TPaveStats *st = (TPaveStats *)h1->FindObject("stats"); - st->SetTextSize(0.03); - SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); - */ - - /* - canvas.cd(1); + myPlots.stats(); 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, - ("SiPixel Lorentz Angle IOV:" + std::to_string(std::get<0>(iov))).c_str()); - */ + + for (unsigned int c = 1; c <= maxPads; c++) { + auto index = isBarrel ? c - 1 : c + 3; + + canvas.cd(c); + ltx.DrawLatexNDC(gPad->GetLeftMargin(), + 1 - gPad->GetTopMargin() + 0.01, + (PixelRegions::IDlabels.at(index) + ", IOV:" + std::to_string(std::get<0>(iov))).c_str()); + } std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); From a16495c19ac433093f1b6cfcc5b243e22ffd035d Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 10 May 2020 23:00:37 +0200 Subject: [PATCH 12/32] add per region plots for the Gains and Pedestals --- .../interface/PixelRegionContainers.h | 227 ++++++------------ .../interface/SiPixelGainCalibHelper.h | 147 +++++++++++- CondCore/SiPixelPlugins/plugins/BuildFile.xml | 17 +- ...lGainCalibrationForHLT_PayloadInspector.cc | 18 ++ ...GainCalibrationOffline_PayloadInspector.cc | 18 ++ CondCore/SiPixelPlugins/test/BuildFile.xml | 1 + 6 files changed, 269 insertions(+), 159 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index 9982ef6dd555f..afb042c56cc6f 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -5,7 +5,9 @@ #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" - +#include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" +#include #include "TH1.h" #include @@ -20,42 +22,43 @@ namespace PixelRegions { // "PixelId" // BPix: 1000*(subdetId=1) + 100*(layer=1,2,3,4) // FPix: 1000*(subdetId=2) + 100*(side=1,2) + 10*(disk=1,2,3) + 1*(ring=1,2) + enum PixelId { - L1 = 1100, + L1 = 1100, // BPix L2 = 1200, L3 = 1300, - L4 = 1400, // BPix - Rm1l = 2111, + L4 = 1400, + Rm1l = 2111, // FPix minus Rm1u = 2112, Rm2l = 2121, Rm2u = 2122, Rm3l = 2131, - Rm3u = 2132, // FPix minus - Rp1l = 2211, + Rm3u = 2132, + Rp1l = 2211, // FPix plus Rp1u = 2212, Rp2l = 2221, Rp2u = 2222, Rp3l = 2231, - Rp3u = 2232, // FPix plus + Rp3u = 2232, End = 99999 }; - const std::vector PixelIDs = {PixelId::L1, + const std::vector PixelIDs = {PixelId::L1, // BPix PixelId::L2, PixelId::L3, - PixelId::L4, // BPix - PixelId::Rm1l, + PixelId::L4, + PixelId::Rm1l, // FPix minus PixelId::Rm1u, PixelId::Rm2l, PixelId::Rm2u, PixelId::Rm3l, - PixelId::Rm3u, // FPix minus - PixelId::Rp1l, + PixelId::Rm3u, + PixelId::Rp1l, // FPix plus PixelId::Rp1u, PixelId::Rp2l, PixelId::Rp2u, PixelId::Rp3l, - PixelId::Rp3u, // FPix plus + PixelId::Rp3u, PixelId::End}; const std::vector IDlabels = {"Barrel Pixel L1", @@ -73,25 +76,30 @@ namespace PixelRegions { "FPIX(+) Disk 2 inner ring", "FPIX(+) Disk 2 outer ring", "FPIX(+) Disk 3 inner ring", - "FPIX(+) Disk 3 outer ring"}; + "FPIX(+) Disk 3 outer ring", + "END"}; + //============================================================================ static const PixelId calculateBPixID(const unsigned int layer) { // BPix: 1000*(subdetId=1) + 100*(layer=1,2,3,4) PixelId bpixLayer = static_cast(1000 + 100 * layer); return bpixLayer; } + //============================================================================ static const PixelId calculateFPixID(const unsigned int side, const unsigned int disk, const unsigned int ring) { // FPix: 1000*(subdetId=2) + 100*(side=1,2) + 10*(disk=1,2,3) + 1*(ring=1,2) PixelId fpixRing = static_cast(2000 + 100 * side + 10 * disk + ring); return fpixRing; } + //============================================================================ static const int getPixelSubDetector(const unsigned int pixid) { // subdetId: BPix=1, FPix=2 return (pixid / 1000) % 10; } + //============================================================================ static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology* trackTopo, const bool phase1) { DetId detId = DetId(detid); unsigned int subid = detId.subdetId(); @@ -104,15 +112,41 @@ namespace PixelRegions { PixelEndcapName fpix(detId, trackTopo, phase1); int side = trackTopo->pxfSide(detId); // 1 (-z), 2 for (+z) int disk = fpix.diskName(); //trackTopo->pxfDisk(detId); // 1, 2, 3 - int ring = fpix.ringName(); // 1 (lower), 2 (upper) - // ### FIXME ### - // ring numbering for phase-0 needs to be adjusted + // This works only in case of the Phase-1 detector + //int ring = fpix.ringName(); // 1 (lower), 2 (upper) + int ring = SiPixelPI::ring(detid, *trackTopo, phase1); // 1 (lower), 2 (upper) pixid = calculateFPixID(side, disk, ring); } PixelId pixID = static_cast(pixid); return pixID; } + //============================================================================ + static const std::vector attachedDets(const PixelRegions::PixelId theId, + const TrackerTopology* trackTopo, + const bool phase1) { + std::vector out; + edm::FileInPath m_fp; + if (phase1) { + m_fp = edm::FileInPath("SLHCUpgradeSimulations/Geometry/data/PhaseI/PixelSkimmedGeometry_phase1.txt"); + } else { + m_fp = edm::FileInPath("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt"); + } + + SiPixelDetInfoFileReader pxlreader(m_fp.fullPath()); + const std::vector& pxldetids = pxlreader.getAllDetIds(); + for (const auto& d : pxldetids) { + auto ID = detIdToPixelId(d, trackTopo, phase1); + if (ID == theId) { + out.push_back(d); + } + } + return out; + } + + /*-------------------------------------------------------------------- + / Ancillary class to build pixel phase0/phase1 plots per region + /--------------------------------------------------------------------*/ class PixelRegionContainers { public: PixelRegionContainers(const TrackerTopology* t_topo, const bool isPhase1) @@ -120,149 +154,27 @@ namespace PixelRegions { ~PixelRegionContainers() {} + //============================================================================ void bookAll(std::string title_label, std::string x_label, std::string y_label, const int nbins, const float xmin, const float xmax) { - for (int i = PixelId::L1; i < PixelId::End; i++) { - switch (i) { - case PixelId::L1: - m_theMap[PixelId::L1] = std::make_shared( - itoa(i).c_str(), - Form("Barrel Pixel L1 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::L2: - m_theMap[PixelId::L2] = std::make_shared( - itoa(i).c_str(), - Form("Barrel Pixel L2 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::L3: - m_theMap[PixelId::L3] = std::make_shared( - itoa(i).c_str(), - Form("Barrel Pixel L3 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::L4: - m_theMap[PixelId::L4] = std::make_shared( - itoa(i).c_str(), - Form("Barrel Pixel L4 %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rm1l: - m_theMap[PixelId::Rm1l] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(-) Disk 1 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rm1u: - m_theMap[PixelId::Rm1u] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(-) Disk 1 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rm2l: - m_theMap[PixelId::Rm2l] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(-) Disk 2 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rm2u: - m_theMap[PixelId::Rm2u] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(-) Disk 2 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rm3l: - m_theMap[PixelId::Rm3l] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(-) Disk 3 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rm3u: - m_theMap[PixelId::Rm3u] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(-) Disk 3 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rp1l: - m_theMap[PixelId::Rp1l] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(+) Disk 1 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rp1u: - m_theMap[PixelId::Rp1u] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(+) Disk 1 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rp2l: - m_theMap[PixelId::Rp2l] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(+) Disk 2 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rp2u: - m_theMap[PixelId::Rp2u] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(+) Disk 2 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rp3l: - m_theMap[PixelId::Rp3l] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(+) Disk 3 inner ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - case PixelId::Rp3u: - m_theMap[PixelId::Rp3u] = std::make_shared( - itoa(i).c_str(), - Form("FPIX(+) Disk 3 outer ring %s;%s;%s", title_label.c_str(), x_label.c_str(), y_label.c_str()), - nbins, - xmin, - xmax); - break; - default: - /* Found an invalid enum entry; ignore it */ - break; - } + for (const auto& pixelId : PixelIDs | boost::adaptors::indexed(0)) { + m_theMap[pixelId.value()] = std::make_shared(itoa(pixelId.value()).c_str(), + Form("%s %s;%s;%s", + (IDlabels.at(pixelId.index())).c_str(), + title_label.c_str(), + x_label.c_str(), + y_label.c_str()), + nbins, + xmin, + xmax); } } + //============================================================================ void fill(const unsigned int detid, const float value) { // convert from detid to pixelid PixelRegions::PixelId myId = PixelRegions::detIdToPixelId(detid, m_trackerTopo, m_isPhase1); @@ -274,6 +186,7 @@ namespace PixelRegions { } } + //============================================================================ void draw(TCanvas& canv, bool isBarrel) { if (isBarrel) { for (int j = 1; j <= 4; j++) { @@ -288,6 +201,7 @@ namespace PixelRegions { } } + //============================================================================ void beautify() { for (const auto& plot : m_theMap) { plot.second->SetTitle(""); @@ -300,6 +214,7 @@ namespace PixelRegions { } } + //============================================================================ void stats() { for (const auto& plot : m_theMap) { TPaveStats* st = (TPaveStats*)plot.second->FindObject("stats"); @@ -310,6 +225,16 @@ namespace PixelRegions { } } + //============================================================================ + std::shared_ptr& getHistoFromMap(const PixelRegions::PixelId& theId) { + auto it = m_theMap.find(theId); + if (it != m_theMap.end()) { + return it->second; + } else { + throw cms::Exception("PixelRegionContainer") << "No histogram is available for PixelId" << theId << "\n"; + } + } + private: const TrackerTopology* m_trackerTopo; bool m_isPhase1; diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 19da098b22c3a..099b7b45f68d4 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -10,6 +10,7 @@ #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationOffline.h" #include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLT.h" +#include "CondCore/SiPixelPlugins/interface/PixelRegionContainers.h" #include #include @@ -40,9 +41,14 @@ namespace gainCalibHelper { template static void fillTheHisto(const std::shared_ptr& payload, std::shared_ptr h1, - gainCalibPI::type theType) { + gainCalibPI::type theType, + const std::vector& wantedIds = {}) { std::vector detids; - payload->getDetIds(detids); + if (wantedIds.empty()) { + payload->getDetIds(detids); + } else { + detids.assign(wantedIds.begin(), wantedIds.end()); + } for (const auto& d : detids) { auto range = payload->getRange(d); @@ -293,6 +299,143 @@ namespace gainCalibHelper { std::string label_; }; + /******************************************************************* + 1d histograms per region of SiPixelGainCalibration for Gains of 1 IOV + ********************************************************************/ + template + class SiPixelGainCalibrationValuesPerRegion : public cond::payloadInspector::PlotImage { + public: + SiPixelGainCalibrationValuesPerRegion() + : cond::payloadInspector::PlotImage( + Form("SiPixelGainCalibration %s Values Per Region", TypeName[myType])) { + this->setSingleIov(true); + if constexpr (std::is_same_v) { + isForHLT_ = false; + label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; + } else { + isForHLT_ = true; + label_ = "SiPixelGainCalibrationForHLT_PayloadInspector"; + } + } + + bool fill(const std::vector>& iovs) override { + gStyle->SetOptStat("emr"); + + auto iov = iovs.front(); + std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); + + std::vector detids; + payload->getDetIds(detids); + + float minimum(9999.); + float maximum(-9999.); + + switch (myType) { + case gainCalibPI::t_gain: + maximum = payload->getGainHigh(); + minimum = payload->getGainLow(); + break; + case gainCalibPI::t_pedestal: + maximum = payload->getPedHigh(); + minimum = payload->getPedLow(); + break; + default: + edm::LogError(label_) << "Unrecognized type " << myType << std::endl; + break; + } + + TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); + canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); + canvas.cd(); + + const char* path_toTopologyXML = (detids.size() == SiPixelPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + TrackerTopology tTopo = + StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); + + auto myPlots = PixelRegions::PixelRegionContainers(&tTopo, (detids.size() == SiPixelPI::phase1size)); + myPlots.bookAll(Form("SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]), + Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]), + Form("# %ss", (isForHLT_ ? "column" : "pixel")), + 200, + minimum, + maximum); + + canvas.Modified(); + + // fill the histograms + for (const auto& pixelId : PixelRegions::PixelIDs) { + auto wantedDets = PixelRegions::attachedDets(pixelId, &tTopo, (detids.size() == SiPixelPI::phase1size)); + gainCalibPI::fillTheHisto(payload, myPlots.getHistoFromMap(pixelId), myType, wantedDets); + } + + myPlots.beautify(); + myPlots.draw(canvas, isBarrel); + + /* + canvas.cd()->SetLogy(); + h1->SetTitle(""); + h1->GetYaxis()->SetRangeUser(0.1, h1->GetMaximum() * 10.); + h1->SetFillColor(kBlue); + h1->SetMarkerStyle(20); + h1->SetMarkerSize(1); + h1->Draw("bar2"); + + SiPixelPI::makeNicePlotStyle(h1.get()); + h1->SetStats(true); + + canvas.Update(); + */ + + TLegend legend = TLegend(0.40, 0.88, 0.94, 0.93); + legend.SetHeader(("Payload hash: #bf{" + (std::get<1>(iov)) + "}").c_str(), + "C"); // option "C" allows to center the header + //legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL"); + legend.SetLineColor(10); + legend.SetTextSize(0.025); + legend.Draw("same"); + + unsigned int maxPads = isBarrel ? 4 : 12; + for (unsigned int c = 1; c <= maxPads; c++) { + canvas.cd(c); + SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.07, 0.12, 0.12, 0.05); + legend.Draw("same"); + canvas.cd(c)->Update(); + } + + myPlots.stats(); + + /* + TPaveStats* st = (TPaveStats*)h1->FindObject("stats"); + st->SetTextSize(0.03); + SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); + */ + + auto ltx = TLatex(); + ltx.SetTextFont(62); + ltx.SetTextSize(0.05); + ltx.SetTextAlign(11); + + for (unsigned int c = 1; c <= maxPads; c++) { + auto index = isBarrel ? c - 1 : c + 3; + canvas.cd(c); + ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.1, + 1 - gPad->GetTopMargin() + 0.01, + (PixelRegions::IDlabels.at(index) + ", IOV:" + std::to_string(std::get<0>(iov))).c_str()); + } + + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + + return true; + } + + protected: + bool isForHLT_; + std::string label_; + }; + /******************************************************************* 1d histogram of SiPixelGainCalibration for Gain/Pedestals correlation of 1 IOV diff --git a/CondCore/SiPixelPlugins/plugins/BuildFile.xml b/CondCore/SiPixelPlugins/plugins/BuildFile.xml index b645ea6df98ab..7d73c18a988be 100644 --- a/CondCore/SiPixelPlugins/plugins/BuildFile.xml +++ b/CondCore/SiPixelPlugins/plugins/BuildFile.xml @@ -3,6 +3,7 @@ + @@ -11,6 +12,7 @@ + @@ -19,6 +21,7 @@ + @@ -27,14 +30,16 @@ + - - - - - - + + + + + + + diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc index 8eefce7a395b7..0223134febb6e 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc @@ -16,6 +16,20 @@ namespace { gainCalibHelper::SiPixelGainCalibrationValues; + using SiPixelGainCalibrationForHLTGainsValuesBarrel = gainCalibHelper:: + SiPixelGainCalibrationValuesPerRegion; + using SiPixelGainCalibrationForHLTGainsValuesEndcap = gainCalibHelper:: + SiPixelGainCalibrationValuesPerRegion; + + using SiPixelGainCalibrationForHLTPedestalsValuesBarrel = + gainCalibHelper::SiPixelGainCalibrationValuesPerRegion; + using SiPixelGainCalibrationForHLTPedestalsValuesEndcap = + gainCalibHelper::SiPixelGainCalibrationValuesPerRegion; + using SiPixelGainCalibrationForHLTCorrelations = gainCalibHelper::SiPixelGainCalibrationCorrelations; @@ -71,6 +85,10 @@ namespace { PAYLOAD_INSPECTOR_MODULE(SiPixelGainCalibrationForHLT) { PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTGainsValues); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTPedestalsValues); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTGainsValuesBarrel); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTGainsValuesEndcap); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTPedestalsValuesBarrel); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTPedestalsValuesEndcap); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTCorrelations); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTGainsByPart); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTPedestalsByPart); diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc index 7ea1c25d9b001..86c23a6276325 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc @@ -17,6 +17,20 @@ namespace { gainCalibHelper::SiPixelGainCalibrationValues; + using SiPixelGainCalibrationOfflineGainsValuesBarrel = gainCalibHelper:: + SiPixelGainCalibrationValuesPerRegion; + using SiPixelGainCalibrationOfflineGainsValuesEndcap = gainCalibHelper:: + SiPixelGainCalibrationValuesPerRegion; + + using SiPixelGainCalibrationOfflinePedestalsValuesBarrel = + gainCalibHelper::SiPixelGainCalibrationValuesPerRegion; + using SiPixelGainCalibrationOfflinePedestalsValuesEndcap = + gainCalibHelper::SiPixelGainCalibrationValuesPerRegion; + using SiPixelGainCalibrationOfflineCorrelations = gainCalibHelper::SiPixelGainCalibrationCorrelations; @@ -74,6 +88,10 @@ namespace { PAYLOAD_INSPECTOR_MODULE(SiPixelGainCalibrationOffline) { PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineGainsValues); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflinePedestalsValues); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineGainsValuesBarrel); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineGainsValuesEndcap); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflinePedestalsValuesBarrel); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflinePedestalsValuesEndcap); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineCorrelations); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineGainsByPart); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflinePedestalsByPart); diff --git a/CondCore/SiPixelPlugins/test/BuildFile.xml b/CondCore/SiPixelPlugins/test/BuildFile.xml index 6b42a53e387a4..995bd1539e527 100644 --- a/CondCore/SiPixelPlugins/test/BuildFile.xml +++ b/CondCore/SiPixelPlugins/test/BuildFile.xml @@ -5,5 +5,6 @@ + From b7d0d34c717eafa6d4e995210e64c1e1043122a3 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 7 May 2020 17:16:59 +0200 Subject: [PATCH 13/32] more fine-tuning of the by-Region plots --- .../interface/PixelRegionContainers.h | 39 +++++++++++---- .../interface/SiPixelGainCalibHelper.h | 47 ++++++++----------- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index afb042c56cc6f..c03d1e3058882 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -150,7 +150,10 @@ namespace PixelRegions { class PixelRegionContainers { public: PixelRegionContainers(const TrackerTopology* t_topo, const bool isPhase1) - : m_trackerTopo(t_topo), m_isPhase1(isPhase1) {} + : m_trackerTopo(t_topo), m_isPhase1(isPhase1) { + // set log scale by default to false + m_isLog = false; + } ~PixelRegionContainers() {} @@ -187,26 +190,39 @@ namespace PixelRegions { } //============================================================================ - void draw(TCanvas& canv, bool isBarrel) { + void draw(TCanvas& canv, bool isBarrel, const char* option = "bar2") { if (isBarrel) { for (int j = 1; j <= 4; j++) { - canv.cd(j); - m_theMap.at(PixelIDs[j - 1])->Draw("bar2"); + if (!m_isLog) { + canv.cd(j); + } else { + canv.cd(j)->SetLogy(); + } + m_theMap.at(PixelIDs[j - 1])->Draw(option); } } else { // forward for (int j = 1; j <= 12; j++) { - canv.cd(j); - m_theMap.at(PixelIDs[j + 3])->Draw("bar2"); + if (!m_isLog) { + canv.cd(j); + } else { + canv.cd(j)->SetLogy(); + } + m_theMap.at(PixelIDs[j + 3])->Draw(option); } } } //============================================================================ - void beautify() { + void beautify(const int linecolor = kBlack, const int fillcolor = kRed) { for (const auto& plot : m_theMap) { plot.second->SetTitle(""); - plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30); - plot.second->SetFillColor(kRed); + if (!m_isLog) { + plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30); + } else { + plot.second->GetYaxis()->SetRangeUser(0.1, plot.second->GetMaximum() * 10.); + } + plot.second->SetLineColor(linecolor); + plot.second->SetFillColor(fillcolor); plot.second->SetMarkerStyle(20); plot.second->SetMarkerSize(1); SiPixelPI::makeNicePlotStyle(plot.second.get()); @@ -214,13 +230,16 @@ namespace PixelRegions { } } + //============================================================================ + void setLogScale() { m_isLog = true; } + //============================================================================ void stats() { for (const auto& plot : m_theMap) { TPaveStats* st = (TPaveStats*)plot.second->FindObject("stats"); if (st) { st->SetTextSize(0.03); - SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); + SiPixelPI::adjustStats(st, 0.15, 0.85, 0.39, 0.93); } } } diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 099b7b45f68d4..4f01280f3f0fe 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -309,6 +309,8 @@ namespace gainCalibHelper { : cond::payloadInspector::PlotImage( Form("SiPixelGainCalibration %s Values Per Region", TypeName[myType])) { this->setSingleIov(true); + cond::payloadInspector::PlotBase::addInputParam("SetLog"); + if constexpr (std::is_same_v) { isForHLT_ = false; label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; @@ -319,7 +321,15 @@ namespace gainCalibHelper { } bool fill(const std::vector>& iovs) override { - gStyle->SetOptStat("emr"); + // parse first if log + bool setLog(false); + auto paramValues = cond::payloadInspector::PlotBase::inputParamValues(); + auto ip = paramValues.find("SetLog"); + if (ip != paramValues.end()) { + setLog = boost::lexical_cast(ip->second); + } + + gStyle->SetOptStat("mr"); auto iov = iovs.front(); std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); @@ -370,26 +380,14 @@ namespace gainCalibHelper { gainCalibPI::fillTheHisto(payload, myPlots.getHistoFromMap(pixelId), myType, wantedDets); } - myPlots.beautify(); - myPlots.draw(canvas, isBarrel); - - /* - canvas.cd()->SetLogy(); - h1->SetTitle(""); - h1->GetYaxis()->SetRangeUser(0.1, h1->GetMaximum() * 10.); - h1->SetFillColor(kBlue); - h1->SetMarkerStyle(20); - h1->SetMarkerSize(1); - h1->Draw("bar2"); - - SiPixelPI::makeNicePlotStyle(h1.get()); - h1->SetStats(true); - - canvas.Update(); - */ + if (setLog) { + myPlots.setLogScale(); + } + myPlots.beautify(kBlue, 10); + myPlots.draw(canvas, isBarrel, "HIST"); - TLegend legend = TLegend(0.40, 0.88, 0.94, 0.93); - legend.SetHeader(("Payload hash: #bf{" + (std::get<1>(iov)) + "}").c_str(), + TLegend legend = TLegend(0.45, 0.88, 0.91, 0.92); + legend.SetHeader(("hash: #bf{" + (std::get<1>(iov)) + "}").c_str(), "C"); // option "C" allows to center the header //legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL"); legend.SetLineColor(10); @@ -406,12 +404,6 @@ namespace gainCalibHelper { myPlots.stats(); - /* - TPaveStats* st = (TPaveStats*)h1->FindObject("stats"); - st->SetTextSize(0.03); - SiPixelPI::adjustStats(st, 0.15, 0.83, 0.39, 0.93); - */ - auto ltx = TLatex(); ltx.SetTextFont(62); ltx.SetTextSize(0.05); @@ -420,7 +412,8 @@ namespace gainCalibHelper { for (unsigned int c = 1; c <= maxPads; c++) { auto index = isBarrel ? c - 1 : c + 3; canvas.cd(c); - ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.1, + auto leftX = setLog ? 0. : 0.1; + ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX, 1 - gPad->GetTopMargin() + 0.01, (PixelRegions::IDlabels.at(index) + ", IOV:" + std::to_string(std::get<0>(iov))).c_str()); } From de076e024c861f9ea4907534f2d414a97a34ff36 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 8 May 2020 13:20:00 +0200 Subject: [PATCH 14/32] fix filling of layer/ring plots in phase-0 case --- .../interface/PixelRegionContainers.h | 44 +++++++++++++++++-- .../interface/SiPixelGainCalibHelper.h | 4 ++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index c03d1e3058882..080825028675b 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -125,11 +125,13 @@ namespace PixelRegions { static const std::vector attachedDets(const PixelRegions::PixelId theId, const TrackerTopology* trackTopo, const bool phase1) { - std::vector out; + std::vector out = {}; edm::FileInPath m_fp; if (phase1) { + // phase-1 skimmed geometry from release m_fp = edm::FileInPath("SLHCUpgradeSimulations/Geometry/data/PhaseI/PixelSkimmedGeometry_phase1.txt"); } else { + // phase-0 skimmed geometry from release m_fp = edm::FileInPath("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt"); } @@ -141,6 +143,20 @@ namespace PixelRegions { out.push_back(d); } } + + // in case no DetIds are assigned, fill with UINT32_MAX + // in order to be able to tell a part the default case + // in SiPixelGainCalibHelper::fillTheHitsto + if (out.empty()) { + out.push_back(0xFFFFFFFF); + } + + COUT << "ID:" << theId << " "; + for (const auto& entry : out) { + COUT << entry << ","; + } + COUT << std::endl; + return out; } @@ -198,7 +214,18 @@ namespace PixelRegions { } else { canv.cd(j)->SetLogy(); } - m_theMap.at(PixelIDs[j - 1])->Draw(option); + if ((j == 4) && !m_isPhase1) { + m_theMap.at(PixelIDs[j - 1])->Draw("AXIS"); + TLatex t2; + t2.SetTextAlign(22); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextFont(61); + t2.SetTextColor(kBlack); + t2.DrawLatexNDC(0.5, 0.5, "Not in Phase-0!"); + } else { + m_theMap.at(PixelIDs[j - 1])->Draw(option); + } } } else { // forward for (int j = 1; j <= 12; j++) { @@ -207,7 +234,18 @@ namespace PixelRegions { } else { canv.cd(j)->SetLogy(); } - m_theMap.at(PixelIDs[j + 3])->Draw(option); + if ((j % 6 == 5 || j % 6 == 0) && !m_isPhase1) { + m_theMap.at(PixelIDs[j + 3])->Draw("AXIS"); + TLatex t2; + t2.SetTextAlign(22); + t2.SetTextSize(0.1); + t2.SetTextAngle(45); + t2.SetTextFont(61); + t2.SetTextColor(kBlack); + t2.DrawLatexNDC(0.5, 0.5, "Not in Phase-0!"); + } else { + m_theMap.at(PixelIDs[j + 3])->Draw(option); + } } } } diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 4f01280f3f0fe..fc5a23c31c01e 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -51,6 +51,10 @@ namespace gainCalibHelper { } for (const auto& d : detids) { + // skip the special case used to signal there are no attached dets + if (d == 0xFFFFFFFF) + continue; + auto range = payload->getRange(d); int numberOfRowsToAverageOver = payload->getNumberOfRowsToAverageOver(); int ncols = payload->getNCols(d); From 9014c1ac2340d69e07a923400b5b73fd58083fd0 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 10 May 2020 22:44:51 +0200 Subject: [PATCH 15/32] add display not supported --- .../interface/SiPixelGainCalibHelper.h | 7 +++++++ .../plugins/SiPixelLorentzAngle_PayloadInspector.cc | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index fc5a23c31c01e..b701a98c22d48 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -359,6 +359,13 @@ namespace gainCalibHelper { } TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); + if(detids.size() > SiPixelPI::phase1size){ + SiPixelPI::displayNotSupported(canvas, detids.size()); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } + canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); canvas.cd(); diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 5f7d6cf7ad90b..0072db05dfd8d 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -153,6 +153,13 @@ namespace { auto extrema = SiPixelPI::findMinMaxInMap(LAMap_); TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); + if(LAMap_.size() > SiPixelPI::phase1size){ + SiPixelPI::displayNotSupported(canvas, LAMap_.size()); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } + canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); canvas.cd(); @@ -374,6 +381,12 @@ namespace { std::string firstIOVsince = std::to_string(std::get<0>(firstiov)); TCanvas canvas("Comparison", "Comparison", 1600, 800); + if(f_LAMap_.size() > SiPixelPI::phase1size || l_LAMap_.size() > SiPixelPI::phase1size){ + SiPixelPI::displayNotSupported(canvas, std::max(f_LAMap_.size(),l_LAMap_.size())); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } std::map> FirstLA_spectraByRegion; std::map> LastLA_spectraByRegion; From 948f6fd2bdee5b02e26cc2d2becdbb6ce47e7525 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 11 May 2020 13:38:36 +0200 Subject: [PATCH 16/32] move to shared pointers in lieu of raw pointers --- .../interface/Phase1PixelMaps.h | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h index 6a2d0ab9da338..3c5835e6589a4 100644 --- a/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h +++ b/CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h @@ -30,17 +30,17 @@ class Phase1PixelMaps { //============================================================================ void bookBarrelHistograms(const std::string& currentHistoName, const char* what) { std::string histName; - TH2Poly* th2p; + std::shared_ptr th2p; for (unsigned i = 0; i < 4; ++i) { histName = "barrel_layer_"; - th2p = new TH2Poly((histName + std::to_string(i + 1)).c_str(), - Form("PXBMap of %s - Layer %i", what, i + 1), - -15.0, - 15.0, - 0.0, - 5.0); + th2p = std::make_shared((histName + std::to_string(i + 1)).c_str(), + Form("PXBMap of %s - Layer %i", what, i + 1), + -15.0, + 15.0, + 0.0, + 5.0); th2p->SetFloat(); @@ -53,7 +53,7 @@ class Phase1PixelMaps { pxbTh2PolyBarrel[currentHistoName].push_back(th2p); } - th2p = new TH2Poly("barrel_summary", "PXBMap", -5.0, 5.0, 0.0, 5.0); + th2p = std::make_shared("barrel_summary", "PXBMap", -5.0, 5.0, 0.0, 5.0); th2p->SetFloat(); th2p->GetXaxis()->SetTitle(""); @@ -66,18 +66,18 @@ class Phase1PixelMaps { //============================================================================ void bookForwardHistograms(const std::string& currentHistoName, const char* what) { std::string histName; - TH2Poly* th2p; + std::shared_ptr th2p; for (unsigned side = 1; side <= 2; ++side) { for (unsigned disk = 1; disk <= 3; ++disk) { histName = "forward_disk_"; - th2p = new TH2Poly((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), - Form("PXFMap of %s - Side %i Disk %i", what, side, disk), - -15.0, - 15.0, - -15.0, - 15.0); + th2p = std::make_shared((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(), + Form("PXFMap of %s - Side %i Disk %i", what, side, disk), + -15.0, + 15.0, + -15.0, + 15.0); th2p->SetFloat(); th2p->GetXaxis()->SetTitle("x [cm]"); th2p->GetYaxis()->SetTitle("y [cm]"); @@ -89,7 +89,7 @@ class Phase1PixelMaps { } } - th2p = new TH2Poly("forward_summary", "PXFMap", -40.0, 50.0, -20.0, 90.0); + th2p = std::make_shared("forward_summary", "PXFMap", -40.0, 50.0, -20.0, 90.0); th2p->SetFloat(); th2p->GetXaxis()->SetTitle(""); @@ -118,7 +118,7 @@ class Phase1PixelMaps { float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]}; float vertY[] = {(ladder - 1.0f), (ladder - 1.0f), (float)ladder, (float)ladder, (ladder - 1.0f)}; - bins[id] = new TGraph(5, vertX, vertY); + bins[id] = std::make_shared(5, vertX, vertY); bins[id]->SetName(TString::Format("%u", id)); // Summary plot @@ -127,7 +127,7 @@ class Phase1PixelMaps { vertY[k] += ((layer > 2) ? 30.0f : 0.0f); } - binsSummary[id] = new TGraph(5, vertX, vertY); + binsSummary[id] = std::make_shared(5, vertX, vertY); binsSummary[id]->SetName(TString::Format("%u", id)); pxbTh2PolyBarrel[currentHistoName][layer - 1]->AddBin(bins[id]->Clone()); @@ -156,7 +156,7 @@ class Phase1PixelMaps { float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]}; float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]}; - bins[id] = new TGraph(4, vertX, vertY); + bins[id] = std::make_shared(4, vertX, vertY); bins[id]->SetName(TString::Format("%u", id)); // Summary plot @@ -165,7 +165,7 @@ class Phase1PixelMaps { vertY[k] += (disk - 1) * 35.0f; } - binsSummary[id] = new TGraph(4, vertX, vertY); + binsSummary[id] = std::make_shared(4, vertX, vertY); binsSummary[id]->SetName(TString::Format("%u", id)); pxfTh2PolyForward[currentHistoName][mapIdx]->AddBin(bins[id]->Clone()); @@ -205,7 +205,7 @@ class Phase1PixelMaps { void beautifyAllHistograms() { for (const auto& vec : pxbTh2PolyBarrel) { for (const auto& plot : vec.second) { - SiPixelPI::makeNicePlotStyle(plot); + SiPixelPI::makeNicePlotStyle(plot.get()); plot->GetXaxis()->SetTitleOffset(0.9); plot->GetYaxis()->SetTitleOffset(0.9); } @@ -213,7 +213,7 @@ class Phase1PixelMaps { for (const auto& vec : pxfTh2PolyForward) { for (const auto& plot : vec.second) { - SiPixelPI::makeNicePlotStyle(plot); + SiPixelPI::makeNicePlotStyle(plot.get()); plot->GetXaxis()->SetTitleOffset(0.9); plot->GetYaxis()->SetTitleOffset(0.9); } @@ -254,11 +254,11 @@ class Phase1PixelMaps { Option_t* m_option; TrackerTopology m_trackerTopo; - std::map bins, binsSummary; - std::map> pxbTh2PolyBarrel; - std::map pxbTh2PolyBarrelSummary; - std::map> pxfTh2PolyForward; - std::map pxfTh2PolyForwardSummary; + std::map> bins, binsSummary; + std::map>> pxbTh2PolyBarrel; + std::map> pxbTh2PolyBarrelSummary; + std::map>> pxfTh2PolyForward; + std::map> pxfTh2PolyForwardSummary; std::vector m_cornersBPIX; std::vector m_cornersFPIX; From 0ec079683206a7fd61f726c2116119a79fd9636a Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 11 May 2020 13:38:53 +0200 Subject: [PATCH 17/32] remove methods giving compiliation warnings --- .../SiPixelPlugins/interface/PixelRegionContainers.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index 080825028675b..fa447554bb451 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -93,12 +93,6 @@ namespace PixelRegions { return fpixRing; } - //============================================================================ - static const int getPixelSubDetector(const unsigned int pixid) { - // subdetId: BPix=1, FPix=2 - return (pixid / 1000) % 10; - } - //============================================================================ static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology* trackTopo, const bool phase1) { DetId detId = DetId(detid); @@ -122,9 +116,9 @@ namespace PixelRegions { } //============================================================================ - static const std::vector attachedDets(const PixelRegions::PixelId theId, - const TrackerTopology* trackTopo, - const bool phase1) { + const std::vector attachedDets(const PixelRegions::PixelId theId, + const TrackerTopology* trackTopo, + const bool phase1) { std::vector out = {}; edm::FileInPath m_fp; if (phase1) { From 131c95b50e3373e8447069268ef6dc2b182b43d8 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 11 May 2020 13:39:27 +0200 Subject: [PATCH 18/32] code-checks --- .../interface/SiPixelGainCalibHelper.h | 6 +++--- .../plugins/SiPixelLorentzAngle_PayloadInspector.cc | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index b701a98c22d48..f0629b807eb22 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -359,11 +359,11 @@ namespace gainCalibHelper { } TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); - if(detids.size() > SiPixelPI::phase1size){ - SiPixelPI::displayNotSupported(canvas, detids.size()); + if (detids.size() > SiPixelPI::phase1size) { + SiPixelPI::displayNotSupported(canvas, detids.size()); std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); - return false; + return false; } canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 0072db05dfd8d..bb408c8e54a45 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -153,11 +153,11 @@ namespace { auto extrema = SiPixelPI::findMinMaxInMap(LAMap_); TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); - if(LAMap_.size() > SiPixelPI::phase1size){ - SiPixelPI::displayNotSupported(canvas, LAMap_.size()); + if (LAMap_.size() > SiPixelPI::phase1size) { + SiPixelPI::displayNotSupported(canvas, LAMap_.size()); std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); - return false; + return false; } canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); @@ -381,11 +381,11 @@ namespace { std::string firstIOVsince = std::to_string(std::get<0>(firstiov)); TCanvas canvas("Comparison", "Comparison", 1600, 800); - if(f_LAMap_.size() > SiPixelPI::phase1size || l_LAMap_.size() > SiPixelPI::phase1size){ - SiPixelPI::displayNotSupported(canvas, std::max(f_LAMap_.size(),l_LAMap_.size())); + if (f_LAMap_.size() > SiPixelPI::phase1size || l_LAMap_.size() > SiPixelPI::phase1size) { + SiPixelPI::displayNotSupported(canvas, std::max(f_LAMap_.size(), l_LAMap_.size())); std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); - return false; + return false; } std::map> FirstLA_spectraByRegion; From ed021b54300e9d3dd51e32722bff9ee16db154eb Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 11 May 2020 13:39:46 +0200 Subject: [PATCH 19/32] add header inspection plots --- ...iPixelTemplateDBObject_PayloadInspector.cc | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 836bf444bd49a..58bfd3bbfbbee 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -28,6 +28,7 @@ #include #include #include +#include // include ROOT #include "TH2.h" @@ -110,6 +111,66 @@ namespace { } // fill }; + /************************************************ + // header plotting + *************************************************/ + class SiPixelTemplateHeader : public cond::payloadInspector::PlotImage { + public: + SiPixelTemplateHeader() + : cond::payloadInspector::PlotImage("SiPixelTemplate assumed value of uH") { + setSingleIov(true); + } + + bool fill(const std::vector>& iovs) override { + auto iov = iovs.front(); + + std::vector thePixelTemp_; + std::shared_ptr payload = fetchPayload(std::get<1>(iov)); + + if (payload.get()) { + if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { + throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; + } + + // store the map of ID / interesting quantities + SiPixelTemplate templ(thePixelTemp_); + TCanvas canvas("Beam Spot Parameters Summary", "BeamSpot Parameters summary", 1000, 1000); + canvas.cd(); + + unsigned int tempSize = thePixelTemp_.size(); + + canvas.SetTopMargin(0.07); + canvas.SetBottomMargin(0.06); + canvas.SetLeftMargin(0.15); + canvas.SetRightMargin(0.03); + canvas.Modified(); + canvas.SetGrid(); + + auto h2_TemplateHeaders = + std::unique_ptr(new TH2F("Header", "Template Header summary", 5, 0.0, 5.0, tempSize, 0, tempSize)); + h2_TemplateHeaders->SetStats(false); + + for (const auto& theTemp : thePixelTemp_ | boost::adaptors::indexed(1)) { + auto tempValue = theTemp.value(); + auto tempIndex = theTemp.index(); + h2_TemplateHeaders->SetBinContent(1, tempIndex, tempValue.head.ID); + h2_TemplateHeaders->SetBinContent(2, tempIndex, tempValue.head.Bfield); + h2_TemplateHeaders->SetBinContent(3, tempIndex, tempValue.head.xsize); + h2_TemplateHeaders->SetBinContent(4, tempIndex, tempValue.head.ysize); + h2_TemplateHeaders->SetBinContent(5, tempIndex, tempValue.head.zsize); + } + + canvas.cd(); + h2_TemplateHeaders->Draw("TEXT"); + std::string fileName(m_imageFileName); + canvas.SaveAs(fileName.c_str()); + } + return true; + } // fill + }; + /************************************************ // testing TH2Poly classes for plotting *************************************************/ @@ -314,6 +375,7 @@ namespace { // Register the classes as boost python plugin PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) { PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest); + //PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateHeader); PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsBPixMap); PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFPixMap); PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLABPixMap); From 957f936a02e8b53d588a815786d0800440c0d891 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 11 May 2020 17:56:06 +0200 Subject: [PATCH 20/32] few improvements in SiPixelTemplateDBObject PayloadInspector --- ...iPixelTemplateDBObject_PayloadInspector.cc | 80 +++++++++++++------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 58bfd3bbfbbee..7e684f159931c 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -53,7 +53,6 @@ namespace { /************************************************ test class *************************************************/ - class SiPixelTemplateDBObjectTest : public cond::payloadInspector::Histogram1D { public: SiPixelTemplateDBObjectTest() @@ -69,9 +68,10 @@ namespace { std::shared_ptr payload = Base::fetchPayload(std::get<1>(iov)); if (payload.get()) { if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { - throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " - "SiPixelTemplateDBObject version " - << payload->version() << "\n\n"; + throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector") + << "\nERROR: Templates not filled correctly. Check the conditions. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; } SiPixelTemplate templ(thePixelTemp_); @@ -114,11 +114,11 @@ namespace { /************************************************ // header plotting *************************************************/ - class SiPixelTemplateHeader : public cond::payloadInspector::PlotImage { + class SiPixelTemplateHeaderTable : public cond::payloadInspector::PlotImage { public: - SiPixelTemplateHeader() - : cond::payloadInspector::PlotImage("SiPixelTemplate assumed value of uH") { - setSingleIov(true); + SiPixelTemplateHeaderTable() + : cond::payloadInspector::PlotImage("SiPixelTemplateDBObject Header summary") { + Base::setSingleIov(true); } bool fill(const std::vector>& iovs) override { @@ -129,46 +129,75 @@ namespace { if (payload.get()) { if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { - throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " - "SiPixelTemplateDBObject version " - << payload->version() << "\n\n"; + throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector") + << "\nERROR: Templates not filled correctly. Check the conditions. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; } // store the map of ID / interesting quantities SiPixelTemplate templ(thePixelTemp_); - TCanvas canvas("Beam Spot Parameters Summary", "BeamSpot Parameters summary", 1000, 1000); + TCanvas canvas("Template Header Summary", "Template Header summary", 1400, 1000); canvas.cd(); unsigned int tempSize = thePixelTemp_.size(); canvas.SetTopMargin(0.07); canvas.SetBottomMargin(0.06); - canvas.SetLeftMargin(0.15); + canvas.SetLeftMargin(0.17); canvas.SetRightMargin(0.03); canvas.Modified(); canvas.SetGrid(); - auto h2_TemplateHeaders = - std::unique_ptr(new TH2F("Header", "Template Header summary", 5, 0.0, 5.0, tempSize, 0, tempSize)); + auto h2_TemplateHeaders = std::unique_ptr(new TH2F("Header", ";;", tempSize, 0, tempSize, 6, 0., 6.)); h2_TemplateHeaders->SetStats(false); for (const auto& theTemp : thePixelTemp_ | boost::adaptors::indexed(1)) { auto tempValue = theTemp.value(); auto tempIndex = theTemp.index(); - h2_TemplateHeaders->SetBinContent(1, tempIndex, tempValue.head.ID); - h2_TemplateHeaders->SetBinContent(2, tempIndex, tempValue.head.Bfield); - h2_TemplateHeaders->SetBinContent(3, tempIndex, tempValue.head.xsize); - h2_TemplateHeaders->SetBinContent(4, tempIndex, tempValue.head.ysize); - h2_TemplateHeaders->SetBinContent(5, tempIndex, tempValue.head.zsize); + float uH = roundoff(tempValue.head.lorxwidth / tempValue.head.zsize / tempValue.head.Bfield, 4); + h2_TemplateHeaders->SetBinContent(tempIndex, 6, tempValue.head.ID); + h2_TemplateHeaders->SetBinContent(tempIndex, 5, tempValue.head.Bfield); + h2_TemplateHeaders->SetBinContent(tempIndex, 4, uH); + h2_TemplateHeaders->SetBinContent(tempIndex, 3, tempValue.head.xsize); + h2_TemplateHeaders->SetBinContent(tempIndex, 2, tempValue.head.ysize); + h2_TemplateHeaders->SetBinContent(tempIndex, 1, tempValue.head.zsize); + h2_TemplateHeaders->GetYaxis()->SetBinLabel(6, "TemplateID"); + h2_TemplateHeaders->GetYaxis()->SetBinLabel(5, "B-field [T]"); + h2_TemplateHeaders->GetYaxis()->SetBinLabel(4, "#mu_{H} [1/T]"); + h2_TemplateHeaders->GetYaxis()->SetBinLabel(3, "x-size [#mum]"); + h2_TemplateHeaders->GetYaxis()->SetBinLabel(2, "y-size [#mum]"); + h2_TemplateHeaders->GetYaxis()->SetBinLabel(1, "z-size [#mum]"); + h2_TemplateHeaders->GetXaxis()->SetBinLabel(tempIndex, ""); } + h2_TemplateHeaders->GetXaxis()->LabelsOption("h"); + h2_TemplateHeaders->GetXaxis()->SetNdivisions(500 + tempSize, false); + h2_TemplateHeaders->GetYaxis()->SetLabelSize(0.05); + h2_TemplateHeaders->SetMarkerSize(1.5); + canvas.cd(); h2_TemplateHeaders->Draw("TEXT"); + + 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, + ("SiPixelTemplate IOV:" + std::to_string(std::get<0>(iov))).c_str()); + std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); } return true; - } // fill + } + + float roundoff(float value, unsigned char prec) { + float pow_10 = pow(10.0f, (float)prec); + return round(value * pow_10) / pow_10; + } }; /************************************************ @@ -208,9 +237,10 @@ namespace { if (payload.get()) { if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { - throw cms::Exception("") << "\nERROR: Templates not filled correctly. Check the sqlite file. Using " - "SiPixelTemplateDBObject version " - << payload->version() << "\n\n"; + throw cms::Exception("SiPixelTemplateDBObject_PayloadInspector") + << "\nERROR: Templates not filled correctly. Check the conditions. Using " + "SiPixelTemplateDBObject version " + << payload->version() << "\n\n"; } // store the map of ID / interesting quantities @@ -375,7 +405,7 @@ namespace { // Register the classes as boost python plugin PAYLOAD_INSPECTOR_MODULE(SiPixelTemplateDBObject) { PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateDBObjectTest); - //PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateHeader); + PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateHeaderTable); PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsBPixMap); PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateIDsFPixMap); PAYLOAD_INSPECTOR_CLASS(SiPixelTemplateLABPixMap); From d5201b01b8aa3c92b7e5301e186c53562706d24c Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 13 May 2020 18:28:09 +0200 Subject: [PATCH 21/32] fix fill method for SiPixelTemplateDBObject_PayloadInspector --- .../plugins/SiPixelTemplateDBObject_PayloadInspector.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 7e684f159931c..9adcd2ef91c03 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -61,10 +61,10 @@ namespace { Base::setSingleIov(true); } - bool fill(const std::vector>& iovs) override { - for (auto const& iov : iovs) { + bool fill() override { + auto tag = PlotBase::getTag<0>(); + for (auto iov : tag.iovs) { std::vector thePixelTemp_; - std::shared_ptr payload = Base::fetchPayload(std::get<1>(iov)); if (payload.get()) { if (!SiPixelTemplate::pushfile(*payload, thePixelTemp_)) { From f2ea129c8b2f7d8983ddee41423a5002e1c3d82c Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 14 May 2020 17:34:15 +0200 Subject: [PATCH 22/32] add additional plot in the test script --- .../test/testSiPixelTemplateDBObject.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh index 8a7ec0034efc3..73b894ad128d1 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelTemplateDBObject.sh @@ -67,3 +67,14 @@ getPayloadData.py \ --test ; mv *.png $W_DIR/plots_Template/LAFPixMap.png + +getPayloadData.py \ + --plugin pluginSiPixelTemplateDBObject_PayloadInspector \ + --plot plot_SiPixelTemplateHeaderTable \ + --tag SiPixelTemplateDBObject38Tv3_express \ + --time_type Run \ + --iovs '{"start_iov": "326083", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_Template/HeaderTable.png From c7e34e1c9d4ce51fdc1a4fa1d94f5086b33f4eb7 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 14 May 2020 17:45:36 +0200 Subject: [PATCH 23/32] profit of the new class templates introduced in #29622 --- .../interface/SiPixelGainCalibHelper.h | 79 +++++++++++-------- .../SiPixelLorentzAngle_PayloadInspector.cc | 71 +++++++++-------- .../SiPixelQuality_PayloadInspector.cc | 60 +++++++------- ...iPixelTemplateDBObject_PayloadInspector.cc | 59 +++++++------- 4 files changed, 146 insertions(+), 123 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index f0629b807eb22..705688c1cb9eb 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -203,11 +203,12 @@ namespace gainCalibHelper { 1d histogram of SiPixelGainCalibration for Gains of 1 IOV ********************************************************************/ template - class SiPixelGainCalibrationValues : public cond::payloadInspector::PlotImage { + class SiPixelGainCalibrationValues + : public cond::payloadInspector::PlotImage { public: SiPixelGainCalibrationValues() - : cond::payloadInspector::PlotImage(Form("SiPixelGainCalibration %s Values", TypeName[myType])) { - this->setSingleIov(true); + : cond::payloadInspector::PlotImage( + Form("SiPixelGainCalibration %s Values", TypeName[myType])) { if constexpr (std::is_same_v) { isForHLT_ = false; label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; @@ -217,12 +218,14 @@ namespace gainCalibHelper { } } - bool fill(const std::vector>& iovs) override { - gStyle->SetOptStat("emr"); + bool fill() override { + auto tag = cond::payloadInspector::PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); - auto iov = iovs.front(); std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); + gStyle->SetOptStat("emr"); + float minimum(9999.); float maximum(-9999.); @@ -307,12 +310,12 @@ namespace gainCalibHelper { 1d histograms per region of SiPixelGainCalibration for Gains of 1 IOV ********************************************************************/ template - class SiPixelGainCalibrationValuesPerRegion : public cond::payloadInspector::PlotImage { + class SiPixelGainCalibrationValuesPerRegion + : public cond::payloadInspector::PlotImage { public: SiPixelGainCalibrationValuesPerRegion() - : cond::payloadInspector::PlotImage( + : cond::payloadInspector::PlotImage( Form("SiPixelGainCalibration %s Values Per Region", TypeName[myType])) { - this->setSingleIov(true); cond::payloadInspector::PlotBase::addInputParam("SetLog"); if constexpr (std::is_same_v) { @@ -324,7 +327,12 @@ namespace gainCalibHelper { } } - bool fill(const std::vector>& iovs) override { + bool fill() override { + gStyle->SetOptStat("mr"); + + auto tag = cond::payloadInspector::PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); + // parse first if log bool setLog(false); auto paramValues = cond::payloadInspector::PlotBase::inputParamValues(); @@ -333,9 +341,6 @@ namespace gainCalibHelper { setLog = boost::lexical_cast(ip->second); } - gStyle->SetOptStat("mr"); - - auto iov = iovs.front(); std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); std::vector detids; @@ -445,11 +450,12 @@ namespace gainCalibHelper { correlation of 1 IOV ********************************************************************/ template - class SiPixelGainCalibrationCorrelations : public cond::payloadInspector::PlotImage { + class SiPixelGainCalibrationCorrelations + : public cond::payloadInspector::PlotImage { public: SiPixelGainCalibrationCorrelations() - : cond::payloadInspector::PlotImage("SiPixelGainCalibration gain/pedestal correlations") { - this->setSingleIov(true); + : cond::payloadInspector::PlotImage( + "SiPixelGainCalibration gain/pedestal correlations") { if constexpr (std::is_same_v) { isForHLT_ = false; label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; @@ -459,11 +465,13 @@ namespace gainCalibHelper { } } - bool fill(const std::vector>& iovs) override { + bool fill() override { + auto tag = cond::payloadInspector::PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); + gStyle->SetOptStat("emr"); gStyle->SetPalette(1); - auto iov = iovs.front(); std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); TCanvas canvas("Canv", "Canv", 1400, 800); @@ -563,12 +571,12 @@ namespace gainCalibHelper { 1d histogram of SiPixelGainCalibration for Pedestals of 1 IOV ********************************************************************/ template - class SiPixelGainCalibrationValuesByPart : public cond::payloadInspector::PlotImage { + class SiPixelGainCalibrationValuesByPart + : public cond::payloadInspector::PlotImage { public: SiPixelGainCalibrationValuesByPart() - : cond::payloadInspector::PlotImage( + : cond::payloadInspector::PlotImage( Form("SiPixelGainCalibrationOffline %s Values By Partition", TypeName[myType])) { - this->setSingleIov(true); if constexpr (std::is_same_v) { isForHLT_ = false; label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; @@ -578,10 +586,12 @@ namespace gainCalibHelper { } } - bool fill(const std::vector>& iovs) override { + bool fill() override { + auto tag = cond::payloadInspector::PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); + gStyle->SetOptStat("emr"); - auto iov = iovs.front(); std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); TCanvas canvas("Canv", "Canv", 1400, 800); @@ -886,10 +896,11 @@ namespace gainCalibHelper { occupancy style map BPix *************************************************/ template - class SiPixelGainCalibrationBPIXMap : public cond::payloadInspector::PlotImage { + class SiPixelGainCalibrationBPIXMap + : public cond::payloadInspector::PlotImage { public: SiPixelGainCalibrationBPIXMap() - : cond::payloadInspector::PlotImage( + : cond::payloadInspector::PlotImage( Form("SiPixelGainCalibration %s Barrel Pixel Map", TypeName[myType])), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { @@ -900,11 +911,12 @@ namespace gainCalibHelper { isForHLT_ = true; label_ = "SiPixelGainCalibrationForHLT_PayloadInspector"; } - this->setSingleIov(true); }; - bool fill(const std::vector>& iovs) override { - auto iov = iovs.front(); + 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)); static const int n_layers = 4; @@ -1016,14 +1028,14 @@ namespace gainCalibHelper { *************************************************/ template - class SiPixelGainCalibrationFPIXMap : public cond::payloadInspector::PlotImage { + class SiPixelGainCalibrationFPIXMap + : public cond::payloadInspector::PlotImage { public: SiPixelGainCalibrationFPIXMap() - : cond::payloadInspector::PlotImage( + : cond::payloadInspector::PlotImage( Form("SiPixelGainCalibration %s Forward Pixel Map", TypeName[myType])), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { - this->setSingleIov(true); if constexpr (std::is_same_v) { isForHLT_ = false; label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; @@ -1033,8 +1045,9 @@ namespace gainCalibHelper { } } - bool fill(const std::vector>& iovs) override { - auto iov = iovs.front(); + 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)); static const int n_rings = 2; diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index bb408c8e54a45..81c8e2e6dbaed 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -37,16 +37,16 @@ namespace { *************************************************/ // inherit from one of the predefined plot class: Histogram1D - class SiPixelLorentzAngleValue : public cond::payloadInspector::Histogram1D { + class SiPixelLorentzAngleValue + : public cond::payloadInspector::Histogram1D { public: SiPixelLorentzAngleValue() - : cond::payloadInspector::Histogram1D( - "SiPixel LorentzAngle values", "SiPixel LorentzAngle values", 100, 0.0, 0.1) { - Base::setSingleIov(true); - } + : cond::payloadInspector::Histogram1D( + "SiPixel LorentzAngle values", "SiPixel LorentzAngle values", 100, 0.0, 0.1) {} - bool fill(const std::vector> &iovs) override { - for (auto const &iov : iovs) { + bool fill() override { + auto tag = PlotBase::getTag<0>(); + for (auto const &iov : tag.iovs) { std::shared_ptr payload = Base::fetchPayload(std::get<1>(iov)); if (payload.get()) { std::map LAMap_ = payload->getLorentzAngles(); @@ -63,16 +63,18 @@ namespace { /************************************************ 1d histogram of SiPixelLorentzAngle of 1 IOV *************************************************/ - class SiPixelLorentzAngleValues : public cond::payloadInspector::PlotImage { + class SiPixelLorentzAngleValues + : public cond::payloadInspector::PlotImage { public: - SiPixelLorentzAngleValues() : cond::payloadInspector::PlotImage("SiPixelLorentzAngle Values") { - setSingleIov(true); - } + SiPixelLorentzAngleValues() + : cond::payloadInspector::PlotImage( + "SiPixelLorentzAngle Values") {} - bool fill(const std::vector> &iovs) override { + bool fill() override { gStyle->SetOptStat("emr"); - auto iov = iovs.front(); + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); std::map LAMap_ = payload->getLorentzAngles(); auto extrema = SiPixelPI::findMinMaxInMap(LAMap_); @@ -137,17 +139,18 @@ namespace { 1d histogram of SiPixelLorentzAngle of 1 IOV per region *************************************************/ template - class SiPixelLorentzAngleValuesPerRegion : public cond::payloadInspector::PlotImage { + class SiPixelLorentzAngleValuesPerRegion + : public cond::payloadInspector::PlotImage { public: SiPixelLorentzAngleValuesPerRegion() - : cond::payloadInspector::PlotImage("SiPixelLorentzAngle Values per region") { - setSingleIov(true); - } + : cond::payloadInspector::PlotImage( + "SiPixelLorentzAngle Values per region") {} - bool fill(const std::vector> &iovs) override { + bool fill() override { gStyle->SetOptStat("emr"); - auto iov = iovs.front(); + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); std::map LAMap_ = payload->getLorentzAngles(); auto extrema = SiPixelPI::findMinMaxInMap(LAMap_); @@ -576,17 +579,18 @@ namespace { occupancy style map BPix *************************************************/ - class SiPixelBPixLorentzAngleMap : public cond::payloadInspector::PlotImage { + class SiPixelBPixLorentzAngleMap + : public cond::payloadInspector::PlotImage { public: SiPixelBPixLorentzAngleMap() - : cond::payloadInspector::PlotImage("SiPixelLorentzAngle Barrel Pixel Map"), + : cond::payloadInspector::PlotImage( + "SiPixelLorentzAngle Barrel Pixel Map"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( - edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { - setSingleIov(true); - } + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} - bool fill(const std::vector> &iovs) override { - auto iov = iovs.front(); + bool fill() override { + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); static const int n_layers = 4; @@ -698,17 +702,18 @@ namespace { occupancy style map FPix *************************************************/ - class SiPixelFPixLorentzAngleMap : public cond::payloadInspector::PlotImage { + class SiPixelFPixLorentzAngleMap + : public cond::payloadInspector::PlotImage { public: SiPixelFPixLorentzAngleMap() - : cond::payloadInspector::PlotImage("SiPixelLorentzAngle Forward Pixel Map"), + : cond::payloadInspector::PlotImage( + "SiPixelLorentzAngle Forward Pixel Map"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( - edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { - setSingleIov(true); - } + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} - bool fill(const std::vector> &iovs) override { - auto iov = iovs.front(); + bool fill() override { + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); static const int n_rings = 2; diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc index b93f17014b866..fe399b26a9ef5 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelQuality_PayloadInspector.cc @@ -42,16 +42,16 @@ namespace { test class *************************************************/ - class SiPixelQualityTest : public cond::payloadInspector::Histogram1D { + class SiPixelQualityTest + : public cond::payloadInspector::Histogram1D { public: SiPixelQualityTest() - : cond::payloadInspector::Histogram1D( - "SiPixelQuality test", "SiPixelQuality test", 10, 0.0, 10.0) { - Base::setSingleIov(true); - } + : cond::payloadInspector::Histogram1D( + "SiPixelQuality test", "SiPixelQuality test", 10, 0.0, 10.0) {} - bool fill(const std::vector >& iovs) override { - for (auto const& iov : iovs) { + bool fill() override { + auto tag = PlotBase::getTag<0>(); + for (auto const& iov : tag.iovs) { std::shared_ptr payload = Base::fetchPayload(std::get<1>(iov)); if (payload.get()) { fillWithValue(1.); @@ -76,16 +76,16 @@ namespace { summary class *************************************************/ - class SiPixelQualityBadRocsSummary : public cond::payloadInspector::PlotImage { + class SiPixelQualityBadRocsSummary + : public cond::payloadInspector::PlotImage { public: - SiPixelQualityBadRocsSummary() : cond::payloadInspector::PlotImage("SiPixel Quality Summary") { - setSingleIov(false); - } - - bool fill(const std::vector >& iovs) override { - std::vector > sorted_iovs = iovs; + SiPixelQualityBadRocsSummary() + : cond::payloadInspector::PlotImage( + "SiPixel Quality Summary") {} - for (const auto& iov : iovs) { + bool fill() override { + auto tag = PlotBase::getTag<0>(); + for (const auto& iov : tag.iovs) { std::shared_ptr payload = fetchPayload(std::get<1>(iov)); auto unpacked = SiPixelPI::unpack(std::get<0>(iov)); @@ -145,17 +145,18 @@ namespace { occupancy style map BPix *************************************************/ - class SiPixelBPixQualityMap : public cond::payloadInspector::PlotImage { + class SiPixelBPixQualityMap + : public cond::payloadInspector::PlotImage { public: SiPixelBPixQualityMap() - : cond::payloadInspector::PlotImage("SiPixelQuality Barrel Pixel Map"), + : cond::payloadInspector::PlotImage( + "SiPixelQuality Barrel Pixel Map"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( - edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { - setSingleIov(true); - } + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} - bool fill(const std::vector >& iovs) override { - auto iov = iovs.front(); + bool fill() override { + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); static const int n_layers = 4; @@ -259,17 +260,18 @@ namespace { occupancy style map FPix *************************************************/ - class SiPixelFPixQualityMap : public cond::payloadInspector::PlotImage { + class SiPixelFPixQualityMap + : public cond::payloadInspector::PlotImage { public: SiPixelFPixQualityMap() - : cond::payloadInspector::PlotImage("SiPixelQuality Forward Pixel Map"), + : cond::payloadInspector::PlotImage( + "SiPixelQuality Forward Pixel Map"), m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile( - edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} { - setSingleIov(true); - } + edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {} - bool fill(const std::vector >& iovs) override { - auto iov = iovs.front(); + bool fill() override { + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); static const int n_rings = 2; diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 9adcd2ef91c03..4b919c7d0cc35 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -53,17 +53,16 @@ namespace { /************************************************ test class *************************************************/ - class SiPixelTemplateDBObjectTest : public cond::payloadInspector::Histogram1D { + class SiPixelTemplateDBObjectTest + : public cond::payloadInspector::Histogram1D { public: SiPixelTemplateDBObjectTest() - : cond::payloadInspector::Histogram1D( - "SiPixelTemplateDBObject test", "SiPixelTemplateDBObject test", 10, 0.0, 100.) { - Base::setSingleIov(true); - } + : cond::payloadInspector::Histogram1D( + "SiPixelTemplateDBObject test", "SiPixelTemplateDBObject test", 10, 0.0, 100.) {} bool fill() override { auto tag = PlotBase::getTag<0>(); - for (auto iov : tag.iovs) { + for (auto const& iov : tag.iovs) { std::vector thePixelTemp_; std::shared_ptr payload = Base::fetchPayload(std::get<1>(iov)); if (payload.get()) { @@ -114,16 +113,17 @@ namespace { /************************************************ // header plotting *************************************************/ - class SiPixelTemplateHeaderTable : public cond::payloadInspector::PlotImage { + class SiPixelTemplateHeaderTable + : public cond::payloadInspector::PlotImage { public: SiPixelTemplateHeaderTable() - : cond::payloadInspector::PlotImage("SiPixelTemplateDBObject Header summary") { - Base::setSingleIov(true); - } - - bool fill(const std::vector>& iovs) override { - auto iov = iovs.front(); + : cond::payloadInspector::PlotImage( + "SiPixelTemplateDBObject Header summary") {} + bool fill() override { + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); + auto tagname = tag.name; std::vector thePixelTemp_; std::shared_ptr payload = fetchPayload(std::get<1>(iov)); @@ -182,11 +182,11 @@ namespace { auto ltx = TLatex(); ltx.SetTextFont(62); ltx.SetTextColor(kBlue); - ltx.SetTextSize(0.05); + ltx.SetTextSize(0.045); ltx.SetTextAlign(11); ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, - ("SiPixelTemplate IOV:" + std::to_string(std::get<0>(iov))).c_str()); + (tagname + ",IOV:" + std::to_string(std::get<0>(iov))).c_str()); std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); @@ -204,7 +204,8 @@ namespace { // testing TH2Poly classes for plotting *************************************************/ template - class SiPixelTemplateLA : public cond::payloadInspector::PlotImage { + class SiPixelTemplateLA + : public cond::payloadInspector::PlotImage { struct header_info { int ID; //!< template ID number float lorywidth; //!< estimate of y-lorentz width for optimal resolution @@ -222,16 +223,15 @@ namespace { public: SiPixelTemplateLA() - : cond::payloadInspector::PlotImage("SiPixelTemplate assumed value of uH") { - setSingleIov(true); - } + : cond::payloadInspector::PlotImage( + "SiPixelTemplate assumed value of uH") {} - bool fill(const std::vector>& iovs) override { + bool fill() override { gStyle->SetPalette(kBlackBody); TGaxis::SetMaxDigits(2); - auto iov = iovs.front(); - + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::vector thePixelTemp_; std::shared_ptr payload = fetchPayload(std::get<1>(iov)); @@ -326,15 +326,18 @@ namespace { // testing TH2Poly classes for plotting *************************************************/ template - class SiPixelTemplateIDs : public cond::payloadInspector::PlotImage { + class SiPixelTemplateIDs + : public cond::payloadInspector::PlotImage { public: - SiPixelTemplateIDs() : cond::payloadInspector::PlotImage("SiPixelTemplate ID Values") { - setSingleIov(true); - } + SiPixelTemplateIDs() + : cond::payloadInspector::PlotImage( + "SiPixelTemplate ID Values") {} - bool fill(const std::vector>& iovs) override { + bool fill() override { gStyle->SetPalette(kRainBow); - auto iov = iovs.front(); + + auto tag = PlotBase::getTag<0>(); + auto iov = tag.iovs.front(); std::shared_ptr payload = fetchPayload(std::get<1>(iov)); if (payload.get()) { From 6d8d3ad8cf1b9a8b731619e251808387e692043c Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 10:37:37 +0200 Subject: [PATCH 24/32] add check on the setting of user-inputed parameters --- .../interface/SiPixelGainCalibHelper.h | 7 ++++++- .../interface/SiPixelPayloadInspectorHelper.h | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 705688c1cb9eb..786ec76feff5d 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -338,7 +338,12 @@ namespace gainCalibHelper { auto paramValues = cond::payloadInspector::PlotBase::inputParamValues(); auto ip = paramValues.find("SetLog"); if (ip != paramValues.end()) { - setLog = boost::lexical_cast(ip->second); + auto answer = boost::lexical_cast(ip->second); + if (!SiPixelPI::checkAnswerOK(answer, setLog)) { + throw cms::Exception(label_) + << "\nERROR: " << answer + << " is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n"; + } } std::shared_ptr payload = this->fetchPayload(std::get<1>(iov)); diff --git a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h index 273ca33dd7aac..6fccd04684e94 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h @@ -1002,5 +1002,17 @@ namespace SiPixelPI { return std::make_pair(min.second, max.second); } + /*--------------------------------------------------------------------*/ + bool checkAnswerOK(std::string& answer, bool& result) + /*--------------------------------------------------------------------*/ + { + std::transform(answer.begin(), answer.end(), answer.begin(), [](unsigned char x) { return ::tolower(x); }); + + bool answer_valid = (answer == "y") || (answer == "n") || (answer == "yes") || (answer == "no") || + (answer == "true") || (answer == "false") || (answer == "1") || (answer == "0"); + + result = answer_valid && (answer[0] == 'y' || answer[0] == 't' || answer[0] == '1'); + return answer_valid; + } }; // namespace SiPixelPI #endif From 9f55baf441c427de4df99351bf056d141a1c613b Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 10:39:11 +0200 Subject: [PATCH 25/32] add one class to unit test in order to test also PixelRegionContainers.h --- .../test/testSiPixelPayloadInspector.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp index 6cc83cf854dba..de792bc100970 100644 --- a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp +++ b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp @@ -120,6 +120,14 @@ int main(int argc, char** argv) { histo16.process(connectionString, PI::mk_input(tag, end, end)); std::cout << histo16.data() << std::endl; + boost::python::dict inputs; + inputs["SetLog"] = "True"; // sets to true, 1,True,Yes will work + + SiPixelGainCalibrationOfflineGainsValuesBarrel histo17; + histo17.setInputParamValues(inputs); + histo17.process(connectionString, PI::mk_input(tag, end, end)); + std::cout << histo17.data() << std::endl; + // SiPixelTemplates tag = "SiPixelTemplateDBObject38Tv3_express"; @@ -128,13 +136,13 @@ int main(int argc, char** argv) { std::cout << "## Exercising SiPixelTemplates plots " << std::endl; - SiPixelTemplateIDsBPixMap histo17; - histo17.process(connectionString, PI::mk_input(tag, end, end)); + SiPixelTemplateIDsBPixMap histo18; + histo18.process(connectionString, PI::mk_input(tag, end, end)); std::cout << histo17.data() << std::endl; - SiPixelTemplateLAFPixMap histo18; + SiPixelTemplateLAFPixMap histo19; histo18.process(connectionString, PI::mk_input(tag, end, end)); - std::cout << histo18.data() << std::endl; + std::cout << histo19.data() << std::endl; Py_Finalize(); } From 66e5bd32c8310f4d0a97afb2f864ab37fbd19d22 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 18:41:15 +0200 Subject: [PATCH 26/32] improve testing --- .../test/testSiPixelLorentzAngle.sh | 24 +++++++++++++++++++ .../test/testSiPixelPayloadInspector.cpp | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh index 23c6ad3f91e9c..bf42ab32b7fc5 100755 --- a/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh +++ b/CondCore/SiPixelPlugins/test/testSiPixelLorentzAngle.sh @@ -15,6 +15,30 @@ fi mkdir $W_DIR/plots_LA +getPayloadData.py \ + --plugin pluginSiPixelLorentzAngle_PayloadInspector \ + --plot plot_SiPixelLorentzAngleValuesBarrelCompareTwoTags \ + --tag SiPixelLorentzAngleSim_phase1_BoR3_HV350_Tr2000 \ + --tagtwo SiPixelLorentzAngle_phase1_EEoR3_HV800_Tr2000 \ + --time_type Run \ + --iovs '{"start_iov": "1", "end_iov": "1"}' \ + --iovstwo '{"start_iov": "1", "end_iov": "1"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_LA/comparisonByRegionTwoTagsPhase1.png + +getPayloadData.py \ + --plugin pluginSiPixelLorentzAngle_PayloadInspector \ + --plot plot_SiPixelLorentzAngleValuesEndcapCompareSingleTag \ + --tag SiPixelLorentzAngle_2009_v1_express \ + --time_type Run \ + --iovs '{"start_iov": "197571", "end_iov": "326083"}' \ + --db Prod \ + --test ; + +mv *.png $W_DIR/plots_LA/comparisonByRegionSingleTagsPhase0-Phase1.png + getPayloadData.py \ --plugin pluginSiPixelLorentzAngle_PayloadInspector \ --plot plot_SiPixelLorentzAngleValueComparisonTwoTags \ diff --git a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp index de792bc100970..241e50c2556c7 100644 --- a/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp +++ b/CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp @@ -138,10 +138,10 @@ int main(int argc, char** argv) { SiPixelTemplateIDsBPixMap histo18; histo18.process(connectionString, PI::mk_input(tag, end, end)); - std::cout << histo17.data() << std::endl; + std::cout << histo18.data() << std::endl; SiPixelTemplateLAFPixMap histo19; - histo18.process(connectionString, PI::mk_input(tag, end, end)); + histo19.process(connectionString, PI::mk_input(tag, end, end)); std::cout << histo19.data() << std::endl; Py_Finalize(); From 06d8b99b445f32031f5d0d13396e451111c50be8 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 18:41:57 +0200 Subject: [PATCH 27/32] include features to do by-region comparisons of one multi-ioved tag and two tags --- .../interface/PixelRegionContainers.h | 24 ++- .../SiPixelLorentzAngle_PayloadInspector.cc | 176 ++++++++++++++++++ ...iPixelTemplateDBObject_PayloadInspector.cc | 2 +- 3 files changed, 195 insertions(+), 7 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index fa447554bb451..7c61facf35c18 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -175,7 +175,7 @@ namespace PixelRegions { const float xmin, const float xmax) { for (const auto& pixelId : PixelIDs | boost::adaptors::indexed(0)) { - m_theMap[pixelId.value()] = std::make_shared(itoa(pixelId.value()).c_str(), + m_theMap[pixelId.value()] = std::make_shared((title_label + itoa(pixelId.value())).c_str(), Form("%s %s;%s;%s", (IDlabels.at(pixelId.index())).c_str(), title_label.c_str(), @@ -200,7 +200,7 @@ namespace PixelRegions { } //============================================================================ - void draw(TCanvas& canv, bool isBarrel, const char* option = "bar2") { + void draw(TCanvas& canv, bool isBarrel, const char* option = "bar2", bool isComparison = false) { if (isBarrel) { for (int j = 1; j <= 4; j++) { if (!m_isLog) { @@ -208,7 +208,7 @@ namespace PixelRegions { } else { canv.cd(j)->SetLogy(); } - if ((j == 4) && !m_isPhase1) { + if ((j == 4) && !m_isPhase1 && !isComparison) { m_theMap.at(PixelIDs[j - 1])->Draw("AXIS"); TLatex t2; t2.SetTextAlign(22); @@ -228,7 +228,7 @@ namespace PixelRegions { } else { canv.cd(j)->SetLogy(); } - if ((j % 6 == 5 || j % 6 == 0) && !m_isPhase1) { + if ((j % 6 == 5 || j % 6 == 0) && !m_isPhase1 && !isComparison) { m_theMap.at(PixelIDs[j + 3])->Draw("AXIS"); TLatex t2; t2.SetTextAlign(22); @@ -266,12 +266,14 @@ namespace PixelRegions { void setLogScale() { m_isLog = true; } //============================================================================ - void stats() { + void stats(int index = 0) { for (const auto& plot : m_theMap) { TPaveStats* st = (TPaveStats*)plot.second->FindObject("stats"); if (st) { st->SetTextSize(0.03); - SiPixelPI::adjustStats(st, 0.15, 0.85, 0.39, 0.93); + st->SetLineColor(10); + st->SetTextColor(plot.second->GetFillColor()); + SiPixelPI::adjustStats(st, 0.13, 0.85 - index * 0.08, 0.36, 0.93 - index * 0.08); } } } @@ -286,6 +288,16 @@ namespace PixelRegions { } } + //============================================================================ + void rescaleMax(PixelRegionContainers& the2Container) { + for (const auto& plot : m_theMap) { + auto thePixId = plot.first; + auto extrema = SiPixelPI::getExtrema((plot.second).get(), the2Container.getHistoFromMap(thePixId).get()); + plot.second->GetYaxis()->SetRangeUser(extrema.first, extrema.second); + the2Container.getHistoFromMap(thePixId)->GetYaxis()->SetRangeUser(extrema.first, extrema.second); + } + } + private: const TrackerTopology* m_trackerTopo; bool m_isPhase1; diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 81c8e2e6dbaed..71d2b5cd10bfe 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -230,6 +230,178 @@ namespace { using SiPixelLorentzAngleValuesBarrel = SiPixelLorentzAngleValuesPerRegion; using SiPixelLorentzAngleValuesEndcap = SiPixelLorentzAngleValuesPerRegion; + /************************************************ + 1d histogram of SiPixelLorentzAngle of 2 IOV per region + *************************************************/ + template + class SiPixelLorentzAngleValuesComparisonPerRegion + : public cond::payloadInspector::PlotImage { + public: + SiPixelLorentzAngleValuesComparisonPerRegion() + : cond::payloadInspector::PlotImage( + "SiPixelLorentzAngle Values Comparisons per region") {} + + bool fill() override { + gStyle->SetOptStat("emr"); + + // 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 tagname1 = cond::payloadInspector::PlotBase::getTag<0>().name; + std::string tagname2 = ""; + 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; + tagname2 = cond::payloadInspector::PlotBase::getTag<1>().name; + lastiov = tag2iovs.front(); + } else { + lastiov = theIOVs.back(); + } + + std::shared_ptr last_payload = this->fetchPayload(std::get<1>(lastiov)); + std::map l_LAMap_ = last_payload->getLorentzAngles(); + auto l_extrema = SiPixelPI::findMinMaxInMap(l_LAMap_); + + std::shared_ptr first_payload = this->fetchPayload(std::get<1>(firstiov)); + std::map f_LAMap_ = first_payload->getLorentzAngles(); + auto f_extrema = SiPixelPI::findMinMaxInMap(f_LAMap_); + + auto max = (l_extrema.second > f_extrema.second) ? l_extrema.second : f_extrema.second; + auto min = (l_extrema.first < f_extrema.first) ? l_extrema.first : f_extrema.first; + + std::string lastIOVsince = std::to_string(std::get<0>(lastiov)); + std::string firstIOVsince = std::to_string(std::get<0>(firstiov)); + + TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); + if ((f_LAMap_.size() > SiPixelPI::phase1size) || (l_LAMap_.size() > SiPixelPI::phase1size)) { + SiPixelPI::displayNotSupported(canvas, std::max(f_LAMap_.size(), l_LAMap_.size())); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } + + canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); + canvas.cd(); + + // deal with last IOV + + const char *path_toTopologyXML = (l_LAMap_.size() == SiPixelPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + + auto l_tTopo = + StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); + + auto l_myPlots = PixelRegions::PixelRegionContainers(&l_tTopo, (l_LAMap_.size() == SiPixelPI::phase1size)); + l_myPlots.bookAll("SiPixel LA,last", + "SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T]", + "#modules", + 50, + min * 0.9, + max * 1.1); + + //canvas.Modified(); + + for (const auto &element : l_LAMap_) { + l_myPlots.fill(element.first, element.second); + } + + l_myPlots.beautify(); + l_myPlots.draw(canvas, isBarrel, "bar2", true); + + // deal with first IOV + + path_toTopologyXML = (f_LAMap_.size() == SiPixelPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + + auto f_tTopo = + StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); + + auto f_myPlots = PixelRegions::PixelRegionContainers(&f_tTopo, (f_LAMap_.size() == SiPixelPI::phase1size)); + f_myPlots.bookAll("SiPixel LA,first", + "SiPixel LorentzAngle #mu_{H}(tan#theta_{L}/B) [1/T]", + "#modules", + 50, + min * 0.9, + max * 1.1); + + //canvas.Modified(); + + for (const auto &element : f_LAMap_) { + f_myPlots.fill(element.first, element.second); + } + + f_myPlots.beautify(kAzure, kBlue); + f_myPlots.draw(canvas, isBarrel, "HISTsames", true); + + // rescale the y-axis ranges in order to fit the canvas + l_myPlots.rescaleMax(f_myPlots); + + // done dealing with IOVs + + auto colorTag = isBarrel ? PixelRegions::L1 : PixelRegions::Rm1l; + std::unique_ptr legend; + if (this->m_plotAnnotations.ntags == 2) { + legend = std::make_unique(0.36, 0.86, 0.94, 0.92); + legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + tagname2 + "}").c_str(), "F"); + legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + tagname1 + "}").c_str(), "F"); + legend->SetTextSize(0.024); + } else { + legend = std::make_unique(0.58, 0.80, 0.90, 0.92); + legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + lastIOVsince + "}").c_str(), "F"); + legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + firstIOVsince + "}").c_str(), "F"); + legend->SetTextSize(0.040); + } + legend->SetLineColor(10); + + unsigned int maxPads = isBarrel ? 4 : 12; + for (unsigned int c = 1; c <= maxPads; c++) { + canvas.cd(c); + SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05); + legend->Draw("same"); + canvas.cd(c)->Update(); + } + + f_myPlots.stats(0); + l_myPlots.stats(1); + + auto ltx = TLatex(); + ltx.SetTextFont(62); + ltx.SetTextSize(0.05); + ltx.SetTextAlign(11); + + for (unsigned int c = 1; c <= maxPads; c++) { + auto index = isBarrel ? c - 1 : c + 3; + canvas.cd(c); + ltx.DrawLatexNDC(gPad->GetLeftMargin(), + 1 - gPad->GetTopMargin() + 0.01, + (PixelRegions::IDlabels.at(index) + " : #color[4]{" + std::to_string(std::get<0>(firstiov)) + + "} vs #color[2]{" + std::to_string(std::get<0>(lastiov)) + "}") + .c_str()); + } + + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + + //#ifdef MMDEBUG + canvas.SaveAs("DEBUG.root"); + //#endif + + return true; + } + }; + + using SiPixelLorentzAngleValuesBarrelCompareSingleTag = SiPixelLorentzAngleValuesComparisonPerRegion; + using SiPixelLorentzAngleValuesEndcapCompareSingleTag = SiPixelLorentzAngleValuesComparisonPerRegion; + + using SiPixelLorentzAngleValuesBarrelCompareTwoTags = SiPixelLorentzAngleValuesComparisonPerRegion; + using SiPixelLorentzAngleValuesEndcapCompareTwoTags = SiPixelLorentzAngleValuesComparisonPerRegion; + /************************************************ 1d histogram of SiPixelLorentzAngle of 1 IOV *************************************************/ @@ -820,6 +992,10 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelLorentzAngle) { PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValues); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesBarrel); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesEndcap); + PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesBarrelCompareSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesEndcapCompareSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesBarrelCompareTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValuesEndcapCompareTwoTags); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValueComparisonSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleValueComparisonTwoTags); PAYLOAD_INSPECTOR_CLASS(SiPixelLorentzAngleByRegionComparisonSingleTag); diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc index 4b919c7d0cc35..39167d56086ba 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelTemplateDBObject_PayloadInspector.cc @@ -186,7 +186,7 @@ namespace { ltx.SetTextAlign(11); ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, - (tagname + ",IOV:" + std::to_string(std::get<0>(iov))).c_str()); + (tagname + ", IOV:" + std::to_string(std::get<0>(iov))).c_str()); std::string fileName(m_imageFileName); canvas.SaveAs(fileName.c_str()); From f213866e7f7cc8e7ae655f73821aac2006827167 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 23:05:36 +0200 Subject: [PATCH 28/32] improvements in the SiPixelLorentzAngle_PayloadInspector --- .../plugins/SiPixelLorentzAngle_PayloadInspector.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc index 71d2b5cd10bfe..cab6fa6f2fe3c 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelLorentzAngle_PayloadInspector.cc @@ -239,7 +239,7 @@ namespace { public: SiPixelLorentzAngleValuesComparisonPerRegion() : cond::payloadInspector::PlotImage( - "SiPixelLorentzAngle Values Comparisons per region") {} + Form("SiPixelLorentzAngle Values Comparisons per region %i tags(s)", ntags)) {} bool fill() override { gStyle->SetOptStat("emr"); @@ -388,9 +388,9 @@ namespace { std::string fileName(this->m_imageFileName); canvas.SaveAs(fileName.c_str()); - //#ifdef MMDEBUG +#ifdef MMDEBUG canvas.SaveAs("DEBUG.root"); - //#endif +#endif return true; } From 0d50e1ec7372524092a373f1049ec917cbd3f52d Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 23:05:57 +0200 Subject: [PATCH 29/32] some aesthetical improvements in PixelRegionContainers --- .../SiPixelPlugins/interface/PixelRegionContainers.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index 7c61facf35c18..47f250432ca30 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -251,10 +251,12 @@ namespace PixelRegions { if (!m_isLog) { plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30); } else { - plot.second->GetYaxis()->SetRangeUser(0.1, plot.second->GetMaximum() * 10.); + plot.second->GetYaxis()->SetRangeUser(0.1, plot.second->GetMaximum() * 100.); } plot.second->SetLineColor(linecolor); - plot.second->SetFillColor(fillcolor); + if (fillcolor > 0) { + plot.second->SetFillColor(fillcolor); + } plot.second->SetMarkerStyle(20); plot.second->SetMarkerSize(1); SiPixelPI::makeNicePlotStyle(plot.second.get()); @@ -272,7 +274,11 @@ namespace PixelRegions { if (st) { st->SetTextSize(0.03); st->SetLineColor(10); - st->SetTextColor(plot.second->GetFillColor()); + if (plot.second->GetFillColor() != 0) { + st->SetTextColor(plot.second->GetFillColor()); + } else { + st->SetTextColor(plot.second->GetLineColor()); + } SiPixelPI::adjustStats(st, 0.13, 0.85 - index * 0.08, 0.36, 0.93 - index * 0.08); } } From 0f576b8cc50082ea94c8f99ba96108328b1677f0 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 15 May 2020 23:06:32 +0200 Subject: [PATCH 30/32] support comparison per layer / disk for Gains and Pedestals --- .../interface/SiPixelGainCalibHelper.h | 201 ++++++++++++++++++ ...GainCalibrationOffline_PayloadInspector.cc | 61 ++++++ 2 files changed, 262 insertions(+) diff --git a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h index 786ec76feff5d..f2cf840075a7c 100644 --- a/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h +++ b/CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h @@ -450,6 +450,207 @@ namespace gainCalibHelper { std::string label_; }; + /******************************************************************* + 1d histograms comparison per region of SiPixelGainCalibration for Gains of 2 IOV + ********************************************************************/ + template + class SiPixelGainCalibrationValuesComparisonPerRegion + : public cond::payloadInspector::PlotImage { + public: + SiPixelGainCalibrationValuesComparisonPerRegion() + : cond::payloadInspector::PlotImage( + Form("SiPixelGainCalibration %s Values Per Region %i tag(s)", TypeName[myType], ntags)) { + cond::payloadInspector::PlotBase::addInputParam("SetLog"); + + if constexpr (std::is_same_v) { + isForHLT_ = false; + label_ = "SiPixelGainCalibrationOffline_PayloadInspector"; + } else { + isForHLT_ = true; + label_ = "SiPixelGainCalibrationForHLT_PayloadInspector"; + } + } + + bool fill() override { + gStyle->SetOptStat("mr"); + + COUT << "ntags: " << ntags << " this->m_plotAnnotations.ntags: " << this->m_plotAnnotations.ntags << std::endl; + + // 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 tagname1 = cond::payloadInspector::PlotBase::getTag<0>().name; + std::string tagname2 = ""; + 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; + tagname2 = cond::payloadInspector::PlotBase::getTag<1>().name; + lastiov = tag2iovs.front(); + } else { + lastiov = theIOVs.back(); + } + + // parse first if log + bool setLog(false); + auto paramValues = cond::payloadInspector::PlotBase::inputParamValues(); + auto ip = paramValues.find("SetLog"); + if (ip != paramValues.end()) { + auto answer = boost::lexical_cast(ip->second); + if (!SiPixelPI::checkAnswerOK(answer, setLog)) { + throw cms::Exception(label_) + << "\nERROR: " << answer + << " is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n"; + } + } + + std::shared_ptr last_payload = this->fetchPayload(std::get<1>(lastiov)); + std::shared_ptr first_payload = this->fetchPayload(std::get<1>(firstiov)); + + std::string lastIOVsince = std::to_string(std::get<0>(lastiov)); + std::string firstIOVsince = std::to_string(std::get<0>(firstiov)); + + std::vector f_detids, l_detids; + last_payload->getDetIds(l_detids); + first_payload->getDetIds(f_detids); + + float minimum(9999.); + float maximum(-9999.); + + switch (myType) { + case gainCalibPI::t_gain: + maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh()); + minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow()); + break; + case gainCalibPI::t_pedestal: + maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh()); + minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow()); + break; + default: + edm::LogError(label_) << "Unrecognized type " << myType << std::endl; + break; + } + + TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200); + if (std::max(l_detids.size(), f_detids.size()) > SiPixelPI::phase1size) { + SiPixelPI::displayNotSupported(canvas, std::max(f_detids.size(), l_detids.size())); + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + return false; + } + + canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3); + canvas.cd(); + + const char* path_toTopologyXML = (l_detids.size() == SiPixelPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + auto l_tTopo = + StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); + + auto l_myPlots = PixelRegions::PixelRegionContainers(&l_tTopo, (l_detids.size() == SiPixelPI::phase1size)); + l_myPlots.bookAll( + Form("Last SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]), + Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]), + Form("# %ss", (isForHLT_ ? "column" : "pixel")), + 200, + minimum, + maximum); + + path_toTopologyXML = (f_detids.size() == SiPixelPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + auto f_tTopo = + StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); + + auto f_myPlots = PixelRegions::PixelRegionContainers(&f_tTopo, (f_detids.size() == SiPixelPI::phase1size)); + f_myPlots.bookAll( + Form("First SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]), + Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]), + Form("# %ss", (isForHLT_ ? "column" : "pixel")), + 200, + minimum, + maximum); + + // fill the histograms + for (const auto& pixelId : PixelRegions::PixelIDs) { + auto f_wantedDets = PixelRegions::attachedDets(pixelId, &f_tTopo, (f_detids.size() == SiPixelPI::phase1size)); + auto l_wantedDets = PixelRegions::attachedDets(pixelId, &l_tTopo, (l_detids.size() == SiPixelPI::phase1size)); + gainCalibPI::fillTheHisto(first_payload, f_myPlots.getHistoFromMap(pixelId), myType, f_wantedDets); + gainCalibPI::fillTheHisto(last_payload, l_myPlots.getHistoFromMap(pixelId), myType, l_wantedDets); + } + + if (setLog) { + f_myPlots.setLogScale(); + l_myPlots.setLogScale(); + } + + l_myPlots.beautify(kRed, -1); + f_myPlots.beautify(kAzure, -1); + + l_myPlots.draw(canvas, isBarrel, "HIST", true); + f_myPlots.draw(canvas, isBarrel, "HISTsames", true); + + // rescale the y-axis ranges in order to fit the canvas + l_myPlots.rescaleMax(f_myPlots); + + // done dealing with IOVs + auto colorTag = isBarrel ? PixelRegions::L1 : PixelRegions::Rm1l; + std::unique_ptr legend; + if (this->m_plotAnnotations.ntags == 2) { + legend = std::make_unique(0.36, 0.86, 0.94, 0.92); + legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + tagname2 + "}").c_str(), "F"); + legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + tagname1 + "}").c_str(), "F"); + legend->SetTextSize(0.024); + } else { + legend = std::make_unique(0.58, 0.80, 0.90, 0.92); + legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + lastIOVsince + "}").c_str(), "F"); + legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + firstIOVsince + "}").c_str(), "F"); + legend->SetTextSize(0.040); + } + legend->SetLineColor(10); + + unsigned int maxPads = isBarrel ? 4 : 12; + for (unsigned int c = 1; c <= maxPads; c++) { + canvas.cd(c); + SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05); + legend->Draw("same"); + canvas.cd(c)->Update(); + } + + f_myPlots.stats(0); + l_myPlots.stats(1); + + auto ltx = TLatex(); + ltx.SetTextFont(62); + ltx.SetTextSize(0.05); + ltx.SetTextAlign(11); + + for (unsigned int c = 1; c <= maxPads; c++) { + auto index = isBarrel ? c - 1 : c + 3; + canvas.cd(c); + auto leftX = setLog ? 0. : 0.1; + ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX, + 1 - gPad->GetTopMargin() + 0.01, + (PixelRegions::IDlabels.at(index) + " : #color[4]{" + std::to_string(std::get<0>(firstiov)) + + "} vs #color[2]{" + std::to_string(std::get<0>(lastiov)) + "}") + .c_str()); + } + + std::string fileName(this->m_imageFileName); + canvas.SaveAs(fileName.c_str()); + + return true; + } + + protected: + bool isForHLT_; + std::string label_; + }; + /******************************************************************* 1d histogram of SiPixelGainCalibration for Gain/Pedestals correlation of 1 IOV diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc index 86c23a6276325..11d11b50f132b 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc @@ -55,6 +55,54 @@ namespace { gainCalibHelper::SiPixelGainCalibrationValueComparisonTwoTags; + using SiPixelGainCalibOfflineGainComparisonBarrelSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflinePedestalComparisonBarrelSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflineGainComparisonBarrelTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflinePedestalComparisonBarrelTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflineGainComparisonEndcapSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflinePedestalComparisonEndcapSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflineGainComparisonEndcapTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibOfflinePedestalComparisonEndcapTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + using SiPixelGainCalibOfflineGainsBPIXMap = gainCalibHelper::SiPixelGainCalibrationBPIXMap; @@ -95,6 +143,19 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelGainCalibrationOffline) { PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineCorrelations); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineGainsByPart); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflinePedestalsByPart); + + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonBarrelSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonBarrelTwoTags); + + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonBarrelSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonBarrelTwoTags); + + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonEndcapSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonEndcapTwoTags); + + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonEndcapSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonEndcapTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonSingleTag) PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonTwoTags); From 908a4831df3d5835c23d5e9ea8940faedfd9d55a Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 17 May 2020 19:35:17 +0200 Subject: [PATCH 31/32] better variable naming --- CondCore/SiPixelPlugins/interface/PixelRegionContainers.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h index 47f250432ca30..d80b88458b303 100644 --- a/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h +++ b/CondCore/SiPixelPlugins/interface/PixelRegionContainers.h @@ -295,12 +295,12 @@ namespace PixelRegions { } //============================================================================ - void rescaleMax(PixelRegionContainers& the2Container) { + void rescaleMax(PixelRegionContainers& the2ndContainer) { for (const auto& plot : m_theMap) { auto thePixId = plot.first; - auto extrema = SiPixelPI::getExtrema((plot.second).get(), the2Container.getHistoFromMap(thePixId).get()); + auto extrema = SiPixelPI::getExtrema((plot.second).get(), the2ndContainer.getHistoFromMap(thePixId).get()); plot.second->GetYaxis()->SetRangeUser(extrema.first, extrema.second); - the2Container.getHistoFromMap(thePixId)->GetYaxis()->SetRangeUser(extrema.first, extrema.second); + the2ndContainer.getHistoFromMap(thePixId)->GetYaxis()->SetRangeUser(extrema.first, extrema.second); } } From 21490dc29eebd880d3e082155a5ed419420738b4 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sun, 17 May 2020 20:10:58 +0200 Subject: [PATCH 32/32] better variable naming, add new plots also to HLT Gain Payload Inspector --- ...lGainCalibrationForHLT_PayloadInspector.cc | 56 +++++++++++++++++++ ...GainCalibrationOffline_PayloadInspector.cc | 6 -- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc index 0223134febb6e..fd48d675aa07c 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationForHLT_PayloadInspector.cc @@ -54,6 +54,54 @@ namespace { gainCalibHelper::SiPixelGainCalibrationValueComparisonTwoTags; + using SiPixelGainCalibForHLTGainComparisonBarrelSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTPedestalComparisonBarrelSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTGainComparisonBarrelTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTPedestalComparisonBarrelTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTGainComparisonEndcapSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTPedestalComparisonEndcapSingleTag = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTGainComparisonEndcapTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + + using SiPixelGainCalibForHLTPedestalComparisonEndcapTwoTags = + gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion; + using SiPixelGainCalibForHLTGainsBPIXMap = gainCalibHelper::SiPixelGainCalibrationBPIXMap; using SiPixelGainCalibForHLTPedestalsBPIXMap = @@ -92,6 +140,14 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelGainCalibrationForHLT) { PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTCorrelations); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTGainsByPart); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationForHLTPedestalsByPart); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTGainComparisonBarrelSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTGainComparisonBarrelTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTPedestalComparisonBarrelSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTPedestalComparisonBarrelTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTGainComparisonEndcapSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTGainComparisonEndcapTwoTags); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTPedestalComparisonEndcapSingleTag); + PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTPedestalComparisonEndcapTwoTags); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTGainComparisonSingleTag) PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTPedestalComparisonSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibForHLTGainComparisonTwoTags); diff --git a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc index 11d11b50f132b..bf84f66cfe4b3 100644 --- a/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc +++ b/CondCore/SiPixelPlugins/plugins/SiPixelGainCalibrationOffline_PayloadInspector.cc @@ -7,7 +7,6 @@ */ #include "CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h" -//#include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationOffline.h" namespace { @@ -143,19 +142,14 @@ PAYLOAD_INSPECTOR_MODULE(SiPixelGainCalibrationOffline) { PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineCorrelations); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflineGainsByPart); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibrationOfflinePedestalsByPart); - PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonBarrelSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonBarrelTwoTags); - PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonBarrelSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonBarrelTwoTags); - PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonEndcapSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonEndcapTwoTags); - PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonEndcapSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonEndcapTwoTags); - PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonSingleTag) PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflinePedestalComparisonSingleTag); PAYLOAD_INSPECTOR_CLASS(SiPixelGainCalibOfflineGainComparisonTwoTags);