CMS 3D CMS Logo

EcalTPGWeightIdMap_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 TPG Weight Id Map of 1 IOV
24  ******************************************/
25 class EcalTPGWeightIdMapPlot: public cond::payloadInspector::PlotImage<EcalTPGWeightIdMap>{
26  public:
27  EcalTPGWeightIdMapPlot():
28  cond::payloadInspector::PlotImage<EcalTPGWeightIdMap>("Ecal TPG Weight Id Map - 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 <EcalTPGWeightIdMap> 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  EcalTPGWeightIdMap::EcalTPGWeightMap map=(*payload).getMap();
41  NbRows=map.size();
42 
43 
44  align =new TH2F("Ecal TPG Weight Id Map","MapKey w0 w1 w2 w3 w4",
45  6, 0, 6, NbRows, 0, NbRows);
46 
47  double row = NbRows - 0.5;
48  for (EcalTPGWeightIdMap::EcalTPGWeightMapItr it = map.begin();it != map.end();it++) {
49 
50  uint32_t mapKey=it->first;
51  EcalTPGWeights item=it->second;
52  uint32_t w0,w1,w2,w3,w4;
53  item.getValues(w0,w1,w2,w3,w4);
54 
55  align->Fill(0.5, row, mapKey+1);
56  align->Fill(1.5, row, w0);
57  align->Fill(2.5, row, w1);
58  align->Fill(3.5, row, w2);
59  align->Fill(4.5, row, w3);
60  align->Fill(5.5, row, w4);
61 
62  row = row - 1.;
63  }//loop over EcalTPGWeightIdMap rows
64 
65 
66  }else
67  return false;
68 
69 
70  gStyle->SetPalette(1);
71  gStyle->SetOptStat(0);
72  TCanvas canvas("CC map", "CC map", 1000, 1000);
73  TLatex t1;
74  t1.SetNDC();
75  t1.SetTextAlign(26);
76  t1.SetTextSize(0.05);
77  t1.SetTextColor(2);
78  t1.DrawLatex(0.5, 0.96,Form("Ecal TPG Weight Id Map, IOV %i", run));
79 
80  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
81  pad->Draw();
82  pad->cd();
83  align->Draw("TEXT");
84 
85  drawTable(NbRows, 6);
86 
87  align->GetXaxis()->SetTickLength(0.);
88  align->GetXaxis()->SetLabelSize(0.);
89  align->GetYaxis()->SetTickLength(0.);
90  align->GetYaxis()->SetLabelSize(0.);
91 
92  std::string ImageName(m_imageFileName);
93  canvas.SaveAs(ImageName.c_str());
94 
95  return true;
96  }
97 
98 
99 };
100 
101 }
102 // Register the classes as boost python plugin
104  PAYLOAD_INSPECTOR_CLASS(EcalTPGWeightIdMapPlot);
105 }
std::map< uint32_t, EcalTPGWeights >::const_iterator EcalTPGWeightMapItr
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
void getValues(uint32_t &w0, uint32_t &w1, uint32_t &w2, uint32_t &w3, uint32_t &w4) const
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
common ppss p3p6s2 common epss epspn46 common const1 w4
Definition: inclppp.h:1
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs)=0
std::map< uint32_t, EcalTPGWeights > EcalTPGWeightMap
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
common ppss p3p6s2 common epss epspn46 common const1 w3
Definition: inclppp.h:1
Definition: plugin.cc:24
def canvas(sub, attr)
Definition: svgfig.py:482
void drawTable(int nbRows, int nbColumns)