284{
285
287 "============================================================");
288
290 << " and "
293 << " and "
296 "============================================================");
297
298 SG::ReadHandle<xAOD::PixelClusterContainer> monitoredPixelClustersHandle =
302 monitoredPixelClustersHandle.
cptr();
303
304 SG::ReadHandle<xAOD::StripClusterContainer> monitoredStripClustersHandle =
308 monitoredStripClustersHandle.
cptr();
309
310 SG::ReadHandle<xAOD::PixelClusterContainer> referencePixelClustersHandle =
314 referencePixelClustersHandle.
cptr();
315
316 SG::ReadHandle<xAOD::StripClusterContainer> referenceStripClustersHandle =
320 referenceStripClustersHandle.
cptr();
321
322 size_t t_n_pixel = monitoredPixelClusters->
size();
323 size_t t_n_strip = monitoredStripClusters->
size();
324 size_t a_n_pixel = referencePixelClusters->
size();
325 size_t a_n_strip = referenceStripClusters->
size();
326
327 ATH_MSG_DEBUG(
" Monitored/reference pixel clusters " << t_n_pixel <<
" / "
328 << a_n_pixel);
329 ATH_MSG_DEBUG(
" Monitored/reference strip clusters " << t_n_strip <<
" / "
330 << a_n_strip);
331
332 if (t_n_pixel != a_n_pixel) {
333 ATH_MSG_DEBUG(
"[ERROR] mismatched pixel cluster numbers found!");
334 ATH_MSG_DEBUG(
" Monitored/reference clusters " << t_n_pixel <<
" / "
335 << a_n_pixel);
336 }
337 if (t_n_strip != a_n_strip) {
338 ATH_MSG_DEBUG(
"[ERROR] mismatched strip cluster numbers found!");
339 ATH_MSG_DEBUG(
" Monitored/reference clusters " << t_n_strip <<
" / "
340 << a_n_strip);
341 }
342
343
344 std::map<std::string, std::vector<const xAOD::PixelCluster*>>
345 monitored_pixel_map, reference_pixel_map;
346 std::map<std::string, std::vector<const xAOD::StripCluster*>>
347 monitored_strip_map, reference_strip_map;
348
349 for (const auto* c : *monitoredPixelClusters) {
350 monitored_pixel_map[std::to_string(
c->identifierHash())].push_back(c);
351 }
352 for (const auto* c : *monitoredStripClusters) {
353 monitored_strip_map[std::to_string(
c->identifierHash())].push_back(c);
354 }
355 for (const auto* c : *referencePixelClusters) {
356 reference_pixel_map[std::to_string(
c->identifierHash())].push_back(c);
357 }
358 for (const auto* c : *referenceStripClusters) {
359 reference_strip_map[std::to_string(
c->identifierHash())].push_back(c);
360 }
361
362
363 std::set<std::string> pixel_modules, strip_modules;
364 for (const auto& [key, _] : monitored_pixel_map)
365 pixel_modules.insert(key);
366 for (const auto& [key, _] : reference_pixel_map)
367 pixel_modules.insert(key);
368 for (const auto& [key, _] : monitored_strip_map)
369 strip_modules.insert(key);
370 for (const auto& [key, _] : reference_strip_map)
371 strip_modules.insert(key);
372
373 int pixel_unequal = 0, strip_unequal = 0;
374 int matched_pixel = 0, matched_strip = 0;
375 int pixel_pos_diff_0p5sig = 0;
376 int pixel_pos_diff_0p25sig = 0;
377 int pixel_pos_diff_1sig = 0;
378 int strip_pos_diff_0p5sig = 0;
379 int strip_pos_diff_0p25sig = 0;
380 int strip_pos_diff_1sig = 0;
381
382 ATH_MSG_DEBUG(
"Pixel/Strip modules " << pixel_modules.size() <<
" / "
383 << strip_modules.size());
386 "============================================================");
387
388
389 for (const auto& hid : pixel_modules) {
390 auto& tpixel = monitored_pixel_map[hid];
391 auto& apixel = reference_pixel_map[hid];
392
393 if (tpixel.empty() && apixel.empty())
394 continue;
395
396 if (tpixel.size() != apixel.size()) {
398 << ": mismatched clusters found!");
400 << " and monitored found " << tpixel.size() << " clusters!");
401 pixel_unequal++;
402 continue;
403 }
404
405 std::vector<
406 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>
407 pixel_pairs;
409
410 matched_pixel += pixel_pairs.size();
411
412
413 for (const auto& pair : pixel_pairs) {
416
417 (pixel_cluster_matches)[pair.first] = pair.second;
418
419
420 double l_dx = monitored_cluster->localPosition<2>()[
Trk::locX] -
421 reference_cluster->localPosition<2>()[
Trk::locX];
422 double l_dy = monitored_cluster->localPosition<2>()[
Trk::locY] -
423 reference_cluster->localPosition<2>()[
Trk::locY];
424 double l_pos_diff = std::sqrt(l_dx * l_dx + l_dy * l_dy);
425
426
427 float g_dx = (monitored_cluster->globalPosition()).x() -
428 (reference_cluster->globalPosition()).x();
429 float g_dy = (monitored_cluster->globalPosition()).y() -
430 (reference_cluster->globalPosition()).y();
431 float g_dz = (monitored_cluster->globalPosition()).z() -
432 (reference_cluster->globalPosition()).z();
433 float g_pos_diff =
434 std::sqrt(g_dx * g_dx + g_dy * g_dy + g_dz * g_dz);
435
436
437 Eigen::Matrix<float, 2, 2> monitored_cov =
438 monitored_cluster->localCovariance<2>();
439 Eigen::Matrix<float, 2, 2> reference_cov =
440 reference_cluster->localCovariance<2>();
441
442 const InDetDD::SiDetectorElement* monitored_element =
444 monitored_cluster->identifierHash());
445 const InDetDD::PixelModuleDesign& design =
446 static_cast<const InDetDD::PixelModuleDesign&>(
447 monitored_element->
design());
448
449 const Identifier monitored_Pixel_ModuleID =
451 double monitored_lorentz_shift =
454
455
456 if (std::abs(l_dx / (std::sqrt(monitored_cov(0, 0)))) > 0.25 ||
457 std::abs(l_dy / (std::sqrt(monitored_cov(1, 1)))) > 0.25) {
458 pixel_pos_diff_0p25sig++;
459
462 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
463
466 " Monitored: ("
467 << monitored_cluster->localPosition<2>()[
Trk::locX] <<
", "
468 << monitored_cluster->localPosition<2>()[
Trk::locY] <<
")");
470 << reference_cluster->localPosition<2>()[
Trk::locX] <<
", "
471 << reference_cluster->localPosition<2>()[
Trk::locY]
472 << ")");
474 << ", Δr = " << l_pos_diff);
477 << monitored_cov(1, 1) << ")");
479 << reference_cov(1, 1) << ")");
480 ATH_MSG_DEBUG(
" Δx = " << monitored_cov(0, 0) - reference_cov(0, 0)
481 << ", Δy = "
482 << monitored_cov(1, 1) - reference_cov(1, 1));
483
484
485 const auto& rdoListRange = monitored_cluster->rdoList();
486 std::vector<Identifier> monitored_rdoList(
487 rdoListRange.begin(), rdoListRange.end());
488 for (auto rdoIter : monitored_rdoList) {
489 const InDetDD::SiCellId& chargeCellId =
491 std::array<InDetDD::PixelDiodeTree::CellIndexType, 2>
494
495 InDetDD::PixelDiodeTree::DiodeProxyWithPosition si_param(
498 << chargeCellId
499 << ", position: " << si_param.position()[0]
500 << ", " << si_param.position()[1]);
501 }
502
503
506 << monitored_cluster->channelsInPhi() << ", "
507 << monitored_cluster->channelsInEta() << ", "
508 << monitored_cluster->widthInEta() << ")");
510 << reference_cluster->channelsInPhi() << ", "
511 << reference_cluster->channelsInEta() << ", "
512 << reference_cluster->widthInEta() << ")");
513
514 ATH_MSG_DEBUG(
" Δphi = " << monitored_cluster->channelsInPhi() -
515 reference_cluster->channelsInPhi()
516 << ", Δeta = "
517 << monitored_cluster->channelsInEta() -
518 reference_cluster->channelsInEta()
519 << ", Δwidth = "
520 << monitored_cluster->widthInEta() -
521 reference_cluster->widthInEta());
522 }
523 if (std::abs(l_dx / (std::sqrt(monitored_cov(0, 0)))) > 0.5 ||
524 std::abs(l_dy / (std::sqrt(monitored_cov(1, 1)))) > 0.5) {
525 pixel_pos_diff_0p5sig++;
526 }
527 if (std::abs(l_dx / (std::sqrt(monitored_cov(0, 0)))) > 1 ||
528 std::abs(l_dy / (std::sqrt(monitored_cov(1, 1)))) > 1) {
529 pixel_pos_diff_1sig++;
530 }
531
532
535 << (monitored_cluster->globalPosition()).x() << ", "
536 << (monitored_cluster->globalPosition()).y() << ", "
537 << (monitored_cluster->globalPosition()).z() << ")");
539 << (reference_cluster->globalPosition()).x() << ", "
540 << (reference_cluster->globalPosition()).y() << ", "
541 << (reference_cluster->globalPosition()).z() << ")");
543 << g_dz << ", Δr = " << g_pos_diff);
544
545 }
546 }
547
549 "============================================================");
552 "============================================================");
553
554 for (const auto& hid : strip_modules) {
555 auto& tstrip = monitored_strip_map[hid];
556 auto& astrip = reference_strip_map[hid];
557
558 if (tstrip.empty() && astrip.empty())
559 continue;
560
561 if (tstrip.size() != astrip.size()) {
563 << hid << ": mismatched clusters found!");
565 << " and monitored found "
566 << tstrip.size() << " clusters!");
567 strip_unequal++;
568 continue;
569 }
570
571 std::vector<
572 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>
573 strip_pairs;
575
576 matched_strip += strip_pairs.size();
577
578
579 for (const auto& pair : strip_pairs) {
582
583 (strip_cluster_matches)[pair.first] = pair.second;
584
585
586 double pos_diff = monitored_cluster->localPosition<1>()[
Trk::locX] -
587 reference_cluster->localPosition<1>()[
Trk::locX];
588
589
590
591 Eigen::Matrix<float, 1, 1> monitored_cov =
592 monitored_cluster->localCovariance<1>();
593 Eigen::Matrix<float, 1, 1> reference_cov =
594 reference_cluster->localCovariance<1>();
595
596 const InDetDD::SiDetectorElement* monitored_element =
597 m_stripManager->getDetectorElement(monitored_cluster->identifierHash());
598
599
600 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 0.25) {
601 strip_pos_diff_0p25sig++;
602
604 const Identifier strip_moduleID =
m_stripID->module_id(monitored_element->
identify());
605 const IdentifierHash Strip_ModuleHash =
m_stripID->wafer_hash(strip_moduleID);
606 double monitored_lorentz_shift =
608
611 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
612
615 " Monitored: ("
616 << monitored_cluster->localPosition<1>()[
Trk::locX] <<
")");
618 << reference_cluster->localPosition<1>()[
Trk::locX] <<
")");
621 ATH_MSG_DEBUG(
" Monitored: (" << monitored_cov(0, 0) <<
")");
622 ATH_MSG_DEBUG(
" Reference: (" << reference_cov(0, 0) <<
")");
623 ATH_MSG_DEBUG(
" Δx = " << monitored_cov(0, 0) - reference_cov(0, 0));
624
625 const auto& rdoListRange = monitored_cluster->rdoList();
626 std::vector<Identifier> monitored_rdoList(
627 rdoListRange.begin(), rdoListRange.end());
628
629 if (monitored_element->
isBarrel()) {
630 const InDetDD::SCT_BarrelModuleSideDesign* s_design = (
static_cast<const InDetDD::SCT_BarrelModuleSideDesign*
>(&monitored_element->
design()));
631
632 for (auto rdoIter : monitored_rdoList) {
633 const InDetDD::SiCellId& chargeCellId =
635 InDetDD::SiLocalPosition si_pos =
639 << chargeCellId
640 << ", position: " << loc_pos[0]
641 << ", " << loc_pos[1]);
642 }
643
644 }else{
645
646 const InDetDD::StripStereoAnnulusDesign* annulus_design = (
static_cast<const InDetDD::StripStereoAnnulusDesign*
>(&monitored_element->
design()));
647
648 for (auto rdoIter : monitored_rdoList) {
649 const InDetDD::SiCellId& chargeCellId =
651
652 InDetDD::SiLocalPosition si_pos =
656 << chargeCellId
657 << ", posiiton: " << loc_pos[0]
658 << ", " << loc_pos[1]);
659 }
660
661 }
662
663
666 << monitored_cluster->channelsInPhi() << ")");
668 << reference_cluster->channelsInPhi() << ")");
669
670 ATH_MSG_DEBUG(
" Δphi = " << monitored_cluster->channelsInPhi() -
671 reference_cluster->channelsInPhi());
672
673 }
674 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 0.5) {
675 strip_pos_diff_0p5sig++;
676 }
677 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 1) {
678 strip_pos_diff_1sig++;
679 }
680
681 }
682 }
683
685 "============================================================");
686
687
689 "============================================================");
693 << pixel_pos_diff_1sig << " ("
694 << (matched_pixel > 0
695 ? 100.0 * pixel_pos_diff_1sig / matched_pixel
696 : 0.0)
697 << "%)");
699 << pixel_pos_diff_0p5sig << " ("
700 << (matched_pixel > 0
701 ? 100.0 * pixel_pos_diff_0p5sig / matched_pixel
702 : 0.0)
703 << "%)");
705 << pixel_pos_diff_0p25sig << " ("
706 << (matched_pixel > 0
707 ? 100.0 * pixel_pos_diff_0p25sig / matched_pixel
708 : 0.0)
709 << "%)");
711 "============================================================");
713 "============================================================");
717 << strip_pos_diff_1sig << " ("
718 << (matched_strip > 0
719 ? 100.0 * strip_pos_diff_1sig / matched_strip
720 : 0.0)
721 << "%)");
723 << strip_pos_diff_0p5sig << " ("
724 << (matched_strip > 0
725 ? 100.0 * strip_pos_diff_0p5sig / matched_strip
726 : 0.0)
727 << "%)");
729 << strip_pos_diff_0p25sig << " ("
730 << (matched_strip > 0
731 ? 100.0 * strip_pos_diff_0p25sig / matched_strip
732 : 0.0)
733 << "%)");
735 "============================================================");
736
747
748 return StatusCode::SUCCESS;
749}
#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
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
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Eigen::Matrix< double, 2, 1 > Vector2D
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.