File indexing completed on 2024-09-04 04:34:52
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0012 #include "CondCore/Utilities/interface/PayloadInspector.h"
0013 #include "CondCore/CondDB/interface/Time.h"
0014
0015
0016 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0017 #include "CondCore/L1TPlugins/interface/L1TUtmTriggerMenuPayloadInspectorHelper.h"
0018
0019 #include <memory>
0020 #include <sstream>
0021 #include <iostream>
0022
0023
0024 #include "TH2F.h"
0025 #include "TLegend.h"
0026 #include "TCanvas.h"
0027 #include "TLine.h"
0028 #include "TGraph.h"
0029 #include "TStyle.h"
0030 #include "TLatex.h"
0031 #include "TPave.h"
0032 #include "TPaveStats.h"
0033
0034 namespace {
0035
0036 using namespace cond::payloadInspector;
0037
0038 class L1TUtmTriggerMenuDisplayAlgos : public PlotImage<L1TUtmTriggerMenu, SINGLE_IOV> {
0039 public:
0040 L1TUtmTriggerMenuDisplayAlgos() : PlotImage<L1TUtmTriggerMenu, SINGLE_IOV>("L1TUtmTriggerMenu plot") {}
0041
0042 bool fill() override {
0043 auto tag = PlotBase::getTag<0>();
0044 auto iov = tag.iovs.front();
0045 std::string IOVsince = std::to_string(std::get<0>(iov));
0046 auto tagname = tag.name;
0047 std::shared_ptr<L1TUtmTriggerMenu> payload = fetchPayload(std::get<1>(iov));
0048
0049 if (payload.get()) {
0050 const auto& theMap = payload->getAlgorithmMap();
0051 unsigned int mapsize = theMap.size();
0052
0053
0054 float canvasHeight = std::max(800.0f, mapsize * 30.0f);
0055 float pitch = 1.0 / (mapsize + 2.0);
0056
0057 float y = 1.0;
0058 float x1 = 0.02, x2 = x1 + 0.15;
0059 std::vector<float> y_x1, y_x2, y_line;
0060 std::vector<std::string> s_x1, s_x2;
0061
0062
0063 y -= pitch;
0064 y_x1.push_back(y);
0065 s_x1.push_back("#scale[1.2]{Algo Name}");
0066 y_x2.push_back(y);
0067 s_x2.push_back("#scale[1.2]{tag: " + tag.name + " in IOV: " + IOVsince + "}");
0068
0069 y -= pitch / 2.0;
0070 y_line.push_back(y);
0071
0072
0073 for (const auto& [name, algo] : theMap) {
0074 y -= pitch;
0075 y_x1.push_back(y);
0076 s_x1.push_back("''");
0077 y_x2.push_back(y);
0078 s_x2.push_back("#color[2]{" + name + "}");
0079 y_line.push_back(y - (pitch / 2.0));
0080 }
0081
0082
0083 TCanvas canvas("L1TriggerAlgos", "L1TriggerAlgos", 2000, static_cast<int>(canvasHeight));
0084 TLatex l;
0085 l.SetTextAlign(12);
0086
0087
0088 float textSize = std::clamp(pitch * 10.0f, 0.015f, 0.035f);
0089 l.SetTextSize(textSize);
0090
0091
0092 canvas.cd();
0093 for (unsigned int i = 0; i < y_x1.size(); i++) {
0094 l.DrawLatexNDC(x1, y_x1[i], s_x1[i].c_str());
0095 }
0096 for (unsigned int i = 0; i < y_x2.size(); i++) {
0097 l.DrawLatexNDC(x2, y_x2[i], s_x2[i].c_str());
0098 }
0099
0100
0101 TLine lines[y_line.size()];
0102 for (unsigned int i = 0; i < y_line.size(); i++) {
0103 lines[i] = TLine(gPad->GetUxmin(), y_line[i], gPad->GetUxmax(), y_line[i]);
0104 lines[i].SetLineWidth(1);
0105 lines[i].SetLineStyle(9);
0106 lines[i].SetLineColor(2);
0107 lines[i].Draw("same");
0108 }
0109
0110
0111 std::string fileName(m_imageFileName);
0112 canvas.SaveAs(fileName.c_str());
0113 }
0114 return true;
0115 }
0116 };
0117
0118 template <typename T, IOVMultiplicity nIOVs, int ntags>
0119 class L1TUtmTriggerMenu_CompareAlgosBase : public PlotImage<L1TUtmTriggerMenu, nIOVs, ntags> {
0120 public:
0121 L1TUtmTriggerMenu_CompareAlgosBase()
0122 : PlotImage<L1TUtmTriggerMenu, nIOVs, ntags>("L1TUtmTriggerMenu comparison of contents") {}
0123
0124 bool fill() override {
0125
0126 auto theIOVs = PlotBase::getTag<0>().iovs;
0127 auto f_tagname = PlotBase::getTag<0>().name;
0128 std::string l_tagname = "";
0129 auto firstiov = theIOVs.front();
0130 std::tuple<cond::Time_t, cond::Hash> lastiov;
0131
0132
0133 assert(this->m_plotAnnotations.ntags < 3);
0134
0135 if (this->m_plotAnnotations.ntags == 2) {
0136 auto tag2iovs = PlotBase::getTag<1>().iovs;
0137 l_tagname = PlotBase::getTag<1>().name;
0138 lastiov = tag2iovs.front();
0139 } else {
0140 lastiov = theIOVs.back();
0141 }
0142
0143 std::shared_ptr<L1TUtmTriggerMenu> last_payload = this->fetchPayload(std::get<1>(lastiov));
0144 std::shared_ptr<L1TUtmTriggerMenu> first_payload = this->fetchPayload(std::get<1>(firstiov));
0145
0146 std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
0147 std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
0148
0149
0150 std::string tmpTagName = l_tagname;
0151 if (tmpTagName.empty())
0152 tmpTagName = f_tagname;
0153
0154 L1TUtmTriggerMenuInspectorHelper::L1TUtmTriggerMenuDisplay<T> thePlot(
0155 last_payload.get(), tmpTagName, lastIOVsince);
0156 thePlot.setImageFileName(this->m_imageFileName);
0157 thePlot.plotDiffWithOtherMenu(first_payload.get(), f_tagname, firstIOVsince);
0158
0159 return true;
0160 }
0161 };
0162
0163 using L1TUtmTriggerMenu_CompareAlgos = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmAlgorithm, MULTI_IOV, 1>;
0164 using L1TUtmTriggerMenu_CompareAlgosTwoTags = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmAlgorithm, SINGLE_IOV, 2>;
0165
0166 using L1TUtmTriggerMenu_CompareConditions = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmCondition, MULTI_IOV, 1>;
0167 using L1TUtmTriggerMenu_CompareConditionsTwoTags = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmCondition, SINGLE_IOV, 2>;
0168
0169 }
0170
0171 PAYLOAD_INSPECTOR_MODULE(L1TUtmTriggerMenu) {
0172 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenuDisplayAlgos);
0173 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareAlgos);
0174 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareAlgosTwoTags);
0175 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareConditions);
0176 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareConditionsTwoTags);
0177 }