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

#include <FastRecoVisualizationTool.h>

Inheritance diagram for MuonValR4::FastRecoVisualizationTool:
Collaboration diagram for MuonValR4::FastRecoVisualizationTool:

Public Member Functions

virtual StatusCode initialize () override final
virtual void plotPatternBuckets (const EventContext &ctx, const std::string &extraLabel, PatternHitVisualInfoVec &&patternVisualVec) const override final
virtual void plotPatternBuckets (const EventContext &ctx, const std::string &extraLabel, PatternHitVisualInfoVec &&patternVisualVec, PrimitiveVec &&extraPaints) const override final
virtual void plotPatternBuckets (const EventContext &ctx, const std::string &extraLabel, PatternHitVisualInfo &&patternVisual) const override final
virtual void plotPatternBuckets (const EventContext &ctx, const std::string &extraLabel, PatternHitVisualInfo &&patternVisual, 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 SpacePointdrawHit (const SpacePointType &hit, const Amg::Transform3D &localToGlobalBucket, Canvas_t &canvas, const View view, unsigned int fillStyle) const

Private Types

enum class  View { objViewEta = static_cast<int>(MuonValR4::objViewEta) , objViewPhi = static_cast<int>(MuonValR4::objViewPhi) , objViewZR = 2 , objViewRZ = 3 }
 Enum for the different views. More...
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::AuxElement::ConstAccessor<SegLinkVec_t>

Private Member Functions

void plotPatternBucket (const EventContext &ctx, const std::string &extraLabel, const MuonR4::SpacePointBucket &bucket, PatternHitVisualInfo &&patternVisual, PrimitiveVec &&extraPaints) const
 Plot a single pattern bucket.
void drawSearchWindow (const Amg::Transform3D &localToGlobalBucket, PrimitiveVec &outputContainer, const double thetaMin, const double thetaMax, const Canvas_t &canvas, const View view) const
 Draw the search window lines in the local frame expressed by the Transform3D for eta views and in the GlobalR-GlobalZ plane for RZ/ZR views.
void drawLineResidual (const ActsTrk::GeometryContext &gctx, const Amg::Transform3D &localToGlobalBucket, PrimitiveVec &outputContainer, const MuonR4::SpacePoint *seed, const MuonR4::SpacePoint *testHit, const double lineSlope, const double Rwindow, const PatternHitVisualInfo::HitStatus status, const Canvas_t &canvas, const View view) const
 Draw the pattern line and acceptance window for the testHit used during pattern building in the local frame expressed by the Transform3D for eta views and in the GlobalR-GlobalZ plane for RZ/ZR views.
void drawSegment (const xAOD::MuonSegment &segment, const Amg::Transform3D &localToGlobalBucket, PrimitiveVec &outputContainer, bool &drawnTrueLabel, const Canvas_t &canvas, const View view) const
 Draw a segment on the canvas.
template<class SpacePointType>
bool drawHits (const MuonR4::SpacePointBucket &bucket, const Amg::Transform3D &localToGlobalBucket, const std::vector< SpacePointType > &hitsToDraw, Canvas_t &canvasDim, const View 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::SpacePointdrawHit (const SpacePointType &hit, const Amg::Transform3D &localToGlobalBucket, Canvas_t &canvas, const View view, unsigned int fillStyle) const
 Converts a Hit into a particular TBox/ TEllipse for drawing.
void paintSimHits (const ActsTrk::GeometryContext &gctx, const Amg::Transform3D &localToGlobalBucket, const xAOD::MuonSegment &truthSeg, PrimitiveVec &outputContainer, const View view) const
 Paints the truth sim hits associated with the segment.
std::unique_ptr< TLine > drawLine (const Amg::Vector3D &lineDirection, const Amg::Vector3D &linePoint, const double lowEnd, const double highEnd, const int color=kRed+1, const int lineStyle=kDashed, const View view=View::objViewEta) const
 Draws a line given the parameters of the line in the local frame for Eta and Phi views and in the R-Z plane for RZ (and ZR) views.

Private Attributes

ServiceHandle< IRootVisualizationServicem_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.
UnsignedIntegerProperty m_canvasLimit {this, "CanvasLimits", 5000}
 Maximum canvases to draw.
BooleanProperty m_saveSinglePDFs {this, "saveSinglePDFs", false}
 If set to true each canvas is saved into a dedicated pdf file.
BooleanProperty m_saveSummaryPDF {this, "saveSummaryPDF", false}
 If set to true a summary Canvas is created.
StringProperty m_canvasPrefix {this, "CanvasPreFix", ""}
 Prefix of the individual canvas file names <MANDATORY>
StringProperty m_subDir {this, "outSubDir", ""}
 Define the subdirectory in which the plots shall be saved.
BooleanProperty m_doEtaBucketViews {this,"doEtaBucketViews", true}
 Switch to visualize the eta view of the bucket event.
BooleanProperty m_doPhiBucketViews {this,"doPhiBucketViews", false}
 Switch to visualize the phi view of the bucket event.
BooleanProperty m_doRZBucketViews {this,"doRZBucketViews", false}
BooleanProperty m_paintTruthHits {this, "paintTruthHits", false}
 Switch to visualize the truth hits.
BooleanProperty m_paintTruthSegment {this, "paintTruthSegment", false}
 Switch to visualize the truth segment.
BooleanProperty m_paintSuccessfullPatterns {this, "PaintSuccessfullPatterns", true, "Toggle the display of successfully built patterns in the visualization"}
 Switch to visualize successfull patterns.
BooleanProperty m_paintFailedPatterns {this, "PaintFailedPatterns", false, "Toggle the display of failed patterns in the visualization"}
 Switch to visualize failed patterns.
BooleanProperty m_paintOverlapPatterns {this, "PaintOverlapPatterns", false, "Toggle the display of overlap patterns in the visualization"}
 Switch to visualize overlap patterns.
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainerm_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::UncalibratedMeasurementContainerm_truthLinkDecorKeys {this, "LinkDecorKeys", {}}
 Declaration of the dependency on the decorations.
std::vector< SegLinkDecor_tm_truthLinkDecors {}
BooleanProperty m_displayOnlyTruth {this, "displayTruthOnly", false}
 Toggle to print pattern buckets only if they contain truth hits.
BooleanProperty m_displayOnlyWithPattern {this, "displayOnlyWithPattern", true}
 Toggle to print pattern buckets only if they contain pattern hits.
const MuonGMR4::MuonDetectorManagerm_detMgr {nullptr}
 pointer to the Detector manager
SG::ReadHandleKey< ActsTrk::GeometryContextm_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
 Geometry context key to retrieve the alignment.
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 Service Handle to the IMuonIdHelperSvc.
std::atomic< bool > m_plotsDone ATLAS_THREAD_SAFE {false}
 Flag toggling whether all Canvases have been exhausted.

Detailed Description

Definition at line 28 of file FastRecoVisualizationTool.h.

Member Typedef Documentation

◆ Canvas_t

◆ Edges

◆ SegLink_t

◆ SegLinkDecor_t

◆ SegLinkVec_t

Definition at line 231 of file FastRecoVisualizationTool.h.

Member Enumeration Documentation

◆ View

Enum for the different views.

Enumerator
objViewEta 
objViewPhi 
objViewZR 
objViewRZ 

Definition at line 60 of file FastRecoVisualizationTool.h.

60 {
61 objViewEta = static_cast<int>(MuonValR4::objViewEta),
62 objViewPhi = static_cast<int>(MuonValR4::objViewPhi),
63 objViewZR = 2,
64 objViewRZ = 3
65 };
constexpr int objViewEta
ObjectView.
constexpr int objViewPhi

Member Function Documentation

◆ drawHit() [1/2]

template<class SpacePointType>
const SpacePoint * MuonValR4::FastRecoVisualizationTool::drawHit ( const SpacePointType & hit,
const Amg::Transform3D & localToGlobalBucket,
Canvas_t & canvas,
const View 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 475 of file FastRecoVisualizationTool.cxx.

479 {
480
482 const bool isEtaView {view == View::objViewEta || view == View::objViewRZ || view == View::objViewZR};
483 if ((isEtaView && !hit.measuresEta()) || (view == View::objViewPhi && !hit.measuresPhi())) {
484 return nullptr;
485 }
486 const Amg::Vector3D& localPos {hit.localPosition()};
487 const Amg::Vector3D globalPos {localToGlobalBucket * localPos};
488 const auto expand = [&canvas, &hit]( double centerX, double centerY) {
489 canvas.expandPad(centerX- hit.driftRadius(), centerY - hit.driftRadius());
490 canvas.expandPad(centerX+ hit.driftRadius(), centerY + hit.driftRadius());
491 };
492 if (hit.type() != xAOD::UncalibMeasType::Other) {
493 if (view == View::objViewEta || view == View::objViewPhi) {
494 expand(localPos[static_cast<int>(view)], localPos.z());
495 } else if (view == View::objViewZR) {
496 expand(globalPos.z(), globalPos.perp());
497 } else if (view == View::objViewRZ) {
498 expand(globalPos.perp(), globalPos.z());
499 }
500 }
501 const SpacePoint* underlyingSp{nullptr};
503 constexpr int invalidCalibFill = 3305;
504 if constexpr (std::is_same_v<SpacePointType, SpacePoint>) {
505 underlyingSp = &hit;
507 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(hit.primaryMeasurement());
508 if (dc->status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
509 fillStyle = invalidCalibFill;
510 }
511 }
512 } else if constexpr(std::is_same_v<SpacePointType, CalibratedSpacePoint>) {
513 underlyingSp = hit.spacePoint();
514 if (hit.fitState() == CalibratedSpacePoint::State::Valid) {
515 fillStyle = fullFilling;
516 } else if (hit.fitState() == CalibratedSpacePoint::State::FailedCalib) {
517 fillStyle = invalidCalibFill;
518 } else {
519 fillStyle = hatchedFilling;
520 }
521 }
522 const Amg::Vector3D posInCanvas = [view, localPos, globalPos]() -> Amg::Vector3D{
523 switch (view) {
524 case View::objViewEta:
525 case View::objViewPhi:
526 return localPos;
527 case View::objViewZR:
528 return globalPos.z()* Amg::Vector3D::UnitY() + globalPos.perp() * Amg::Vector3D::UnitZ();
529 case View::objViewRZ:
530 return globalPos.z()* Amg::Vector3D::UnitZ() + globalPos.perp() * Amg::Vector3D::UnitY();
531 }
532 return Amg::Vector3D::Zero();
533 }();
534 const int covIdx {view == View::objViewPhi ? static_cast<int>(View::objViewPhi) : static_cast<int>(View::objViewEta)};
535 switch(hit.type()) {
536 case xAOD::UncalibMeasType::MdtDriftCircleType: {
537 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(underlyingSp->primaryMeasurement());
538 canvas.add(drawDriftCircle(posInCanvas, dc->readoutElement()->innerTubeRadius(),
539 kBlack, hollowFilling));
540
541 const int circColor = isLabeled(*dc) ? truthColor : kBlue;
542 canvas.add(drawDriftCircle(posInCanvas, hit.driftRadius(), circColor, fillStyle));
543 break;
545 const auto* meas{static_cast<const xAOD::RpcMeasurement*>(underlyingSp->primaryMeasurement())};
546 const int boxColor = isLabeled(*meas) ? truthColor : kGreen +2;
547 const double boxWidth = 0.5*std::sqrt(12)*std::sqrt(underlyingSp->covariance()[covIdx]);
548 canvas.add(drawBox(posInCanvas, boxWidth, 0.5*meas->readoutElement()->gasGapPitch(),
549 boxColor, fillStyle, covIdx));
550 break;
552 const auto* meas{static_cast<const xAOD::TgcStrip*>(underlyingSp->primaryMeasurement())};
553 const int boxColor = isLabeled(*meas) ? truthColor : kCyan + 2;
554 const double boxWidth = 0.5*std::sqrt(12)*std::sqrt(underlyingSp->covariance()[covIdx]);
555 canvas.add(drawBox(posInCanvas, boxWidth, 0.5*meas->readoutElement()->gasGapPitch(),
556 boxColor, fillStyle, covIdx));
557 break;
559 const int boxColor = isLabeled(*underlyingSp->primaryMeasurement()) ? truthColor : kAquamarine;
560 const double boxWidth = 5*Gaudi::Units::mm;
561 canvas.add(drawBox(posInCanvas, boxWidth, 10.*Gaudi::Units::mm, boxColor, fillStyle, covIdx));
562 break;
564 break;
566 const int boxColor = isLabeled(*underlyingSp->primaryMeasurement()) ? truthColor : kTeal;
567 const double boxWidth = 5*Gaudi::Units::mm;
568 canvas.add(drawBox(posInCanvas, boxWidth, 10.*Gaudi::Units::mm, boxColor, fillStyle, covIdx));
569 break;
570 } default: {
571 ATH_MSG_WARNING("Please implement proper drawings of the new small wheel.. "<<__FILE__<<":"<<__LINE__);
572 break;
573 }
574 }
575 return underlyingSp;
576 }
#define ATH_MSG_WARNING(x)
virtual bool isLabeled(const MuonR4::SpacePoint &hit) const override final
Fetches all labeled (e.g.
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, AmgSymMatrix(N) &covMatrix)
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr int hatchedFilling
constexpr int fullFilling
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.
MdtDriftCircle_v1 MdtDriftCircle
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9

◆ drawHit() [2/2]

template<class SpacePointType>
const MuonR4::SpacePoint * MuonValR4::FastRecoVisualizationTool::drawHit ( const SpacePointType & hit,
const Amg::Transform3D & localToGlobalBucket,
Canvas_t & canvas,
const View 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
localToGlobalBucketBucket frame transformation, used for the conversion of the line parameters from global to local frame and viversa
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::FastRecoVisualizationTool::drawHits ( const MuonR4::SpacePointBucket & bucket,
const Amg::Transform3D & localToGlobalBucket,
const std::vector< SpacePointType > & hitsToDraw,
Canvas_t & canvasDim,
const View 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
localToGlobalBucketBucket frame transformation, used for the conversion of the line parameters from global to local frame and viversa
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 579 of file FastRecoVisualizationTool.cxx.

583 {
584
585 SpacePointSet drawnPoints{};
586 for (const SpacePointType& hit : hitsToDraw) {
587 drawnPoints.insert(drawHit(*hit, localToGlobalBucket, canvas, view, fullFilling));
588 }
589 for (const SpacePointBucket::value_type& hit : bucket) {
590 // Don't redraw the other points
591 if (drawnPoints.count(hit.get())) {
592 continue;
593 }
594 drawHit(*hit, localToGlobalBucket, canvas, view, hollowFilling);
595 }
596 return drawnPoints.size() - drawnPoints.count(nullptr) > 1;
597 }
const MuonR4::SpacePoint * drawHit(const SpacePointType &hit, const Amg::Transform3D &localToGlobalBucket, Canvas_t &canvas, const View view, unsigned int fillStyle) const
Converts a Hit into a particular TBox/ TEllipse for drawing.
constexpr int hollowFilling
Filling codes for hollow / fullFilling / hatched filling.
std::vector< const SpacePoint * > SpacePointSet
vector of space points
Definition FitterTypes.h:38

◆ drawLine()

std::unique_ptr< TLine > MuonValR4::FastRecoVisualizationTool::drawLine ( const Amg::Vector3D & lineDirection,
const Amg::Vector3D & linePoint,
const double lowEnd,
const double highEnd,
const int color = kRed +1,
const int lineStyle = kDashed,
const View view = View::objViewEta ) const
private

Draws a line given the parameters of the line in the local frame for Eta and Phi views and in the R-Z plane for RZ (and ZR) views.

Parameters
lineDirectionLine direction vector in the local frame for Eta and Phi views or in the z-y plane (convention) for RZ and ZR views
linePointPoint on the line in the local frame for Eta and Phi views or in the z-y plane (convention) for RZ and ZR views
lowEndLower boundary in Canvas-y of the line (i.e. loc Z) for Eta/Phi views, or in global R for ZR/RZ views. If the line is perpendicular to the Canvas-y/globalR axis, it will be interpreted as Canvas-x/globalZ lower limit.
highEndUpper boundary in Canvas-y of the line, (i.e. loc Z) for Eta/Phi views, or in global R for ZR/RZ views. If the line is perpendicular to the Canvas-y/globalR axis, it will be interpreted as Canvas-x/globalZ upper limit.
lineStyleStyle of the drawn line (cf. TAttLine documentation)
viewIs the line placed in the y-z or x-z plane or R-Z/Z-R planes

For eta and phi views, we work in the local frame

In the case of a line parallel to the loc Y axis (i.e. horizontal in the Canvas)

For R-Z and Z-R views, we work in the global frame, and the limits are on R. By convention, we use the Z-y plane in 3D space to store the line parameters

Special case: line parallel to global Z axis (constant in global R)

Z along the x-axis of the canvas, R along the y-axis

R along the x-axis, Z along the y-axis

Special case: line parallel to global R axis

Z along the x-axis of the canvas, R along the y-axis

R along the x-axis, Z along the y-axis

Z along the x-axis of the canvas, R along the y-axis

R along the x-axis, Z along the y-axis

Definition at line 598 of file FastRecoVisualizationTool.cxx.

604 {
606 using ParamDefs = MuonR4::SpacePoint::SeedingAux::FitParIndex;
607 auto makeLine = [](const double x1, const double y1, const double x2, const double y2, const int color, const int style){
608 auto line = std::make_unique<TLine>(x1, y1, x2, y2);
609 line->SetLineColor(color);
610 line->SetLineWidth(2);
611 line->SetLineStyle(style);
612 return line;
613 };
614
615 if (view == View::objViewEta || view == View::objViewPhi){
617 if (std::abs(lineDirection.z()) < std::numeric_limits<double>::epsilon()) {
619 return makeLine(lowEnd, linePoint.z(), highEnd, linePoint.z(), color, lineStyle);
620 } else {
621 return MuonValR4::drawLine(linePoint + Amg::intersect<3>(linePoint,lineDirection,Amg::Vector3D::UnitZ(), lowEnd).value_or(0.)* lineDirection,
622 linePoint + Amg::intersect<3>(linePoint,lineDirection,Amg::Vector3D::UnitZ(), highEnd).value_or(0.)* lineDirection,
623 color, lineStyle, static_cast<int>(view));
624 }
625 } else {
627 if (std::abs(lineDirection.y()) < std::numeric_limits<double>::epsilon()) {
629 if (view == View::objViewZR) {
631 return makeLine(lowEnd, linePoint.y(), highEnd, linePoint.y(), color, lineStyle);
632 } else {
634 return makeLine(linePoint.y(), lowEnd, linePoint.y(), highEnd, color, lineStyle);
635 }
636 } else if (std::abs(lineDirection.z()) < std::numeric_limits<double>::epsilon()) {
638 if (view == View::objViewZR) {
640 return makeLine(linePoint.z(), lowEnd, linePoint.z(), highEnd, color, lineStyle);
641 } else {
643 return makeLine(lowEnd, linePoint.z(), highEnd, linePoint.z(), color, lineStyle);
644 }
645 } else {
646 const double slope {lineDirection.y() / lineDirection.z()};
647 const double intercept {linePoint.y() - slope * linePoint.z()};
648 const double Zlow {(lowEnd - intercept) / slope};
649 const double Zhigh {(highEnd - intercept) / slope};
650 if (view == View::objViewZR) {
652 return makeLine(Zlow, lowEnd, Zhigh, highEnd, color, lineStyle);
653 } else {
655 return makeLine(lowEnd, Zlow, highEnd, Zhigh, color, lineStyle);
656 }
657 }
658 }
659 }
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
Acts::Experimental::CompositeSpacePointLineFitter::ParamVec_t Parameters
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.

◆ drawLineResidual()

void MuonValR4::FastRecoVisualizationTool::drawLineResidual ( const ActsTrk::GeometryContext & gctx,
const Amg::Transform3D & localToGlobalBucket,
PrimitiveVec & outputContainer,
const MuonR4::SpacePoint * seed,
const MuonR4::SpacePoint * testHit,
const double lineSlope,
const double Rwindow,
const PatternHitVisualInfo::HitStatus status,
const Canvas_t & canvas,
const View view ) const
private

Draw the pattern line and acceptance window for the testHit used during pattern building in the local frame expressed by the Transform3D for eta views and in the GlobalR-GlobalZ plane for RZ/ZR views.

Parameters
gctxGeometry context needed to retrieve the seed global position and its position in the bucket frame
localToGlobalBucketBucket frame transformation, used for the conversion of the line parameters from global to local frame and viversa
outputContainerVector to which the drawn lines are appended
seedSeed hit of the pattern
testHitHit being tested during pattern building
lineSlopeSlope of the pattern line in the GlobalR-GlobalZ plane computed during pattern building to test the testHit
RwindowSize of the acceptance window in the GlobalR direction to accept the testHit in pattern building
statusStatus of the testHit during pattern building (e.g. accepted, rejected or replaced)
canvasReference to the Canvas object to which the drawn lines. Needed to set the line limits
viewDraw the line in the eta or RZ/ZR view

In phi view we dont plot anything

We do not expect pattern lines horizontal in global Z vs global R plane

Draw the pattern line in the z-y plane of the 3D space (convention)

Determine the extremes of that line

Draw the acceptance lines in R

Draw the pattern line in the local frame of the testHit. Using the chamber phi we ensure the line is always in the y-z plane

Retrieve the seed position in the local frame of the bucket we want to draw

Determine the extremes of that line

Draw the acceptance lines in R

Definition at line 316 of file FastRecoVisualizationTool.cxx.

325 {
326 using HitStatus = PatternHitVisualInfo::HitStatus;
328 if (view == View::objViewPhi) {
329 return;
330 }
331 if (std::abs(lineSlope) < std::numeric_limits<double>::epsilon()) {
333 return;
334 }
335 auto color {status == HitStatus::eKept ? kGreen : (status == HitStatus::eReplaced ? kPink : kGray)};
336 if (view == View::objViewZR || view == View::objViewRZ) {
338 const Amg::Vector3D lineDir {Acts::makeDirectionFromAxisTangents(0., lineSlope)};
339 const Amg::Vector3D seedGlobalPos {seed->msSector()->localToGlobalTransform(gctx) * seed->localPosition()};
340 const Amg::Vector3D linePos {seedGlobalPos.perp()* Amg::Vector3D::UnitY() + seedGlobalPos.z() * Amg::Vector3D::UnitZ()};
342 const double seedGlobalR {seedGlobalPos.perp()};
343 const double testGlobalR {(localToGlobalBucket * testHit->localPosition()).perp()};
344 const double testGlobalZ {(localToGlobalBucket * testHit->localPosition()).z()};
345 const double lineIntercept {linePos.y() - lineSlope * linePos.z()};
346 const double line2WindowInters {lineSlope*testGlobalZ + lineIntercept};
347 double lowLimit{};
348 double upLimit{};
349 if (seedGlobalR < testGlobalR) {
350 lowLimit = (seed->msSector() == testHit->msSector() ?
351 seedGlobalR : (view == View::objViewZR ? canvas.corner(Edges::yLow) : canvas.corner(Edges::xLow)));
352 upLimit = line2WindowInters;
353 } else {
354 upLimit = (seed->msSector() == testHit->msSector() ?
355 seedGlobalR : (view == View::objViewZR ? canvas.corner(Edges::yHigh) : canvas.corner(Edges::xHigh)));
356 lowLimit = line2WindowInters;
357 }
358 outputContainer.emplace_back(drawLine(lineDir, linePos,
359 lowLimit, upLimit, color, kDashed, view));
360
362 const Amg::Vector3D barLineDir {Amg::Vector3D::UnitY()};
363 const Amg::Vector3D barLinePos {testGlobalZ* Amg::Vector3D::UnitZ()};
364 lowLimit = testGlobalR - Rwindow;
365 upLimit = testGlobalR + Rwindow;
366 outputContainer.emplace_back(drawLine(barLineDir, barLinePos,
367 lowLimit, upLimit, color, kDotted, view));
368 } else {
370 const double globLineTheta { lineSlope > 0 ? atan(lineSlope) : atan(lineSlope) + M_PI };
371 const double globLinePhi {localToGlobalBucket.translation().phi()};
372 const Amg::Vector3D globLineDir {Acts::makeDirectionFromPhiTheta(globLinePhi,globLineTheta)};
373 const Amg::Vector3D locLineDir {localToGlobalBucket.inverse().linear() * globLineDir};
375 const Amg::Vector3D seedGlobalPos {seed->msSector()->localToGlobalTransform(gctx) * seed->localPosition()};
376 const Amg::Vector3D seedLocalPos {localToGlobalBucket.inverse() * seedGlobalPos};
378 const double& testLocalZ {testHit->localPosition().z()};
379 const double& testLocalY {testHit->localPosition().y()};
380 const double testGlobalR {(localToGlobalBucket * testHit->localPosition()).perp()};
381 double seedGlobalR {seedGlobalPos.perp()};
382 const bool isBarrel {seed->msSector()->barrel()};
383 const double line2WindowInters {isBarrel ? Acts::detail::LineHelper::lineIntersect<3>(seedLocalPos, locLineDir, testLocalY* Amg::Vector3D::UnitY(), Amg::Vector3D::UnitZ()).position().z()
384 : Acts::detail::LineHelper::lineIntersect<3>(seedLocalPos, locLineDir, testLocalZ* Amg::Vector3D::UnitZ(), Amg::Vector3D::UnitY()).position().z()};
385 double lowLimit{};
386 double upLimit{};
387 if (seedGlobalR < testGlobalR) {
388 lowLimit = (seed->msSector() == testHit->msSector() ? seedLocalPos.z() : canvas.corner(Edges::yLow));
389 upLimit = line2WindowInters;
390 } else {
391 upLimit = (seed->msSector() == testHit->msSector() ? seedLocalPos.z() : canvas.corner(Edges::yHigh));
392 lowLimit = line2WindowInters;
393 }
394 outputContainer.emplace_back(drawLine(locLineDir, seedLocalPos,
395 lowLimit, upLimit, color, kDashed, view));
396
398 const Amg::Vector3D barLineDir {isBarrel ? Amg::Vector3D::UnitZ() : Amg::Vector3D::UnitY()};
399 const Amg::Vector3D barLinePos {isBarrel ? testLocalY* Amg::Vector3D::UnitY() : testLocalZ* Amg::Vector3D::UnitZ()};
400 lowLimit = isBarrel ? testLocalZ - Rwindow : testLocalY - Rwindow;
401 upLimit = isBarrel ? testLocalZ + Rwindow : testLocalY + Rwindow;
402 outputContainer.emplace_back(drawLine(barLineDir, barLinePos,
403 lowLimit, upLimit, color, kDotted, view));
404 }
405 }
#define M_PI
Eigen::Matrix< double, 3, 1 > Vector3D
std::unique_ptr< TLine > drawLine(const Amg::Vector3D &lineDirection, const Amg::Vector3D &linePoint, const double lowEnd, const double highEnd, const int color=kRed+1, const int lineStyle=kDashed, const View view=View::objViewEta) const
Draws a line given the parameters of the line in the local frame for Eta and Phi views and in the R-Z...
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
status
Definition merge.py:16

◆ drawSearchWindow()

void MuonValR4::FastRecoVisualizationTool::drawSearchWindow ( const Amg::Transform3D & localToGlobalBucket,
PrimitiveVec & outputContainer,
const double thetaMin,
const double thetaMax,
const Canvas_t & canvas,
const View view ) const
private

Draw the search window lines in the local frame expressed by the Transform3D for eta views and in the GlobalR-GlobalZ plane for RZ/ZR views.

Parameters
localToGlobalBucketBucket frame transformation, used for the conversion of the line parameters from global to local frame and viversa
outputContainerVector to which the drawn lines are appended
thetaMinMinimum global theta of the search window
thetaMaxMaximum global theta of the search window
canvasReference to the Canvas object to which the drawn lines. Needed to set the line limits
viewDraw the line in the eta or RZ/ZR view

In phi view we dont plot anything

We do not expect pattern lines horizontal in global Z vs global R plane

In RZ views, we have already the slope. We draw the line in the z-y plane of the 3D space (convention)

In eta views, we need to convert the slope from global to local frame

Definition at line 274 of file FastRecoVisualizationTool.cxx.

279 {
281 if (view == View::objViewPhi) {
282 return;
283 }
284 auto addSearchWindowLine = [&outputContainer, &localToGlobalBucket, &view, &canvas, this](const double globLineTheta){
285 constexpr double smallAngle {1e-3};
286 if (std::abs(globLineTheta) < smallAngle || std::abs(globLineTheta - M_PI) < smallAngle) {
288 throw std::runtime_error("Unexpected horizontal pattern search line in global frame. Cannot draw search window.");
289 return;
290 }
291 Amg::Vector3D lineDirection{};
292 Amg::Vector3D linePosition{};
293 double lowEnd{};
294 double upEnd{};
295 if (view == View::objViewZR || view == View::objViewRZ) {
297 lineDirection = Acts::makeDirectionFromAxisTangents(0., tan(globLineTheta));
298 linePosition = Amg::Vector3D::Zero();
299 lowEnd = view == View::objViewZR ? canvas.corner(Edges::yLow) : canvas.corner(Edges::xLow);
300 upEnd = view == View::objViewZR ? canvas.corner(Edges::yHigh) : canvas.corner(Edges::xHigh);
301 } else {
303 const double globLinePhi {localToGlobalBucket.translation().phi()};
304 const Amg::Vector3D globLineDir {Acts::makeDirectionFromPhiTheta(globLinePhi,globLineTheta)};
305 lineDirection = localToGlobalBucket.inverse().linear() * globLineDir;
306 linePosition = localToGlobalBucket.inverse() * Amg::Vector3D::Zero();
307 lowEnd = canvas.corner(Edges::yLow);
308 upEnd = canvas.corner(Edges::yHigh);
309 }
310 outputContainer.emplace_back(drawLine(lineDirection, linePosition,
311 lowEnd, upEnd, kOrange, kDashed, view));
312 };
313 addSearchWindowLine(thetaMin);
314 addSearchWindowLine(thetaMax);
315 }

◆ drawSegment()

void MuonValR4::FastRecoVisualizationTool::drawSegment ( const xAOD::MuonSegment & segment,
const Amg::Transform3D & localToGlobalBucket,
PrimitiveVec & outputContainer,
bool & drawnTrueLabel,
const Canvas_t & canvas,
const View view ) const
private

Draw a segment on the canvas.

Parameters
segmentSegment to draw
localToGlobalBucketBucket frame transformation, used for the conversion of the line parameters from global to local frame and viversa
outputContainerVector to which the drawn lines are appended
drawnTrueLabelBoolean set to true if the label with the true segment parameters has already been drawn on the canvas. If not, it is drawn with the segment and the boolean is set to true.
canvasReference to the Canvas object to which the drawn lines. Needed to set the line limits
viewDraw the line in the eta or RZ/ZR view

Compute line and direction in the global frame

Compute line and direction in the globalR-GlobalZ plane

Definition at line 406 of file FastRecoVisualizationTool.cxx.

411 {
413 return;
414 }
415 auto [linePos, lineDir] = makeLine(localSegmentPars(segment));
416 double lowEnd{canvas.corner(Edges::yLow)};
417 double highEnd{canvas.corner(Edges::yHigh)};
418 if (view == View::objViewZR || view == View::objViewRZ){
420 const Amg::Vector3D globDir {localToGlobalBucket.linear() * lineDir};
421 const Amg::Vector3D globPos {localToGlobalBucket * linePos};
423 const double slopeRZ {(globPos.x()*globDir.x() + globPos.y()*globDir.y()) / (globPos.perp()*globDir.z())};
424 lineDir = Acts::makeDirectionFromAxisTangents(0., slopeRZ);
425 linePos = globPos.perp()* Amg::Vector3D::UnitY() + globPos.z() * Amg::Vector3D::UnitZ();
426 if (view == View::objViewRZ) {
427 lowEnd = canvas.corner(Edges::xLow);
428 highEnd = canvas.corner(Edges::xHigh);
429 }
430 }
431 outputContainer.emplace_back(drawLine(lineDir, linePos, lowEnd, highEnd,
432 truthColor, kDotted, view));
433 if (!drawnTrueLabel) {
434 outputContainer.emplace_back(drawLabel(std::format("true parameters: {:}",makeLabel(localSegmentPars(segment))),0.2, 0.89));
435 drawnTrueLabel = true;
436 }
437 }
BooleanProperty m_paintTruthSegment
Switch to visualize the truth segment.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::string makeLabel(const Parameters &pars)
Dumps the parameters into a string in the form of TLatex.
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,.

◆ getLabeledSegments() [1/2]

FastRecoVisualizationTool::LabeledSegmentSet MuonValR4::FastRecoVisualizationTool::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 84 of file FastRecoVisualizationTool.cxx.

84 {
85 std::vector<const xAOD::UncalibratedMeasurement*> measurements{};
86 measurements.reserve(2* hits.size());
87 for (const SpacePoint* hit: hits) {
88 measurements.push_back(hit->primaryMeasurement());
89 if(hit->secondaryMeasurement()) {
90 measurements.push_back(hit->secondaryMeasurement());
91 }
92 }
93 return getLabeledSegments(measurements);
94 }
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]

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

Definition at line 95 of file FastRecoVisualizationTool.cxx.

95 {
96 LabeledSegmentSet truthSegs{};
97 for (const xAOD::UncalibratedMeasurement* hit : hits) {
98 for (const SegLinkDecor_t& decor: m_truthLinkDecors) {
99 for (const SegLink_t& link : decor(*hit)) {
100 truthSegs.insert(*link);
101 }
102 }
103 }
104 return truthSegs;
105 }
ElementLink< xAOD::MuonSegmentContainer > SegLink_t
SG::AuxElement::ConstAccessor< SegLinkVec_t > SegLinkDecor_t
std::vector< SegLinkDecor_t > m_truthLinkDecors
PatternVisualizationTool::LabeledSegmentSet LabeledSegmentSet
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.

◆ initialize()

StatusCode MuonValR4::FastRecoVisualizationTool::initialize ( )
finaloverridevirtual

Definition at line 32 of file FastRecoVisualizationTool.cxx.

32 {
33 if (m_canvasLimit > 0) {
34 m_clientToken.canvasLimit = m_canvasLimit;
35 m_clientToken.preFixName = m_canvasPrefix;
36 m_clientToken.saveSinglePlots = m_saveSinglePDFs;
37 m_clientToken.saveSummaryPlot = m_saveSummaryPDF;
38 m_clientToken.subDirectory = m_subDir;
39 ATH_CHECK(m_visualSvc.retrieve());
40 ATH_CHECK(m_visualSvc->registerClient(m_clientToken));
41 } else {
42 m_plotsDone = true;
43 }
44 ATH_CHECK(m_prepContainerKeys.initialize(!m_truthSegLinks.empty()));
46 ATH_MSG_INFO("Hits linked to the following segment decorations are considered as truth");
47 for (const std::string& decorName : m_truthSegLinks) {
48 ATH_MSG_INFO(" **** "<<decorName);
49 if (decorName.empty()) {
50 ATH_MSG_FATAL("Decoration must not be empty");
51 return StatusCode::FAILURE;
52 }
53 for (const SG::ReadHandleKey<xAOD::UncalibratedMeasurementContainer>& key : m_prepContainerKeys) {
54 m_truthLinkDecorKeys.emplace_back(key, decorName);
55 m_truthLinkDecors.push_back(SegLinkDecor_t{decorName});
56 }
57 }
58 ATH_CHECK(m_truthLinkDecorKeys.initialize());
59 m_displayOnlyTruth.value() &= !m_truthLinkDecorKeys.empty();
60
61 ATH_CHECK(m_idHelperSvc.retrieve());
62 ATH_CHECK(m_geoCtxKey.initialize());
63 ATH_CHECK(detStore()->retrieve(m_detMgr));
65 ATH_MSG_ERROR("No bucket view enabled. Please enable at least one of the bucket views to visualize the buckets.");
66 return StatusCode::FAILURE;
67 }
69 ATH_MSG_ERROR("Multiple bucket views enabled. Please enable only one bucket view.");
70 return StatusCode::FAILURE;
71 }
72 return StatusCode::SUCCESS;
73 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
Gaudi::Property< std::set< std::string > > m_truthSegLinks
List of truth segment links to fetch.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service Handle to the IMuonIdHelperSvc.
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.
BooleanProperty m_saveSinglePDFs
If set to true each canvas is saved into a dedicated pdf file.
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
Geometry context key to retrieve the alignment.
StringProperty m_canvasPrefix
Prefix of the individual canvas file names <MANDATORY>
BooleanProperty m_saveSummaryPDF
If set to true a summary Canvas is created.
ServiceHandle< IRootVisualizationService > m_visualSvc
Service handle of the visualization service.
BooleanProperty m_doPhiBucketViews
Switch to visualize the phi view of the bucket event.
BooleanProperty m_displayOnlyTruth
Toggle to print pattern buckets only if they contain truth hits.
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prepContainerKeys
Declare dependency on the prep data containers.
BooleanProperty m_doEtaBucketViews
Switch to visualize the eta view of the bucket event.
const MuonGMR4::MuonDetectorManager * m_detMgr
pointer to the Detector manager
StringProperty m_subDir
Define the subdirectory in which the plots shall be saved.
UnsignedIntegerProperty m_canvasLimit
Maximum canvases to draw.

◆ isLabeled() [1/2]

bool MuonValR4::FastRecoVisualizationTool::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 74 of file FastRecoVisualizationTool.cxx.

74 {
75 return isLabeled(*hit.primaryMeasurement()) ||
77 }
const xAOD::UncalibratedMeasurement * secondaryMeasurement() const
const xAOD::UncalibratedMeasurement * primaryMeasurement() const

◆ isLabeled() [2/2]

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

Definition at line 78 of file FastRecoVisualizationTool.cxx.

78 {
79 return std::find_if(m_truthLinkDecors.begin(), m_truthLinkDecors.end(),
80 [&hit](const SegLinkDecor_t& decor){
81 return !decor(hit).empty();
82 }) != m_truthLinkDecors.end();
83 }

◆ paintSimHits()

void MuonValR4::FastRecoVisualizationTool::paintSimHits ( const ActsTrk::GeometryContext & gctx,
const Amg::Transform3D & localToGlobalBucket,
const xAOD::MuonSegment & truthSeg,
PrimitiveVec & outputContainer,
const View view ) const
private

Paints the truth sim hits associated with the segment.

Hits are drawn as orange arrows

Parameters
gctxGeometry context to fetch the alignment constants
truthSegSegment made from truth sim hits
outputContainerVector to which the drawn lines are appended
viewDraw the hit either in the eta or phi view

Compute line and direction in the global frame

Definition at line 438 of file FastRecoVisualizationTool.cxx.

442 {
443 if (!m_paintTruthHits) {
444 return;
445 }
446 auto truthHits = getMatchingSimHits(truthSeg);
447 for (const xAOD::MuonSimHit* simHit : truthHits) {
448 const MuonGMR4::MuonReadoutElement* re = m_detMgr->getReadoutElement(simHit->identify());
449 const IdentifierHash hash = re->detectorType() == ActsTrk::DetectorType::Mdt ?
450 re->measurementHash(simHit->identify()) :
451 re->layerHash(simHit->identify());
452 const Amg::Transform3D trf = re->msSector()->globalToLocalTransform(gctx) *
453 re->localToGlobalTransform(gctx, hash);
454 const Amg::Vector3D locPos = trf * xAOD::toEigen(simHit->localPosition());
455 const Amg::Vector3D locDir = trf.linear() * xAOD::toEigen(simHit->localDirection());
456 if (view == View::objViewEta || view == View::objViewPhi){
457 outputContainer.emplace_back(drawArrow(locPos, locDir, truthColor, kDashed, static_cast<int>(view)));
458 } else {
459 constexpr double arrowLength = 2.*Gaudi::Units::cm;
461 const Amg::Vector3D globDir {localToGlobalBucket.linear() * locDir};
462 const Amg::Vector3D globPos {localToGlobalBucket * locPos};
463 const Amg::Vector3D end = globPos + (arrowLength / std::hypot(globDir.z(),globDir.perp()) ) * globDir;
464 auto arrow = view == View::objViewZR ? std::make_unique<TArrow>(globPos.z(), globPos.perp(), end.z(), end.perp(),0.01) :
465 std::make_unique<TArrow>(globPos.perp(), globPos.z(), end.perp(), end.z(),0.01);
466 arrow->SetLineColor(truthColor);
467 arrow->SetLineWidth(2);
468 arrow->SetLineStyle(kDashed);
469 outputContainer.emplace_back(std::move(arrow));
470 }
471 }
472 }
const boost::regex re(r_e)
Scalar perp() const
perp method - perpendicular length
#define z
BooleanProperty m_paintTruthHits
Switch to visualize the truth hits.
@ Mdt
MuonSpectrometer.
Eigen::Affine3d Transform3D
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.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12

◆ plotPatternBucket()

void MuonValR4::FastRecoVisualizationTool::plotPatternBucket ( const EventContext & ctx,
const std::string & extraLabel,
const MuonR4::SpacePointBucket & bucket,
PatternHitVisualInfo && patternVisual,
PrimitiveVec && extraPaints ) const
private

Plot a single pattern bucket.

Parameters
ctxEvent Context
extraLabelExtra label for the plot
bucketReference to the pattern bucket to plot
patternVisualVisual information for the pattern
extraPaintsAdditional painting instructions

Check whether the canvas limit has been reached

Check whether to display only patterns with truth information

Check whether the pattern status is to be displayed

Check whether to display only buckets with patterns. Collect pattern hits belonging to the bucket and check the size

Prepare the canvas for drawing

Determine the view to use ad, in cae=se of Z-R view, check if we have two swap the axis (e.g. endcap)

Check the orientatation of the local y axis. If is not aligned to the global Z, we will swap the axis for RZ views

First draw the pattern hits in this bucket

Draw the search window

Print first all the lines

Check if we have the bucket hit in this pattern visual

Check if the hit has been replaced or removed

Print pattern and acceptance window lines corresponding to this bucket hit

Print pattern information on the canvas

Draw truth segments

Definition at line 143 of file FastRecoVisualizationTool.cxx.

147 {
148 using PatternStatus = FastRecoVisualizationTool::PatternHitVisualInfo::PatternStatus;
149 using HitStatus = FastRecoVisualizationTool::PatternHitVisualInfo::HitStatus;
151 if (m_plotsDone) {
152 return;
153 }
155 LabeledSegmentSet truthSegs{getLabeledSegments(Acts::unpackConstSmartPointers(bucket))};
156 if (truthSegs.empty() && m_displayOnlyTruth) {
157 return;
158 }
160 PatternStatus patStatus{patternVisual.status};
161 if ((patStatus == PatternStatus::eSuccessful && !m_paintSuccessfullPatterns) ||
162 (patStatus == PatternStatus::eFailed && !m_paintFailedPatterns) ||
163 (patStatus == PatternStatus::eOverlap && !m_paintOverlapPatterns)) {
164 return;
165 }
167 std::vector<const MuonR4::SpacePoint*> patHitsInBucket{};
168 const MuonR4::GlobalPattern& pat {*patternVisual.patternCopy};
169 for (const Muon::MuonStationIndex::StIndex& station : pat.getStations()) {
170 for (const MuonR4::SpacePoint* hit : pat.hitsInStation(station)) {
171 if (std::ranges::find_if(bucket,
172 [hit](const std::shared_ptr<MuonR4::SpacePoint> sp) { return sp.get() == hit; }) != bucket.end()) {
173 patHitsInBucket.push_back(hit);
174 }
175 }
176 }
177 if (patHitsInBucket.empty() && m_displayOnlyWithPattern) {
178 return;
179 }
181 std::string nameTag = std::format("{}_{}_Bkt_{:d}", extraLabel, bucket.msSector()->identString(), bucket.bucketId());
182 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, nameTag);
183 if (!canvas){
184 m_plotsDone = true;
185 return;
186 }
187 canvas->add(std::move(extraPaints));
188 const ActsTrk::GeometryContext* geoCtx{nullptr};
189 if (!SG::get(geoCtx, m_geoCtxKey, ctx).isSuccess()) {
190 throw std::runtime_error("Failed to retrieve GeometryContext from EventStore");
191 return;
192 }
195 const Amg::Transform3D& localToGlobalBucket{bucket.msSector()->localToGlobalTransform(*geoCtx)};
197 if (view == View::objViewZR && !bucket.msSector()->barrel()) {
199 }
200 switch (view) {
201 case View::objViewEta:
202 canvas->setAxisTitles("y [mm]", "z [mm]");
203 break;
204 case View::objViewPhi:
205 canvas->setAxisTitles("x [mm]", "z [mm]");
206 break;
207 case View::objViewZR:
208 canvas->setAxisTitles("z [mm]", "R [mm]");
209 break;
210 case View::objViewRZ:
211 canvas->setAxisTitles("R [mm]", "z [mm]");
212 break;
213 }
215 if (!drawHits(bucket, localToGlobalBucket, patHitsInBucket, *canvas, view)) {
216 return;
217 }
218
220
222 drawSearchWindow(localToGlobalBucket, lines, patternVisual.thetaSearchMin, patternVisual.thetaSearchMax, *canvas, view);
223
225 for (const auto& sp : bucket) {
226 const MuonR4::SpacePoint* testHit {sp.get()};
228 if (patternVisual.hitLineInfo.find(testHit) == patternVisual.hitLineInfo.end()) {
229 continue;
230 }
232 const HitStatus hitStatus {std::ranges::find(patternVisual.discardedHits, testHit) != patternVisual.discardedHits.end() ? HitStatus::eDiscarded :
233 (std::ranges::find(patternVisual.replacedHits, testHit) != patternVisual.replacedHits.end() ? HitStatus::eReplaced : HitStatus::eKept)};
234
236 const auto& [lineSlope, deltaRWindow] = patternVisual.hitLineInfo.at(testHit);
237 drawLineResidual(*geoCtx, localToGlobalBucket, lines, patternVisual.seed, testHit, lineSlope, deltaRWindow, hitStatus, *canvas, view);
238 }
239
241 double yLegend{0.9};
242 auto printOnCanvas = [&lines, &yLegend](const std::string& text){
243 lines.push_back(drawLabel(text, 0.2, yLegend, 13));
244 yLegend-=0.03;
245 };
246
247 printOnCanvas(std::format("Seed hit: {}", m_idHelperSvc->toString(patternVisual.seed->identify())));
248 printOnCanvas(std::format("Chamber: {}", m_idHelperSvc->toStringChamber(bucket.front()->identify())));
249 printOnCanvas(std::format("nPrec: {:d}", pat.nPrecisionHits()));
250 printOnCanvas(std::format("nEtaNonPrec: {:d}", pat.nEtaNonPrecisionHits()));
251 printOnCanvas(std::format("nPhi: {:d}", pat.nPhiHits()));
252 printOnCanvas(std::format("theta: {:.2f}^{{#circ}}", inDegrees(pat.theta())));
253 printOnCanvas(std::format("phi: {:.2f}^{{#circ}}", inDegrees(pat.phi())));
254 printOnCanvas(std::format("TotalResidual: {:.2f}", pat.totalResidual()));
255 printOnCanvas(std::format("Status: {}", patStatus == PatternStatus::eSuccessful ? "Success" : (patStatus == PatternStatus::eFailed ? "Fail" : "Overlap")));
256 printOnCanvas(std::format("Sector: {:d}", pat.sector()));
257 printOnCanvas(std::format("OverlapSector: {:d}", pat.isSectorOverlap() ? pat.secondarySector() : -1));
258
260 bool drawnTrueLabel{true};
261 for (const xAOD::MuonSegment* segment : truthSegs) {
262 drawSegment(*segment, localToGlobalBucket, lines, drawnTrueLabel, *canvas, view);
263 paintSimHits(*geoCtx, localToGlobalBucket, *segment, lines, view);
264 }
265 canvas->add(std::move(lines));
266
267 std::string legendLabel = std::format("Event: {:}, chamber : {:}, #{:}-view ({:})",
268 ctx.eventID().event_number(),
269 bucket.msSector()->identString(),
270 view ==View::objViewEta ? "eta" : (view ==View::objViewPhi ? "phi" : (view == View::objViewZR ? "ZR" : "RZ")),
271 nameTag);
272 canvas->add(drawLabel(legendLabel, 0.15, 0.96));
273 }
static Double_t sp
bool barrel() const
Returns whether the sector is placed in the barrel.
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
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
unsigned int bucketId() const
Returns the Identifier in the context of the MuonChamber.
BooleanProperty m_paintSuccessfullPatterns
Switch to visualize successfull patterns.
BooleanProperty m_paintOverlapPatterns
Switch to visualize overlap patterns.
void paintSimHits(const ActsTrk::GeometryContext &gctx, const Amg::Transform3D &localToGlobalBucket, const xAOD::MuonSegment &truthSeg, PrimitiveVec &outputContainer, const View view) const
Paints the truth sim hits associated with the segment.
void drawSearchWindow(const Amg::Transform3D &localToGlobalBucket, PrimitiveVec &outputContainer, const double thetaMin, const double thetaMax, const Canvas_t &canvas, const View view) const
Draw the search window lines in the local frame expressed by the Transform3D for eta views and in the...
BooleanProperty m_displayOnlyWithPattern
Toggle to print pattern buckets only if they contain pattern hits.
BooleanProperty m_paintFailedPatterns
Switch to visualize failed patterns.
void drawLineResidual(const ActsTrk::GeometryContext &gctx, const Amg::Transform3D &localToGlobalBucket, PrimitiveVec &outputContainer, const MuonR4::SpacePoint *seed, const MuonR4::SpacePoint *testHit, const double lineSlope, const double Rwindow, const PatternHitVisualInfo::HitStatus status, const Canvas_t &canvas, const View view) const
Draw the pattern line and acceptance window for the testHit used during pattern building in the local...
void drawSegment(const xAOD::MuonSegment &segment, const Amg::Transform3D &localToGlobalBucket, PrimitiveVec &outputContainer, bool &drawnTrueLabel, const Canvas_t &canvas, const View view) const
Draw a segment on the canvas.
bool drawHits(const MuonR4::SpacePointBucket &bucket, const Amg::Transform3D &localToGlobalBucket, const std::vector< SpacePointType > &hitsToDraw, Canvas_t &canvasDim, const View view) const
Translates the Spacepoint information into TObjects that are dawn on the canvas & evaluates the size ...
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec
StIndex
enum to classify the different station layers in the muon spectrometer
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegment_v1 MuonSegment
Reference the current persistent version:

