Skip to content

Commit

Permalink
Merge pull request #29980 from mmusich/clean_PixelPayloadInspector
Browse files Browse the repository at this point in the history
[11.1.X]  Fix several bugs introduced in the Pixel PI
  • Loading branch information
cmsbuild authored May 28, 2020
2 parents ab5e413 + 9bdb059 commit ea60d76
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 103 deletions.
64 changes: 56 additions & 8 deletions CondCore/SiPixelPlugins/interface/Phase1PixelMaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Phase1PixelMaps {
~Phase1PixelMaps() {}

//============================================================================
void bookBarrelHistograms(const std::string& currentHistoName, const char* what) {
void bookBarrelHistograms(const std::string& currentHistoName, const char* what, const char* zaxis) {
std::string histName;
std::shared_ptr<TH2Poly> th2p;

Expand All @@ -46,8 +46,8 @@ class Phase1PixelMaps {

th2p->GetXaxis()->SetTitle("z [cm]");
th2p->GetYaxis()->SetTitle("ladder");
//th2p->GetXaxis()->SetTitleOffset(0.09);
//th2p->GetYaxis()->SetTitleOffset(0.09);
th2p->GetZaxis()->SetTitle(zaxis);
th2p->GetZaxis()->CenterTitle();
th2p->SetStats(false);
th2p->SetOption(m_option);
pxbTh2PolyBarrel[currentHistoName].push_back(th2p);
Expand All @@ -64,7 +64,7 @@ class Phase1PixelMaps {
}

//============================================================================
void bookForwardHistograms(const std::string& currentHistoName, const char* what) {
void bookForwardHistograms(const std::string& currentHistoName, const char* what, const char* zaxis) {
std::string histName;
std::shared_ptr<TH2Poly> th2p;

Expand All @@ -81,8 +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->GetZaxis()->SetTitle(zaxis);
th2p->GetZaxis()->CenterTitle();
th2p->SetStats(false);
th2p->SetOption(m_option);
pxfTh2PolyForward[currentHistoName].push_back(th2p);
Expand Down Expand Up @@ -208,6 +208,8 @@ class Phase1PixelMaps {
SiPixelPI::makeNicePlotStyle(plot.get());
plot->GetXaxis()->SetTitleOffset(0.9);
plot->GetYaxis()->SetTitleOffset(0.9);
plot->GetZaxis()->SetTitleOffset(1.2);
plot->GetZaxis()->SetTitleSize(0.05);
}
}

Expand All @@ -216,10 +218,54 @@ class Phase1PixelMaps {
SiPixelPI::makeNicePlotStyle(plot.get());
plot->GetXaxis()->SetTitleOffset(0.9);
plot->GetYaxis()->SetTitleOffset(0.9);
plot->GetZaxis()->SetTitleOffset(1.2);
plot->GetZaxis()->SetTitleSize(0.05);
}
}
}

//============================================================================
void rescaleAllBarrel(const std::string& currentHistoName) {
std::vector<float> maxima;
std::transform(pxbTh2PolyBarrel[currentHistoName].begin(),
pxbTh2PolyBarrel[currentHistoName].end(),
std::back_inserter(maxima),
[](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMaximum(); });
std::vector<float> minima;
std::transform(pxbTh2PolyBarrel[currentHistoName].begin(),
pxbTh2PolyBarrel[currentHistoName].end(),
std::back_inserter(minima),
[](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMinimum(); });

auto globalMax = *std::max_element(maxima.begin(), maxima.end());
auto globalMin = *std::min_element(minima.begin(), minima.end());

for (auto& histo : pxbTh2PolyBarrel[currentHistoName]) {
histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
}
}

//============================================================================
void rescaleAllForward(const std::string& currentHistoName) {
std::vector<float> maxima;
std::transform(pxfTh2PolyForward[currentHistoName].begin(),
pxfTh2PolyForward[currentHistoName].end(),
std::back_inserter(maxima),
[](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMaximum(); });
std::vector<float> minima;
std::transform(pxfTh2PolyForward[currentHistoName].begin(),
pxfTh2PolyForward[currentHistoName].end(),
std::back_inserter(minima),
[](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMinimum(); });

auto globalMax = *std::max_element(maxima.begin(), maxima.end());
auto globalMin = *std::min_element(minima.begin(), minima.end());

for (auto& histo : pxfTh2PolyForward[currentHistoName]) {
histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
}
}

//============================================================================
void DrawBarrelMaps(const std::string& currentHistoName, TCanvas& canvas) {
canvas.Divide(2, 2);
Expand All @@ -229,7 +275,8 @@ class Phase1PixelMaps {
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);
rescaleAllBarrel(currentHistoName);
SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.18);
}
pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw();
}
Expand All @@ -244,7 +291,8 @@ class Phase1PixelMaps {
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);
rescaleAllForward(currentHistoName);
SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.18);
}
pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw();
}
Expand Down
6 changes: 3 additions & 3 deletions CondCore/SiPixelPlugins/interface/PixelRegionContainers.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ namespace PixelRegions {
}

