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

#include <TrackVisualizationTool.h>

Inheritance diagram for MuonValR4::TrackVisualizationTool:
Collaboration diagram for MuonValR4::TrackVisualizationTool:

Classes

struct  PlotLegend
 Helper struct to administer the markers & colors that are added to the legend. More...

Public Member Functions

virtual ~TrackVisualizationTool ()=default
 Destructor.
virtual StatusCode initialize () override final
virtual void displaySeeds (const EventContext &ctx, const MuonR4::MsTrackSeedContainer &seeds) const override final
 Displays all segments on the representative cylinder in the R-Z & X-Y plane and draws the markers of the successfully built seeds & truth segments.
virtual void displaySeeds (const EventContext &ctx, const MuonR4::MsTrackSeedContainer &seeds, PrimitivesVec_t &&extPrimitives) const override final
 Displays all segments on the representative cylinder in the R-Z & X-Y plane and draws the markers of the successfully built seeds & truth segments.
virtual void displayTrackSeedObj (const EventContext &ctx, const MuonR4::MsTrackSeed &seed, const OptBoundPars_t &parsToExt, const std::string &objName="") const override final
 Visualizes the measurements of the segments on the track seed together with their predicted local line parameters as an obj file.

Private Types

enum class  DisplayView { RZ , XY }
 Enumeration to toggle whether the seeds shall be painted in x-y or R-z view. More...
using Canvas_t = IRootVisualizationService::ICanvasObject
using Edges = Canvas_t::AxisRanges
using Location = MuonR4::MsTrackSeed::Location
 Enumeration to toggle whether the segment shall displayed on the barrel/endcap.

Private Member Functions

void displaySeeds (const EventContext &ctx, const DisplayView view, const xAOD::MuonSegmentContainer &segments, const MuonR4::MsTrackSeedContainer &seeds, PrimitivesVec_t &&extPrimitives) const
 Actual implementation of the display seeds method with the augmentation to define the view.
void fillTruthSeedPoints (const EventContext &ctx, const DisplayView view, PlotLegend &legend, Canvas_t &canvas) const
 Add the truth segments to the canvas.
void displaySeedSegmentsGlobalWithTruth (const EventContext &ctx, const DisplayView view, const MuonR4::MsTrackSeedContainer &seeds) const

Static Private Member Functions

static Amg::Vector2D viewVector (const double phi, const Amg::Vector2D &posOnCylinder, const DisplayView view)
 Transforms the projected vector into the actual view, if it's xy then an external phi is needed to place the marker.

Private Attributes

ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool {this, "ExtrapolationTool" ,"" }
 Track extrapolation tool.
ServiceHandle< IRootVisualizationService > m_visualSvc {this, "VisualSvc", "MuonValR4::RootVisualizationService"}
 Service handle of the visualization service.
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc {this, "TrackingGeometrySvc", "ActsTrackingGeometrySvc"}
 Service handle to the tracking geometry service.
IRootVisualizationService::ClientToken m_clientToken {}
 Token to present to the visualization service such that the display froms this tool are grouped together.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_truthSegKey {this, "TruthSegkey", "MuonTruthSegments"}
 Key to the truth segment selection to draw the segment parameters.
ToolHandle< MuonR4::ITrackSeedingDiagnosticsTool > m_seedingTool {this, "SeedingTool", ""}
 The track seeding tool to construct the seed candidates and to estimate the initial parameters.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey {this, "SegmentContainer", "MuonSegmentsFromR4" }
 Declare the data dependency on the standard Mdt+Rpc+Tgc segment container & on the NSW segment container.
ActsTrk::ContextUtility m_contextProvider {this}
 Dependency on the geometry alignment.
Gaudi::Property< unsigned > m_canvasLimit {this, "CanvasLimit", 5000}
 Maximum canvases to draw.
Gaudi::Property< bool > m_saveSinglePDFs {this, "saveSinglePDFs", true}
 If set to true each canvas is saved into a dedicated pdf file.
Gaudi::Property< bool > m_saveSummaryPDF {this, "saveSummaryPDF", true}
 If set to true a summary Canvas is created.
