ATLAS Offline Software
Loading...
Searching...
No Matches
MuonValR4::PatternVisualizationTool Class Reference

#include <PatternVisualizationTool.h>

Inheritance diagram for MuonValR4::PatternVisualizationTool:
Collaboration diagram for MuonValR4::PatternVisualizationTool:

Public Types

using LabeledSegmentSet = std::unordered_set<const xAOD::MuonSegment*>

Public Member Functions

virtual StatusCode initialize () override final
virtual void visualizeBucket (const EventContext &ctx, const MuonR4::SpacePointBucket &bucket, const std::string &extraLabel) const override final
virtual void visualizeBucket (const EventContext &ctx, const MuonR4::SpacePointBucket &bucket, const std::string &extraLabel, PrimitiveVec &&extraPaints) const override final
virtual void visualizeSeed (const EventContext &ctx, const MuonR4::SegmentSeed &seed, const std::string &extraLabel) const override final
virtual void visualizeSeed (const EventContext &ctx, const MuonR4::SegmentSeed &seed, const std::string &extraLabel, PrimitiveVec &&extraPaints) const override final
virtual void visualizeAccumulator (const EventContext &ctx, const MuonR4::HoughPlane &accumulator, const Acts::HoughTransformUtils::HoughAxisRanges &axisRanges, const MaximumVec &maxima, const std::string &extraLabel) const override final
virtual void visualizeAccumulator (const EventContext &ctx, const MuonR4::HoughPlane &accumulator, const Acts::HoughTransformUtils::HoughAxisRanges &axisRanges, const MaximumVec &maxima, const std::string &extraLabel, PrimitiveVec &&extraPaints) const override final
virtual void visualizeSegment (const EventContext &ctx, const MuonR4::Segment &segment, const std::string &extraLabel) const override final
virtual void visualizeSegment (const EventContext &ctx, const MuonR4::Segment &segment, const std::string &extraLabel, PrimitiveVec &&extraPaints) const override final
virtual LabeledSegmentSet getLabeledSegments (const std::vector< const MuonR4::SpacePoint * > &hits) const override final
 Returns whether the hit has been used on the labeled segments we refer to (e.g.
virtual LabeledSegmentSet getLabeledSegments (const std::vector< const xAOD::UncalibratedMeasurement * > &hits) const override final
virtual bool isLabeled (const MuonR4::SpacePoint &hit) const override final
 Fetches all labeled (e.g.
virtual bool isLabeled (const xAOD::UncalibratedMeasurement &hit) const override final
template<class SpacePointType>
const SpacePoint * drawHit (const SpacePointType &hit, Canvas_t &canvas, DynamicLegend &legend, const unsigned int view, unsigned int fillStyle) const

Private Types

using Canvas_t = IRootVisualizationService::ICanvasObject
using Edges = Canvas_t::AxisRanges
using SegLink_t = ElementLink<xAOD::MuonSegmentContainer>
using SegLinkVec_t = std::vector<SegLink_t>
using SegLinkDecor_t = SG::ConstAccessor<SegLinkVec_t>

Private Member Functions

template<class SpacePointType>
bool drawHits (const MuonR4::SpacePointBucket &bucket, const std::vector< SpacePointType > &hitsToDraw, Canvas_t &canvasDim, DynamicLegend &legend, unsigned int view) const
 Translates the Spacepoint information into TObjects that are dawn on the canvas & evaluates the size of the box surrounding the event.
template<class SpacePointType>
const MuonR4::SpacePoint * drawHit (const SpacePointType &hit, Canvas_t &canvas, DynamicLegend &legend, const unsigned int view, unsigned int fillStyle) const
 Converts a Hit into a particular TBox/ TEllipse for drawing.
template<class SpacePointType>
void writeChi2 (const MuonR4::SegmentFit::Parameters &pars, const std::vector< SpacePointType > &hits, Canvas_t &canvas, const double legX=0.2, double startLegY=0.8, const double endLegY=0.3) const
 Writes the chi2 of the hits onto the Canvas.
void paintSimHits (const EventContext &ctx, const xAOD::MuonSegment &truthSeg, Canvas_t &canvas, const int view) const
 Paints the truth sim hits associated with the segment.

Private Attributes

ServiceHandle< IRootVisualizationService > m_visualSvc {this, "VisualSvc", "MuonValR4::RootVisualizationService"}
 Service handle of the visualization service.
IRootVisualizationService::ClientToken m_clientToken {}
 Token to present to the visualization service such that the display froms this tool are grouped together.
Gaudi::Property< unsigned int > m_canvasLimit {this, "CanvasLimits", 5000}
 Maximum canvases to draw.
Gaudi::Property< bool > m_saveSinglePDFs {this, "saveSinglePDFs", false}
 If set to true each canvas is saved into a dedicated pdf file.
Gaudi::Property< bool > m_saveSummaryPDF {this, "saveSummaryPDF", false}
 If set to true a summary Canvas is created.
Gaudi::Property< std::string > m_canvasPrefix {this, "CanvasPreFix", ""}
 Prefix of the individual canvas file names <MANDATORY>.
Gaudi::Property< std::string > m_subDir {this, "outSubDir", ""}
 Define the subdirectory in which the plots shall be saved.
Gaudi::Property< bool > m_displayBucket {this, "displayBucket", true}
 Display the surrounding hits from the bucket not part of the seed.
Gaudi::Property< bool > m_accumlIsEta {this, "AccumulatorsInEtaPlane", true}
 Swtich toggling whether the accumulator view are in the eta or phi plane.
Gaudi::Property< bool > m_doEtaBucketViews {this,"doEtaBucketViews", true}
 Switch to visualize the eta view of the bucket event.
Gaudi::Property< bool > m_doPhiBucketViews {this,"doPhiBucketViews", false}
 Switch to visualize the phi view of the bucket event.
Gaudi::Property< bool > m_paintTruthHits {this, "paintTruthHits", false}
 Switch to visualize the truth hits.
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prepContainerKeys {this, "PrdContainer", {}}
 Declare dependency on the prep data containers.
Gaudi::Property< std::set< std::string > > m_truthSegLinks {this, "TruthSegDecors", {}}
 List of truth segment links to fetch.
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_truthLinkDecorKeys {this, "LinkDecorKeys", {}}
 Declaration of the dependency on the decorations.
std::vector< SegLinkDecor_t > m_truthLinkDecors {}
Gaudi::Property< bool > m_displayOnlyTruth {this, "displayTruthOnly", false}
const MuonGMR4::MuonDetectorManager * m_detMgr {nullptr}
 pointer to the Detector manager
ActsTrk::GeoContextReadKey_t m_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
 Geometry context key to retrieve the alignment.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 Service Handle to the IMuonIdHelperSvc.
std::atomic< bool > m_plotsDone {false}
 Flag toggling whether all Canvases have been exhausted.

Detailed Description

Definition at line 133 of file PatternVisualizationTool.h.

Member Typedef Documentation

◆ Canvas_t

◆ Edges

◆ LabeledSegmentSet

◆ SegLink_t

◆ SegLinkDecor_t

◆ SegLinkVec_t

Definition at line 284 of file PatternVisualizationTool.h.

Member Function Documentation

◆ drawHit() [1/2]

template<class SpacePointType>
const SpacePoint * MuonValR4::PatternVisualizationTool::drawHit ( const SpacePointType & hit,
Canvas_t & canvas,
DynamicLegend & legend,
const unsigned int view,
unsigned int fillStyle ) const

Don't draw any hit which is not participating in the view

Update the fill style accrodingly

Definition at line 508 of file PatternVisualizationTool.cxx.

510 {
511
513 if ((view == objViewEta && !hit.measuresEta()) || (view == objViewPhi && !hit.measuresPhi())) {
514 return nullptr;
515 }
516
517 if (hit.type() != xAOD::UncalibMeasType::Other) {
518 canvas.expandPad(hit.localPosition()[view] - hit.driftRadius(),
519 hit.localPosition().z() - hit.driftRadius());
520 canvas.expandPad(hit.localPosition()[view] + hit.driftRadius(),
521 hit.localPosition().z() + hit.driftRadius());
522 }
523
524 const SpacePoint* underlyingSp{nullptr};
526 constexpr int invalidCalibFill = 3305;
527 if constexpr (std::is_same_v<SpacePointType, SpacePoint>) {
528 ATH_MSG_VERBOSE("drawHit called with SpacePoint");
529 underlyingSp = &hit;
531 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(hit.primaryMeasurement());
532 if (dc && dc->status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
533 fillStyle = invalidCalibFill;
534 }
535 }
536 } else if constexpr(std::is_same_v<SpacePointType, CalibratedSpacePoint>) {
537 ATH_MSG_VERBOSE("drawHit called with CalibratedSpacePoint");
538 underlyingSp = hit.spacePoint();
539 if (hit.fitState() == CalibratedSpacePoint::State::Valid) {
540 fillStyle = fullFilling;
541 } else if (hit.fitState() == CalibratedSpacePoint::State::FailedCalib) {
542 fillStyle = invalidCalibFill;
543 } else {
544 fillStyle = hatchedFilling;
545 }
546 }
547 else{
548 ATH_MSG_VERBOSE("drawHit called with unsupported SpacePointType");
549 }
550
551 //TODO: investigate MuonSegmentFittingAlg.PatternVisualizationTool throws seg fault without check but the calibrated space point should have reference space point no?
552 if (!underlyingSp){
553 ATH_MSG_VERBOSE("Underlying space point not found, skipping hit");
554 return nullptr;
555 }
556
557 const auto* primaryMeas = underlyingSp->primaryMeasurement();
558 const auto* secondaryMeas = underlyingSp->secondaryMeasurement();
559
560 //If there is a secondary measurement and it is not matched, choose a different colour to the cases where we have primary and it is matched
561 //Need to cast secondary measurement to the respective det type?
562 auto labeledColor = (secondaryMeas && !isLabeled(*secondaryMeas)) ? kOrange - 3 : truthColor;
563
564 const auto covarianceWidth = [&]() -> double {
565 const double variance = std::max(0., underlyingSp->covariance()[view]);
566 //In case of strip it would be too small to visualize the hit, so we set a minimum width of 5 mm, should we add sqrt(12) to get the full width of the strip?
567 return std::max(5. * Gaudi::Units::mm, std::sqrt(variance));
568 };
569
570 const auto addLabeledOutline = [&](const double boxWidth, const double boxHeight) {
571 if (!isLabeled(*primaryMeas)) {
572 return;
573 }
574 // Draw a dedicated hollow overlay so the truth-color border is always visible.
575 auto outline = drawBox(hit.localPosition(), boxWidth, boxHeight, labeledColor, hollowFilling, view);
576 outline->SetFillStyle(hollowFilling);
577 outline->SetLineColor(labeledColor);
578 TObject* p_outline = outline.get();
579 canvas.add(std::move(outline), "l");
580 legend.addOnce(LegendItem::LabeledBox, p_outline, "TrueSimHitMatch", "f");
581 };
582
583 // Add the hit to the legend depending on the fill style (outlier, full, or hatched)
584 const auto addHitLegendByFill = [&](TObject* object,
585 const LegendItem bucketItem,
586 const char* bucketLabel,
587 const LegendItem onObjectItem,
588 const char* onObjectLabel, const char* option = "f") {
589
590 if (fillStyle == hatchedFilling) {
591 legend.addOnce(LegendItem::OutlierHit, object, "Outlier", option);
592 return;
593 }
594 if (fillStyle == fullFilling) {
595 legend.addOnce(onObjectItem, object, onObjectLabel, option);
596 return;
597 }
598
599 // Hits in the bucket with a hollow filling
600 legend.addOnce(bucketItem, object, bucketLabel, option);
601 };
602
603 switch(hit.type()) {
605 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(primaryMeas);
606 canvas.add(drawDriftCircle(hit.localPosition(), dc->readoutElement()->innerTubeRadius(), kBlack, hollowFilling));
607 auto driftCircle = drawDriftCircle(hit.localPosition(), hit.driftRadius(), kBlue, fillStyle);
608 TObject* p_driftCircle = driftCircle.get();
609 canvas.add(std::move(driftCircle));
610
611 //Unforunately the legend will be a box ... to have a point we could make TGraph with a point and add it to the legend but then we would have to draw the hit as a TGrapg as well, so for now we keep it as a box
612 addHitLegendByFill(p_driftCircle,
614 "MDT inBucket",
616 "MDT onObject", "f");
617
618 //In case the hit is also a truth hit, change the line colour to indicate that
619 if (isLabeled(*dc)) {
620 auto labeledDriftCircle = drawDriftCircle(hit.localPosition(), hit.driftRadius(), labeledColor, hollowFilling);
621 TObject* p_labeledDriftCircle = labeledDriftCircle.get();
622 canvas.add(std::move(labeledDriftCircle));
623 legend.addOnce( LegendItem::LabeledTube, p_labeledDriftCircle, "TrueSimMdtHitMatch", "f");
624 }
625 break;
627 const auto* meas{static_cast<const xAOD::RpcMeasurement*>(primaryMeas)};
628 const double boxWidth = 0.5*std::sqrt(12)*std::sqrt(underlyingSp->covariance()[view]);
629 auto rpcBox = drawBox(hit.localPosition(), boxWidth, 0.5*meas->readoutElement()->gasGapPitch(),
630 kGreen + 2, fillStyle);
631 TObject* p_rpcBox = rpcBox.get();
632 canvas.add(std::move(rpcBox));
633 addHitLegendByFill(p_rpcBox,
635 "RPC inBucket",
637 "RPC onObject");
638 addLabeledOutline(boxWidth, 0.5*meas->readoutElement()->gasGapPitch());
639 break;
641 const auto* meas{static_cast<const xAOD::TgcStrip*>(primaryMeas)};
642 const double boxWidth = 0.5*std::sqrt(12)*std::sqrt(underlyingSp->covariance()[view]);
643 auto tgcBox = drawBox(hit.localPosition(), boxWidth, 0.5*meas->readoutElement()->gasGapPitch(),
644 kCyan + 2, fillStyle);
645 TObject* p_tgcBox = tgcBox.get();
646 canvas.add(std::move(tgcBox));
647 addHitLegendByFill(p_tgcBox,
649 "TGC inBucket",
651 "TGC onObject");
652 addLabeledOutline(boxWidth, 0.5*meas->readoutElement()->gasGapPitch());
653 break;
655 const double boxWidth = covarianceWidth();
656 constexpr double boxHeight = 10.*Gaudi::Units::mm;
657 auto mmBox = drawBox(hit.localPosition(), boxWidth, boxHeight, kAquamarine, fillStyle, view);
658 TObject* p_mmBox = mmBox.get();
659 canvas.add(std::move(mmBox));
660
661 addHitLegendByFill(p_mmBox,
663 "MMG inBucket",
665 "MMG onObject");
666 addLabeledOutline(boxWidth, boxHeight);
667 break;
669 break;
671 const double boxWidth = covarianceWidth();
672 const double boxHeight = 10.*Gaudi::Units::mm;
673 auto stgcBox = drawBox(hit.localPosition(), boxWidth, boxHeight, kTeal, fillStyle, view);
674
675
676 //In case of pad use a transparent filling to see the underlying strip or wire
677 //TODO: do more splitting into strip+wire, strip+pad, wire+pad, strip+wire+pad and add legend accordingly?
679 const auto* primary = static_cast<const xAOD::sTgcMeasurement*>( primaryMeas );
680 if (primary && primary->channelType() == xAOD::sTgcMeasurement::sTgcChannelTypes::Pad) {
681 stgcBox->SetFillColorAlpha(kTeal, 0.1);
682 legendType = LegendItem::StgcPadHit;
683 }
684 TObject* p_stgcBox = stgcBox.get();
685
686 canvas.add(std::move(stgcBox));
687 if (legendType == LegendItem::StgcPadHit) {
688 addHitLegendByFill(p_stgcBox,
690 "sTGCp inBucket",
692 "sTGCp onObject");
693 } else {
694 addHitLegendByFill(p_stgcBox,
696 "sTGCs+w inBucket",
698 "sTGCs+w onObject");
699 }
700 addLabeledOutline(boxWidth, boxHeight);
701 break;
702 } default: {
703 ATH_MSG_WARNING("Please implement proper drawings of the new small wheel.. "<<__FILE__<<":"<<__LINE__);
704 break;
705 }
706 }
707 return underlyingSp;
708 }
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
bool hit(const Container &ids, int pdgId)
virtual bool isLabeled(const MuonR4::SpacePoint &hit) const override final
Fetches all labeled (e.g.
constexpr int objViewEta
ObjectView.
constexpr int hollowFilling
Filling codes for hollow / fullFilling / hatched filling.
constexpr int hatchedFilling
std::unique_ptr< TEllipse > drawDriftCircle(const Amg::Vector3D &center, const double radius, const int color=kViolet, const int fillStyle=hollowFilling)
Create a TEllipse for drawing a drift circle.
constexpr int fullFilling
constexpr int objViewPhi
std::unique_ptr< TBox > drawBox(const Amg::Vector3D &boxCenter, const double boxWidth, const double boxHeight, const int color=kGreen+2, const int fillStyle=hollowFilling, const int view=objViewEta)
Creates a box for drawing, e.g strip measurements.
@ driftCircle
MdtDriftCircle_v1 MdtDriftCircle
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9
RpcMeasurement_v1 RpcMeasurement
sTgcMeasurement_v1 sTgcMeasurement

◆ drawHit() [2/2]

template<class SpacePointType>
const MuonR4::SpacePoint * MuonValR4::PatternVisualizationTool::drawHit ( const SpacePointType & hit,
Canvas_t & canvas,
DynamicLegend & legend,
const unsigned int view,
unsigned int fillStyle ) const
private

Converts a Hit into a particular TBox/ TEllipse for drawing.

If the hit provides information that's requested for that view. The underlying space pointer is returned and the dimensions of the canvas are updated, if the drawing was succesful

Parameters
hitReference to the hit to draw
canvasReference to the Canvas object to which the drawn hits are appended. The drawn hits also expand the drawn range
viewDraw the hit either in the eta or phi view,
fillStyleStandard fill style for the box e.g. full.

◆ drawHits()

template<class SpacePointType>
bool MuonValR4::PatternVisualizationTool::drawHits ( const MuonR4::SpacePointBucket & bucket,
const std::vector< SpacePointType > & hitsToDraw,
Canvas_t & canvasDim,
DynamicLegend & legend,
unsigned int view ) const
private

Translates the Spacepoint information into TObjects that are dawn on the canvas & evaluates the size of the box surrounding the event.

Returns true if at least 2 objects were created.

Parameters
bucketSpacePoint bucket from which the hits are taken. If the <DisplayBucket> is set true, the hits that were not in the subset are also painted with hollow filling
hitsToDrawPrimary hit collection to draw which are drawn with fullFillStyle
canvasReference to the Canvas object to which the drawn hits are appended. The drawn hits also expand the drawn range
viewEither the eta or the phi view?

Definition at line 711 of file PatternVisualizationTool.cxx.

714 {
715
716 SpacePointSet drawnPoints{};
717
718 for (const SpacePointType& hit : hitsToDraw) {
719 drawnPoints.insert(drawHit(*hit, canvas, legend, view, fullFilling));
720 }
721 if (m_displayBucket) {
722 for (const SpacePointBucket::value_type& hit : bucket) {
723 // Don't redraw the other points
724 if (drawnPoints.count(hit.get())) {
725 continue;
726 }
727
728 drawHit(*hit, canvas, legend, view, hollowFilling);
729 }
730 }
731 return drawnPoints.size() - drawnPoints.count(nullptr) > 0;
732 }
Gaudi::Property< bool > m_displayBucket
Display the surrounding hits from the bucket not part of the seed.
const MuonR4::SpacePoint * drawHit(const SpacePointType &hit, Canvas_t &canvas, DynamicLegend &legend, const unsigned int view, unsigned int fillStyle) const
Converts a Hit into a particular TBox/ TEllipse for drawing.
std::vector< const SpacePoint * > SpacePointSet
vector of space points
Definition FitterTypes.h:38

◆ getLabeledSegments() [1/2]

LabeledSegmentSet MuonValR4::PatternVisualizationTool::getLabeledSegments ( const std::vector< const MuonR4::SpacePoint * > & hits) const
finaloverridevirtual

Returns whether the hit has been used on the labeled segments we refer to (e.g.

truth or data Zµµ)

Parameters
hitsVector of hits to search

Definition at line 100 of file PatternVisualizationTool.cxx.

100 {
101 std::vector<const xAOD::UncalibratedMeasurement*> measurements{};
102 measurements.reserve(2* hits.size());
103 for (const SpacePoint* hit: hits) {
104 measurements.push_back(hit->primaryMeasurement());
105 if(hit->secondaryMeasurement()) {
106 measurements.push_back(hit->secondaryMeasurement());
107 }
108 }
109 return getLabeledSegments(measurements);
110 }
virtual LabeledSegmentSet getLabeledSegments(const std::vector< const MuonR4::SpacePoint * > &hits) const override final
Returns whether the hit has been used on the labeled segments we refer to (e.g.

◆ getLabeledSegments() [2/2]

LabeledSegmentSet MuonValR4::PatternVisualizationTool::getLabeledSegments ( const std::vector< const xAOD::UncalibratedMeasurement * > & hits) const
finaloverridevirtual

Definition at line 111 of file PatternVisualizationTool.cxx.

111 {
112 LabeledSegmentSet truthSegs{};
113 for (const xAOD::UncalibratedMeasurement* hit : hits) {
114 for (const SegLinkDecor_t& decor: m_truthLinkDecors) {
115 for (const SegLink_t& link : decor(*hit)) {
116 truthSegs.insert(*link);
117 }
118 }
119 }
120 return truthSegs;
121 }
SG::ConstAccessor< SegLinkVec_t > SegLinkDecor_t
std::unordered_set< const xAOD::MuonSegment * > LabeledSegmentSet
std::vector< SegLinkDecor_t > m_truthLinkDecors
ElementLink< xAOD::MuonSegmentContainer > SegLink_t
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.

◆ initialize()

StatusCode MuonValR4::PatternVisualizationTool::initialize ( )
finaloverridevirtual

Definition at line 55 of file PatternVisualizationTool.cxx.

55 {
56 if (m_canvasLimit > 0) {
57 m_clientToken.canvasLimit = m_canvasLimit;
58 m_clientToken.preFixName = m_canvasPrefix;
59 m_clientToken.saveSinglePlots = m_saveSinglePDFs;
60 m_clientToken.saveSummaryPlot = m_saveSummaryPDF;
61 m_clientToken.subDirectory = m_subDir;
62 ATH_CHECK(m_visualSvc.retrieve());
63 ATH_CHECK(m_visualSvc->registerClient(m_clientToken));
64 } else {
65 m_plotsDone = true;
66 }
67 ATH_CHECK(m_prepContainerKeys.initialize(!m_truthSegLinks.empty()));
69 ATH_MSG_INFO("Hits linked to the following segment decorations are considered as truth");
70 for (const std::string& decorName : m_truthSegLinks) {
71 ATH_MSG_INFO(" **** "<<decorName);
72 if (decorName.empty()) {
73 ATH_MSG_FATAL("Decoration must not be empty");
74 return StatusCode::FAILURE;
75 }
76 for (const SG::ReadHandleKey<xAOD::UncalibratedMeasurementContainer>& key : m_prepContainerKeys) {
77 m_truthLinkDecorKeys.emplace_back(key, decorName);
78 m_truthLinkDecors.push_back(SegLinkDecor_t{decorName});
79 }
80 }
81 ATH_CHECK(m_truthLinkDecorKeys.initialize());
82 m_displayOnlyTruth.value() &= !m_truthLinkDecorKeys.empty();
83
84 ATH_CHECK(m_idHelperSvc.retrieve());
85 ATH_CHECK(m_geoCtxKey.initialize());
86 ATH_CHECK(detStore()->retrieve(m_detMgr));
87 return StatusCode::SUCCESS;
88 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Gaudi::Property< std::string > m_subDir
Define the subdirectory in which the plots shall be saved.
ActsTrk::GeoContextReadKey_t m_geoCtxKey
Geometry context key to retrieve the alignment.
Gaudi::Property< unsigned int > m_canvasLimit
Maximum canvases to draw.
Gaudi::Property< std::string > m_canvasPrefix
Prefix of the individual canvas file names <MANDATORY>.
Gaudi::Property< bool > m_saveSinglePDFs
If set to true each canvas is saved into a dedicated pdf file.
IRootVisualizationService::ClientToken m_clientToken
Token to present to the visualization service such that the display froms this tool are grouped toget...
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_truthLinkDecorKeys
Declaration of the dependency on the decorations.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service Handle to the IMuonIdHelperSvc.
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prepContainerKeys
Declare dependency on the prep data containers.
Gaudi::Property< std::set< std::string > > m_truthSegLinks
List of truth segment links to fetch.
ServiceHandle< IRootVisualizationService > m_visualSvc
Service handle of the visualization service.
Gaudi::Property< bool > m_saveSummaryPDF
If set to true a summary Canvas is created.
const MuonGMR4::MuonDetectorManager * m_detMgr
pointer to the Detector manager
std::atomic< bool > m_plotsDone
Flag toggling whether all Canvases have been exhausted.

◆ isLabeled() [1/2]

bool MuonValR4::PatternVisualizationTool::isLabeled ( const MuonR4::SpacePoint & hit) const
finaloverridevirtual

Fetches all labeled (e.g.

by truth or Zµµ reco) segments containing at least one measurement in the list passed as arg

Parameters
hitReference to the hit to check

Definition at line 89 of file PatternVisualizationTool.cxx.

89 {
90 return isLabeled(*hit.primaryMeasurement()) ||
91 (hit.secondaryMeasurement() && isLabeled(*hit.secondaryMeasurement()));
92 }

◆ isLabeled() [2/2]

bool MuonValR4::PatternVisualizationTool::isLabeled ( const xAOD::UncalibratedMeasurement & hit) const
finaloverridevirtual

Definition at line 93 of file PatternVisualizationTool.cxx.

93 {
94 return std::find_if(m_truthLinkDecors.begin(), m_truthLinkDecors.end(),
95 [&hit](const SegLinkDecor_t& decor){
96 return !decor(hit).empty();
97 }) != m_truthLinkDecors.end();
98 }

◆ paintSimHits()

void MuonValR4::PatternVisualizationTool::paintSimHits ( const EventContext & ctx,
const xAOD::MuonSegment & truthSeg,
Canvas_t & canvas,
const int view ) const
private

Paints the truth sim hits associated with the segment.

Hits are drawn as orange arrows

Parameters
ctxEventContext to fetch the alignment constants
truthSegSegment made from truth sim hits
canvasReference to the Canvas object to which the drawn hits are appended
viewDraw the hit either in the eta or phi view

Definition at line 240 of file PatternVisualizationTool.cxx.

243 {
244 if (!m_paintTruthHits) {
245 return;
246 }
247 auto truthHits = getMatchingSimHits(truthSeg);
248 const ActsTrk::GeometryContext* geoCtx{nullptr};
249 if (!SG::get(geoCtx, m_geoCtxKey, ctx).isSuccess()) {
250 return;
251 }
252 for (const xAOD::MuonSimHit* simHit : truthHits) {
253 const MuonGMR4::MuonReadoutElement* re = m_detMgr->getReadoutElement(simHit->identify());
254 const IdentifierHash hash = re->detectorType() == ActsTrk::DetectorType::Mdt ?
255 re->measurementHash(simHit->identify()) :
256 re->layerHash(simHit->identify());
257 const Acts::Transform3 trf = re->msSector()->globalToLocalTransform(*geoCtx) *
258 re->localToGlobalTransform(*geoCtx, hash);
259 const Amg::Vector3D locPos = trf * xAOD::toEigen(simHit->localPosition());
260 const Amg::Vector3D locDir = trf.linear() * xAOD::toEigen(simHit->localDirection());
261 canvas.add(drawArrow(locPos, locDir, truthColor, kDashed, view));
262 }
263 }
const std::regex re(r_e)
Gaudi::Property< bool > m_paintTruthHits
Switch to visualize the truth hits.
@ Mdt
MuonSpectrometer.
Eigen::Matrix< double, 3, 1 > Vector3D
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
std::unique_ptr< TArrow > drawArrow(const Amg::Vector3D &start, const Amg::Vector3D &dir, const int color=kRed+1, const int lineStyle=kDashed, const int view=objViewEta)
Draw an arror between two endpoints in the y-z or the x-z plane.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12

◆ visualizeAccumulator() [1/2]

void MuonValR4::PatternVisualizationTool::visualizeAccumulator ( const EventContext & ctx,
const MuonR4::HoughPlane & accumulator,
const Acts::HoughTransformUtils::HoughAxisRanges & axisRanges,
const MaximumVec & maxima,
const std::string & extraLabel ) const
finaloverridevirtual

Definition at line 122 of file PatternVisualizationTool.cxx.

126 {
127 PrimitiveVec primitives{};
128 visualizeAccumulator(ctx, accumulator, axisRanges, maxima, extraLabel, std::move(primitives));
129 }
virtual void visualizeAccumulator(const EventContext &ctx, const MuonR4::HoughPlane &accumulator, const Acts::HoughTransformUtils::HoughAxisRanges &axisRanges, const MaximumVec &maxima, const std::string &extraLabel) const override final
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec

◆ visualizeAccumulator() [2/2]

void MuonValR4::PatternVisualizationTool::visualizeAccumulator ( const EventContext & ctx,
const MuonR4::HoughPlane & accumulator,
const Acts::HoughTransformUtils::HoughAxisRanges & axisRanges,
const MaximumVec & maxima,
const std::string & extraLabel,
PrimitiveVec && extraPaints ) const
finaloverridevirtual

Check whether the canvas limit has been reached

Definition at line 130 of file PatternVisualizationTool.cxx.

135 {
136
138 if (m_plotsDone) {
139 return;
140 }
141
142 ATH_MSG_VERBOSE("Visualize accumulator");
143
144 if (accumulator.getNonEmptyBins().empty()) {
145 ATH_MSG_WARNING("Hough accumulator is empty");
146 return;
147 }
148
149 auto accHisto = std::make_unique<TH2F>("AccumulatorHisto", "histo",
150 accumulator.nBinsX(), axisRanges.xMin, axisRanges.xMax,
151 accumulator.nBinsY(), axisRanges.yMin, axisRanges.yMax);
152 accHisto->SetDirectory(nullptr);
153
154 std::vector<const SpacePoint*> spacePointsInAcc{};
155 for (const std::size_t bin : accumulator.getNonEmptyBins()) {
156 const auto [xBin, yBin] = accumulator.axisBins(bin);
157 auto hitIds = accumulator.hitIds(xBin, yBin);
158 spacePointsInAcc.insert(spacePointsInAcc.end(),hitIds.begin(), hitIds.end());
159 accHisto->SetBinContent(xBin+1, yBin+1, accumulator.nHits(bin));
160 }
161
162 const LabeledSegmentSet truthSegs{getLabeledSegments(spacePointsInAcc)};
163 if (truthSegs.empty() && m_displayOnlyTruth) {
164 ATH_MSG_VERBOSE("visualizeAccumulator skipped: no truth segments found and displayOnlyTruth=true");
165 return;
166 }
167
168 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, extraLabel);
169 if (!canvas){
170 m_plotsDone = true;
171 return;
172 }
173
174
175 const double maxBins = std::max(accumulator.nBinsX(), accumulator.nBinsY());
176 double markerTextSize = 0.035;
177 // Scale down for large accumulators
178 markerTextSize *= 25. / std::max(25., maxBins);
179 // Avoid absurdly tiny/large text
180 markerTextSize = std::clamp(markerTextSize, 0.006, 0.035);
181 accHisto->SetMarkerSize(markerTextSize);
182 accHisto->SetMarkerColor(kBlack);
183 accHisto->SetMinimum(0.);
184
185 canvas->expandPad(axisRanges.xMin, axisRanges.yMin);
186 canvas->expandPad(axisRanges.xMax, axisRanges.yMax);
187 canvas->setAxisTitles(std::format("tan#{}", m_accumlIsEta ? "beta" : "#alpha"),
188 std::format("{:}_{{0}} [mm]", m_accumlIsEta ? "y" : "x"));
189 canvas->add(std::move(accHisto), "HIST SAME");
190
191 // Draw explicit bin labels at bin centers. This is more robust than TH2 TEXT
192 // when plotting into the visualization service's prebuilt frame.
193 const double binLabelPx = std::clamp(1.2 * 500. / maxBins, 7.0, 18.0);
194 for (const std::size_t bin : accumulator.getNonEmptyBins()) {
195 const auto [xBin, yBin] = accumulator.axisBins(bin);
196 const double xCenter = axisRanges.xMin + (xBin + 0.5) * (axisRanges.xMax - axisRanges.xMin) / accumulator.nBinsX();
197 const double yCenter = axisRanges.yMin + (yBin + 0.5) * (axisRanges.yMax - axisRanges.yMin) / accumulator.nBinsY();
198
199 //Extract number of entries in the bin with no decimal precision just int
200 std::string binLabel = std::format("{:0}", int(accumulator.nHits(bin)));
201
202 auto binTxt = drawLabel(binLabel, xCenter, yCenter, binLabelPx, false, kBlack);
203 binTxt->SetTextAlign(22);
204 canvas->add(std::move(binTxt));
205 }
206
207 int iseg = 0;
208 for (const xAOD::MuonSegment* segment : truthSegs) {
209 const auto [pos, dir] = makeLine(localSegmentPars(*segment));
210 const double tan = m_accumlIsEta ? houghTanBeta(dir) : houghTanAlpha(dir);
211 const double icept = pos[m_accumlIsEta ? objViewEta : objViewPhi];
212 auto truthMarker = std::make_unique<TMarker>(tan, icept, kFullCrossX);
213 truthMarker->SetMarkerColor(truthColor);
214 truthMarker->SetMarkerSize(4);
215 canvas->add(std::move(truthMarker));
216 canvas->add(drawLabel(std::format("true parameters: {:}",
217 makeLabel(localSegmentPars(*segment))),0.2, 0.9 - 0.05*iseg));
218 iseg += 1;
219 }
220 for (const auto& maximum : maxima) {
221 auto maxMarker = std::make_unique<TMarker>(maximum.x, maximum.y, kFullTriangleUp);
222 maxMarker->SetMarkerColor(parLineColor);
223 maxMarker->SetMarkerSize(4);
224 canvas->add(std::move(maxMarker));
225
226 // Draw a bounding box around the maximum island center (x,y) and widths (wx,wy).
227 const double xMin = maximum.x - maximum.wx;
228 const double xMax = maximum.x + maximum.wx;
229 const double yMin = maximum.y - maximum.wy;
230 const double yMax = maximum.y + maximum.wy;
231
232 auto maxBox = drawBox(xMin, yMin, xMax, yMax, parLineColor, hollowFilling);
233 maxBox->SetLineStyle(kDashed);
234 maxBox->SetLineWidth(2);
235 canvas->add(std::move(maxBox));
236 }
237
238 canvas->add(std::move(primitives));
239 }
Gaudi::Property< bool > m_accumlIsEta
Swtich toggling whether the accumulator view are in the eta or phi plane.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
std::string makeLabel(const Parameters &pars)
Dumps the parameters into a string in the form of TLatex.
double houghTanBeta(const Amg::Vector3D &v)
Returns the hough tanBeta [y] / [z].
double houghTanAlpha(const Amg::Vector3D &v)
: Returns the hough tanAlpha [x] / [z]
std::unique_ptr< TLatex > drawLabel(const std::string &text, const double xPos, const double yPos, const double textSize=18, const bool useNDC=true, const int color=kBlack)
Create a TLatex label,.
MuonSegment_v1 MuonSegment
Reference the current persistent version:

◆ visualizeBucket() [1/2]

void MuonValR4::PatternVisualizationTool::visualizeBucket ( const EventContext & ctx,
const MuonR4::SpacePointBucket & bucket,
const std::string & extraLabel ) const
finaloverridevirtual

Definition at line 330 of file PatternVisualizationTool.cxx.

332 {
333 PrimitiveVec primitives{};
334 visualizeBucket(ctx, bucket, extraLabel, std::move(primitives));
335 }
virtual void visualizeBucket(const EventContext &ctx, const MuonR4::SpacePointBucket &bucket, const std::string &extraLabel) const override final

◆ visualizeBucket() [2/2]

void MuonValR4::PatternVisualizationTool::visualizeBucket ( const EventContext & ctx,
const MuonR4::SpacePointBucket & bucket,
const std::string & extraLabel,
PrimitiveVec && extraPaints ) const
finaloverridevirtual

Check whether the canvas limit has been reached

reset the primitives

Definition at line 336 of file PatternVisualizationTool.cxx.

339 {
341 if (m_plotsDone) {
342 return;
343 }
344 ATH_MSG_VERBOSE("visualizeBucket called for " << extraLabel);
345
346 LabeledSegmentSet truthSegs{getLabeledSegments(Acts::unpackConstSmartPointers(bucket))};
347 if (truthSegs.empty() && m_displayOnlyTruth) {
348 ATH_MSG_VERBOSE("visualizeBucket skipped: no truth segments found and displayOnlyTruth=true");
349 return;
350 }
351
352 for (const int view : {objViewEta, objViewPhi}) {
353 if ((view == objViewEta && !m_doEtaBucketViews) ||
354 (view == objViewPhi && !m_doPhiBucketViews)){
355 continue;
356 }
357
358 const std::string_view viewName = view == objViewEta ? "eta" : "phi";
359
360 auto canvas = m_visualSvc->prepareCanvas( ctx, m_clientToken, std::format("{}_{}view", extraLabel, viewName));
361
362
363 if (!canvas) {
364 m_plotsDone = true;
365 return;
366 }
367
368 DynamicLegend legend(0.8, 0.2, 0.95, 0.5);
369
370 canvas->add(clone(primitives));
371
373 if (!drawHits(bucket, bucket, *canvas, legend, view)) {
374 canvas->trash();
375 continue;
376 }
377 bool drawnTrueLabel{false};
378 for (const xAOD::MuonSegment* segment : truthSegs) {
379
380 auto truthLine = drawLine(localSegmentPars(*segment), canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh), truthColor, kDotted, view);
381 TLine* line = static_cast<TLine*>(truthLine.get());
382 canvas->add( std::move(truthLine) );
383 legend.addOnce( LegendItem::TruthSegmentLine, line, "Truth Segment", "l" );
384
385 if (!drawnTrueLabel) {
386 canvas->add(drawLabel(std::format("true parameters: {:}",makeLabel(localSegmentPars(*segment))),0.2, 0.89));
387 drawnTrueLabel = true;
388 }
389 paintSimHits(ctx,*segment, *canvas, view);
390 }
391
392 std::string legendLabel = std::format("Event: {:}, chamber : {:}, #{:}-view ({:})",
393 ctx.eventID().event_number(),
394 bucket.msSector()->identString(),
395 view ==objViewEta ? "eta" : "phi",
396 extraLabel);
397 canvas->add(drawLabel(legendLabel, 0.15, 0.96));
398
399 canvas->setAxisTitles(std::format("{:} [mm]", view == objViewEta ? 'y' : 'x'), "z [mm]");
400
401 if (!legend.empty()) {
402 canvas->add(legend.release(), "same");
403 }
404
405 }
406 }
std::string identString() const
Returns a string encoding the chamber index & the sector of the MS sector.
const MuonGMR4::SpectrometerSector * msSector() const
returns th associated muonChamber
Gaudi::Property< bool > m_doEtaBucketViews
Switch to visualize the eta view of the bucket event.
bool drawHits(const MuonR4::SpacePointBucket &bucket, const std::vector< SpacePointType > &hitsToDraw, Canvas_t &canvasDim, DynamicLegend &legend, unsigned int view) const
Translates the Spacepoint information into TObjects that are dawn on the canvas & evaluates the size ...
Gaudi::Property< bool > m_doPhiBucketViews
Switch to visualize the phi view of the bucket event.
void paintSimHits(const EventContext &ctx, const xAOD::MuonSegment &truthSeg, Canvas_t &canvas, const int view) const
Paints the truth sim hits associated with the segment.
std::unique_ptr< TLine > drawLine(const MuonR4::SegmentFit::Parameters &pars, const double lowEnd, const double highEnd, const int color=kRed+1, const int lineStyle=kDashed, const int view=objViewEta)
Draws a line from the segment fit parameters.
std::vector< std::unique_ptr< TObject > > clone(const std::vector< std::unique_ptr< TObject > > &cloneMe)

◆ visualizeSeed() [1/2]

void MuonValR4::PatternVisualizationTool::visualizeSeed ( const EventContext & ctx,
const MuonR4::SegmentSeed & seed,
const std::string & extraLabel ) const
finaloverridevirtual

Definition at line 264 of file PatternVisualizationTool.cxx.

266 {
267 PrimitiveVec primitives{};
268 visualizeSeed(ctx, seed, extraLabel, std::move(primitives));
269 }
virtual void visualizeSeed(const EventContext &ctx, const MuonR4::SegmentSeed &seed, const std::string &extraLabel) const override final

◆ visualizeSeed() [2/2]

void MuonValR4::PatternVisualizationTool::visualizeSeed ( const EventContext & ctx,
const MuonR4::SegmentSeed & seed,
const std::string & extraLabel,
PrimitiveVec && extraPaints ) const
finaloverridevirtual

Check whether the canvas limit has been reached

Definition at line 270 of file PatternVisualizationTool.cxx.

273 {
274
275 ATH_MSG_VERBOSE("Visualizing seed with " << seed.getHitsInMax().size() << " hits");
277 if (m_plotsDone) {
278 ATH_MSG_VERBOSE("visualizeSeed skipped: canvas quota already exhausted for " << extraLabel);
279 return;
280 }
281 const LabeledSegmentSet truthSegs{getLabeledSegments(seed.getHitsInMax())};
282 if (truthSegs.empty() && m_displayOnlyTruth) {
283 ATH_MSG_VERBOSE("visualizeSeed skipped: no truth segments found and displayOnlyTruth=true");
284 return;
285 }
286 for (const int view : {objViewEta, objViewPhi}) {
287 if ((view == objViewEta && !m_doEtaBucketViews) ||
288 (view == objViewPhi && !m_doPhiBucketViews)){
289 continue;
290 }
291
292 std::string_view viewName = view == objViewEta ? "eta" : "phi";
293
294 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, std::format("{}_{}", extraLabel, viewName));
295
296 if (!canvas) {
297 m_plotsDone = true;
298 return;
299 }
300
301 DynamicLegend legend;
302 canvas->add(clone(primitives));
303
304 canvas->setAxisTitles(std::format("{:} [mm]", view == objViewEta ? 'y' : 'x'), "z [mm]");
305
306 if (!drawHits(*seed.parentBucket(), seed.getHitsInMax(), *canvas, legend, view)) {
307 continue;
308 }
309 for (const xAOD::MuonSegment* segment : truthSegs) {
310 canvas->add(drawLine(localSegmentPars(*segment),
311 canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh),
312 truthColor, kDotted, view));
313 paintSimHits(ctx,*segment, *canvas, view);
314 }
315 canvas->add(drawLine(seed.parameters(), canvas->corner(Edges::yLow),
316 canvas->corner(Edges::yHigh), parLineColor, kDashed, view));
317
318 writeChi2(seed.parameters(), seed.getHitsInMax(), *canvas);
319
320 std::string legendLabel = std::format("Event: {:}, chamber : {:}, #{:}-view ({:})",
321 ctx.eventID().event_number(),
322 m_idHelperSvc->toStringChamber(seed.getHitsInMax().front()->identify()),
323 view ==objViewEta ? "eta" : "phi",
324 extraLabel);
325 canvas->add(drawLabel(legendLabel, 0.1, 0.96));
326 canvas->add(drawLabel( "Seed parameters: " + makeLabel(seed.parameters()),0.25, 0.89));
327 }
328 }
void writeChi2(const MuonR4::SegmentFit::Parameters &pars, const std::vector< SpacePointType > &hits, Canvas_t &canvas, const double legX=0.2, double startLegY=0.8, const double endLegY=0.3) const
Writes the chi2 of the hits onto the Canvas.

