Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:08

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/EcalTPGWeightIdMap.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 TPG Weight Id Map of 1 IOV
0024  ******************************************/
0025   class EcalTPGWeightIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGWeightIdMap> {
0026   public:
0027     EcalTPGWeightIdMapPlot() : cond::payloadInspector::PlotImage<EcalTPGWeightIdMap>("Ecal TPG Weight Id Map - map ") {
0028       setSingleIov(true);
0029     }
0030 
0031     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0032       auto iov = iovs.front();
0033       std::shared_ptr<EcalTPGWeightIdMap> payload = fetchPayload(std::get<1>(iov));
0034       unsigned int run = std::get<0>(iov);
0035       TH2F* align;
0036       int NbRows;
0037 
0038       if (payload.get()) {
0039         EcalTPGWeightIdMap::EcalTPGWeightMap map = (*payload).getMap();
0040         NbRows = map.size();
0041 
0042         align = new TH2F("Ecal TPG Weight Id Map",
0043                          "MapKey          w0                     w1                     w2                       w3    "
0044                          "                   w4",
0045                          6,
0046                          0,
0047                          6,
0048                          NbRows,
0049                          0,
0050                          NbRows);
0051 
0052         double row = NbRows - 0.5;
0053         for (EcalTPGWeightIdMap::EcalTPGWeightMapItr it = map.begin(); it != map.end(); it++) {
0054           uint32_t mapKey = it->first;
0055           EcalTPGWeights item = it->second;
0056           uint32_t w0, w1, w2, w3, w4;
0057           item.getValues(w0, w1, w2, w3, w4);
0058 
0059           align->Fill(0.5, row, mapKey + 1);
0060           align->Fill(1.5, row, w0);
0061           align->Fill(2.5, row, w1);
0062           align->Fill(3.5, row, w2);
0063           align->Fill(4.5, row, w3);
0064           align->Fill(5.5, row, w4);
0065 
0066           row = row - 1.;
0067         }  //loop over EcalTPGWeightIdMap rows
0068 
0069       } else
0070         return false;
0071 
0072       gStyle->SetPalette(1);
0073       gStyle->SetOptStat(0);
0074       TCanvas canvas("CC map", "CC map", 1000, 1000);
0075       TLatex t1;
0076       t1.SetNDC();
0077       t1.SetTextAlign(26);
0078       t1.SetTextSize(0.05);
0079       t1.SetTextColor(2);
0080       t1.DrawLatex(0.5, 0.96, Form("Ecal TPG Weight Id Map, IOV %i", run));
0081 
0082       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0083       pad->Draw();
0084       pad->cd();
0085       align->Draw("TEXT");
0086 
0087       drawTable(NbRows, 6);
0088 
0089       align->GetXaxis()->SetTickLength(0.);
0090       align->GetXaxis()->SetLabelSize(0.);
0091       align->GetYaxis()->SetTickLength(0.);
0092       align->GetYaxis()->SetLabelSize(0.);
0093 
0094       std::string ImageName(m_imageFileName);
0095       canvas.SaveAs(ImageName.c_str());
0096 
0097       return true;
0098     }
0099   };
0100 
0101 }  // namespace
0102 // Register the classes as boost python plugin
0103 PAYLOAD_INSPECTOR_MODULE(EcalTPGWeightIdMap) { PAYLOAD_INSPECTOR_CLASS(EcalTPGWeightIdMapPlot); }