Gaudi::Property< std::string > m_subDir {this, "outSubDir", ""}
 Define the subdirectory in which the plots shall be saved.
Gaudi::Property< std::string > m_canvasPrefix {this, "CanvasPreFix", "MsTrackValid"}
 Prefix of the individual canvas file names <MANDATORY>.
std::atomic< bool > m_plotsDone {false}
 Flag toggling whether all Canvases have been exhausted.
std::atomic< unsigned > m_objCounter {0}
 How many obj have been produced.

Detailed Description

Definition at line 22 of file TrackVisualizationTool.h.

Member Typedef Documentation

◆ Canvas_t

◆ Edges

◆ Location

Enumeration to toggle whether the segment shall displayed on the barrel/endcap.

Definition at line 73 of file TrackVisualizationTool.h.

Member Enumeration Documentation

◆ DisplayView

Enumeration to toggle whether the seeds shall be painted in x-y or R-z view.

Enumerator
RZ 
XY 

Definition at line 75 of file TrackVisualizationTool.h.

75{RZ, XY};

Constructor & Destructor Documentation

◆ ~TrackVisualizationTool()

virtual MuonValR4::TrackVisualizationTool::~TrackVisualizationTool ( )
virtualdefault

Destructor.

Member Function Documentation

◆ displaySeeds() [1/3]

void MuonValR4::TrackVisualizationTool::displaySeeds ( const EventContext & ctx,
const DisplayView view,
const xAOD::MuonSegmentContainer & segments,
const MuonR4::MsTrackSeedContainer & seeds,
PrimitivesVec_t && extPrimitives ) const
private

Actual implementation of the display seeds method with the augmentation to define the view.

Parameters
ctxEventContext to access store gate & conditions
viewActual view to display
segmentsContainer of all MS segments in the event
seedsThe constructed track seeds from the event
extPrimitivesExtra TObjects that should be additionally painted onto the Canvases

First add the truth points

Draw the sector map

Definition at line 303 of file TrackVisualizationTool.cxx.