◆ visualizeSegment() [1/2]

void MuonValR4::PatternVisualizationTool::visualizeSegment ( const EventContext & ctx,
const MuonR4::Segment & segment,
const std::string & extraLabel ) const
finaloverridevirtual

Definition at line 408 of file PatternVisualizationTool.cxx.

410 {
411 PrimitiveVec primitives{};
412 visualizeSegment(ctx, segment,extraLabel, std::move(primitives));
413 }
virtual void visualizeSegment(const EventContext &ctx, const MuonR4::Segment &segment, const std::string &extraLabel) const override final

◆ visualizeSegment() [2/2]

void MuonValR4::PatternVisualizationTool::visualizeSegment ( const EventContext & ctx,
const MuonR4::Segment & segment,
const std::string & extraLabel,
PrimitiveVec && extraPaints ) const
finaloverridevirtual

Check whether the canvas limit has been reached

Definition at line 415 of file PatternVisualizationTool.cxx.

418 {
420 if (m_plotsDone) {
421 return;
422 }
423
424 ATH_MSG_VERBOSE("Visualizing segment with " << segment.measurements().size() << " hits");
425
426 const LabeledSegmentSet truthSegs{getLabeledSegments(segment.parent()->getHitsInMax())};
427 if (truthSegs.empty() && m_displayOnlyTruth) {
428 return;
429 }
430 const ActsTrk::GeometryContext* geoCtx{nullptr};
431 if (!SG::get(geoCtx, m_geoCtxKey, ctx).isSuccess()) {
432 return;
433 }
434
435
436 const Parameters segPars = SegmentFit::localSegmentPars(*geoCtx, segment);
437
438 for (const int view : {objViewEta, objViewPhi}) {
439 if ((view == objViewEta && !m_doEtaBucketViews) ||
440 (view == objViewPhi && !m_doPhiBucketViews)){
441 continue;
442 }
443
444 const std::string_view viewName = view == objViewEta ? "eta" : "phi";
445
446 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, std::format("{}_{}view", extraLabel, viewName));
447 if (!canvas) {
448 m_plotsDone = true;
449 return;
450 }
451 canvas->setAxisTitles(std::format("{:} [mm]", view == objViewEta ? 'y' : 'x'), "z [mm]");
452 canvas->add(clone(primitives));
453
454 DynamicLegend legend(0.8, 0.2, 0.95, 0.5);
455
456
457 ATH_MSG_DEBUG("Drawing hits!");
458 if (!drawHits(*segment.parent()->parentBucket(), segment.measurements(),
459 *canvas, legend, view)) {
460 canvas->trash();
461 continue;
462 }
463
464 ATH_MSG_DEBUG("Drawing chi2!");
465 writeChi2(segPars, segment.measurements(), *canvas);
466
467
468 {
469 auto segmentline = drawLine(segPars, canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh), parLineColor, kDashed, view);
470 legend.addOnce(LegendItem::RecoSegmentLine, segmentline.get(), "Reco Segment", "l");
471 canvas->add(std::move(segmentline));
472
473 }
474 bool drawnTrueLabel{false};
475 for (const xAOD::MuonSegment* segment : truthSegs) {
476 auto truthLine = drawLine(localSegmentPars(*segment), canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh), truthColor, kDotted, view);
477 legend.addOnce( LegendItem::TruthSegmentLine, truthLine.get(), "Truth Segment", "l" );
478 canvas->add( std::move(truthLine) );
479 using namespace Acts::detail::LineHelper;
480 const Acts::Vector3 bsExtp = lineIntersect<3>(Amg::Vector3D::Zero(), Amg::Vector3D::UnitZ(),
481 segment->position(), segment->direction()).position();
482 if (!drawnTrueLabel) {
483 canvas->add(drawLabel(std::format("true parameters: {:}, d_{{0}}={:.2f}, z_{{0}}={:.2f}",
484 makeLabel(localSegmentPars(*segment)), bsExtp.perp(),
485 std::abs(bsExtp.z()) ) , 0.1, 0.05));
486 drawnTrueLabel = true;
487 }
488 paintSimHits(ctx,*segment, *canvas, view);
489 }
490
491 const Identifier canvasId{segment.parent()->getHitsInMax().front()->identify()};
492 std::string legendLabel=std::format("Event: {:}, chamber: {:}, #chi^{{2}} / nDoF: {:.2f} ({:d}), #{:}-view (:)",
493 ctx.eventID().event_number(), m_idHelperSvc->toStringChamber(canvasId),
494 segment.chi2() /std::max(1u, segment.nDoF()), segment.nDoF(),
495 view ==objViewEta ? "eta" : "phi", extraLabel);
496
497 canvas->add(drawLabel(legendLabel, 0.2, 0.96));
498 canvas->add(drawLabel(makeLabel(segPars),0.25, 0.91));
499
500 if (!legend.empty()) {
501 canvas->add(legend.release(), "same");
502 }
503 }
504 }
#define ATH_MSG_DEBUG(x,...)
const std::vector< HitType > & getHitsInMax() const
Returns the list of assigned hits.
const SpacePointBucket * parentBucket() const
Returns the bucket out of which the seed was formed.
unsigned int nDoF() const
Returns the number of degrees of freedom.
const SegmentSeed * parent() const
Returns the seed out of which the segment was built.
const MeasVec & measurements() const
Returns the associated measurements.
const Amg::Vector3D & position() const
Returns the global segment position.
const Amg::Vector3D & direction() const
Returns the global segment direction.
Acts::Experimental::CompositeSpacePointLineFitter::ParamVec_t Parameters

