CMS 3D CMS Logo

HcalSiPMCharacteristics_PayloadInspector.cc
Go to the documentation of this file.
6 
7 // the data format of the condition to be inspected
9 
10 #include "TH2F.h"
11 #include "TCanvas.h"
12 #include "TLine.h"
13 #include "TStyle.h"
14 #include "TLatex.h"
15 #include "TPave.h"
16 #include "TPaveStats.h"
17 #include <string>
18 #include <fstream>
19 
20 namespace {
21 
22  /********************************************
23  printing float values of reco paramters
24  *********************************************/
25  class HcalSiPMCharacteristicsSummary : public cond::payloadInspector::PlotImage<HcalSiPMCharacteristics> {
26  public:
27  HcalSiPMCharacteristicsSummary() : cond::payloadInspector::PlotImage<HcalSiPMCharacteristics>("HCAL RecoParam Ratios - map ") {
28  setSingleIov( true );
29  }
30 
31 
32 
33  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
34 
35 
36  auto iov = iovs.front();
37  std::shared_ptr<HcalSiPMCharacteristics> payload = fetchPayload( std::get<1>(iov) );
38  if(payload.get()) {
39 
40  std::string subDetName;
41  std::vector<HcalSiPMCharacteristics> itemsVec;
42  std::pair<std::string,int> valMap;
43 
44 
45  //TODO: Abstract into a function that takes valMap as the argument
46 
47  TLatex label,val;
48  TLine* ll;
49  TCanvas* can = new TCanvas("RecoParamsSummary","RecoParamsSummary",2400, 1680);
50  can->cd();
51  //HcalObjRepresent::drawTable(2,2);
52 
53  label.SetNDC();
54  label.SetTextAlign(26);
55  label.SetTextSize(0.05);
56  label.SetTextColor(2);
57  label.DrawLatex(0.5, 0.96,Form("Hcal SiPM Characteristics"));
58  std::vector<float> line;
60 
61  int nTypes = payload->getTypes();
62  float startPosY = 0.9, endPosY = 0.1;
63  float startPosX = 0.03, endPosX = 0.92;
64  int type;
65  std::vector<float>::iterator linEle;
66  std::vector<std::string>::iterator linStrEle;
67  int j = 0;
68  float xDiff, yDiff;
69  // Header line
70  std::vector<std::string> lblline = {"Type", "Pixels", "parLin1", "parLin2", "parLin3","crossTalk"};//, aux1, aux2};
71  xDiff = (endPosX - startPosX)/(lblline.size()-1);
72  yDiff = (startPosY - endPosY)/nTypes;
73 
74 
75  label.SetTextAlign(12);
76  label.SetTextSize(0.05);
77  label.SetTextColor(1);
78  ll = new TLine(startPosX -0.2*xDiff, startPosY + 0.5*yDiff, startPosX - 0.2*xDiff, startPosY - 0.5*yDiff);
79  ll->Draw();
80  for(linStrEle = lblline.begin(); linStrEle != lblline.end(); ++linStrEle) {
81  ll = new TLine(startPosX + (j+0.5)*xDiff, startPosY + 0.5*yDiff, startPosX + (j+0.5)*xDiff, startPosY - 0.5*yDiff);
82  label.DrawLatex(startPosX + (j==0 ? -0.1 : (j-0.4))*xDiff , startPosY, (*linStrEle).c_str());
83  ll->Draw();
84  j++;
85  }
86  ll = new TLine(0,startPosY - 0.5 * yDiff, 1, startPosY - 0.5 * yDiff);
87  ll->Draw();
88 
89 
90  val.SetNDC();
91  val.SetTextAlign(26);
92  val.SetTextSize(0.035);
93  for(int i = 0;i < nTypes;i++){
94  type = payload->getType(i);
95 
96 
97  line = {(float)type, (float)payload->getPixels(type), payload->getNonLinearities(type).at(0), payload->getNonLinearities(type).at(1), payload->getNonLinearities(type).at(2), payload->getCrossTalk(type)};
98  ll = new TLine(startPosX -0.2*xDiff, startPosY - (i+0.5)*yDiff, startPosX - 0.2*xDiff, startPosY - (i+1.5)*yDiff);
99  ll->Draw();
100  j = 0;
101 
102  for(linEle = line.begin(); linEle != line.end(); ++linEle) {
103  ll = new TLine(startPosX + (j+0.5)*xDiff, startPosY - (i+0.5)*yDiff, startPosX + (j+0.5)*xDiff, startPosY - (i+1.5)*yDiff);
104  val.DrawLatex(startPosX + j*xDiff , startPosY - (i+1)*yDiff, HcalObjRepresent::SciNotatStr((*linEle)).c_str());
105  ll->Draw();
106  j++;
107  }
108 
109  }
110 
111 
112 
113  std::string ImageName(m_imageFileName);
114  can->SaveAs(ImageName.c_str());
115  return false;
116  } else return false;
117  }// fill method
118  };
119 //TODO: Add a Change Summary?
120 
121 } // close namespace
122 
123  // Register the classes as boost python plugin
125  PAYLOAD_INSPECTOR_CLASS(HcalSiPMCharacteristicsSummary);
126 }
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
void drawTable(int nbRows, int nbColumns)
char const * label
#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)
std::string SciNotatStr(float num)
Definition: plugin.cc:24