ATLAS Offline Software
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 
25 using namespace Acts::PlanarHelper;
26 using namespace MuonR4;
27 using namespace Acts::UnitLiterals;
28 namespace 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()->localToGlobalTrans(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.};
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:{
126  if (meas->type() == xAOD::UncalibMeasType::RpcStripType) {
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  dY = 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
MuonR4::collectMeasurements
std::vector< const xAOD::UncalibratedMeasurement * > collectMeasurements(const Segment &seg, bool skipOutlier=true)
Helper function to extract the measurements from the segment.
Definition: TrackingHelpers.cxx:33
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
xAOD::RpcMeasurement_v1
RpcMeasurement_v1: Class storing the geneic.
Definition: RpcMeasurement_v1.h:21
UtilFunctions.h
xAOD::CombinedMuonStrip_v1::primaryStrip
const xAOD::UncalibratedMeasurement * primaryStrip() const
Returns the primary associated measurement.
Definition: CombinedMuonStrip_v1.cxx:27
xAOD::MuonSegment_v1::direction
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
Definition: MuonSegment_v1.cxx:18
xAOD::MMCluster_v1::localMeasurementPos
Amg::Vector3D localMeasurementPos() const
Returns the local measurement position as 3-vector.
Definition: MMCluster_v1.cxx:62
xAOD::MMCluster_v1
Definition: MMCluster_v1.h:20
MuonGMR4::SpectrometerSector::localToGlobalTrans
const Amg::Transform3D & localToGlobalTrans(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
Definition: SpectrometerSector.cxx:75
xAOD::TgcStrip_v1
Definition: TgcStrip_v1.h:19
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
MuonR4::Segment
Placeholder for what will later be the muon segment EDM representation.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:19
Amg::y
@ y
Definition: GeoPrimitives.h:35
xAOD::UncalibMeasType::MMClusterType
@ MMClusterType
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
xAOD::UncalibMeasType::sTgcStripType
@ sTgcStripType
MuonValR4::drawSegmentLine
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.
Definition: ObjVisualizationHelpers.cxx:46
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
xAOD::UncalibMeasType::TgcStripType
@ TgcStripType
MuonR4::detailedSegment
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
Definition: TrackingHelpers.cxx:22
xAOD::RpcMeasurement_v1::localMeasurementPos
Amg::Vector3D localMeasurementPos() const
Returns the local position of the measurement.
Definition: RpcMeasurement_v1.cxx:46
xAOD::MdtDriftCircle_v1::driftRadius
float driftRadius() const
Returns the drift radius.
Definition: MdtDriftCircle_v1.cxx:45
beamspotman.steps
int steps
Definition: beamspotman.py:501
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
xAOD::UncalibratedMeasurement_v1::type
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
MuonValR4::drawPropagation
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.
Definition: ObjVisualizationHelpers.cxx:29
Amg::x
@ x
Definition: GeoPrimitives.h:34
ObjVisualizationHelpers.h
xAOD::Other
@ Other
xAOD::UncalibratedMeasurement_v1::localCovariance
ConstMatrixMap< N > localCovariance() const
Returns the local covariance of the measurement.
ActsTrk::GeometryContext
Definition: GeometryContext.h:28
MuonR4::Segment::msSector
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:39
xAOD::UncalibratedMeasurement_v1::localPosition
ConstVectorMap< N > localPosition() const
Returns the local position of the measurement.
MdtDriftCircle.h
xAOD::UncalibratedMeasurement_v1::numDimensions
virtual unsigned int numDimensions() const =0
Returns the number of dimensions of the measurement.
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
xAOD::MuonSegment_v1::position
Amg::Vector3D position() const
Returns the position as Amg::Vector.
Definition: MuonSegment_v1.cxx:15
TrackingHelpers.h
TgcStrip.h
sTgcMeasurement.h
RpcMeasurement.h
MuonValR4::drawSegmentMeasurements
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.
Definition: ObjVisualizationHelpers.cxx:81
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
xAOD::muonSurface
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:68
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonValR4::drawBoundParameters
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.
Definition: ObjVisualizationHelpers.cxx:175
xAOD::CombinedMuonStrip_v1
The Acts fitters running on the Uncalibrated measurements are uncapable of producing two track states...
Definition: CombinedMuonStrip_v1.h:19
xAOD::sTgcMeasurement_v1::localMeasurementPos
Amg::Vector3D localMeasurementPos() const
Returns the local measurement position as 3-vector.
Definition: sTgcMeasurement_v1.cxx:41
re
const boost::regex re(r_e)
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
MMCluster.h
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
MuonValR4::drawMeasurement
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.
Definition: ObjVisualizationHelpers.cxx:90
xAOD::UncalibMeasType::RpcStripType
@ RpcStripType
xAOD::UncalibMeasType::MdtDriftCircleType
@ MdtDriftCircleType
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
MuonGMR4::TgcReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/TgcReadoutElement.h:19
xAOD::sTgcMeasurement_v1
Definition: sTgcMeasurement_v1.h:21
CombinedMuonStrip.h
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Amg::getTranslate3D
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Definition: GeoPrimitivesHelpers.h:289
ActsTrk::GeometryContext::context
Acts::GeometryContext context() const
Definition: GeometryContext.h:46