CMS 3D CMS Logo

EcalWeightSet_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 
22 namespace {
23 
24 /*******************************************************
25  2d plot of Ecal Weight Set of 1 IOV
26  *******************************************************/
27 class EcalWeightSetPlot: public cond::payloadInspector::PlotImage<EcalWeightSet>{
28  public:
29  EcalWeightSetPlot():
30  cond::payloadInspector::PlotImage<EcalWeightSet>("Ecal Weight Set - map "){
31  setSingleIov(true);
32  }
33 
34  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs)override {
35  auto iov=iovs.front();
36  std::shared_ptr <EcalWeightSet> payload = fetchPayload(std::get<1> (iov));
37  unsigned int run=std::get<0> (iov);
38  TH2F* align;
39  int NbRows;
40 
41  if(payload.get()){
42  NbRows=3;
43  align=new TH2F("Ecal Weight Set","WeightsBeforeGainSwitch",10,0,10,NbRows,0,NbRows);
44 
45  EcalWeightSet::EcalWeightMatrix mat=(*payload).getWeightsBeforeGainSwitch();
46 
47 
48  double rr=9.5,cc=0.5;
49  //x = *(m.**begin**()+7);
50  for(EcalWeightSet::EcalWeightMatrix::const_iterator it=mat.begin();it != mat.end();it++){
51  align->Fill(cc,rr,*(it));
52 
53  cc++;
54  if(cc==10.5){
55  cc=0.5;
56  rr--;
57  }
58  }
59 
60  }else
61  return false;
62 
63  gStyle->SetPalette(1);
64  gStyle->SetOptStat(0);
65  TCanvas canvas("CC map", "CC map", 1000, 1000);
66  TLatex t1;
67  t1.SetNDC();
68  t1.SetTextAlign(26);
69  t1.SetTextSize(0.05);
70  t1.SetTextColor(2);
71  t1.DrawLatex(0.5, 0.96,Form("Ecal Weight Set, IOV %i", run));
72 
73 
74  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
75  pad->Draw();
76  pad->cd();
77  align->Draw("TEXT");
78 
79  drawTable(NbRows,10);
80 
81  align->GetXaxis()->SetTickLength(0.);
82  align->GetXaxis()->SetLabelSize(0.);
83  align->GetYaxis()->SetTickLength(0.);
84  align->GetYaxis()->SetLabelSize(0.);
85 
86  std::string ImageName(m_imageFileName);
87  canvas.SaveAs(ImageName.c_str());
88 
89  return true;
90  }
91 };
92 
93 
94 } //close namespace
95 
96 // Register the classes as boost python plugin
98  PAYLOAD_INSPECTOR_CLASS(EcalWeightSetPlot);
99 }
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs)=0
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:24
def canvas(sub, attr)
Definition: svgfig.py:482
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:22
void drawTable(int nbRows, int nbColumns)