Skip to content
189 changes: 62 additions & 127 deletions CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace gainCalibHelper {
namespace gainCalibPI {

enum type { t_gain = 0, t_pedestal = 1, t_correlation = 2 };
std::array<std::string, 3> t_titles = {{"gain", "pedestal", "correlation"}};

//===========================================================================
// helper method to fill the ratio and diff distributions
Expand Down Expand Up @@ -1351,11 +1352,11 @@ namespace gainCalibHelper {
/************************************************
occupancy style map BPix
*************************************************/
template <gainCalibPI::type myType, class PayloadType>
class SiPixelGainCalibrationBPIXMap
template <gainCalibPI::type myType, class PayloadType, SiPixelPI::DetType myDetType>
class SiPixelGainCalibrationMap
: public cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV> {
public:
SiPixelGainCalibrationBPIXMap()
SiPixelGainCalibrationMap()
: cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV>(
Form("SiPixelGainCalibration %s Barrel Pixel Map", TypeName[myType])),
m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
Expand All @@ -1370,13 +1371,17 @@ namespace gainCalibHelper {
};

bool fill() override {
TGaxis::SetMaxDigits(2);

auto tag = cond::payloadInspector::PlotBase::getTag<0>();
auto tagname = tag.name;
auto iov = tag.iovs.front();

std::shared_ptr<PayloadType> payload = this->fetchPayload(std::get<1>(iov));

Phase1PixelROCMaps theBPixGainsMap("");
static constexpr int n_layers = 4;
std::string ztitle =
fmt::sprintf("average per %s %s", isForHLT_ ? "column" : "pixel", gainCalibPI::t_titles[myType]);
Phase1PixelROCMaps theGainsMap("", ztitle);

std::map<uint32_t, float> GainCalibMap_;
gainCalibPI::fillThePerModuleMap(payload, GainCalibMap_, myType);
Expand All @@ -1390,163 +1395,93 @@ namespace gainCalibHelper {
}

// hard-coded phase-I
std::array<double, n_layers> minima = {{999., 999., 999., 999.}};
std::array<double, n_layers> b_minima = {{999., 999., 999., 999.}};
std::array<double, n_rings> f_minima = {{999., 999.}};

for (const auto& element : GainCalibMap_) {
int subid = DetId(element.first).subdetId();
if (subid == PixelSubdetector::PixelBarrel) {
auto layer = m_trackerTopo.pxbLayer(DetId(element.first));

if (element.second < minima.at(layer - 1))
minima.at(layer - 1) = element.second;

theBPixGainsMap.fillWholeModule(element.first, element.second);
if (element.second < b_minima.at(layer - 1)) {
b_minima.at(layer - 1) = element.second;
}
theGainsMap.fillWholeModule(element.first, element.second);
} else if (subid == PixelSubdetector::PixelEndcap) {
auto ring = SiPixelPI::ring(DetId(element.first), m_trackerTopo, true);
if (element.second < f_minima.at(ring - 1)) {
f_minima.at(ring - 1) = element.second;
}
theGainsMap.fillWholeModule(element.first, element.second);
}
}

gStyle->SetOptStat(0);
//=========================
TCanvas canvas("Summary", "Summary", 1200, 1200);
theBPixGainsMap.drawBarrelMaps(canvas);

for (unsigned int lay = 1; lay <= n_layers; lay++) {
SiPixelPI::adjustCanvasMargins(canvas.cd(lay), -1, 0.08, 0.1, 0.13);

auto h_bpix_Gains = theBPixGainsMap.getLayerMaps();

COUT << " layer:" << lay << " max:" << h_bpix_Gains[lay - 1]->GetMaximum() << " min: " << minima.at(lay - 1)
<< std::endl;

h_bpix_Gains[lay - 1]->GetZaxis()->SetRangeUser(minima.at(lay - 1) - 0.001,
h_bpix_Gains[lay - 1]->GetMaximum() + 0.001);
}
TCanvas canvas("Summary", "Summary", 1200, k_height[myDetType]);
canvas.cd();

auto unpacked = SiPixelPI::unpack(std::get<0>(iov));

for (unsigned int lay = 1; lay <= n_layers; lay++) {
canvas.cd(lay);
auto ltx = TLatex();
ltx.SetTextFont(62);
ltx.SetTextColor(kBlue);
ltx.SetTextSize(0.055);
ltx.SetTextAlign(11);
ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1 - gPad->GetTopMargin() + 0.01,
unpacked.first == 0
? ("IOV:" + std::to_string(unpacked.second)).c_str()
: (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str());
}

std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());

return true;
}

private:
TrackerTopology m_trackerTopo;

protected:
bool isForHLT_;
std::string label_;
};

/************************************************
occupancy style map FPix
*************************************************/

template <gainCalibPI::type myType, class PayloadType>
class SiPixelGainCalibrationFPIXMap
: public cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV> {
public:
SiPixelGainCalibrationFPIXMap()
: cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::SINGLE_IOV>(
Form("SiPixelGainCalibration %s Forward Pixel Map", TypeName[myType])),
m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
isForHLT_ = false;
label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
} else {
isForHLT_ = true;
label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
}
}

bool fill() override {
auto tag = cond::payloadInspector::PlotBase::getTag<0>();
auto iov = tag.iovs.front();
std::shared_ptr<PayloadType> payload = this->fetchPayload(std::get<1>(iov));
std::string IOVstring = (unpacked.first == 0)
? std::to_string(unpacked.second)
: (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second));

Phase1PixelROCMaps theFPixGainsMap("");
static constexpr int n_rings = 2;
const auto headerText = fmt::sprintf("#color[4]{%s}, IOV: #color[4]{%s}", tagname, IOVstring);

std::map<uint32_t, float> GainCalibMap_;
gainCalibPI::fillThePerModuleMap(payload, GainCalibMap_, myType);
if (GainCalibMap_.size() != SiPixelPI::phase1size) {
edm::LogError(label_) << "SiPixelGainCalibration maps are not supported for non-Phase1 Pixel geometries !";
TCanvas canvas("Canv", "Canv", 1200, 1000);
SiPixelPI::displayNotSupported(canvas, GainCalibMap_.size());
std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());
return false;
switch (myDetType) {
case SiPixelPI::t_barrel:
theGainsMap.drawBarrelMaps(canvas, headerText);
break;
case SiPixelPI::t_forward:
theGainsMap.drawForwardMaps(canvas, headerText);
break;
case SiPixelPI::t_all:
theGainsMap.drawMaps(canvas, headerText);
break;
default:
throw cms::Exception("SiPixelGainCalibrationMap")
<< "\nERROR: unrecognized Pixel Detector part " << std::endl;
}

// hardcoded phase-I
std::array<double, n_rings> minima = {{999., 999.}};
if (myDetType == SiPixelPI::t_barrel || myDetType == SiPixelPI::t_all) {
for (unsigned int lay = 1; lay <= n_layers; lay++) {
//SiPixelPI::adjustCanvasMargins(canvas.cd(lay), -1, 0.08, 0.1, 0.13);

for (const auto& element : GainCalibMap_) {
int subid = DetId(element.first).subdetId();
if (subid == PixelSubdetector::PixelEndcap) {
auto ring = SiPixelPI::ring(DetId(element.first), m_trackerTopo, true);
auto h_bpix_Gains = theGainsMap.getLayerMaps();

if (element.second < minima.at(ring - 1))
minima.at(ring - 1) = element.second;
COUT << " layer:" << lay << " max:" << h_bpix_Gains[lay - 1]->GetMaximum() << " min: " << b_minima.at(lay - 1)
<< std::endl;

theFPixGainsMap.fillWholeModule(element.first, element.second);
h_bpix_Gains[lay - 1]->GetZaxis()->SetRangeUser(b_minima.at(lay - 1) - 0.001,
h_bpix_Gains[lay - 1]->GetMaximum() + 0.001);
}
}

gStyle->SetOptStat(0);
//=========================
TCanvas canvas("Summary", "Summary", 1200, 600);
theFPixGainsMap.drawForwardMaps(canvas);
if (myDetType == SiPixelPI::t_forward || myDetType == SiPixelPI::t_all) {
for (unsigned int ring = 1; ring <= n_rings; ring++) {
//SiPixelPI::adjustCanvasMargins(canvas.cd(ring), -1, 0.08, 0.1, 0.13);

for (unsigned int ring = 1; ring <= n_rings; ring++) {
SiPixelPI::adjustCanvasMargins(canvas.cd(ring), -1, 0.08, 0.1, 0.13);
auto h_fpix_Gains = theGainsMap.getRingMaps();

auto h_fpix_Gains = theFPixGainsMap.getRingMaps();
COUT << " ring:" << ring << " max:" << h_fpix_Gains[ring - 1]->GetMaximum()
<< " min: " << f_minima.at(ring - 1) << std::endl;

COUT << " ring:" << ring << " max:" << h_fpix_Gains[ring - 1]->GetMaximum() << " min: " << minima.at(ring - 1)
<< std::endl;

h_fpix_Gains[ring - 1]->GetZaxis()->SetRangeUser(minima.at(ring - 1) - 0.001,
h_fpix_Gains[ring - 1]->GetMaximum() + 0.001);
}

auto unpacked = SiPixelPI::unpack(std::get<0>(iov));

for (unsigned int ring = 1; ring <= n_rings; ring++) {
canvas.cd(ring);
auto ltx = TLatex();
ltx.SetTextFont(62);
ltx.SetTextColor(kBlue);
ltx.SetTextSize(0.05);
ltx.SetTextAlign(11);
ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1 - gPad->GetTopMargin() + 0.01,
unpacked.first == 0
? ("IOV:" + std::to_string(unpacked.second)).c_str()
: (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str());
h_fpix_Gains[ring - 1]->GetZaxis()->SetRangeUser(f_minima.at(ring - 1) - 0.001,
h_fpix_Gains[ring - 1]->GetMaximum() + 0.001);
}
}

std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());

return true;
}

private:
TrackerTopology m_trackerTopo;
static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
static constexpr int n_layers = 4;
static constexpr int n_rings = 2;

protected:
bool isForHLT_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ namespace SiPixelPI {
}

enum DetType { t_barrel = 0, t_forward = 1, t_all = 2 };
const std::array<std::string, 3> DetNames = {{"Barrel", "End Caps", "Whole"}};

enum regions {
BPixL1o, //0 Barrel Pixel Layer 1 outer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ namespace {
1d histogram of SiPixelFEDChannelContainer of 1 IOV
*************************************************/

class SiPixelFEDChannelContainerTest : public PlotImage<SiPixelFEDChannelContainer, SINGLE_IOV> {
template <SiPixelPI::DetType myType>
class SiPixelFEDChannelContainerMap : public PlotImage<SiPixelFEDChannelContainer, SINGLE_IOV> {
public:
SiPixelFEDChannelContainerTest()
SiPixelFEDChannelContainerMap()
: PlotImage<SiPixelFEDChannelContainer, SINGLE_IOV>("SiPixelFEDChannelContainer scenarios count"),
m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
Expand Down Expand Up @@ -99,6 +100,7 @@ namespace {
Phase1PixelROCMaps theROCMap("");

auto tag = PlotBase::getTag<0>();
auto tagname = tag.name;
auto iov = tag.iovs.front();

// open db session for the cabling map
Expand Down Expand Up @@ -217,37 +219,29 @@ namespace {

gStyle->SetOptStat(0);
//=========================
TCanvas canvas("Summary", "Summary", 1200, 1600);
theROCMap.drawMaps(canvas);
TCanvas canvas("Summary", "Summary", 1200, k_height[myType]);
canvas.cd();

auto unpacked = SiPixelPI::unpack(std::get<0>(iov));

for (unsigned int lay = 1; lay <= n_layers; lay++) {
canvas.cd(lay);
auto ltx = TLatex();
ltx.SetTextFont(62);
ltx.SetTextColor(kBlue);
ltx.SetTextSize(0.055);
ltx.SetTextAlign(11);
ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1 - gPad->GetTopMargin() + 0.01,
unpacked.first == 0
? ("IOV:" + std::to_string(unpacked.second)).c_str()
: (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str());
}

for (unsigned int ring = 1; ring <= n_rings; ring++) {
canvas.cd(n_layers + ring);
auto ltx = TLatex();
ltx.SetTextFont(62);
ltx.SetTextColor(kBlue);
ltx.SetTextSize(0.050);
ltx.SetTextAlign(11);
ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1 - gPad->GetTopMargin() + 0.01,
unpacked.first == 0
? ("IOV:" + std::to_string(unpacked.second)).c_str()
: (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str());
std::string IOVstring = (unpacked.first == 0)
? std::to_string(unpacked.second)
: (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second));

const auto headerText = fmt::sprintf("#color[4]{%s}, IOV: #color[4]{%s}", tagname, IOVstring);

switch (myType) {
case SiPixelPI::t_barrel:
theROCMap.drawBarrelMaps(canvas, headerText);
break;
case SiPixelPI::t_forward:
theROCMap.drawForwardMaps(canvas, headerText);
break;
case SiPixelPI::t_all:
theROCMap.drawMaps(canvas, headerText);
break;
default:
throw cms::Exception("SiPixelQualityMap") << "\nERROR: unrecognized Pixel Detector part " << std::endl;
}

std::string fileName(m_imageFileName);
Expand Down Expand Up @@ -285,13 +279,20 @@ namespace {
static constexpr int n_rings = 2;
static constexpr int n_layers = 4;

// graphics
static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};

TrackerTopology m_trackerTopo;
edm::ParameterSet m_connectionPset;
cond::persistency::ConnectionPool m_connectionPool;
std::string m_CablingTagName;
std::string m_condDbCabling;
};

using SiPixelBPixFEDChannelContainerMap = SiPixelFEDChannelContainerMap<SiPixelPI::t_barrel>;
using SiPixelFPixFEDChannelContainerMap = SiPixelFEDChannelContainerMap<SiPixelPI::t_forward>;
using SiPixelFullFEDChannelContainerMap = SiPixelFEDChannelContainerMap<SiPixelPI::t_all>;

/************************************************
1d histogram of SiPixelFEDChannelContainer of 1 IOV
*************************************************/
Expand Down Expand Up @@ -387,6 +388,8 @@ namespace {

// Register the classes as boost python plugin
PAYLOAD_INSPECTOR_MODULE(SiPixelFEDChannelContainer) {
PAYLOAD_INSPECTOR_CLASS(SiPixelFEDChannelContainerTest);
PAYLOAD_INSPECTOR_CLASS(SiPixelBPixFEDChannelContainerMap);
PAYLOAD_INSPECTOR_CLASS(SiPixelFPixFEDChannelContainerMap);
PAYLOAD_INSPECTOR_CLASS(SiPixelFullFEDChannelContainerMap);
PAYLOAD_INSPECTOR_CLASS(SiPixelFEDChannelContainerScenarios);
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ namespace {
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTGainsBPIXMap =
SiPixelGainCalibrationBPIXMap<gainCalibPI::t_gain, SiPixelGainCalibrationForHLT>;
SiPixelGainCalibrationMap<gainCalibPI::t_gain, SiPixelGainCalibrationForHLT, SiPixelPI::t_barrel>;
using SiPixelGainCalibForHLTPedestalsBPIXMap =
SiPixelGainCalibrationBPIXMap<gainCalibPI::t_pedestal, SiPixelGainCalibrationForHLT>;
SiPixelGainCalibrationMap<gainCalibPI::t_pedestal, SiPixelGainCalibrationForHLT, SiPixelPI::t_barrel>;

using SiPixelGainCalibForHLTGainsFPIXMap =
SiPixelGainCalibrationFPIXMap<gainCalibPI::t_gain, SiPixelGainCalibrationForHLT>;
SiPixelGainCalibrationMap<gainCalibPI::t_gain, SiPixelGainCalibrationForHLT, SiPixelPI::t_forward>;
using SiPixelGainCalibForHLTPedestalsFPIXMap =
SiPixelGainCalibrationFPIXMap<gainCalibPI::t_pedestal, SiPixelGainCalibrationForHLT>;
SiPixelGainCalibrationMap<gainCalibPI::t_pedestal, SiPixelGainCalibrationForHLT, SiPixelPI::t_forward>;

using SiPixelGainCalibForHLTGainByRegionComparisonSingleTag =
SiPixelGainCalibrationByRegionComparisonBase<gainCalibPI::t_gain,
Expand Down
Loading