CMS 3D CMS Logo

EcalTPGLutIdMap_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 LutId Map of 1 IOV
24  ******************************************/
25  class EcalTPGLutIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGLutIdMap> {
26  public:
27  EcalTPGLutIdMapPlot() : cond::payloadInspector::PlotImage<EcalTPGLutIdMap>("Ecal TPG LutId Map - map ") {
28  setSingleIov(true);
29  }
30 
31  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
32  auto iov = iovs.front();
33  std::shared_ptr<EcalTPGLutIdMap> payload = fetchPayload(std::get<1>(iov));
34  unsigned int run = std::get<0>(iov);
35  TH2F* align;
36  int NbRows;
37 
38  if (payload.get()) {
39  EcalTPGLutIdMap::EcalTPGLutMap map = (*payload).getMap();
40  NbRows = 30;
41 
42  align = new TH2F("Ecal TPG LutId Map",
43  "EB LutEcalTPGLut EE "
44  " LutEcalTPGLut",
45  4,
46  0,
47  4,
48  NbRows,
49  0,
50  NbRows);
51 
52  double row = NbRows - 0.5;
53  int columnBase = 0;
54  for (EcalTPGLutIdMap::EcalTPGLutMapItr it = map.begin(); it != map.end(); it++) {
55  EcalTPGLut ecaltpgLut = it->second;
56  uint32_t mapKey = it->first;
57 
58  const unsigned int* lut = (ecaltpgLut.getLut());
59 
60  for (int i = 0; i < 30; i++) {
61  if (i == (NbRows / 2 - 1))
62  align->Fill(0.5 + columnBase, row, mapKey + 1);
63 
64  align->Fill(1.5 + columnBase, row, *(lut + i));
65  row = row - 1.;
66  }
67 
68  columnBase += 2;
69  row = NbRows - 0.5;
70  } //loop over TPGLutIdMap rows
71 
72  } else
73  return false;
74 
75  gStyle->SetPalette(1);
76  gStyle->SetOptStat(0);
77  TCanvas canvas("CC map", "CC map", 1000, 1000);
78  TLatex t1;
79  t1.SetNDC();
80  t1.SetTextAlign(26);
81  t1.SetTextSize(0.05);
82  t1.SetTextColor(2);
83  t1.DrawLatex(0.5, 0.96, Form("ECAL TPG LutId Map, IOV %i", run));
84 
85  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
86  pad->Draw();
87  pad->cd();
88  align->Draw("TEXT");
89  TLine* l = new TLine;
90  l->SetLineWidth(1);
91  for (int i = 1; i < NbRows; i++) {
92  double y = (double)i;
93  l = new TLine(1., y, 2., y);
94  l->Draw();
95  }
96 
97  for (int i = 1; i < NbRows; i++) {
98  double y = (double)i;
99  l = new TLine(3., y, 4., y);
100  l->Draw();
101  }
102 
103  for (int i = 1; i < 4; i++) {
104  double x = (double)i;
105  double y = (double)NbRows;
106  l = new TLine(x, 0., x, y);
107  l->Draw();
108  }
109 
110  align->GetXaxis()->SetTickLength(0.);
111  align->GetXaxis()->SetLabelSize(0.);
112  align->GetYaxis()->SetTickLength(0.);
113  align->GetYaxis()->SetLabelSize(0.);
114 
115  std::string ImageName(m_imageFileName);
116  canvas.SaveAs(ImageName.c_str());
117 
118  return true;
119  }
120  };
121 
122 } // namespace
123 // Register the classes as boost python plugin
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
align
Definition: AlignableIndexer.h:30
EcalTPGLutIdMap::EcalTPGLutMap
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
Definition: EcalTPGLutIdMap.h:12
PayloadInspector.h
EBDetId.h
EEDetId.h
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
DDAxes::x
PayloadInspectorModule.h
EcalTPGLut::getLut
const unsigned int * getLut() const
Definition: EcalTPGLut.cc:13
EcalTPGLutIdMap.h
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
jets_cff.payload
payload
Definition: jets_cff.py:32
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
Time.h
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:905
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalDrawUtils.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
EcalTPGLut
Definition: EcalTPGLut.h:6
writedatasetfile.run
run
Definition: writedatasetfile.py:27
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:894
EcalTPGLutIdMap::EcalTPGLutMapItr
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
Definition: EcalTPGLutIdMap.h:13
genParticles_cff.map
map
Definition: genParticles_cff.py:11