◆ plotPatternBuckets() [1/4]

void MuonValR4::FastRecoVisualizationTool::plotPatternBuckets ( const EventContext & ctx,
const std::string & extraLabel,
PatternHitVisualInfo && patternVisual ) const
finaloverridevirtual

Definition at line 126 of file FastRecoVisualizationTool.cxx.

128 {
129 PrimitiveVec primitives{};
130 plotPatternBuckets(ctx, extraLabel, std::move(patternVisual), std::move(primitives));
131 }
virtual void plotPatternBuckets(const EventContext &ctx, const std::string &extraLabel, PatternHitVisualInfoVec &&patternVisualVec) const override final

◆ plotPatternBuckets() [2/4]

void MuonValR4::FastRecoVisualizationTool::plotPatternBuckets ( const EventContext & ctx,
const std::string & extraLabel,
PatternHitVisualInfo && patternVisual,
PrimitiveVec && extraPaints ) const
finaloverridevirtual

Definition at line 133 of file FastRecoVisualizationTool.cxx.

136 {
137 for (const MuonR4::SpacePointBucket* bucket : patternVisual.parentBuckets) {
138 PatternHitVisualInfo patternVisualCopy {patternVisual};
139 PrimitiveVec extraPaintsCopy {clone(extraPaints)};
140 plotPatternBucket(ctx, extraLabel, *bucket, std::move(patternVisualCopy), std::move(extraPaintsCopy));
141 }
142 }
void plotPatternBucket(const EventContext &ctx, const std::string &extraLabel, const MuonR4::SpacePointBucket &bucket, PatternHitVisualInfo &&patternVisual, PrimitiveVec &&extraPaints) const
Plot a single pattern bucket.
std::vector< std::unique_ptr< TObject > > clone(const std::vector< std::unique_ptr< TObject > > &cloneMe)