◆ writeChi2()

template<class SpacePointType>
void MuonValR4::PatternVisualizationTool::writeChi2 ( const MuonR4::SegmentFit::Parameters & pars,
const std::vector< SpacePointType > & hits,
Canvas_t & canvas,
const double legX = 0.2,
double startLegY = 0.8,
const double endLegY = 0.3 ) const
private

Writes the chi2 of the hits onto the Canvas.

Parameters
parsParameter for which the chi2 is evaluated,
hitsVector of hits to consider
canvasReference to the Canvas object to which the drawn hits are appended
legXx-position of the list
statLegYy-position of the first entry. The next one is 0.05 apart
endLegy-position of the last shown entry. The routine aborts if there're more hits in the event.

Definition at line 734 of file PatternVisualizationTool.cxx.

738 {
739 const auto [pos, dir] = makeLine(pars);
740
741 unsigned int nHits = 0;
742 for (const SpacePointType& hit : hits) {
743 const SpacePoint* underlyingSp{nullptr};
744 bool displayChi2{true};
745 if constexpr(std::is_same_v<SpacePointType, Segment::MeasType>) {
746 underlyingSp = hit->spacePoint();
747 displayChi2 = (hit->fitState() == CalibratedSpacePoint::State::Valid);
748 } else {
749 underlyingSp = hit;
750 }
751
752 ATH_MSG_VERBOSE("Writing chi2 for hit " << nHits << " of type " << hit->type());
753
754 const Identifier hitId = underlyingSp ? underlyingSp->identify(): Identifier{};
755 std::string legendstream{};
756 switch(hit->type()) {
758 const int driftSign{SeedingAux::strawSign(pos, dir, *hit)};
759 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
760 legendstream = std::format("ML: {:1d}, TL: {:1d}, T: {:3d}, {:}",
761 idHelper.multilayer(hitId), idHelper.tubeLayer(hitId),
762 idHelper.tube(hitId), driftSign == -1 ? "L" : "R");
763 break;
765 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
766 legendstream= std::format("DR: {:1d}, DZ: {:1d}, GAP: {:1d}, #eta/#phi: {:}/{:}",
767 idHelper.doubletR(hitId), idHelper.doubletZ(hitId), idHelper.gasGap(hitId),
768 hit->measuresEta() ? "si" : "nay", hit->measuresPhi() ? "si" : "nay");
769 break;
771 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
772 legendstream = std::format("ST: {:}, GAP: {:1d}, #eta/#phi: {:}/{:}",
773 m_idHelperSvc->stationNameString(hitId), idHelper.gasGap(hitId),
774 hit->measuresEta() ? "si" : "nay", hit->measuresPhi() ? "si" : "nay");
775 break;
777 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
778 const auto* clus = static_cast<const xAOD::MMCluster*>(underlyingSp->primaryMeasurement());
779 const MuonGMR4::StripDesign& design = clus->readoutElement()->stripLayer(clus->layerHash()).design();
780 legendstream = std::format("ML: {:1d}, GAP: {:1d}, {:}", idHelper.multilayer(hitId), idHelper.gasGap(hitId),
781 !design.hasStereoAngle() ? "X" : design.stereoAngle() > 0 ? "U" :"V");
782 break;
784 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
785 legendstream = std::format("ML: {:1d}, GAP: {:1d}, #eta/#phi: {:}/{:}",
786 idHelper.multilayer(hitId), idHelper.gasGap(hitId),
787 hit->measuresEta() ? "si" : "nay", hit->measuresPhi() ? "si" : "nay");
788 break;
790 legendstream = "Ext. constaint";
791 }
792 default:
793 break;
794 }
795 if (displayChi2) {
796 //Make thi chi2 view specific?
797 const double chi2 = SeedingAux::chi2Term(pos, dir,*hit);
798 legendstream+=std::format(", #chi^{{2}}: {:.2f}", chi2);
799 } else {
800 legendstream+=", NotValidState";
801 }
802
803
804 ++nHits;
805
806 canvas.add(drawLabel(legendstream, legX, startLegY, 8));
807 startLegY -= 0.02;
808 if (startLegY<= endLegY) {
809 break;
810 }
811 }
812 }
static const uint32_t nHits
int multilayer(const Identifier &id) const
Access to components of the ID.
int tube(const Identifier &id) const
int tubeLayer(const Identifier &id) const
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
const StripLayer & stripLayer(const Identifier &measId) const
double stereoAngle() const
Returns the value of the stereo angle.
bool hasStereoAngle() const
Returns whether a stereo angle is defined.
const StripDesign & design(bool phiView=false) const
Returns the underlying strip design.
int gasGap(const Identifier &id) const override
get the hashes
int doubletR(const Identifier &id) const
int doubletZ(const Identifier &id) const
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
int gasGap(const Identifier &id) const override
get the hashes
const MuonGMR4::MmReadoutElement * readoutElement() const override final
Retrieve the associated MmReadoutElement.
double chi2(TH1 *h0, TH1 *h1)
MMCluster_v1 MMCluster

