20 #include <fmt/printf.h> 31 #include "TPaveStats.h" 39 enum type { t_slope = 0, t_offset = 1 };
46 template <SiPixelVCalPI::type myType>
47 class SiPixelVCalValue :
public Histogram1D<SiPixelVCal, SINGLE_IOV> {
51 "SiPixel VCal values",
56 bool fill()
override {
57 auto tag = PlotBase::getTag<0>();
58 for (
auto const &iov :
tag.iovs) {
59 std::shared_ptr<SiPixelVCal>
payload = Base::fetchPayload(std::get<1>(iov));
61 auto VCalMap_ =
payload->getSlopeAndOffset();
62 for (
const auto &element : VCalMap_) {
63 if (myType == SiPixelVCalPI::t_slope) {
64 fillWithValue(element.second.slope);
65 }
else if (myType == SiPixelVCalPI::t_offset) {
66 fillWithValue(element.second.offset);
75 using SiPixelVCalSlopeValue = SiPixelVCalValue<SiPixelVCalPI::t_slope>;
76 using SiPixelVCalOffsetValue = SiPixelVCalValue<SiPixelVCalPI::t_offset>;
81 class SiPixelVCalValues :
public PlotImage<SiPixelVCal, SINGLE_IOV> {
85 bool fill()
override {
86 gStyle->SetOptStat(
"emr");
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();
93 auto slopes =
payload->getAllSlopes();
107 auto o_range = (o_extrema.second - o_extrema.first) / 10.;
109 TCanvas
canvas(
"Canv",
"Canv", 1000, 1000);
113 std::make_shared<TH1F>(
"slope value",
114 "SiPixel VCal slope value;SiPixel VCal slope value [ADC/VCal units];# modules",
116 s_extrema.first * 0.9,
117 s_extrema.second * 1.1);
119 auto h_offset = std::make_shared<TH1F>(
"offset value",
120 "SiPixel VCal offset value;SiPixel VCal offset value [ADC];# modules",
122 o_extrema.first - o_range,
123 o_extrema.second + o_range);
125 for (
unsigned int i = 1;
i <= 2;
i++) {
129 for (
const auto &
slope : slopes) {
130 h_slope->Fill(
slope.second);
134 h_offset->Fill(
offset.second);
138 adjustHisto(h_slope);
141 TLegend
legend = TLegend(0.40, 0.83, 0.94, 0.93);
142 legend.SetHeader((
"Payload hash: #bf{" + (std::get<1>(iov)) +
"}").c_str(),
144 legend.AddEntry(h_slope.get(), (
"TAG: " +
tag.name).c_str(),
"F");
145 legend.SetTextSize(0.035);
149 TPaveStats *st = (TPaveStats *)h_slope->FindObject(
"stats");
150 st->SetTextSize(0.035);
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());
162 adjustHisto(h_offset);
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());
170 TPaveStats *st2 = (TPaveStats *)h_offset->FindObject(
"stats");
171 st2->SetTextSize(0.035);
181 void adjustHisto(
const std::shared_ptr<TH1F> &
histo) {
183 histo->GetYaxis()->SetRangeUser(0.,
histo->GetMaximum() * 1.30);
184 histo->SetFillColor(kRed);
185 histo->SetMarkerStyle(20);
186 histo->SetMarkerSize(1);
189 histo->SetStats(
true);
190 histo->GetYaxis()->SetTitleOffset(0.9);
197 template <
bool isBarrel, SiPixelVCalPI::type myType>
198 class SiPixelVCalValuesPerRegion :
public PlotImage<SiPixelVCal, SINGLE_IOV> {
202 bool fill()
override {
203 gStyle->SetOptStat(
"emr");
205 auto tag = PlotBase::getTag<0>();
207 auto iov =
tag.iovs.front();
208 std::shared_ptr<SiPixelVCal>
payload = fetchPayload(std::get<1>(iov));
210 if (myType == SiPixelVCalPI::t_slope) {
211 Map_ =
payload->getAllSlopes();
213 Map_ =
payload->getAllOffsets();
216 auto range = (extrema.second - extrema.first) / 10.;
235 myPlots.
bookAll((myType == SiPixelVCalPI::t_slope) ?
"SiPixel VCal slope value" :
"SiPixel VCal offset value",
236 (myType == SiPixelVCalPI::t_slope) ?
"SiPixel VCal slope value [ADC/VCal units]" 237 :
"SiPixel VCal offset value [ADC]",
240 extrema.first -
range,
241 extrema.second +
range);
245 for (
const auto &element : Map_) {
246 myPlots.fill(element.first, element.second);
252 TLegend
legend = TLegend(0.40, 0.88, 0.93, 0.90);
253 legend.SetHeader((
"Hash: #bf{" + (std::get<1>(iov)) +
"}").c_str(),
256 legend.SetTextSize(0.025);
259 unsigned int maxPads =
isBarrel ? 4 : 12;
260 for (
unsigned int c = 1;
c <= maxPads;
c++) {
271 ltx.SetTextSize(0.05);
272 ltx.SetTextAlign(11);
274 for (
unsigned int c = 1;
c <= maxPads;
c++) {
278 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
279 1 - gPad->GetTopMargin() + 0.01,
280 fmt::sprintf(
"%s, #color[2]{%s, IOV: %s}",
294 using SiPixelVCalSlopeValuesBarrel = SiPixelVCalValuesPerRegion<true, SiPixelVCalPI::t_slope>;
295 using SiPixelVCalSlopeValuesEndcap = SiPixelVCalValuesPerRegion<false, SiPixelVCalPI::t_slope>;
297 using SiPixelVCalOffsetValuesBarrel = SiPixelVCalValuesPerRegion<true, SiPixelVCalPI::t_offset>;
298 using SiPixelVCalOffsetValuesEndcap = SiPixelVCalValuesPerRegion<false, SiPixelVCalPI::t_offset>;
303 template <
bool isBarrel, SiPixelVCalPI::type myType, IOVMultiplicity nIOVs,
int ntags>
304 class SiPixelVCalValuesCompareSubdet :
public PlotImage<SiPixelVCal, nIOVs, ntags> {
306 SiPixelVCalValuesCompareSubdet()
307 :
PlotImage<
SiPixelVCal, nIOVs, ntags>(Form(
"SiPixelVCal Values Comparisons by Subdet %i tags(s)", ntags)) {}
309 bool fill()
override {
310 gStyle->SetOptStat(
"emr");
313 auto theIOVs = PlotBase::getTag<0>().iovs;
314 auto f_tagname = PlotBase::getTag<0>().
name;
316 auto firstiov = theIOVs.front();
317 std::tuple<cond::Time_t, cond::Hash> lastiov;
320 assert(this->m_plotAnnotations.ntags < 3);
322 if (this->m_plotAnnotations.ntags == 2) {
323 auto tag2iovs = PlotBase::getTag<1>().iovs;
324 l_tagname = PlotBase::getTag<1>().
name;
325 lastiov = tag2iovs.front();
327 lastiov = theIOVs.back();
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();
337 l_Map_ = last_payload->getAllOffsets();
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();
345 f_Map_ = first_payload->getAllOffsets();
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;
371 const char *path_toTopologyXML = l_phaseInfo.
pathToTopoXML();
380 fmt::sprintf(
"SiPixel VCal %s,last", (myType == SiPixelVCalPI::t_slope ?
"slope" :
"offset")),
381 fmt::sprintf(
"SiPixel VCal %s", (myType == SiPixelVCalPI::t_slope ?
" slope [ADC/VCal]" :
" offset [ADC]")),
387 for (
const auto &element : l_Map_) {
388 l_myPlots.fill(element.first, element.second);
391 l_myPlots.beautify();
396 path_toTopologyXML = f_phaseInfo.pathToTopoXML();
403 fmt::sprintf(
"SiPixel VCal %s,first", (myType == SiPixelVCalPI::t_slope ?
"slope" :
"offset")),
404 fmt::sprintf(
"SiPixel VCal %s", (myType == SiPixelVCalPI::t_slope ?
" slope [ADC/VCal]" :
" offset [ADC]")),
410 for (
const auto &element : f_Map_) {
411 f_myPlots.fill(element.first, element.second);
414 f_myPlots.beautify(kAzure, kBlue);
418 l_myPlots.rescaleMax(f_myPlots);
423 std::unique_ptr<TLegend>
legend;
424 if (this->m_plotAnnotations.ntags == 2) {
425 legend = std::make_unique<TLegend>(0.36, 0.86, 0.94, 0.92);
426 legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), (
"#color[2]{" + l_tagname +
"}").c_str(),
"F");
427 legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), (
"#color[4]{" + f_tagname +
"}").c_str(),
"F");
428 legend->SetTextSize(0.024);
430 legend = std::make_unique<TLegend>(0.58, 0.80, 0.90, 0.92);
431 legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), (
"#color[2]{" + lastIOVsince +
"}").c_str(),
"F");
432 legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), (
"#color[4]{" + firstIOVsince +
"}").c_str(),
"F");
433 legend->SetTextSize(0.040);
437 unsigned int maxPads =
isBarrel ? 4 : 12;
438 for (
unsigned int c = 1;
c <= maxPads;
c++) {
450 ltx.SetTextSize(0.05);
451 ltx.SetTextAlign(11);
453 for (
unsigned int c = 1;
c <= maxPads;
c++) {
456 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
457 1 - gPad->GetTopMargin() + 0.01,
470 using SiPixelVCalSlopesBarrelCompareSingleTag =
471 SiPixelVCalValuesCompareSubdet<true, SiPixelVCalPI::t_slope, MULTI_IOV, 1>;
472 using SiPixelVCalOffsetsBarrelCompareSingleTag =
473 SiPixelVCalValuesCompareSubdet<true, SiPixelVCalPI::t_offset, MULTI_IOV, 1>;
475 using SiPixelVCalSlopesEndcapCompareSingleTag =
476 SiPixelVCalValuesCompareSubdet<false, SiPixelVCalPI::t_slope, MULTI_IOV, 1>;
477 using SiPixelVCalOffsetsEndcapCompareSingleTag =
478 SiPixelVCalValuesCompareSubdet<false, SiPixelVCalPI::t_offset, MULTI_IOV, 1>;
480 using SiPixelVCalSlopesBarrelCompareTwoTags =
481 SiPixelVCalValuesCompareSubdet<true, SiPixelVCalPI::t_slope, SINGLE_IOV, 2>;
482 using SiPixelVCalOffsetsBarrelCompareTwoTags =
483 SiPixelVCalValuesCompareSubdet<true, SiPixelVCalPI::t_offset, SINGLE_IOV, 2>;
485 using SiPixelVCalSlopesEndcapCompareTwoTags =
486 SiPixelVCalValuesCompareSubdet<false, SiPixelVCalPI::t_slope, SINGLE_IOV, 2>;
487 using SiPixelVCalOffsetsEndcapCompareTwoTags =
488 SiPixelVCalValuesCompareSubdet<false, SiPixelVCalPI::t_offset, SINGLE_IOV, 2>;
494 template <SiPixelVCalPI::type myType, IOVMultiplicity nIOVs,
int ntags>
495 class SiPixelVCalValueComparisonBase :
public PlotImage<SiPixelVCal, nIOVs, ntags> {
497 SiPixelVCalValueComparisonBase()
498 :
PlotImage<
SiPixelVCal, nIOVs, ntags>(Form(
"SiPixelVCal Synoptic Values Comparison %i tag(s)", ntags)) {}
500 bool fill()
override {
501 TH1F::SetDefaultSumw2(
true);
504 auto theIOVs = PlotBase::getTag<0>().iovs;
505 auto f_tagname = PlotBase::getTag<0>().
name;
507 auto firstiov = theIOVs.front();
508 std::tuple<cond::Time_t, cond::Hash> lastiov;
511 assert(this->m_plotAnnotations.ntags < 3);
513 if (this->m_plotAnnotations.ntags == 2) {
514 auto tag2iovs = PlotBase::getTag<1>().iovs;
515 l_tagname = PlotBase::getTag<1>().
name;
516 lastiov = tag2iovs.front();
518 lastiov = theIOVs.back();
524 std::shared_ptr<SiPixelVCal> last_payload = this->fetchPayload(std::get<1>(lastiov));
525 if (myType == SiPixelVCalPI::t_slope) {
526 l_Map_ = last_payload->getAllSlopes();
528 l_Map_ = last_payload->getAllOffsets();
532 std::shared_ptr<SiPixelVCal> first_payload = this->fetchPayload(std::get<1>(firstiov));
533 if (myType == SiPixelVCalPI::t_slope) {
534 f_Map_ = first_payload->getAllSlopes();
536 f_Map_ = first_payload->getAllOffsets();
540 auto max = (l_extrema.second > f_extrema.second) ? l_extrema.second : f_extrema.second;
541 auto min = (l_extrema.first < f_extrema.first) ? l_extrema.first : f_extrema.first;
547 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
549 auto hfirst = std::unique_ptr<TH1F>(
550 new TH1F(
"value_first",
551 fmt::sprintf(
"SiPixel VCal %s value;SiPixel VCal %s ;# modules",
552 (myType == SiPixelVCalPI::t_slope ?
"slope" :
"offset"),
553 (myType == SiPixelVCalPI::t_slope ?
" slope [ADC/VCal]" :
" offset [ADC]"))
558 hfirst->SetStats(
false);
560 auto hlast = std::unique_ptr<TH1F>(
561 new TH1F(
"value_last",
562 fmt::sprintf(
"SiPixel VCal %s value;SiPixel VCal %s ;# modules",
563 (myType == SiPixelVCalPI::t_slope ?
"slope" :
"offset"),
564 (myType == SiPixelVCalPI::t_slope ?
" slope [ADC/VCal]" :
" offset [ADC]"))
569 hlast->SetStats(
false);
574 for (
const auto &element : f_Map_) {
575 hfirst->Fill(element.second);
578 for (
const auto &element : l_Map_) {
579 hlast->Fill(element.second);
583 hfirst->GetYaxis()->SetRangeUser(extrema.first, extrema.second * 1.10);
585 hfirst->SetTitle(
"");
586 hfirst->SetFillColor(kRed);
587 hfirst->SetBarWidth(0.95);
588 hfirst->Draw(
"histbar");
591 hlast->SetFillColorAlpha(kBlue, 0.20);
592 hlast->SetBarWidth(0.95);
593 hlast->Draw(
"histbarsame");
600 TLegend
legend = TLegend(0.30, 0.86, 0.95, 0.94);
601 legend.AddEntry(hfirst.get(), (
"payload: #color[2]{" + std::get<1>(firstiov) +
"}").c_str(),
"F");
602 legend.AddEntry(hlast.get(), (
"payload: #color[4]{" + std::get<1>(lastiov) +
"}").c_str(),
"F");
603 legend.SetTextSize(0.025);
608 ltx.SetTextSize(0.040);
609 ltx.SetTextAlign(11);
611 if (this->m_plotAnnotations.ntags == 2) {
612 ltxText = fmt::sprintf(
"#color[2]{%s, %s} vs #color[4]{%s, %s}",
618 ltxText = fmt::sprintf(
"%s IOV: #color[2]{%s} vs IOV: #color[4]{%s}",
623 ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, ltxText.c_str());
632 using SiPixelVCalSlopesComparisonSingleTag = SiPixelVCalValueComparisonBase<SiPixelVCalPI::t_slope, MULTI_IOV, 1>;
633 using SiPixelVCalOffsetsComparisonSingleTag = SiPixelVCalValueComparisonBase<SiPixelVCalPI::t_offset, MULTI_IOV, 1>;
634 using SiPixelVCalSlopesComparisonTwoTags = SiPixelVCalValueComparisonBase<SiPixelVCalPI::t_slope, SINGLE_IOV, 2>;
635 using SiPixelVCalOffsetsComparisonTwoTags = SiPixelVCalValueComparisonBase<SiPixelVCalPI::t_offset, SINGLE_IOV, 2>;
const std::vector< std::string > IDlabels
static const double slope[3]
const char * pathToTopoXML()
std::string to_string(const V &value)
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
std::pair< T, T > findMinMaxInMap(const std::map< unsigned int, T > &theMap)
static const unsigned int phase1size
Abs< T >::type abs(const T &t)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
std::map< uint32_t, float > mapToDetId
void adjustStats(TPaveStats *stats, float X1, float Y1, float X2, float Y2)
void bookAll(std::string title_label, std::string x_label, std::string y_label, const int nbins, const float xmin, const float xmax)
void makeNicePlotStyle(TH1 *hist)
void displayNotSupported(TCanvas &canv, const unsigned int size)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)