Skip to content

Commit

Permalink
Merge pull request #35244 from mmusich/miscellaneousPayloadInspectorF…
Browse files Browse the repository at this point in the history
…ixes

Miscellaneous graphical payload inspector fixes
  • Loading branch information
cmsbuild authored Sep 14, 2021
2 parents befbd9c + 9114727 commit 4dfcfe4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,10 @@ namespace {
final->SetMarkerSize(2.5);
t1.SetTextColor(kRed);
initial->Draw();
t1.DrawLatex(x0i, y0i - 0.5, Form("(%.2f,%.2f)", x0i, y0i));
t1.DrawLatex(x0i, y0i + (y0i > y0f ? 0.3 : -0.5), Form("(%.2f,%.2f)", x0i, y0i));
final->Draw("same");
t1.SetTextColor(kBlue);
t1.DrawLatex(x0f, y0f + 0.3, Form("(%.2f,%.2f)", x0f, y0f));
t1.DrawLatex(x0f, y0f + (y0i > y0f ? -0.5 : 0.3), Form("(%.2f,%.2f)", x0f, y0f));
}

// fourth pad is a special case for the z coordinate
Expand Down Expand Up @@ -1032,10 +1032,10 @@ namespace {
final->SetMarkerSize(2.5);
initial->Draw();
t1.SetTextColor(kRed);
t1.DrawLatex(c - 1, z0i - 1.5, Form("(%.2f)", z0i));
t1.DrawLatex(c - 1, z0i + (z0i > z0f ? 1. : -1.5), Form("(%.2f)", z0i));
final->Draw("same");
t1.SetTextColor(kBlue);
t1.DrawLatex(c - 1, z0f + 1., Form("(%.2f)", z0f));
t1.DrawLatex(c - 1, z0f + (z0i > z0f ? -1.5 : 1), Form("(%.2f)", z0f));
}

std::string fileName(this->m_imageFileName);
Expand Down
64 changes: 34 additions & 30 deletions CondCore/HLTPlugins/plugins/AlCaRecoTriggerBits_PayloadInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "CondCore/CondDB/interface/Time.h"
#include "CondFormats/HLTObjects/interface/AlCaRecoTriggerBits.h"

#include <fmt/printf.h>
#include <memory>
#include <sstream>
#include <iostream>
Expand All @@ -12,13 +13,14 @@

