Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:34

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/EcalTPGPhysicsConst.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 Physics Const of 1 IOV
0024  ******************************************/
0025   class EcalTPGPhysicsConstPlot : public cond::payloadInspector::PlotImage<EcalTPGPhysicsConst> {
0026   public:
0027     EcalTPGPhysicsConstPlot()
0028         : cond::payloadInspector::PlotImage<EcalTPGPhysicsConst>("ECAL TPG Physics Constant - 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<EcalTPGPhysicsConst> 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         EcalTPGPhysicsConstMap map = (*payload).getMap();
0041         NbRows = map.size();
0042 
0043         align = new TH2F("TPGPhysicsConstant",
0044                          "mapKey   EtSat         ttf_threshold_Low         ttf_threshold_High         FG_lowThreshold  "
0045                          "       FG_highThreshold         FG_lowRatio         FG_highRatio",
0046                          8,
0047                          0,
0048                          8,
0049                          NbRows,
0050                          0,
0051                          NbRows);
0052 
0053         double row = NbRows - 0.5;
0054         for (std::map<uint32_t, EcalTPGPhysicsConst::Item>::const_iterator it = map.begin(); it != map.end(); it++) {
0055           uint32_t mapKey = it->first;
0056           EcalTPGPhysicsConst::Item item = it->second;
0057 
0058           align->Fill(0.5, row, mapKey);
0059           align->Fill(1.5, row, item.EtSat);
0060           align->Fill(2.5, row, item.ttf_threshold_Low);
0061           align->Fill(3.5, row, item.ttf_threshold_High);
0062           align->Fill(4.5, row, item.FG_lowThreshold);
0063           align->Fill(5.5, row, item.FG_highThreshold);
0064           align->Fill(6.5, row, item.FG_lowRatio);
0065           align->Fill(7.5, row, item.FG_highRatio);
0066 
0067           row = row - 1.;
0068         }
0069 
0070       } else
0071         return false;
0072 
0073       gStyle->SetPalette(1);
0074       gStyle->SetOptStat(0);
0075       TCanvas canvas("CC map", "CC map", 1000, 1000);
0076       TLatex t1;
0077       t1.SetNDC();
0078       t1.SetTextAlign(26);
0079       t1.SetTextSize(0.05);
0080       t1.SetTextColor(2);
0081       t1.DrawLatex(0.5, 0.96, Form("ECAL TPG Physics Constant, IOV %i", run));
0082 
0083       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0084       pad->Draw();
0085       pad->cd();
0086       align->Draw("TEXT");
0087 
0088       drawTable(NbRows, 8);
0089 
0090       align->GetXaxis()->SetTickLength(0.);
0091       align->GetXaxis()->SetLabelSize(0.);
0092       align->GetYaxis()->SetTickLength(0.);
0093       align->GetYaxis()->SetLabelSize(0.);
0094 
0095       std::string ImageName(m_imageFileName);
0096       canvas.SaveAs(ImageName.c_str());
0097 
0098       return true;
0099     }
0100   };
0101 
0102 }  // namespace
0103 // Register the classes as boost python plugin
0104 PAYLOAD_INSPECTOR_MODULE(EcalTPGPhysicsConst) { PAYLOAD_INSPECTOR_CLASS(EcalTPGPhysicsConstPlot); }