CMS 3D CMS Logo

EcalTPGFineGrainEBIdMap_PayloadInspector.cc
Go to the documentation of this file.
8 
9 // the data format of the condition to be inspected
11 
12 #include "TH2F.h"
13 #include "TCanvas.h"
14 #include "TStyle.h"
15 #include "TLine.h"
16 #include "TLatex.h"
17 
18 #include <string>
19 #include <cstring>
20 
21 namespace {
22  enum { TEMPLATESAMPLES = 5 };
23  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 17, MAX_IPHI = 72 }; // barrel lower and upper bounds on eta and phi
24 
25  /***********************************************
26  2d plot of EcalTPGFineGrainEBIdMap of 1 IOV
27  ************************************************/
28  class EcalTPGFineGrainEBIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGFineGrainEBIdMap> {
29  public:
30  EcalTPGFineGrainEBIdMapPlot()
31  : cond::payloadInspector::PlotImage<EcalTPGFineGrainEBIdMap>("Ecal TPGFineGrainEBIdMap - map ") {
32  setSingleIov(true);
33  }
34 
35  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
36  TH2F** barrel = new TH2F*[TEMPLATESAMPLES];
37  double pEBmin[TEMPLATESAMPLES], pEBmax[TEMPLATESAMPLES];
38  std::string text[TEMPLATESAMPLES] = {"ThresholdETLow", "ThresholdETHigh", "RatioLow", "RatioHigh", "LUT"};
39  int EBcnt = 0;
40 
41  for (int s = 0; s < TEMPLATESAMPLES; ++s) {
42  char* y = new char[text[s].length() + 1];
43  std::strcpy(y, text[s].c_str());
44  barrel[s] = new TH2F("EB", y, MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
45  }
46 
47  uint32_t ThresholdETLow = 0;
48  uint32_t ThresholdETHigh = 0;
49  uint32_t RatioLow = 0;
50  uint32_t RatioHigh = 0;
51  uint32_t LUT = 0;
52 
53  auto iov = iovs.front();
54  std::shared_ptr<EcalTPGFineGrainEBIdMap> payload = fetchPayload(std::get<1>(iov));
55  unsigned int run = std::get<0>(iov);
56  if (payload.get()) {
57  const std::map<uint32_t, EcalTPGFineGrainConstEB>& towerMap = (*payload).getMap();
58  std::map<uint32_t, EcalTPGFineGrainConstEB>::const_iterator it = towerMap.begin();
59 
60  for (int iphi = MIN_IPHI - 1; iphi <= MAX_IPHI; iphi++) {
61  for (int ieta = -1 * MAX_IETA; ieta < MAX_IETA; ieta++) {
62  //if(ieta > 0) ieta--;
63 
64  EcalTPGFineGrainConstEB fg = (*it).second;
65 
66  fg.getValues(ThresholdETLow, ThresholdETHigh, RatioLow, RatioHigh, LUT);
67 
68  barrel[0]->Fill(iphi, ieta, ThresholdETLow);
69  barrel[1]->Fill(iphi, ieta, ThresholdETHigh);
70  barrel[2]->Fill(iphi, ieta, RatioLow);
71  barrel[3]->Fill(iphi, ieta, RatioHigh);
72  barrel[4]->Fill(iphi, ieta, LUT);
73 
74  if (ThresholdETLow < pEBmin[0])
75  pEBmin[0] = ThresholdETLow;
76  if (ThresholdETHigh < pEBmin[1])
77  pEBmin[1] = ThresholdETHigh;
78  if (RatioLow < pEBmin[2])
79  pEBmin[2] = RatioLow;
80  if (RatioHigh < pEBmin[3])
81  pEBmin[3] = RatioHigh;
82  if (LUT < pEBmin[4])
83  pEBmin[4] = LUT;
84 
85  if (ThresholdETLow > pEBmax[0])
86  pEBmax[0] = ThresholdETLow;
87  if (ThresholdETHigh > pEBmax[1])
88  pEBmax[1] = ThresholdETHigh;
89  if (RatioLow > pEBmax[2])
90  pEBmax[2] = RatioLow;
91  if (RatioHigh > pEBmax[3])
92  pEBmax[3] = RatioHigh;
93  if (LUT > pEBmax[4])
94  pEBmax[4] = LUT;
95 
96  EBcnt++;
97  }
98  }
99 
100  } // payload
101 
102  gStyle->SetPalette(1);
103  gStyle->SetOptStat(0);
104  TCanvas canvas("CC map", "CC map", 1600, 2800);
105  TLatex t1;
106  t1.SetNDC();
107  t1.SetTextAlign(26);
108  t1.SetTextSize(0.04);
109  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGFine Grain EBIdMap, IOV %i", run));
110 
111  float xmi = 0.24;
112  float xma = 0.76;
113 
114  TPad** pad = new TPad*[TEMPLATESAMPLES];
115  for (int s = 0; s < TEMPLATESAMPLES; s++) {
116  float yma = 0.94 - (0.16 * s);
117  float ymi = yma - 0.14;
118  //pad[s] = new TPad(text[s],Form("Towers %i", EBcnt),xmi, ymi, xma, yma);
119  char* y = new char[text[s].length() + 1];
120  std::strcpy(y, text[s].c_str());
121 
122  pad[s] = new TPad(Form("Towers %i", EBcnt), y, xmi, ymi, xma, yma);
123  pad[s]->Draw();
124  }
125 
126  for (int s = 0; s < TEMPLATESAMPLES; s++) {
127  pad[s]->cd();
128 
129  if (pEBmin[s] == pEBmax[s]) { // same values everywhere!..
130  pEBmin[s] = pEBmin[s] - 1.e-06;
131  pEBmax[s] = pEBmax[s] + 1.e-06;
132  }
133 
134  barrel[s]->SetMaximum(pEBmax[s]);
135  barrel[s]->SetMinimum(pEBmin[s]);
136  barrel[s]->Draw("colz");
137 
138  TLine* l = new TLine(0., 0., 0., 0.);
139  l->SetLineWidth(1);
140  for (int i = 0; i < MAX_IETA; i++) {
141  Double_t x = 4. + (i * 4);
142  l = new TLine(x, -MAX_IETA, x, MAX_IETA);
143  l->Draw();
144  }
145  }
146 
147  std::string ImageName(m_imageFileName);
148  canvas.SaveAs(ImageName.c_str());
149 
150  return true;
151  } // fill method
152  };
153 
154 } // namespace
155 
156 // Register the classes as boost python plugin
void getValues(uint32_t &ThresholdETLow, uint32_t &ThresholdETHigh, uint32_t &RatioLow, uint32_t &RatioHigh, uint32_t &LUT) const
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
def canvas(sub, attr)
Definition: svgfig.py:482
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:31
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)