229{
230
232 "============================================================");
233
235 << " and "
238 << " and "
241 "============================================================");
242
243 SG::ReadHandle<xAOD::PixelClusterContainer> monitoredPixelClustersHandle =
247 monitoredPixelClustersHandle.
cptr();
248
249 SG::ReadHandle<xAOD::StripClusterContainer> monitoredStripClustersHandle =
253 monitoredStripClustersHandle.
cptr();
254
255 SG::ReadHandle<xAOD::PixelClusterContainer> referencePixelClustersHandle =
259 referencePixelClustersHandle.
cptr();
260
261 SG::ReadHandle<xAOD::StripClusterContainer> referenceStripClustersHandle =
265 referenceStripClustersHandle.
cptr();
266
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();
271
272 ATH_MSG_DEBUG(
" Monitored/reference pixel clusters " << t_n_pixel <<
" / "
273 << a_n_pixel);
274 ATH_MSG_DEBUG(
" Monitored/reference strip clusters " << t_n_strip <<
" / "
275 << a_n_strip);
276
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 <<
" / "
280 << a_n_pixel);
281 }
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 <<
" / "
285 << a_n_strip);
286 }
287
288
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;
293
294 for (const auto* c : *monitoredPixelClusters) {
295 monitored_pixel_map[std::to_string(
c->identifierHash())].push_back(c);
296 }
297 for (const auto* c : *monitoredStripClusters) {
298 monitored_strip_map[std::to_string(
c->identifierHash())].push_back(c);
299 }
300 for (const auto* c : *referencePixelClusters) {
301 reference_pixel_map[std::to_string(
c->identifierHash())].push_back(c);
302 }
303 for (const auto* c : *referenceStripClusters) {
304 reference_strip_map[std::to_string(
c->identifierHash())].push_back(c);
305 }
306
307
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);
317
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;
326
327 ATH_MSG_DEBUG(
"Pixel/Strip modules " << pixel_modules.size() <<
" / "
328 << strip_modules.size());
331 "============================================================");
332
333
334 for (const auto& hid : pixel_modules) {
335 auto& tpixel = monitored_pixel_map[hid];
336 auto& apixel = reference_pixel_map[hid];
337
338 if (tpixel.empty() && apixel.empty())
339 continue;
340
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!"
346 << std::endl;
347 pixel_unequal++;
348 continue;
349 }
350
351 std::vector<
352 std::pair<const xAOD::PixelCluster*, const xAOD::PixelCluster*>>
353 pixel_pairs;
355
356 matched_pixel += pixel_pairs.size();
357
358
359 for (const auto& pair : pixel_pairs) {
362
363 (pixel_cluster_matches)[pair.first] = pair.second;
364
365
366 double l_dx = monitored_cluster->localPosition<2>()[
Trk::locX] -
367 reference_cluster->localPosition<2>()[
Trk::locX];
368 double l_dy = monitored_cluster->localPosition<2>()[
Trk::locY] -
369 reference_cluster->localPosition<2>()[
Trk::locY];
370 double l_pos_diff = std::sqrt(l_dx * l_dx + l_dy * l_dy);
371
372
373 float g_dx = (monitored_cluster->globalPosition()).x() -
374 (reference_cluster->globalPosition()).x();
375 float g_dy = (monitored_cluster->globalPosition()).y() -
376 (reference_cluster->globalPosition()).y();
377 float g_dz = (monitored_cluster->globalPosition()).z() -
378 (reference_cluster->globalPosition()).z();
379 float g_pos_diff =
380 std::sqrt(g_dx * g_dx + g_dy * g_dy + g_dz * g_dz);
381
382
383 Eigen::Matrix<float, 2, 2> monitored_cov =
384 monitored_cluster->localCovariance<2>();
385 Eigen::Matrix<float, 2, 2> reference_cov =
386 reference_cluster->localCovariance<2>();
387
388 const InDetDD::SiDetectorElement* monitored_element =
390 monitored_cluster->identifierHash());
391 const InDetDD::PixelModuleDesign& design =
392 static_cast<const InDetDD::PixelModuleDesign&>(
393 monitored_element->
design());
394
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++;
398
399 const Identifier monitored_Pixel_ModuleID =
401 double monitored_lorentz_shift =
404
405
406
409 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
410
413 " Monitored: ("
414 << monitored_cluster->localPosition<2>()[
Trk::locX] <<
", "
415 << monitored_cluster->localPosition<2>()[
Trk::locY] <<
")");
417 << reference_cluster->localPosition<2>()[
Trk::locX] <<
", "
418 << reference_cluster->localPosition<2>()[
Trk::locY]
419 << ")");
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)
428 << ", Δy = "
429 << monitored_cov(1, 1) - reference_cov(1, 1));
430
431
432 const auto& rdoListRange = monitored_cluster->rdoList();
433 std::vector<Identifier> monitored_rdoList(
434 rdoListRange.begin(), rdoListRange.end());
435 for (auto rdoIter : monitored_rdoList) {
436 const InDetDD::SiCellId& chargeCellId =
438 std::array<InDetDD::PixelDiodeTree::CellIndexType, 2>
441
442 InDetDD::PixelDiodeTree::DiodeProxyWithPosition si_param(
445 << chargeCellId
446 << ", position: " << si_param.position()[0]
447 << ", " << si_param.position()[1]);
448 }
449
450
453 << monitored_cluster->channelsInPhi() << ", "
454 << monitored_cluster->channelsInEta() << ", "
455 << monitored_cluster->widthInEta() << ")");
457 << reference_cluster->channelsInPhi() << ", "
458 << reference_cluster->channelsInEta() << ", "
459 << reference_cluster->widthInEta() << ")");
460
461 ATH_MSG_DEBUG(
" Δphi = " << monitored_cluster->channelsInPhi() -
462 reference_cluster->channelsInPhi()
463 << ", Δeta = "
464 << monitored_cluster->channelsInEta() -
465 reference_cluster->channelsInEta()
466 << ", Δwidth = "
467 << monitored_cluster->widthInEta() -
468 reference_cluster->widthInEta());
469 }
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++;
473 }
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++;
477 }
478
479
482 << (monitored_cluster->globalPosition()).x() << ", "
483 << (monitored_cluster->globalPosition()).y() << ", "
484 << (monitored_cluster->globalPosition()).z() << ")");
486 << (reference_cluster->globalPosition()).x() << ", "
487 << (reference_cluster->globalPosition()).y() << ", "
488 << (reference_cluster->globalPosition()).z() << ")");
490 << g_dz << ", Δr = " << g_pos_diff);
491
492 }
493 }
494
496 "============================================================");
499 "============================================================");
500
501 for (const auto& hid : strip_modules) {
502 auto& tstrip = monitored_strip_map[hid];
503 auto& astrip = reference_strip_map[hid];
504
505 if (tstrip.empty() && astrip.empty())
506 continue;
507
508 if (tstrip.size() != astrip.size()) {
510 << hid << ": mismatched clusters found!");
512 << " and monitored found "
513 << tstrip.size() << " clusters!");
514 strip_unequal++;
515 continue;
516 }
517
518 std::vector<
519 std::pair<const xAOD::StripCluster*, const xAOD::StripCluster*>>
520 strip_pairs;
522
523 matched_strip += strip_pairs.size();
524
525
526 for (const auto& pair : strip_pairs) {
529
530 (strip_cluster_matches)[pair.first] = pair.second;
531
532
533 double pos_diff = monitored_cluster->localPosition<1>()[
Trk::locX] -
534 reference_cluster->localPosition<1>()[
Trk::locX];
535
536
537
538 Eigen::Matrix<float, 1, 1> monitored_cov =
539 monitored_cluster->localCovariance<1>();
540 Eigen::Matrix<float, 1, 1> reference_cov =
541 reference_cluster->localCovariance<1>();
542
543 const InDetDD::SiDetectorElement* monitored_element =
544 m_stripManager->getDetectorElement(monitored_cluster->identifierHash());
545
546
547 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 0.25) {
548 strip_pos_diff_0p25sig++;
549
551 const Identifier strip_moduleID =
m_stripID->module_id(monitored_element->
identify());
552 const IdentifierHash Strip_ModuleHash =
m_stripID->wafer_hash(strip_moduleID);
553 double monitored_lorentz_shift =
555
558 ATH_MSG_DEBUG(
"Lorentz shift: " << std::fixed << std::setprecision(9) << monitored_lorentz_shift);
559
562 " Monitored: ("
563 << monitored_cluster->localPosition<1>()[
Trk::locX] <<
")");
565 << reference_cluster->localPosition<1>()[
Trk::locX] <<
")");
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));
571
572 const auto& rdoListRange = monitored_cluster->rdoList();
573 std::vector<Identifier> monitored_rdoList(
574 rdoListRange.begin(), rdoListRange.end());
575
576 if (monitored_element->
isBarrel()) {
577 const InDetDD::SCT_BarrelModuleSideDesign* s_design = (
static_cast<const InDetDD::SCT_BarrelModuleSideDesign*
>(&monitored_element->
design()));
578
579 for (auto rdoIter : monitored_rdoList) {
580 const InDetDD::SiCellId& chargeCellId =
582 InDetDD::SiLocalPosition si_pos =
586 << chargeCellId
587 << ", position: " << loc_pos[0]
588 << ", " << loc_pos[1]);
589 }
590
591 }else{
592
593 const InDetDD::StripStereoAnnulusDesign* annulus_design = (
static_cast<const InDetDD::StripStereoAnnulusDesign*
>(&monitored_element->
design()));
594
595 for (auto rdoIter : monitored_rdoList) {
596 const InDetDD::SiCellId& chargeCellId =
598
599 InDetDD::SiLocalPosition si_pos =
603 << chargeCellId
604 << ", posiiton: " << loc_pos[0]
605 << ", " << loc_pos[1]);
606 }
607
608 }
609
610
613 << monitored_cluster->channelsInPhi() << ")");
615 << reference_cluster->channelsInPhi() << ")");
616
617 ATH_MSG_DEBUG(
" Δphi = " << monitored_cluster->channelsInPhi() -
618 reference_cluster->channelsInPhi());
619
620 }
621 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 0.5) {
622 strip_pos_diff_0p5sig++;
623 }
624 if (std::abs(pos_diff / (std::sqrt(monitored_cov(0, 0)))) > 1) {
625 strip_pos_diff_1sig++;
626 }
627
628 }
629 }
630
632 "============================================================");
633
634
636 "============================================================");
640 << pixel_pos_diff_1sig << " ("
641 << (matched_pixel > 0
642 ? 100.0 * pixel_pos_diff_1sig / matched_pixel
643 : 0.0)
644 << "%)");
646 << pixel_pos_diff_0p5sig << " ("
647 << (matched_pixel > 0
648 ? 100.0 * pixel_pos_diff_0p5sig / matched_pixel
649 : 0.0)
650 << "%)");
652 << pixel_pos_diff_0p25sig << " ("
653 << (matched_pixel > 0
654 ? 100.0 * pixel_pos_diff_0p25sig / matched_pixel
655 : 0.0)
656 << "%)");
658 "============================================================");
660 "============================================================");
664 << strip_pos_diff_1sig << " ("
665 << (matched_strip > 0
666 ? 100.0 * strip_pos_diff_1sig / matched_strip
667 : 0.0)
668 << "%)");
670 << strip_pos_diff_0p5sig << " ("
671 << (matched_strip > 0
672 ? 100.0 * strip_pos_diff_0p5sig / matched_strip
673 : 0.0)
674 << "%)");
676 << strip_pos_diff_0p25sig << " ("
677 << (matched_strip > 0
678 ? 100.0 * strip_pos_diff_0p25sig / matched_strip
679 : 0.0)
680 << "%)");
682 "============================================================");
683
694
695 return StatusCode::SUCCESS;
696}
#define ATH_MSG_VERBOSE(x)
Gaudi::Accumulators::Counter m_pixel_unequal
Gaudi::Accumulators::Counter m_strip_unequal
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.
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)
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)
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.
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.