◆ plotPatternBuckets() [3/4]

void MuonValR4::FastRecoVisualizationTool::plotPatternBuckets ( const EventContext & ctx,
const std::string & extraLabel,
PatternHitVisualInfoVec && patternVisualVec ) const
finaloverridevirtual

Definition at line 106 of file FastRecoVisualizationTool.cxx.

108 {
109 PrimitiveVec primitives{};
110 plotPatternBuckets(ctx, extraLabel, std::move(patternVisualVec), std::move(primitives));
111 }

◆ plotPatternBuckets() [4/4]

void MuonValR4::FastRecoVisualizationTool::plotPatternBuckets ( const EventContext & ctx,
const std::string & extraLabel,
PatternHitVisualInfoVec && patternVisualVec,
PrimitiveVec && extraPaints ) const
finaloverridevirtual

Loop over the pattern visual objects. We make a plot for every combination of bucket and pattern

Definition at line 112 of file FastRecoVisualizationTool.cxx.

115 {
116 if (patternVisualVec.empty()) {
117 ATH_MSG_VERBOSE("No pattern visual info available. Do not create visualization.");
118 return;
119 }
121 for (PatternHitVisualInfo& patVisual : patternVisualVec) {
122 PrimitiveVec primitivesCopy {clone(primitives)};
123 plotPatternBuckets(ctx, extraLabel, std::move(patVisual), std::move(primitivesCopy));
124 }
125 }
#define ATH_MSG_VERBOSE(x)

