Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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/EcalWeightSet.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 Weight Set of 1 IOV
0025  *******************************************************/
0026   class EcalWeightSetPlot : public cond::payloadInspector::PlotImage<EcalWeightSet> {
0027   public:
0028     EcalWeightSetPlot() : cond::payloadInspector::PlotImage<EcalWeightSet>("Ecal Weight Set - 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();
0034       std::shared_ptr<EcalWeightSet> payload = fetchPayload(std::get<1>(iov));
0035       unsigned int run = std::get<0>(iov);
0036       TH2F* align;
0037       int NbRows;
0038 
0039       if (payload.get()) {
0040         NbRows = 3;
0041         align = new TH2F("Ecal Weight Set", "WeightsBeforeGainSwitch", 10, 0, 10, NbRows, 0, NbRows);
0042 
0043         EcalWeightSet::EcalWeightMatrix mat = (*payload).getWeightsBeforeGainSwitch();
0044 
0045         double rr = 9.5, cc = 0.5;
0046         //x = *(m.**begin**()+7);
0047         for (EcalWeightSet::EcalWeightMatrix::const_iterator it = mat.begin(); it != mat.end(); it++) {
0048           align->Fill(cc, rr, *(it));
0049 
0050           cc++;
0051           if (cc == 10.5) {
0052             cc = 0.5;
0053             rr--;
0054           }
0055         }
0056 
0057       } else
0058         return false;
0059 
0060       gStyle->SetPalette(1);
0061       gStyle->SetOptStat(0);
0062       TCanvas canvas("CC map", "CC map", 1000, 1000);
0063       TLatex t1;
0064       t1.SetNDC();
0065       t1.SetTextAlign(26);
0066       t1.SetTextSize(0.05);
0067       t1.SetTextColor(2);
0068       t1.DrawLatex(0.5, 0.96, Form("Ecal Weight Set, IOV %i", run));
0069 
0070       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0071       pad->Draw();
0072       pad->cd();
0073       align->Draw("TEXT");
0074 
0075       drawTable(NbRows, 10);
0076 
0077       align->GetXaxis()->SetTickLength(0.);
0078       align->GetXaxis()->SetLabelSize(0.);
0079       align->GetYaxis()->SetTickLength(0.);
0080       align->GetYaxis()->SetLabelSize(0.);
0081 
0082       std::string ImageName(m_imageFileName);
0083       canvas.SaveAs(ImageName.c_str());
0084 
0085       return true;
0086     }
0087   };
0088 
0089 }  // namespace
0090 
0091 // Register the classes as boost python plugin
0092 PAYLOAD_INSPECTOR_MODULE(EcalWeightSet) { PAYLOAD_INSPECTOR_CLASS(EcalWeightSetPlot); }