From e15521c0041b7bb6a82c21d41156cbd9d668041c Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 2 Aug 2023 14:43:50 +0200 Subject: [PATCH 1/2] support Pixel Only comparison plots per-coordinate --- .../TrackerAlignment_PayloadInspector.cc | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc b/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc index f2a185b230615..48730e2089242 100644 --- a/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc +++ b/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc @@ -67,7 +67,7 @@ namespace { // one at a time //******************************************// - template + template class TrackerAlignmentCompareAll : public PlotImage { public: TrackerAlignmentCompareAll() @@ -103,6 +103,24 @@ namespace { std::vector ref_ali = first_payload->m_align; std::vector target_ali = last_payload->m_align; + // Use remove_if along with a lambda expression to remove elements based on the condition (subid > 2) + if (doOnlyPixel) { + ref_ali.erase(std::remove_if(ref_ali.begin(), + ref_ali.end(), + [](const AlignTransform &transform) { + int subid = DetId(transform.rawId()).subdetId(); + return subid > 2; + }), + ref_ali.end()); + + target_ali.erase(std::remove_if(target_ali.begin(), + target_ali.end(), + [](const AlignTransform &transform) { + int subid = DetId(transform.rawId()).subdetId(); + return subid > 2; + }), + target_ali.end()); + } TCanvas canvas("Alignment Comparison", "Alignment Comparison", 2000, 1200); canvas.Divide(3, 2); @@ -114,10 +132,18 @@ namespace { return false; } + const bool ph2 = (ref_ali.size() > AlignmentPI::phase1size); + // check that the geomtery is a tracker one - const char *path_toTopologyXML = (ref_ali.size() == AlignmentPI::phase0size) - ? "Geometry/TrackerCommonData/data/trackerParameters.xml" - : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + const char *path_toTopologyXML = nullptr; + if (ph2) { + path_toTopologyXML = "Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml"; + } else { + path_toTopologyXML = (ref_ali.size() == AlignmentPI::phase0size) + ? "Geometry/TrackerCommonData/data/trackerParameters.xml" + : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml"; + } + TrackerTopology tTopo = StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath(path_toTopologyXML).fullPath()); @@ -210,7 +236,7 @@ namespace { tSubdet[i].SetTextColor(kRed); tSubdet[i].SetNDC(); tSubdet[i].SetTextAlign(21); - tSubdet[i].SetTextSize(0.03); + tSubdet[i].SetTextSize(doOnlyPixel ? 0.05 : 0.03); tSubdet[i].SetTextAngle(90); } @@ -231,7 +257,6 @@ namespace { l[subpad][index].Draw("same"); } - 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(); @@ -240,7 +265,7 @@ namespace { 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); + float theX_ = lm + (rm - lm) * frac + ((elem.index() > 0 || doOnlyPixel) ? 0.025 : 0.01); tSubdet[subpad].DrawLatex( theX_, 0.23, Form("%s", AlignmentPI::getStringFromPart(elem.value().second, /*is phase2?*/ ph2).c_str())); @@ -265,8 +290,11 @@ namespace { } }; - typedef TrackerAlignmentCompareAll<1, MULTI_IOV> TrackerAlignmentComparatorSingleTag; - typedef TrackerAlignmentCompareAll<2, SINGLE_IOV> TrackerAlignmentComparatorTwoTags; + typedef TrackerAlignmentCompareAll<1, MULTI_IOV, false> TrackerAlignmentComparatorSingleTag; + typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, false> TrackerAlignmentComparatorTwoTags; + + typedef TrackerAlignmentCompareAll<1, MULTI_IOV, true> PixelAlignmentComparatorSingleTag; + typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, true> PixelAlignmentComparatorTwoTags; //*******************************************// // Size of the movement over all partitions, @@ -1178,6 +1206,8 @@ namespace { } // namespace PAYLOAD_INSPECTOR_MODULE(TrackerAlignment) { + PAYLOAD_INSPECTOR_CLASS(PixelAlignmentComparatorSingleTag); + PAYLOAD_INSPECTOR_CLASS(PixelAlignmentComparatorTwoTags); PAYLOAD_INSPECTOR_CLASS(TrackerAlignmentComparatorSingleTag); PAYLOAD_INSPECTOR_CLASS(TrackerAlignmentComparatorTwoTags); PAYLOAD_INSPECTOR_CLASS(TrackerAlignmentCompareX); From 3b065fb438be5069f2ce78bf1dd7951b8ec243dc Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 2 Aug 2023 17:23:36 +0200 Subject: [PATCH 2/2] add unit test for PixelAlignmentComparatorTwoTags --- .../testTrackerAlignmentPayloadInspector.cpp | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/CondCore/AlignmentPlugins/test/testTrackerAlignmentPayloadInspector.cpp b/CondCore/AlignmentPlugins/test/testTrackerAlignmentPayloadInspector.cpp index 7124f3ff69990..c13d339712084 100644 --- a/CondCore/AlignmentPlugins/test/testTrackerAlignmentPayloadInspector.cpp +++ b/CondCore/AlignmentPlugins/test/testTrackerAlignmentPayloadInspector.cpp @@ -25,42 +25,51 @@ int main(int argc, char** argv) { cond::Time_t start = static_cast(294034); cond::Time_t end = static_cast(305898); - std::cout << "## Alignment Histos" << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << "## Alignment Histos"; TrackerAlignmentCompareX histo1; histo1.process(connectionString, PI::mk_input(tag, start, end)); - std::cout << histo1.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo1.data(); TrackerAlignmentSummaryBPix histo2; histo2.process(connectionString, PI::mk_input(tag, start, end)); - std::cout << histo2.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo2.data(); X_BPixBarycenterHistory histo3; histo3.process(connectionString, PI::mk_input(tag, start, end)); - std::cout << histo3.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo3.data(); - std::cout << "## Testing Two Tag Histos" << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << "## Testing Two Tag Histos"; TrackerAlignmentBarycentersCompareTwoTags histo4; histo4.process( connectionString, PI::mk_input("TrackerAlignment_2017_ultralegacymc_v2", 1, 1, "TrackerAlignment_Upgrade2017_realistic_v2", 1, 1)); - std::cout << histo4.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo4.data(); TrackerAlignmentCompareXTwoTags histo5; histo5.process( connectionString, PI::mk_input("TrackerAlignment_2017_ultralegacymc_v2", 1, 1, "TrackerAlignment_Upgrade2017_realistic_v2", 1, 1)); - std::cout << histo5.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo5.data(); - std::cout << "## Testing Barycenter Histos" << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << "## Testing Barycenter Histos"; TrackerAlignmentBarycentersCompare histo6; histo6.process(connectionString, PI::mk_input(tag, start, end)); - std::cout << histo6.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo6.data(); PixelBarycentersCompare histo7; histo7.process(connectionString, PI::mk_input(tag, start, end)); - std::cout << histo7.data() << std::endl; + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo7.data(); + + edm::LogPrint("testTrackerAlignmentPayloadInspector") << "## Testing Comparator Histos"; + + PixelAlignmentComparatorTwoTags histo8; + histo8.process( + connectionString, + PI::mk_input("TrackerAlignment_2017_ultralegacymc_v2", 1, 1, "TrackerAlignment_Upgrade2017_realistic_v2", 1, 1)); + edm::LogPrint("testTrackerAlignmentPayloadInspector") << histo8.data(); + Py_Finalize(); }