Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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/EcalDAQTowerStatus.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 DAQ Tower Status Summary of 1 IOV
0024  ******************************************/
0025   class EcalDAQTowerStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalDAQTowerStatus> {
0026   public:
0027     EcalDAQTowerStatusSummaryPlot()
0028         : cond::payloadInspector::PlotImage<EcalDAQTowerStatus>("Ecal DAQ Tower Status Summary - 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<EcalDAQTowerStatus> 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 = 3;
0041 
0042       if (payload.get()) {  //payload is an iov retrieved from payload using hash.
0043 
0044         align = new TH2F("Ecal DAQ Tower Status Summary",
0045                          "EB/EE      bit 0 -> towers excluded from the DAQ",
0046                          NbColumns,
0047                          0,
0048                          NbColumns,
0049                          NbRows,
0050                          0,
0051                          NbRows);
0052 
0053         float ebVals = 0.0f;
0054         float eeVals = 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         align->Fill(1.5, row, ebVals);
0067         align->Fill(2.5, row, ebTotal);
0068 
0069         row--;
0070 
0071         align->Fill(0.5, row, 2);
0072         align->Fill(1.5, row, eeVals);
0073         align->Fill(2.5, row, eeTotal);
0074 
0075       }  // if payload.get()
0076       else
0077         return false;
0078 
0079       gStyle->SetPalette(1);
0080       gStyle->SetOptStat(0);
0081       TCanvas canvas("CC map", "CC map", 1000, 1000);
0082       TLatex t1;
0083       t1.SetNDC();
0084       t1.SetTextAlign(26);
0085       t1.SetTextSize(0.05);
0086       t1.SetTextColor(2);
0087       t1.DrawLatex(0.5, 0.96, Form("Ecal DAQTower Status Summary, IOV %i", run));
0088 
0089       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0090       pad->Draw();
0091       pad->cd();
0092       align->Draw("TEXT");
0093 
0094       drawTable(NbRows, NbColumns);
0095 
0096       align->GetXaxis()->SetTickLength(0.);
0097       align->GetXaxis()->SetLabelSize(0.);
0098       align->GetYaxis()->SetTickLength(0.);
0099       align->GetYaxis()->SetLabelSize(0.);
0100 
0101       std::string ImageName(m_imageFileName);
0102       canvas.SaveAs(ImageName.c_str());
0103       return true;
0104     }  // fill method
0105 
0106     void getSummary(std::vector<EcalDAQStatusCode> vItems, float& vals, long unsigned int& total) {
0107       for (std::vector<EcalDAQStatusCode>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems) {
0108         if (iItems->getStatusCode() > 0)
0109           vals++;
0110       }
0111     }
0112   };
0113 
0114 }  // namespace
0115 
0116 // Register the classes as boost python plugin
0117 PAYLOAD_INSPECTOR_MODULE(EcalDAQTowerStatus) { PAYLOAD_INSPECTOR_CLASS(EcalDAQTowerStatusSummaryPlot); }