Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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/EcalTBWeights.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 TBWeights of 1 IOV
0025  *******************************************************/
0026   class EcalTBWeightsPlot : public cond::payloadInspector::PlotImage<EcalTBWeights> {
0027   public:
0028     EcalTBWeightsPlot() : cond::payloadInspector::PlotImage<EcalTBWeights>("Ecal TBWeights - 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<EcalTBWeights> 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         EcalTBWeights::EcalTBWeightMap map = (*payload).getMap();
0041         NbRows = map.size();
0042         align = new TH2F("Ecal PTM Temperatures",
0043                          "EcalXtalGroupId          EcalTDCId          EcalWeightSet",
0044                          3,
0045                          0,
0046                          3,
0047                          NbRows,
0048                          0,
0049                          NbRows);
0050 
0051         double row = NbRows - 0.5;
0052 
0053         for (EcalTBWeights::EcalPTMTemperatureMap::const_iterator it = map.begin(); it != map.end(); it++) {
0054           //uint32_t mapKey=it->first;
0055           //float val=it->second;
0056 
0057           //align->Fill(0.5,row,mapKey);
0058           //align->Fill(1.5,row,val);
0059 
0060           row--;
0061         }
0062 
0063       } else
0064         return false;
0065 
0066       gStyle->SetPalette(1);
0067       gStyle->SetOptStat(0);
0068       TCanvas canvas("CC map", "CC map", 1000, 1000);
0069       TLatex t1;
0070       t1.SetNDC();
0071       t1.SetTextAlign(26);
0072       t1.SetTextSize(0.05);
0073       t1.SetTextColor(2);
0074       t1.DrawLatex(0.5, 0.96, Form("Ecal TBWeights, IOV %i", run));
0075 
0076       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0077       pad->Draw();
0078       pad->cd();
0079       align->Draw("TEXT");
0080       TLine* l = new TLine;
0081       l->SetLineWidth(1);
0082 
0083       for (int i = 1; i < NbRows; i++) {
0084         double y = (double)i;
0085         l = new TLine(0., y, 3., y);
0086         l->Draw();
0087       }
0088 
0089       for (int i = 1; i < 3; i++) {
0090         double x = (double)i;
0091         double y = (double)NbRows;
0092         l = new TLine(x, 0., x, y);
0093         l->Draw();
0094       }
0095 
0096       align->GetXaxis()->SetTickLength(0.);
0097       align->GetXaxis()->SetLabelSize(0.);
0098       align->GetYaxis()->SetTickLength(0.);
0099       align->GetYaxis()->SetLabelSize(0.);
0100 
0101       std::string ImageName(m_imageFileName);
0102       canvas.SaveAs(ImageName.c_str());
0103 
0104       return true;
0105     }
0106   };
0107 
0108 }  // namespace
0109 
0110 // Register the classes as boost python plugin
0111 PAYLOAD_INSPECTOR_MODULE(EcalTBWeights) { PAYLOAD_INSPECTOR_CLASS(EcalTBWeightsPlot); }