307 {
308
309 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, std::format("SeedDisplay{:}",
310 view == DisplayView::XY ? "XY" : "RZ" ));
311
312 if (!canvas) {
313 m_plotsDone = true;
314 return;
315 }
316 canvas->setAxisTitles(view == DisplayView::XY ? "x [m]" : "z [m]",
317 view == DisplayView::XY ? "y [m]" : "R [m]");
318
319 PlotLegend legend{0.005,0.005, 0.6,0.1};
321 fillTruthSeedPoints(ctx, view, legend, *canvas);
322
323 auto onSeed = [&seeds](const xAOD::MuonSegment* segment,
324 const Location loc) {
325 return std::ranges::any_of(seeds,[segment, loc](const MsTrackSeed& seed){
326 return seed.location() == loc && std::ranges::find(seed.segments(), segment) != seed.segments().end();
327 });
328 };
329
330 const Acts::GeometryContext tgContext = m_contextProvider.getGeometryContext(ctx);
331 bool drawnPoint{false};
332
333 for (const xAOD::MuonSegment* segment: segments) {
334 using enum Location;
336 using namespace Muon;
337 const MuonGMR4::SpectrometerSector* msSector = detailedSegment(*segment)->msSector();
338 const auto chIdx = segment->chamberIndex();
339 const int mColor = msSector->barrel() ? ColorBarrel : (msSector->side() > 0 ? ColorEndcapA : ColorEndcapC);
340
341 for (const auto secProj : {leftOverlap, center, rightOverlap}) {
342 const ExpandedSector sector{static_cast<unsigned>(segment->sector()), secProj};
343 if (ExpandedSector{segment->position().phi()} != sector){
344 continue;
345 }
346
347 for (const Location loc : {Barrel, Endcap}) {
348 const Amg::Vector2D projPos{m_seedingTool->expressOnCylinder(tgContext, *segment, loc, sector)};
349 if (!m_seedingTool->withinBounds(projPos, loc)) {
350 continue;
351 }
352 drawnPoint = true;
353 const bool isGood = onSeed(segment, loc);
354 const int mStyle = stationMarkerSyle(chIdx, true, isGood);
355 const Amg::Vector2D markerPos{viewVector(sector.phi(), projPos, view)};
356 extPrimitives.emplace_back( drawMarker(markerPos, mStyle, mColor)); //Is this necessary?
357 canvas->add( drawMarker(markerPos, mStyle, mColor));
358
359 if (view == DisplayView::XY) {
360 const double r = markerPos.mag() + extraMargin;
361 canvas->expandPad(r, r);
362 canvas->expandPad(-r, -r);
363 } else {
364 canvas->expandPad(markerPos[0] - extraMargin, markerPos[1] - extraMargin);
365 canvas->expandPad(markerPos[0] + extraMargin, markerPos[1] + extraMargin);
366 }
367 legend.addMarker(mStyle, std::format("{:}{:}", MuonStationIndex::layerName(MuonStationIndex::toLayerIndex(chIdx)),
368 isGood ? "" : " (discarded)"), mColor);
369 legend.addColor(mColor, msSector->barrel() ? "Barrel" : msSector->side() > 0 ? "Endcap A" : "Endcap C");
370 }
371 }
372 }
373 if (!drawnPoint) {
374 canvas->trash();
375 return;
376 }
377 for (const MsTrackSeed& seed : seeds) {
378 const Amg::Vector3D& pos{seed.position()};
379 canvas->add(drawMarker(viewVector(pos.phi(), Amg::Vector2D{pos.perp(), pos.z()}, view),
380 kFullDiamond, kBlack));
381 legend.addMarker(kFullDiamond, "track seed");
382 }
384 for (unsigned int s = 1; s<=16 ; ++s) {
385 if (view != DisplayView::XY) {
386 break;
387 }
388 const double phi = sectorMap.sectorPhi(s);
389 const double dPhi = sectorMap.sectorWidth(s);
390
391 const int lStyle = s%2 ? kDashed : kDotted;
392 const double r = canvas->corner(Edges::xHigh);
393 const CxxUtils::sincos phiM{phi-dPhi}, phiP{phi+dPhi};
394 const Amg::Vector2D e1{r * phiM.cs, r * phiM.sn};
395 const Amg::Vector2D e2{r * phiP.cs, r * phiP.sn};
396
397 auto theLine = std::make_unique<TLine>(0.,0., e1.x(), e1.y());
398 theLine->SetLineStyle(lStyle);
399 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
400 theLine = std::make_unique<TLine>(0.,0., e2.x(), e2.y());
401 theLine->SetLineStyle(lStyle);
402 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
403 theLine = std::make_unique<TLine>(e1.x(), e1.y(), e2.x(), e2.y());
404 theLine->SetLineStyle(lStyle);
405 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
406 }
407 legend.fillPrimitives(*canvas);
408 }
Scalar phi() const
phi method
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
bool barrel() const
Returns whether the sector is placed in the barrel.
double phi() const
Returns the phi angle of the expanded sector.
SectorProjector
Enumeration to select the sector projection of the regular MS sector.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
void fillTruthSeedPoints(const EventContext &ctx, const DisplayView view, PlotLegend &legend, Canvas_t &canvas) const
Add the truth segments to the canvas.
ServiceHandle< IRootVisualizationService > m_visualSvc
Service handle of the visualization service.
std::atomic< bool > m_plotsDone
Flag toggling whether all Canvases have been exhausted.
IRootVisualizationService::ClientToken m_clientToken
Token to present to the visualization service such that the display froms this tool are grouped toget...
static Amg::Vector2D viewVector(const double phi, const Amg::Vector2D &posOnCylinder, const DisplayView view)
Transforms the projected vector into the actual view, if it's xy then an external phi is needed to pl...
ActsTrk::ContextUtility m_contextProvider
Dependency on the geometry alignment.
ToolHandle< MuonR4::ITrackSeedingDiagnosticsTool > m_seedingTool
The track seeding tool to construct the seed candidates and to estimate the initial parameters.
MuonR4::MsTrackSeed::Location Location
Enumeration to toggle whether the segment shall displayed on the barrel/endcap.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int r
Definition globals.cxx:22
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
@ Endcap
Definition DetType.h:14
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
Muon_v1 Muon
Reference the current persistent version:
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Helper struct to administer the markers & colors that are added to the legend.

