Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical improvements for TrackerAlignment_PayloadInspector #41205

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ namespace AlignmentPI {
/*--------------------------------------------------------------------*/
{
char buffer[255];
TPaveText* stat = new TPaveText(0.60, 0.75, 0.95, 0.95, "NDC");
TPaveText* stat = new TPaveText(0.71, 0.75, 0.95, 0.88, "NDC");
sprintf(buffer, "%s \n", AlignmentPI::getStringFromPart(part).c_str());
stat->AddText(buffer);

Expand All @@ -765,7 +765,7 @@ namespace AlignmentPI {
}
stat->AddText(buffer);

stat->SetLineColor(color);
stat->SetLineColor(0);
stat->SetTextColor(color);
stat->SetFillColor(10);
stat->SetShadowColor(10);
Expand Down
123 changes: 59 additions & 64 deletions CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
#include "CondCore/AlignmentPlugins/interface/AlignmentPayloadInspectorHelper.h"
#include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"

#include <boost/range/adaptor/indexed.hpp>
#include <iomanip> // std::setprecision
#include <iostream>
#include <memory>
#include <sstream>
#include <iostream>
#include <iomanip> // std::setprecision

// include ROOT
#include "TH2F.h"
Expand Down Expand Up @@ -217,46 +218,32 @@ namespace {
for (const auto &coord : coords) {
auto s_coord = AlignmentPI::getStringFromCoordinate(coord);
canvas.cd(subpad + 1);

unsigned int i = 0;
for (const auto &line : boundaries) {
l[subpad][i] = TLine(diffs[coord]->GetBinLowEdge(line.first),
canvas.cd(subpad + 1)->GetUymin(),
diffs[coord]->GetBinLowEdge(line.first),
canvas.cd(subpad + 1)->GetUymax() * 0.84);
l[subpad][i].SetLineWidth(1);
l[subpad][i].SetLineStyle(9);
l[subpad][i].SetLineColor(2);
l[subpad][i].Draw("same");
i++;
for (const auto &line : boundaries | boost::adaptors::indexed(0)) {
const auto &index = line.index();
const auto value = line.value();
l[subpad][index] = TLine(diffs[coord]->GetBinLowEdge(value.first),
canvas.cd(subpad + 1)->GetUymin(),
diffs[coord]->GetBinLowEdge(value.first),
canvas.cd(subpad + 1)->GetUymax() * 0.84);
l[subpad][index].SetLineWidth(1);
l[subpad][index].SetLineStyle(9);
l[subpad][index].SetLineColor(2);
l[subpad][index].Draw("same");
}

if (ref_ali.size() <= AlignmentPI::phase1size) {
const auto &theX_ = {0.2, 0.24, 0.31, 0.4, 0.55, 0.8};
for (unsigned int j = 1; j < 7; j++) {
auto thePart = static_cast<AlignmentPI::partitions>(j);
tSubdet[subpad].DrawLatex(
theX_.begin()[j - 1], 0.20, Form("%s", (AlignmentPI::getStringFromPart(thePart)).c_str()));
}
} else {
// this is for phase-2
unsigned int j = 0;
for (const auto &elem : boundaries) {
const auto &lm = canvas.cd(subpad + 1)->GetLeftMargin();
const auto &rm = 1 - canvas.cd(subpad + 1)->GetRightMargin();
const auto &frac = float(elem.first) / ref_ali.size();

LogDebug("TrackerAlignmentCompareAll")
<< __PRETTY_FUNCTION__ << " left margin: " << lm << " right margin: " << rm << " fraction: " << frac;

float theX_ = lm + (rm - lm) * frac + (j > 0 ? 0.025 : 0.01);

tSubdet[subpad].DrawLatex(
theX_,
0.23,
Form("%s", AlignmentPI::getStringFromPart(elem.second, /*guaranteed is phase2*/ true).c_str()));
j++;
}
const bool ph2 = (ref_ali.size() > AlignmentPI::phase1size);
for (const auto &elem : boundaries | boost::adaptors::indexed(0)) {
const auto &lm = canvas.cd(subpad + 1)->GetLeftMargin();
const auto &rm = 1 - canvas.cd(subpad + 1)->GetRightMargin();
const auto &frac = float(elem.value().first) / ref_ali.size();

LogDebug("TrackerAlignmentCompareAll")
<< __PRETTY_FUNCTION__ << " left margin: " << lm << " right margin: " << rm << " fraction: " << frac;

float theX_ = lm + (rm - lm) * frac + (elem.index() > 0 ? 0.025 : 0.01);

tSubdet[subpad].DrawLatex(
theX_, 0.23, Form("%s", AlignmentPI::getStringFromPart(elem.value().second, /*is phase2?*/ ph2).c_str()));
}

auto ltx = TLatex();
Expand Down Expand Up @@ -392,21 +379,19 @@ namespace {
canvas.cd();

TLine l[boundaries.size()];
unsigned int i = 0;
for (const auto &line : boundaries) {
l[i] = TLine(compare->GetBinLowEdge(line.first),
canvas.cd()->GetUymin(),
compare->GetBinLowEdge(line.first),
canvas.cd()->GetUymax());
l[i].SetLineWidth(1);
l[i].SetLineStyle(9);
l[i].SetLineColor(2);
l[i].Draw("same");
i++;
for (const auto &line : boundaries | boost::adaptors::indexed(0)) {
const auto &index = line.index();
const auto value = line.value();
l[index] = TLine(compare->GetBinLowEdge(value.first),
canvas.cd()->GetUymin(),
compare->GetBinLowEdge(value.first),
canvas.cd()->GetUymax());
l[index].SetLineWidth(1);
l[index].SetLineStyle(9);
l[index].SetLineColor(2);
l[index].Draw("same");
}

//std::cout << "boundaries.size()= " << boundaries.size() << std::endl;

TLatex tSubdet;
tSubdet.SetNDC();
tSubdet.SetTextAlign(21);
Expand All @@ -417,7 +402,7 @@ namespace {
tSubdet.SetTextColor(kRed);
auto myPair = AlignmentPI::calculatePosition(gPad, compare->GetBinLowEdge(elem.first));
float theX_ = elem.first != 0 ? myPair.first + 0.025 : myPair.first + 0.01;
bool isPhase2 = (ref_ali.size() > AlignmentPI::phase1size);
const bool isPhase2 = (ref_ali.size() > AlignmentPI::phase1size);
tSubdet.DrawLatex(theX_, 0.20, Form("%s", AlignmentPI::getStringFromPart(elem.second, isPhase2).c_str()));
}

Expand Down Expand Up @@ -557,9 +542,9 @@ namespace {

diffs[coord] = std::make_unique<TH1F>(Form("hDiff_%s", s_coord.c_str()),
Form(";#Delta%s %s;n. of modules", s_coord.c_str(), unit.c_str()),
1000,
-500.,
500.);
1001,
-500.5,
500.5);
}

// fill the comparison histograms
Expand All @@ -568,16 +553,25 @@ namespace {

int c_index = 1;

auto legend = std::make_unique<TLegend>(0.14, 0.93, 0.55, 0.98);
legend->AddEntry(
diffs[AlignmentPI::t_x].get(),
("#DeltaIOV: " + std::to_string(std::get<0>(lastiov)) + "-" + std::to_string(std::get<0>(firstiov))).c_str(),
"L");
legend->SetTextSize(0.03);
//TLegend (Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char *header="", Option_t *option="brNDC")
auto legend = std::make_unique<TLegend>(0.14, 0.88, 0.96, 0.99);
if (this->m_plotAnnotations.ntags == 2) {
legend->SetHeader("#bf{Two Tags Comparison}", "C"); // option "C" allows to center the header
legend->AddEntry(
diffs[AlignmentPI::t_x].get(),
("#splitline{" + tagname1 + " : " + firstIOVsince + "}{" + tagname2 + " : " + lastIOVsince + "}").c_str(),
"PL");
} else {
legend->SetHeader(("tag: #bf{" + tagname1 + "}").c_str(), "C"); // option "C" allows to center the header
legend->AddEntry(diffs[AlignmentPI::t_x].get(),
("#splitline{IOV since: " + firstIOVsince + "}{IOV since: " + lastIOVsince + "}").c_str(),
"PL");
}
legend->SetTextSize(0.025);

for (const auto &coord : coords) {
canvas.cd(c_index)->SetLogy();
canvas.cd(c_index)->SetTopMargin(0.02);
canvas.cd(c_index)->SetTopMargin(0.01);
canvas.cd(c_index)->SetBottomMargin(0.15);
canvas.cd(c_index)->SetLeftMargin(0.14);
canvas.cd(c_index)->SetRightMargin(0.04);
Expand All @@ -592,6 +586,7 @@ namespace {
int i_max = diffs[coord]->FindLastBinAbove(0.);
int i_min = diffs[coord]->FindFirstBinAbove(0.);
diffs[coord]->GetXaxis()->SetRange(std::max(1, i_min - 10), std::min(i_max + 10, diffs[coord]->GetNbinsX()));
diffs[coord]->SetMaximum(diffs[coord]->GetMaximum() * 5);
diffs[coord]->Draw("HIST");
AlignmentPI::makeNiceStats(diffs[coord].get(), q, kBlack);

Expand Down
7 changes: 7 additions & 0 deletions CondCore/AlignmentPlugins/test/testTrackerAlignment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ getPayloadData.py \
--db Prod \
--test ;

mv *.png $W_DIR/results_alignments/TrackerAlignmentBarycenters.png

# add examples of Pixel barycenter comparison
#*************************************************************************#
Expand All @@ -93,6 +94,8 @@ getPayloadData.py \
--db Prod \
--test ;

mv *.png $W_DIR/results_alignments/PixelBarycentersCompare.png

getPayloadData.py \
--plugin pluginTrackerAlignment_PayloadInspector \
--plot plot_PixelBarycentersCompareTwoTags \
Expand All @@ -104,6 +107,8 @@ getPayloadData.py \
--db Prod \
--test ;

mv *.png $W_DIR/results_alignments/PixelBarycentersCompareTwoTags.png

# add examples of full 6 coordinate comparisons
#*************************************************************************#
getPayloadData.py \
Expand All @@ -116,3 +121,5 @@ getPayloadData.py \
--iovstwo '{"start_iov": "358156", "end_iov": "358156"}' \
--db Prod \
--test ;

mv *.png $W_DIR/results_alignments/TrackerAlignmentComparatorTwoTags.png