Skip to content

Commit

Permalink
improve AlCaRecoTriggerBits_PayloadInspector and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Sep 10, 2021
1 parent 78c24e2 commit 9114727
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 31 deletions.
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

0 comments on commit 9114727

Please sign in to comment.