File indexing completed on 2024-09-07 04:35:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0010 #include "CondCore/Utilities/interface/PayloadInspector.h"
0011 #include "CondCore/CondDB/interface/Time.h"
0012
0013
0014 #include "CondFormats/SiStripObjects/interface/SiStripConfObject.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0017 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019
0020
0021 #include "CondCore/SiStripPlugins/interface/SiStripPayloadInspectorHelper.h"
0022
0023 #include <memory>
0024 #include <sstream>
0025 #include <iostream>
0026 #include <regex>
0027
0028
0029 #include "TH2F.h"
0030 #include "TF1.h"
0031 #include "TLegend.h"
0032 #include "TCanvas.h"
0033 #include "TLine.h"
0034 #include "TStyle.h"
0035 #include "TLatex.h"
0036
0037 namespace {
0038
0039 using namespace cond::payloadInspector;
0040
0041
0042 class SiStripConfObjectTest : public Histogram1D<SiStripConfObject, SINGLE_IOV> {
0043 public:
0044 SiStripConfObjectTest()
0045 : Histogram1D<SiStripConfObject, SINGLE_IOV>(
0046 "SiStrip Configuration Object test", "SiStrip Configuration Object test", 1, 0.0, 1.0) {}
0047
0048 bool fill() override {
0049 auto tag = PlotBase::getTag<0>();
0050 for (auto const& iov : tag.iovs) {
0051 std::shared_ptr<SiStripConfObject> payload = Base::fetchPayload(std::get<1>(iov));
0052 if (payload.get()) {
0053 fillWithValue(1.);
0054
0055 std::stringstream ss;
0056 ss << "Summary of strips configuration object:" << std::endl;
0057
0058 SiStripConfObject::parMap::const_iterator it = payload->parameters.begin();
0059 for (; it != payload->parameters.end(); ++it) {
0060 ss << "parameter name = " << it->first << " value = " << it->second << std::endl;
0061 }
0062
0063 std::cout << ss.str() << std::endl;
0064
0065 }
0066 }
0067 return true;
0068 }
0069 };
0070
0071
0072 class SiStripConfObjectDisplay : public PlotImage<SiStripConfObject, SINGLE_IOV> {
0073 public:
0074 SiStripConfObjectDisplay() : PlotImage<SiStripConfObject, SINGLE_IOV>("Display Configuration Values") {}
0075
0076 bool fill() override {
0077 auto tag = PlotBase::getTag<0>();
0078 auto iov = tag.iovs.front();
0079 std::shared_ptr<SiStripConfObject> payload = fetchPayload(std::get<1>(iov));
0080
0081 unsigned int run = std::get<0>(iov);
0082 std::vector<float> y_line;
0083
0084 TLatex t1;
0085 t1.SetNDC();
0086 t1.SetTextAlign(26);
0087 t1.SetTextSize(0.045);
0088 t1.SetTextColor(2);
0089
0090 TLatex latex;
0091 latex.SetNDC();
0092 latex.SetTextSize(0.035);
0093
0094 unsigned int configsize_ = payload->parameters.size();
0095 TLine lines[configsize_ + 1];
0096
0097 auto h_Config = std::make_unique<TH1F>("ConfigParamter", ";;configuration value", configsize_, 0., configsize_);
0098 h_Config->SetStats(false);
0099
0100 bool isShiftAndXTalk = payload->isParameter("shift_IB1Deco");
0101
0102
0103 int c_width = isShiftAndXTalk ? 2000 : 1000;
0104 int c_height = isShiftAndXTalk ? 1000 : 800;
0105
0106 TCanvas canvas("Configuration Summary", "Configuration Summary", c_width, c_height);
0107 canvas.cd();
0108
0109
0110 if (!isShiftAndXTalk) {
0111 t1.DrawLatex(0.5, 0.96, Form("SiStrip ConfObject, IOV %i", run));
0112 latex.DrawLatex(0.1, 0.92, "Parameter");
0113 latex.DrawLatex(0.6, 0.92, "Value");
0114 y_line.push_back(0.92);
0115 latex.SetTextFont(42);
0116 latex.SetTextColor(kBlack);
0117
0118 SiStripConfObject::parMap::const_iterator it = payload->parameters.begin();
0119 unsigned int count = 0;
0120 for (; it != payload->parameters.end(); ++it) {
0121 count++;
0122 float y_loc = 0.92 - (0.90 / configsize_) * count;
0123 latex.SetTextSize(std::min(0.035, 0.95 / configsize_));
0124 latex.DrawLatex(0.1, y_loc, (it->first).c_str());
0125 latex.DrawLatex(0.6, y_loc, (it->second).c_str());
0126 y_line.push_back(y_loc);
0127 }
0128
0129 unsigned int iL = 0;
0130 for (const auto& line : y_line) {
0131 lines[iL] = TLine(gPad->GetUxmin(), line, gPad->GetUxmax(), line);
0132 lines[iL].SetLineWidth(1);
0133 lines[iL].SetLineStyle(9);
0134 lines[iL].SetLineColor(2);
0135 lines[iL].Draw("same");
0136 iL++;
0137 }
0138
0139 }
0140
0141 else {
0142 canvas.SetBottomMargin(0.16);
0143 canvas.SetLeftMargin(0.08);
0144 canvas.SetRightMargin(0.02);
0145 canvas.SetTopMargin(0.05);
0146 canvas.Modified();
0147
0148 SiStripConfObject::parMap::const_iterator it = payload->parameters.begin();
0149
0150 unsigned int count = 0;
0151 for (; it != payload->parameters.end(); ++it) {
0152 count++;
0153
0154 h_Config->SetBinContent(count, std::stof(it->second));
0155 h_Config->GetXaxis()->SetBinLabel(count, (std::regex_replace(it->first, std::regex("_"), " ")).c_str());
0156 }
0157
0158 SiStripPI::makeNicePlotStyle(h_Config.get());
0159 h_Config->GetYaxis()->SetTitleOffset(0.8);
0160 h_Config->GetXaxis()->SetLabelSize(0.03);
0161 h_Config->SetMaximum(h_Config->GetMaximum() * 1.20);
0162 h_Config->SetFillColorAlpha(kRed, 0.35);
0163 h_Config->Draw();
0164 h_Config->Draw("textsame");
0165
0166 t1.DrawLatex(0.5, 0.96, Form("SiStrip ConfObject, IOV %i: Payload %s", run, (std::get<1>(iov)).c_str()));
0167 }
0168
0169 std::string fileName(m_imageFileName);
0170 canvas.SaveAs(fileName.c_str());
0171
0172 return true;
0173 }
0174 };
0175
0176 }
0177
0178 PAYLOAD_INSPECTOR_MODULE(SiStripConfObject) {
0179 PAYLOAD_INSPECTOR_CLASS(SiStripConfObjectTest);
0180 PAYLOAD_INSPECTOR_CLASS(SiStripConfObjectDisplay);
0181 }