ATLAS Offline Software
Loading...
Searching...
No Matches
ObjVisualizationHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
7
14
15#include "Acts/Surfaces/detail/PlanarHelper.hpp"
16#include "Acts/Visualization/GeometryView3D.hpp"
17#include "Acts/Surfaces/StrawSurface.hpp"
18#include "Acts/Surfaces/LineBounds.hpp"
19#include "Acts/Surfaces/RectangleBounds.hpp"
20#include "Acts/Surfaces/TrapezoidBounds.hpp"
21#include "Acts/Surfaces/PlaneSurface.hpp"
22#include "Acts/Definitions/Units.hpp"
23
24
25using namespace Acts::PlanarHelper;
26using namespace MuonR4;
27using namespace Acts::UnitLiterals;
28namespace MuonValR4 {
29 void drawPropagation(const std::vector<Acts::detail::Step>& steps,
30 Acts::ObjVisualization3D& visualHelper,
31 const Acts::ViewConfig& viewConfig){
32
33 if (steps.empty()) {
34 return;
35 }
36 Amg::Vector3D start = steps.front().position;
37 for (std::size_t s = 1; s < steps.size(); ++s) {
38 Amg::Vector3D end = steps[s].position;
39 if ( (end - start).mag() > Acts::s_epsilon){
40 Acts::GeometryView3D::drawSegment(visualHelper, start, end, viewConfig);
41 start = std::move(end);
42 }
43
44 }
45 }
47 const xAOD::MuonSegment& segment,
48 Acts::ObjVisualization3D& visualHelper,
49 const Acts::ViewConfig& viewConfig ,
50 const double standardLength){
51
52 std::vector<const xAOD::UncalibratedMeasurement*> assocMeas = collectMeasurements(segment, false);
53 if (assocMeas.empty()){
54 Acts::GeometryView3D::drawSegment(visualHelper,
55 segment.position() - 0.5 * standardLength * segment.direction(),
56 segment.position() + 0.5 * standardLength * segment.direction(),
57 viewConfig);
58 return;
59 }
60 const xAOD::UncalibratedMeasurement* firstMeas = assocMeas.front()->type() != xAOD::UncalibMeasType::Other ?
61 assocMeas.front() : assocMeas[1];
62 const xAOD::UncalibratedMeasurement* lastMeas = assocMeas.back();
63
64 const Amg::Vector3D firstSurfPos = xAOD::muonSurface(firstMeas).center(gctx.context());
65 const Amg::Vector3D lastSurfPos = xAOD::muonSurface(lastMeas).center(gctx.context());
66
67 const Segment* detSeg = detailedSegment(segment);
69 const Amg::Vector3D planeNorm = detSeg->msSector()->localToGlobalTransform(gctx).linear().col(2);
71 const auto firstPlaneIsect = intersectPlane(segment.position(), segment.direction(),
72 planeNorm, firstSurfPos);
73 const auto lastPlaneIsect = intersectPlane(segment.position(), segment.direction(),
74 planeNorm, lastSurfPos);
75
76 Acts::GeometryView3D::drawSegment(visualHelper,
77 segment.position() + firstPlaneIsect.pathLength() * segment.direction(),
78 segment.position() + lastPlaneIsect.pathLength() * segment.direction(),
79 viewConfig);
80 }
82 const xAOD::MuonSegment& segment,
83 Acts::ObjVisualization3D& visualHelper,
84 const Acts::ViewConfig& viewConfig) {
85 std::vector<const xAOD::UncalibratedMeasurement*> assocMeas = collectMeasurements(segment, false);
86 for (const xAOD::UncalibratedMeasurement* meas : assocMeas){
87 drawMeasurement(gctx, meas, visualHelper, viewConfig);
88 }
89 }
92 Acts::ObjVisualization3D& visualHelper,
93 const Acts::ViewConfig& viewConfig) {
94
95 const Acts::Surface& surf = xAOD::muonSurface(meas);
96 const Acts::GeometryContext tgContext = gctx.context();
97 const auto& bounds = surf.bounds();
99 const auto& lBounds = static_cast<const Acts::LineBounds&>(bounds);
100 const auto* driftCirc = static_cast<const xAOD::MdtDriftCircle*>(meas);
101 const double dR = driftCirc->driftRadius();
102 const double hZ = driftCirc->numDimensions() == 1 ?
103 lBounds.get(Acts::LineBounds::eHalfLengthZ) :
104 std::sqrt(meas->localCovariance<2>()(1,1));
105 auto newBounds = std::make_unique<Acts::LineBounds>(dR, hZ);
106 auto dummySurface = Acts::Surface::makeShared<Acts::StrawSurface>(surf.transform(tgContext)*
107 Amg::getTranslate3D(driftCirc->localMeasurementPos()),
108 std::move(newBounds));
109 Acts::GeometryView3D::drawSurface(visualHelper, *dummySurface, tgContext,
110 Amg::Transform3D::Identity(), viewConfig);
111 return;
112 }
113 double dX{0.}, dY{0.};
114 Amg::Vector3D locPos{Amg::Vector3D::Zero()};
115 switch (meas->numDimensions()) {
117 case 0:{
118 const auto* cmbMeas = static_cast<const xAOD::CombinedMuonStrip*>(meas);
119 locPos[Amg::x] = cmbMeas->primaryStrip()->localPosition<1>()[0];
120 locPos[Amg::y] = cmbMeas->secondaryStrip()->localPosition<1>()[0];
121 dX = std::sqrt(cmbMeas->primaryStrip()->localCovariance<1>()(0,0));
122 dY = std::sqrt(cmbMeas->secondaryStrip()->localCovariance<1>()(0,0));
123 break;
124 } case 1:{
127 const auto* rpcClus = static_cast<const xAOD::RpcMeasurement*>(meas);
128 locPos = rpcClus->localMeasurementPos();
129 dX = rpcClus->measuresPhi() ? 0.5* rpcClus->readoutElement()->stripPhiLength()
130 : std::sqrt(rpcClus->localCovariance<1>()(0,0));
131 dY = rpcClus->measuresPhi() ? std::sqrt(rpcClus->localCovariance<1>()(0,0))
132 : 0.5* rpcClus->readoutElement()->stripEtaLength();
133 } else if (meas->type() == xAOD::UncalibMeasType::TgcStripType) {
134 const auto* tgcClus = static_cast<const xAOD::TgcStrip*>(meas);
135 const MuonGMR4::TgcReadoutElement* re = tgcClus->readoutElement();
136 const auto& stripLay = re->sensorLayout(tgcClus->measurementHash());
137 locPos = tgcClus->localMeasurementPos();
138 dX = tgcClus->measuresPhi() ? 0.5* stripLay->design(true).stripLength(tgcClus->channelNumber())
139 : std::sqrt(tgcClus->localCovariance<1>()(0,0));
140 dY = tgcClus->measuresPhi() ? std::sqrt(tgcClus->localCovariance<1>()(0,0))
141 : 0.5* stripLay->design(false).stripLength(tgcClus->channelNumber());
142 } else if (meas->type() == xAOD::UncalibMeasType::MMClusterType) {
143 const auto* mmClust = static_cast<const xAOD::MMCluster*>(meas);
144 locPos = mmClust->localMeasurementPos();
145 dX = std::sqrt(mmClust->localCovariance<1>()(0,0));
146 dY = 0.5* mmClust->readoutElement()->stripLength(mmClust->measurementHash());
147 } else if(meas->type() == xAOD::UncalibMeasType::sTgcStripType) {
148 const auto* sTgcClus = static_cast<const xAOD::sTgcMeasurement*>(meas);
149 locPos = sTgcClus->localMeasurementPos();
150 if (sTgcClus->channelType() == sTgcIdHelper::sTgcChannelTypes::Strip){
151 dX = std::sqrt(sTgcClus->localCovariance<1>()(0,0));
152 dY = 0.5* sTgcClus->readoutElement()->stripDesign(sTgcClus->measurementHash()).stripLength(sTgcClus->channelNumber());
153 } else if (sTgcClus->channelType() == sTgcIdHelper::sTgcChannelTypes::Wire) {
154 dY = std::sqrt(sTgcClus->localCovariance<1>()(0,0));
155 dX = 0.5*sTgcClus->readoutElement()->wireDesign(sTgcClus->measurementHash()).stripLength(sTgcClus->channelNumber());
156 }
157 }
158 break;
159 }
161 case 2:{
162 locPos.block<2,1>(0, 0) = xAOD::toEigen(meas->localPosition<2>());
163 dX = std::sqrt(meas->localCovariance<2>()(0,0));
164 dY = std::sqrt(meas->localCovariance<2>()(1,1));
165 break;
166 }
167 }
168 auto newBounds = std::make_unique<Acts::RectangleBounds>(dX, dY);
169 auto dummySurf = Acts::Surface::makeShared<Acts::PlaneSurface>(surf.transform(tgContext)*
170 Amg::getTranslate3D(locPos),
171 std::move(newBounds));
172 Acts::GeometryView3D::drawSurface(visualHelper, *dummySurf, tgContext,
173 Amg::Transform3D::Identity(), viewConfig);
174 }
176 const Acts::BoundTrackParameters& pars,
177 Acts::ObjVisualization3D& visualHelper,
178 const Acts::ViewConfig& viewConfig,
179 const double standardLength){
180 const Amg::Vector3D globPos = pars.position(gctx.context());
181 const Amg::Vector3D start = globPos - 0.5 * standardLength * pars.direction();
182 const Amg::Vector3D end = globPos + 0.5 * standardLength * pars.direction();
183 Acts::GeometryView3D::drawSegment(visualHelper, start, end, viewConfig);
184 }
185
186
187} // namespace MuonValR4
const boost::regex re(r_e)
Scalar mag() const
mag method
Acts::GeometryContext context() const
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
Placeholder for what will later be the muon segment EDM representation.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
ConstMatrixMap< N > localCovariance() const
Returns the local covariance of the measurement.
ConstVectorMap< N > localPosition() const
Returns the local position of the measurement.
virtual unsigned int numDimensions() const =0
Returns the number of dimensions of the measurement.
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
std::vector< const xAOD::UncalibratedMeasurement * > collectMeasurements(const xAOD::MuonSegment &segment, bool skipOutlier=true)
Helper function to extract the measurements from the segment.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
void drawBoundParameters(const ActsTrk::GeometryContext &gctx, const Acts::BoundTrackParameters &pars, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=3.*Gaudi::Units::cm)
Draw a line representing the bound track parameters.
void drawPropagation(const std::vector< Acts::detail::Step > &steps, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine)
Draws the recorded propagation steps as a polygon line.
void drawMeasurement(const ActsTrk::GeometryContext &gctx, const xAOD::UncalibratedMeasurement *meas, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw an uncalibrated measurement inside the obj file.
void drawSegmentMeasurements(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
void drawSegmentLine(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=1.*Gaudi::Units::m)
Draw a segment line inside the obj file.
MdtDriftCircle_v1 MdtDriftCircle
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.
RpcMeasurement_v1 RpcMeasurement
MMCluster_v1 MMCluster
sTgcMeasurement_v1 sTgcMeasurement
MuonSegment_v1 MuonSegment
Reference the current persistent version:
CombinedMuonStrip_v1 CombinedMuonStrip
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.