86 std::vector<const xAOD::PixelCluster*>& monitored_list,
87 std::vector<const xAOD::PixelCluster*>& reference_list,
88 const std::string& module_id,
90 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>& pairs)
const
94 std::vector<std::set<Identifier>> monitored_rdo_sets;
95 std::vector<std::set<Identifier>> reference_rdo_sets;
97 for (
const auto* c : monitored_list) {
98 const auto& rdoListRange = c->rdoList();
99 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
100 monitored_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
103 for (
const auto* c : reference_list) {
104 const auto& rdoListRange = c->rdoList();
105 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
106 reference_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
110 std::vector<std::pair<int, int>> matched_pairs;
111 std::vector<int> unmatched_monitored;
112 std::set<int> unmatched_reference;
114 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
115 unmatched_reference.insert(j);
118 for (
size_t i = 0; i < monitored_rdo_sets.size(); ++i) {
120 bool found_match =
false;
121 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
122 if (monitored_rdo_sets[i] == reference_rdo_sets[j]) {
123 matched_pairs.emplace_back(i, j);
124 pairs.emplace_back(monitored_list.at(i), reference_list.at(j));
126 unmatched_reference.erase(j);
131 unmatched_monitored.push_back(i);
136 if (!unmatched_monitored.empty() || !unmatched_reference.empty()) {
138 <<
": cluster mismatch detected!");
139 if (!unmatched_monitored.empty()) {
141 << unmatched_monitored.size() <<
"):");
142 for (
int i : unmatched_monitored) {
157 << monitored_cov(1, 1) <<
")");
161 if (!unmatched_reference.empty()) {
162 ATH_MSG_DEBUG(
" Unmatched reference clusters (" << unmatched_reference.size()
164 for (
int j : unmatched_reference) {
181 << reference_cov(1, 1) <<
")");
185 ATH_MSG_DEBUG(
"------------------------------------------------------------");
191 std::vector<const xAOD::StripCluster*>& monitored_list,
192 std::vector<const xAOD::StripCluster*>& reference_list,
193 const std::string& module_id,
195 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>& pairs)
const
199 std::vector<std::set<Identifier>> monitored_rdo_sets;
200 std::vector<std::set<Identifier>> reference_rdo_sets;
202 for (
const auto* c : monitored_list) {
203 const auto& rdoListRange = c->rdoList();
204 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
205 monitored_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
208 for (
const auto* c : reference_list) {
209 const auto& rdoListRange = c->rdoList();
210 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
211 reference_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
215 std::vector<std::pair<int, int>> matched_pairs;
216 std::vector<int> unmatched_monitored;
217 std::set<int> unmatched_reference;
219 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
220 unmatched_reference.insert(j);
223 for (
size_t i = 0; i < monitored_rdo_sets.size(); ++i) {
224 bool found_match =
false;
225 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
226 if (monitored_rdo_sets[i] == reference_rdo_sets[j]) {
227 matched_pairs.emplace_back(i, j);
228 pairs.emplace_back(monitored_list.at(i), reference_list.at(j));
230 unmatched_reference.erase(j);
235 unmatched_monitored.push_back(i);
240 if (!unmatched_monitored.empty() || !unmatched_reference.empty()) {
242 <<
": cluster mismatch detected!");
243 if (!unmatched_monitored.empty()) {
245 << unmatched_monitored.size() <<
"):");
246 for (
int i : unmatched_monitored) {
259 ATH_MSG_DEBUG(
" Monitored: (" << monitored_cov(0, 0) <<
")");
263 if (!unmatched_reference.empty()) {
264 ATH_MSG_DEBUG(
" Unmatched reference clusters (" << unmatched_reference.size()
266 for (
int j : unmatched_reference) {
280 ATH_MSG_DEBUG(
" Reference: (" << reference_cov(0, 0) <<
")");
284 ATH_MSG_DEBUG(
"------------------------------------------------------------");
320 const EventContext& eventContext, std::unordered_map<const xAOD::PixelCluster*, const xAOD::PixelCluster*>& pixel_cluster_matches, std::unordered_map<const xAOD::StripCluster*, const xAOD::StripCluster*>& strip_cluster_matches)
const
324 "============================================================");
333 "============================================================");
339 monitoredPixelClustersHandle.
cptr();
345 monitoredStripClustersHandle.
cptr();
351 referencePixelClustersHandle.
cptr();
357 referenceStripClustersHandle.
cptr();
359 const traccc::detector_design_description::host* monDesign =
nullptr;
362 const traccc::detector_conditions_description::host* monCond{};
365 size_t t_n_pixel = monitoredPixelClusters->
size();
366 size_t t_n_strip = monitoredStripClusters->
size();
367 size_t a_n_pixel = referencePixelClusters->
size();
368 size_t a_n_strip = referenceStripClusters->
size();
370 ATH_MSG_DEBUG(
" Monitored/reference pixel clusters " << t_n_pixel <<
" / "
372 ATH_MSG_DEBUG(
" Monitored/reference strip clusters " << t_n_strip <<
" / "
375 if (t_n_pixel != a_n_pixel) {
377 ATH_MSG_ERROR(
" Monitored/reference clusters " << t_n_pixel <<
" / "
379 return StatusCode::FAILURE;
381 if (t_n_strip != a_n_strip) {
383 ATH_MSG_ERROR(
" Monitored/reference clusters " << t_n_strip <<
" / "
385 return StatusCode::FAILURE;
389 std::map<std::string, std::vector<const xAOD::PixelCluster*>>
390 monitored_pixel_map, reference_pixel_map;
391 std::map<std::string, std::vector<const xAOD::StripCluster*>>
392 monitored_strip_map, reference_strip_map;
394 for (
const auto* c : *monitoredPixelClusters) {
395 monitored_pixel_map[std::to_string(c->identifierHash())].push_back(c);
397 for (
const auto* c : *monitoredStripClusters) {
398 monitored_strip_map[std::to_string(c->identifierHash())].push_back(c);
400 for (
const auto* c : *referencePixelClusters) {
401 reference_pixel_map[std::to_string(c->identifierHash())].push_back(c);
403 for (
const auto* c : *referenceStripClusters) {
404 reference_strip_map[std::to_string(c->identifierHash())].push_back(c);
408 std::set<std::string> pixel_modules, strip_modules;
409 for (
const auto& [key, _] : monitored_pixel_map)
410 pixel_modules.insert(key);
411 for (
const auto& [key, _] : reference_pixel_map)
412 pixel_modules.insert(key);
413 for (
const auto& [key, _] : monitored_strip_map)
414 strip_modules.insert(key);
415 for (
const auto& [key, _] : reference_strip_map)
416 strip_modules.insert(key);
418 int pixel_unequal = 0, strip_unequal = 0;
419 int matched_pixel = 0, matched_strip = 0;
420 int pixel_pos_diff_0p5sig = 0;
421 int pixel_pos_diff_0p25sig = 0;
422 int pixel_pos_diff_1sig = 0;
423 int strip_pos_diff_0p5sig = 0;
424 int strip_pos_diff_0p25sig = 0;
425 int strip_pos_diff_1sig = 0;
426 int strip_pos_diff_barrel = 0;
427 int strip_pos_diff_EC = 0;
429 ATH_MSG_DEBUG(
"Pixel/Strip modules " << pixel_modules.size() <<
" / "
430 << strip_modules.size());
433 "============================================================");
436 for (
const auto& hid : pixel_modules) {
437 auto& tpixel = monitored_pixel_map[hid];
438 auto& apixel = reference_pixel_map[hid];
440 if (tpixel.empty() && apixel.empty())
443 if (tpixel.size() != apixel.size()) {
445 <<
": mismatched clusters found!");
447 <<
" and monitored found " << tpixel.size() <<
" clusters!");
453 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>
457 matched_pixel += pixel_pairs.size();
460 for (
const auto&
pair : pixel_pairs) {
464 (pixel_cluster_matches)[
pair.first] =
pair.second;
471 double l_pos_diff = std::sqrt(l_dx * l_dx + l_dy * l_dy);
481 std::sqrt(g_dx * g_dx + g_dy * g_dy + g_dz * g_dz);
484 Eigen::Matrix<float, 2, 2> monitored_cov =
486 Eigen::Matrix<float, 2, 2> reference_cov =
494 monitored_element->
design());
498 double monitored_lorentz_shift =
503 if (std::abs(l_dx / (std::sqrt(reference_cov(0, 0)))) > 0.25 ||
504 std::abs(l_dy / (std::sqrt(reference_cov(1, 1)))) > 0.25) {
505 pixel_pos_diff_0p25sig++;
509 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
511 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): " << tracccShift->first);
512 ATH_MSG_DEBUG(
" Δshift = " << tracccShift->first - monitored_lorentz_shift);
514 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): not found for module " << monitored_Pixel_ModuleID);
528 <<
", Δr = " << l_pos_diff);
531 << monitored_cov(1, 1) <<
")");
533 << reference_cov(1, 1) <<
")");
534 ATH_MSG_DEBUG(
" Δx = " << monitored_cov(0, 0) - reference_cov(0, 0)
536 << monitored_cov(1, 1) - reference_cov(1, 1));
539 const auto& rdoListRange = monitored_cluster->
rdoList();
540 std::vector<Identifier> monitored_rdoList(
541 rdoListRange.begin(), rdoListRange.end());
542 for (
auto rdoIter : monitored_rdoList) {
545 std::array<InDetDD::PixelDiodeTree::CellIndexType, 2>
553 <<
", position: " << si_param.
position()[0]
558 *monDesign, *monCond)) {
559 ATH_MSG_DEBUG(
" traccc position for this cell: " << (*tracccPos)[0]
560 <<
", " << (*tracccPos)[1]
561 <<
" (Δ = " << (*tracccPos)[0] - si_param.
position()[0]
562 <<
", " << (*tracccPos)[1] - si_param.
position()[1] <<
")");
588 if (std::abs(l_dx / (std::sqrt(reference_cov(0, 0)))) > 0.5 ||
589 std::abs(l_dy / (std::sqrt(reference_cov(1, 1)))) > 0.5) {
590 pixel_pos_diff_0p5sig++;
592 if (std::abs(l_dx / (std::sqrt(reference_cov(0, 0)))) > 1 ||
593 std::abs(l_dy / (std::sqrt(reference_cov(1, 1)))) > 1) {
594 pixel_pos_diff_1sig++;
608 << g_dz <<
", Δr = " << g_pos_diff);
614 "============================================================");
617 "============================================================");
619 for (
const auto& hid : strip_modules) {
620 auto& tstrip = monitored_strip_map[hid];
621 auto& astrip = reference_strip_map[hid];
623 if (tstrip.empty() && astrip.empty())
626 if (tstrip.size() != astrip.size()) {
628 << hid <<
": mismatched clusters found!");
630 <<
" and monitored found "
631 << tstrip.size() <<
" clusters!");
637 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>
641 matched_strip += strip_pairs.size();
644 for (
const auto&
pair : strip_pairs) {
648 (strip_cluster_matches)[
pair.first] =
pair.second;
656 Eigen::Matrix<float, 1, 1> monitored_cov =
658 Eigen::Matrix<float, 1, 1> reference_cov =
665 if (std::abs(pos_diff / (std::sqrt(reference_cov(0, 0)))) > 0.25) {
666 strip_pos_diff_0p25sig++;
671 if (
m_stripID->barrel_ec(strip_moduleID) == 0) strip_pos_diff_barrel++;
672 else strip_pos_diff_EC++;
675 double monitored_lorentz_shift =
680 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
684 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): " << tracccShift->first);
685 ATH_MSG_DEBUG(
" Δshift = " << tracccShift->first - monitored_lorentz_shift);
687 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): not found for wafer " << strip_waferID);
698 ATH_MSG_DEBUG(
" Monitored: (" << monitored_cov(0, 0) <<
")");
699 ATH_MSG_DEBUG(
" Reference: (" << reference_cov(0, 0) <<
")");
700 ATH_MSG_DEBUG(
" Δx = " << monitored_cov(0, 0) - reference_cov(0, 0));
702 const auto& rdoListRange = monitored_cluster->
rdoList();
703 std::vector<Identifier> monitored_rdoList(
704 rdoListRange.begin(), rdoListRange.end());
706 if (monitored_element->
isBarrel()) {
709 for (
auto rdoIter : monitored_rdoList) {
717 <<
", position: " << loc_pos[0]
718 <<
", " << loc_pos[1]);
724 <<
" (Δ = " << (*tracccPos)[0] - loc_pos[0] <<
")");
734 for (
auto rdoIter : monitored_rdoList) {
746 <<
", position: " << loc_pos[0]
747 <<
", " << loc_pos[1]
748 <<
", polar (phi, r): " << pc_pos.
xPhi()
749 <<
", " << pc_pos.
xEta());
755 <<
" (Δphi = " << (*tracccPos)[1] - pc_pos.
xPhi() <<
")");
774 if (std::abs(pos_diff / (std::sqrt(reference_cov(0, 0)))) > 0.5) {
775 strip_pos_diff_0p5sig++;
777 if (std::abs(pos_diff / (std::sqrt(reference_cov(0, 0)))) > 1) {
778 strip_pos_diff_1sig++;
785 "============================================================");
789 "============================================================");
793 << pixel_pos_diff_1sig <<
" ("
794 << (matched_pixel > 0
795 ? 100.0 * pixel_pos_diff_1sig / matched_pixel
799 << pixel_pos_diff_0p5sig <<
" ("
800 << (matched_pixel > 0
801 ? 100.0 * pixel_pos_diff_0p5sig / matched_pixel
805 << pixel_pos_diff_0p25sig <<
" ("
806 << (matched_pixel > 0
807 ? 100.0 * pixel_pos_diff_0p25sig / matched_pixel
811 "============================================================");
813 "============================================================");
817 << strip_pos_diff_1sig <<
" ("
818 << (matched_strip > 0
819 ? 100.0 * strip_pos_diff_1sig / matched_strip
823 << strip_pos_diff_0p5sig <<
" ("
824 << (matched_strip > 0
825 ? 100.0 * strip_pos_diff_0p5sig / matched_strip
829 << strip_pos_diff_0p25sig <<
" ("
830 << (matched_strip > 0
831 ? 100.0 * strip_pos_diff_0p25sig / matched_strip
835 "============================================================");
850 return StatusCode::SUCCESS;
854 const EventContext& eventContext, std::unordered_map<const xAOD::PixelCluster*, const xAOD::PixelCluster*>& pixel_cluster_matches)
const
866 monitoredSpacepointsHandle.
cptr();
872 referenceSpacepointsHandle.
cptr();
874 size_t t_n_sp = monitoredSpacepoints->
size();
875 size_t a_n_sp = referenceSpacepoints->
size();
877 ATH_MSG_DEBUG(
" Monitored/reference spacepoints " << t_n_sp <<
" / " << a_n_sp);
879 if (t_n_sp != a_n_sp) {
880 ATH_MSG_DEBUG(
"[ERROR] mismatched spacepoint numbers found!");
881 ATH_MSG_DEBUG(
" Monitored/reference spacepoints " << t_n_sp <<
" / "
887 int unmatched_monitored_sp = 0;
888 int unmatched_reference_sp = 0;
889 int sp_global_pos_diff_1mm = 0;
890 int sp_global_pos_diff_5mm = 0;
891 int sp_variance_r_diff = 0;
892 int sp_variance_z_diff = 0;
894 std::vector<std::pair<const xAOD::SpacePoint*, const xAOD::SpacePoint*>>
896 std::set<const xAOD::SpacePoint*> matched_reference_sp;
898 for (
const auto* monitored_sp : *monitoredSpacepoints) {
900 const auto& monitored_measurements = monitored_sp->measurements();
903 bool found_match =
false;
904 for (
const auto* reference_sp : *referenceSpacepoints) {
906 const auto& reference_measurements = reference_sp->measurements();
909 if (monitored_measurements.size() != reference_measurements.size())
913 bool all_clusters_match =
true;
914 for (
size_t i = 0; i < monitored_measurements.size(); ++i) {
916 monitored_measurements[i];
918 reference_measurements[i];
921 auto monitored_pixel =
923 auto reference_pixel =
926 if (monitored_pixel && reference_pixel) {
927 auto it = pixel_cluster_matches.find(monitored_pixel);
928 if (it == pixel_cluster_matches.end() ||
929 it->second != reference_pixel) {
930 all_clusters_match =
false;
936 "strip spacepoints are not yet handled, skipping pair");
937 all_clusters_match =
false;
942 if (all_clusters_match) {
946 sp_matches.push_back(std::make_pair(monitored_sp, reference_sp));
947 matched_reference_sp.insert(reference_sp);
955 unmatched_monitored_sp++;
959 for (
auto& sp_pair : sp_matches) {
964 double dx = monitored_sp->
x() - reference_sp->
x();
965 double dy = monitored_sp->
y() - reference_sp->
y();
966 double dz = monitored_sp->
z() - reference_sp->
z();
967 double pos_diff = std::sqrt(dx * dx + dy * dy + dz * dz);
971 ATH_MSG_DEBUG(
" Monitored: (" << monitored_sp->
x() <<
", " << monitored_sp->
y()
972 <<
", " << monitored_sp->
z() <<
")");
973 ATH_MSG_DEBUG(
" Reference: (" << reference_sp->
x() <<
", " << reference_sp->
y()
974 <<
", " << reference_sp->
z() <<
")");
975 ATH_MSG_DEBUG(
" Δx = " << dx <<
", Δy = " << dy <<
", Δz = " << dz
976 <<
", Δr = " << pos_diff);
979 sp_global_pos_diff_1mm++;
981 sp_global_pos_diff_5mm++;
991 << reference_sp->
radius() <<
")");
1002 sp_variance_r_diff++;
1006 sp_variance_z_diff++;
1010 unmatched_reference_sp = referenceSpacepoints->
size() - matched_reference_sp.size();
1014 "============================================================");
1016 ATH_MSG_INFO(
" Total monitored spacepoints: " << t_n_sp);
1017 ATH_MSG_INFO(
" Total reference spacepoints: " << a_n_sp);
1019 ATH_MSG_INFO(
" Unmatched monitored spacepoints: " << unmatched_monitored_sp);
1020 ATH_MSG_INFO(
" Unmatched reference spacepoints: " << unmatched_reference_sp);
1022 "============================================================");
1025 " Spacepoints with global pos diff > 1 mm: "
1026 << sp_global_pos_diff_1mm <<
" ("
1027 << (matched_sp > 0 ? 100.0 * sp_global_pos_diff_1mm / matched_sp : 0.0)
1030 " Spacepoints with global pos diff > 5 mm: "
1031 << sp_global_pos_diff_5mm <<
" ("
1032 << (matched_sp > 0 ? 100.0 * sp_global_pos_diff_5mm / matched_sp : 0.0)
1035 "============================================================");
1038 " Spacepoints with >10% variance R difference: "
1039 << sp_variance_r_diff <<
" ("
1040 << (matched_sp > 0 ? 100.0 * sp_variance_r_diff / matched_sp : 0.0)
1043 " Spacepoints with >10% variance Z difference: "
1044 << sp_variance_z_diff <<
" ("
1045 << (matched_sp > 0 ? 100.0 * sp_variance_z_diff / matched_sp : 0.0)
1048 "============================================================");
1061 return StatusCode::SUCCESS;