CMS 3D CMS Logo

EcalTPGCrystalStatus_PayloadInspector.cc
Go to the documentation of this file.
7 // the data format of the condition to be inspected
9 
10 #include "TH2F.h"
11 #include "TCanvas.h"
12 #include "TStyle.h"
13 #include "TLine.h"
14 #include "TLatex.h"
15 
16 #include <string>
17 
18 namespace {
19  enum { kEBChannels = 61200, kEEChannels = 14648, kSides = 2 };
20  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360 }; // barrel lower and upper bounds on eta and phi
21  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
22 
23  /***********************************************
24  2d plot of ECAL TPGCrystalStatus of 1 IOV
25  ************************************************/
26  class EcalTPGCrystalStatusPlot : public cond::payloadInspector::PlotImage<EcalTPGCrystalStatus> {
27  public:
28  EcalTPGCrystalStatusPlot()
29  : cond::payloadInspector::PlotImage<EcalTPGCrystalStatus>("ECAL TPGCrystalStatus - map ") {
30  setSingleIov(true);
31  }
32 
33  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
34  TH2F* barrel = new TH2F("EB", "EB TPG Crystal Status", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
35  TH2F* endc_p = new TH2F("EE+", "EE+ TPG Crystal Status", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
36  TH2F* endc_m = new TH2F("EE-", "EE- TPG Crystal Status", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
37  int EBstat = 0, EEstat[2] = {0, 0};
38 
39  auto iov = iovs.front();
40  std::shared_ptr<EcalTPGCrystalStatus> payload = fetchPayload(std::get<1>(iov));
41  unsigned int run = std::get<0>(iov);
42  if (payload.get()) {
43  for (int ieta = -MAX_IETA; ieta <= MAX_IETA; ieta++) {
44  Double_t eta = (Double_t)ieta;
45  if (ieta == 0)
46  continue;
47  else if (ieta > 0.)
48  eta = eta - 0.5; // 0.5 to 84.5
49  else
50  eta = eta + 0.5; // -84.5 to -0.5
51  for (int iphi = 1; iphi <= MAX_IPHI; iphi++) {
52  Double_t phi = (Double_t)iphi - 0.5;
53  EBDetId id(ieta, iphi);
54  double val = (*payload)[id.rawId()].getStatusCode();
55  barrel->Fill(phi, eta, val);
56  if (val > 0)
57  EBstat++;
58  }
59  }
60 
61  for (int sign = 0; sign < kSides; sign++) {
62  int thesign = sign == 1 ? 1 : -1;
63  for (int ix = 1; ix <= IX_MAX; ix++) {
64  for (int iy = 1; iy <= IY_MAX; iy++) {
65  if (!EEDetId::validDetId(ix, iy, thesign))
66  continue;
67  EEDetId id(ix, iy, thesign);
68  double val = (*payload)[id.rawId()].getStatusCode();
69  if (thesign == 1) {
70  endc_p->Fill(ix, iy, val);
71  if (val > 0)
72  EEstat[1]++;
73  } else {
74  endc_m->Fill(ix, iy, val);
75  if (val > 0)
76  EEstat[0]++;
77  }
78  } // iy
79  } // ix
80  } // side
81  } // payload
82 
83  gStyle->SetPalette(1);
84  gStyle->SetOptStat(0);
85  // TCanvas canvas("CC map","CC map", 1600, 450);
86  Double_t w = 1200;
87  Double_t h = 1400;
88  TCanvas canvas("c", "c", w, h);
89  canvas.SetWindowSize(w + (w - canvas.GetWw()), h + (h - canvas.GetWh()));
90 
91  TLatex t1;
92  t1.SetNDC();
93  t1.SetTextAlign(26);
94  t1.SetTextSize(0.05);
95  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGCrystalStatus, IOV %i", run));
96 
97  // float xmi[3] = {0.0 , 0.24, 0.76};
98  // float xma[3] = {0.24, 0.76, 1.00};
99  float xmi[3] = {0.0, 0.0, 0.5};
100  float xma[3] = {1.0, 0.5, 1.0};
101  float ymi[3] = {0.47, 0.0, 0.0};
102  float yma[3] = {0.94, 0.47, 0.47};
103  TPad** pad = new TPad*;
104  for (int obj = 0; obj < 3; obj++) {
105  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], ymi[obj], xma[obj], yma[obj]);
106  pad[obj]->Draw();
107  }
108 
109  pad[0]->cd();
110  DrawEB(barrel, 0., 1.);
111  t1.DrawLatex(0.2, 0.94, Form("%i crystals", EBstat));
112  pad[1]->cd();
113  DrawEE(endc_m, 0., 1.);
114  t1.DrawLatex(0.15, 0.92, Form("%i crystals", EEstat[0]));
115  pad[2]->cd();
116  DrawEE(endc_p, 0., 1.);
117  t1.DrawLatex(0.15, 0.92, Form("%i crystals", EEstat[1]));
118 
119  std::string ImageName(m_imageFileName);
120  canvas.SaveAs(ImageName.c_str());
121  return true;
122  } // fill method
123  };
124 
125  /************************************************************************
126  2d plot of ECAL TPGCrystalStatus difference between 2 IOVs
127  ************************************************************************/
128  class EcalTPGCrystalStatusDiff : public cond::payloadInspector::PlotImage<EcalTPGCrystalStatus> {
129  public:
130  EcalTPGCrystalStatusDiff()
131  : cond::payloadInspector::PlotImage<EcalTPGCrystalStatus>("ECAL TPGCrystalStatus difference") {
132  setSingleIov(false);
133  }
134 
135  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
136  TH2F* barrel = new TH2F("EB", "EB difference", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
137  TH2F* endc_p = new TH2F("EE+", "EE+ difference", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
138  TH2F* endc_m = new TH2F("EE-", "EE- difference", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
139  int EBstat = 0, EEstat[2] = {0, 0};
140 
141  unsigned int run[2] = {0, 0}, irun = 0;
142  float vEB[kEBChannels], vEE[kEEChannels];
143  for (auto const& iov : iovs) {
144  std::shared_ptr<EcalTPGCrystalStatus> payload = fetchPayload(std::get<1>(iov));
145  run[irun] = std::get<0>(iov);
146  if (payload.get()) {
147  for (int ieta = -MAX_IETA; ieta <= MAX_IETA; ieta++) {
148  Double_t eta = (Double_t)ieta;
149  if (ieta == 0)
150  continue;
151  else if (ieta > 0.)
152  eta = eta - 0.5; // 0.5 to 84.5
153  else
154  eta = eta + 0.5; // -84.5 to -0.5
155  for (int iphi = 1; iphi <= MAX_IPHI; iphi++) {
156  Double_t phi = (Double_t)iphi - 0.5;
157  EBDetId id(ieta, iphi);
158  int channel = id.hashedIndex();
159  double val = (*payload)[id.rawId()].getStatusCode();
160  if (irun == 0)
161  vEB[channel] = val;
162  else {
163  double diff = val - vEB[channel];
164  barrel->Fill(phi, eta, diff);
165  if (diff != 0)
166  EBstat++;
167  // std::cout << " entry " << EBtot << " mean " << EBmean << " rms " << EBrms << std::endl;
168  }
169  }
170  }
171 
172  for (int sign = 0; sign < kSides; sign++) {
173  int thesign = sign == 1 ? 1 : -1;
174  for (int ix = 1; ix <= IX_MAX; ix++) {
175  for (int iy = 1; iy <= IY_MAX; iy++) {
176  if (!EEDetId::validDetId(ix, iy, thesign))
177  continue;
178  EEDetId id(ix, iy, thesign);
179  int channel = id.hashedIndex();
180  double val = (*payload)[id.rawId()].getStatusCode();
181  if (irun == 0)
182  vEE[channel] = val;
183  else {
184  double diff = val - vEE[channel];
185  if (thesign == 1) {
186  endc_p->Fill(ix, iy, diff);
187  if (diff != 0)
188  EEstat[1]++;
189  } else {
190  endc_m->Fill(ix, iy, diff);
191  if (diff != 0)
192  EEstat[0]++;
193  }
194  }
195  } // iy
196  } // ix
197  } // side
198  } // payload
199  else
200  return false;
201  irun++;
202  } // loop over IOVs
203 
204  gStyle->SetPalette(1);
205  gStyle->SetOptStat(0);
206  Double_t w = 1200;
207  Double_t h = 1400;
208  TCanvas canvas("c", "c", w, h);
209  canvas.SetWindowSize(w + (w - canvas.GetWw()), h + (h - canvas.GetWh()));
210 
211  TLatex t1;
212  t1.SetNDC();
213  t1.SetTextAlign(26);
214  t1.SetTextSize(0.05);
215  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGCrystalStatus, IOV %i - %i", run[1], run[0]));
216 
217  // float xmi[3] = {0.0 , 0.24, 0.76};
218  // float xma[3] = {0.24, 0.76, 1.00};
219  float xmi[3] = {0.0, 0.0, 0.5};
220  float xma[3] = {1.0, 0.5, 1.0};
221  float ymi[3] = {0.47, 0.0, 0.0};
222  float yma[3] = {0.94, 0.47, 0.47};
223  std::vector<TPad*> pad;
224  for (int obj = 0; obj < 3; obj++) {
225  pad.push_back(new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], ymi[obj], xma[obj], yma[obj]));
226  pad[obj]->Draw();
227  }
228 
229  pad[0]->cd();
230  DrawEB(barrel, -1., 1.);
231  t1.DrawLatex(0.2, 0.94, Form("%i differences", EBstat));
232  pad[1]->cd();
233  DrawEE(endc_m, -1., 1.);
234  t1.DrawLatex(0.15, 0.92, Form("%i differences", EEstat[0]));
235  pad[2]->cd();
236  DrawEE(endc_p, -1., 1.);
237  t1.DrawLatex(0.15, 0.92, Form("%i differences", EEstat[1]));
238 
239  std::string ImageName(m_imageFileName);
240  canvas.SaveAs(ImageName.c_str());
241  return true;
242  } // fill method
243  };
244 
245  /*****************************************
246  2d plot of EcalTPGCrystalStatus Error Summary of 1 IOV
247  ******************************************/
248  class EcalTPGCrystalStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalTPGCrystalStatus> {
249  public:
250  EcalTPGCrystalStatusSummaryPlot()
251  : cond::payloadInspector::PlotImage<EcalTPGCrystalStatus>("Ecal TPGCrystal Status Error Summary - map ") {
252  setSingleIov(true);
253  }
254 
255  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
256  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
257  std::shared_ptr<EcalTPGCrystalStatus> payload =
258  fetchPayload(std::get<1>(iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
259  unsigned int run = std::get<0>(iov); //referes to Time_t in iov.
260  TH2F* align; //pointer to align which is a 2D histogram
261 
262  int NbRows = 3;
263  int NbColumns = 3;
264 
265  if (payload.get()) { //payload is an iov retrieved from payload using hash.
266 
267  align = new TH2F("Ecal TPGCrystal Status Error Summary",
268  "EB/EE-/EE+ ErrorCount Total Number",
269  NbColumns,
270  0,
271  NbColumns,
272  NbRows,
273  0,
274  NbRows);
275 
276  long unsigned int ebErrorCount = 0;
277  long unsigned int ee1ErrorCount = 0;
278  long unsigned int ee2ErrorCount = 0;
279 
280  long unsigned int ebTotal = (payload->barrelItems()).size();
281  long unsigned int ee1Total = 0;
282  long unsigned int ee2Total = 0;
283 
284  getBarrelErrorSummary<EcalTPGCrystalStatusCode>(payload->barrelItems(), ebErrorCount);
285  getEndCapErrorSummary<EcalTPGCrystalStatusCode>(
286  payload->endcapItems(), ee1ErrorCount, ee2ErrorCount, ee1Total, ee2Total);
287 
288  double row = NbRows - 0.5;
289 
290  //EB summary values
291  align->Fill(0.5, row, 1);
292  align->Fill(1.5, row, ebErrorCount);
293  align->Fill(2.5, row, ebTotal);
294 
295  row--;
296  //EE- summary values
297  align->Fill(0.5, row, 2);
298  align->Fill(1.5, row, ee1ErrorCount);
299  align->Fill(2.5, row, ee1Total);
300 
301  row--;
302 
303  //EE+ summary values
304  align->Fill(0.5, row, 3);
305  align->Fill(1.5, row, ee2ErrorCount);
306  align->Fill(2.5, row, ee2Total);
307 
308  } // if payload.get()
309  else
310  return false;
311 
312  gStyle->SetPalette(1);
313  gStyle->SetOptStat(0);
314  TCanvas canvas("CC map", "CC map", 1000, 1000);
315  TLatex t1;
316  t1.SetNDC();
317  t1.SetTextAlign(26);
318  t1.SetTextSize(0.04);
319  t1.SetTextColor(2);
320  t1.DrawLatex(0.5, 0.96, Form("EcalTPGCrystalStatus Error Summary, IOV %i", run));
321 
322  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
323  pad->Draw();
324  pad->cd();
325  align->Draw("TEXT");
326 
327  drawTable(NbRows, NbColumns);
328 
329  align->GetXaxis()->SetTickLength(0.);
330  align->GetXaxis()->SetLabelSize(0.);
331  align->GetYaxis()->SetTickLength(0.);
332  align->GetYaxis()->SetLabelSize(0.);
333 
334  std::string ImageName(m_imageFileName);
335  canvas.SaveAs(ImageName.c_str());
336  return true;
337  } // fill method
338  };
339 
340 } // namespace
341 
342 // Register the classes as boost python plugin
344  PAYLOAD_INSPECTOR_CLASS(EcalTPGCrystalStatusPlot);
345  PAYLOAD_INSPECTOR_CLASS(EcalTPGCrystalStatusDiff);
346  PAYLOAD_INSPECTOR_CLASS(EcalTPGCrystalStatusSummaryPlot);
347 }
change_name.diff
diff
Definition: change_name.py:13
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
align
Definition: AlignableIndexer.h:30
kEEChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EBDetId
Definition: EBDetId.h:17
PayloadInspector.h
EBDetId.h
EEDetId.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalCondObjectContainer< EcalTPGCrystalStatusCode >
PayloadInspectorModule.h
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
DrawEB
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
PVValHelper::eta
Definition: PVValidationHelpers.h:69
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
w
const double w
Definition: UKUtility.cc:23
jets_cff.payload
payload
Definition: jets_cff.py:34
h
EcalBadCrystalsCount.h
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EcalDrawUtils.h
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
DDAxes::phi
heppy_batch.val
val
Definition: heppy_batch.py:351
writedatasetfile.run
run
Definition: writedatasetfile.py:27
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
drawTable
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
EcalTPGCrystalStatus.h
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
kEBChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13