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 #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/EcalADCToGeVConstant.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  2d plot of Ecal ADC To GeV Constant of 1 IOV
0025  *******************************************************/
0026   class EcalADCToGeVConstantPlot : public cond::payloadInspector::PlotImage<EcalADCToGeVConstant> {
0027   public:
0028     EcalADCToGeVConstantPlot()
0029         : cond::payloadInspector::PlotImage<EcalADCToGeVConstant>("ECAL ADC To GeV Constant - map ") {
0030       setSingleIov(true);
0031     }
0032 
0033     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0034       auto iov = iovs.front();
0035       std::shared_ptr<EcalADCToGeVConstant> payload = fetchPayload(std::get<1>(iov));
0036       unsigned int run = std::get<0>(iov);
0037       TH2F* align;
0038       int NbRows;
0039 
0040       if (payload.get()) {
0041         NbRows = 1;
0042         align = new TH2F("ADC To GeV [GeV/ADC count]", "EB          EE", 2, 0, 2, NbRows, 0, NbRows);
0043         EcalADCToGeVConstant it = (*payload);
0044 
0045         double row = NbRows - 0.5;
0046 
0047         align->Fill(0.5, row, it.getEBValue());
0048         align->Fill(1.5, row, it.getEEValue());
0049       } else
0050         return false;
0051 
0052       gStyle->SetPalette(1);
0053       gStyle->SetOptStat(0);
0054       TCanvas canvas("CC map", "CC map", 1000, 1000);
0055       TLatex t1;
0056       t1.SetNDC();
0057       t1.SetTextAlign(26);
0058       t1.SetTextSize(0.05);
0059       t1.SetTextColor(2);
0060       t1.DrawLatex(0.5, 0.96, Form("Ecal ADC To GeV, IOV %i", run));
0061 
0062       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0063       pad->Draw();
0064       pad->cd();
0065       align->Draw("TEXT");
0066 
0067       drawTable(NbRows, 2);
0068 
0069       align->GetXaxis()->SetTickLength(0.);
0070       align->GetXaxis()->SetLabelSize(0.);
0071       align->GetYaxis()->SetTickLength(0.);
0072       align->GetYaxis()->SetLabelSize(0.);
0073 
0074       std::string ImageName(m_imageFileName);
0075       canvas.SaveAs(ImageName.c_str());
0076 
0077       return true;
0078     }
0079   };
0080 
0081 }  // namespace
0082 
0083 // Register the classes as boost python plugin
0084 PAYLOAD_INSPECTOR_MODULE(EcalADCToGeVConstant) { PAYLOAD_INSPECTOR_CLASS(EcalADCToGeVConstantPlot); }