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::MsTrackSeeder &seederObj, const xAOD::MuonSegmentContainer &segments, 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::MsTrackSeeder &seederObj, const xAOD::MuonSegmentContainer &segments, 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 MuonR4::MsTrackSeeder &seederObj, 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 MuonR4::MsTrackSeeder &seeder, 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::IExtrapolationToolm_extrapolationTool {this, "ExtrapolationTool" ,"" }
 Track extrapolation tool.
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.
SG::ReadHandleKey< xAOD::MuonSegmentContainerm_truthSegKey {this, "TruthSegkey", "MuonTruthSegments"}
 Key to the truth segment selection to draw the segment parameters.
SG::ReadHandleKey< ActsTrk::GeometryContextm_geoCtxKey {this, "AlignmentKey", "ActsAlignment", "cond handle key"}
 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 21 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 98 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 100 of file TrackVisualizationTool.h.

100{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 MuonR4::MsTrackSeeder & seederObj,
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
seederObjConfigured instance of the track seeder which actually constructed the seeds.
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 272 of file TrackVisualizationTool.cxx.

277 {
278
279 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, std::format("SeedDisplay{:}",
280 view == DisplayView::XY ? "XY" : "RZ" ));
281
282 if (!canvas) {
283 m_plotsDone = true;
284 return;
285 }
286 canvas->setAxisTitles(view == DisplayView::XY ? "x [m]" : "z [m]",
287 view == DisplayView::XY ? "y [m]" : "R [m]");
288
289 PlotLegend legend{0.005,0.005, 0.6,0.1};
291 fillTruthSeedPoints(ctx, seeder, view, legend, *canvas);
292
293 auto onSeed = [&seeds](const xAOD::MuonSegment* segment,
294 const Location loc) {
295 return std::ranges::any_of(seeds,[segment, loc](const MsTrackSeed& seed){
296 return seed.location() == loc && std::ranges::find(seed.segments(), segment) != seed.segments().end();
297 });
298 };
299
300 const ActsTrk::GeometryContext* gctx{nullptr};
301 if (!SG::get(gctx, m_geoCtxKey, ctx).isSuccess()) {
302 THROW_EXCEPTION("Failed to fetch the geometry context "<<m_geoCtxKey.fullKey());
303 }
304 bool drawnPoint{false};
305
306 for (const xAOD::MuonSegment* segment: segments) {
307 using enum Location;
309 using namespace Muon;
310 const MuonGMR4::SpectrometerSector* msSector = detailedSegment(*segment)->msSector();
311 const auto chIdx = segment->chamberIndex();
312 const int mColor = msSector->barrel() ? ColorBarrel : (msSector->side() > 0 ? ColorEndcapA : ColorEndcapC);
313
314 for (const auto secProj : {leftOverlap, center, rightOverlap}) {
315 if (!sectorMap.insideSector(segment->sector() + Acts::toUnderlying(secProj),
316 segment->position().phi())){
317 continue;
318 }
319
320 for (const Location loc : {Barrel, Endcap}) {
321 const Amg::Vector2D projPos{seeder.expressOnCylinder(*gctx, *segment, loc, secProj)};
322 if (!seeder.withinBounds(projPos, loc)) {
323 continue;
324 }
325 drawnPoint = true;
326 const bool isGood = onSeed(segment, loc);
327 const int mStyle = stationMarkerSyle(chIdx, true, isGood);
328 const double phi = seeder.projectedPhi(segment->sector(), secProj);
329 const Amg::Vector2D markerPos{viewVector(phi, projPos, view)};
330 extPrimitives.emplace_back(drawMarker(markerPos, mStyle, mColor));
331
332 if (view == DisplayView::XY) {
333 const double r = markerPos.mag() + extraMargin;
334 canvas->expandPad(r, r);
335 canvas->expandPad(-r, -r);
336 } else {
337 canvas->expandPad(markerPos[0] - extraMargin, markerPos[1] - extraMargin);
338 canvas->expandPad(markerPos[0] + extraMargin, markerPos[1] + extraMargin);
339 }
340 legend.addMarker(mStyle, std::format("{:}{:}", MuonStationIndex::layerName(MuonStationIndex::toLayerIndex(chIdx)),
341 isGood ? "" : " (discarded)"), mColor);
342 legend.addColor(mColor, msSector->barrel() ? "Barrel" : msSector->side() > 0 ? "Endcap A" : "Endcap C");
343 }
344 }
345 }
346 if (!drawnPoint) {
347 canvas->trash();
348 return;
349 }
350 for (const MsTrackSeed& seed : seeds) {
351 const Amg::Vector3D& pos{seed.position()};
352 canvas->add(drawMarker(viewVector(pos.phi(), Amg::Vector2D{pos.perp(), pos.z()}, view),
353 kFullDiamond, kBlack));
354 legend.addMarker(kFullDiamond, "track seed");
355 }
357 for (unsigned int s = 1; s<=16 ; ++s) {
358 if (view != DisplayView::XY) {
359 break;
360 }
361 const double phi = sectorMap.sectorPhi(s);
362 const double dPhi = sectorMap.sectorWidth(s);
363
364 const int lStyle = s%2 ? kDashed : kDotted;
365 const double r = canvas->corner(Edges::xHigh);
366 const CxxUtils::sincos phiM{phi-dPhi}, phiP{phi+dPhi};
367 const Amg::Vector2D e1{r * phiM.cs, r * phiM.sn};
368 const Amg::Vector2D e2{r * phiP.cs, r * phiP.sn};
369
370 auto theLine = std::make_unique<TLine>(0.,0., e1.x(), e1.y());
371 theLine->SetLineStyle(lStyle);
372 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
373 theLine = std::make_unique<TLine>(0.,0., e2.x(), e2.y());
374 theLine->SetLineStyle(lStyle);
375 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
376 theLine = std::make_unique<TLine>(e1.x(), e1.y(), e2.x(), e2.y());
377 theLine->SetLineStyle(lStyle);
378 extPrimitives.insert(extPrimitives.begin(), std::move(theLine));
379 }
380 legend.fillPrimitives(*canvas);
381 }
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.
SectorProjector
Enumeration to select the sector projection.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
Dependency on the geometry alignment.
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...
MuonR4::MsTrackSeed::Location Location
Enumeration to toggle whether the segment shall displayed on the barrel/endcap.
void fillTruthSeedPoints(const EventContext &ctx, const MuonR4::MsTrackSeeder &seeder, const DisplayView view, PlotLegend &legend, Canvas_t &canvas) const
Add the truth segments to the canvas.
::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.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
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.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ displaySeeds() [2/3]

