CMS 3D CMS Logo

EcalSRSettings_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  2d plot of Ecal SR Settings Summary of 1 IOV
24  *******************************************************/
25 class EcalSRSettingsSummaryPlot: public cond::payloadInspector::PlotImage<EcalSRSettings>{
26  public:
27  EcalSRSettingsSummaryPlot():
28  cond::payloadInspector::PlotImage<EcalSRSettings>("Ecal SR Settings Summary - map "){
29  setSingleIov(true);
30  }
31 
32  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs)override {
33  const int maxInCol=27;
34 
35  auto iov=iovs.front();
36  std::shared_ptr <EcalSRSettings> payload = fetchPayload(std::get<1> (iov));
37  unsigned int run=std::get<0> (iov);
38 
39  TH2F* align;
40 
41  int NbRows,gridRows;
42  int NbColumns,offset;
43 
44  if(payload.get()){
45  EcalSRSettings ecalSR=(*payload);
46 
47  NbRows = ecalSR.srpLowInterestChannelZS_.size();
48 
49  gridRows=(NbRows<=maxInCol)?NbRows:maxInCol;
50  offset=ceil(1.0*NbRows/maxInCol);
51  NbColumns=offset*2+3;
52 
53  align =new TH2F("Ecal SR Settings Summary","ebDccAdcToGeV eeDccAdcToGeV Rows# srpLowInterestChannelZS srpHighInterestChannelZS",
54  NbColumns, 0, NbColumns, gridRows, 0, gridRows);
55 
56  double row = gridRows - 0.5;
57  double column=3.5;
58  int cnt=0;
59 
60  align->Fill(0.5,gridRows-0.5,ecalSR.ebDccAdcToGeV_);
61  align->Fill(1.5,gridRows-0.5,ecalSR.eeDccAdcToGeV_);
62 
63  for(int i=0;i<gridRows;i++){
64  align->Fill(2.5, gridRows-i-0.5, i+1);
65  }
66 
67 
68  for (std::vector<float>::const_iterator it =ecalSR.srpLowInterestChannelZS_.begin();
69  it != ecalSR.srpLowInterestChannelZS_.end();it++) {
70 
71  align->Fill(column, row, *it);
72 
73  cnt++;
74  column=floor(1.0*cnt/maxInCol)+3.5;
75  row=(row==0.5?(gridRows-0.5):row-1);
76  }
77 
78  row = gridRows - 0.5;
79  column=3.5;
80  cnt=0;
81 
82  for (std::vector<float>::const_iterator it =ecalSR.srpHighInterestChannelZS_.begin();
83  it != ecalSR.srpHighInterestChannelZS_.end();it++) {
84 
85  align->Fill(column+offset, row, *it);
86 
87  cnt++;
88  column=floor(1.0*cnt/maxInCol)+3.5;
89  row=(row==0.5?(gridRows-0.5):row-1);
90  }
91 
92  }else
93  return false;
94 
95  gStyle->SetPalette(1);
96  gStyle->SetOptStat(0);
97  TCanvas canvas("CC map", "CC map", 1000, 1000);
98  TLatex t1;
99  t1.SetNDC();
100  t1.SetTextAlign(26);
101  t1.SetTextSize(0.05);
102  t1.SetTextColor(2);
103  t1.DrawLatex(0.5, 0.96,Form("Ecal SRSettings Summary, IOV %i", run));
104 
105 
106  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
107  pad->Draw();
108  pad->cd();
109  align->Draw("TEXT");
110 
111  drawTable(NbRows,NbColumns);
112 
113  align->GetXaxis()->SetTickLength(0.);
114  align->GetXaxis()->SetLabelSize(0.);
115  align->GetYaxis()->SetTickLength(0.);
116  align->GetYaxis()->SetLabelSize(0.);
117 
118  std::string ImageName(m_imageFileName);
119  canvas.SaveAs(ImageName.c_str());
120 
121  return true;
122  }
123 };
124 
125 }
126 
127 // Register the classes as boost python plugin
129  PAYLOAD_INSPECTOR_CLASS(EcalSRSettingsSummaryPlot);
130 }
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
std::vector< float > srpHighInterestChannelZS_
#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)
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
std::vector< float > srpLowInterestChannelZS_
Definition: plugin.cc:24
def canvas(sub, attr)
Definition: svgfig.py:481
float eeDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EE.
void drawTable(int nbRows, int nbColumns)