21 #include "CLHEP/Vector/RotationInterfaces.h"
45 #include "TPaveStats.h"
49 using namespace cond::payloadInspector;
60 const std::map<AlignmentPI::coordinate, float> hardcodeGPR = {
67 template <AlignmentPI::coordinate coord,
int ntags, IOVMultiplicity nIOVs>
68 class TrackerAlignmentComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
70 TrackerAlignmentComparatorBase()
72 " coordinate between two geometries") {}
74 bool fill()
override {
76 auto theIOVs = PlotBase::getTag<0>().
iovs;
77 auto tagname1 = PlotBase::getTag<0>().
name;
79 auto firstiov = theIOVs.front();
80 std::tuple<cond::Time_t, cond::Hash> lastiov;
83 assert(this->m_plotAnnotations.ntags < 3);
85 if (this->m_plotAnnotations.ntags == 2) {
86 auto tag2iovs = PlotBase::getTag<1>().
iovs;
87 tagname2 = PlotBase::getTag<1>().
name;
88 lastiov = tag2iovs.front();
90 lastiov = theIOVs.back();
93 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
94 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
99 std::vector<AlignTransform> ref_ali = first_payload->m_align;
100 std::vector<AlignTransform> target_ali = last_payload->m_align;
102 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 1200, 1200);
104 if (ref_ali.size() != target_ali.size()) {
106 <<
"the size of the reference alignment (" << ref_ali.size()
107 <<
") is different from the one of the target (" << target_ali.size()
108 <<
")! You are probably trying to compare different underlying geometries. Exiting";
114 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
115 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
119 for (
const auto &ali : ref_ali) {
120 auto mydetid = ali.rawId();
123 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
125 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
136 std::unique_ptr<TH1F>
compare =
137 std::make_unique<TH1F>(
"comparison",
138 Form(
";Detector Id index; #Delta%s %s", s_coord.c_str(), unit.c_str()),
141 ref_ali.size() - 0.5);
143 std::vector<int> boundaries;
145 for (
unsigned int i = 0;
i < ref_ali.size();
i++) {
146 if (ref_ali[
i].rawId() == target_ali[
i].rawId()) {
151 if (thePart != currentPart) {
152 currentPart = thePart;
153 boundaries.push_back(counter);
156 CLHEP::HepRotation target_rot(target_ali[
i].
rotation());
157 CLHEP::HepRotation ref_rot(ref_ali[
i].
rotation());
184 compare->SetBinContent(
188 compare->SetBinContent(
192 compare->SetBinContent(
196 compare->SetBinContent(
i + 1, (target_eulerAngles[0] - ref_eulerAngles[0]) * 1000.);
199 compare->SetBinContent(
i + 1, (target_eulerAngles[1] - ref_eulerAngles[1]) * 1000.);
202 compare->SetBinContent(
i + 1, (target_eulerAngles[2] - ref_eulerAngles[2]) * 1000.);
205 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
213 canvas.SetLeftMargin(0.17);
214 canvas.SetRightMargin(0.05);
215 canvas.SetBottomMargin(0.15);
217 auto max = compare->GetMaximum();
218 auto min = compare->GetMinimum();
221 compare->GetYaxis()->SetRangeUser(-
range * 1.3,
range * 1.2);
222 compare->SetMarkerStyle(20);
223 compare->SetMarkerSize(0.5);
229 TLine
l[boundaries.size()];
231 for (
const auto &
line : boundaries) {
232 l[
i] = TLine(compare->GetBinLowEdge(
line),
234 compare->GetBinLowEdge(
line),
236 l[
i].SetLineWidth(1);
237 l[
i].SetLineStyle(9);
238 l[
i].SetLineColor(2);
245 tSubdet.SetTextAlign(21);
246 tSubdet.SetTextSize(0.027);
247 tSubdet.SetTextAngle(90);
248 for (
unsigned int j = 1;
j <= 6;
j++) {
250 tSubdet.SetTextColor(kRed);
253 float theX_ = myPair.first + 0.025;
257 TLegend
legend = TLegend(0.58, 0.82, 0.95, 0.9);
258 legend.SetTextSize(0.03);
259 legend.SetHeader(
"Alignment comparison",
"C");
269 t1.SetTextSize(0.05);
270 t1.DrawLatex(0.2, 0.93, Form(
"%s", s_coord.c_str()));
271 t1.SetTextColor(kBlue);
272 t1.DrawLatex(0.6, 0.93, Form(
"IOV %s - %s ", lastIOVsince.c_str(), firstIOVsince.c_str()));
281 template <AlignmentPI::coordinate coord>
282 using TrackerAlignmentCompare = TrackerAlignmentComparatorBase<coord, 1, MULTI_IOV>;
284 template <AlignmentPI::coordinate coord>
285 using TrackerAlignmentCompareTwoTags = TrackerAlignmentComparatorBase<coord, 2, SINGLE_IOV>;
287 typedef TrackerAlignmentCompare<AlignmentPI::t_x> TrackerAlignmentCompareX;
288 typedef TrackerAlignmentCompare<AlignmentPI::t_y> TrackerAlignmentCompareY;
289 typedef TrackerAlignmentCompare<AlignmentPI::t_z> TrackerAlignmentCompareZ;
291 typedef TrackerAlignmentCompare<AlignmentPI::rot_alpha> TrackerAlignmentCompareAlpha;
292 typedef TrackerAlignmentCompare<AlignmentPI::rot_beta> TrackerAlignmentCompareBeta;
293 typedef TrackerAlignmentCompare<AlignmentPI::rot_gamma> TrackerAlignmentCompareGamma;
295 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_x> TrackerAlignmentCompareXTwoTags;
296 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_y> TrackerAlignmentCompareYTwoTags;
297 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_z> TrackerAlignmentCompareZTwoTags;
299 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_alpha> TrackerAlignmentCompareAlphaTwoTags;
300 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_beta> TrackerAlignmentCompareBetaTwoTags;
301 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_gamma> TrackerAlignmentCompareGammaTwoTags;
307 template <AlignmentPI::partitions q>
308 class TrackerAlignmentSummary :
public PlotImage<Alignments, MULTI_IOV> {
310 TrackerAlignmentSummary()
314 bool fill()
override {
315 auto tag = PlotBase::getTag<0>();
316 auto sorted_iovs =
tag.iovs;
319 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const &t1,
auto const &t2) {
320 return std::get<0>(t1) < std::get<0>(t2);
323 auto firstiov = sorted_iovs.front();
324 auto lastiov = sorted_iovs.back();
326 std::shared_ptr<Alignments> last_payload = fetchPayload(std::get<1>(lastiov));
327 std::shared_ptr<Alignments> first_payload = fetchPayload(std::get<1>(firstiov));
332 std::vector<AlignTransform> ref_ali = first_payload->m_align;
333 std::vector<AlignTransform> target_ali = last_payload->m_align;
335 if (ref_ali.size() != target_ali.size()) {
337 <<
"the size of the reference alignment (" << ref_ali.size()
338 <<
") is different from the one of the target (" << target_ali.size()
339 <<
")! You are probably trying to compare different underlying geometries. Exiting";
345 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
346 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
350 for (
const auto &ali : ref_ali) {
351 auto mydetid = ali.rawId();
354 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
356 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
361 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 1800, 1200);
364 std::unordered_map<AlignmentPI::coordinate, std::unique_ptr<TH1F> > diffs;
372 for (
const auto &coord : coords) {
377 diffs[coord] = std::make_unique<TH1F>(Form(
"hDiff_%s", s_coord.c_str()),
378 Form(
";#Delta%s %s;n. of modules", s_coord.c_str(), unit.c_str()),
384 int loopedComponents(0);
385 for (
unsigned int i = 0; i < ref_ali.size(); i++) {
386 if (ref_ali[i].rawId() == target_ali[
i].rawId()) {
393 CLHEP::HepRotation target_rot(target_ali[i].
rotation());
394 CLHEP::HepRotation ref_rot(ref_ali[i].
rotation());
419 for (
const auto &coord : coords) {
422 diffs[coord]->Fill((target_ali[i].translation().
x() - ref_ali[i].translation().
x()) *
426 diffs[coord]->Fill((target_ali[i].translation().
y() - ref_ali[i].translation().
y()) *
430 diffs[coord]->Fill((target_ali[i].translation().
z() - ref_ali[i].translation().
z()) *
434 diffs[coord]->Fill((target_eulerAngles[0] - ref_eulerAngles[0]) * 1000.);
437 diffs[coord]->Fill((target_eulerAngles[1] - ref_eulerAngles[1]) * 1000.);
440 diffs[coord]->Fill((target_eulerAngles[2] - ref_eulerAngles[2]) * 1000.);
443 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
452 auto legend = std::make_unique<TLegend>(0.14, 0.93, 0.55, 0.98);
457 legend->SetTextSize(0.03);
459 for (
const auto &coord : coords) {
460 canvas.cd(c_index)->SetLogy();
461 canvas.cd(c_index)->SetTopMargin(0.02);
462 canvas.cd(c_index)->SetBottomMargin(0.15);
463 canvas.cd(c_index)->SetLeftMargin(0.14);
464 canvas.cd(c_index)->SetRightMargin(0.04);
465 diffs[coord]->SetLineWidth(2);
473 int i_max = diffs[coord]->FindLastBinAbove(0.);
474 int i_min = diffs[coord]->FindFirstBinAbove(0.);
475 diffs[coord]->GetXaxis()->SetRange(
std::max(1, i_min - 10),
std::min(i_max + 10, diffs[coord]->GetNbinsX()));
476 diffs[coord]->Draw(
"HIST");
479 legend->Draw(
"same");
491 typedef TrackerAlignmentSummary<AlignmentPI::BPix> TrackerAlignmentSummaryBPix;
492 typedef TrackerAlignmentSummary<AlignmentPI::FPix> TrackerAlignmentSummaryFPix;
493 typedef TrackerAlignmentSummary<AlignmentPI::TIB> TrackerAlignmentSummaryTIB;
495 typedef TrackerAlignmentSummary<AlignmentPI::TID> TrackerAlignmentSummaryTID;
496 typedef TrackerAlignmentSummary<AlignmentPI::TOB> TrackerAlignmentSummaryTOB;
497 typedef TrackerAlignmentSummary<AlignmentPI::TEC> TrackerAlignmentSummaryTEC;
503 template <AlignmentPI::coordinate coord>
504 class BPixBarycenterHistory :
public HistoryPlot<Alignments, float> {
506 BPixBarycenterHistory()
510 ~BPixBarycenterHistory()
override =
default;
513 std::vector<AlignTransform> alignments = payload.
m_align;
515 float barycenter = 0.;
517 for (
const auto &ali : alignments) {
520 <<
"Encountered invalid Tracker DetId:" << ali.rawId() <<
" " <<
DetId(ali.rawId()).det()
525 int subid =
DetId(ali.rawId()).subdetId();
532 barycenter += (ali.translation().x());
535 barycenter += (ali.translation().y());
538 barycenter += (ali.translation().z());
541 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
546 edm::LogInfo(
"TrackerAlignment_PayloadInspector") <<
"barycenter (" << barycenter <<
")/n. modules (" << nmodules
547 <<
") = " << barycenter / nmodules << std::endl;
550 barycenter /= nmodules;
553 barycenter += hardcodeGPR.at(coord);
560 typedef BPixBarycenterHistory<AlignmentPI::t_x> X_BPixBarycenterHistory;
561 typedef BPixBarycenterHistory<AlignmentPI::t_y> Y_BPixBarycenterHistory;
562 typedef BPixBarycenterHistory<AlignmentPI::t_z> Z_BPixBarycenterHistory;
567 class TrackerAlignmentBarycenters :
public PlotImage<Alignments, SINGLE_IOV> {
571 bool fill()
override {
572 auto tag = PlotBase::getTag<0>();
573 auto iov =
tag.iovs.front();
574 std::shared_ptr<Alignments> payload = fetchPayload(std::get<1>(iov));
575 unsigned int run = std::get<0>(iov);
577 TCanvas
canvas(
"Tracker Alignment Barycenter Summary",
"Tracker Alignment Barycenter summary", 1600, 1000);
580 canvas.SetTopMargin(0.07);
581 canvas.SetBottomMargin(0.06);
582 canvas.SetLeftMargin(0.15);
583 canvas.SetRightMargin(0.03);
587 auto h2_BarycenterParameters =
588 std::make_unique<TH2F>(
"Parameters",
"SubDetector Barycenter summary", 6, 0.0, 6.0, 6, 0, 6.);
590 auto h2_uncBarycenterParameters =
591 std::make_unique<TH2F>(
"Parameters2",
"SubDetector Barycenter summary", 6, 0.0, 6.0, 6, 0, 6.);
593 h2_BarycenterParameters->SetStats(
false);
594 h2_BarycenterParameters->SetTitle(
nullptr);
595 h2_uncBarycenterParameters->SetStats(
false);
596 h2_uncBarycenterParameters->SetTitle(
nullptr);
598 std::vector<AlignTransform> alignments = payload->m_align;
603 const char *path_toTopologyXML = isPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
604 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
614 auto Xbarycenters = barycenters.
getX();
615 auto Ybarycenters = barycenters.
getY();
616 auto Zbarycenters = barycenters.
getZ();
621 auto c_Xbarycenters = barycenters.
getX();
622 auto c_Ybarycenters = barycenters.
getY();
623 auto c_Zbarycenters = barycenters.
getZ();
625 h2_BarycenterParameters->GetXaxis()->SetBinLabel(1,
"X [cm]");
626 h2_BarycenterParameters->GetXaxis()->SetBinLabel(2,
"Y [cm]");
627 h2_BarycenterParameters->GetXaxis()->SetBinLabel(3,
"Z [cm]");
628 h2_BarycenterParameters->GetXaxis()->SetBinLabel(4,
"X_{no GPR} [cm]");
629 h2_BarycenterParameters->GetXaxis()->SetBinLabel(5,
"Y_{no GPR} [cm]");
630 h2_BarycenterParameters->GetXaxis()->SetBinLabel(6,
"Z_{no GPR} [cm]");
632 bool isLikelyMC(
false);
634 std::count_if(Xbarycenters.begin(), Xbarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
636 std::count_if(Ybarycenters.begin(), Ybarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
638 std::count_if(Zbarycenters.begin(), Zbarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
642 if ((checkX + checkY + checkZ) == 0 && run == 1)
645 unsigned int yBin = 6;
646 for (
unsigned int i = 0; i < 6; i++) {
649 h2_BarycenterParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
651 h2_BarycenterParameters->SetBinContent(1, yBin, c_Xbarycenters[i]);
652 h2_BarycenterParameters->SetBinContent(2, yBin, c_Ybarycenters[i]);
653 h2_BarycenterParameters->SetBinContent(3, yBin, c_Zbarycenters[i]);
656 h2_uncBarycenterParameters->SetBinContent(4, yBin, Xbarycenters[i]);
657 h2_uncBarycenterParameters->SetBinContent(5, yBin, Ybarycenters[i]);
658 h2_uncBarycenterParameters->SetBinContent(6, yBin, Zbarycenters[i]);
662 h2_BarycenterParameters->GetXaxis()->LabelsOption(
"h");
663 h2_BarycenterParameters->GetYaxis()->SetLabelSize(0.05);
664 h2_BarycenterParameters->GetXaxis()->SetLabelSize(0.05);
665 h2_BarycenterParameters->SetMarkerSize(1.5);
666 h2_BarycenterParameters->Draw(
"TEXT");
668 h2_uncBarycenterParameters->SetMarkerSize(1.5);
669 h2_uncBarycenterParameters->SetMarkerColor(kRed);
670 h2_uncBarycenterParameters->Draw(
"TEXTsame");
675 t1.SetTextSize(0.05);
676 t1.DrawLatex(0.5, 0.96, Form(
"Tracker Alignment Barycenters, IOV %i", run));
677 t1.SetTextSize(0.025);
692 template <
int ntags, IOVMultiplicity nIOVs>
693 class TrackerAlignmentBarycentersComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
695 TrackerAlignmentBarycentersComparatorBase()
698 bool fill()
override {
700 auto theIOVs = PlotBase::getTag<0>().
iovs;
701 auto tagname1 = PlotBase::getTag<0>().
name;
703 auto firstiov = theIOVs.front();
704 std::tuple<cond::Time_t, cond::Hash> lastiov;
707 assert(this->m_plotAnnotations.ntags < 3);
709 if (this->m_plotAnnotations.ntags == 2) {
710 auto tag2iovs = PlotBase::getTag<1>().
iovs;
711 tagname2 = PlotBase::getTag<1>().
name;
712 lastiov = tag2iovs.front();
714 lastiov = theIOVs.back();
717 unsigned int first_run = std::get<0>(firstiov);
718 unsigned int last_run = std::get<0>(lastiov);
720 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
721 std::vector<AlignTransform> last_alignments = last_payload->m_align;
723 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
724 std::vector<AlignTransform> first_alignments = first_payload->m_align;
730 const char *path_toTopologyXML = isInitialPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
731 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
736 path_toTopologyXML = isFinalPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
737 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
742 TCanvas
canvas(
"Tracker Alignment Barycenter Summary",
"Tracker Alignment Barycenter summary", 1200, 800);
745 canvas.SetTopMargin(0.07);
746 canvas.SetBottomMargin(0.06);
747 canvas.SetLeftMargin(0.15);
748 canvas.SetRightMargin(0.03);
752 auto h2_BarycenterDiff =
753 std::make_unique<TH2F>(
"Parameters diff",
"SubDetector Barycenter Difference", 3, 0.0, 3.0, 6, 0, 6.);
755 h2_BarycenterDiff->SetStats(
false);
756 h2_BarycenterDiff->SetTitle(
nullptr);
757 h2_BarycenterDiff->GetXaxis()->SetBinLabel(1,
"X [#mum]");
758 h2_BarycenterDiff->GetXaxis()->SetBinLabel(2,
"Y [#mum]");
759 h2_BarycenterDiff->GetXaxis()->SetBinLabel(3,
"Z [#mum]");
767 unsigned int yBin = 6;
768 for (
unsigned int i = 0; i < 6; i++) {
771 h2_BarycenterDiff->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
772 h2_BarycenterDiff->SetBinContent(
774 h2_BarycenterDiff->SetBinContent(
776 h2_BarycenterDiff->SetBinContent(
781 h2_BarycenterDiff->GetXaxis()->LabelsOption(
"h");
782 h2_BarycenterDiff->GetYaxis()->SetLabelSize(0.05);
783 h2_BarycenterDiff->GetXaxis()->SetLabelSize(0.05);
784 h2_BarycenterDiff->SetMarkerSize(1.5);
785 h2_BarycenterDiff->SetMarkerColor(kRed);
786 h2_BarycenterDiff->Draw(
"TEXT");
791 t1.SetTextSize(0.05);
792 t1.DrawLatex(0.5, 0.96, Form(
"Tracker Alignment Barycenters Diff, IOV %i - IOV %i", last_run, first_run));
793 t1.SetTextSize(0.025);
802 bool isInitialPhase0;
806 using TrackerAlignmentBarycentersCompare = TrackerAlignmentBarycentersComparatorBase<1, MULTI_IOV>;
807 using TrackerAlignmentBarycentersCompareTwoTags = TrackerAlignmentBarycentersComparatorBase<2, SINGLE_IOV>;
812 template <
int ntags, IOVMultiplicity nIOVs>
813 class PixelBarycentersComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
815 PixelBarycentersComparatorBase() :
PlotImage<
Alignments, nIOVs, ntags>(
"Comparison of Pixel Barycenters") {}
817 bool fill()
override {
819 auto theIOVs = PlotBase::getTag<0>().
iovs;
820 auto tagname1 = PlotBase::getTag<0>().
name;
822 auto firstiov = theIOVs.front();
823 std::tuple<cond::Time_t, cond::Hash> lastiov;
826 assert(this->m_plotAnnotations.ntags < 3);
828 if (this->m_plotAnnotations.ntags == 2) {
829 auto tag2iovs = PlotBase::getTag<1>().
iovs;
830 tagname2 = PlotBase::getTag<1>().
name;
831 lastiov = tag2iovs.front();
833 lastiov = theIOVs.back();
836 unsigned int first_run = std::get<0>(firstiov);
837 unsigned int last_run = std::get<0>(lastiov);
839 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
840 std::vector<AlignTransform> last_alignments = last_payload->m_align;
842 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
843 std::vector<AlignTransform> first_alignments = first_payload->m_align;
845 TCanvas
canvas(
"Pixel Barycenter Summary",
"Pixel Barycenter summary", 1200, 1200);
852 t1.SetTextSize(0.03);
855 (
"Pixel Barycenters comparison, IOV: #color[2]{" +
std::to_string(first_run) +
858 t1.SetTextSize(0.025);
860 for (
unsigned int c = 1;
c <= 4;
c++) {
861 canvas.cd(
c)->SetTopMargin(0.07);
862 canvas.cd(
c)->SetBottomMargin(0.12);
863 canvas.cd(
c)->SetLeftMargin(0.15);
864 canvas.cd(
c)->SetRightMargin(0.03);
869 std::array<std::string, 3> structures = {{
"FPIX-",
"BPIX",
"FPIX+"}};
870 std::array<std::unique_ptr<TH2F>, 3>
histos;
876 const char *path_toTopologyXML = isInitialPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
877 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
887 path_toTopologyXML = isFinalPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml"
888 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
898 if (isFinalPhase0 != isInitialPhase0) {
900 <<
"the size of the reference alignment (" << first_alignments.size()
901 <<
") is different from the one of the target (" << last_alignments.size()
902 <<
")! You are probably trying to compare different underlying geometries.";
905 unsigned int index(0);
906 for (
const auto &piece : structures) {
907 const char *
name = piece.c_str();
908 histos[
index] = std::make_unique<TH2F>(
910 Form(
"%s x-y Barycenter Difference;x_{%s}-x_{TOB} [mm];y_{%s}-y_{TOB} [mm]", name, name, name),
918 histos[
index]->SetStats(
false);
919 histos[
index]->SetTitle(
nullptr);
920 histos[
index]->GetYaxis()->SetLabelSize(0.05);
921 histos[
index]->GetXaxis()->SetLabelSize(0.05);
922 histos[
index]->GetYaxis()->SetTitleSize(0.06);
923 histos[
index]->GetXaxis()->SetTitleSize(0.06);
924 histos[
index]->GetYaxis()->CenterTitle();
925 histos[
index]->GetXaxis()->CenterTitle();
926 histos[
index]->GetXaxis()->SetTitleOffset(0.9);
930 auto h2_ZBarycenterDiff = std::make_unique<TH2F>(
931 "Pixel_z_diff",
"Pixel z-Barycenter Difference;; z_{Pixel-Ideal} -z_{TOB} [mm]", 3, -0.5, 2.5, 100, -10., 10.);
932 h2_ZBarycenterDiff->SetStats(
false);
933 h2_ZBarycenterDiff->SetTitle(
nullptr);
934 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(1,
"FPIX -");
935 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(2,
"BPIX");
936 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(3,
"FPIX +");
937 h2_ZBarycenterDiff->GetYaxis()->SetLabelSize(0.05);
938 h2_ZBarycenterDiff->GetXaxis()->SetLabelSize(0.07);
939 h2_ZBarycenterDiff->GetYaxis()->SetTitleSize(0.06);
940 h2_ZBarycenterDiff->GetXaxis()->SetTitleSize(0.06);
941 h2_ZBarycenterDiff->GetYaxis()->CenterTitle();
942 h2_ZBarycenterDiff->GetXaxis()->CenterTitle();
943 h2_ZBarycenterDiff->GetYaxis()->SetTitleOffset(1.1);
945 std::function<GlobalPoint(int)> cutFunctorInitial = [&myInitialBarycenters](
int index) {
958 std::function<GlobalPoint(int)> cutFunctorFinal = [&myFinalBarycenters](
int index) {
971 float x0i, x0f, y0i, y0f;
974 t1.SetTextSize(0.047);
975 for (
unsigned int c = 1;
c <= 3;
c++) {
976 x0i = cutFunctorInitial(
c).x() * 10;
977 x0f = cutFunctorFinal(
c).x() * 10;
978 y0i = cutFunctorInitial(
c).y() * 10;
979 y0f = cutFunctorFinal(
c).y() * 10;
982 histos[
c - 1]->Draw();
984 COUT <<
"initial x,y " << std::left << std::setw(7) << structures[
c - 1] <<
" (" << x0i <<
"," << y0i <<
") mm"
986 COUT <<
"final x,y " << std::left << std::setw(7) << structures[
c - 1] <<
" (" << x0f <<
"," << y0f <<
") mm"
989 TMarker *initial =
new TMarker(x0i, y0i, 21);
990 TMarker *
final =
new TMarker(x0f, y0f, 20);
992 initial->SetMarkerColor(kRed);
993 final->SetMarkerColor(kBlue);
994 initial->SetMarkerSize(2.5);
995 final->SetMarkerSize(2.5);
996 t1.SetTextColor(kRed);
998 t1.DrawLatex(x0i, y0i + (y0i > y0f ? 0.3 : -0.5), Form(
"(%.2f,%.2f)", x0i, y0i));
1000 t1.SetTextColor(kBlue);
1001 t1.DrawLatex(x0f, y0f + (y0i > y0f ? -0.5 : 0.3), Form(
"(%.2f,%.2f)", x0f, y0f));
1006 h2_ZBarycenterDiff->Draw();
1011 std::array<double, 3> hardcodeIdealZPhase0 = {{-41.94909, 0., 41.94909}};
1012 std::array<double, 3> hardcodeIdealZPhase1 = {{-39.82911, 0., 39.82911}};
1014 for (
unsigned int c = 1;
c <= 3;
c++) {
1018 (cutFunctorInitial(
c).z() - (isInitialPhase0 ? hardcodeIdealZPhase0[
c - 1] : hardcodeIdealZPhase1[
c - 1])) *
1021 (cutFunctorFinal(
c).z() - (isFinalPhase0 ? hardcodeIdealZPhase0[
c - 1] : hardcodeIdealZPhase1[
c - 1])) * 10;
1023 TMarker *initial =
new TMarker(
c - 1, z0i, 21);
1024 TMarker *
final =
new TMarker(
c - 1, z0f, 20);
1026 COUT <<
"initial z " << std::left << std::setw(7) << structures[
c - 1] <<
" " << z0i <<
" mm" << std::endl;
1027 COUT <<
"final z " << std::left << std::setw(7) << structures[
c - 1] <<
" " << z0f <<
" mm" << std::endl;
1029 initial->SetMarkerColor(kRed);
1030 final->SetMarkerColor(kBlue);
1031 initial->SetMarkerSize(2.5);
1032 final->SetMarkerSize(2.5);
1034 t1.SetTextColor(kRed);
1035 t1.DrawLatex(
c - 1, z0i + (z0i > z0f ? 1. : -1.5), Form(
"(%.2f)", z0i));
1036 final->Draw(
"same");
1037 t1.SetTextColor(kBlue);
1038 t1.DrawLatex(
c - 1, z0f + (z0i > z0f ? -1.5 : 1), Form(
"(%.2f)", z0f));
1048 bool isInitialPhase0;
1052 using PixelBarycentersCompare = PixelBarycentersComparatorBase<1, MULTI_IOV>;
1053 using PixelBarycentersCompareTwoTags = PixelBarycentersComparatorBase<2, SINGLE_IOV>;
const std::array< double, 6 > getY()
bool compare(const P &i, const P &j)
const edm::EventSetup & c
void makeNicePlotStyle(TH1 *hist, int color)
void computeBarycenters(const std::vector< AlignTransform > &input, const TrackerTopology &tTopo, const std::map< AlignmentPI::coordinate, float > &GPR)
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
std::string getStringFromPart(AlignmentPI::partitions i)
std::string to_string(const V &value)
Log< level::Error, false > LogError
std::vector< AlignTransform > m_align
static const float cmToUm
const uint16_t range(const Frame &aFrame)
void makeNiceStats(TH1F *hist, AlignmentPI::partitions part, int color)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
const std::array< double, 6 > getX()
static const unsigned int phase0size
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
uint16_t const *__restrict__ x
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Log< level::Info, false > LogInfo
GlobalPoint getPartitionAvg(AlignmentPI::PARTITION p)
AlgebraicVector EulerAngles
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
std::string getStringFromCoordinate(AlignmentPI::coordinate coord)
bool tidIsDoubleSide(const DetId &id) const
std::pair< double, double > calculatePosition(TVirtualPad *myPad, int boundary)
static std::atomic< unsigned int > counter
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Log< level::Warning, false > LogWarning
const std::array< double, 6 > getZ()
Basic3DVector unit() const
constexpr Detector det() const
get the detector field from this detid