Member Data Documentation

◆ ATLAS_THREAD_SAFE

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

Flag toggling whether all Canvases have been exhausted.

Definition at line 247 of file FastRecoVisualizationTool.h.

247{false};

◆ m_canvasLimit

UnsignedIntegerProperty MuonValR4::FastRecoVisualizationTool::m_canvasLimit {this, "CanvasLimits", 5000}
private

Maximum canvases to draw.

Definition at line 200 of file FastRecoVisualizationTool.h.

200{this, "CanvasLimits", 5000};

◆ m_canvasPrefix

StringProperty MuonValR4::FastRecoVisualizationTool::m_canvasPrefix {this, "CanvasPreFix", ""}
private

Prefix of the individual canvas file names <MANDATORY>

Definition at line 206 of file FastRecoVisualizationTool.h.

206{this, "CanvasPreFix", ""};

◆ m_clientToken

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

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

Definition at line 198 of file FastRecoVisualizationTool.h.

198{};

◆ m_detMgr

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

pointer to the Detector manager

Definition at line 241 of file FastRecoVisualizationTool.h.

241{nullptr};

◆ m_displayOnlyTruth

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_displayOnlyTruth {this, "displayTruthOnly", false}
private

Toggle to print pattern buckets only if they contain truth hits.

Definition at line 236 of file FastRecoVisualizationTool.h.

