21 #include "CLHEP/Vector/RotationInterfaces.h" 31 #include <boost/range/adaptor/indexed.hpp> 47 #include "TPaveStats.h" 62 const std::map<AlignmentPI::coordinate, float> hardcodeGPR = {
70 template <
int ntags, IOVMultiplicity nIOVs>
71 class TrackerAlignmentCompareAll :
public PlotImage<Alignments, nIOVs, ntags> {
73 TrackerAlignmentCompareAll()
74 :
PlotImage<
Alignments, nIOVs, ntags>(
"comparison of all coordinates between two geometries") {}
76 bool fill()
override {
77 TGaxis::SetExponentOffset(-0.12, 0.01,
"y");
80 auto theIOVs = PlotBase::getTag<0>().iovs;
81 auto tagname1 = PlotBase::getTag<0>().
name;
83 auto firstiov = theIOVs.front();
84 std::tuple<cond::Time_t, cond::Hash> lastiov;
87 assert(this->m_plotAnnotations.ntags < 3);
89 if (this->m_plotAnnotations.ntags == 2) {
90 auto tag2iovs = PlotBase::getTag<1>().iovs;
91 tagname2 = PlotBase::getTag<1>().
name;
92 lastiov = tag2iovs.front();
94 lastiov = theIOVs.back();
97 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
98 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
103 std::vector<AlignTransform> ref_ali = first_payload->m_align;
104 std::vector<AlignTransform> target_ali = last_payload->m_align;
106 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 2000, 1200);
109 if (ref_ali.size() != target_ali.size()) {
111 <<
"the size of the reference alignment (" << ref_ali.size()
112 <<
") is different from the one of the target (" << target_ali.size()
113 <<
")! You are probably trying to compare different underlying geometries. Exiting";
119 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 120 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
124 for (
const auto &ali : ref_ali) {
125 auto mydetid = ali.rawId();
128 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
130 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
142 std::unordered_map<AlignmentPI::coordinate, std::unique_ptr<TH1F> > diffs;
145 for (
const auto &coord : coords) {
150 diffs[coord] = std::make_unique<TH1F>(Form(
"comparison_%s", s_coord.c_str()),
151 Form(
";Detector Id index; #Delta%s %s", s_coord.c_str(),
unit.c_str()),
154 ref_ali.size() - 0.5);
158 std::map<int, AlignmentPI::partitions> boundaries;
162 unsigned int subpad{1};
163 TLegend
legend = TLegend(0.17, 0.84, 0.95, 0.94);
164 legend.SetTextSize(0.023);
165 for (
const auto &coord : coords) {
167 canvas.cd(subpad)->SetTopMargin(0.06);
168 canvas.cd(subpad)->SetLeftMargin(0.17);
169 canvas.cd(subpad)->SetRightMargin(0.05);
170 canvas.cd(subpad)->SetBottomMargin(0.15);
172 auto max = diffs[coord]->GetMaximum();
173 auto min = diffs[coord]->GetMinimum();
179 diffs[coord]->GetYaxis()->SetRangeUser(-
range * 1.5,
range * 1.5);
180 diffs[coord]->GetYaxis()->SetTitleOffset(1.5);
181 diffs[coord]->SetMarkerStyle(20);
182 diffs[coord]->SetMarkerSize(0.5);
183 diffs[coord]->Draw(
"P");
186 if (this->m_plotAnnotations.ntags == 2) {
187 legend.SetHeader(
"#bf{Two Tags Comparison}",
"C");
190 (
"#splitline{" + tagname1 +
" : " + firstIOVsince +
"}{" + tagname2 +
" : " + lastIOVsince +
"}")
194 legend.SetHeader((
"tag: #bf{" + tagname1 +
"}").c_str(),
"C");
195 legend.AddEntry(diffs[coord].
get(),
196 (
"#splitline{IOV since: " + firstIOVsince +
"}{IOV since: " + lastIOVsince +
"}").c_str(),
207 TLine
l[6][boundaries.size()];
209 for (
unsigned int i = 0;
i < 6;
i++) {
210 tSubdet[
i].SetTextColor(kRed);
212 tSubdet[
i].SetTextAlign(21);
213 tSubdet[
i].SetTextSize(0.03);
214 tSubdet[
i].SetTextAngle(90);
218 for (
const auto &coord : coords) {
221 for (
const auto &
line : boundaries | boost::adaptors::indexed(0)) {
224 l[subpad][
index] = TLine(diffs[coord]->GetBinLowEdge(
value.first),
225 canvas.cd(subpad + 1)->GetUymin(),
226 diffs[coord]->GetBinLowEdge(
value.first),
227 canvas.cd(subpad + 1)->GetUymax() * 0.84);
228 l[subpad][
index].SetLineWidth(1);
229 l[subpad][
index].SetLineStyle(9);
230 l[subpad][
index].SetLineColor(2);
231 l[subpad][
index].Draw(
"same");
235 for (
const auto &elem : boundaries | boost::adaptors::indexed(0)) {
236 const auto &lm =
canvas.cd(subpad + 1)->GetLeftMargin();
237 const auto &
rm = 1 -
canvas.cd(subpad + 1)->GetRightMargin();
238 const auto &
frac =
float(elem.value().first) / ref_ali.size();
240 LogDebug(
"TrackerAlignmentCompareAll")
241 << __PRETTY_FUNCTION__ <<
" left margin: " << lm <<
" right margin: " <<
rm <<
" fraction: " <<
frac;
243 float theX_ = lm + (
rm - lm) *
frac + (elem.index() > 0 ? 0.025 : 0.01);
245 tSubdet[subpad].DrawLatex(
251 ltx.SetTextSize(0.042);
252 ltx.SetTextAlign(11);
253 ltx.DrawLatexNDC(
canvas.cd(subpad + 1)->GetLeftMargin(),
254 1 -
canvas.cd(subpad + 1)->GetTopMargin() + 0.01,
255 (
"Tracker Alignment Compare : #color[4]{" + s_coord +
"}").c_str());
268 typedef TrackerAlignmentCompareAll<1, MULTI_IOV> TrackerAlignmentComparatorSingleTag;
269 typedef TrackerAlignmentCompareAll<2, SINGLE_IOV> TrackerAlignmentComparatorTwoTags;
276 template <AlignmentPI::coordinate coord,
int ntags, IOVMultiplicity nIOVs>
277 class TrackerAlignmentComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
279 TrackerAlignmentComparatorBase()
281 " coordinate between two geometries") {}
283 bool fill()
override {
284 TGaxis::SetExponentOffset(-0.12, 0.01,
"y");
287 auto theIOVs = PlotBase::getTag<0>().iovs;
288 auto tagname1 = PlotBase::getTag<0>().
name;
290 auto firstiov = theIOVs.front();
291 std::tuple<cond::Time_t, cond::Hash> lastiov;
294 assert(this->m_plotAnnotations.ntags < 3);
296 if (this->m_plotAnnotations.ntags == 2) {
297 auto tag2iovs = PlotBase::getTag<1>().iovs;
298 tagname2 = PlotBase::getTag<1>().
name;
299 lastiov = tag2iovs.front();
301 lastiov = theIOVs.back();
304 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
305 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
310 std::vector<AlignTransform> ref_ali = first_payload->m_align;
311 std::vector<AlignTransform> target_ali = last_payload->m_align;
313 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 1200, 1200);
315 if (ref_ali.size() != target_ali.size()) {
317 <<
"the size of the reference alignment (" << ref_ali.size()
318 <<
") is different from the one of the target (" << target_ali.size()
319 <<
")! You are probably trying to compare different underlying geometries. Exiting";
325 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 326 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
330 for (
const auto &ali : ref_ali) {
331 auto mydetid = ali.rawId();
334 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
336 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
346 std::unique_ptr<TH1F>
compare =
347 std::make_unique<TH1F>(
"comparison",
348 Form(
";Detector Id index; #Delta%s %s", s_coord.c_str(),
unit.c_str()),
351 ref_ali.size() - 0.5);
354 std::map<int, AlignmentPI::partitions> boundaries;
360 canvas.SetTopMargin(0.06);
361 canvas.SetLeftMargin(0.17);
362 canvas.SetRightMargin(0.05);
363 canvas.SetBottomMargin(0.15);
373 compare->GetYaxis()->SetTitleOffset(1.5);
381 TLine
l[boundaries.size()];
382 for (
const auto &
line : boundaries | boost::adaptors::indexed(0)) {
397 tSubdet.SetTextAlign(21);
398 tSubdet.SetTextSize(0.027);
399 tSubdet.SetTextAngle(90);
401 for (
const auto &elem : boundaries) {
402 tSubdet.SetTextColor(kRed);
404 float theX_ = elem.first != 0 ? myPair.first + 0.025 : myPair.first + 0.01;
409 TLegend
legend = TLegend(0.17, 0.86, 0.95, 0.94);
410 if (this->m_plotAnnotations.ntags == 2) {
411 legend.SetHeader(
"#bf{Two Tags Comparison}",
"C");
414 (
"#splitline{" + tagname1 +
" : " + firstIOVsince +
"}{" + tagname2 +
" : " + lastIOVsince +
"}").c_str(),
417 legend.SetHeader((
"tag: #bf{" + tagname1 +
"}").c_str(),
"C");
419 (
"#splitline{IOV since: " + firstIOVsince +
"}{IOV since: " + lastIOVsince +
"}").c_str(),
422 legend.SetTextSize(0.020);
427 ltx.SetTextSize(0.042);
428 ltx.SetTextAlign(11);
429 ltx.DrawLatexNDC(gPad->GetLeftMargin(),
430 1 - gPad->GetTopMargin() + 0.01,
431 (
"Tracker Alignment Compare :#color[4]{" + s_coord +
"}").c_str());
440 template <AlignmentPI::coordinate coord>
441 using TrackerAlignmentCompare = TrackerAlignmentComparatorBase<coord, 1, MULTI_IOV>;
443 template <AlignmentPI::coordinate coord>
444 using TrackerAlignmentCompareTwoTags = TrackerAlignmentComparatorBase<coord, 2, SINGLE_IOV>;
446 typedef TrackerAlignmentCompare<AlignmentPI::t_x> TrackerAlignmentCompareX;
447 typedef TrackerAlignmentCompare<AlignmentPI::t_y> TrackerAlignmentCompareY;
448 typedef TrackerAlignmentCompare<AlignmentPI::t_z> TrackerAlignmentCompareZ;
450 typedef TrackerAlignmentCompare<AlignmentPI::rot_alpha> TrackerAlignmentCompareAlpha;
451 typedef TrackerAlignmentCompare<AlignmentPI::rot_beta> TrackerAlignmentCompareBeta;
452 typedef TrackerAlignmentCompare<AlignmentPI::rot_gamma> TrackerAlignmentCompareGamma;
454 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_x> TrackerAlignmentCompareXTwoTags;
455 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_y> TrackerAlignmentCompareYTwoTags;
456 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::t_z> TrackerAlignmentCompareZTwoTags;
458 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_alpha> TrackerAlignmentCompareAlphaTwoTags;
459 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_beta> TrackerAlignmentCompareBetaTwoTags;
460 typedef TrackerAlignmentCompareTwoTags<AlignmentPI::rot_gamma> TrackerAlignmentCompareGammaTwoTags;
466 template <
int ntags, IOVMultiplicity nIOVs, AlignmentPI::partitions q>
467 class TrackerAlignmentSummaryBase :
public PlotImage<Alignments, nIOVs, ntags> {
469 TrackerAlignmentSummaryBase()
470 :
PlotImage<
Alignments, nIOVs, ntags>(
"Comparison of all coordinates between two geometries for " +
473 bool fill()
override {
475 auto theIOVs = PlotBase::getTag<0>().iovs;
476 auto tagname1 = PlotBase::getTag<0>().
name;
478 auto firstiov = theIOVs.front();
479 std::tuple<cond::Time_t, cond::Hash> lastiov;
482 assert(this->m_plotAnnotations.ntags < 3);
484 if (this->m_plotAnnotations.ntags == 2) {
485 auto tag2iovs = PlotBase::getTag<1>().iovs;
486 tagname2 = PlotBase::getTag<1>().
name;
487 lastiov = tag2iovs.front();
489 lastiov = theIOVs.back();
492 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
493 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
498 std::vector<AlignTransform> ref_ali = first_payload->m_align;
499 std::vector<AlignTransform> target_ali = last_payload->m_align;
501 if (ref_ali.size() != target_ali.size()) {
503 <<
"the size of the reference alignment (" << ref_ali.size()
504 <<
") is different from the one of the target (" << target_ali.size()
505 <<
")! You are probably trying to compare different underlying geometries. Exiting";
511 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 512 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
516 for (
const auto &ali : ref_ali) {
517 auto mydetid = ali.rawId();
520 <<
"Encountered invalid Tracker DetId:" <<
DetId(mydetid).
rawId() <<
" (" <<
DetId(mydetid).
det()
522 <<
"); subdetId " <<
DetId(mydetid).
subdetId() <<
" - terminating ";
527 TCanvas
canvas(
"Alignment Comparison",
"Alignment Comparison", 1800, 1200);
530 std::unordered_map<AlignmentPI::coordinate, std::unique_ptr<TH1F> > diffs;
538 for (
const auto &coord : coords) {
543 diffs[coord] = std::make_unique<TH1F>(Form(
"hDiff_%s", s_coord.c_str()),
544 Form(
";#Delta%s %s;n. of modules", s_coord.c_str(),
unit.c_str()),
551 std::map<int, AlignmentPI::partitions> boundaries;
557 auto legend = std::make_unique<TLegend>(0.14, 0.88, 0.96, 0.99);
558 if (this->m_plotAnnotations.ntags == 2) {
559 legend->SetHeader(
"#bf{Two Tags Comparison}",
"C");
562 (
"#splitline{" + tagname1 +
" : " + firstIOVsince +
"}{" + tagname2 +
" : " + lastIOVsince +
"}").c_str(),
565 legend->SetHeader((
"tag: #bf{" + tagname1 +
"}").c_str(),
"C");
567 (
"#splitline{IOV since: " + firstIOVsince +
"}{IOV since: " + lastIOVsince +
"}").c_str(),
570 legend->SetTextSize(0.025);
572 for (
const auto &coord : coords) {
573 canvas.cd(c_index)->SetLogy();
574 canvas.cd(c_index)->SetTopMargin(0.01);
575 canvas.cd(c_index)->SetBottomMargin(0.15);
576 canvas.cd(c_index)->SetLeftMargin(0.14);
577 canvas.cd(c_index)->SetRightMargin(0.04);
578 diffs[coord]->SetLineWidth(2);
586 int i_max = diffs[coord]->FindLastBinAbove(0.);
587 int i_min = diffs[coord]->FindFirstBinAbove(0.);
588 diffs[coord]->GetXaxis()->SetRange(
std::max(1, i_min - 10),
std::min(i_max + 10, diffs[coord]->GetNbinsX()));
589 diffs[coord]->SetMaximum(diffs[coord]->GetMaximum() * 5);
590 diffs[coord]->Draw(
"HIST");
605 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::BPix> TrackerAlignmentSummaryBPix;
606 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::FPix> TrackerAlignmentSummaryFPix;
607 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TIB> TrackerAlignmentSummaryTIB;
609 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TID> TrackerAlignmentSummaryTID;
610 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TOB> TrackerAlignmentSummaryTOB;
611 typedef TrackerAlignmentSummaryBase<1, MULTI_IOV, AlignmentPI::TEC> TrackerAlignmentSummaryTEC;
613 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::BPix> TrackerAlignmentSummaryBPixTwoTags;
614 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::FPix> TrackerAlignmentSummaryFPixTwoTags;
615 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TIB> TrackerAlignmentSummaryTIBTwoTags;
617 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TID> TrackerAlignmentSummaryTIDTwoTags;
618 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TOB> TrackerAlignmentSummaryTOBTwoTags;
619 typedef TrackerAlignmentSummaryBase<2, SINGLE_IOV, AlignmentPI::TEC> TrackerAlignmentSummaryTECTwoTags;
625 template <AlignmentPI::coordinate coord>
626 class BPixBarycenterHistory :
public HistoryPlot<Alignments, float> {
628 BPixBarycenterHistory()
632 ~BPixBarycenterHistory()
override =
default;
635 std::vector<AlignTransform> alignments =
payload.m_align;
637 float barycenter = 0.;
639 for (
const auto &ali : alignments) {
642 <<
"Encountered invalid Tracker DetId:" << ali.rawId() <<
" " <<
DetId(ali.rawId()).det()
647 int subid =
DetId(ali.rawId()).subdetId();
654 barycenter += (ali.translation().x());
657 barycenter += (ali.translation().y());
660 barycenter += (ali.translation().z());
663 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
668 edm::LogInfo(
"TrackerAlignment_PayloadInspector") <<
"barycenter (" << barycenter <<
")/n. modules (" << nmodules
669 <<
") = " << barycenter / nmodules << std::endl;
672 barycenter /= nmodules;
675 barycenter += hardcodeGPR.at(coord);
682 typedef BPixBarycenterHistory<AlignmentPI::t_x> X_BPixBarycenterHistory;
683 typedef BPixBarycenterHistory<AlignmentPI::t_y> Y_BPixBarycenterHistory;
684 typedef BPixBarycenterHistory<AlignmentPI::t_z> Z_BPixBarycenterHistory;
689 class TrackerAlignmentBarycenters :
public PlotImage<Alignments, SINGLE_IOV> {
693 bool fill()
override {
694 auto tag = PlotBase::getTag<0>();
695 auto iov =
tag.iovs.front();
697 std::shared_ptr<Alignments>
payload = fetchPayload(std::get<1>(iov));
698 unsigned int run = std::get<0>(iov);
700 TCanvas
canvas(
"Tracker Alignment Barycenter Summary",
"Tracker Alignment Barycenter summary", 1600, 1000);
703 canvas.SetTopMargin(0.07);
704 canvas.SetBottomMargin(0.06);
705 canvas.SetLeftMargin(0.15);
706 canvas.SetRightMargin(0.03);
710 auto h2_BarycenterParameters =
711 std::make_unique<TH2F>(
"Parameters",
"SubDetector Barycenter summary", 6, 0.0, 6.0, 6, 0, 6.);
713 auto h2_uncBarycenterParameters =
714 std::make_unique<TH2F>(
"Parameters2",
"SubDetector Barycenter summary", 6, 0.0, 6.0, 6, 0, 6.);
716 h2_BarycenterParameters->SetStats(
false);
717 h2_BarycenterParameters->SetTitle(
nullptr);
718 h2_uncBarycenterParameters->SetStats(
false);
719 h2_uncBarycenterParameters->SetTitle(
nullptr);
721 std::vector<AlignTransform> alignments =
payload->m_align;
726 const char *path_toTopologyXML = isPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 727 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
737 auto Xbarycenters = barycenters.
getX();
738 auto Ybarycenters = barycenters.
getY();
739 auto Zbarycenters = barycenters.
getZ();
744 auto c_Xbarycenters = barycenters.
getX();
745 auto c_Ybarycenters = barycenters.
getY();
746 auto c_Zbarycenters = barycenters.
getZ();
748 h2_BarycenterParameters->GetXaxis()->SetBinLabel(1,
"X [cm]");
749 h2_BarycenterParameters->GetXaxis()->SetBinLabel(2,
"Y [cm]");
750 h2_BarycenterParameters->GetXaxis()->SetBinLabel(3,
"Z [cm]");
751 h2_BarycenterParameters->GetXaxis()->SetBinLabel(4,
"X_{no GPR} [cm]");
752 h2_BarycenterParameters->GetXaxis()->SetBinLabel(5,
"Y_{no GPR} [cm]");
753 h2_BarycenterParameters->GetXaxis()->SetBinLabel(6,
"Z_{no GPR} [cm]");
755 bool isLikelyMC(
false);
757 std::count_if(Xbarycenters.begin(), Xbarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
759 std::count_if(Ybarycenters.begin(), Ybarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
761 std::count_if(Zbarycenters.begin(), Zbarycenters.begin() + 2, [](
float a) {
return (
std::abs(
a) >= 1.e-4); });
765 if ((checkX + checkY + checkZ) == 0 &&
run == 1)
768 unsigned int yBin = 6;
769 for (
unsigned int i = 0;
i < 6;
i++) {
772 h2_BarycenterParameters->GetYaxis()->SetBinLabel(
yBin, theLabel.c_str());
774 h2_BarycenterParameters->SetBinContent(1,
yBin, c_Xbarycenters[
i]);
775 h2_BarycenterParameters->SetBinContent(2,
yBin, c_Ybarycenters[
i]);
776 h2_BarycenterParameters->SetBinContent(3,
yBin, c_Zbarycenters[
i]);
779 h2_uncBarycenterParameters->SetBinContent(4,
yBin, Xbarycenters[
i]);
780 h2_uncBarycenterParameters->SetBinContent(5,
yBin, Ybarycenters[
i]);
781 h2_uncBarycenterParameters->SetBinContent(6,
yBin, Zbarycenters[
i]);
785 h2_BarycenterParameters->GetXaxis()->LabelsOption(
"h");
786 h2_BarycenterParameters->GetYaxis()->SetLabelSize(0.05);
787 h2_BarycenterParameters->GetXaxis()->SetLabelSize(0.05);
788 h2_BarycenterParameters->SetMarkerSize(1.5);
789 h2_BarycenterParameters->Draw(
"TEXT");
791 h2_uncBarycenterParameters->SetMarkerSize(1.5);
792 h2_uncBarycenterParameters->SetMarkerColor(kRed);
793 h2_uncBarycenterParameters->Draw(
"TEXTsame");
798 t1.SetTextSize(0.045);
799 t1.DrawLatex(0.5, 0.96, Form(
"TkAl Barycenters, Tag: #color[4]{%s}, IOV #color[4]{%i}",
tagname.c_str(),
run));
800 t1.SetTextSize(0.025);
815 template <
int ntags, IOVMultiplicity nIOVs>
816 class TrackerAlignmentBarycentersComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
818 TrackerAlignmentBarycentersComparatorBase()
821 bool fill()
override {
823 auto theIOVs = PlotBase::getTag<0>().iovs;
824 auto tagname1 = PlotBase::getTag<0>().
name;
826 auto firstiov = theIOVs.front();
827 std::tuple<cond::Time_t, cond::Hash> lastiov;
830 assert(this->m_plotAnnotations.ntags < 3);
832 if (this->m_plotAnnotations.ntags == 2) {
833 auto tag2iovs = PlotBase::getTag<1>().iovs;
834 tagname2 = PlotBase::getTag<1>().
name;
835 lastiov = tag2iovs.front();
837 lastiov = theIOVs.back();
840 unsigned int first_run = std::get<0>(firstiov);
841 unsigned int last_run = std::get<0>(lastiov);
843 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
844 std::vector<AlignTransform> last_alignments = last_payload->m_align;
846 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
847 std::vector<AlignTransform> first_alignments = first_payload->m_align;
853 const char *path_toTopologyXML = isInitialPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 854 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
859 path_toTopologyXML = isFinalPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 860 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
865 TCanvas
canvas(
"Tracker Alignment Barycenter Summary",
"Tracker Alignment Barycenter summary", 1200, 800);
868 canvas.SetTopMargin(0.07);
869 canvas.SetBottomMargin(0.06);
870 canvas.SetLeftMargin(0.15);
871 canvas.SetRightMargin(0.03);
875 auto h2_BarycenterDiff =
876 std::make_unique<TH2F>(
"Parameters diff",
"SubDetector Barycenter Difference", 3, 0.0, 3.0, 6, 0, 6.);
878 h2_BarycenterDiff->SetStats(
false);
879 h2_BarycenterDiff->SetTitle(
nullptr);
880 h2_BarycenterDiff->GetXaxis()->SetBinLabel(1,
"X [#mum]");
881 h2_BarycenterDiff->GetXaxis()->SetBinLabel(2,
"Y [#mum]");
882 h2_BarycenterDiff->GetXaxis()->SetBinLabel(3,
"Z [#mum]");
890 unsigned int yBin = 6;
891 for (
unsigned int i = 0;
i < 6;
i++) {
894 h2_BarycenterDiff->GetYaxis()->SetBinLabel(
yBin, theLabel.c_str());
895 h2_BarycenterDiff->SetBinContent(
897 h2_BarycenterDiff->SetBinContent(
899 h2_BarycenterDiff->SetBinContent(
904 h2_BarycenterDiff->GetXaxis()->LabelsOption(
"h");
905 h2_BarycenterDiff->GetYaxis()->SetLabelSize(0.05);
906 h2_BarycenterDiff->GetXaxis()->SetLabelSize(0.05);
907 h2_BarycenterDiff->SetMarkerSize(1.5);
908 h2_BarycenterDiff->SetMarkerColor(kRed);
909 h2_BarycenterDiff->Draw(
"TEXT");
914 t1.SetTextSize(0.05);
915 t1.DrawLatex(0.5, 0.96, Form(
"Tracker Alignment Barycenters Diff, IOV %i - IOV %i",
last_run,
first_run));
916 t1.SetTextSize(0.025);
925 bool isInitialPhase0;
929 using TrackerAlignmentBarycentersCompare = TrackerAlignmentBarycentersComparatorBase<1, MULTI_IOV>;
930 using TrackerAlignmentBarycentersCompareTwoTags = TrackerAlignmentBarycentersComparatorBase<2, SINGLE_IOV>;
935 template <
int ntags, IOVMultiplicity nIOVs>
936 class PixelBarycentersComparatorBase :
public PlotImage<Alignments, nIOVs, ntags> {
938 PixelBarycentersComparatorBase() :
PlotImage<
Alignments, nIOVs, ntags>(
"Comparison of Pixel Barycenters") {}
940 bool fill()
override {
942 auto theIOVs = PlotBase::getTag<0>().iovs;
943 auto tagname1 = PlotBase::getTag<0>().
name;
945 auto firstiov = theIOVs.front();
946 std::tuple<cond::Time_t, cond::Hash> lastiov;
949 assert(this->m_plotAnnotations.ntags < 3);
951 if (this->m_plotAnnotations.ntags == 2) {
952 auto tag2iovs = PlotBase::getTag<1>().iovs;
953 tagname2 = PlotBase::getTag<1>().
name;
954 lastiov = tag2iovs.front();
956 lastiov = theIOVs.back();
959 unsigned int first_run = std::get<0>(firstiov);
960 unsigned int last_run = std::get<0>(lastiov);
962 std::shared_ptr<Alignments> last_payload = this->fetchPayload(std::get<1>(lastiov));
963 std::vector<AlignTransform> last_alignments = last_payload->m_align;
965 std::shared_ptr<Alignments> first_payload = this->fetchPayload(std::get<1>(firstiov));
966 std::vector<AlignTransform> first_alignments = first_payload->m_align;
968 TCanvas
canvas(
"Pixel Barycenter Summary",
"Pixel Barycenter summary", 1200, 1200);
975 t1.SetTextSize(0.03);
981 t1.SetTextSize(0.025);
983 for (
unsigned int c = 1;
c <= 4;
c++) {
984 canvas.cd(
c)->SetTopMargin(0.07);
985 canvas.cd(
c)->SetBottomMargin(0.12);
986 canvas.cd(
c)->SetLeftMargin(0.15);
987 canvas.cd(
c)->SetRightMargin(0.03);
992 std::array<std::string, 3> structures = {{
"FPIX-",
"BPIX",
"FPIX+"}};
993 std::array<std::unique_ptr<TH2F>, 3>
histos;
999 const char *path_toTopologyXML = isInitialPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 1000 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1010 path_toTopologyXML = isFinalPhase0 ?
"Geometry/TrackerCommonData/data/trackerParameters.xml" 1011 :
"Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1021 if (isFinalPhase0 != isInitialPhase0) {
1023 <<
"the size of the reference alignment (" << first_alignments.size()
1024 <<
") is different from the one of the target (" << last_alignments.size()
1025 <<
")! You are probably trying to compare different underlying geometries.";
1028 unsigned int index(0);
1029 for (
const auto &piece : structures) {
1030 const char *
name = piece.c_str();
1033 Form(
"%s x-y Barycenter Difference;x_{%s}-x_{TOB} [mm];y_{%s}-y_{TOB} [mm]",
name,
name,
name),
1053 auto h2_ZBarycenterDiff = std::make_unique<TH2F>(
1054 "Pixel_z_diff",
"Pixel z-Barycenter Difference;; z_{Pixel-Ideal} -z_{TOB} [mm]", 3, -0.5, 2.5, 100, -10., 10.);
1055 h2_ZBarycenterDiff->SetStats(
false);
1056 h2_ZBarycenterDiff->SetTitle(
nullptr);
1057 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(1,
"FPIX -");
1058 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(2,
"BPIX");
1059 h2_ZBarycenterDiff->GetXaxis()->SetBinLabel(3,
"FPIX +");
1060 h2_ZBarycenterDiff->GetYaxis()->SetLabelSize(0.05);
1061 h2_ZBarycenterDiff->GetXaxis()->SetLabelSize(0.07);
1062 h2_ZBarycenterDiff->GetYaxis()->SetTitleSize(0.06);
1063 h2_ZBarycenterDiff->GetXaxis()->SetTitleSize(0.06);
1064 h2_ZBarycenterDiff->GetYaxis()->CenterTitle();
1065 h2_ZBarycenterDiff->GetXaxis()->CenterTitle();
1066 h2_ZBarycenterDiff->GetYaxis()->SetTitleOffset(1.1);
1068 std::function<GlobalPoint(int)> cutFunctorInitial = [&myInitialBarycenters](
int index) {
1081 std::function<GlobalPoint(int)> cutFunctorFinal = [&myFinalBarycenters](
int index) {
1094 float x0i, x0f, y0i, y0f;
1097 t1.SetTextSize(0.047);
1098 for (
unsigned int c = 1;
c <= 3;
c++) {
1099 x0i = cutFunctorInitial(
c).x() * 10;
1100 x0f = cutFunctorFinal(
c).x() * 10;
1101 y0i = cutFunctorInitial(
c).y() * 10;
1102 y0f = cutFunctorFinal(
c).y() * 10;
1107 COUT <<
"initial x,y " << std::left << std::setw(7) << structures[
c - 1] <<
" (" << x0i <<
"," << y0i <<
") mm" 1109 COUT <<
"final x,y " << std::left << std::setw(7) << structures[
c - 1] <<
" (" << x0f <<
"," << y0f <<
") mm" 1112 TMarker *initial =
new TMarker(x0i, y0i, 21);
1113 TMarker *
final =
new TMarker(x0f, y0f, 20);
1115 initial->SetMarkerColor(kRed);
1116 final->SetMarkerColor(kBlue);
1117 initial->SetMarkerSize(2.5);
1118 final->SetMarkerSize(2.5);
1119 t1.SetTextColor(kRed);
1121 t1.DrawLatex(x0i, y0i + (y0i > y0f ? 0.3 : -0.5), Form(
"(%.2f,%.2f)", x0i, y0i));
1122 final->Draw(
"same");
1123 t1.SetTextColor(kBlue);
1124 t1.DrawLatex(x0f, y0f + (y0i > y0f ? -0.5 : 0.3), Form(
"(%.2f,%.2f)", x0f, y0f));
1129 h2_ZBarycenterDiff->Draw();
1134 std::array<double, 3> hardcodeIdealZPhase0 = {{-41.94909, 0., 41.94909}};
1135 std::array<double, 3> hardcodeIdealZPhase1 = {{-39.82911, 0., 39.82911}};
1137 for (
unsigned int c = 1;
c <= 3;
c++) {
1141 (cutFunctorInitial(
c).z() - (isInitialPhase0 ? hardcodeIdealZPhase0[
c - 1] : hardcodeIdealZPhase1[
c - 1])) *
1144 (cutFunctorFinal(
c).z() - (isFinalPhase0 ? hardcodeIdealZPhase0[
c - 1] : hardcodeIdealZPhase1[
c - 1])) * 10;
1146 TMarker *initial =
new TMarker(
c - 1, z0i, 21);
1147 TMarker *
final =
new TMarker(
c - 1, z0f, 20);
1149 COUT <<
"initial z " << std::left << std::setw(7) << structures[
c - 1] <<
" " << z0i <<
" mm" << std::endl;
1150 COUT <<
"final z " << std::left << std::setw(7) << structures[
c - 1] <<
" " << z0f <<
" mm" << std::endl;
1152 initial->SetMarkerColor(kRed);
1153 final->SetMarkerColor(kBlue);
1154 initial->SetMarkerSize(2.5);
1155 final->SetMarkerSize(2.5);
1157 t1.SetTextColor(kRed);
1158 t1.DrawLatex(
c - 1, z0i + (z0i > z0f ? 1. : -1.5), Form(
"(%.2f)", z0i));
1159 final->Draw(
"same");
1160 t1.SetTextColor(kBlue);
1161 t1.DrawLatex(
c - 1, z0f + (z0i > z0f ? -1.5 : 1), Form(
"(%.2f)", z0f));
1171 bool isInitialPhase0;
1175 using PixelBarycentersCompare = PixelBarycentersComparatorBase<1, MULTI_IOV>;
1176 using PixelBarycentersCompareTwoTags = PixelBarycentersComparatorBase<2, SINGLE_IOV>;
const std::array< double, 6 > getY()
bool tidIsDoubleSide(const DetId &id) const
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
Log< level::Error, false > LogError
constexpr Detector det() const
get the detector field from this detid
static std::string to_string(const XMLCh *ch)
static const float cmToUm
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
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) ...
static const unsigned int phase1size
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Basic3DVector unit() const
Log< level::Info, false > LogInfo
void fillComparisonHistograms(std::map< int, AlignmentPI::partitions > &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)
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)
void fillComparisonHistogram(const AlignmentPI::coordinate &coord, std::map< int, AlignmentPI::partitions > &boundaries, const std::vector< AlignTransform > &ref_ali, const std::vector< AlignTransform > &target_ali, std::unique_ptr< TH1F > &compare)
Log< level::Warning, false > LogWarning
const std::array< double, 6 > getZ()
std::string getStringFromPart(AlignmentPI::partitions i, bool isPhase2=false)