diff --git a/CondCore/AlignmentPlugins/interface/AlignmentPayloadInspectorHelper.h b/CondCore/AlignmentPlugins/interface/AlignmentPayloadInspectorHelper.h index 425546e04a2df..69f126e719999 100644 --- a/CondCore/AlignmentPlugins/interface/AlignmentPayloadInspectorHelper.h +++ b/CondCore/AlignmentPlugins/interface/AlignmentPayloadInspectorHelper.h @@ -1184,6 +1184,79 @@ namespace AlignmentPI { } // loop on detids } + /*--------------------------------------------------------------------*/ + inline bool isReorderedTFPXTEPX(const std::vector& transforms) + /*--------------------------------------------------------------------*/ + { + // Lambda function to extract the disk, blade panel and numbers from rawId + auto extractBladePanel = [](const AlignTransform& transform) { + // Extract blade and panel numbers using bitwise operations + uint32_t rawId = transform.rawId(); + int subid = DetId(transform.rawId()).subdetId(); + if (subid == 2) { + // Tracker with subdisk hierarchy level (additional hierarchy level wrt original) + // see for parameters: Geometry/TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml + // + // + // 23, 19, 18, 12, 10, 2, 0x3, 0xF, 0x1, 0x3F, 0x3, 0xFF + // + + //unsigned int sideStartBit_ = 23; + //unsigned int diskStartBit_ = 19; + //unsigned int subDiskStartBit_ = 18; + //unsigned int bladeStartBit_ = 12; + //unsigned int panelStartBit_ = 10; + //unsigned int moduleStartBit_ = 2; + //unsigned int sideMask_ = 0x3; + //unsigned int diskMask_ = 0xF; + //unsigned int subDiskMask_ = 0x1; + //unsigned int bladeMask_ = 0x3F; + //unsigned int panelMask_ = 0x3; + //unsigned int moduleMask_ = 0xFF; + + // Original Tracker + // see for parameters: Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml + // + // + // 23, 18, 12, 10, 2, 0x3, 0xF, 0x3F, 0x3, 0xFF + // + + //unsigned int sideStartBit_ = 23; + unsigned int diskStartBit_ = 18; + unsigned int bladeStartBit_ = 12; + unsigned int panelStartBit_ = 10; + //unsigned int moduleStartBit_ = 2; + //unsigned int sideMask_ = 0x3; + unsigned int diskMask_ = 0xF; + unsigned int bladeMask_ = 0x3F; + unsigned int panelMask_ = 0x3; + //unsigned int moduleMask_ = 0xFF; + + int disk = (rawId >> diskStartBit_) & diskMask_; // Assuming regular trackerParameters.xml + int blade = (rawId >> bladeStartBit_) & bladeMask_; // Assuming regular trackerParameters.xml + int panel = (rawId >> panelStartBit_) & panelMask_; // Assuming regular trackerParameters.xml + return std::make_tuple(disk, blade, panel); + } + return std::make_tuple(-1, -1, -1); // Return (-1, -1, -1) if subdetId is not 2 + }; + + bool foundZeroDisk = false; // Flag to track if a disk with value 0 is found + std::for_each( + transforms.begin(), transforms.end(), [&extractBladePanel, &foundZeroDisk](const AlignTransform& transform) { + auto [disk, blade, panel] = extractBladePanel(transform); + int subid = DetId(transform.rawId()).subdetId(); + if (subid == 2) { + if (disk == 0) { + edm::LogInfo("isReorderedTFPXTEPX") << "subid: " << subid << " detid: " << transform.rawId() + << " disk: " << disk << " blade: " << blade << " panel: " << panel; + foundZeroDisk = true; // Set flag to true if disk value is 0 + } + } + }); + + return foundZeroDisk; // Return true if at least one disk with value 0 is found + } + } // namespace AlignmentPI #endif diff --git a/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc b/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc index 8e2f754bcc1de..46bbd439cbc12 100644 --- a/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc +++ b/CondCore/AlignmentPlugins/plugins/TrackerAlignment_PayloadInspector.cc @@ -69,7 +69,9 @@ namespace { // one at a time //******************************************// - template + enum RegionCategory { ALL = 0, INNER = 1, OUTER = 2 }; + + template class TrackerAlignmentCompareAll : public PlotImage { public: TrackerAlignmentCompareAll() @@ -105,13 +107,46 @@ namespace { std::vector ref_ali = first_payload->m_align; std::vector target_ali = last_payload->m_align; + const bool ph2 = (ref_ali.size() > AlignmentPI::phase1size); + + // check that the geomtery is a tracker one + const char *path_toTopologyXML = nullptr; + if (ph2) { + if (AlignmentPI::isReorderedTFPXTEPX(ref_ali) && AlignmentPI::isReorderedTFPXTEPX(target_ali)) { + edm::LogPrint("TrackerAlignment_PayloadInspector") + << "Both reference and target alignments are reordered. Using the trackerParameters for the Reordered " + "TFPX,TEPX."; + path_toTopologyXML = "Geometry/TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml"; + } else if (!AlignmentPI::isReorderedTFPXTEPX(ref_ali) && !AlignmentPI::isReorderedTFPXTEPX(target_ali)) { + edm::LogPrint("TrackerAlignment_PayloadInspector") + << "Neither reference nor target alignments are reordered. Using the standard trackerParameters."; + path_toTopologyXML = "Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml"; + } else { + if (cat == RegionCategory::ALL || cat == RegionCategory::INNER) { + // Emit warning and exit false if alignments are mismatched + edm::LogWarning("TrackerAlignment_PayloadInspector") + << "Mismatched alignments detected. One is reordered while the other is not. Unable to proceed."; + return false; + } else { + edm::LogWarning("TrackerAlignment_PayloadInspector") + << "Mismatched inner tracks alignments detected. One is reordered while the other is not. Ignoring as " + "OT only comparison requested."; + 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"; + } + // Use remove_if along with a lambda expression to remove elements based on the condition (subid > 2) - if (doOnlyPixel) { + if (cat != RegionCategory::ALL) { ref_ali.erase(std::remove_if(ref_ali.begin(), ref_ali.end(), [](const AlignTransform &transform) { int subid = DetId(transform.rawId()).subdetId(); - return subid > 2; + return (cat == RegionCategory::INNER) ? (subid > 2) : (subid <= 2); }), ref_ali.end()); @@ -119,7 +154,7 @@ namespace { target_ali.end(), [](const AlignTransform &transform) { int subid = DetId(transform.rawId()).subdetId(); - return subid > 2; + return (cat == RegionCategory::INNER) ? (subid > 2) : (subid <= 2); }), target_ali.end()); } @@ -134,18 +169,6 @@ namespace { return false; } - const bool ph2 = (ref_ali.size() > AlignmentPI::phase1size); - - // check that the geomtery is a tracker one - 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()); @@ -184,7 +207,9 @@ namespace { // fill all the histograms together std::map boundaries; - boundaries.insert({0, AlignmentPI::BPix}); // always start with BPix, not filled in the loop + if (cat < RegionCategory::OUTER) { + boundaries.insert({0, AlignmentPI::BPix}); // always start with BPix, not filled in the loop + } AlignmentPI::fillComparisonHistograms(boundaries, ref_ali, target_ali, diffs); unsigned int subpad{1}; @@ -232,6 +257,8 @@ namespace { canvas.cd(); canvas.Modified(); + bool doOnlyPixel = (cat == RegionCategory::INNER); + TLine l[6][boundaries.size()]; TLatex tSubdet[6]; for (unsigned int i = 0; i < 6; i++) { @@ -292,11 +319,14 @@ namespace { } }; - typedef TrackerAlignmentCompareAll<1, MULTI_IOV, false> TrackerAlignmentComparatorSingleTag; - typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, false> TrackerAlignmentComparatorTwoTags; + typedef TrackerAlignmentCompareAll<1, MULTI_IOV, RegionCategory::ALL> TrackerAlignmentComparatorSingleTag; + typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, RegionCategory::ALL> TrackerAlignmentComparatorTwoTags; - typedef TrackerAlignmentCompareAll<1, MULTI_IOV, true> PixelAlignmentComparatorSingleTag; - typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, true> PixelAlignmentComparatorTwoTags; + typedef TrackerAlignmentCompareAll<1, MULTI_IOV, RegionCategory::INNER> PixelAlignmentComparatorSingleTag; + typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, RegionCategory::INNER> PixelAlignmentComparatorTwoTags; + + typedef TrackerAlignmentCompareAll<1, MULTI_IOV, RegionCategory::OUTER> OTAlignmentComparatorSingleTag; + typedef TrackerAlignmentCompareAll<2, SINGLE_IOV, RegionCategory::OUTER> OTAlignmentComparatorTwoTags; //*******************************************// // Size of the movement over all partitions, @@ -350,10 +380,32 @@ 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) { + if (AlignmentPI::isReorderedTFPXTEPX(ref_ali) && AlignmentPI::isReorderedTFPXTEPX(target_ali)) { + edm::LogPrint("TrackerAlignment_PayloadInspector") + << "Both reference and target alignments are reordered. Using the trackerParameters for the Reordered " + "TFPX,TEPX."; + path_toTopologyXML = "Geometry/TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml"; + } else if (!AlignmentPI::isReorderedTFPXTEPX(ref_ali) && !AlignmentPI::isReorderedTFPXTEPX(target_ali)) { + edm::LogPrint("TrackerAlignment_PayloadInspector") + << "Neither reference nor target alignments are reordered. Using the standard trackerParameters."; + path_toTopologyXML = "Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml"; + } else { + // Emit warning and exit false if alignments are mismatched + edm::LogWarning("TrackerAlignment_PayloadInspector") + << "Mismatched alignments detected. One is reordered while the other is not. Unable to proceed."; + return false; + } + } 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()); @@ -1422,6 +1474,8 @@ namespace { PAYLOAD_INSPECTOR_MODULE(TrackerAlignment) { PAYLOAD_INSPECTOR_CLASS(PixelAlignmentComparatorSingleTag); PAYLOAD_INSPECTOR_CLASS(PixelAlignmentComparatorTwoTags); + PAYLOAD_INSPECTOR_CLASS(OTAlignmentComparatorSingleTag); + PAYLOAD_INSPECTOR_CLASS(OTAlignmentComparatorTwoTags); PAYLOAD_INSPECTOR_CLASS(TrackerAlignmentComparatorSingleTag); PAYLOAD_INSPECTOR_CLASS(TrackerAlignmentComparatorTwoTags); PAYLOAD_INSPECTOR_CLASS(TrackerAlignmentCompareX);