236{this, "displayTruthOnly", false};

◆ m_displayOnlyWithPattern

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_displayOnlyWithPattern {this, "displayOnlyWithPattern", true}
private

Toggle to print pattern buckets only if they contain pattern hits.

Definition at line 238 of file FastRecoVisualizationTool.h.

238{this, "displayOnlyWithPattern", true};

◆ m_doEtaBucketViews

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_doEtaBucketViews {this,"doEtaBucketViews", true}
private

Switch to visualize the eta view of the bucket event.

Definition at line 210 of file FastRecoVisualizationTool.h.

210{this,"doEtaBucketViews", true};

◆ m_doPhiBucketViews

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_doPhiBucketViews {this,"doPhiBucketViews", false}
private

Switch to visualize the phi view of the bucket event.

Definition at line 212 of file FastRecoVisualizationTool.h.

212{this,"doPhiBucketViews", false};

◆ m_doRZBucketViews

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_doRZBucketViews {this,"doRZBucketViews", false}
private

Definition at line 213 of file FastRecoVisualizationTool.h.

213{this,"doRZBucketViews", false};

◆ m_geoCtxKey

SG::ReadHandleKey<ActsTrk::GeometryContext> MuonValR4::FastRecoVisualizationTool::m_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
private

Geometry context key to retrieve the alignment.

