80 std::vector<const xAOD::PixelCluster*>& monitored_list,
81 std::vector<const xAOD::PixelCluster*>& reference_list,
82 const std::string& module_id,
84 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>& pairs)
88 std::vector<std::set<Identifier>> monitored_rdo_sets;
89 std::vector<std::set<Identifier>> reference_rdo_sets;
91 for (
const auto* c : monitored_list) {
92 const auto& rdoListRange = c->rdoList();
93 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
94 monitored_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
97 for (
const auto* c : reference_list) {
98 const auto& rdoListRange = c->rdoList();
99 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
100 reference_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
104 std::vector<std::pair<int, int>> matched_pairs;
105 std::vector<int> unmatched_monitored;
106 std::set<int> unmatched_reference;
108 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
109 unmatched_reference.insert(j);
112 for (
size_t i = 0; i < monitored_rdo_sets.size(); ++i) {
114 bool found_match =
false;
115 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
116 if (monitored_rdo_sets[i] == reference_rdo_sets[j]) {
117 matched_pairs.emplace_back(i, j);
118 pairs.emplace_back(monitored_list.at(i), reference_list.at(j));
120 unmatched_reference.erase(j);
125 unmatched_monitored.push_back(i);
130 if (!unmatched_monitored.empty() || !unmatched_reference.empty()) {
131 std::cout <<
"\n[ERROR] Module " << module_id
132 <<
": cluster mismatch detected!" << std::endl;
133 if (!unmatched_monitored.empty()) {
134 std::cout <<
" Unmatched monitored clusters ("
135 << unmatched_monitored.size() <<
"):" << std::endl;
136 for (
int i : unmatched_monitored) {
137 std::cout <<
" - #" << i << std::endl;
140 if (!unmatched_reference.empty()) {
141 std::cout <<
" Unmatched reference clusters (" << unmatched_reference.size()
142 <<
"):" << std::endl;
143 for (
int j : unmatched_reference) {
144 std::cout <<
" - #" << j << std::endl;
148 <<
"------------------------------------------------------------"
155 std::vector<const xAOD::StripCluster*>& monitored_list,
156 std::vector<const xAOD::StripCluster*>& reference_list,
157 const std::string& module_id,
159 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>& pairs)
163 std::vector<std::set<Identifier>> monitored_rdo_sets;
164 std::vector<std::set<Identifier>> reference_rdo_sets;
166 for (
const auto* c : monitored_list) {
167 const auto& rdoListRange = c->rdoList();
168 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
169 monitored_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
172 for (
const auto* c : reference_list) {
173 const auto& rdoListRange = c->rdoList();
174 std::vector<Identifier> rdoList(rdoListRange.begin(), rdoListRange.end());
175 reference_rdo_sets.emplace_back(rdoList.begin(), rdoList.end());
179 std::vector<std::pair<int, int>> matched_pairs;
180 std::vector<int> unmatched_monitored;
181 std::set<int> unmatched_reference;
183 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
184 unmatched_reference.insert(j);
187 for (
size_t i = 0; i < monitored_rdo_sets.size(); ++i) {
188 bool found_match =
false;
189 for (
size_t j = 0; j < reference_rdo_sets.size(); ++j) {
190 if (monitored_rdo_sets[i] == reference_rdo_sets[j]) {
191 matched_pairs.emplace_back(i, j);
192 pairs.emplace_back(monitored_list.at(i), reference_list.at(j));
194 unmatched_reference.erase(j);
199 unmatched_monitored.push_back(i);
204 if (!unmatched_monitored.empty() || !unmatched_reference.empty()) {
205 std::cout <<
"\n[ERROR] Module " << module_id
206 <<
": cluster mismatch detected!" << std::endl;
207 if (!unmatched_monitored.empty()) {
208 std::cout <<
" Unmatched monitored clusters ("
209 << unmatched_monitored.size() <<
"):" << std::endl;
210 for (
int i : unmatched_monitored) {
211 std::cout <<
" - #" << i << std::endl;
214 if (!unmatched_reference.empty()) {
215 std::cout <<
" Unmatched reference clusters (" << unmatched_reference.size()
216 <<
"):" << std::endl;
217 for (
int j : unmatched_reference) {
218 std::cout <<
" - #" << j << std::endl;
222 <<
"------------------------------------------------------------"
228 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
232 "============================================================");
241 "============================================================");
247 monitoredPixelClustersHandle.
cptr();
253 monitoredStripClustersHandle.
cptr();
259 referencePixelClustersHandle.
cptr();
265 referenceStripClustersHandle.
cptr();
267 size_t t_n_pixel = monitoredPixelClusters->
size();
268 size_t t_n_strip = monitoredStripClusters->
size();
269 size_t a_n_pixel = referencePixelClusters->
size();
270 size_t a_n_strip = referenceStripClusters->
size();
272 ATH_MSG_DEBUG(
" Monitored/reference pixel clusters " << t_n_pixel <<
" / "
274 ATH_MSG_DEBUG(
" Monitored/reference strip clusters " << t_n_strip <<
" / "
277 if (t_n_pixel != a_n_pixel) {
278 ATH_MSG_DEBUG(
"[ERROR] mismatched pixel cluster numbers found!");
279 ATH_MSG_DEBUG(
" Monitored/reference clusters " << t_n_pixel <<
" / "
282 if (t_n_strip != a_n_strip) {
283 ATH_MSG_DEBUG(
"[ERROR] mismatched strip cluster numbers found!");
284 ATH_MSG_DEBUG(
" Monitored/reference clusters " << t_n_strip <<
" / "
289 std::map<std::string, std::vector<const xAOD::PixelCluster*>>
290 monitored_pixel_map, reference_pixel_map;
291 std::map<std::string, std::vector<const xAOD::StripCluster*>>
292 monitored_strip_map, reference_strip_map;
294 for (
const auto* c : *monitoredPixelClusters) {
295 monitored_pixel_map[std::to_string(c->identifierHash())].push_back(c);
297 for (
const auto* c : *monitoredStripClusters) {
298 monitored_strip_map[std::to_string(c->identifierHash())].push_back(c);
300 for (
const auto* c : *referencePixelClusters) {
301 reference_pixel_map[std::to_string(c->identifierHash())].push_back(c);
303 for (
const auto* c : *referenceStripClusters) {
304 reference_strip_map[std::to_string(c->identifierHash())].push_back(c);
308 std::set<std::string> pixel_modules, strip_modules;
309 for (
const auto& [key, _] : monitored_pixel_map)
310 pixel_modules.insert(key);
311 for (
const auto& [key, _] : reference_pixel_map)
312 pixel_modules.insert(key);
313 for (
const auto& [key, _] : monitored_strip_map)
314 strip_modules.insert(key);
315 for (
const auto& [key, _] : reference_strip_map)
316 strip_modules.insert(key);
318 int pixel_unequal = 0, strip_unequal = 0;
319 int matched_pixel = 0, matched_strip = 0;
320 int pixel_pos_diff_0p5sig = 0;
321 int pixel_pos_diff_0p25sig = 0;
322 int pixel_pos_diff_1sig = 0;
323 int strip_pos_diff_0p5sig = 0;
324 int strip_pos_diff_0p25sig = 0;
325 int strip_pos_diff_1sig = 0;
327 ATH_MSG_DEBUG(
"Pixel/Strip modules " << pixel_modules.size() <<
" / "
328 << strip_modules.size());
331 "============================================================");
334 for (
const auto& hid : pixel_modules) {
335 auto& tpixel = monitored_pixel_map[hid];
336 auto& apixel = reference_pixel_map[hid];
338 if (tpixel.empty() && apixel.empty())
341 if (tpixel.size() != apixel.size()) {
342 std::cout <<
"\n[ERROR] Pixel Module " << hid
343 <<
": mismatched clusters found!" << std::endl;
344 std::cout <<
" Reference found " << apixel.size()
345 <<
" and monitored found " << tpixel.size() <<
" clusters!"
352 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>
356 matched_pixel += pixel_pairs.size();
359 for (
const auto&
pair : pixel_pairs) {
363 (pixel_cluster_matches)[
pair.first] =
pair.second;
370 double l_pos_diff = std::sqrt(l_dx * l_dx + l_dy * l_dy);
380 std::sqrt(g_dx * g_dx + g_dy * g_dy + g_dz * g_dz);
383 Eigen::Matrix<float, 2, 2> monitored_cov =
385 Eigen::Matrix<float, 2, 2> reference_cov =
393 monitored_element->
design());
395 if (std::abs(l_dx / (std::sqrt(monitored_cov(0, 0)))) > 0.25 ||
396 std::abs(l_dy / (std::sqrt(monitored_cov(1, 1)))) > 0.25) {
397 pixel_pos_diff_0p25sig++;
401 double monitored_lorentz_shift =
409 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
421 <<
", Δr = " << l_pos_diff);
424 << monitored_cov(1, 1) <<
")");
426 << reference_cov(1, 1) <<
")");
427 ATH_MSG_DEBUG(
" Δx = " << monitored_cov(0, 0) - reference_cov(0, 0)
429 << monitored_cov(1, 1) - reference_cov(1, 1));
432 const auto& rdoListRange = monitored_cluster->
rdoList();
433 std::vector<Identifier> monitored_rdoList(
434 rdoListRange.begin(), rdoListRange.end());
435 for (
auto rdoIter : monitored_rdoList) {
438 std::array<InDetDD::PixelDiodeTree::CellIndexType, 2>
446 <<
", position: " << si_param.
position()[0]
470 if (std::abs(l_dx / (std::sqrt(monitored_cov(0, 0)))) > 0.5 ||
471 std::abs(l_dy / (std::sqrt(monitored_cov(1, 1)))) > 0.5) {
472 pixel_pos_diff_0p5sig++;
474 if (std::abs(l_dx / (std::sqrt(monitored_cov(0, 0)))) > 1 ||
475 std::abs(l_dy / (std::sqrt(monitored_cov(1, 1)))) > 1) {
476 pixel_pos_diff_1sig++;
490 << g_dz <<
", Δr = " << g_pos_diff);
496 "============================================================");
499 "============================================================");
501 for (
const auto& hid : strip_modules) {
502 auto& tstrip = monitored_strip_map[hid];
503 auto& astrip = reference_strip_map[hid];
505 if (tstrip.empty() && astrip.empty())
508 if (tstrip.size() != astrip.size()) {
510 << hid <<
": mismatched clusters found!");
512 <<
" and monitored found "
513 << tstrip.size() <<
" clusters!");
519 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>
523 matched_strip += strip_pairs.size();
526 for (
const auto&
pair : strip_pairs) {
530 (strip_cluster_matches)[
pair.first] =
pair.second;
538 Eigen::Matrix<float, 1, 1> monitored_cov =
540 Eigen::Matrix<float, 1, 1> reference_cov =
547 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 0.25) {
548 strip_pos_diff_0p25sig++;
553 double monitored_lorentz_shift =
558 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
568 ATH_MSG_DEBUG(
" Monitored: (" << monitored_cov(0, 0) <<
")");
569 ATH_MSG_DEBUG(
" Reference: (" << reference_cov(0, 0) <<
")");
570 ATH_MSG_DEBUG(
" Δx = " << monitored_cov(0, 0) - reference_cov(0, 0));
572 const auto& rdoListRange = monitored_cluster->
rdoList();
573 std::vector<Identifier> monitored_rdoList(
574 rdoListRange.begin(), rdoListRange.end());
576 if (monitored_element->
isBarrel()) {
579 for (
auto rdoIter : monitored_rdoList) {
587 <<
", position: " << loc_pos[0]
588 <<
", " << loc_pos[1]);
595 for (
auto rdoIter : monitored_rdoList) {
604 <<
", posiiton: " << loc_pos[0]
605 <<
", " << loc_pos[1]);
621 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 0.5) {
622 strip_pos_diff_0p5sig++;
624 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 1) {
625 strip_pos_diff_1sig++;
632 "============================================================");
636 "============================================================");
640 << pixel_pos_diff_1sig <<
" ("
641 << (matched_pixel > 0
642 ? 100.0 * pixel_pos_diff_1sig / matched_pixel
646 << pixel_pos_diff_0p5sig <<
" ("
647 << (matched_pixel > 0
648 ? 100.0 * pixel_pos_diff_0p5sig / matched_pixel
652 << pixel_pos_diff_0p25sig <<
" ("
653 << (matched_pixel > 0
654 ? 100.0 * pixel_pos_diff_0p25sig / matched_pixel
658 "============================================================");
660 "============================================================");
664 << strip_pos_diff_1sig <<
" ("
665 << (matched_strip > 0
666 ? 100.0 * strip_pos_diff_1sig / matched_strip
670 << strip_pos_diff_0p5sig <<
" ("
671 << (matched_strip > 0
672 ? 100.0 * strip_pos_diff_0p5sig / matched_strip
676 << strip_pos_diff_0p25sig <<
" ("
677 << (matched_strip > 0
678 ? 100.0 * strip_pos_diff_0p25sig / matched_strip
682 "============================================================");
695 return StatusCode::SUCCESS;
699 const EventContext& eventContext, std::unordered_map<const xAOD::PixelCluster*, const xAOD::PixelCluster*>& pixel_cluster_matches)
const
711 monitoredSpacepointsHandle.
cptr();
717 referenceSpacepointsHandle.
cptr();
719 size_t t_n_sp = monitoredSpacepoints->
size();
720 size_t a_n_sp = referenceSpacepoints->
size();
722 ATH_MSG_DEBUG(
" Monitored/reference spacepoints " << t_n_sp <<
" / " << a_n_sp);
724 if (t_n_sp != a_n_sp) {
725 ATH_MSG_DEBUG(
"[ERROR] mismatched spacepoint numbers found!");
726 ATH_MSG_DEBUG(
" Monitored/reference spacepoints " << t_n_sp <<
" / "
732 int unmatched_monitored_sp = 0;
733 int unmatched_reference_sp = 0;
734 int sp_global_pos_diff_1mm = 0;
735 int sp_global_pos_diff_5mm = 0;
736 int sp_variance_r_diff = 0;
737 int sp_variance_z_diff = 0;
739 std::vector<std::pair<const xAOD::SpacePoint*, const xAOD::SpacePoint*>>
741 std::set<const xAOD::SpacePoint*> matched_reference_sp;
743 for (
const auto* monitored_sp : *monitoredSpacepoints) {
745 const auto& monitored_measurements = monitored_sp->measurements();
748 bool found_match =
false;
749 for (
const auto* reference_sp : *referenceSpacepoints) {
751 const auto& reference_measurements = reference_sp->measurements();
754 if (monitored_measurements.size() != reference_measurements.size())
758 bool all_clusters_match =
true;
759 for (
size_t i = 0; i < monitored_measurements.size(); ++i) {
761 monitored_measurements[i];
763 reference_measurements[i];
766 auto monitored_pixel =
768 auto reference_pixel =
771 if (monitored_pixel && reference_pixel) {
772 auto it = pixel_cluster_matches.find(monitored_pixel);
773 if (it == pixel_cluster_matches.end() ||
774 it->second != reference_pixel) {
775 all_clusters_match =
false;
781 "strip spacepoints are not yet handled, skipping pair");
782 all_clusters_match =
false;
787 if (all_clusters_match) {
791 sp_matches.push_back(std::make_pair(monitored_sp, reference_sp));
792 matched_reference_sp.insert(reference_sp);
800 unmatched_monitored_sp++;
804 for (
auto& sp_pair : sp_matches) {
809 double dx = monitored_sp->
x() - reference_sp->
x();
810 double dy = monitored_sp->
y() - reference_sp->
y();
811 double dz = monitored_sp->
z() - reference_sp->
z();
812 double pos_diff = std::sqrt(dx * dx + dy * dy + dz * dz);
816 ATH_MSG_DEBUG(
" Monitored: (" << monitored_sp->
x() <<
", " << monitored_sp->
y()
817 <<
", " << monitored_sp->
z() <<
")");
818 ATH_MSG_DEBUG(
" Reference: (" << reference_sp->
x() <<
", " << reference_sp->
y()
819 <<
", " << reference_sp->
z() <<
")");
820 ATH_MSG_DEBUG(
" Δx = " << dx <<
", Δy = " << dy <<
", Δz = " << dz
821 <<
", Δr = " << pos_diff);
824 sp_global_pos_diff_1mm++;
826 sp_global_pos_diff_5mm++;
836 << reference_sp->
radius() <<
")");
847 sp_variance_r_diff++;
851 sp_variance_z_diff++;
855 unmatched_reference_sp = referenceSpacepoints->
size() - matched_reference_sp.size();
859 "============================================================");
861 ATH_MSG_INFO(
" Total monitored spacepoints: " << t_n_sp);
862 ATH_MSG_INFO(
" Total reference spacepoints: " << a_n_sp);
864 ATH_MSG_INFO(
" Unmatched monitored spacepoints: " << unmatched_monitored_sp);
865 ATH_MSG_INFO(
" Unmatched reference spacepoints: " << unmatched_reference_sp);
867 "============================================================");
870 " Spacepoints with global pos diff > 1 mm: "
871 << sp_global_pos_diff_1mm <<
" ("
872 << (matched_sp > 0 ? 100.0 * sp_global_pos_diff_1mm / matched_sp : 0.0)
875 " Spacepoints with global pos diff > 5 mm: "
876 << sp_global_pos_diff_5mm <<
" ("
877 << (matched_sp > 0 ? 100.0 * sp_global_pos_diff_5mm / matched_sp : 0.0)
880 "============================================================");
883 " Spacepoints with >10% variance R difference: "
884 << sp_variance_r_diff <<
" ("
885 << (matched_sp > 0 ? 100.0 * sp_variance_r_diff / matched_sp : 0.0)
888 " Spacepoints with >10% variance Z difference: "
889 << sp_variance_z_diff <<
" ("
890 << (matched_sp > 0 ? 100.0 * sp_variance_z_diff / matched_sp : 0.0)
893 "============================================================");
906 return StatusCode::SUCCESS;