Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:36

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 // the data format of the condition to be inspected
0009 #include "CondFormats/EcalObjects/interface/EcalSRSettings.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  2d plot of Ecal SR Settings Summary of 1 IOV
0024  *******************************************************/
0025   class EcalSRSettingsSummaryPlot : public cond::payloadInspector::PlotImage<EcalSRSettings> {
0026   public:
0027     EcalSRSettingsSummaryPlot() : cond::payloadInspector::PlotImage<EcalSRSettings>("Ecal SR Settings Summary - map ") {
0028       setSingleIov(true);
0029     }
0030 
0031     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0032       const int maxInCol = 27;
0033 
0034       auto iov = iovs.front();
0035       std::shared_ptr<EcalSRSettings> payload = fetchPayload(std::get<1>(iov));
0036       unsigned int run = std::get<0>(iov);
0037 
0038       TH2F* align;
0039 
0040       int NbRows, gridRows;
0041       int NbColumns, offset;
0042 
0043       if (payload.get()) {
0044         EcalSRSettings ecalSR = (*payload);
0045 
0046         NbRows = ecalSR.srpLowInterestChannelZS_.size();
0047 
0048         gridRows = (NbRows <= maxInCol) ? NbRows : maxInCol;
0049         offset = ceil(1.0 * NbRows / maxInCol);
0050         NbColumns = offset * 2 + 3;
0051 
0052         align =
0053             new TH2F("Ecal SR Settings Summary",
0054                      "ebDccAdcToGeV    eeDccAdcToGeV    Rows#    srpLowInterestChannelZS    srpHighInterestChannelZS",
0055                      NbColumns,
0056                      0,
0057                      NbColumns,
0058                      gridRows,
0059                      0,
0060                      gridRows);
0061 
0062         double row = gridRows - 0.5;
0063         double column = 3.5;
0064         int cnt = 0;
0065 
0066         align->Fill(0.5, gridRows - 0.5, ecalSR.ebDccAdcToGeV_);
0067         align->Fill(1.5, gridRows - 0.5, ecalSR.eeDccAdcToGeV_);
0068 
0069         for (int i = 0; i < gridRows; i++) {
0070           align->Fill(2.5, gridRows - i - 0.5, i + 1);
0071         }
0072 
0073         for (std::vector<float>::const_iterator it = ecalSR.srpLowInterestChannelZS_.begin();
0074              it != ecalSR.srpLowInterestChannelZS_.end();
0075              it++) {
0076           align->Fill(column, row, *it);
0077 
0078           cnt++;
0079           column = floor(1.0 * cnt / maxInCol) + 3.5;
0080           row = (row == 0.5 ? (gridRows - 0.5) : row - 1);
0081         }
0082 
0083         row = gridRows - 0.5;
0084         column = 3.5;
0085         cnt = 0;
0086 
0087         for (std::vector<float>::const_iterator it = ecalSR.srpHighInterestChannelZS_.begin();
0088              it != ecalSR.srpHighInterestChannelZS_.end();
0089              it++) {
0090           align->Fill(column + offset, row, *it);
0091 
0092           cnt++;
0093           column = floor(1.0 * cnt / maxInCol) + 3.5;
0094           row = (row == 0.5 ? (gridRows - 0.5) : row - 1);
0095         }
0096 
0097       } else
0098         return false;
0099 
0100       gStyle->SetPalette(1);
0101       gStyle->SetOptStat(0);
0102       TCanvas canvas("CC map", "CC map", 1000, 1000);
0103       TLatex t1;
0104       t1.SetNDC();
0105       t1.SetTextAlign(26);
0106       t1.SetTextSize(0.05);
0107       t1.SetTextColor(2);
0108       t1.DrawLatex(0.5, 0.96, Form("Ecal SRSettings Summary, IOV %i", run));
0109 
0110       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0111       pad->Draw();
0112       pad->cd();
0113       align->Draw("TEXT");
0114 
0115       drawTable(NbRows, NbColumns);
0116 
0117       align->GetXaxis()->SetTickLength(0.);
0118       align->GetXaxis()->SetLabelSize(0.);
0119       align->GetYaxis()->SetTickLength(0.);
0120       align->GetYaxis()->SetLabelSize(0.);
0121 
0122       std::string ImageName(m_imageFileName);
0123       canvas.SaveAs(ImageName.c_str());
0124 
0125       return true;
0126     }
0127   };
0128 
0129 }  // namespace
0130 
0131 // Register the classes as boost python plugin
0132 PAYLOAD_INSPECTOR_MODULE(EcalSRSettings) { PAYLOAD_INSPECTOR_CLASS(EcalSRSettingsSummaryPlot); }