namespace {

using namespace cond::payloadInspector;

/************************************************
Display AlCaRecoTriggerBits mapping
*************************************************/
class AlCaRecoTriggerBits_Display : public cond::payloadInspector::PlotImage<AlCaRecoTriggerBits> {
class AlCaRecoTriggerBits_Display : public PlotImage<AlCaRecoTriggerBits> {
public:
AlCaRecoTriggerBits_Display()
: cond::payloadInspector::PlotImage<AlCaRecoTriggerBits>("Table of AlCaRecoTriggerBits") {
AlCaRecoTriggerBits_Display() : PlotImage<AlCaRecoTriggerBits>("Table of AlCaRecoTriggerBits") {
setSingleIov(true);
}

Expand Down Expand Up @@ -127,24 +129,33 @@ namespace {
/************************************************
Compare AlCaRecoTriggerBits mapping
*************************************************/
class AlCaRecoTriggerBits_CompareBase : public cond::payloadInspector::PlotImage<AlCaRecoTriggerBits> {
template <IOVMultiplicity nIOVs, int ntags>
class AlCaRecoTriggerBits_CompareBase : public PlotImage<AlCaRecoTriggerBits, nIOVs, ntags> {
public:
AlCaRecoTriggerBits_CompareBase()
: cond::payloadInspector::PlotImage<AlCaRecoTriggerBits>("Table of AlCaRecoTriggerBits comparison") {}

bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
std::vector<std::tuple<cond::Time_t, cond::Hash> > sorted_iovs = iovs;

// make absolute sure the IOVs are sortd by since
std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const &t1, auto const &t2) {
return std::get<0>(t1) < std::get<0>(t2);
});

auto firstiov = sorted_iovs.front();
auto lastiov = sorted_iovs.back();
: PlotImage<AlCaRecoTriggerBits, nIOVs, ntags>("Table of AlCaRecoTriggerBits comparison") {}

bool fill() override {
// trick to deal with the multi-ioved tag and two tag case at the same time
auto theIOVs = PlotBase::getTag<0>().iovs;
auto f_tagname = PlotBase::getTag<0>().name;
std::string l_tagname = "";
auto firstiov = theIOVs.front();
std::tuple<cond::Time_t, cond::Hash> 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 = PlotBase::getTag<1>().iovs;
l_tagname = PlotBase::getTag<1>().name;
lastiov = tag2iovs.front();
} else {
lastiov = theIOVs.back();
}

std::shared_ptr<AlCaRecoTriggerBits> last_payload = fetchPayload(std::get<1>(lastiov));
std::shared_ptr<AlCaRecoTriggerBits> first_payload = fetchPayload(std::get<1>(firstiov));
std::shared_ptr<AlCaRecoTriggerBits> last_payload = this->fetchPayload(std::get<1>(lastiov));
std::shared_ptr<AlCaRecoTriggerBits> 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));
Expand Down Expand Up @@ -195,9 +206,9 @@ namespace {
y_x1.push_back(y);
s_x1.push_back("#scale[1.2]{Key}");
y_x2.push_back(y);
s_x2.push_back("#scale[1.2]{in IOV: " + firstIOVsince + "}");
s_x2.push_back(fmt::sprintf("#scale[1.2]{%s in IOV: %s}", f_tagname, firstIOVsince));
y_x3.push_back(y);
s_x3.push_back("#scale[1.2]{in IOV: " + lastIOVsince + "}");
s_x3.push_back(fmt::sprintf("#scale[1.2]{%s in IOV: %s}", l_tagname, lastIOVsince));
y -= pitch / 3;

// print the ones missing in the last key
Expand Down Expand Up @@ -391,21 +402,14 @@ namespace {
}

//canvas.SetCanvasSize(2000,(1-y)*1000);
std::string fileName(m_imageFileName);
std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());
return true;
}
};

class AlCaRecoTriggerBits_Compare : public AlCaRecoTriggerBits_CompareBase {
public:
AlCaRecoTriggerBits_Compare() : AlCaRecoTriggerBits_CompareBase() { this->setSingleIov(false); }
};

class AlCaRecoTriggerBits_CompareTwoTags : public AlCaRecoTriggerBits_CompareBase {
public:
AlCaRecoTriggerBits_CompareTwoTags() : AlCaRecoTriggerBits_CompareBase() { this->setTwoTags(true); }
};
using AlCaRecoTriggerBits_Compare = AlCaRecoTriggerBits_CompareBase<MULTI_IOV, 1>;
using AlCaRecoTriggerBits_CompareTwoTags = AlCaRecoTriggerBits_CompareBase<SINGLE_IOV, 2>;

} // namespace

Expand Down
15 changes: 14 additions & 1 deletion CondCore/HLTPlugins/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,17 @@ getPayloadData.py \
--db Prod \
--test;

mv *.png $W_DIR/plots/AlCaRecoTriggerBits_Compare.png
mv *.png $W_DIR/plots/AlCaRecoTriggerBits_Compare.png

getPayloadData.py \
--plugin pluginAlCaRecoTriggerBits_PayloadInspector \
--plot plot_AlCaRecoTriggerBits_CompareTwoTags \
--tag AlCaRecoTriggerBits_TrackerDQM_v2_prompt \
--tagtwo AlCaRecoTriggerBits_TrackerDQM_v6_offline \
--time_type Run \
--iovs '{"start_iov": "325492", "end_iov": "325492"}' \
--iovstwo '{"start_iov": "304738", "end_iov": "304738"}' \
--db Prod \
--test;

mv *.png $W_DIR/plots/AlCaRecoTriggerBits_CompareTwoTags.png
5 changes: 4 additions & 1 deletion CondCore/SiPixelPlugins/interface/SiPixelTemplateHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ namespace templateHelper {
h2_Header->GetXaxis()->SetBinLabel(idx, "");

for (unsigned int iy = 1; iy <= 12; iy++) {
if (tempValue.head.Dtype != 0 || uH < 0) {
// Some of the Phase-2 templates have DType = 0 for all partitions (TBPX, TEPX, TFPX)
// so they are distinguished by the uH strength value (<0).
// To avoid changing the behaviour of 0T payload (uH=-99) that case is treated separately
if (tempValue.head.Dtype != 0 || (uH < 0 && uH > -99)) {
h2_ghost->SetBinContent(idx, iy, 1);
} else {
h2_ghost->SetBinContent(idx, iy, -1);
Expand Down

0 comments on commit 4dfcfe4

Please sign in to comment.