Definition at line 243 of file FastRecoVisualizationTool.h.

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

◆ m_idHelperSvc

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

Service Handle to the IMuonIdHelperSvc.

Definition at line 245 of file FastRecoVisualizationTool.h.

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

◆ m_paintFailedPatterns

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_paintFailedPatterns {this, "PaintFailedPatterns", false, "Toggle the display of failed patterns in the visualization"}
private

Switch to visualize failed patterns.

Definition at line 221 of file FastRecoVisualizationTool.h.

221{this, "PaintFailedPatterns", false, "Toggle the display of failed patterns in the visualization"};

◆ m_paintOverlapPatterns

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_paintOverlapPatterns {this, "PaintOverlapPatterns", false, "Toggle the display of overlap patterns in the visualization"}
private

Switch to visualize overlap patterns.

Definition at line 223 of file FastRecoVisualizationTool.h.

223{this, "PaintOverlapPatterns", false, "Toggle the display of overlap patterns in the visualization"};

◆ m_paintSuccessfullPatterns

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_paintSuccessfullPatterns {this, "PaintSuccessfullPatterns", true, "Toggle the display of successfully built patterns in the visualization"}
private

Switch to visualize successfull patterns.

Definition at line 219 of file FastRecoVisualizationTool.h.

219{this, "PaintSuccessfullPatterns", true, "Toggle the display of successfully built patterns in the visualization"};