void MuonValR4::TrackVisualizationTool::displaySeeds ( const EventContext & ctx,
const MuonR4::MsTrackSeeder & seederObj,
const xAOD::MuonSegmentContainer & segments,
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
seederObjConfigured instance of the track seeder which actually constructed the seeds.
segmentsContainer of all MS segments in the event
seedsThe constructed track seeds from the event

Definition at line 136 of file TrackVisualizationTool.cxx.

139 {
140 displaySeeds(ctx, seederObj, segments, seeds, PrimitivesVec_t{});
141 }
virtual void displaySeeds(const EventContext &ctx, const MuonR4::MsTrackSeeder &seederObj, const xAOD::MuonSegmentContainer &segments, 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::MsTrackSeeder & seederObj,
const xAOD::MuonSegmentContainer & segments,
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
seederObjConfigured instance of the track seeder which actually constructed the seeds.
segmentsContainer of all MS segments in the event
extPrimitivesExtra TObjects that should be additionally painted onto the Canvases

Definition at line 142 of file TrackVisualizationTool.cxx.

146 {
147 if (m_plotsDone || segments.empty()) {
148 return;
149 }
150
151
152
153 displaySeeds(ctx, seederObj, DisplayView::RZ, segments, seeds, clone(extPrimitives));
154 displaySeeds(ctx, seederObj, DisplayView::XY, segments, seeds, std::move(extPrimitives));
155
156 //For each seed plot respective segment parameters
157
160
161 }
bool empty() const noexcept
Returns true if the collection is empty.
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)

◆ displaySeedSegmentsGlobalWithTruth()

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

Definition at line 163 of file TrackVisualizationTool.cxx.

166 {
167
168 auto canvas = m_visualSvc->prepareCanvas(
169 ctx, m_clientToken,
170 std::format("SeedSegsGlobalTruth{:}", view == DisplayView::XY ? "XY" : "RZ"));
171
172 if (!canvas) { m_plotsDone = true; return; }
173
174 canvas->setAxisTitles(view == DisplayView::XY ? "x [m]" : "z [m]",
175 view == DisplayView::XY ? "y [m]" : "R [m]");
176
177 PlotLegend legend{0.005, 0.005, 0.6, 0.1};
178
179 PrimitivesVec_t primitives{};
180 bool drewAny{false};
181
182 // -----------------------
183 // (A) Draw TRUTH segments
184 // -----------------------
185 const xAOD::MuonSegmentContainer* truthSegs{nullptr};
186 if (!SG::get(truthSegs, m_truthSegKey, ctx).isSuccess()) {
187 THROW_EXCEPTION("Failed to fetch the truth segment container");
188 }
189 if (truthSegs) {
190 for (const xAOD::MuonSegment* seg : *truthSegs) {
191 if (!seg) continue;
192
193 const Amg::Vector3D p = seg->position();
194 const double x = p.x() * inM;
195 const double y = p.y() * inM;
196 const double z = p.z() * inM;
197 const double r = std::hypot(x, y);
198
199 const Amg::Vector2D plotPos =
201 : Amg::Vector2D{z, r};
202
203 // Same station-based marker, but OPEN marker to visually separate truth vs reco
204 const auto chIdx = seg->chamberIndex();
205 const int mStyleTruth = stationMarkerSyle(chIdx, /*openMarker=*/true, /*onSeed=*/true);
206
207 primitives.emplace_back(drawMarker(plotPos, mStyleTruth, truthColor, /*mSize=*/3));
208 legend.addMarker(
209 mStyleTruth,
210 std::string(Muon::MuonStationIndex::layerName(Muon::MuonStationIndex::toLayerIndex(chIdx))) + " (truth)", truthColor);
211
212 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
213 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
214 drewAny = true;
215 }
216 }
217
218 // ---------------------------------
219 // (B) Draw RECO seed-associated segs
220 // ---------------------------------
221 for (std::size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
222 const MsTrackSeed& seed = seeds[iSeed];
223 const int color = seedColorIdx(iSeed);
224
225 std::string seedLabel = std::format("s{:d}: ", static_cast<int>(iSeed));
226
227 for (const xAOD::MuonSegment* seg : seed.segments()) {
228 if (!seg) continue;
229
230 const Amg::Vector3D p = seg->position();
231 const double x = p.x() * inM;
232 const double y = p.y() * inM;
233 const double z = p.z() * inM;
234 const double r = std::hypot(x, y);
235
236 const Amg::Vector2D plotPos =
238 : Amg::Vector2D{z, r};
239
240 const auto chIdx = seg->chamberIndex();
241 const int mStyle = stationMarkerSyle(chIdx, /*openMarker=*/false, /*onSeed=*/true);
242
243 primitives.emplace_back(drawMarker(plotPos, mStyle, color));
244
245 std::string label = printID(*seg);
246 seedLabel += label + "_";
247
248 primitives.emplace_back(MuonValR4::drawLabel(label, plotPos.x() + 0.01, plotPos.y() + 0.01, 10, false, color));
249
250 // Marker legend: only one entry per station style (PlotLegend dedups)
251 legend.addMarker(
252 mStyle,
254
255 canvas->expandPad(plotPos.x() - extraMargin, plotPos.y() - extraMargin);
256 canvas->expandPad(plotPos.x() + extraMargin, plotPos.y() + extraMargin);
257 drewAny = true;
258 }
259 //Add text which shows segment names associated to the respective seeed
260 primitives.emplace_back(MuonValR4::drawLabel(seedLabel, 0.15, 0.9 - (0.03*iSeed), 10, true, color));
261 }
262
263 if (!drewAny) { canvas->trash(); return; }
264
265 for (auto& p : primitives) canvas->add(std::move(p));
266 legend.fillPrimitives(*canvas);
267}
#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
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".

◆ 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 427 of file TrackVisualizationTool.cxx.

430 {
432 return;
433 }
434 const ActsTrk::GeometryContext* gctx{nullptr};
435 SG::get(gctx, m_geoCtxKey, ctx).ignore();
436
437 Acts::ObjVisualization3D visualHelper{};
438 const std::string subDir = std::format("./ObjDisplays/{:}/", m_subDir.value());
439 ensureDirectory(subDir);
440 if (parsToExt.ok() && m_extrapolationTool.isEnabled()) {
441 auto stepsResult = m_extrapolationTool->propagationSteps(ctx, *parsToExt);
442 if (stepsResult.ok()) {
443 MuonValR4::drawPropagation(stepsResult->first, visualHelper);
444 } else {
445 ATH_MSG_WARNING("Failed to extrapolate the seed for visualization: " << stepsResult.error().message());
446 }
447 }
448 std::string segStr{removeNonAlphaNum(objName)};
449 for (const xAOD::MuonSegment* seg : seed.segments()) {
450 MuonValR4::drawSegmentMeasurements(*gctx,* seg, visualHelper);
451 MuonValR4::drawSegmentLine(*gctx,*seg, visualHelper);
452 segStr += std::format("_{:}", MuonR4::printID(*seg));
453 }
454
455 unsigned fileVersion{0};
456 std::string finalStr{};
457 while (finalStr.empty() || std::filesystem::exists(finalStr)) {
458 finalStr = std::format("{:}/{:}_{:}_{:}_{:}.obj", subDir,
459 m_clientToken.preFixName, ctx.eventID().event_number(), ++fileVersion, segStr);
460 }
461 visualHelper.write(finalStr);
462 ++m_objCounter;
463 }
#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.
void ensureDirectory(const std::string &path)
Ensures that the subdirectory in the path is created.
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.
std::string removeNonAlphaNum(std::string str)
Removes all non-alpha numerical characters from a string.
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.

◆ fillTruthSeedPoints()

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

Add the truth segments to the canvas.

Parameters
ctxEventContext to access store gate
seederObjConfigured instance of the track seeder which actually constructed the seeds.
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 382 of file TrackVisualizationTool.cxx.

386 {
387 const xAOD::MuonSegmentContainer* truthSegs{nullptr};
388 if (!SG::get(truthSegs,m_truthSegKey, ctx).isSuccess()) {
389 THROW_EXCEPTION("Failed to fetch the truth segment container");
390 }
391 if (!truthSegs) {
392 return;
393 }
394 const ActsTrk::GeometryContext* gctx{nullptr};
395 if (!SG::get(gctx, m_geoCtxKey, ctx).isSuccess()) {
396 THROW_EXCEPTION("Failed to fetch the geometry context "<<m_geoCtxKey.fullKey());
397 }
398
399 bool addedEntry{false};
400 for (const xAOD::MuonSegment* segment: *truthSegs) {
401 const auto chIdx = segment->chamberIndex();
402 const int mStyle = stationMarkerSyle(chIdx, true, true);
403
404 using enum Location;
406 for (const auto secProj : {leftOverlap, center, rightOverlap}) {
407 if (!sectorMap.insideSector(segment->sector() + Acts::toUnderlying(secProj),
408 segment->position().phi())){
409 continue;
410 }
411 for (const Location loc : {Barrel, Endcap}) {
412 const Amg::Vector2D projected{seeder.expressOnCylinder(*gctx, *segment, loc, secProj)};
413 if (!seeder.withinBounds(projected, loc)) {
414 continue;
415 }
416 const double phi = MsTrackSeeder::projectedPhi(segment->sector(), secProj);
417 canvas.add(drawMarker(viewVector(phi, projected, view), mStyle, truthColor, 3));
419 addedEntry = true;
420 }
421 }
422 }
423 if (addedEntry) {
424 legend.addColor(truthColor, "truth");
425 }
426 }
bool withinBounds(const Amg::Vector2D &projPos, const Location loc) const
Returns whether the expression on the cylinder is within the surface bounds.
Amg::Vector2D expressOnCylinder(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, const Location loc, const SectorProjector proj) const
Expresses the segment on the cylinder surface.
static double projectedPhi(const int sector, const SectorProjector proj)
Returns the projected phi for a given sector and projector.

◆ initialize()

StatusCode MuonValR4::TrackVisualizationTool::initialize ( )
finaloverridevirtual

Definition at line 119 of file TrackVisualizationTool.cxx.

119 {
120 if (m_canvasLimit > 0) {
121 m_clientToken.canvasLimit = m_canvasLimit;
122 m_clientToken.preFixName = m_canvasPrefix;
123 m_clientToken.saveSinglePlots = m_saveSinglePDFs;
124 m_clientToken.saveSummaryPlot = m_saveSummaryPDF;
125 m_clientToken.subDirectory = m_subDir;
126 ATH_CHECK(m_visualSvc.retrieve());
127 ATH_CHECK(m_visualSvc->registerClient(m_clientToken));
128 } else {
129 m_plotsDone = true;
130 }
132 ATH_CHECK(m_geoCtxKey.initialize());
133 ATH_CHECK(m_extrapolationTool.retrieve(EnableTool{!m_extrapolationTool.empty()}));
134 return StatusCode::SUCCESS;
135 }
#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 109 of file TrackVisualizationTool.cxx.

111 {
112 using enum DisplayView;
113 if (view == RZ) {
114 return Amg::Vector2D{ posOnCylinder[1]*inM, posOnCylinder[0]*inM};
115 }
116 const CxxUtils::sincos phi{phiV};
117 return posOnCylinder[0] * inM * Amg::Vector2D{phi.cs, phi.sn};
118 }
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 151 of file TrackVisualizationTool.h.

151{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 159 of file TrackVisualizationTool.h.

159{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 145 of file TrackVisualizationTool.h.

145{};

◆ m_extrapolationTool

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

Track extrapolation tool.

Definition at line 140 of file TrackVisualizationTool.h.

140{this, "ExtrapolationTool" ,"" };

◆ m_geoCtxKey

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

Dependency on the geometry alignment.

Definition at line 149 of file TrackVisualizationTool.h.

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

◆ m_objCounter

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

How many obj have been produced.

Definition at line 163 of file TrackVisualizationTool.h.

163{0};

◆ m_plotsDone

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

Flag toggling whether all Canvases have been exhausted.

Definition at line 161 of file TrackVisualizationTool.h.

161{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 153 of file TrackVisualizationTool.h.

153{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 155 of file TrackVisualizationTool.h.

155{this, "saveSummaryPDF", true};

◆ 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 157 of file TrackVisualizationTool.h.

157{this, "outSubDir", ""};

◆ 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 147 of file TrackVisualizationTool.h.

147{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 142 of file TrackVisualizationTool.h.

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

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