//============================================================================
void draw(TCanvas& canv, bool isBarrel, const char* option = "bar2", bool isComparison = false) {
void draw(TCanvas& canv, bool isBarrel, const char* option = "bar2", bool isPhase1Comparison = false) {
if (isBarrel) {
for (int j = 1; j <= 4; j++) {
if (!m_isLog) {
canv.cd(j);
} else {
canv.cd(j)->SetLogy();
}
if ((j == 4) && !m_isPhase1 && !isComparison) {
if ((j == 4) && !m_isPhase1 && !isPhase1Comparison) {
m_theMap.at(PixelIDs[j - 1])->Draw("AXIS");
TLatex t2;
t2.SetTextAlign(22);
Expand All @@ -228,7 +228,7 @@ namespace PixelRegions {
} else {
canv.cd(j)->SetLogy();
}
if ((j % 6 == 5 || j % 6 == 0) && !m_isPhase1 && !isComparison) {
if ((j % 6 == 5 || j % 6 == 0) && !m_isPhase1 && !isPhase1Comparison) {
m_theMap.at(PixelIDs[j + 3])->Draw("AXIS");
TLatex t2;
t2.SetTextAlign(22);
Expand Down
48 changes: 24 additions & 24 deletions CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ namespace gainCalibHelper {
auto iov = tag.iovs.front();

// parse first if log
bool setLog(false);
bool setLog(true);
auto paramValues = cond::payloadInspector::PlotBase::inputParamValues();
auto ip = paramValues.find("SetLog");
if (ip != paramValues.end()) {
Expand Down Expand Up @@ -404,7 +404,7 @@ namespace gainCalibHelper {
if (setLog) {
myPlots.setLogScale();
}
myPlots.beautify(kBlue, 10);
myPlots.beautify(kBlue, -1);
myPlots.draw(canvas, isBarrel, "HIST");

TLegend legend = TLegend(0.45, 0.88, 0.91, 0.92);
Expand All @@ -418,7 +418,7 @@ namespace gainCalibHelper {
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);
SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
legend.Draw("same");
canvas.cd(c)->Update();
}
Expand Down Expand Up @@ -453,12 +453,16 @@ namespace gainCalibHelper {
/*******************************************************************
1d histograms comparison per region of SiPixelGainCalibration for Gains of 2 IOV
********************************************************************/
template <bool isBarrel, gainCalibPI::type myType, int ntags, class PayloadType>
template <bool isBarrel,
gainCalibPI::type myType,
cond::payloadInspector::IOVMultiplicity nIOVs,
int ntags,
class PayloadType>
class SiPixelGainCalibrationValuesComparisonPerRegion
: public cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::MULTI_IOV, ntags> {
: public cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags> {
public:
SiPixelGainCalibrationValuesComparisonPerRegion()
: cond::payloadInspector::PlotImage<PayloadType, cond::payloadInspector::MULTI_IOV, ntags>(
: cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>(
Form("SiPixelGainCalibration %s Values Per Region %i tag(s)", TypeName[myType], ntags)) {
cond::payloadInspector::PlotBase::addInputParam("SetLog");

Expand Down Expand Up @@ -495,7 +499,7 @@ namespace gainCalibHelper {
}

// parse first if log
bool setLog(false);
bool setLog(true);
auto paramValues = cond::payloadInspector::PlotBase::inputParamValues();
auto ip = paramValues.find("SetLog");
if (ip != paramValues.end()) {
Expand Down Expand Up @@ -545,13 +549,15 @@ namespace gainCalibHelper {
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";
bool is_l_phase0 = (l_detids.size() == SiPixelPI::phase0size);
bool is_f_phase0 = (f_detids.size() == SiPixelPI::phase0size);

const char* path_toTopologyXML = is_l_phase0 ? "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));
auto l_myPlots = PixelRegions::PixelRegionContainers(&l_tTopo, !is_l_phase0);
l_myPlots.bookAll(
Form("Last SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
Expand All @@ -560,13 +566,12 @@ namespace gainCalibHelper {
minimum,
maximum);

path_toTopologyXML = (f_detids.size() == SiPixelPI::phase0size)
? "Geometry/TrackerCommonData/data/trackerParameters.xml"
: "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
path_toTopologyXML = is_f_phase0 ? "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));
auto f_myPlots = PixelRegions::PixelRegionContainers(&f_tTopo, !is_f_phase0);
f_myPlots.bookAll(
Form("First SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
Expand All @@ -577,8 +582,8 @@ namespace gainCalibHelper {

// 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));
auto f_wantedDets = PixelRegions::attachedDets(pixelId, &f_tTopo, !is_f_phase0);
auto l_wantedDets = PixelRegions::attachedDets(pixelId, &l_tTopo, !is_l_phase0);
gainCalibPI::fillTheHisto(first_payload, f_myPlots.getHistoFromMap(pixelId), myType, f_wantedDets);
gainCalibPI::fillTheHisto(last_payload, l_myPlots.getHistoFromMap(pixelId), myType, l_wantedDets);
}
Expand All @@ -591,8 +596,8 @@ namespace gainCalibHelper {
l_myPlots.beautify(kRed, -1);
f_myPlots.beautify(kAzure, -1);

l_myPlots.draw(canvas, isBarrel, "HIST", true);
f_myPlots.draw(canvas, isBarrel, "HISTsames", true);
l_myPlots.draw(canvas, isBarrel, "HIST", (!is_f_phase0 || !is_l_phase0));
f_myPlots.draw(canvas, isBarrel, "HISTsames", (!is_f_phase0 || !is_l_phase0));

// rescale the y-axis ranges in order to fit the canvas
l_myPlots.rescaleMax(f_myPlots);
Expand Down Expand Up @@ -857,7 +862,6 @@ namespace gainCalibHelper {
hBPix->SetFillColor(kBlue);
hBPix->SetMarkerStyle(20);
hBPix->SetMarkerSize(1);
//hBPix->Draw("bar2");
hBPix->Draw("hist");

SiPixelPI::makeNicePlotStyle(hBPix.get());
Expand All @@ -869,7 +873,6 @@ namespace gainCalibHelper {
hFPix->SetFillColor(kBlue);
hFPix->SetMarkerStyle(20);
hFPix->SetMarkerSize(1);
//hFPix->Draw("bar2");
hFPix->Draw("hist");

SiPixelPI::makeNicePlotStyle(hFPix.get());
Expand Down Expand Up @@ -1011,16 +1014,13 @@ namespace gainCalibHelper {
hfirst->GetYaxis()->SetRangeUser(1., extrema.second * 10);

hfirst->SetTitle("");
//hfirst->SetFillColor(kRed);
hfirst->SetLineColor(kRed);
hfirst->SetBarWidth(0.95);
//hfirst->Draw("histbar");
hfirst->Draw("hist");

hlast->SetTitle("");
hlast->SetFillColorAlpha(kBlue, 0.20);
hlast->SetBarWidth(0.95);
//hlast->Draw("histbarsame");
hlast->Draw("histsames");

SiPixelPI::makeNicePlotStyle(hfirst.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,14 +804,10 @@ namespace SiPixelPI {
/*--------------------------------------------------------------------*/
{
std::vector<std::pair<int, int>> rocsToMask;

//int nblade_list[2] = {11, 17};
int nybins_list[2] = {92, 140};
//int nblade = nblade_list[ring - 1];
int nybins = nybins_list[ring - 1];

int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1;
//int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2;
int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3
: ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3;

Expand Down Expand Up @@ -839,14 +835,10 @@ namespace SiPixelPI {
/*--------------------------------------------------------------------*/
{
std::vector<std::tuple<int, int, int>> rocsToMask;

//int nblade_list[2] = {11, 17};
int nybins_list[2] = {92, 140};
//int nblade = nblade_list[ring - 1];
int nybins = nybins_list[ring - 1];

int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (std::abs(disk))) * 8) + 1;
//int start_y = blade > 0 ? ((blade+nblade)*4)-panel*2 : ((nblade-(std::abs(blade)))*4)-panel*2;
int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3
: ((nybins / 2) - (std::abs(blade) * 4) - panel * 2) + 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,48 +57,56 @@ namespace {
using SiPixelGainCalibForHLTGainComparisonBarrelSingleTag =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<true,
gainCalibHelper::gainCalibPI::t_gain,
cond::payloadInspector::MULTI_IOV,
1,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTPedestalComparisonBarrelSingleTag =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<true,
gainCalibHelper::gainCalibPI::t_pedestal,
cond::payloadInspector::MULTI_IOV,
1,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTGainComparisonBarrelTwoTags =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<true,
gainCalibHelper::gainCalibPI::t_gain,
cond::payloadInspector::SINGLE_IOV,
2,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTPedestalComparisonBarrelTwoTags =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<true,
gainCalibHelper::gainCalibPI::t_pedestal,
cond::payloadInspector::SINGLE_IOV,
2,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTGainComparisonEndcapSingleTag =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<false,
gainCalibHelper::gainCalibPI::t_gain,
cond::payloadInspector::MULTI_IOV,
1,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTPedestalComparisonEndcapSingleTag =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<false,
gainCalibHelper::gainCalibPI::t_pedestal,
cond::payloadInspector::MULTI_IOV,
1,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTGainComparisonEndcapTwoTags =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<false,
gainCalibHelper::gainCalibPI::t_gain,
cond::payloadInspector::SINGLE_IOV,
2,
SiPixelGainCalibrationForHLT>;

using SiPixelGainCalibForHLTPedestalComparisonEndcapTwoTags =
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion<false,
gainCalibHelper::gainCalibPI::t_pedestal,
cond::payloadInspector::SINGLE_IOV,
2,
SiPixelGainCalibrationForHLT>;

Expand Down
Loading

0 comments on commit ea60d76

Please sign in to comment.