◆ displaySeeds() [2/3]

void MuonValR4::TrackVisualizationTool::displaySeeds ( const EventContext & ctx,
const MuonR4::MsTrackSeedContainer & seeds ) const
finaloverridevirtual

Displays all segments on the representative cylinder in the R-Z & X-Y plane and draws the markers of the successfully built seeds & truth segments.

Parameters
ctxEventContext to access store gate & conditions
seedsThe constructed track seeds from the event

Definition at line 153 of file TrackVisualizationTool.cxx.

154 {
155 displaySeeds(ctx, seeds, PrimitivesVec_t{});
156 }
virtual void displaySeeds(const EventContext &ctx, const MuonR4::MsTrackSeedContainer &seeds) const override final
Displays all segments on the representative cylinder in the R-Z & X-Y plane and draws the markers of ...

◆ displaySeeds() [3/3]

void MuonValR4::TrackVisualizationTool::displaySeeds ( const EventContext & ctx,
const MuonR4::MsTrackSeedContainer & seeds,
PrimitivesVec_t && extPrimitives ) const
finaloverridevirtual

Displays all segments on the representative cylinder in the R-Z & X-Y plane and draws the markers of the successfully built seeds & truth segments.

Parameters
ctxEventContext to access store gate & conditions
seedsThe constructed track seeds from the event

Definition at line 157 of file TrackVisualizationTool.cxx.

159 {
160
161
162 const xAOD::MuonSegmentContainer* segments{nullptr};
163 if (m_plotsDone || !SG::get(segments, m_segmentKey, ctx) || segments->empty()) {
164 return;
165 }
166
167 displaySeeds(ctx, DisplayView::RZ, *segments, seeds, clone(extPrimitives));
168 displaySeeds(ctx, DisplayView::XY, *segments, seeds, std::move(extPrimitives));
169
170 //For each seed plot respective segment parameters
171
174
175 }
bool empty() const noexcept
Returns true if the collection is empty.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Declare the data dependency on the standard Mdt+Rpc+Tgc segment container & on the NSW segment contai...
void displaySeedSegmentsGlobalWithTruth(const EventContext &ctx, const DisplayView view, const MuonR4::MsTrackSeedContainer &seeds) const
std::vector< std::unique_ptr< TObject > > clone(const std::vector< std::unique_ptr< TObject > > &cloneMe)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".

◆ displaySeedSegmentsGlobalWithTruth()

void MuonValR4::TrackVisualizationTool::displaySeedSegmentsGlobalWithTruth ( const EventContext & ctx,
const DisplayView view,
const MuonR4::MsTrackSeedContainer & seeds ) const
private

Definition at line 177 of file TrackVisualizationTool.cxx.

