File indexing completed on 2024-04-06 12:01:42
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 if (payload.get()) {
0049
0050 const auto& theMap = payload->getAlgorithmMap();
0051
0052 unsigned int mapsize = theMap.size();
0053 float pitch = 1. / (mapsize);
0054
0055 float y, x1, x2;
0056 std::vector<float> y_x1, y_x2, y_line;
0057 std::vector<std::string> s_x1, s_x2, s_x3;
0058
0059
0060
0061 y = 1.0;
0062 x1 = 0.02;
0063 x2 = x1 + 0.15;
0064
0065 y -= pitch;
0066 y_x1.push_back(y);
0067 s_x1.push_back("#scale[1.2]{Algo Name}");
0068 y_x2.push_back(y);
0069 s_x2.push_back("#scale[1.2]{tag: " + tag.name + " in IOV: " + IOVsince + "}");
0070
0071 y -= pitch / 2.;
0072 y_line.push_back(y);
0073
0074 for (const auto& [name, algo] : theMap) {
0075 y -= pitch;
0076 y_x1.push_back(y);
0077 s_x1.push_back("''");
0078
0079 y_x2.push_back(y);
0080 s_x2.push_back("#color[2]{" + name + "}");
0081 y_line.push_back(y - (pitch / 2.));
0082 }
0083
0084 TCanvas canvas("L1TriggerAlgos", "L1TriggerAlgos", 2000, mapsize * 40);
0085 TLatex l;
0086
0087 l.SetTextAlign(12);
0088 l.SetTextSize(pitch * 10);
0089 canvas.cd();
0090 for (unsigned int i = 0; i < y_x1.size(); i++) {
0091 l.DrawLatexNDC(x1, 1 - (1 - y_x1[i]), s_x1[i].c_str());
0092 }
0093
0094 for (unsigned int i = 0; i < y_x2.size(); i++) {
0095 l.DrawLatexNDC(x2, 1 - (1 - y_x2[i]), s_x2[i].c_str());
0096 }
0097
0098 canvas.cd();
0099 canvas.Update();
0100
0101 TLine lines[y_line.size()];
0102 unsigned int iL = 0;
0103 for (const auto& line : y_line) {
0104 lines[iL] = TLine(gPad->GetUxmin(), 1 - (1 - line), gPad->GetUxmax(), 1 - (1 - line));
0105 lines[iL].SetLineWidth(1);
0106 lines[iL].SetLineStyle(9);
0107 lines[iL].SetLineColor(2);
0108 lines[iL].Draw("same");
0109 iL++;
0110 }
0111
0112 std::string fileName(m_imageFileName);
0113 canvas.SaveAs(fileName.c_str());
0114 }
0115 return true;
0116 }
0117 };
0118
0119 template <typename T, IOVMultiplicity nIOVs, int ntags>
0120 class L1TUtmTriggerMenu_CompareAlgosBase : public PlotImage<L1TUtmTriggerMenu, nIOVs, ntags> {
0121 public:
0122 L1TUtmTriggerMenu_CompareAlgosBase()
0123 : PlotImage<L1TUtmTriggerMenu, nIOVs, ntags>("L1TUtmTriggerMenu comparison of contents") {}
0124
0125 bool fill() override {
0126
0127 auto theIOVs = PlotBase::getTag<0>().iovs;
0128 auto f_tagname = PlotBase::getTag<0>().name;
0129 std::string l_tagname = "";
0130 auto firstiov = theIOVs.front();
0131 std::tuple<cond::Time_t, cond::Hash> lastiov;
0132
0133
0134 assert(this->m_plotAnnotations.ntags < 3);
0135
0136 if (this->m_plotAnnotations.ntags == 2) {
0137 auto tag2iovs = PlotBase::getTag<1>().iovs;
0138 l_tagname = PlotBase::getTag<1>().name;
0139 lastiov = tag2iovs.front();
0140 } else {
0141 lastiov = theIOVs.back();
0142 }
0143
0144 std::shared_ptr<L1TUtmTriggerMenu> last_payload = this->fetchPayload(std::get<1>(lastiov));
0145 std::shared_ptr<L1TUtmTriggerMenu> first_payload = this->fetchPayload(std::get<1>(firstiov));
0146
0147 std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
0148 std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
0149
0150
0151 std::string tmpTagName = l_tagname;
0152 if (tmpTagName.empty())
0153 tmpTagName = f_tagname;
0154
0155 L1TUtmTriggerMenuInspectorHelper::L1TUtmTriggerMenuDisplay<T> thePlot(
0156 last_payload.get(), tmpTagName, lastIOVsince);
0157 thePlot.setImageFileName(this->m_imageFileName);
0158 thePlot.plotDiffWithOtherMenu(first_payload.get(), f_tagname, firstIOVsince);
0159
0160 return true;
0161 }
0162 };
0163
0164 using L1TUtmTriggerMenu_CompareAlgos = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmAlgorithm, MULTI_IOV, 1>;
0165 using L1TUtmTriggerMenu_CompareAlgosTwoTags = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmAlgorithm, SINGLE_IOV, 2>;
0166
0167 using L1TUtmTriggerMenu_CompareConditions = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmCondition, MULTI_IOV, 1>;
0168 using L1TUtmTriggerMenu_CompareConditionsTwoTags = L1TUtmTriggerMenu_CompareAlgosBase<L1TUtmCondition, SINGLE_IOV, 2>;
0169
0170 }
0171
0172 PAYLOAD_INSPECTOR_MODULE(L1TUtmTriggerMenu) {
0173 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenuDisplayAlgos);
0174 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareAlgos);
0175 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareAlgosTwoTags);
0176 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareConditions);
0177 PAYLOAD_INSPECTOR_CLASS(L1TUtmTriggerMenu_CompareConditionsTwoTags);
0178 }