CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalSampleMask_PayloadInspector.cc
Go to the documentation of this file.
7 
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h" // a 2-D histogram with four bytes per cell (float)
12 #include "TCanvas.h"
13 #include "TLine.h"
14 #include "TStyle.h"
15 #include "TLatex.h" //write mathematical equations.
16 #include "TPave.h"
17 #include "TPaveStats.h"
18 #include <string>
19 #include <fstream>
20 
21 namespace {
22 
23  /*******************************************************
24  2d plot of Ecal Sample Mask of 1 IOV
25  *******************************************************/
26  class EcalSampleMaskPlot : public cond::payloadInspector::PlotImage<EcalSampleMask> {
27  public:
28  EcalSampleMaskPlot() : cond::payloadInspector::PlotImage<EcalSampleMask>("ECAL Sample Mask - map ") {
29  setSingleIov(true);
30  }
31 
32  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
33  auto iov = iovs.front();
34  std::shared_ptr<EcalSampleMask> payload = fetchPayload(std::get<1>(iov));
35  unsigned int run = std::get<0>(iov);
36  TH2F* align;
37  int NbRows;
38 
39  if (payload.get()) {
40  NbRows = 1;
41  align = new TH2F("Ecal Sample Mask", "EB EE", 2, 0, 2, NbRows, 0, NbRows);
42  EcalSampleMask it = (*payload);
43 
44  double row = NbRows - 0.5;
45 
46  align->Fill(0.5, row, it.getEcalSampleMaskRecordEB());
47  align->Fill(1.5, row, it.getEcalSampleMaskRecordEE());
48  } else
49  return false;
50 
51  gStyle->SetPalette(1);
52  gStyle->SetOptStat(0);
53  TCanvas canvas("CC map", "CC map", 1000, 1000);
54  TLatex t1;
55  t1.SetNDC();
56  t1.SetTextAlign(26);
57  t1.SetTextSize(0.05);
58  t1.SetTextColor(2);
59  t1.DrawLatex(0.5, 0.96, Form("Ecal Sample Mask, IOV %i", run));
60 
61  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
62  pad->Draw();
63  pad->cd();
64  align->Draw("TEXT");
65 
66  drawTable(NbRows, 2);
67 
68  align->GetXaxis()->SetTickLength(0.);
69  align->GetXaxis()->SetLabelSize(0.);
70  align->GetYaxis()->SetTickLength(0.);
71  align->GetYaxis()->SetLabelSize(0.);
72 
73  std::string ImageName(m_imageFileName);
74  canvas.SaveAs(ImageName.c_str());
75 
76  return true;
77  }
78  };
79 
80 } // namespace
81 
82 // Register the classes as boost python plugin
def canvas
Definition: svgfig.py:482
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
float getEcalSampleMaskRecordEE() const
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
float getEcalSampleMaskRecordEB() const
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)