CMS 3D CMS Logo

EcalTBWeights_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 TBWeights of 1 IOV
25  *******************************************************/
26 class EcalTBWeightsPlot: public cond::payloadInspector::PlotImage<EcalTBWeights>{
27  public:
28  EcalTBWeightsPlot():
29  cond::payloadInspector::PlotImage<EcalTBWeights>("Ecal TBWeights - map "){
30  setSingleIov(true);
31  }
32 
33  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs)override {
34  auto iov=iovs.front();
35  std::shared_ptr <EcalTBWeights> payload = fetchPayload(std::get<1> (iov));
36  unsigned int run=std::get<0> (iov);
37  TH2F* align;
38  int NbRows;
39 
40  if(payload.get()){
41  EcalTBWeights::EcalTBWeightMap map=(*payload).getMap();
42  NbRows=map.size();
43  align=new TH2F("Ecal PTM Temperatures","EcalXtalGroupId EcalTDCId EcalWeightSet",
44  3,0,3,NbRows,0,NbRows);
45 
46  double row = NbRows-0.5;
47 
48  for (EcalTBWeights::EcalPTMTemperatureMap::const_iterator it =map.begin();
49  it != map.end();it++) {
50 
51  //uint32_t mapKey=it->first;
52  //float val=it->second;
53 
54  //align->Fill(0.5,row,mapKey);
55  //align->Fill(1.5,row,val);
56 
57  row--;
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 TBWeights, 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  TLine* l = new TLine;
79  l->SetLineWidth(1);
80 
81  for (int i = 1; i < NbRows; i++) {
82  double y = (double) i;
83  l = new TLine(0., y, 3., y);
84  l->Draw();
85  }
86 
87  for (int i = 1; i < 3; i++) {
88  double x = (double) i;
89  double y = (double) NbRows;
90  l = new TLine(x, 0., x, y);
91  l->Draw();
92  }
93 
94  align->GetXaxis()->SetTickLength(0.);
95  align->GetXaxis()->SetLabelSize(0.);
96  align->GetYaxis()->SetTickLength(0.);
97  align->GetYaxis()->SetLabelSize(0.);
98 
99  std::string ImageName(m_imageFileName);
100  canvas.SaveAs(ImageName.c_str());
101 
102  return true;
103  }
104 };
105 
106 } //close namespace
107 
108 // Register the classes as boost python plugin
110  PAYLOAD_INSPECTOR_CLASS(EcalTBWeightsPlot);
111 }
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:18
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:23
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)