◆ m_paintTruthHits

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_paintTruthHits {this, "paintTruthHits", false}
private

Switch to visualize the truth hits.

Definition at line 215 of file FastRecoVisualizationTool.h.

215{this, "paintTruthHits", false};

◆ m_paintTruthSegment

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_paintTruthSegment {this, "paintTruthSegment", false}
private

Switch to visualize the truth segment.

Definition at line 217 of file FastRecoVisualizationTool.h.

217{this, "paintTruthSegment", false};

◆ m_prepContainerKeys

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

Declare dependency on the prep data containers.

Definition at line 225 of file FastRecoVisualizationTool.h.

225{this, "PrdContainer", {}};

◆ m_saveSinglePDFs

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_saveSinglePDFs {this, "saveSinglePDFs", false}
private

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

Definition at line 202 of file FastRecoVisualizationTool.h.

202{this, "saveSinglePDFs", false};

◆ m_saveSummaryPDF

BooleanProperty MuonValR4::FastRecoVisualizationTool::m_saveSummaryPDF {this, "saveSummaryPDF", false}
private

If set to true a summary Canvas is created.

Definition at line 204 of file FastRecoVisualizationTool.h.

204{this, "saveSummaryPDF", false};

◆ m_subDir

StringProperty MuonValR4::FastRecoVisualizationTool::m_subDir {this, "outSubDir", ""}
private

Define the subdirectory in which the plots shall be saved.

Definition at line 208 of file FastRecoVisualizationTool.h.

208{this, "outSubDir", ""};

◆ m_truthLinkDecorKeys

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

Declaration of the dependency on the decorations.

(Overwritten in initialize)

Definition at line 229 of file FastRecoVisualizationTool.h.

229{this, "LinkDecorKeys", {}};

◆ m_truthLinkDecors

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

Definition at line 233 of file FastRecoVisualizationTool.h.

233{};

◆ m_truthSegLinks

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

List of truth segment links to fetch.

Definition at line 227 of file FastRecoVisualizationTool.h.

227{this, "TruthSegDecors", {}};

◆ m_visualSvc

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

Service handle of the visualization service.

Definition at line 196 of file FastRecoVisualizationTool.h.

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

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