1 #ifndef CONDCORE_SIPIXELPLUGINS_SIPIXELGAINCALIBHELPER_H
2 #define CONDCORE_SIPIXELPLUGINS_SIPIXELGAINCALIBHELPER_H
15 #include <type_traits>
28 #include "TPaveStats.h"
33 using AvgMap = std::map<uint32_t, float>;
35 namespace gainCalibPI {
41 template <
typename PayloadType>
43 std::shared_ptr<TH1F> h1,
45 const std::vector<uint32_t>& wantedIds = {}) {
46 std::vector<uint32_t> detids;
47 if (wantedIds.empty()) {
50 detids.assign(wantedIds.begin(), wantedIds.end());
53 for (
const auto&
d : detids) {
59 int numberOfRowsToAverageOver =
payload->getNumberOfRowsToAverageOver();
61 int nRocsInRow = (
range.second -
range.first) /
ncols / numberOfRowsToAverageOver;
62 unsigned int nRowsForHLT = 1;
63 int nrows =
std::max((
payload->getNumberOfRowsToAverageOver() * nRocsInRow),
66 auto rangeAndCol =
payload->getRangeAndNCols(
d);
70 COUT <<
"NCOLS: " <<
payload->getNCols(
d) <<
" " << rangeAndCol.second <<
" NROWS:" << nrows
71 <<
", RANGES: " << rangeAndCol.first.second - rangeAndCol.first.first
72 <<
", Ratio: " <<
float(rangeAndCol.first.second - rangeAndCol.first.first) / rangeAndCol.second
78 for (
int row = 0; row < nrows; row++) {
81 quid =
payload->getGain(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
84 quid =
payload->getPed(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
87 edm::LogError(
"gainCalibPI::fillTheHisto") <<
"Unrecognized type " << theType << std::endl;
98 template <
typename PayloadType>
102 std::vector<uint32_t> detids;
105 for (
const auto&
d : detids) {
107 int numberOfRowsToAverageOver =
payload->getNumberOfRowsToAverageOver();
109 int nRocsInRow = (
range.second -
range.first) /
ncols / numberOfRowsToAverageOver;
110 unsigned int nRowsForHLT = 1;
111 int nrows =
std::max((
payload->getNumberOfRowsToAverageOver() * nRocsInRow),
114 auto rangeAndCol =
payload->getRangeAndNCols(
d);
121 for (
int row = 0; row < nrows; row++) {
126 payload->getGain(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
129 sumOfX +=
payload->getPed(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
132 edm::LogError(
"gainCalibPI::fillThePerModuleMap") <<
"Unrecognized type " << theType << std::endl;
138 map[
d] = sumOfX / nPixels;
144 template <
typename PayloadType>
146 std::shared_ptr<TH1> hBPix,
147 std::shared_ptr<TH1> hFPix,
149 std::vector<uint32_t> detids;
154 for (
const auto&
d : detids) {
157 int numberOfRowsToAverageOver =
payload->getNumberOfRowsToAverageOver();
159 int nRocsInRow = (
range.second -
range.first) /
ncols / numberOfRowsToAverageOver;
160 unsigned int nRowsForHLT = 1;
161 int nrows =
std::max((
payload->getNumberOfRowsToAverageOver() * nRocsInRow),
164 auto rangeAndCol =
payload->getRangeAndNCols(
d);
169 for (
int row = 0; row < nrows; row++) {
170 float gain =
payload->getGain(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
171 float ped =
payload->getPed(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
175 if (isCorrelation_) {
176 hBPix->Fill(
gain, ped);
183 if (isCorrelation_) {
184 hFPix->Fill(
gain, ped);
191 edm::LogError(
"gainCalibPI::fillTheHistos") <<
d <<
" is not a Pixel DetId" << std::endl;
200 constexpr
char const*
TypeName[2] = {
"Gains",
"Pedestals"};
205 template <gainCalibPI::type myType,
class PayloadType>
211 Form(
"SiPixelGainCalibration %s Values",
TypeName[myType])) {
212 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
214 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
217 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
222 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
223 auto iov =
tag.iovs.front();
227 gStyle->SetOptStat(
"emr");
229 float minimum(9999.);
230 float maximum(-9999.);
234 maximum =
payload->getGainHigh();
235 minimum =
payload->getGainLow();
238 maximum =
payload->getPedHigh();
239 minimum =
payload->getPedLow();
246 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
247 auto h1 = std::make_shared<TH1F>(Form(
"%s values",
TypeName[myType]),
248 Form(
"SiPixel Gain Calibration %s - %s;per %s %s;# %ss",
266 h1->GetYaxis()->SetRangeUser(0.1, h1->GetMaximum() * 10.);
267 h1->SetFillColor(kBlue);
268 h1->SetMarkerStyle(20);
269 h1->SetMarkerSize(1);
277 TLegend
legend = TLegend(0.40, 0.88, 0.94, 0.93);
278 legend.SetHeader((
"Payload hash: #bf{" + (std::get<1>(iov)) +
"}").c_str(),
282 legend.SetTextSize(0.025);
285 TPaveStats* st = (TPaveStats*)h1->FindObject(
"stats");
286 st->SetTextSize(0.03);
292 ltx.SetTextSize(0.05);
293 ltx.SetTextAlign(11);
294 ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.1,
295 1 - gPad->GetTopMargin() + 0.01,
296 (
"SiPixel Gain Calibration IOV:" + std::to_string(std::get<0>(iov))).c_str());
312 template <
bool isBarrel, gainCalibPI::type myType,
class PayloadType>
318 Form(
"SiPixelGainCalibration %s Values Per Region",
TypeName[myType])) {
321 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
323 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
326 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
330 bool fill()
override {
331 gStyle->SetOptStat(
"mr");
333 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
334 auto iov =
tag.iovs.front();
339 auto ip = paramValues.find(
"SetLog");
340 if (ip != paramValues.end()) {
341 auto answer = boost::lexical_cast<std::string>(ip->second);
345 <<
" is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n";
351 std::vector<uint32_t> detids;
354 float minimum(9999.);
355 float maximum(-9999.);
359 maximum =
payload->getGainHigh();
360 minimum =
payload->getGainLow();
363 maximum =
payload->getPedHigh();
364 minimum =
payload->getPedLow();
383 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
384 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
389 myPlots.bookAll(Form(
"SiPixel Gain Calibration %s - %s", (
isForHLT_ ?
"ForHLT" :
"Offline"),
TypeName[myType]),
391 Form(
"# %ss", (
isForHLT_ ?
"column" :
"pixel")),
405 myPlots.setLogScale();
407 myPlots.beautify(kBlue, -1);
410 TLegend
legend = TLegend(0.45, 0.88, 0.91, 0.92);
411 legend.SetHeader((
"hash: #bf{" + (std::get<1>(iov)) +
"}").c_str(),
415 legend.SetTextSize(0.025);
418 unsigned int maxPads =
isBarrel ? 4 : 12;
419 for (
unsigned int c = 1;
c <= maxPads;
c++) {
430 ltx.SetTextSize(0.05);
431 ltx.SetTextAlign(11);
433 for (
unsigned int c = 1;
c <= maxPads;
c++) {
436 auto leftX = setLog ? 0. : 0.1;
437 ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX,
438 1 - gPad->GetTopMargin() + 0.01,
466 Form(
"SiPixelGainCalibration %s Values Per Region %i tag(s)",
TypeName[myType],
ntags)) {
469 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
471 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
474 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
478 bool fill()
override {
479 gStyle->SetOptStat(
"mr");
484 auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
485 auto tagname1 = cond::payloadInspector::PlotBase::getTag<0>().name;
487 auto firstiov = theIOVs.front();
488 std::tuple<cond::Time_t, cond::Hash> lastiov;
494 auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
495 tagname2 = cond::payloadInspector::PlotBase::getTag<1>().name;
496 lastiov = tag2iovs.front();
498 lastiov = theIOVs.back();
504 auto ip = paramValues.find(
"SetLog");
505 if (ip != paramValues.end()) {
506 auto answer = boost::lexical_cast<std::string>(ip->second);
510 <<
" is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n";
514 std::shared_ptr<PayloadType> last_payload = this->
fetchPayload(std::get<1>(lastiov));
515 std::shared_ptr<PayloadType> first_payload = this->
fetchPayload(std::get<1>(firstiov));
517 std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
518 std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
520 std::vector<uint32_t> f_detids, l_detids;
521 last_payload->getDetIds(l_detids);
522 first_payload->getDetIds(f_detids);
524 float minimum(9999.);
525 float maximum(-9999.);
529 maximum =
std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
530 minimum =
std::min(last_payload->getGainLow(), first_payload->getGainLow());
533 maximum =
std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
534 minimum =
std::min(last_payload->getPedLow(), first_payload->getPedLow());
555 const char* path_toTopologyXML = is_l_phase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
556 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
562 Form(
"Last SiPixel Gain Calibration %s - %s", (
isForHLT_ ?
"ForHLT" :
"Offline"),
TypeName[myType]),
564 Form(
"# %ss", (
isForHLT_ ?
"column" :
"pixel")),
569 path_toTopologyXML = is_f_phase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
570 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
576 Form(
"First SiPixel Gain Calibration %s - %s", (
isForHLT_ ?
"ForHLT" :
"Offline"),
TypeName[myType]),
578 Form(
"# %ss", (
isForHLT_ ?
"column" :
"pixel")),
592 f_myPlots.setLogScale();
593 l_myPlots.setLogScale();
596 l_myPlots.beautify(kRed, -1);
597 f_myPlots.beautify(kAzure, -1);
599 l_myPlots.draw(
canvas,
isBarrel,
"HIST", (!is_f_phase0 || !is_l_phase0));
600 f_myPlots.draw(
canvas,
isBarrel,
"HISTsames", (!is_f_phase0 || !is_l_phase0));
603 l_myPlots.rescaleMax(f_myPlots);
607 std::unique_ptr<TLegend>
legend;
609 legend = std::make_unique<TLegend>(0.36, 0.86, 0.94, 0.92);
610 legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), (
"#color[2]{" + tagname2 +
"}").c_str(),
"F");
611 legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), (
"#color[4]{" + tagname1 +
"}").c_str(),
"F");
612 legend->SetTextSize(0.024);
614 legend = std::make_unique<TLegend>(0.58, 0.80, 0.90, 0.92);
615 legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), (
"#color[2]{" + lastIOVsince +
"}").c_str(),
"F");
616 legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), (
"#color[4]{" + firstIOVsince +
"}").c_str(),
"F");
617 legend->SetTextSize(0.040);
621 unsigned int maxPads =
isBarrel ? 4 : 12;
622 for (
unsigned int c = 1;
c <= maxPads;
c++) {
634 ltx.SetTextSize(0.05);
635 ltx.SetTextAlign(11);
637 for (
unsigned int c = 1;
c <= maxPads;
c++) {
640 auto leftX = setLog ? 0. : 0.1;
641 ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX,
642 1 - gPad->GetTopMargin() + 0.01,
644 "} vs #color[2]{" + std::to_string(std::get<0>(lastiov)) +
"}")
663 template <
class PayloadType>
669 "SiPixelGainCalibration gain/pedestal correlations") {
670 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
672 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
675 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
679 bool fill()
override {
680 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
681 auto iov =
tag.iovs.front();
683 gStyle->SetOptStat(
"emr");
684 gStyle->SetPalette(1);
688 TCanvas
canvas(
"Canv",
"Canv", 1400, 800);
692 auto hBPix = std::make_shared<TH2F>(
"Correlation BPIX",
693 Form(
"SiPixel Gain Calibration %s BPIx;per %s gains;per %s pedestals",
704 auto hFPix = std::make_shared<TH2F>(
"Correlation FPIX",
705 Form(
"SiPixel Gain Calibration %s FPix;per %s gains;per %s pedestals",
716 for (
unsigned int i : {1, 2}) {
729 hBPix->GetYaxis()->SetTitleOffset(1.65);
736 hFPix->GetYaxis()->SetTitleOffset(1.65);
739 TLegend
legend = TLegend(0.3, 0.92, 0.70, 0.95);
740 legend.SetHeader((
"Payload hash: #bf{" + (std::get<1>(iov)) +
"}").c_str(),
743 legend.SetTextSize(0.025);
752 ltx.SetTextSize(0.045);
753 ltx.SetTextAlign(11);
755 ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
756 1 - gPad->GetTopMargin() + 0.01,
757 (
"SiPixel Gain Calibration IOV:" + std::to_string(std::get<0>(iov))).c_str());
759 ltx.DrawLatexNDC(0.75, 0.15,
"BPIX");
762 ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
763 1 - gPad->GetTopMargin() + 0.01,
764 (
"SiPixel Gain Calibration IOV:" + std::to_string(std::get<0>(iov))).c_str());
766 ltx.DrawLatexNDC(0.75, 0.15,
"FPIX");
771 canvas.SaveAs(
"out.root");
784 template <gainCalibPI::type myType,
class PayloadType>
790 Form(
"SiPixelGainCalibrationOffline %s Values By Partition",
TypeName[myType])) {
791 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
793 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
796 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
800 bool fill()
override {
801 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
802 auto iov =
tag.iovs.front();
804 gStyle->SetOptStat(
"emr");
808 TCanvas
canvas(
"Canv",
"Canv", 1400, 800);
812 float minimum(9999.);
813 float maximum(-9999.);
817 maximum =
payload->getGainHigh();
818 minimum =
payload->getGainLow();
821 maximum =
payload->getPedHigh();
822 minimum =
payload->getPedLow();
829 auto hBPix = std::make_shared<TH1F>(Form(
"%s BPIX",
TypeName[myType]),
830 Form(
"SiPixel Gain Calibration %s BPIx -%s;per %s %s (BPix);# %ss",
840 auto hFPix = std::make_shared<TH1F>(Form(
"%s FPIX",
TypeName[myType]),
841 Form(
"SiPixel Gain Calibration %s FPix -%s;per %s %s (FPix);# %ss",
851 for (
unsigned int i : {1, 2}) {
861 hBPix->GetYaxis()->SetRangeUser(0.1, hBPix->GetMaximum() * 10);
862 hBPix->SetFillColor(kBlue);
863 hBPix->SetMarkerStyle(20);
864 hBPix->SetMarkerSize(1);
868 hBPix->SetStats(
true);
872 hFPix->GetYaxis()->SetRangeUser(0.1, hFPix->GetMaximum() * 10);
873 hFPix->SetFillColor(kBlue);
874 hFPix->SetMarkerStyle(20);
875 hFPix->SetMarkerSize(1);
879 hFPix->SetStats(
true);
883 TLegend
legend = TLegend(0.32, 0.92, 0.97, 0.95);
884 legend.SetHeader((
"Payload hash: #bf{" + (std::get<1>(iov)) +
"}").c_str(),
888 legend.SetTextSize(0.025);
895 TPaveStats* st1 = (TPaveStats*)hBPix->FindObject(
"stats");
896 st1->SetTextSize(0.03);
900 TPaveStats* st2 = (TPaveStats*)hFPix->FindObject(
"stats");
901 st2->SetTextSize(0.03);
907 ltx.SetTextSize(0.045);
908 ltx.SetTextAlign(11);
910 ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
911 1 - gPad->GetTopMargin() + 0.01,
912 (
"SiPixel Gain Calibration IOV:" + std::to_string(std::get<0>(iov))).c_str());
915 ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
916 1 - gPad->GetTopMargin() + 0.01,
917 (
"SiPixel Gain Calibration IOV:" + std::to_string(std::get<0>(iov))).c_str());
933 template <gainCalibPI::type myType,
class PayloadType>
938 Form(
"SiPixelGainCalibration %s Values Comparison",
TypeName[myType])) {
939 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
945 bool fill(
const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs)
override {
946 gStyle->SetOptStat(
"emr");
947 TGaxis::SetExponentOffset(-0.1, 0.01,
"y");
948 TH1F::SetDefaultSumw2(
true);
950 std::vector<std::tuple<cond::Time_t, cond::Hash>> sorted_iovs = iovs;
952 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const&
t1,
auto const&
t2) {
953 return std::get<0>(
t1) < std::get<0>(
t2);
955 auto firstiov = sorted_iovs.front();
956 auto lastiov = sorted_iovs.back();
958 std::shared_ptr<PayloadType> last_payload = this->
fetchPayload(std::get<1>(lastiov));
959 std::shared_ptr<PayloadType> first_payload = this->
fetchPayload(std::get<1>(firstiov));
961 std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
962 std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
964 float minimum(9999.);
965 float maximum(-9999.);
969 maximum =
std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
970 minimum =
std::min(last_payload->getGainLow(), first_payload->getGainLow());
973 maximum =
std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
974 minimum =
std::min(last_payload->getPedLow(), first_payload->getPedLow());
981 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
983 auto hfirst = std::make_shared<TH1F>(Form(
"First, IOV %s", firstIOVsince.c_str()),
984 Form(
"SiPixel Gain Calibration %s - %s;per %s %s;# %ss",
994 auto hlast = std::make_shared<TH1F>(Form(
"Last, IOV %s", lastIOVsince.c_str()),
995 Form(
"SiPixel Gain Calibration %s - %s;per %s %s;# %ss",
1014 hfirst->GetYaxis()->SetRangeUser(1., extrema.second * 10);
1016 hfirst->SetTitle(
"");
1017 hfirst->SetLineColor(kRed);
1018 hfirst->SetBarWidth(0.95);
1019 hfirst->Draw(
"hist");
1021 hlast->SetTitle(
"");
1022 hlast->SetFillColorAlpha(kBlue, 0.20);
1023 hlast->SetBarWidth(0.95);
1024 hlast->Draw(
"histsames");
1027 hfirst->SetStats(
true);
1029 hlast->SetStats(
true);
1033 TLegend
legend = TLegend(0.45, 0.86, 0.74, 0.94);
1037 legend.AddEntry(hfirst.get(), (
"payload: #color[2]{" + std::get<1>(firstiov) +
"}").c_str(),
"F");
1038 legend.AddEntry(hlast.get(), (
"payload: #color[4]{" + std::get<1>(lastiov) +
"}").c_str(),
"F");
1039 legend.SetTextSize(0.022);
1043 TPaveStats* st1 = (TPaveStats*)hfirst->FindObject(
"stats");
1044 st1->SetTextSize(0.022);
1045 st1->SetLineColor(kRed);
1046 st1->SetTextColor(kRed);
1049 TPaveStats* st2 = (TPaveStats*)hlast->FindObject(
"stats");
1050 st2->SetTextSize(0.022);
1051 st2->SetLineColor(kBlue);
1052 st2->SetTextColor(kBlue);
1055 auto ltx = TLatex();
1056 ltx.SetTextFont(62);
1058 ltx.SetTextSize(0.047);
1059 ltx.SetTextAlign(11);
1060 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1061 1 - gPad->GetTopMargin() + 0.01,
1062 (
"SiPixel Gain Calibration IOV:#color[2]{" + std::to_string(std::get<0>(firstiov)) +
1063 "} vs IOV:#color[4]{" + std::to_string(std::get<0>(lastiov)) +
"}")
1069 canvas.SaveAs(
"out.root");
1080 template <gainCalibPI::type myType,
class PayloadType>
1090 template <gainCalibPI::type myType,
class PayloadType>
1104 template <gainCalibPI::type myType,
class PayloadType>
1110 Form(
"SiPixelGainCalibration %s Barrel Pixel Map",
TypeName[myType])),
1113 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
1115 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
1118 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
1122 bool fill()
override {
1123 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
1124 auto iov =
tag.iovs.front();
1128 static const int n_layers = 4;
1129 int nlad_list[n_layers] = {6, 14, 22, 32};
1133 std::array<TH2D*, n_layers> h_bpix_Gains;
1135 for (
unsigned int lay = 1; lay <= 4; lay++) {
1136 int nlad = nlad_list[lay - 1];
1140 h_bpix_Gains[lay - 1] =
new TH2D(
name.c_str(),
1145 (nlad * 4 + 2) * divide_roc,
1150 std::map<uint32_t, float> GainCalibMap_;
1153 edm::LogError(
label_) <<
"SiPixelGainCalibration maps are not supported for non-Phase1 Pixel geometries !";
1154 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
1162 std::array<double, 4> minima = {{999., 999., 999., 999.}};
1164 for (
const auto& element : GainCalibMap_) {
1173 COUT <<
"layer:" << layer <<
" ladder:" <<
ladder <<
" module:" <<
module <<
" signed ladder: " << s_ladder
1174 <<
" signed module: " << s_module << std::endl;
1176 if (element.second < minima.at(layer - 1))
1177 minima.at(layer - 1) = element.second;
1180 for (
const auto&
bin : rocsToMask) {
1181 h_bpix_Gains[layer - 1]->SetBinContent(
bin.first,
bin.second, element.second);
1186 gStyle->SetOptStat(0);
1188 TCanvas
canvas(
"Summary",
"Summary", 1200, 1200);
1191 for (
unsigned int lay = 1; lay <= 4; lay++) {
1194 COUT <<
" layer:" << lay <<
" max:" << h_bpix_Gains[lay - 1]->GetMaximum() <<
" min: " << minima.at(lay - 1)
1198 h_bpix_Gains[lay - 1]->GetZaxis()->SetRangeUser(minima.at(lay - 1) - 0.001,
1199 h_bpix_Gains[lay - 1]->GetMaximum() + 0.001);
1204 for (
unsigned int lay = 1; lay <= 4; lay++) {
1206 auto ltx = TLatex();
1207 ltx.SetTextFont(62);
1208 ltx.SetTextColor(kBlue);
1209 ltx.SetTextSize(0.055);
1210 ltx.SetTextAlign(11);
1211 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1212 1 - gPad->GetTopMargin() + 0.01,
1214 ? (
"IOV:" + std::to_string(unpacked.second)).c_str()
1215 : (std::to_string(unpacked.first) +
"," + std::to_string(unpacked.second)).c_str());
1236 template <gainCalibPI::type myType,
class PayloadType>
1242 Form(
"SiPixelGainCalibration %s Forward Pixel Map",
TypeName[myType])),
1245 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
1247 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
1250 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
1254 bool fill()
override {
1255 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
1256 auto iov =
tag.iovs.front();
1259 static const int n_rings = 2;
1260 std::array<TH2D*, n_rings> h_fpix_Gains;
1265 int n =
ring == 1 ? 92 : 140;
1266 float y =
ring == 1 ? 11.5 : 17.5;
1270 h_fpix_Gains[
ring - 1] =
1271 new TH2D(
name.c_str(),
title.c_str(), 56 * divide_roc, -3.5, 3.5,
n * divide_roc, -
y,
y);
1274 std::map<uint32_t, float> GainCalibMap_;
1277 edm::LogError(
label_) <<
"SiPixelGainCalibration maps are not supported for non-Phase1 Pixel geometries !";
1278 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
1286 std::array<double, 2> minima = {{999., 999.}};
1288 for (
const auto& element : GainCalibMap_) {
1297 COUT <<
"ring:" <<
ring <<
" blade: " << s_blade <<
" panel: " << panel
1298 <<
" signed blade/panel: " << s_blade_panel <<
" disk: " << s_disk << std::endl;
1300 if (element.second < minima.at(
ring - 1))
1301 minima.at(
ring - 1) = element.second;
1304 for (
const auto&
bin : rocsToMask) {
1305 h_fpix_Gains[
ring - 1]->SetBinContent(
bin.first,
bin.second, element.second);
1310 gStyle->SetOptStat(0);
1312 TCanvas
canvas(
"Summary",
"Summary", 1200, 600);
1318 COUT <<
" ringer:" <<
ring <<
" max:" << h_fpix_Gains[
ring - 1]->GetMaximum() <<
" min: " << minima.at(
ring - 1)
1322 h_fpix_Gains[
ring - 1]->GetZaxis()->SetRangeUser(minima.at(
ring - 1) - 0.001,
1323 h_fpix_Gains[
ring - 1]->GetMaximum() + 0.001);
1330 auto ltx = TLatex();
1331 ltx.SetTextFont(62);
1332 ltx.SetTextColor(kBlue);
1333 ltx.SetTextSize(0.05);
1334 ltx.SetTextAlign(11);
1335 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1336 1 - gPad->GetTopMargin() + 0.01,
1338 ? (
"IOV:" + std::to_string(unpacked.second)).c_str()
1339 : (std::to_string(unpacked.first) +
"," + std::to_string(unpacked.second)).c_str());
1358 template <gainCalibPI::type myType,
class PayloadType>
1363 Form(
"SiPixelGainCalibration %s Comparison by Region",
TypeName[myType])) {
1364 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
1366 label_ =
"SiPixelGainCalibrationOffline_PayloadInspector";
1369 label_ =
"SiPixelGainCalibrationForHLT_PayloadInspector";
1372 bool fill(
const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs)
override {
1373 gStyle->SetPaintTextFormat(
".3f");
1375 std::vector<std::tuple<cond::Time_t, cond::Hash>> sorted_iovs = iovs;
1378 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const&
t1,
auto const&
t2) {
1379 return std::get<0>(
t1) < std::get<0>(
t2);
1382 auto firstiov = sorted_iovs.front();
1383 auto lastiov = sorted_iovs.back();
1385 std::shared_ptr<PayloadType> last_payload = this->
fetchPayload(std::get<1>(lastiov));
1386 std::shared_ptr<PayloadType> first_payload = this->
fetchPayload(std::get<1>(firstiov));
1388 std::map<uint32_t, float> f_GainsMap_;
1391 std::map<uint32_t, float> l_GainsMap_;
1394 std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1395 std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1397 TCanvas
canvas(
"Comparison",
"Comparison", 1600, 800);
1399 std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> FirstGains_spectraByRegion;
1400 std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> LastGains_spectraByRegion;
1401 std::shared_ptr<TH1F> summaryFirst;
1402 std::shared_ptr<TH1F> summaryLast;
1404 float minimum(9999.);
1405 float maximum(-9999.);
1409 maximum =
std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
1410 minimum =
std::min(last_payload->getGainLow(), first_payload->getGainLow());
1413 maximum =
std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
1414 minimum =
std::min(last_payload->getPedLow(), first_payload->getPedLow());
1426 FirstGains_spectraByRegion[
part] =
1427 std::make_shared<TH1F>(Form(
"hfirstGains_%s", s_part.c_str()),
1428 Form(
";%s #LT %s #GT;n. of modules", s_part.c_str(),
TypeName[myType]),
1433 LastGains_spectraByRegion[
part] =
1434 std::make_shared<TH1F>(Form(
"hlastGains_%s", s_part.c_str()),
1435 Form(
";%s #LT %s #GT;n. of modules", s_part.c_str(),
TypeName[myType]),
1441 summaryFirst = std::make_shared<TH1F>(
"first Summary",
1442 Form(
"Summary of #LT per %s %s #GT;;average %s",
1446 FirstGains_spectraByRegion.size(),
1448 FirstGains_spectraByRegion.size());
1450 summaryLast = std::make_shared<TH1F>(
"last Summary",
1451 Form(
"Summary of #LT per %s %s #GT;;average %s",
1455 LastGains_spectraByRegion.size(),
1457 LastGains_spectraByRegion.size());
1460 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
1461 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1465 bool isPhase0(
false);
1473 for (
const auto& it : f_GainsMap_) {
1480 t_info_fromXML.
init();
1481 DetId detid(it.first);
1485 FirstGains_spectraByRegion[thePart]->Fill(it.second);
1489 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
1490 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1501 for (
const auto& it : l_GainsMap_) {
1508 t_info_fromXML.
init();
1509 DetId detid(it.first);
1513 LastGains_spectraByRegion[thePart]->Fill(it.second);
1524 FirstGains_spectraByRegion[
part]->GetMean() > 10.e-6 ? FirstGains_spectraByRegion[
part]->GetMean() : 0.;
1525 summaryFirst->SetBinContent(
bin, f_mean);
1531 LastGains_spectraByRegion[
part]->GetMean() > 10.e-6 ? LastGains_spectraByRegion[
part]->GetMean() : 0.;
1532 summaryLast->SetBinContent(
bin, l_mean);
1538 summaryFirst->SetMarkerColor(kRed);
1539 summaryFirst->GetXaxis()->LabelsOption(
"v");
1540 summaryFirst->GetXaxis()->SetLabelSize(0.05);
1541 summaryFirst->GetYaxis()->SetTitleOffset(0.9);
1544 summaryLast->SetMarkerColor(kBlue);
1545 summaryLast->GetYaxis()->SetTitleOffset(0.9);
1546 summaryLast->GetXaxis()->LabelsOption(
"v");
1547 summaryLast->GetXaxis()->SetLabelSize(0.05);
1554 summaryFirst->SetFillColor(kRed);
1555 summaryLast->SetFillColor(kBlue);
1557 summaryFirst->SetBarWidth(0.45);
1558 summaryFirst->SetBarOffset(0.1);
1560 summaryLast->SetBarWidth(0.4);
1561 summaryLast->SetBarOffset(0.55);
1563 summaryLast->SetMarkerSize(1.2);
1564 summaryFirst->SetMarkerSize(1.2);
1566 float max = (summaryFirst->GetMaximum() > summaryLast->GetMaximum()) ? summaryFirst->GetMaximum()
1567 : summaryLast->GetMaximum();
1569 summaryFirst->GetYaxis()->SetRangeUser(0.,
std::max(0.,
max * 1.40));
1571 summaryFirst->Draw(
"b text0");
1572 summaryLast->Draw(
"b text0 same");
1574 TLegend
legend = TLegend(0.52, 0.80, 0.98, 0.9);
1575 legend.SetHeader(Form(
"#LT %s #GT value comparison",
TypeName[myType]),
1579 (
"IOV: #scale[1.2]{" + std::to_string(std::get<0>(lastiov)) +
"} | #color[4]{" + std::get<1>(lastiov) +
"}")
1584 (
"IOV: #scale[1.2]{" + std::to_string(std::get<0>(firstiov)) +
"} | #color[2]{" + std::get<1>(firstiov) +
"}")
1587 legend.SetTextSize(0.025);
1600 template <gainCalibPI::type myType,
class PayloadType>
1610 template <gainCalibPI::type myType,
class PayloadType>
1611 class SiPixelGainCalibrationByRegionComparisonTwoTags
1612 :
public SiPixelGainCalibrationByRegionComparisonBase<myType, PayloadType> {