21 #include "CLHEP/Vector/RotationInterfaces.h" 46 #include "TPaveStats.h" 61 const std::map<AlignmentPI::coordinate, float> hardcodeGPR = {
69 template <
int ntags, IOVMultiplicity nIOVs>
70 class TrackerAlignmentCompareAll :
public PlotImage<Alignments, nIOVs, ntags> {
72 TrackerAlignmentCompareAll()
73 :
PlotImage<
Alignments, nIOVs, ntags>(
"comparison of all coordinates between two geometries") {}
75 bool fill()
override {
76 TGaxis::SetExponentOffset(-0.12, 0.01,
"y");
79 auto theIOVs = PlotBase::getTag<0>().iovs;
80 auto tagname1 = PlotBase::getTag<0>().
name;
82 auto firstiov = theIOVs.front();
83 std::tuple<cond::Time_t, cond::Hash> lastiov;
86 assert(this->m_plotAnnotations.ntags < 3);
88 if (this->m_plotAnnotations.ntags == 2) {
89 auto tag2iovs = PlotBase::getTag<1>().iovs;
90 tagname2 = PlotBase::getTag<1>().
name;
91 lastiov = tag2iovs.front();
93 lastiov = theIOVs.back();
96 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
97 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
102 std::vector<AlignTransform> ref_ali = first_payload->m_align;
103 std::vector<AlignTransform> target_ali = last_payload->m_align;
105 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 2000, 1200);
108 if (ref_ali.size() != target_ali.size()) {
110 <<
"the size of the reference alignment (" << ref_ali.size()
111 <<
") is different from the one of the target (" << target_ali.size()
112 <<
")! You are probably trying to compare different underlying geometries. Exiting";
118 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 119 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
123 for (
const auto &ali : ref_ali) {
124 auto mydetid = ali.rawId();
127 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
129 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
141 std::unordered_map<AlignmentPI::coordinate, std::unique_ptr<TH1F> > diffs;
144 for (
const auto &coord : coords) {
149 diffs[coord] = std::make_unique<TH1F>(Form(
"comparison_%s", s_coord.c_str()),
150 Form(
";Detector Id index; #Delta%s %s", s_coord.c_str(),
unit.c_str()),
153 ref_ali.size() - 0.5);
157 std::vector<int> boundaries;
160 unsigned int subpad{1};
161 TLegend
legend = TLegend(0.17, 0.84, 0.95, 0.94);
162 legend.SetTextSize(0.023);
163 for (
const auto &coord : coords) {
165 canvas.cd(subpad)->SetTopMargin(0.06);
166 canvas.cd(subpad)->SetLeftMargin(0.17);
167 canvas.cd(subpad)->SetRightMargin(0.05);
168 canvas.cd(subpad)->SetBottomMargin(0.15);
170 auto max = diffs[coord]->GetMaximum();
171 auto min = diffs[coord]->GetMinimum();
177 diffs[coord]->GetYaxis()->SetRangeUser(-
range * 1.5,
range * 1.5);
178 diffs[coord]->GetYaxis()->SetTitleOffset(1.5);
179 diffs[coord]->SetMarkerStyle(20);
180 diffs[coord]->SetMarkerSize(0.5);
181 diffs[coord]->Draw(
"P");
184 if (this->m_plotAnnotations.ntags == 2) {
185 legend.SetHeader(
"#bf{Two Tags Comparison}",
"C");
188 (
"#splitline{" + tagname1 +
" : " + firstIOVsince +
"}{" + tagname2 +
" : " + lastIOVsince +
"}")
192 legend.SetHeader((
"tag: #bf{" + tagname1 +
"}").c_str(),
"C");
193 legend.AddEntry(diffs[coord].
get(),
194 (
"#splitline{IOV since: " + firstIOVsince +
"}{IOV since: " + lastIOVsince +
"}").c_str(),
205 TLine
l[6][boundaries.size()];
207 for (
unsigned int i = 0;
i < 6;
i++) {
208 tSubdet[
i].SetTextColor(kRed);
210 tSubdet[
i].SetTextAlign(21);
211 tSubdet[
i].SetTextSize(0.03);
212 tSubdet[
i].SetTextAngle(90);
216 for (
const auto &coord : coords) {
221 for (
const auto &
line : boundaries) {
222 l[subpad][
i] = TLine(diffs[coord]->GetBinLowEdge(
line),
223 canvas.cd(subpad + 1)->GetUymin(),
224 diffs[coord]->GetBinLowEdge(
line),
225 canvas.cd(subpad + 1)->GetUymax() * 0.84);
226 l[subpad][
i].SetLineWidth(1);
227 l[subpad][
i].SetLineStyle(9);
228 l[subpad][
i].SetLineColor(2);
229 l[subpad][
i].Draw(
"same");
233 const auto &theX_ = {0.2, 0.24, 0.31, 0.4, 0.55, 0.8};
234 for (
unsigned int j = 1;
j <= 7;
j++) {
236 tSubdet[subpad].DrawLatex(
242 ltx.SetTextSize(0.042);
243 ltx.SetTextAlign(11);
244 ltx.DrawLatexNDC(
canvas.cd(subpad + 1)->GetLeftMargin(),
245 1 -
canvas.cd(subpad + 1)->GetTopMargin() + 0.01,
246 (
"Tracker Alignment Compare : #color[4]{" + s_coord +
"}").c_str());
259 typedef TrackerAlignmentCompareAll<1, MULTI_IOV> TrackerAlignmentComparatorSingleTag;
260 typedef TrackerAlignmentCompareAll<2, SINGLE_IOV> TrackerAlignmentComparatorTwoTags;
267 template <AlignmentPI::coordinate coord,
int ntags, IOVMultiplicity nIOVs>
268 class TrackerAlignmentComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
270 TrackerAlignmentComparatorBase()
272 " coordinate between two geometries") {}
274 bool fill()
override {
275 TGaxis::SetExponentOffset(-0.12, 0.01,
"y");
278 auto theIOVs = PlotBase::getTag<0>().iovs;
279 auto tagname1 = PlotBase::getTag<0>().
name;
281 auto firstiov = theIOVs.front();
282 std::tuple<cond::Time_t, cond::Hash> lastiov;
285 assert(this->m_plotAnnotations.ntags < 3);
287 if (this->m_plotAnnotations.ntags == 2) {
288 auto tag2iovs = PlotBase::getTag<1>().iovs;
289 tagname2 = PlotBase::getTag<1>().
name;
290 lastiov = tag2iovs.front();
292 lastiov = theIOVs.back();
295 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
296 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
301 std::vector<AlignTransform> ref_ali = first_payload->m_align;
302 std::vector<AlignTransform> target_ali = last_payload->m_align;
304 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 1200, 1200);
306 if (ref_ali.size() != target_ali.size()) {
308 <<
"the size of the reference alignment (" << ref_ali.size()
309 <<
") is different from the one of the target (" << target_ali.size()
310 <<
")! You are probably trying to compare different underlying geometries. Exiting";
316 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 317 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
321 for (
const auto &ali : ref_ali) {
322 auto mydetid = ali.rawId();
325 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
327 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
337 std::unique_ptr<TH1F>
compare =
338 std::make_unique<TH1F>(
"comparison",
339 Form(
";Detector Id index; #Delta%s %s", s_coord.c_str(),
unit.c_str()),
342 ref_ali.size() - 0.5);
345 std::vector<int> boundaries;
350 canvas.SetTopMargin(0.06);
351 canvas.SetLeftMargin(0.17);
352 canvas.SetRightMargin(0.05);
353 canvas.SetBottomMargin(0.15);
363 compare->GetYaxis()->SetTitleOffset(1.5);
371 TLine
l[boundaries.size()];
373 for (
const auto &
line : boundaries) {
378 l[
i].SetLineWidth(1);
379 l[
i].SetLineStyle(9);
380 l[
i].SetLineColor(2);
387 tSubdet.SetTextAlign(21);
388 tSubdet.SetTextSize(0.027);
389 tSubdet.SetTextAngle(90);
390 for (
unsigned int j = 1;
j <= 6;
j++) {
392 tSubdet.SetTextColor(kRed);
395 float theX_ = myPair.first + 0.025;
399 TLegend
legend = TLegend(0.17, 0.86, 0.95, 0.94);
400 if (this->m_plotAnnotations.ntags == 2) {
401 legend.SetHeader(
"#bf{Two Tags Comparison}",
"C");
404 (
"#splitline{" + tagname1 +
" : " + firstIOVsince +
"}{" + tagname2 +
" : " + lastIOVsince +
"}").c_str(),
407 legend.SetHeader((
"tag: #bf{" + tagname1 +
"}").c_str(),
"C");
409 (
"#splitline{IOV since: " + firstIOVsince +
"}{IOV since: " + lastIOVsince +
"}").c_str(),
412 legend.SetTextSize(0.020);
417 ltx.SetTextSize(0.042);
418 ltx.SetTextAlign(11);
419 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
420 1 - gPad->GetTopMargin() + 0.01,
421 (
"Tracker Alignment Compare :#color[4]{" + s_coord +
"}").c_str());
430 template <AlignmentPI::coordinate coord>
431 using TrackerAlignmentCompare = TrackerAlignmentComparatorBase<coord, 1, MULTI_IOV>;
433 template <AlignmentPI::coordinate coord>
434 using TrackerAlignmentCompareTwoTags = TrackerAlignmentComparatorBase<coord, 2, SINGLE_IOV>;
436 typedef TrackerAlignmentCompare<AlignmentPI::t_x> TrackerAlignmentCompareX;
437 typedef TrackerAlignmentCompare<AlignmentPI::t_y> TrackerAlignmentCompareY;
438 typedef TrackerAlignmentCompare<AlignmentPI::t_z> TrackerAlignmentCompareZ;
440 typedef TrackerAlignmentCompare<AlignmentPI::rot_alpha> TrackerAlignmentCompareAlpha;
441 typedef TrackerAlignmentCompare<AlignmentPI::rot_beta> TrackerAlignmentCompareBeta;
442 typedef TrackerAlignmentCompare<AlignmentPI::rot_gamma> TrackerAlignmentCompareGamma;
444 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_x> TrackerAlignmentCompareXTwoTags;
445 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_y> TrackerAlignmentCompareYTwoTags;
446 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_z> TrackerAlignmentCompareZTwoTags;
448 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_alpha> TrackerAlignmentCompareAlphaTwoTags;
449 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_beta> TrackerAlignmentCompareBetaTwoTags;
450 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_gamma> TrackerAlignmentCompareGammaTwoTags;
456 template <
int ntags, IOVMultiplicity nIOVs, AlignmentPI::partitions q>
457 class TrackerAlignmentSummaryBase :
public PlotImage<Alignments, nIOVs, ntags> {
459 TrackerAlignmentSummaryBase()
460 :
PlotImage<
Alignments, nIOVs, ntags>(
"Comparison of all coordinates between two geometries for " +
463 bool fill()
override {
465 auto theIOVs = PlotBase::getTag<0>().iovs;
466 auto tagname1 = PlotBase::getTag<0>().
name;
468 auto firstiov = theIOVs.front();
469 std::tuple<cond::Time_t, cond::Hash> lastiov;
472 assert(this->m_plotAnnotations.ntags < 3);
474 if (this->m_plotAnnotations.ntags == 2) {
475 auto tag2iovs = PlotBase::getTag<1>().iovs;
476 tagname2 = PlotBase::getTag<1>().
name;
477 lastiov = tag2iovs.front();
479 lastiov = theIOVs.back();
482 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
483 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
488 std::vector<AlignTransform> ref_ali = first_payload->m_align;
489 std::vector<AlignTransform> target_ali = last_payload->m_align;
491 if (ref_ali.size() != target_ali.size()) {
493 <<
"the size of the reference alignment (" << ref_ali.size()
494 <<
") is different from the one of the target (" << target_ali.size()
495 <<
")! You are probably trying to compare different underlying geometries. Exiting";
501 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 502 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
506 for (
const auto &ali : ref_ali) {
507 auto mydetid = ali.rawId();
510 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
512 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
517 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 1800, 1200);
520 std::unordered_map<AlignmentPI::coordinate, std::unique_ptr<TH1F> > diffs;
528 for (
const auto &coord : coords) {
533 diffs[coord] = std::make_unique<TH1F>(Form(
"hDiff_%s", s_coord.c_str()),
534 Form(
";#Delta%s %s;n. of modules", s_coord.c_str(),
unit.c_str()),
541 std::vector<int> boundaries{};
546 auto legend = std::make_unique<TLegend>(0.14, 0.93, 0.55, 0.98);
551 legend->SetTextSize(0.03);
553 for (
const auto &coord : coords) {
554 canvas.cd(c_index)->SetLogy();
555 canvas.cd(c_index)->SetTopMargin(0.02);
556 canvas.cd(c_index)->SetBottomMargin(0.15);
557 canvas.cd(c_index)->SetLeftMargin(0.14);
558 canvas.cd(c_index)->SetRightMargin(0.04);
559 diffs[coord]->SetLineWidth(2);
567 int i_max = diffs[coord]->FindLastBinAbove(0.);
568 int i_min = diffs[coord]->FindFirstBinAbove(0.);
569 diffs[coord]->GetXaxis()->SetRange(
std::max(1, i_min - 10),
std::min(i_max + 10, diffs[coord]->GetNbinsX()));
570 diffs[coord]->Draw(
"HIST");
585 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::BPix> TrackerAlignmentSummaryBPix;
586 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::FPix> TrackerAlignmentSummaryFPix;
587 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TIB> TrackerAlignmentSummaryTIB;
589 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TID> TrackerAlignmentSummaryTID;
590 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TOB> TrackerAlignmentSummaryTOB;
591 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TEC> TrackerAlignmentSummaryTEC;
593 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::BPix> TrackerAlignmentSummaryBPixTwoTags;
594 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::FPix> TrackerAlignmentSummaryFPixTwoTags;
595 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TIB> TrackerAlignmentSummaryTIBTwoTags;
597 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TID> TrackerAlignmentSummaryTIDTwoTags;
598 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TOB> TrackerAlignmentSummaryTOBTwoTags;
599 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TEC> TrackerAlignmentSummaryTECTwoTags;
605 template <AlignmentPI::coordinate coord>
606 class BPixBarycenterHistory :
public HistoryPlot<Alignments, float> {
608 BPixBarycenterHistory()
612 ~BPixBarycenterHistory()
override =
default;
615 std::vector<AlignTransform> alignments =
payload.m_align;
617 float barycenter = 0.;
619 for (
const auto &ali : alignments) {
622 <<
"Encountered invalid Tracker DetId:" << ali.rawId() <<
" " <<
DetId(ali.rawId()).det()
627 int subid =
DetId(ali.rawId()).subdetId();
634 barycenter += (ali.translation().x());
637 barycenter += (ali.translation().y());
640 barycenter += (ali.translation().z());
643 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
648 edm::LogInfo(
"TrackerAlignment_PayloadInspector") <<
"barycenter (" << barycenter <<
")/n. modules (" << nmodules
649 <<
") = " << barycenter / nmodules << std::endl;
652 barycenter /= nmodules;
655 barycenter += hardcodeGPR.at(coord);
662 typedef BPixBarycenterHistory<AlignmentPI::t_x> X_BPixBarycenterHistory;
663 typedef BPixBarycenterHistory<AlignmentPI::t_y> Y_BPixBarycenterHistory;
664 typedef BPixBarycenterHistory<AlignmentPI::t_z> Z_BPixBarycenterHistory;
669 class TrackerAlignmentBarycenters :
public PlotImage<Alignments, SINGLE_IOV> {
673 bool fill()
override {
674 auto tag = PlotBase::getTag<0>();
675 auto iov =
tag.iovs.front();
676 std::shared_ptr<Alignments>
payload = fetchPayload(std::get<1>(iov));
677 unsigned int run = std::get<0>(iov);
679 TCanvas
canvas(
"Tracker Alignment Barycenter Summary",
"Tracker Alignment Barycenter summary", 1600, 1000);
682 canvas.SetTopMargin(0.07);
683 canvas.SetBottomMargin(0.06);
684 canvas.SetLeftMargin(0.15);
685 canvas.SetRightMargin(0.03);
689 auto h2_BarycenterParameters =
690 std::make_unique<TH2F>(
"Parameters",
"SubDetector Barycenter summary", 6, 0.0, 6.0, 6, 0, 6.);
692 auto h2_uncBarycenterParameters =
693 std::make_unique<TH2F>(
"Parameters2",
"SubDetector Barycenter summary", 6, 0.0, 6.0, 6, 0, 6.);
695 h2_BarycenterParameters->SetStats(
false);
696 h2_BarycenterParameters->SetTitle(
nullptr);
697 h2_uncBarycenterParameters->SetStats(
false);
698 h2_uncBarycenterParameters->SetTitle(
nullptr);
700 std::vector<AlignTransform> alignments =
payload->m_align;
705 const char *path_toTopologyXML = isPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 706 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
716 auto Xbarycenters = barycenters.
getX();
717 auto Ybarycenters = barycenters.
getY();
718 auto Zbarycenters = barycenters.
getZ();
723 auto c_Xbarycenters = barycenters.
getX();
724 auto c_Ybarycenters = barycenters.
getY();
725 auto c_Zbarycenters = barycenters.
getZ();
727 h2_BarycenterParameters->GetXaxis()->SetBinLabel(1,
"X [cm]");
728 h2_BarycenterParameters->GetXaxis()->SetBinLabel(2,
"Y [cm]");
729 h2_BarycenterParameters->GetXaxis()->SetBinLabel(3,
"Z [cm]");
730 h2_BarycenterParameters->GetXaxis()->SetBinLabel(4,
"X_{no GPR} [cm]");
731 h2_BarycenterParameters->GetXaxis()->SetBinLabel(5,
"Y_{no GPR} [cm]");
732 h2_BarycenterParameters->GetXaxis()->SetBinLabel(6,
"Z_{no GPR} [cm]");
734 bool isLikelyMC(
false);
736 std::count_if(Xbarycenters.begin(), Xbarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
738 std::count_if(Ybarycenters.begin(), Ybarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
740 std::count_if(Zbarycenters.begin(), Zbarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
744 if ((checkX + checkY + checkZ) == 0 &&
run == 1)
747 unsigned int yBin = 6;
748 for (
unsigned int i = 0;
i < 6;
i++) {
751 h2_BarycenterParameters->GetYaxis()->SetBinLabel(
yBin, theLabel.c_str());
753 h2_BarycenterParameters->SetBinContent(1,
yBin, c_Xbarycenters[
i]);
754 h2_BarycenterParameters->SetBinContent(2,
yBin, c_Ybarycenters[
i]);
755 h2_BarycenterParameters->SetBinContent(3,
yBin, c_Zbarycenters[
i]);
758 h2_uncBarycenterParameters->SetBinContent(4,
yBin, Xbarycenters[
i]);
759 h2_uncBarycenterParameters->SetBinContent(5,
yBin, Ybarycenters[
i]);
760 h2_uncBarycenterParameters->SetBinContent(6,
yBin, Zbarycenters[
i]);
764 h2_BarycenterParameters->GetXaxis()->LabelsOption(
"h");
765 h2_BarycenterParameters->GetYaxis()->SetLabelSize(0.05);
766 h2_BarycenterParameters->GetXaxis()->SetLabelSize(0.05);
767 h2_BarycenterParameters->SetMarkerSize(1.5);
768 h2_BarycenterParameters->Draw(
"TEXT");
770 h2_uncBarycenterParameters->SetMarkerSize(1.5);
771 h2_uncBarycenterParameters->SetMarkerColor(kRed);
772 h2_uncBarycenterParameters->Draw(
"TEXTsame");
777 t1.SetTextSize(0.05);
778 t1.DrawLatex(0.5, 0.96, Form(
"Tracker Alignment Barycenters, IOV %i",
run));
779 t1.SetTextSize(0.025);
794 template <
int ntags, IOVMultiplicity nIOVs>
795 class TrackerAlignmentBarycentersComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
797 TrackerAlignmentBarycentersComparatorBase()
800 bool fill()
override {
802 auto theIOVs = PlotBase::getTag<0>().iovs;
803 auto tagname1 = PlotBase::getTag<0>().
name;
805 auto firstiov = theIOVs.front();
806 std::tuple<cond::Time_t, cond::Hash> lastiov;
809 assert(this->m_plotAnnotations.ntags < 3);
811 if (this->m_plotAnnotations.ntags == 2) {
812 auto tag2iovs = PlotBase::getTag<1>().iovs;
813 tagname2 = PlotBase::getTag<1>().
name;
814 lastiov = tag2iovs.front();
816 lastiov = theIOVs.back();
819 unsigned int first_run = std::get<0>(firstiov);
820 unsigned int last_run = std::get<0>(lastiov);
822 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
823 std::vector<AlignTransform> last_alignments = last_payload->m_align;
825 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
826 std::vector<AlignTransform> first_alignments = first_payload->m_align;
832 const char *path_toTopologyXML = isInitialPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 833 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
838 path_toTopologyXML = isFinalPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 839 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
844 TCanvas
canvas(
"Tracker Alignment Barycenter Summary",
"Tracker Alignment Barycenter summary", 1200, 800);
847 canvas.SetTopMargin(0.07);
848 canvas.SetBottomMargin(0.06);
849 canvas.SetLeftMargin(0.15);
850 canvas.SetRightMargin(0.03);
854 auto h2_BarycenterDiff =
855 std::make_unique<TH2F>(
"Parameters diff",
"SubDetector Barycenter Difference", 3, 0.0, 3.0, 6, 0, 6.);
857 h2_BarycenterDiff->SetStats(
false);
858 h2_BarycenterDiff->SetTitle(
nullptr);
859 h2_BarycenterDiff->GetXaxis()->SetBinLabel(1,
"X [#mum]");
860 h2_BarycenterDiff->GetXaxis()->SetBinLabel(2,
"Y [#mum]");
861 h2_BarycenterDiff->GetXaxis()->SetBinLabel(3,
"Z [#mum]");
869 unsigned int yBin = 6;
870 for (
unsigned int i = 0;
i < 6;
i++) {
873 h2_BarycenterDiff->GetYaxis()->SetBinLabel(
yBin, theLabel.c_str());
874 h2_BarycenterDiff->SetBinContent(
876 h2_BarycenterDiff->SetBinContent(
878 h2_BarycenterDiff->SetBinContent(
883 h2_BarycenterDiff->GetXaxis()->LabelsOption(
"h");
884 h2_BarycenterDiff->GetYaxis()->SetLabelSize(0.05);
885 h2_BarycenterDiff->GetXaxis()->SetLabelSize(0.05);
886 h2_BarycenterDiff->SetMarkerSize(1.5);
887 h2_BarycenterDiff->SetMarkerColor(kRed);
888 h2_BarycenterDiff->Draw(
"TEXT");
893 t1.SetTextSize(0.05);
894 t1.DrawLatex(0.5, 0.96, Form(
"Tracker Alignment Barycenters Diff, IOV %i - IOV %i",
last_run,
first_run));
895 t1.SetTextSize(0.025);
904 bool isInitialPhase0;
908 using TrackerAlignmentBarycentersCompare = TrackerAlignmentBarycentersComparatorBase<1, MULTI_IOV>;
909 using TrackerAlignmentBarycentersCompareTwoTags = TrackerAlignmentBarycentersComparatorBase<2, SINGLE_IOV>;
914 template <
int ntags, IOVMultiplicity nIOVs>
915 class PixelBarycentersComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
917 PixelBarycentersComparatorBase() :
PlotImage<
Alignments, nIOVs, ntags>(
"Comparison of Pixel Barycenters") {}
919 bool fill()
override {
921 auto theIOVs = PlotBase::getTag<0>().iovs;
922 auto tagname1 = PlotBase::getTag<0>().
name;
924 auto firstiov = theIOVs.front();
925 std::tuple<cond::Time_t, cond::Hash> lastiov;
928 assert(this->m_plotAnnotations.ntags < 3);
930 if (this->m_plotAnnotations.ntags == 2) {
931 auto tag2iovs = PlotBase::getTag<1>().iovs;
932 tagname2 = PlotBase::getTag<1>().
name;
933 lastiov = tag2iovs.front();
935 lastiov = theIOVs.back();
938 unsigned int first_run = std::get<0>(firstiov);
939 unsigned int last_run = std::get<0>(lastiov);
941 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
942 std::vector<AlignTransform> last_alignments = last_payload->m_align;
944 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
945 std::vector<AlignTransform> first_alignments = first_payload->m_align;
947 TCanvas
canvas(
"Pixel Barycenter Summary",
"Pixel Barycenter summary", 1200, 1200);
954 t1.SetTextSize(0.03);
960 t1.SetTextSize(0.025);
962 for (
unsigned int c = 1;
c <= 4;
c++) {
963 canvas.cd(
c)->SetTopMargin(0.07);
964 canvas.cd(
c)->SetBottomMargin(0.12);
965 canvas.cd(
c)->SetLeftMargin(0.15);
966 canvas.cd(
c)->SetRightMargin(0.03);
971 std::array<std::string, 3> structures = {{
"FPIX-",
"BPIX",
"FPIX+"}};
972 std::array<std::unique_ptr<TH2F>, 3>
histos;
978 const char *path_toTopologyXML = isInitialPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 979 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
989 path_toTopologyXML = isFinalPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 990 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1000 if (isFinalPhase0 != isInitialPhase0) {
1002 <<
"the size of the reference alignment (" << first_alignments.size()
1003 <<
") is different from the one of the target (" << last_alignments.size()
1004 <<
")! You are probably trying to compare different underlying geometries.";
1007 unsigned int index(0);
1008 for (
const auto &piece : structures) {
1009 const char *
name = piece.c_str();
1012 Form(
"%s x-y Barycenter Difference;x_{%s}-x_{TOB} [mm];y_{%s}-y_{TOB} [mm]",
name,
name,
name),
1032 auto h2_ZBarycenterDiff = std::make_unique<TH2F>(
1033 "Pixel_z_diff",
"Pixel z-Barycenter Difference;; z_{Pixel-Ideal} -z_{TOB} [mm]", 3, -0.5, 2.5, 100, -10., 10.);
1034 h2_ZBarycenterDiff->SetStats(
false);
1035 h2_ZBarycenterDiff->SetTitle(
nullptr);
1036 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(1,
"FPIX -");
1037 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(2,
"BPIX");
1038 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(3,
"FPIX +");
1039 h2_ZBarycenterDiff->GetYaxis()->SetLabelSize(0.05);
1040 h2_ZBarycenterDiff->GetXaxis()->SetLabelSize(0.07);
1041 h2_ZBarycenterDiff->GetYaxis()->SetTitleSize(0.06);
1042 h2_ZBarycenterDiff->GetXaxis()->SetTitleSize(0.06);
1043 h2_ZBarycenterDiff->GetYaxis()->CenterTitle();
1044 h2_ZBarycenterDiff->GetXaxis()->CenterTitle();
1045 h2_ZBarycenterDiff->GetYaxis()->SetTitleOffset(1.1);
1047 std::function<GlobalPoint(int)> cutFunctorInitial = [&myInitialBarycenters](
int index) {
1060 std::function<GlobalPoint(int)> cutFunctorFinal = [&myFinalBarycenters](
int index) {
1073 float x0i, x0f, y0i, y0f;
1076 t1.SetTextSize(0.047);
1077 for (
unsigned int c = 1;
c <= 3;
c++) {
1078 x0i = cutFunctorInitial(
c).x() * 10;
1079 x0f = cutFunctorFinal(
c).x() * 10;
1080 y0i = cutFunctorInitial(
c).y() * 10;
1081 y0f = cutFunctorFinal(
c).y() * 10;
1086 COUT <<
"initial x,y " << std::left << std::setw(7) << structures[
c - 1] <<
" (" << x0i <<
"," << y0i <<
") mm" 1088 COUT <<
"final x,y " << std::left << std::setw(7) << structures[
c - 1] <<
" (" << x0f <<
"," << y0f <<
") mm" 1091 TMarker *initial =
new TMarker(x0i, y0i, 21);
1092 TMarker *
final =
new TMarker(x0f, y0f, 20);
1094 initial->SetMarkerColor(kRed);
1095 final->SetMarkerColor(kBlue);
1096 initial->SetMarkerSize(2.5);
1097 final->SetMarkerSize(2.5);
1098 t1.SetTextColor(kRed);
1100 t1.DrawLatex(x0i, y0i + (y0i > y0f ? 0.3 : -0.5), Form(
"(%.2f,%.2f)", x0i, y0i));
1101 final->Draw(
"same");
1102 t1.SetTextColor(kBlue);
1103 t1.DrawLatex(x0f, y0f + (y0i > y0f ? -0.5 : 0.3), Form(
"(%.2f,%.2f)", x0f, y0f));
1108 h2_ZBarycenterDiff->Draw();
1113 std::array<double, 3> hardcodeIdealZPhase0 = {{-41.94909, 0., 41.94909}};
1114 std::array<double, 3> hardcodeIdealZPhase1 = {{-39.82911, 0., 39.82911}};
1116 for (
unsigned int c = 1;
c <= 3;
c++) {
1120 (cutFunctorInitial(
c).z() - (isInitialPhase0 ? hardcodeIdealZPhase0[
c - 1] : hardcodeIdealZPhase1[
c - 1])) *
1123 (cutFunctorFinal(
c).z() - (isFinalPhase0 ? hardcodeIdealZPhase0[
c - 1] : hardcodeIdealZPhase1[
c - 1])) * 10;
1125 TMarker *initial =
new TMarker(
c - 1, z0i, 21);
1126 TMarker *
final =
new TMarker(
c - 1, z0f, 20);
1128 COUT <<
"initial z " << std::left << std::setw(7) << structures[
c - 1] <<
" " << z0i <<
" mm" << std::endl;
1129 COUT <<
"final z " << std::left << std::setw(7) << structures[
c - 1] <<
" " << z0f <<
" mm" << std::endl;
1131 initial->SetMarkerColor(kRed);
1132 final->SetMarkerColor(kBlue);
1133 initial->SetMarkerSize(2.5);
1134 final->SetMarkerSize(2.5);
1136 t1.SetTextColor(kRed);
1137 t1.DrawLatex(
c - 1, z0i + (z0i > z0f ? 1. : -1.5), Form(
"(%.2f)", z0i));
1138 final->Draw(
"same");
1139 t1.SetTextColor(kBlue);
1140 t1.DrawLatex(
c - 1, z0f + (z0i > z0f ? -1.5 : 1), Form(
"(%.2f)", z0f));
1150 bool isInitialPhase0;
1154 using PixelBarycentersCompare = PixelBarycentersComparatorBase<1, MULTI_IOV>;
1155 using PixelBarycentersCompareTwoTags = PixelBarycentersComparatorBase<2, SINGLE_IOV>;
const std::array< double, 6 > getY()
bool tidIsDoubleSide(const DetId &id) const
void fillComparisonHistogram(const AlignmentPI::coordinate &coord, std::vector< int > &boundaries, const std::vector< AlignTransform > &ref_ali, const std::vector< AlignTransform > &target_ali, std::unique_ptr< TH1F > &compare)
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
std::string getStringFromPart(AlignmentPI::partitions i)
std::string to_string(const V &value)
Log< level::Error, false > LogError
constexpr Detector det() const
get the detector field from this detid
static const float cmToUm
void makeNiceStats(TH1F *hist, AlignmentPI::partitions part, int color)
void fillComparisonHistograms(std::vector< int > &boundaries, const std::vector< AlignTransform > &ref_ali, const std::vector< AlignTransform > &target_ali, std::unordered_map< AlignmentPI::coordinate, std::unique_ptr< TH1F > > &compare, bool diff=false, AlignmentPI::partitions checkPart=AlignmentPI::INVALID)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
const std::array< double, 6 > getX()
static const unsigned int phase0size
Abs< T >::type abs(const T &t)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Basic3DVector unit() const
Log< level::Info, false > LogInfo
GlobalPoint getPartitionAvg(AlignmentPI::PARTITION p)
constexpr uint32_t rawId() const
get the raw id
std::string getStringFromCoordinate(AlignmentPI::coordinate coord)
std::pair< double, double > calculatePosition(TVirtualPad *myPad, int boundary)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Log< level::Warning, false > LogWarning
const std::array< double, 6 > getZ()