diff --git a/CondCore/HLTPlugins/plugins/AlCaRecoTriggerBits_PayloadInspector.cc b/CondCore/HLTPlugins/plugins/AlCaRecoTriggerBits_PayloadInspector.cc index 70096f1615be2..2a19317a2f8c1 100644 --- a/CondCore/HLTPlugins/plugins/AlCaRecoTriggerBits_PayloadInspector.cc +++ b/CondCore/HLTPlugins/plugins/AlCaRecoTriggerBits_PayloadInspector.cc @@ -3,6 +3,7 @@ #include "CondCore/CondDB/interface/Time.h" #include "CondFormats/HLTObjects/interface/AlCaRecoTriggerBits.h" +#include #include #include #include @@ -12,13 +13,14 @@ namespace { + using namespace cond::payloadInspector; + /************************************************ Display AlCaRecoTriggerBits mapping *************************************************/ - class AlCaRecoTriggerBits_Display : public cond::payloadInspector::PlotImage { + class AlCaRecoTriggerBits_Display : public PlotImage { public: - AlCaRecoTriggerBits_Display() - : cond::payloadInspector::PlotImage("Table of AlCaRecoTriggerBits") { + AlCaRecoTriggerBits_Display() : PlotImage("Table of AlCaRecoTriggerBits") { setSingleIov(true); } @@ -127,24 +129,33 @@ namespace { /************************************************ Compare AlCaRecoTriggerBits mapping *************************************************/ - class AlCaRecoTriggerBits_CompareBase : public cond::payloadInspector::PlotImage { + template + class AlCaRecoTriggerBits_CompareBase : public PlotImage { public: AlCaRecoTriggerBits_CompareBase() - : cond::payloadInspector::PlotImage("Table of AlCaRecoTriggerBits comparison") {} - - bool fill(const std::vector > &iovs) override { - std::vector > 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("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 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 last_payload = fetchPayload(std::get<1>(lastiov)); - std::shared_ptr first_payload = fetchPayload(std::get<1>(firstiov)); + 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)); @@ -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 @@ -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; + using AlCaRecoTriggerBits_CompareTwoTags = AlCaRecoTriggerBits_CompareBase; } // namespace diff --git a/CondCore/HLTPlugins/test/test.sh b/CondCore/HLTPlugins/test/test.sh index 739e1cceed0b6..e9d1d5ca299cd 100755 --- a/CondCore/HLTPlugins/test/test.sh +++ b/CondCore/HLTPlugins/test/test.sh @@ -38,4 +38,17 @@ getPayloadData.py \ --db Prod \ --test; -mv *.png $W_DIR/plots/AlCaRecoTriggerBits_Compare.png \ No newline at end of file +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