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