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 #include "CondCore/EcalPlugins/plugins/EcalFunctionParametersUtils.h"
0008 // the data format of the condition to be inspected
0009 #include "CondFormats/EcalObjects/interface/EcalClusterEnergyCorrectionParameters.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 #include <cmath>
0021 
0022 namespace {
0023   /*****************************************
0024  2d plot of Ecal Cluster Energy Correction Parameters of 1 IOV
0025  ******************************************/
0026   class EcalClusterEnergyCorrectionParametersPlot
0027       : public cond::payloadInspector::PlotImage<EcalClusterEnergyCorrectionParameters> {
0028   public:
0029     EcalClusterEnergyCorrectionParametersPlot()
0030         : cond::payloadInspector::PlotImage<EcalClusterEnergyCorrectionParameters>(
0031               "Ecal Cluster Energy Correction Parameters - map ") {
0032       setSingleIov(true);
0033     }
0034 
0035     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0036       auto iov = iovs.front();  //get reference to 1st element in the vector iovs
0037       std::shared_ptr<EcalClusterEnergyCorrectionParameters> payload =
0038           fetchPayload(std::get<1>(iov));   //std::get<1>(iov) refers to the Hash in the tuple iov
0039       unsigned int run = std::get<0>(iov);  //referes to Time_t in iov.
0040       TH2F* align;                          //pointer to align which is a 2D histogram
0041 
0042       int gridRows;
0043       int NbColumns;
0044 
0045       if (payload.get()) {  //payload is an iov retrieved from payload using hash.
0046         align = new TH2F("", "", 0, 0, 0, 0, 0, 0);
0047         fillFunctionParamsValues(
0048             align, (*payload).params(), "Ecal Cluster Energy Correction Parameters", gridRows, NbColumns);
0049 
0050       }  // if payload.get()
0051       else
0052         return false;
0053 
0054       gStyle->SetPalette(1);
0055       gStyle->SetOptStat(0);
0056       TCanvas canvas("CC map", "CC map", 1000, 1000);
0057       TLatex t1;
0058       t1.SetNDC();
0059       t1.SetTextAlign(26);
0060       t1.SetTextSize(0.04);
0061       t1.SetTextColor(2);
0062       t1.DrawLatex(0.5, 0.96, Form("Ecal Cluster Energy Correction Parameters, IOV %i", run));
0063 
0064       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0065       pad->Draw();
0066       pad->cd();
0067       align->Draw("TEXT");
0068 
0069       drawTable(gridRows, NbColumns);
0070 
0071       align->GetXaxis()->SetTickLength(0.);
0072       align->GetXaxis()->SetLabelSize(0.);
0073       align->GetYaxis()->SetTickLength(0.);
0074       align->GetYaxis()->SetLabelSize(0.);
0075 
0076       std::string ImageName(m_imageFileName);
0077       canvas.SaveAs(ImageName.c_str());
0078       return true;
0079     }  // fill method
0080   };
0081 
0082 }  // namespace
0083 
0084 // Register the classes as boost python plugin
0085 PAYLOAD_INSPECTOR_MODULE(EcalClusterEnergyCorrectionParameters) {
0086   PAYLOAD_INSPECTOR_CLASS(EcalClusterEnergyCorrectionParametersPlot);
0087 }