Member Data Documentation

◆ m_accumlIsEta

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_accumlIsEta {this, "AccumulatorsInEtaPlane", true}
private

Swtich toggling whether the accumulator view are in the eta or phi plane.

Just affects the axis labels

Definition at line 270 of file PatternVisualizationTool.h.

270{this, "AccumulatorsInEtaPlane", true};

◆ m_canvasLimit

Gaudi::Property<unsigned int> MuonValR4::PatternVisualizationTool::m_canvasLimit {this, "CanvasLimits", 5000}
private

Maximum canvases to draw.

Definition at line 257 of file PatternVisualizationTool.h.

257{this, "CanvasLimits", 5000};

◆ m_canvasPrefix

Gaudi::Property<std::string> MuonValR4::PatternVisualizationTool::m_canvasPrefix {this, "CanvasPreFix", ""}
private

Prefix of the individual canvas file names <MANDATORY>.

Definition at line 263 of file PatternVisualizationTool.h.

263{this, "CanvasPreFix", ""};

◆ m_clientToken

IRootVisualizationService::ClientToken MuonValR4::PatternVisualizationTool::m_clientToken {}
private

Token to present to the visualization service such that the display froms this tool are grouped together.

Definition at line 255 of file PatternVisualizationTool.h.

255{};

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonValR4::PatternVisualizationTool::m_detMgr {nullptr}
private