180 {
181
182 auto canvas = m_visualSvc->prepareCanvas(
183 ctx, m_clientToken,
184 std::format("SeedSegsGlobalTruth{:}", view == DisplayView::XY ? "XY" : "RZ"));
185
186 if (!canvas) { m_plotsDone = true; return; }
187
188 canvas->setAxisTitles(view == DisplayView::XY ? "x [m]" : "z [m]",
189 view == DisplayView::XY ? "y [m]" : "R [m]");
190
191 PlotLegend legend{0.005, 0.005, 0.6, 0.1};
192
193 PrimitivesVec_t primitives{};
194 bool drewAny{false};
195
196 // -----------------------
197 // (A) Draw TRUTH segments
198 // -----------------------
199 const xAOD::MuonSegmentContainer* truthSegs{nullptr};
200 if (!SG::get(truthSegs, m_truthSegKey, ctx).isSuccess()) {
201 THROW_EXCEPTION("Failed to fetch the truth segment container");
202 }
203 if (truthSegs) {
204 for (const xAOD::MuonSegment* seg : *truthSegs) {
205 if (!seg) continue;
206
207 // Same station-based marker, but OPEN marker to visually separate truth vs reco
208 const auto chIdx = seg->chamberIndex();
209 const int mStyleTruth = stationMarkerSyle(chIdx, /*openMarker=*/true, /*onSeed=*/true);
210
211 const Amg::Vector3D p = seg->position();
212 const double x = p.x() * inM;
213 const double y = p.y() * inM;
214 const double z = p.z() * inM;
215 const double r = std::hypot(x, y);
216 const Amg::Vector2D plotPos =
218 : Amg::Vector2D{z, r};
219 primitives.emplace_back(drawMarker(plotPos, mStyleTruth, truthColor, /*mSize=*/3));
220
221 //Plot direction of the segment as well
222 const double dir_x = seg->direction().x() * inM;
223 const double dir_y = seg->direction().y() * inM;
224 const double dir_z = seg->direction().z() * inM;
225 const Amg::Vector2D plotDir =
226 (view == DisplayView::XY) ? Amg::Vector2D{dir_x, dir_y}
227 : Amg::Vector2D{dir_z, std::hypot(dir_x, dir_y)};
228 primitives.emplace_back(drawArrow2D(plotPos, plotDir, truthColor));
229
230
231 legend.addMarker(
232 mStyleTruth,
233 std::string(Muon::MuonStationIndex::layerName(Muon::MuonStationIndex::toLayerIndex(chIdx))) + " (truth)", truthColor);
234
235 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
236 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
237 drewAny = true;
238 }
239 }
240
241 // ---------------------------------
242 // (B) Draw RECO seed-associated segs
243 // ---------------------------------
244 for (std::size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
245 const MsTrackSeed& seed = seeds[iSeed];
246 const int color = seedColorIdx(iSeed);
247
248 std::string seedLabel = std::format("s{:d}: ", static_cast<int>(iSeed));
249
250 for (const xAOD::MuonSegment* seg : seed.segments()) {
251 if (!seg) continue;
252
253 const auto chIdx = seg->chamberIndex();
254 const int mStyle = stationMarkerSyle(chIdx, /*openMarker=*/false, /*onSeed=*/true);
255
256 const Amg::Vector3D p = seg->position();
257 const double x = p.x() * inM;
258 const double y = p.y() * inM;
259 const double z = p.z() * inM;
260 const double r = std::hypot(x, y);
261 const Amg::Vector2D plotPos =
263 : Amg::Vector2D{z, r};
264
265 primitives.emplace_back(drawMarker(plotPos, mStyle, color));
266
267 //Plot direction of the segment as well
268 const double dir_x = seg->direction().x() * inM;
269 const double dir_y = seg->direction().y() * inM;
270 const double dir_z = seg->direction().z() * inM;
271 const Amg::Vector2D plotDir =
272 (view == DisplayView::XY) ? Amg::Vector2D{dir_x, dir_y}
273 : Amg::Vector2D{dir_z, std::hypot(dir_x, dir_y)};
274 primitives.emplace_back(drawArrow2D(plotPos, plotDir, color));
275
276 std::string label = printID(*seg);
277 seedLabel += label + "_";
278
279 primitives.emplace_back(MuonValR4::drawLabel(label, plotPos.x() + 0.01, plotPos.y() + 0.01, 10, false, color));
280
281 // Marker legend: only one entry per station style (PlotLegend dedups)
282 legend.addMarker(
283 mStyle,
285
286 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
287 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
288 drewAny = true;
289 }
290 //Add text which shows segment names associated to the respective seeed
291 primitives.emplace_back(MuonValR4::drawLabel(seedLabel, 0.15, 0.9 - (0.03*iSeed), 10, true, color));
292 }
293
294 if (!drewAny) { canvas->trash(); return; }
295
296 for (auto& p : primitives) canvas->add(std::move(p));
297 legend.fillPrimitives(*canvas);
298}
#define y
#define x
#define z
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_truthSegKey
Key to the truth segment selection to draw the segment parameters.
std::string label(const std::string &format, int i)
Definition label.h:19
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
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,.
int seedColorIdx(std::size_t iSeed)
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
LayerIndex toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ displayTrackSeedObj()

void MuonValR4::TrackVisualizationTool::displayTrackSeedObj ( const EventContext & ctx,
const MuonR4::MsTrackSeed & seed,
const OptBoundPars_t & parsToExt,
const std::string & objName = "" ) const
finaloverridevirtual

Visualizes the measurements of the segments on the track seed together with their predicted local line parameters as an obj file.

If parameters to extrapolate are parsed, then they're extrapolated to the end of the world and the trajectory is added to the obj

Parameters
ctxEventContext to fetch the conditions data & the event information
seedMsTrack to visualize
parsToExtParameters to extrapolate on top
objNameExtra token to be added to the file name

Definition at line 443 of file TrackVisualizationTool.cxx.

446 {
448 return;
449 }
450 const Acts::GeometryContext tgContext = m_contextProvider.getGeometryContext(ctx);
451 Acts::ObjVisualization3D visualHelper{};
452 const std::string subDir = std::format("./ObjDisplays/{:}/", m_subDir.value());
453 ensureDirectory(subDir);
454
455 std::string segStr{removeNonAlphaNum(objName)};
456 std::unordered_set<Acts::GeometryIdentifier> surfaceIds{};
457 for (const xAOD::MuonSegment* seg : seed.segments()) {
458 for (unsigned m = 0 ; m < nMeasurements(*seg) ; ++m) {
459 surfaceIds.insert(xAOD::muonSurface(getMeasurement(*seg,m)).geometryId());
460 }
461 MuonValR4::drawSegmentMeasurements(tgContext,* seg, visualHelper);
462 MuonValR4::drawSegmentLine(tgContext, *seg, visualHelper);
463 segStr += std::format("_{:}", MuonR4::printID(*seg));
464 }
465
466 if (parsToExt.ok() && m_extrapolationTool.isEnabled()) {
467 auto stepsResult = m_extrapolationTool->propagationSteps(ctx, *parsToExt);
468 if (stepsResult.ok()) {
469 const auto* vol = m_trackingGeometrySvc->trackingGeometry()->highestTrackingVolume();
470
471 auto [begin, end] = std::ranges::remove_if(stepsResult->first,
472 [vol](const Acts::detail::Step& step) {
473 return !vol->volumeBounds().inside(step.position);
474 });
475 stepsResult->first.erase(begin, end);
476 for (const Acts::detail::Step& step: stepsResult->first) {
477 if (!step.surface || surfaceIds.count(step.surface->geometryId())) {
478 continue;
479 }
480 Acts::GeometryView3D::drawSurface(visualHelper, *step.surface, tgContext,
481 Amg::Transform3D::Identity(), Acts::s_viewPassive);
482 }
483 MuonValR4::drawPropagation(stepsResult->first, visualHelper);
484 } else {
485 ATH_MSG_WARNING("Failed to extrapolate the seed for visualization: " << stepsResult.error().message());
486 }
487 }
488
489 unsigned fileVersion{0};
490 std::string finalStr{};
491 while (finalStr.empty() || std::filesystem::exists(finalStr)) {
492 finalStr = std::format("{:}/{:}_{:}_{:}_{:}.obj", subDir,
493 m_clientToken.preFixName, ctx.eventID().event_number(), ++fileVersion, segStr);
494 }
495 visualHelper.write(finalStr);
496 ++m_objCounter;
497 }
#define ATH_MSG_WARNING(x,...)
Gaudi::Property< unsigned > m_canvasLimit
Maximum canvases to draw.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
std::atomic< unsigned > m_objCounter
How many obj have been produced.
Gaudi::Property< std::string > m_subDir
Define the subdirectory in which the plots shall be saved.
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Service handle to the tracking geometry service.
const xAOD::UncalibratedMeasurement * getMeasurement(const xAOD::MuonSegment &segment, const std::size_t n)
Returns the n-th uncalibrated measurement.
std::size_t nMeasurements(const xAOD::MuonSegment &segment)
Returns the number of associated Uncalibrated measurements.
void ensureDirectory(const std::string &path)
Ensures that the subdirectory in the path is created.
void drawSegmentMeasurements(const Acts::GeometryContext &tgContext, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
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 drawSegmentLine(const Acts::GeometryContext &tgContext, 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.
std::string removeNonAlphaNum(std::string str)
Removes all non-alpha numerical characters from a string.
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.

◆ fillTruthSeedPoints()

void MuonValR4::TrackVisualizationTool::fillTruthSeedPoints ( const EventContext & ctx,
const DisplayView view,
PlotLegend & legend,
Canvas_t & canvas ) const
private

Add the truth segments to the canvas.

Parameters
ctxEventContext to access store gate
viewActual view to display
legendReference to the legend object to add the marker / truth legends
canvasReference to the canvas to which the drawn markers are appended to

Definition at line 409 of file TrackVisualizationTool.cxx.

412 {
413 const xAOD::MuonSegmentContainer* truthSegs{nullptr};
414 if (!SG::get(truthSegs,m_truthSegKey, ctx).isSuccess()) {
415 THROW_EXCEPTION("Failed to fetch the truth segment container");
416 }
417 if (!truthSegs) {
418 return;
419 }
420 const Acts::GeometryContext tgContext = m_contextProvider.getGeometryContext(ctx);
421 bool addedEntry{false};
422 for (const xAOD::MuonSegment* segment: *truthSegs) {
423 const auto chIdx = segment->chamberIndex();
424 const int mStyle = stationMarkerSyle(chIdx, true, true);
425
426 using enum Location;
428 ExpandedSector sector{segment->position().phi()};
429 for (const Location loc : {Barrel, Endcap}) {
430 const Amg::Vector2D projected{m_seedingTool->expressOnCylinder(tgContext, *segment, loc, sector)};
431 if (!m_seedingTool->withinBounds(projected, loc)) {
432 continue;
433 }
434 canvas.add(drawMarker(viewVector(sector.phi(), projected, view), mStyle, truthColor, 3));
436 addedEntry = true;
437 }
438 }
439 if (addedEntry) {
440 legend.addColor(truthColor, "truth");
441 }
442 }

◆ initialize()

StatusCode MuonValR4::TrackVisualizationTool::initialize ( )
finaloverridevirtual

Definition at line 133 of file TrackVisualizationTool.cxx.

133 {
134 if (m_canvasLimit > 0) {
135 m_clientToken.canvasLimit = m_canvasLimit;
136 m_clientToken.preFixName = m_canvasPrefix;
137 m_clientToken.saveSinglePlots = m_saveSinglePDFs;
138 m_clientToken.saveSummaryPlot = m_saveSummaryPDF;
139 m_clientToken.subDirectory = m_subDir;
140 ATH_CHECK(m_visualSvc.retrieve());
141 ATH_CHECK(m_visualSvc->registerClient(m_clientToken));
142 } else {
143 m_plotsDone = true;
144 }
146 ATH_CHECK(m_segmentKey.initialize());
147 ATH_CHECK(m_contextProvider.initialize());
148 ATH_CHECK(m_seedingTool.retrieve());
150 ATH_CHECK(m_extrapolationTool.retrieve(EnableTool{!m_extrapolationTool.empty()}));
151 return StatusCode::SUCCESS;
152 }
#define ATH_CHECK
Evaluate an expression and check for errors.
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.
Gaudi::Property< bool > m_saveSummaryPDF
If set to true a summary Canvas is created.

◆ viewVector()

Amg::Vector2D MuonValR4::TrackVisualizationTool::viewVector ( const double phi,
const Amg::Vector2D & posOnCylinder,
const DisplayView view )
staticprivate

Transforms the projected vector into the actual view, if it's xy then an external phi is needed to place the marker.

Parameters
phiAngle for the xy view - taken from the segment direction
posOnCylinderProjection of the segment's position onto the seed cylinder
viewActual view to display

Definition at line 123 of file TrackVisualizationTool.cxx.

125 {
126 using enum DisplayView;
127 if (view == RZ) {
128 return Amg::Vector2D{posOnCylinder[1]*inM, posOnCylinder[0]*inM};
129 }
130 const CxxUtils::sincos phi{phiV};
131 return posOnCylinder[0] * inM * Amg::Vector2D{phi.cs, phi.sn};
132 }
DisplayView
Enumeration to toggle whether the seeds shall be painted in x-y or R-z view.

Member Data Documentation

◆ m_canvasLimit

Gaudi::Property<unsigned> MuonValR4::TrackVisualizationTool::m_canvasLimit {this, "CanvasLimit", 5000}
private

Maximum canvases to draw.

Definition at line 129 of file TrackVisualizationTool.h.

129{this, "CanvasLimit", 5000};

◆ m_canvasPrefix

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

Prefix of the individual canvas file names <MANDATORY>.

Definition at line 137 of file TrackVisualizationTool.h.

137{this, "CanvasPreFix", "MsTrackValid"};

◆ m_clientToken

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

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

Definition at line 117 of file TrackVisualizationTool.h.

117{};

◆ m_contextProvider

ActsTrk::ContextUtility MuonValR4::TrackVisualizationTool::m_contextProvider {this}
private

Dependency on the geometry alignment.

Definition at line 127 of file TrackVisualizationTool.h.

127{this};

◆ m_extrapolationTool

ToolHandle<ActsTrk::IExtrapolationTool> MuonValR4::TrackVisualizationTool::m_extrapolationTool {this, "ExtrapolationTool" ,"" }
private

Track extrapolation tool.

Definition at line 110 of file TrackVisualizationTool.h.

110{this, "ExtrapolationTool" ,"" };

◆ m_objCounter

std::atomic<unsigned> MuonValR4::TrackVisualizationTool::m_objCounter {0}
mutableprivate

How many obj have been produced.

Definition at line 141 of file TrackVisualizationTool.h.

141{0};

◆ m_plotsDone

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

Flag toggling whether all Canvases have been exhausted.

Definition at line 139 of file TrackVisualizationTool.h.

139{false};

◆ m_saveSinglePDFs

Gaudi::Property<bool> MuonValR4::TrackVisualizationTool::m_saveSinglePDFs {this, "saveSinglePDFs", true}
private

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

Definition at line 131 of file TrackVisualizationTool.h.

131{this, "saveSinglePDFs", true};

◆ m_saveSummaryPDF

Gaudi::Property<bool> MuonValR4::TrackVisualizationTool::m_saveSummaryPDF {this, "saveSummaryPDF", true}
private

If set to true a summary Canvas is created.

Definition at line 133 of file TrackVisualizationTool.h.

133{this, "saveSummaryPDF", true};

◆ m_seedingTool

ToolHandle<MuonR4::ITrackSeedingDiagnosticsTool> MuonValR4::TrackVisualizationTool::m_seedingTool {this, "SeedingTool", ""}
private

The track seeding tool to construct the seed candidates and to estimate the initial parameters.

Definition at line 121 of file TrackVisualizationTool.h.

121{this, "SeedingTool", ""};

◆ m_segmentKey

SG::ReadHandleKey<xAOD::MuonSegmentContainer> MuonValR4::TrackVisualizationTool::m_segmentKey {this, "SegmentContainer", "MuonSegmentsFromR4" }
private

Declare the data dependency on the standard Mdt+Rpc+Tgc segment container & on the NSW segment container.

Definition at line 124 of file TrackVisualizationTool.h.

124{this, "SegmentContainer", "MuonSegmentsFromR4" };

◆ m_subDir

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

Define the subdirectory in which the plots shall be saved.

Definition at line 135 of file TrackVisualizationTool.h.

135{this, "outSubDir", ""};

◆ m_trackingGeometrySvc

ServiceHandle<ActsTrk::ITrackingGeometrySvc> MuonValR4::TrackVisualizationTool::m_trackingGeometrySvc {this, "TrackingGeometrySvc", "ActsTrackingGeometrySvc"}
private

Service handle to the tracking geometry service.

Definition at line 114 of file TrackVisualizationTool.h.

114{this, "TrackingGeometrySvc", "ActsTrackingGeometrySvc"};

◆ m_truthSegKey

SG::ReadHandleKey<xAOD::MuonSegmentContainer> MuonValR4::TrackVisualizationTool::m_truthSegKey {this, "TruthSegkey", "MuonTruthSegments"}
private

Key to the truth segment selection to draw the segment parameters.

Definition at line 119 of file TrackVisualizationTool.h.

119{this, "TruthSegkey", "MuonTruthSegments"};

◆ m_visualSvc

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

Service handle of the visualization service.

Definition at line 112 of file TrackVisualizationTool.h.

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

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