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

improve Tracker geometry comparison plot in Payload Inspector #38369

Merged
merged 1 commit into from
Jun 15, 2022
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 @@ -15,6 +15,7 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CondFormats/Alignment/interface/Alignments.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/Math/interface/Rounding.h" // for rounding

//#define MMDEBUG // uncomment for debugging at compile time
#ifdef MMDEBUG
Expand All @@ -28,7 +29,19 @@ namespace AlignmentPI {

// size of the phase-I Tracker APE payload (including both SS + DS modules)
static const unsigned int phase0size = 19876;
static const float cmToUm = 10000;
static const float cmToUm = 10000.f;
static const float tomRad = 1000.f;

// method to zero all elements whose difference from 2Pi
// is less than the tolerance (2*10e-7)
inline float returnZeroIfNear2PI(const float phi) {
const double tol = 2.e-7; // default tolerance 1.e-7 doesn't account for possible variations
if (cms_rounding::roundIfNear0(std::abs(phi) - 2 * M_PI, tol) == 0.f) {
return 0.f;
} else {
return phi;
}
}

enum coordinate {
t_x = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

// include ROOT
#include "TH2F.h"
#include "TGaxis.h"
#include "TLegend.h"
#include "TCanvas.h"
#include "TLine.h"
Expand Down Expand Up @@ -72,6 +73,8 @@ namespace {
" coordinate between two geometries") {}

bool fill() override {
TGaxis::SetExponentOffset(-0.12, 0.01, "y"); // Y offset

// trick to deal with the multi-ioved tag and two tag case at the same time
auto theIOVs = PlotBase::getTag<0>().iovs;
auto tagname1 = PlotBase::getTag<0>().name;
Expand Down Expand Up @@ -192,15 +195,21 @@ namespace {
compare->SetBinContent(
i + 1, (target_ali[i].translation().z() - ref_ali[i].translation().z()) * AlignmentPI::cmToUm);
break;
case AlignmentPI::rot_alpha:
compare->SetBinContent(i + 1, (target_eulerAngles[0] - ref_eulerAngles[0]) * 1000.);
case AlignmentPI::rot_alpha: {
auto deltaRot = target_eulerAngles[0] - ref_eulerAngles[0];
compare->SetBinContent(i + 1, AlignmentPI::returnZeroIfNear2PI(deltaRot) * AlignmentPI::tomRad);
break;
case AlignmentPI::rot_beta:
compare->SetBinContent(i + 1, (target_eulerAngles[1] - ref_eulerAngles[1]) * 1000.);
}
case AlignmentPI::rot_beta: {
auto deltaRot = target_eulerAngles[1] - ref_eulerAngles[1];
compare->SetBinContent(i + 1, AlignmentPI::returnZeroIfNear2PI(deltaRot) * AlignmentPI::tomRad);
break;
case AlignmentPI::rot_gamma:
compare->SetBinContent(i + 1, (target_eulerAngles[2] - ref_eulerAngles[2]) * 1000.);
}
case AlignmentPI::rot_gamma: {
auto deltaRot = target_eulerAngles[2] - ref_eulerAngles[2];
compare->SetBinContent(i + 1, AlignmentPI::returnZeroIfNear2PI(deltaRot) * AlignmentPI::tomRad);
break;
}
default:
edm::LogError("TrackerAlignment_PayloadInspector") << "Unrecognized coordinate " << coord << std::endl;
break;
Expand All @@ -218,8 +227,12 @@ namespace {
auto max = compare->GetMaximum();
auto min = compare->GetMinimum();
auto range = std::abs(max) > std::abs(min) ? std::abs(max) : std::abs(min);
if (range == 0.f)
range = 0.1;
//auto newMax = (max > 0.) ? max*1.2 : max*0.8;
compare->GetYaxis()->SetRangeUser(-range * 1.3, range * 1.2);

compare->GetYaxis()->SetRangeUser(-range * 1.5, range * 1.5);
compare->GetYaxis()->SetTitleOffset(1.5);
compare->SetMarkerStyle(20);
compare->SetMarkerSize(0.5);
compare->Draw("P");
Expand Down Expand Up @@ -277,7 +290,7 @@ namespace {
ltx.SetTextAlign(11);
ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1 - gPad->GetTopMargin() + 0.01,
("Tracker Alignment Comparison:#color[4]{" + s_coord + "}").c_str());
("Tracker Alignment Compare :#color[4]{" + s_coord + "}").c_str());

std::string fileName(this->m_imageFileName);
canvas.SaveAs(fileName.c_str());
Expand Down Expand Up @@ -438,15 +451,21 @@ namespace {
diffs[coord]->Fill((target_ali[i].translation().z() - ref_ali[i].translation().z()) *
AlignmentPI::cmToUm);
break;
case AlignmentPI::rot_alpha:
diffs[coord]->Fill((target_eulerAngles[0] - ref_eulerAngles[0]) * 1000.);
case AlignmentPI::rot_alpha: {
auto deltaRot = target_eulerAngles[0] - ref_eulerAngles[0];
diffs[coord]->Fill(AlignmentPI::returnZeroIfNear2PI(deltaRot) * AlignmentPI::tomRad);
break;
case AlignmentPI::rot_beta:
diffs[coord]->Fill((target_eulerAngles[1] - ref_eulerAngles[1]) * 1000.);
}
case AlignmentPI::rot_beta: {
auto deltaRot = target_eulerAngles[1] - ref_eulerAngles[1];
diffs[coord]->Fill(AlignmentPI::returnZeroIfNear2PI(deltaRot) * AlignmentPI::tomRad);
break;
case AlignmentPI::rot_gamma:
diffs[coord]->Fill((target_eulerAngles[2] - ref_eulerAngles[2]) * 1000.);
}
case AlignmentPI::rot_gamma: {
auto deltaRot = target_eulerAngles[2] - ref_eulerAngles[2];
diffs[coord]->Fill(AlignmentPI::returnZeroIfNear2PI(deltaRot) * AlignmentPI::tomRad);
break;
}
default:
edm::LogError("TrackerAlignment_PayloadInspector") << "Unrecognized coordinate " << coord << std::endl;
break;
Expand Down