pointer to the Detector manager

Definition at line 291 of file PatternVisualizationTool.h.

291{nullptr};

◆ m_displayBucket

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_displayBucket {this, "displayBucket", true}
private

Display the surrounding hits from the bucket not part of the seed.

Definition at line 267 of file PatternVisualizationTool.h.

267{this, "displayBucket", true};

◆ m_displayOnlyTruth

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_displayOnlyTruth {this, "displayTruthOnly", false}
private

Definition at line 288 of file PatternVisualizationTool.h.

288{this, "displayTruthOnly", false};

◆ m_doEtaBucketViews

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_doEtaBucketViews {this,"doEtaBucketViews", true}
private

Switch to visualize the eta view of the bucket event.

Definition at line 272 of file PatternVisualizationTool.h.

272{this,"doEtaBucketViews", true};

◆ m_doPhiBucketViews

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_doPhiBucketViews {this,"doPhiBucketViews", false}
private

Switch to visualize the phi view of the bucket event.

Definition at line 274 of file PatternVisualizationTool.h.

274{this,"doPhiBucketViews", false};

◆ m_geoCtxKey

ActsTrk::GeoContextReadKey_t MuonValR4::PatternVisualizationTool::m_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
private

Geometry context key to retrieve the alignment.

Definition at line 293 of file PatternVisualizationTool.h.

