CMS 3D CMS Logo

SiPixelVCal_PayloadInspector.cc
Go to the documentation of this file.
1 
17 
18 #include <memory>
19 #include <sstream>
20 #include <fmt/printf.h>
21 
22 // include ROOT
23 #include "TH2F.h"
24 #include "TH1F.h"
25 #include "TLegend.h"
26 #include "TCanvas.h"
27 #include "TLine.h"
28 #include "TStyle.h"
29 #include "TLatex.h"
30 #include "TPave.h"
31 #include "TPaveStats.h"
32 #include "TGaxis.h"
33 
34 namespace {
35 
36  namespace SiPixelVCalPI {
37  enum type { t_slope = 0, t_offset = 1 };
38  }
39 
40  /************************************************
41  1d histogram of SiPixelVCal of 1 IOV
42  *************************************************/
43  // inherit from one of the predefined plot class: Histogram1D
44  template <SiPixelVCalPI::type myType>
45  class SiPixelVCalValue : public cond::payloadInspector::Histogram1D<SiPixelVCal, cond::payloadInspector::SINGLE_IOV> {
46  public:
47  SiPixelVCalValue()
48  : cond::payloadInspector::Histogram1D<SiPixelVCal, cond::payloadInspector::SINGLE_IOV>(
49  "SiPixel VCal values",
50  "SiPixel VCal values",
51  100,
52  myType == SiPixelVCalPI::t_slope ? 40. : -700,
53  myType == SiPixelVCalPI::t_slope ? 60. : 0) {}
54 
55  bool fill() override {
56  auto tag = PlotBase::getTag<0>();
57  for (auto const &iov : tag.iovs) {
58  std::shared_ptr<SiPixelVCal> payload = Base::fetchPayload(std::get<1>(iov));
59  if (payload.get()) {
60  auto VCalMap_ = payload->getSlopeAndOffset();
61  for (const auto &element : VCalMap_) {
62  if (myType == SiPixelVCalPI::t_slope) {
63  fillWithValue(element.second.slope);
64  } else if (myType == SiPixelVCalPI::t_offset) {
65  fillWithValue(element.second.offset);
66  }
67  }
68  } // payload
69  } // iovs
70  return true;
71  } // fill
72  };
73 
74  using SiPixelVCalSlopeValue = SiPixelVCalValue<SiPixelVCalPI::t_slope>;
75  using SiPixelVCalOffsetValue = SiPixelVCalValue<SiPixelVCalPI::t_offset>;
76 
77  /************************************************
78  1d histogram of SiPixelVCal of 1 IOV
79  *************************************************/
80  class SiPixelVCalValues : public cond::payloadInspector::PlotImage<SiPixelVCal, cond::payloadInspector::SINGLE_IOV> {
81  public:
82  SiPixelVCalValues()
83  : cond::payloadInspector::PlotImage<SiPixelVCal, cond::payloadInspector::SINGLE_IOV>("SiPixelVCal Values") {}
84 
85  bool fill() override {
86  gStyle->SetOptStat("emr");
87 
88  auto tag = PlotBase::getTag<0>();
89  auto iov = tag.iovs.front();
90  std::shared_ptr<SiPixelVCal> payload = fetchPayload(std::get<1>(iov));
91  auto VCalMap_ = payload->getSlopeAndOffset();
92 
93  auto slopes = payload->getAllSlopes();
94  auto offsets = payload->getAllOffsets();
95 
96  /*
97  std::transform(VCalMap_.begin(),
98  VCalMap_.end(),
99  std::inserter(slopes,slopes.end()),
100  [](std::pair<unsigned int, SiPixelVCal::VCal> vcalentry) -> std::pair<uint32_t,float> { return std::make_pair(vcalentry.first,vcalentry.second.slope); });
101 
102  */
103 
104  auto s_extrema = SiPixelPI::findMinMaxInMap(slopes);
105  auto o_extrema = SiPixelPI::findMinMaxInMap(offsets);
106 
107  auto o_range = (o_extrema.second - o_extrema.first) / 10.;
108 
109  TCanvas canvas("Canv", "Canv", 1000, 1000);
110  canvas.Divide(1, 2);
111  canvas.cd();
112  auto h_slope =
113  std::make_shared<TH1F>("slope value",
114  "SiPixel VCal slope value;SiPixel VCal slope value [ADC/VCal units];# modules",
115  50,
116  s_extrema.first * 0.9,
117  s_extrema.second * 1.1);
118 
119  auto h_offset = std::make_shared<TH1F>("offset value",
120  "SiPixel VCal offset value;SiPixel VCal offset value [ADC];# modules",
121  50,
122  o_extrema.first - o_range,
123  o_extrema.second + o_range);
124 
125  for (unsigned int i = 1; i <= 2; i++) {
126  SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.06, 0.12, 0.08, 0.03);
127  }
128 
129  for (const auto &slope : slopes) {
130  h_slope->Fill(slope.second);
131  }
132 
133  for (const auto &offset : offsets) {
134  h_offset->Fill(offset.second);
135  }
136 
137  canvas.cd(1);
138  adjustHisto(h_slope);
139  canvas.Update();
140 
141  TLegend legend = TLegend(0.40, 0.83, 0.94, 0.93);
142  legend.SetHeader(("Payload hash: #bf{" + (std::get<1>(iov)) + "}").c_str(),
143  "C"); // option "C" allows to center the header
144  legend.AddEntry(h_slope.get(), ("TAG: " + tag.name).c_str(), "F");
145  legend.SetTextSize(0.035);
146  legend.SetLineColor(10);
147  legend.Draw("same");
148 
149  TPaveStats *st = (TPaveStats *)h_slope->FindObject("stats");
150  st->SetTextSize(0.035);
151  SiPixelPI::adjustStats(st, 0.15, 0.83, 0.30, 0.93);
152 
153  auto ltx = TLatex();
154  ltx.SetTextFont(62);
155  ltx.SetTextSize(0.05);
156  ltx.SetTextAlign(11);
157  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
158  1 - gPad->GetTopMargin() + 0.01,
159  ("SiPixel VCal Slope IOV:" + std::to_string(std::get<0>(iov))).c_str());
160 
161  canvas.cd(2);
162  adjustHisto(h_offset);
163  canvas.Update();
164  legend.Draw("same");
165 
166  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
167  1 - gPad->GetTopMargin() + 0.01,
168  ("SiPixel VCal Offset IOV:" + std::to_string(std::get<0>(iov))).c_str());
169 
170  TPaveStats *st2 = (TPaveStats *)h_offset->FindObject("stats");
171  st2->SetTextSize(0.035);
172  SiPixelPI::adjustStats(st2, 0.15, 0.83, 0.30, 0.93);
173 
174  std::string fileName(m_imageFileName);
175  canvas.SaveAs(fileName.c_str());
176 
177  return true;
178  }
179 
180  private:
181  void adjustHisto(const std::shared_ptr<TH1F> &histo) {
182  histo->SetTitle("");
183  histo->GetYaxis()->SetRangeUser(0., histo->GetMaximum() * 1.30);
184  histo->SetFillColor(kRed);
185  histo->SetMarkerStyle(20);
186  histo->SetMarkerSize(1);
187  histo->Draw("bar2");
189  histo->SetStats(true);
190  histo->GetYaxis()->SetTitleOffset(0.9);
191  }
192  };
193 
194  /************************************************
195  1d histogram of SiPixelVCal of 1 IOV per region
196  *************************************************/
197  template <bool isBarrel, SiPixelVCalPI::type myType>
198  class SiPixelVCalValuesPerRegion
199  : public cond::payloadInspector::PlotImage<SiPixelVCal, cond::payloadInspector::SINGLE_IOV> {
200  public:
201  SiPixelVCalValuesPerRegion()
202  : cond::payloadInspector::PlotImage<SiPixelVCal, cond::payloadInspector::SINGLE_IOV>(
203  "SiPixelVCal Values per region") {}
204 
205  bool fill() override {
206  gStyle->SetOptStat("emr");
207 
208  auto tag = PlotBase::getTag<0>();
209  auto iov = tag.iovs.front();
210  std::shared_ptr<SiPixelVCal> payload = fetchPayload(std::get<1>(iov));
212  if (myType == SiPixelVCalPI::t_slope) {
213  Map_ = payload->getAllSlopes();
214  } else {
215  Map_ = payload->getAllOffsets();
216  }
217  auto extrema = SiPixelPI::findMinMaxInMap(Map_);
218  auto range = (extrema.second - extrema.first) / 10.;
219 
220  TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200);
221  if (Map_.size() > SiPixelPI::phase1size) {
223  std::string fileName(this->m_imageFileName);
224  canvas.SaveAs(fileName.c_str());
225  return false;
226  }
227 
228  canvas.cd();
229 
230  SiPixelPI::PhaseInfo phaseInfo(Map_.size());
231  const char *path_toTopologyXML = phaseInfo.pathToTopoXML();
232 
233  TrackerTopology tTopo =
235 
236  auto myPlots = PixelRegions::PixelRegionContainers(&tTopo, phaseInfo.phase());
237  myPlots.bookAll((myType == SiPixelVCalPI::t_slope) ? "SiPixel VCal slope value" : "SiPixel VCal offset value",
238  (myType == SiPixelVCalPI::t_slope) ? "SiPixel VCal slope value [ADC/VCal units]"
239  : "SiPixel VCal offset value [ADC]",
240  "#modules",
241  50,
242  extrema.first - range,
243  extrema.second + range);
244 
245  canvas.Modified();
246 
247  for (const auto &element : Map_) {
248  myPlots.fill(element.first, element.second);
249  }
250 
251  myPlots.beautify();
252  myPlots.draw(canvas, isBarrel);
253 
254  TLegend legend = TLegend(0.40, 0.88, 0.93, 0.90);
255  legend.SetHeader(("Hash: #bf{" + (std::get<1>(iov)) + "}").c_str(),
256  "C"); // option "C" allows to center the header
257  //legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL");
258  legend.SetTextSize(0.025);
259  legend.SetLineColor(10);
260 
261  unsigned int maxPads = isBarrel ? 4 : 12;
262  for (unsigned int c = 1; c <= maxPads; c++) {
263  canvas.cd(c);
264  SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
265  legend.Draw("same");
266  canvas.cd(c)->Update();
267  }
268 
269  myPlots.stats();
270 
271  auto ltx = TLatex();
272  ltx.SetTextFont(62);
273  ltx.SetTextSize(0.05);
274  ltx.SetTextAlign(11);
275 
276  for (unsigned int c = 1; c <= maxPads; c++) {
277  auto index = isBarrel ? c - 1 : c + 3;
278 
279  canvas.cd(c);
280  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
281  1 - gPad->GetTopMargin() + 0.01,
282  (PixelRegions::IDlabels.at(index) + ", IOV:" + std::to_string(std::get<0>(iov))).c_str());
283  }
284 
285  std::string fileName(m_imageFileName);
286  canvas.SaveAs(fileName.c_str());
287 
288  return true;
289  }
290  };
291 
292  using SiPixelVCalSlopeValuesBarrel = SiPixelVCalValuesPerRegion<true, SiPixelVCalPI::t_slope>;
293  using SiPixelVCalSlopeValuesEndcap = SiPixelVCalValuesPerRegion<false, SiPixelVCalPI::t_slope>;
294 
295  using SiPixelVCalOffsetValuesBarrel = SiPixelVCalValuesPerRegion<true, SiPixelVCalPI::t_offset>;
296  using SiPixelVCalOffsetValuesEndcap = SiPixelVCalValuesPerRegion<false, SiPixelVCalPI::t_offset>;
297 
298  /************************************************
299  1d histogram of SiPixelVCal (slope or offset) of 2 IOV per region
300  *************************************************/
301  template <bool isBarrel, int ntags, SiPixelVCalPI::type myType>
302  class SiPixelVCalValuesComparisonPerRegion
303  : public cond::payloadInspector::PlotImage<SiPixelVCal, cond::payloadInspector::MULTI_IOV, ntags> {
304  public:
305  SiPixelVCalValuesComparisonPerRegion()
306  : cond::payloadInspector::PlotImage<SiPixelVCal, cond::payloadInspector::MULTI_IOV, ntags>(
307  Form("SiPixelVCal Values Comparisons per region %i tags(s)", ntags)) {}
308 
309  bool fill() override {
310  gStyle->SetOptStat("emr");
311 
312  // trick to deal with the multi-ioved tag and two tag case at the same time
313  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
314  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
315  std::string l_tagname = "";
316  auto firstiov = theIOVs.front();
317  std::tuple<cond::Time_t, cond::Hash> lastiov;
318 
319  // we don't support (yet) comparison with more than 2 tags
320  assert(this->m_plotAnnotations.ntags < 3);
321 
322  if (this->m_plotAnnotations.ntags == 2) {
323  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
324  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
325  lastiov = tag2iovs.front();
326  } else {
327  lastiov = theIOVs.back();
328  }
329 
332 
333  std::shared_ptr<SiPixelVCal> last_payload = this->fetchPayload(std::get<1>(lastiov));
334  if (myType == SiPixelVCalPI::t_slope) {
335  l_Map_ = last_payload->getAllSlopes();
336  } else {
337  l_Map_ = last_payload->getAllOffsets();
338  }
339  auto l_extrema = SiPixelPI::findMinMaxInMap(l_Map_);
340 
341  std::shared_ptr<SiPixelVCal> first_payload = this->fetchPayload(std::get<1>(firstiov));
342  if (myType == SiPixelVCalPI::t_slope) {
343  f_Map_ = first_payload->getAllSlopes();
344  } else {
345  f_Map_ = first_payload->getAllOffsets();
346  }
347 
348  auto f_extrema = SiPixelPI::findMinMaxInMap(f_Map_);
349 
350  auto max = (l_extrema.second > f_extrema.second) ? l_extrema.second : f_extrema.second;
351  auto min = (l_extrema.first < f_extrema.first) ? l_extrema.first : f_extrema.first;
352 
353  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
354  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
355 
356  TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200);
357  if ((f_Map_.size() > SiPixelPI::phase1size) || (l_Map_.size() > SiPixelPI::phase1size)) {
358  SiPixelPI::displayNotSupported(canvas, std::max(f_Map_.size(), l_Map_.size()));
359  std::string fileName(this->m_imageFileName);
360  canvas.SaveAs(fileName.c_str());
361  return false;
362  }
363 
364  canvas.cd();
365 
366  SiPixelPI::PhaseInfo l_phaseInfo(l_Map_.size());
367  SiPixelPI::PhaseInfo f_phaseInfo(f_Map_.size());
368 
369  // deal with last IOV
370 
371  const char *path_toTopologyXML = l_phaseInfo.pathToTopoXML();
372 
373  auto l_tTopo =
375 
376  auto l_myPlots = PixelRegions::PixelRegionContainers(&l_tTopo, l_phaseInfo.phase());
377  l_myPlots.bookAll(
378  fmt::sprintf("SiPixel VCal %s,last", (myType == SiPixelVCalPI::t_slope ? "slope" : "offset")),
379  fmt::sprintf("SiPixel VCal %s", (myType == SiPixelVCalPI::t_slope ? " slope [ADC/VCal]" : " offset [ADC]")),
380  "#modules",
381  50,
382  min * 0.9,
383  max * 1.1);
384 
385  for (const auto &element : l_Map_) {
386  l_myPlots.fill(element.first, element.second);
387  }
388 
389  l_myPlots.beautify();
390  l_myPlots.draw(canvas, isBarrel, "bar2", true);
391 
392  // deal with first IOV
393 
394  path_toTopologyXML = f_phaseInfo.pathToTopoXML();
395 
396  auto f_tTopo =
398 
399  auto f_myPlots = PixelRegions::PixelRegionContainers(&f_tTopo, f_phaseInfo.phase());
400  f_myPlots.bookAll(
401  fmt::sprintf("SiPixel VCal %s,first", (myType == SiPixelVCalPI::t_slope ? "slope" : "offset")),
402  fmt::sprintf("SiPixel VCal %s", (myType == SiPixelVCalPI::t_slope ? " slope [ADC/VCal]" : " offset [ADC]")),
403  "#modules",
404  50,
405  min * 0.9,
406  max * 1.1);
407 
408  for (const auto &element : f_Map_) {
409  f_myPlots.fill(element.first, element.second);
410  }
411 
412  f_myPlots.beautify(kAzure, kBlue);
413  f_myPlots.draw(canvas, isBarrel, "HISTsames", true);
414 
415  // rescale the y-axis ranges in order to fit the canvas
416  l_myPlots.rescaleMax(f_myPlots);
417 
418  // done dealing with IOVs
419 
420  auto colorTag = isBarrel ? PixelRegions::L1 : PixelRegions::Rm1l;
421  std::unique_ptr<TLegend> legend;
422  if (this->m_plotAnnotations.ntags == 2) {
423  legend = std::make_unique<TLegend>(0.36, 0.86, 0.94, 0.92);
424  legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + l_tagname + "}").c_str(), "F");
425  legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + f_tagname + "}").c_str(), "F");
426  legend->SetTextSize(0.024);
427  } else {
428  legend = std::make_unique<TLegend>(0.58, 0.80, 0.90, 0.92);
429  legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + lastIOVsince + "}").c_str(), "F");
430  legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + firstIOVsince + "}").c_str(), "F");
431  legend->SetTextSize(0.040);
432  }
433  legend->SetLineColor(10);
434 
435  unsigned int maxPads = isBarrel ? 4 : 12;
436  for (unsigned int c = 1; c <= maxPads; c++) {
437  canvas.cd(c);
438  SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
439  legend->Draw("same");
440  canvas.cd(c)->Update();
441  }
442 
443  f_myPlots.stats(0);
444  l_myPlots.stats(1);
445 
446  auto ltx = TLatex();
447  ltx.SetTextFont(62);
448  ltx.SetTextSize(0.05);
449  ltx.SetTextAlign(11);
450 
451  for (unsigned int c = 1; c <= maxPads; c++) {
452  auto index = isBarrel ? c - 1 : c + 3;
453  canvas.cd(c);
454  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
455  1 - gPad->GetTopMargin() + 0.01,
456  (PixelRegions::IDlabels.at(index) + " : #color[4]{" + std::to_string(std::get<0>(firstiov)) +
457  "} vs #color[2]{" + std::to_string(std::get<0>(lastiov)) + "}")
458  .c_str());
459  }
460 
461  std::string fileName(this->m_imageFileName);
462  canvas.SaveAs(fileName.c_str());
463 
464  return true;
465  }
466  };
467 
468  using SiPixelVCalSlopesBarrelCompareSingleTag = SiPixelVCalValuesComparisonPerRegion<true, 1, SiPixelVCalPI::t_slope>;
469  using SiPixelVCalOffsetsBarrelCompareSingleTag =
470  SiPixelVCalValuesComparisonPerRegion<true, 1, SiPixelVCalPI::t_offset>;
471 
472  using SiPixelVCalSlopesEndcapCompareSingleTag =
473  SiPixelVCalValuesComparisonPerRegion<false, 1, SiPixelVCalPI::t_slope>;
474  using SiPixelVCalOffsetsEndcapCompareSingleTag =
475  SiPixelVCalValuesComparisonPerRegion<false, 1, SiPixelVCalPI::t_offset>;
476 
477  using SiPixelVCalSlopesBarrelCompareTwoTags = SiPixelVCalValuesComparisonPerRegion<true, 2, SiPixelVCalPI::t_slope>;
478  using SiPixelVCalOffsetsBarrelCompareTwoTags = SiPixelVCalValuesComparisonPerRegion<true, 2, SiPixelVCalPI::t_offset>;
479 
480  using SiPixelVCalSlopesEndcapCompareTwoTags = SiPixelVCalValuesComparisonPerRegion<false, 2, SiPixelVCalPI::t_slope>;
481  using SiPixelVCalOffsetsEndcapCompareTwoTags =
482  SiPixelVCalValuesComparisonPerRegion<false, 2, SiPixelVCalPI::t_offset>;
483 
484  /************************************************
485  1d histogram of SiPixelVCal of 1 IOV
486  *************************************************/
487 
488  template <SiPixelVCalPI::type myType>
489  class SiPixelVCalValueComparisonBase : public cond::payloadInspector::PlotImage<SiPixelVCal> {
490  public:
491  SiPixelVCalValueComparisonBase()
492  : cond::payloadInspector::PlotImage<SiPixelVCal>("SiPixelVCal Values Comparison") {}
493  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash>> &iovs) override {
494  TH1F::SetDefaultSumw2(true);
495  std::vector<std::tuple<cond::Time_t, cond::Hash>> sorted_iovs = iovs;
496  // make absolute sure the IOVs are sortd by since
497  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const &t1, auto const &t2) {
498  return std::get<0>(t1) < std::get<0>(t2);
499  });
500  auto firstiov = sorted_iovs.front();
501  auto lastiov = sorted_iovs.back();
502 
505 
506  std::shared_ptr<SiPixelVCal> last_payload = fetchPayload(std::get<1>(lastiov));
507  if (myType == SiPixelVCalPI::t_slope) {
508  l_Map_ = last_payload->getAllSlopes();
509  } else {
510  l_Map_ = last_payload->getAllOffsets();
511  }
512  auto l_extrema = SiPixelPI::findMinMaxInMap(l_Map_);
513 
514  std::shared_ptr<SiPixelVCal> first_payload = fetchPayload(std::get<1>(firstiov));
515  if (myType == SiPixelVCalPI::t_slope) {
516  f_Map_ = first_payload->getAllSlopes();
517  } else {
518  f_Map_ = first_payload->getAllOffsets();
519  }
520  auto f_extrema = SiPixelPI::findMinMaxInMap(f_Map_);
521 
522  auto max = (l_extrema.second > f_extrema.second) ? l_extrema.second : f_extrema.second;
523  auto min = (l_extrema.first < f_extrema.first) ? l_extrema.first : f_extrema.first;
524 
525  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
526  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
527 
528  TCanvas canvas("Canv", "Canv", 1200, 1000);
529  canvas.cd();
530  auto hfirst = std::unique_ptr<TH1F>(
531  new TH1F("value_first",
532  fmt::sprintf("SiPixel VCal %s value;SiPixel VCal %s ;# modules",
533  (myType == SiPixelVCalPI::t_slope ? "slope" : "offset"),
534  (myType == SiPixelVCalPI::t_slope ? " slope [ADC/VCal]" : " offset [ADC]"))
535  .c_str(),
536  50,
537  min * 0.9,
538  max * 1.1));
539  hfirst->SetStats(false);
540 
541  auto hlast = std::unique_ptr<TH1F>(
542  new TH1F("value_last",
543  fmt::sprintf("SiPixel VCal %s value;SiPixel VCal %s ;# modules",
544  (myType == SiPixelVCalPI::t_slope ? "slope" : "offset"),
545  (myType == SiPixelVCalPI::t_slope ? " slope [ADC/VCal]" : " offset [ADC]"))
546  .c_str(),
547  50,
548  min * 0.9,
549  max * 1.1));
550  hlast->SetStats(false);
551 
552  SiPixelPI::adjustCanvasMargins(canvas.cd(), 0.06, 0.12, 0.12, 0.05);
553  canvas.Modified();
554 
555  for (const auto &element : f_Map_) {
556  hfirst->Fill(element.second);
557  }
558 
559  for (const auto &element : l_Map_) {
560  hlast->Fill(element.second);
561  }
562 
563  auto extrema = SiPixelPI::getExtrema(hfirst.get(), hlast.get());
564  hfirst->GetYaxis()->SetRangeUser(extrema.first, extrema.second * 1.10);
565 
566  hfirst->SetTitle("");
567  hfirst->SetFillColor(kRed);
568  hfirst->SetBarWidth(0.95);
569  hfirst->Draw("histbar");
570 
571  hlast->SetTitle("");
572  hlast->SetFillColorAlpha(kBlue, 0.20);
573  hlast->SetBarWidth(0.95);
574  hlast->Draw("histbarsame");
575 
576  SiPixelPI::makeNicePlotStyle(hfirst.get());
577  SiPixelPI::makeNicePlotStyle(hlast.get());
578 
579  canvas.Update();
580 
581  TLegend legend = TLegend(0.30, 0.86, 0.95, 0.94);
582  legend.AddEntry(hfirst.get(), ("payload: #color[2]{" + std::get<1>(firstiov) + "}").c_str(), "F");
583  legend.AddEntry(hlast.get(), ("payload: #color[4]{" + std::get<1>(lastiov) + "}").c_str(), "F");
584  legend.SetTextSize(0.025);
585  legend.Draw("same");
586 
587  auto ltx = TLatex();
588  ltx.SetTextFont(62);
589  ltx.SetTextSize(0.047);
590  ltx.SetTextAlign(11);
591  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
592  1 - gPad->GetTopMargin() + 0.01,
593  ("SiPixel VCal IOV: #color[2]{" + std::to_string(std::get<0>(firstiov)) +
594  "} vs IOV: #color[4]{" + std::to_string(std::get<0>(lastiov)) + "}")
595  .c_str());
596 
597  std::string fileName(m_imageFileName);
598  canvas.SaveAs(fileName.c_str());
599 
600  return true;
601  }
602  };
603 
604  template <SiPixelVCalPI::type myType>
605  class SiPixelVCalValueComparisonSingleTag : public SiPixelVCalValueComparisonBase<myType> {
606  public:
607  SiPixelVCalValueComparisonSingleTag() : SiPixelVCalValueComparisonBase<myType>() { this->setSingleIov(false); }
608  };
609 
610  template <SiPixelVCalPI::type myType>
611  class SiPixelVCalValueComparisonTwoTags : public SiPixelVCalValueComparisonBase<myType> {
612  public:
613  SiPixelVCalValueComparisonTwoTags() : SiPixelVCalValueComparisonBase<myType>() { this->setTwoTags(true); }
614  };
615 
616  using SiPixelVCalSlopesComparisonSingleTag = SiPixelVCalValueComparisonSingleTag<SiPixelVCalPI::t_slope>;
617  using SiPixelVCalOffsetsComparisonSingleTag = SiPixelVCalValueComparisonSingleTag<SiPixelVCalPI::t_offset>;
618 
619  using SiPixelVCalSlopesComparisonTwoTags = SiPixelVCalValueComparisonTwoTags<SiPixelVCalPI::t_slope>;
620  using SiPixelVCalOffsetsComparisonTwoTags = SiPixelVCalValueComparisonTwoTags<SiPixelVCalPI::t_offset>;
621 
622 } // namespace
623 
625  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopeValue);
626  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetValue);
627  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalValues);
628  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopeValuesBarrel);
629  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopeValuesEndcap);
630  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetValuesBarrel);
631  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetValuesEndcap);
632  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopesBarrelCompareSingleTag);
633  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetsBarrelCompareSingleTag);
634  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopesEndcapCompareSingleTag);
635  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetsEndcapCompareSingleTag);
636  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopesBarrelCompareTwoTags);
637  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetsBarrelCompareTwoTags);
638  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopesEndcapCompareTwoTags);
639  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetsEndcapCompareTwoTags);
640  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopesComparisonSingleTag);
641  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetsComparisonSingleTag);
642  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalSlopesComparisonTwoTags);
643  PAYLOAD_INSPECTOR_CLASS(SiPixelVCalOffsetsComparisonTwoTags);
644 }
PixelRegionContainers.h
PixelRegions::L1
Definition: PixelRegionContainers.h:32
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SiPixelPI::PhaseInfo::pathToTopoXML
const char * pathToTopoXML()
Definition: SiPixelPayloadInspectorHelper.h:81
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelVCal.h
cond::payloadInspector::Histogram1D
Histogram1< float, PayloadType, UNSPECIFIED_IOV > Histogram1D
Definition: PayloadInspector.h:790
cond::payloadInspector::Histogram1
Definition: PayloadInspector.h:711
min
T min(T a, T b)
Definition: MathUtil.h:58
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
TrackerTopology
Definition: TrackerTopology.h:16
PayloadInspector.h
PixelRegions::Rm1l
Definition: PixelRegionContainers.h:34
SiPixelVCalPI
Definition: SiPixelVCal_PayloadInspector.cc:36
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
cms::cuda::assert
assert(be >=bs)
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
SiPixelPI::displayNotSupported
void displayNotSupported(TCanvas &canv, const unsigned int size)
Definition: SiPixelPayloadInspectorHelper.h:781
PayloadInspectorModule.h
FileInPath.h
edm::FileInPath
Definition: FileInPath.h:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
StandaloneTrackerTopology.h
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
PixelRegions::PixelRegionContainers
Definition: PixelRegionContainers.h:238
mps_fire.end
end
Definition: mps_fire.py:242
jets_cff.payload
payload
Definition: jets_cff.py:32
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
cond::payloadInspector::Plot2D< PayloadType, AxisType, AxisType, IOV_M, 1 >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:490
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelVCal
Definition: SiPixelVCal.h:9
cond
Definition: plugin.cc:23
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
Time.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
SiPixelPI::phase1size
static const unsigned int phase1size
Definition: SiPixelPayloadInspectorHelper.h:43
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:905
listHistos.legend
legend
Definition: listHistos.py:41
cond::payloadInspector::MULTI_IOV
Definition: PayloadInspector.h:295
PixelRegions::IDlabels
const std::vector< std::string > IDlabels
Definition: PixelRegionContainers.h:62
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
SiPixelPI::PhaseInfo
Definition: SiPixelPayloadInspectorHelper.h:48
SiPixelVCal::mapToDetId
std::map< uint32_t, float > mapToDetId
Definition: SiPixelVCal.h:14
SiPixelPI::adjustStats
void adjustStats(TPaveStats *stats, float X1, float Y1, float X2, float Y2)
Definition: SiPixelPayloadInspectorHelper.h:522
cond::payloadInspector::Histogram1::fill
bool fill() override
Definition: PayloadInspector.h:763
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:894
SiPixelPI::makeNicePlotStyle
void makeNicePlotStyle(TH1 *hist)
Definition: SiPixelPayloadInspectorHelper.h:548
SiPixelPI::getExtrema
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
Definition: SiPixelPayloadInspectorHelper.h:532
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
unpackBuffers-CaloStage1.offsets
offsets
Definition: unpackBuffers-CaloStage1.py:127
SiPixelPayloadInspectorHelper.h
cond::payloadInspector::Histogram1::fillWithValue
void fillWithValue(AxisType value, AxisType weight=1)
Definition: PayloadInspector.h:747
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
cond::payloadInspector::SINGLE_IOV
Definition: PayloadInspector.h:295
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
StandaloneTrackerTopology::fromTrackerParametersXMLFile
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Definition: StandaloneTrackerTopology.cc:168
PixelRegions::PixelRegionContainers::bookAll
void bookAll(std::string title_label, std::string x_label, std::string y_label, const int nbins, const float xmin, const float xmax)
Definition: PixelRegionContainers.h:263
SiPixelPI::adjustCanvasMargins
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Definition: SiPixelPayloadInspectorHelper.h:508
SiPixelPI::findMinMaxInMap
std::pair< T, T > findMinMaxInMap(const std::map< unsigned int, T > &theMap)
Definition: SiPixelPayloadInspectorHelper.h:796