Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:28

0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004 
0005 // the data format of the condition to be inspected
0006 #include "CondFormats/EcalObjects/interface/EcalDCSTowerStatus.h"
0007 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0008 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0009 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0010 
0011 #include "TH2F.h"
0012 #include "TCanvas.h"
0013 #include "TStyle.h"
0014 #include "TLine.h"
0015 #include "TLatex.h"
0016 
0017 #include <memory>
0018 #include <sstream>
0019 
0020 namespace {
0021 
0022   /*****************************************
0023  2d plot of Ecal DCS Tower Status Errors Total of 1 IOV
0024  ******************************************/
0025   class EcalDCSTowerStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalDCSTowerStatus> {
0026   public:
0027     EcalDCSTowerStatusSummaryPlot()
0028         : cond::payloadInspector::PlotImage<EcalDCSTowerStatus>("Ecal DCS Tower Status Errors Total - map ") {
0029       setSingleIov(true);
0030     }
0031 
0032     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0033       auto iov = iovs.front();  //get reference to 1st element in the vector iovs
0034       std::shared_ptr<EcalDCSTowerStatus> payload =
0035           fetchPayload(std::get<1>(iov));   //std::get<1>(iov) refers to the Hash in the tuple iov
0036       unsigned int run = std::get<0>(iov);  //referes to Time_t in iov.
0037       TH2F* align;                          //pointer to align which is a 2D histogram
0038 
0039       int NbRows = 2;
0040       int NbColumns = 8;
0041 
0042       if (payload.get()) {  //payload is an iov retrieved from payload using hash.
0043 
0044         align = new TH2F("Ecal DCS Tower Status Errors Total",
0045                          "EB/EE    LV    LVNOMINAL    HV    HVNOMINAL    HVEED    HVEEDNOMINAL    TotalItems",
0046                          NbColumns,
0047                          0,
0048                          NbColumns,
0049                          NbRows,
0050                          0,
0051                          NbRows);
0052 
0053         float ebVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
0054         float eeVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
0055 
0056         long unsigned int ebTotal = (payload->barrelItems()).size();
0057         long unsigned int eeTotal = (payload->endcapItems()).size();
0058 
0059         getSummary(payload->barrelItems(), ebVals, ebTotal);
0060         getSummary(payload->endcapItems(), eeVals, eeTotal);
0061 
0062         double row = NbRows - 0.5;
0063 
0064         //EB summary values
0065         align->Fill(0.5, row, 1);
0066 
0067         for (int i = 0; i < 6; i++) {
0068           align->Fill(1.5 + i, row, ebVals[i]);
0069         }
0070         align->Fill(7.5, row, ebTotal);
0071 
0072         row--;
0073 
0074         align->Fill(0.5, row, 2);
0075 
0076         for (int i = 0; i < 6; i++) {
0077           align->Fill(1.5 + i, row, eeVals[i]);
0078         }
0079         align->Fill(7.5, row, eeTotal);
0080 
0081       }  // if payload.get()
0082       else
0083         return false;
0084 
0085       gStyle->SetPalette(1);
0086       gStyle->SetOptStat(0);
0087       TCanvas canvas("CC map", "CC map", 1000, 1000);
0088       TLatex t1;
0089       t1.SetNDC();
0090       t1.SetTextAlign(26);
0091       t1.SetTextSize(0.04);
0092       t1.SetTextColor(2);
0093       t1.DrawLatex(0.5, 0.96, Form("Ecal DCSTower Status Errors Total, IOV %i", run));
0094 
0095       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0096       pad->Draw();
0097       pad->cd();
0098       align->Draw("TEXT");
0099 
0100       drawTable(NbRows, NbColumns);
0101 
0102       align->GetXaxis()->SetTickLength(0.);
0103       align->GetXaxis()->SetLabelSize(0.);
0104       align->GetYaxis()->SetTickLength(0.);
0105       align->GetYaxis()->SetLabelSize(0.);
0106 
0107       std::string ImageName(m_imageFileName);
0108       canvas.SaveAs(ImageName.c_str());
0109       return true;
0110     }  // fill method
0111 
0112     void getSummary(std::vector<EcalChannelStatusCode> vItems, float vals[], long unsigned int& total) {
0113       unsigned int shift = 0, mask = 1;
0114       unsigned int statusCode;
0115 
0116       for (std::vector<EcalChannelStatusCode>::const_iterator iItems = vItems.begin(); iItems != vItems.end();
0117            ++iItems) {
0118         statusCode = iItems->getStatusCode();
0119         for (shift = 0; shift < 6; ++shift) {
0120           mask = 1 << (shift);
0121           if (statusCode & mask) {
0122             vals[shift] += 1;
0123           }
0124         }
0125       }
0126     }
0127   };
0128 
0129 }  // namespace
0130 
0131 // Register the classes as boost python plugin
0132 PAYLOAD_INSPECTOR_MODULE(EcalDCSTowerStatus) { PAYLOAD_INSPECTOR_CLASS(EcalDCSTowerStatusSummaryPlot); }