293{this, "AlignmentKey", "ActsAlignment", "cond handle key"};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonValR4::PatternVisualizationTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Service Handle to the IMuonIdHelperSvc.

Definition at line 295 of file PatternVisualizationTool.h.

295{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_paintTruthHits

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_paintTruthHits {this, "paintTruthHits", false}
private

Switch to visualize the truth hits.

Definition at line 276 of file PatternVisualizationTool.h.

276{this, "paintTruthHits", false};

◆ m_plotsDone

std::atomic<bool> MuonValR4::PatternVisualizationTool::m_plotsDone {false}
mutableprivate

Flag toggling whether all Canvases have been exhausted.

Definition at line 297 of file PatternVisualizationTool.h.

297{false};

◆ m_prepContainerKeys

SG::ReadHandleKeyArray<xAOD::UncalibratedMeasurementContainer> MuonValR4::PatternVisualizationTool::m_prepContainerKeys {this, "PrdContainer", {}}
private

Declare dependency on the prep data containers.

Definition at line 278 of file PatternVisualizationTool.h.

278{this, "PrdContainer", {}};

◆ m_saveSinglePDFs

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_saveSinglePDFs {this, "saveSinglePDFs", false}
private

If set to true each canvas is saved into a dedicated pdf file.

Definition at line 259 of file PatternVisualizationTool.h.

259{this, "saveSinglePDFs", false};

◆ m_saveSummaryPDF

Gaudi::Property<bool> MuonValR4::PatternVisualizationTool::m_saveSummaryPDF {this, "saveSummaryPDF", false}
private

If set to true a summary Canvas is created.

Definition at line 261 of file PatternVisualizationTool.h.

261{this, "saveSummaryPDF", false};

◆ m_subDir

Gaudi::Property<std::string> MuonValR4::PatternVisualizationTool::m_subDir {this, "outSubDir", ""}
private

Define the subdirectory in which the plots shall be saved.

Definition at line 265 of file PatternVisualizationTool.h.

265{this, "outSubDir", ""};

◆ m_truthLinkDecorKeys

SG::ReadDecorHandleKeyArray<xAOD::UncalibratedMeasurementContainer> MuonValR4::PatternVisualizationTool::m_truthLinkDecorKeys {this, "LinkDecorKeys", {}}
private

Declaration of the dependency on the decorations.

(Overwritten in initialize)

Definition at line 282 of file PatternVisualizationTool.h.

282{this, "LinkDecorKeys", {}};

◆ m_truthLinkDecors

std::vector<SegLinkDecor_t> MuonValR4::PatternVisualizationTool::m_truthLinkDecors {}
private

Definition at line 286 of file PatternVisualizationTool.h.

286{};

◆ m_truthSegLinks

Gaudi::Property<std::set<std::string> > MuonValR4::PatternVisualizationTool::m_truthSegLinks {this, "TruthSegDecors", {}}
private

List of truth segment links to fetch.

Definition at line 280 of file PatternVisualizationTool.h.

280{this, "TruthSegDecors", {}};

◆ m_visualSvc

ServiceHandle<IRootVisualizationService> MuonValR4::PatternVisualizationTool::m_visualSvc {this, "VisualSvc", "MuonValR4::RootVisualizationService"}
private

Service handle of the visualization service.

Definition at line 252 of file PatternVisualizationTool.h.

252{this, "VisualSvc", "MuonValR4::RootVisualizationService"};

The documentation for this class was generated from the following files: