321{
322
324 "============================================================");
325
327 << " and "
330 << " and "
333 "============================================================");
334
335 SG::ReadHandle<xAOD::PixelClusterContainer> monitoredPixelClustersHandle =
339 monitoredPixelClustersHandle.
cptr();
340
341 SG::ReadHandle<xAOD::StripClusterContainer> monitoredStripClustersHandle =
345 monitoredStripClustersHandle.
cptr();
346
347 SG::ReadHandle<xAOD::PixelClusterContainer> referencePixelClustersHandle =
351 referencePixelClustersHandle.
cptr();
352
353 SG::ReadHandle<xAOD::StripClusterContainer> referenceStripClustersHandle =
357 referenceStripClustersHandle.
cptr();
358
359 const traccc::detector_design_description::host* monDesign = nullptr;
361
362 const traccc::detector_conditions_description::host* monCond{};
364
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();
369
370 ATH_MSG_DEBUG(
" Monitored/reference pixel clusters " << t_n_pixel <<
" / "
371 << a_n_pixel);
372 ATH_MSG_DEBUG(
" Monitored/reference strip clusters " << t_n_strip <<
" / "
373 << a_n_strip);
374
375 if (t_n_pixel != a_n_pixel) {
377 ATH_MSG_ERROR(
" Monitored/reference clusters " << t_n_pixel <<
" / "
378 << a_n_pixel);
379 return StatusCode::FAILURE;
380 }
381 if (t_n_strip != a_n_strip) {
383 ATH_MSG_ERROR(
" Monitored/reference clusters " << t_n_strip <<
" / "
384 << a_n_strip);
385 return StatusCode::FAILURE;
386 }
387
388
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;
393
394 for (const auto* c : *monitoredPixelClusters) {
395 monitored_pixel_map[std::to_string(
c->identifierHash())].push_back(c);
396 }
397 for (const auto* c : *monitoredStripClusters) {
398 monitored_strip_map[std::to_string(
c->identifierHash())].push_back(c);
399 }
400 for (const auto* c : *referencePixelClusters) {
401 reference_pixel_map[std::to_string(
c->identifierHash())].push_back(c);
402 }
403 for (const auto* c : *referenceStripClusters) {
404 reference_strip_map[std::to_string(
c->identifierHash())].push_back(c);
405 }
406
407
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);
417
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;
428
429 ATH_MSG_DEBUG(
"Pixel/Strip modules " << pixel_modules.size() <<
" / "
430 << strip_modules.size());
433 "============================================================");
434
435
436 for (const auto& hid : pixel_modules) {
437 auto& tpixel = monitored_pixel_map[hid];
438 auto& apixel = reference_pixel_map[hid];
439
440 if (tpixel.empty() && apixel.empty())
441 continue;
442
443 if (tpixel.size() != apixel.size()) {
445 << ": mismatched clusters found!");
447 << " and monitored found " << tpixel.size() << " clusters!");
448 pixel_unequal++;
449 continue;
450 }
451
452 std::vector<
453 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>
454 pixel_pairs;
456
457 matched_pixel += pixel_pairs.size();
458
459
460 for (const auto& pair : pixel_pairs) {
463
464 (pixel_cluster_matches)[pair.first] = pair.second;
465
466
467 double l_dx = monitored_cluster->localPosition<2>()[
Trk::locX] -
468 reference_cluster->localPosition<2>()[
Trk::locX];
469 double l_dy = monitored_cluster->localPosition<2>()[
Trk::locY] -
470 reference_cluster->localPosition<2>()[
Trk::locY];
471 double l_pos_diff = std::sqrt(l_dx * l_dx + l_dy * l_dy);
472
473
474 float g_dx = (monitored_cluster->globalPosition()).x() -
475 (reference_cluster->globalPosition()).x();
476 float g_dy = (monitored_cluster->globalPosition()).y() -
477 (reference_cluster->globalPosition()).y();
478 float g_dz = (monitored_cluster->globalPosition()).z() -
479 (reference_cluster->globalPosition()).z();
480 float g_pos_diff =
481 std::sqrt(g_dx * g_dx + g_dy * g_dy + g_dz * g_dz);
482
483
484 Eigen::Matrix<float, 2, 2> monitored_cov =
485 monitored_cluster->localCovariance<2>();
486 Eigen::Matrix<float, 2, 2> reference_cov =
487 reference_cluster->localCovariance<2>();
488
489 const InDetDD::SiDetectorElement* monitored_element =
491 monitored_cluster->identifierHash());
492 const InDetDD::PixelModuleDesign& design =
493 static_cast<const InDetDD::PixelModuleDesign&>(
494 monitored_element->
design());
495
496 const Identifier monitored_Pixel_ModuleID =
498 double monitored_lorentz_shift =
501
502
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++;
506
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);
513 } else {
514 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): not found for module " << monitored_Pixel_ModuleID);
515 }
516
517
520 " Monitored: ("
521 << monitored_cluster->localPosition<2>()[
Trk::locX] <<
", "
522 << monitored_cluster->localPosition<2>()[
Trk::locY] <<
")");
524 << reference_cluster->localPosition<2>()[
Trk::locX] <<
", "
525 << reference_cluster->localPosition<2>()[
Trk::locY]
526 << ")");
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)
535 << ", Δy = "
536 << monitored_cov(1, 1) - reference_cov(1, 1));
537
538
539 const auto& rdoListRange = monitored_cluster->rdoList();
540 std::vector<Identifier> monitored_rdoList(
541 rdoListRange.begin(), rdoListRange.end());
542 for (auto rdoIter : monitored_rdoList) {
543 const InDetDD::SiCellId& chargeCellId =
545 std::array<InDetDD::PixelDiodeTree::CellIndexType, 2>
548
549 InDetDD::PixelDiodeTree::DiodeProxyWithPosition si_param(
552 << chargeCellId
553 << ", position: " << si_param.position()[0]
554 << ", " << si_param.position()[1]);
555
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] << ")");
563 } else {
565 }
566 }
567
568
571 << monitored_cluster->channelsInPhi() << ", "
572 << monitored_cluster->channelsInEta() << ", "
573 << monitored_cluster->widthInEta() << ")");
575 << reference_cluster->channelsInPhi() << ", "
576 << reference_cluster->channelsInEta() << ", "
577 << reference_cluster->widthInEta() << ")");
578
579 ATH_MSG_DEBUG(
" Δphi = " << monitored_cluster->channelsInPhi() -
580 reference_cluster->channelsInPhi()
581 << ", Δeta = "
582 << monitored_cluster->channelsInEta() -
583 reference_cluster->channelsInEta()
584 << ", Δwidth = "
585 << monitored_cluster->widthInEta() -
586 reference_cluster->widthInEta());
587 }
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++;
591 }
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++;
595 }
596
597
600 << (monitored_cluster->globalPosition()).x() << ", "
601 << (monitored_cluster->globalPosition()).y() << ", "
602 << (monitored_cluster->globalPosition()).z() << ")");
604 << (reference_cluster->globalPosition()).x() << ", "
605 << (reference_cluster->globalPosition()).y() << ", "
606 << (reference_cluster->globalPosition()).z() << ")");
608 << g_dz << ", Δr = " << g_pos_diff);
609
610 }
611 }
612
614 "============================================================");
617 "============================================================");
618
619 for (const auto& hid : strip_modules) {
620 auto& tstrip = monitored_strip_map[hid];
621 auto& astrip = reference_strip_map[hid];
622
623 if (tstrip.empty() && astrip.empty())
624 continue;
625
626 if (tstrip.size() != astrip.size()) {
628 << hid << ": mismatched clusters found!");
630 << " and monitored found "
631 << tstrip.size() << " clusters!");
632 strip_unequal++;
633 continue;
634 }
635
636 std::vector<
637 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>
638 strip_pairs;
640
641 matched_strip += strip_pairs.size();
642
643
644 for (const auto& pair : strip_pairs) {
647
648 (strip_cluster_matches)[pair.first] = pair.second;
649
650
651 double pos_diff = monitored_cluster->localPosition<1>()[
Trk::locX] -
652 reference_cluster->localPosition<1>()[
Trk::locX];
653
654
655
656 Eigen::Matrix<float, 1, 1> monitored_cov =
657 monitored_cluster->localCovariance<1>();
658 Eigen::Matrix<float, 1, 1> reference_cov =
659 reference_cluster->localCovariance<1>();
660
661 const InDetDD::SiDetectorElement* monitored_element =
662 m_stripManager->getDetectorElement(monitored_cluster->identifierHash());
663
664
665 if (std::abs(pos_diff / (std::sqrt(reference_cov(0, 0)))) > 0.25) {
666 strip_pos_diff_0p25sig++;
667
669 const Identifier strip_moduleID =
m_stripID->module_id(monitored_element->
identify());
670
671 if (
m_stripID->barrel_ec(strip_moduleID) == 0) strip_pos_diff_barrel++;
672 else strip_pos_diff_EC++;
673
674 const IdentifierHash Strip_ModuleHash =
m_stripID->wafer_hash(strip_moduleID);
675 double monitored_lorentz_shift =
677
680 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
681
682 const Identifier strip_waferID =
m_stripID->wafer_id(Strip_ModuleHash + side);
684 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): " << tracccShift->first);
685 ATH_MSG_DEBUG(
" Δshift = " << tracccShift->first - monitored_lorentz_shift);
686 } else {
687 ATH_MSG_DEBUG(
"Lorentz shift (traccc conditions): not found for wafer " << strip_waferID);
688 }
689
692 " Monitored: ("
693 << monitored_cluster->localPosition<1>()[
Trk::locX] <<
")");
695 << reference_cluster->localPosition<1>()[
Trk::locX] <<
")");
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));
701
702 const auto& rdoListRange = monitored_cluster->rdoList();
703 std::vector<Identifier> monitored_rdoList(
704 rdoListRange.begin(), rdoListRange.end());
705
706 if (monitored_element->
isBarrel()) {
707 const InDetDD::SCT_BarrelModuleSideDesign* s_design = (
static_cast<const InDetDD::SCT_BarrelModuleSideDesign*
>(&monitored_element->
design()));
708
709 for (auto rdoIter : monitored_rdoList) {
710 const InDetDD::SiCellId& chargeCellId =
712 InDetDD::SiLocalPosition si_pos =
716 << chargeCellId
717 << ", position: " << loc_pos[0]
718 << ", " << loc_pos[1]);
719
723 << (*tracccPos)[0]
724 << " (Δ = " << (*tracccPos)[0] - loc_pos[0] << ")");
725 } else {
727 }
728 }
729
730 }else{
731
732 const InDetDD::StripStereoAnnulusDesign* annulus_design = (
static_cast<const InDetDD::StripStereoAnnulusDesign*
>(&monitored_element->
design()));
733
734 for (auto rdoIter : monitored_rdoList) {
735 const InDetDD::SiCellId& chargeCellId =
737
738 InDetDD::SiLocalPosition si_pos =
741
742 const InDetDD::SiLocalPosition pc_pos =
745 << chargeCellId
746 << ", position: " << loc_pos[0]
747 << ", " << loc_pos[1]
748 <<
", polar (phi, r): " << pc_pos.
xPhi()
749 <<
", " << pc_pos.
xEta());
750
754 << (*tracccPos)[1]
755 <<
" (Δphi = " << (*tracccPos)[1] - pc_pos.
xPhi() <<
")");
756 } else {
758 }
759 }
760
761 }
762
763
766 << monitored_cluster->channelsInPhi() << ")");
768 << reference_cluster->channelsInPhi() << ")");
769
770 ATH_MSG_DEBUG(
" Δphi = " << monitored_cluster->channelsInPhi() -
771 reference_cluster->channelsInPhi());
772
773 }
774 if (std::abs(pos_diff / (std::sqrt(reference_cov(0, 0)))) > 0.5) {
775 strip_pos_diff_0p5sig++;
776 }
777 if (std::abs(pos_diff / (std::sqrt(reference_cov(0, 0)))) > 1) {
778 strip_pos_diff_1sig++;
779 }
780
781 }
782 }
783
785 "============================================================");
786
787
789 "============================================================");
793 << pixel_pos_diff_1sig << " ("
794 << (matched_pixel > 0
795 ? 100.0 * pixel_pos_diff_1sig / matched_pixel
796 : 0.0)
797 << "%)");
799 << pixel_pos_diff_0p5sig << " ("
800 << (matched_pixel > 0
801 ? 100.0 * pixel_pos_diff_0p5sig / matched_pixel
802 : 0.0)
803 << "%)");
805 << pixel_pos_diff_0p25sig << " ("
806 << (matched_pixel > 0
807 ? 100.0 * pixel_pos_diff_0p25sig / matched_pixel
808 : 0.0)
809 << "%)");
811 "============================================================");
813 "============================================================");
817 << strip_pos_diff_1sig << " ("
818 << (matched_strip > 0
819 ? 100.0 * strip_pos_diff_1sig / matched_strip
820 : 0.0)
821 << "%)");
823 << strip_pos_diff_0p5sig << " ("
824 << (matched_strip > 0
825 ? 100.0 * strip_pos_diff_0p5sig / matched_strip
826 : 0.0)
827 << "%)");
829 << strip_pos_diff_0p25sig << " ("
830 << (matched_strip > 0
831 ? 100.0 * strip_pos_diff_0p25sig / matched_strip
832 : 0.0)
833 << "%)");
835 "============================================================");
836
849
850 return StatusCode::SUCCESS;
851}
#define ATH_MSG_VERBOSE(x,...)
void matchPixelClusters(std::vector< const xAOD::PixelCluster * > &monitored_list, std::vector< const xAOD::PixelCluster * > &reference_list, const std::string &module_id, std::vector< std::pair< const xAOD::PixelCluster *, const xAOD::PixelCluster * > > &pairs) const
Gaudi::Accumulators::Counter m_pixel_unequal
std::optional< std::pair< float, float > > tracccLorentzShift(const Identifier &athenaId, const traccc::detector_conditions_description::host &cond) const
Lorentz shift stored in the traccc host conditions object for the given Athena module (side).
Gaudi::Property< std::string > m_monDesignObjectName
std::optional< std::array< float, 2 > > tracccCellPosition(const Identifier &athenaId, unsigned int channel0, unsigned int channel1, const traccc::detector_design_description::host &design, const traccc::detector_conditions_description::host &cond) const
Centre of the traccc readout bin (channel0, channel1) on the given Athena module, computed like tracc...
Gaudi::Accumulators::Counter m_strip_unequal
void matchStripClusters(std::vector< const xAOD::StripCluster * > &monitored_list, std::vector< const xAOD::StripCluster * > &reference_list, const std::string &module_id, std::vector< std::pair< const xAOD::StripCluster *, const xAOD::StripCluster * > > &pairs) const
size_type size() const noexcept
Returns the number of elements in the collection.
static constexpr std::array< PixelDiodeTree::CellIndexType, 2 > makeCellIndex(T local_x_idx, T local_y_idx)
Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction.
PixelDiodeTree::DiodeProxyWithPosition diodeProxyFromIdxCachePosition(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const
id -> position
int phiIndex() const
Get phi index. Equivalent to strip().
int etaIndex() const
Get eta index.
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
virtual Identifier identify() const override final
identifier of this detector element (inline)
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const override
id -> position
SiLocalPosition localPositionOfCellPC(const SiCellId &cellId) const
This is for debugging only.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Eigen::Matrix< double, 2, 1 > Vector2D
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
PixelClusterContainer_v1 PixelClusterContainer
Define the version of the pixel cluster container.
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.