File indexing completed on 2024-04-06 12:01:37
0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0005 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0006 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0007
0008
0009 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
0010
0011 #include "TH2F.h" // a 2-D histogram with four bytes per cell (float)
0012 #include "TCanvas.h"
0013 #include "TLine.h"
0014 #include "TStyle.h"
0015 #include "TLatex.h" //write mathematical equations.
0016 #include "TPave.h"
0017 #include "TPaveStats.h"
0018 #include <string>
0019 #include <fstream>
0020
0021 namespace {
0022
0023
0024
0025 class EcalTPGLutIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGLutIdMap> {
0026 public:
0027 EcalTPGLutIdMapPlot() : cond::payloadInspector::PlotImage<EcalTPGLutIdMap>("Ecal TPG LutId Map - map ") {
0028 setSingleIov(true);
0029 }
0030
0031 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0032 auto iov = iovs.front();
0033 std::shared_ptr<EcalTPGLutIdMap> payload = fetchPayload(std::get<1>(iov));
0034 unsigned int run = std::get<0>(iov);
0035 TH2F* align;
0036 int NbRows;
0037
0038 if (payload.get()) {
0039 EcalTPGLutIdMap::EcalTPGLutMap map = (*payload).getMap();
0040 NbRows = 30;
0041
0042 align = new TH2F("Ecal TPG LutId Map",
0043 "EB LutEcalTPGLut EE "
0044 " LutEcalTPGLut",
0045 4,
0046 0,
0047 4,
0048 NbRows,
0049 0,
0050 NbRows);
0051
0052 double row = NbRows - 0.5;
0053 int columnBase = 0;
0054 for (EcalTPGLutIdMap::EcalTPGLutMapItr it = map.begin(); it != map.end(); it++) {
0055 EcalTPGLut ecaltpgLut = it->second;
0056 uint32_t mapKey = it->first;
0057
0058 const unsigned int* lut = (ecaltpgLut.getLut());
0059
0060 for (int i = 0; i < 30; i++) {
0061 if (i == (NbRows / 2 - 1))
0062 align->Fill(0.5 + columnBase, row, mapKey + 1);
0063
0064 align->Fill(1.5 + columnBase, row, *(lut + i));
0065 row = row - 1.;
0066 }
0067
0068 columnBase += 2;
0069 row = NbRows - 0.5;
0070 }
0071
0072 } else
0073 return false;
0074
0075 gStyle->SetPalette(1);
0076 gStyle->SetOptStat(0);
0077 TCanvas canvas("CC map", "CC map", 1000, 1000);
0078 TLatex t1;
0079 t1.SetNDC();
0080 t1.SetTextAlign(26);
0081 t1.SetTextSize(0.05);
0082 t1.SetTextColor(2);
0083 t1.DrawLatex(0.5, 0.96, Form("ECAL TPG LutId Map, IOV %i", run));
0084
0085 TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0086 pad->Draw();
0087 pad->cd();
0088 align->Draw("TEXT");
0089 TLine* l = new TLine;
0090 l->SetLineWidth(1);
0091 for (int i = 1; i < NbRows; i++) {
0092 double y = (double)i;
0093 l = new TLine(1., y, 2., y);
0094 l->Draw();
0095 }
0096
0097 for (int i = 1; i < NbRows; i++) {
0098 double y = (double)i;
0099 l = new TLine(3., y, 4., y);
0100 l->Draw();
0101 }
0102
0103 for (int i = 1; i < 4; i++) {
0104 double x = (double)i;
0105 double y = (double)NbRows;
0106 l = new TLine(x, 0., x, y);
0107 l->Draw();
0108 }
0109
0110 align->GetXaxis()->SetTickLength(0.);
0111 align->GetXaxis()->SetLabelSize(0.);
0112 align->GetYaxis()->SetTickLength(0.);
0113 align->GetYaxis()->SetLabelSize(0.);
0114
0115 std::string ImageName(m_imageFileName);
0116 canvas.SaveAs(ImageName.c_str());
0117
0118 return true;
0119 }
0120 };
0121
0122 }
0123
0124 PAYLOAD_INSPECTOR_MODULE(EcalTPGLutIdMap) { PAYLOAD_INSPECTOR_CLASS(EcalTPGLutIdMapPlot); }