ATLAS Offline Software
Loading...
Searching...
No Matches
PatternVisualizationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
10
14
19
20#include "Acts/Utilities/Helpers.hpp"
21#include "Acts/Surfaces/RectangleBounds.hpp"
22#include "Acts/Surfaces/TrapezoidBounds.hpp"
23#include "Acts/Surfaces/PlaneSurface.hpp"
24#include "Acts/Surfaces/StrawSurface.hpp"
25#include "Acts/Visualization/GeometryView3D.hpp"
26
27
28#include <format>
29#include <sstream>
30#include <filesystem>
31
32
33#include "TH1F.h"
34#include "TH2F.h"
35#include "TMarker.h"
36#include "TColor.h"
37namespace {
38 constexpr int truthColor = kOrange +2;
39 constexpr int parLineColor = kRed;
40 using SpacePointSet = std::unordered_set<const MuonR4::SpacePoint*>;
41}
42
43
44namespace MuonValR4 {
45 using namespace MuonR4;
46 using namespace SegmentFit;
48
50 if (m_canvasLimit > 0) {
51 m_clientToken.canvasLimit = m_canvasLimit;
52 m_clientToken.preFixName = m_canvasPrefix;
53 m_clientToken.saveSinglePlots = m_saveSinglePDFs;
54 m_clientToken.saveSummaryPlot = m_saveSummaryPDF;
55 m_clientToken.subDirectory = m_subDir;
56 ATH_CHECK(m_visualSvc.retrieve());
57 ATH_CHECK(m_visualSvc->registerClient(m_clientToken));
58 } else {
59 m_plotsDone = true;
60 }
61 ATH_CHECK(m_prepContainerKeys.initialize(!m_truthSegLinks.empty()));
63 ATH_MSG_INFO("Hits linked to the following segment decorations are considered as truth");
64 for (const std::string& decorName : m_truthSegLinks) {
65 ATH_MSG_INFO(" **** "<<decorName);
66 if (decorName.empty()) {
67 ATH_MSG_FATAL("Decoration must not be empty");
68 return StatusCode::FAILURE;
69 }
71 m_truthLinkDecorKeys.emplace_back(key, decorName);
72 m_truthLinkDecors.push_back(SegLinkDecor_t{decorName});
73 }
74 }
75 ATH_CHECK(m_truthLinkDecorKeys.initialize());
76 m_displayOnlyTruth.value() &= !m_truthLinkDecorKeys.empty();
77
78 ATH_CHECK(m_idHelperSvc.retrieve());
79 ATH_CHECK(m_geoCtxKey.initialize());
80 ATH_CHECK(detStore()->retrieve(m_detMgr));
81 return StatusCode::SUCCESS;
82 }
88 return std::find_if(m_truthLinkDecors.begin(), m_truthLinkDecors.end(),
89 [&hit](const SegLinkDecor_t& decor){
90 return !decor(hit).empty();
91 }) != m_truthLinkDecors.end();
92 }
93
94 LabeledSegmentSet PatternVisualizationTool::getLabeledSegments(const std::vector<const MuonR4::SpacePoint*>& hits) const {
95 std::vector<const xAOD::UncalibratedMeasurement*> measurements{};
96 measurements.reserve(2* hits.size());
97 for (const SpacePoint* hit: hits) {
98 measurements.push_back(hit->primaryMeasurement());
99 if(hit->secondaryMeasurement()) {
100 measurements.push_back(hit->secondaryMeasurement());
101 }
102 }
103 return getLabeledSegments(measurements);
104 }
105 LabeledSegmentSet PatternVisualizationTool::getLabeledSegments(const std::vector<const xAOD::UncalibratedMeasurement*>& hits) const {
106 LabeledSegmentSet truthSegs{};
107 for (const xAOD::UncalibratedMeasurement* hit : hits) {
108 for (const SegLinkDecor_t& decor: m_truthLinkDecors) {
109 for (const SegLink_t& link : decor(*hit)) {
110 truthSegs.insert(*link);
111 }
112 }
113 }
114 return truthSegs;
115 }
117 const MuonR4::HoughPlane& accumulator,
118 const Acts::HoughTransformUtils::HoughAxisRanges& axisRanges,
119 const MaximumVec& maxima,
120 const std::string& extraLabel) const {
121 PrimitiveVec primitives{};
122 visualizeAccumulator(ctx, accumulator, axisRanges, maxima, extraLabel, std::move(primitives));
123 }
125 const MuonR4::HoughPlane& accumulator,
126 const Acts::HoughTransformUtils::HoughAxisRanges& axisRanges,
127 const MaximumVec& maxima,
128 const std::string& extraLabel,
129 PrimitiveVec&& primitives) const {
130
132 if (m_plotsDone) {
133 return;
134 }
135 if (accumulator.getNonEmptyBins().empty()) {
136 ATH_MSG_WARNING("Hough accumulator is empty");
137 return;
138 }
139
140 auto accHisto = std::make_unique<TH2F>("AccumulatorHisto", "histo",
141 accumulator.nBinsX(), axisRanges.xMin, axisRanges.xMax,
142 accumulator.nBinsY(), axisRanges.yMin, axisRanges.yMax);
143 accHisto->SetDirectory(nullptr);
144
145 std::vector<const SpacePoint*> spacePointsInAcc{};
146 for (const std::size_t bin : accumulator.getNonEmptyBins()) {
147 const auto [xBin, yBin] = accumulator.axisBins(bin);
148 auto hitIds = accumulator.hitIds(xBin, yBin);
149 spacePointsInAcc.insert(spacePointsInAcc.end(),hitIds.begin(), hitIds.end());
150 accHisto->SetBinContent(xBin+1, yBin+1, accumulator.nHits(bin));
151 }
152
153 const LabeledSegmentSet truthSegs{getLabeledSegments(spacePointsInAcc)};
154 if (truthSegs.empty() && m_displayOnlyTruth) {
155 return;
156 }
157 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, extraLabel);
158 if (!canvas){
159 m_plotsDone = true;
160 return;
161 }
162 canvas->expandPad(axisRanges.xMin, axisRanges.yMin);
163 canvas->expandPad(axisRanges.xMax, axisRanges.yMax);
164 canvas->setAxisTitles(std::format("tan#{}", m_accumlIsEta ? "beta" : "#alpha"),
165 std::format("{:}_{{0}} [mm]", m_accumlIsEta ? "y" : "x"));
166 canvas->add(std::move(accHisto), "HIST SAME");
167
168 for (const xAOD::MuonSegment* segment : truthSegs) {
169 const auto [pos, dir] = makeLine(localSegmentPars(*segment));
170 const double tan = m_accumlIsEta ? houghTanBeta(dir) : houghTanAlpha(dir);
171 const double icept = pos[m_accumlIsEta ? objViewEta : objViewPhi];
172 auto truthMarker = std::make_unique<TMarker>(tan, icept, kFullCrossX);
173 truthMarker->SetMarkerColor(truthColor);
174 truthMarker->SetMarkerSize(8);
175 canvas->add(std::move(truthMarker));
176 canvas->add(drawLabel(std::format("true parameters: {:}",
177 makeLabel(localSegmentPars(*segment))),0.2, 0.9));
178 }
179 for (const auto& maximum : maxima) {
180 auto maxMarker = std::make_unique<TMarker>(maximum.x, maximum.y, kFullTriangleUp);
181 maxMarker->SetMarkerColor(parLineColor);
182 maxMarker->SetMarkerSize(8);
183 canvas->add(std::move(maxMarker));
184 }
185 canvas->add(std::move(primitives));
186 }
187 void PatternVisualizationTool::paintSimHits(const EventContext& ctx,
188 const xAOD::MuonSegment& truthSeg,
189 Canvas_t& canvas,
190 const int view) const {
191 if (!m_paintTruthHits) {
192 return;
193 }
194 auto truthHits = getMatchingSimHits(truthSeg);
195 const ActsTrk::GeometryContext* geoCtx{nullptr};
196 if (!SG::get(geoCtx, m_geoCtxKey, ctx).isSuccess()) {
197 return;
198 }
199 for (const xAOD::MuonSimHit* simHit : truthHits) {
200 const MuonGMR4::MuonReadoutElement* re = m_detMgr->getReadoutElement(simHit->identify());
201 const IdentifierHash hash = re->detectorType() == ActsTrk::DetectorType::Mdt ?
202 re->measurementHash(simHit->identify()) :
203 re->layerHash(simHit->identify());
204 const Amg::Transform3D trf = re->msSector()->globalToLocalTransform(*geoCtx) *
205 re->localToGlobalTransform(*geoCtx, hash);
206 const Amg::Vector3D locPos = trf * xAOD::toEigen(simHit->localPosition());
207 const Amg::Vector3D locDir = trf.linear() * xAOD::toEigen(simHit->localDirection());
208 canvas.add(drawArrow(locPos, locDir, truthColor, kDashed, view));
209 }
210 }
211 void PatternVisualizationTool::visualizeSeed(const EventContext& ctx,
212 const MuonR4::SegmentSeed& seed,
213 const std::string& extraLabel) const {
214 PrimitiveVec primitives{};
215 visualizeSeed(ctx, seed, extraLabel, std::move(primitives));
216 }
217 void PatternVisualizationTool::visualizeSeed(const EventContext& ctx,
218 const MuonR4::SegmentSeed& seed,
219 const std::string& extraLabel,
220 PrimitiveVec&& primitives) const {
221
223 if (m_plotsDone) {
224 return;
225 }
226 const LabeledSegmentSet truthSegs{getLabeledSegments(seed.getHitsInMax())};
227 if (truthSegs.empty() && m_displayOnlyTruth) {
228 return;
229 }
230
231 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, extraLabel);
232 if (!canvas) {
233 m_plotsDone = true;
234 return;
235 }
236 canvas->add(std::move(primitives));
237
238
239 for (const int view : {objViewEta, objViewPhi}) {
240 if ((view == objViewEta && !m_doEtaBucketViews) ||
241 (view == objViewPhi && !m_doPhiBucketViews)){
242 continue;
243 }
244 canvas->setAxisTitles(std::format("{:} [mm]", view == objViewEta ? 'y' : 'x'), "z [mm]");
245
246 if (!drawHits(*seed.parentBucket(), seed.getHitsInMax(), *canvas, view)) {
247 continue;
248 }
249 for (const xAOD::MuonSegment* segment : truthSegs) {
250 canvas->add(drawLine(localSegmentPars(*segment),
251 canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh),
252 truthColor, kDotted, view));
253 paintSimHits(ctx,*segment, *canvas, view);
254 }
255 canvas->add(drawLine(seed.parameters(), canvas->corner(Edges::yLow),
256 canvas->corner(Edges::yHigh), parLineColor, kDashed, view));
257
258 writeChi2(seed.parameters(), seed.getHitsInMax(), *canvas);
259
260 std::string legendLabel = std::format("Event: {:}, chamber : {:}, #{:}-view ({:})",
261 ctx.eventID().event_number(),
262 m_idHelperSvc->toStringChamber(seed.getHitsInMax().front()->identify()),
263 view ==objViewEta ? "eta" : "phi",
264 extraLabel);
265 canvas->add(drawLabel(legendLabel, 0.1, 0.96));
266 canvas->add(drawLabel(makeLabel(seed.parameters()),0.25, 0.89));
267 }
268 }
269
270 void PatternVisualizationTool::visualizeBucket(const EventContext& ctx,
271 const MuonR4::SpacePointBucket& bucket,
272 const std::string& extraLabel) const {
273 PrimitiveVec primitives{};
274 visualizeBucket(ctx, bucket, extraLabel, std::move(primitives));
275 }
276 void PatternVisualizationTool::visualizeBucket(const EventContext& ctx,
277 const MuonR4::SpacePointBucket& bucket,
278 const std::string& extraLabel,
279 PrimitiveVec&& primitives) const {
281 if (m_plotsDone) {
282 return;
283 }
284
285 LabeledSegmentSet truthSegs{getLabeledSegments(Acts::unpackConstSmartPointers(bucket))};
286 if (truthSegs.empty() && m_displayOnlyTruth) {
287 return;
288 }
289 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, extraLabel);
290 if (!canvas){
291 m_plotsDone = true;
292 return;
293 }
294 canvas->add(std::move(primitives));
295
296 for (const int view : {objViewEta, objViewPhi}) {
297 if ((view == objViewEta && !m_doEtaBucketViews) ||
298 (view == objViewPhi && !m_doPhiBucketViews)){
299 continue;
300 }
301 canvas->setAxisTitles(std::format("{:} [mm]", view == objViewEta ? 'y' : 'x'), "z [mm]");
303 if (!drawHits(bucket, bucket, *canvas, view)) {
304 continue;
305 }
306 bool drawnTrueLabel{false};
307 for (const xAOD::MuonSegment* segment : truthSegs) {
308 canvas->add(drawLine(localSegmentPars(*segment),
309 canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh),
310 truthColor, kDotted, view));
311 if (!drawnTrueLabel) {
312 canvas->add(drawLabel(std::format("true parameters: {:}",makeLabel(localSegmentPars(*segment))),0.2, 0.89));
313 drawnTrueLabel = true;
314 }
315 paintSimHits(ctx,*segment, *canvas, view);
316 }
317
318 std::string legendLabel = std::format("Event: {:}, chamber : {:}, #{:}-view ({:})",
319 ctx.eventID().event_number(),
320 bucket.msSector()->identString(),
321 view ==objViewEta ? "eta" : "phi",
322 extraLabel);
323 canvas->add(drawLabel(legendLabel, 0.15, 0.96));
324 }
325 }
326
327 void PatternVisualizationTool::visualizeSegment(const EventContext& ctx,
328 const MuonR4::Segment& segment,
329 const std::string& extraLabel) const {
330 PrimitiveVec primitives{};
331 visualizeSegment(ctx, segment,extraLabel, std::move(primitives));
332 }
333
334 void PatternVisualizationTool::visualizeSegment(const EventContext& ctx,
335 const MuonR4::Segment& segment,
336 const std::string& extraLabel,
337 PrimitiveVec&& primitives) const {
339 if (m_plotsDone) {
340 return;
341 }
342
343 const LabeledSegmentSet truthSegs{getLabeledSegments(segment.parent()->getHitsInMax())};
344 if (truthSegs.empty() && m_displayOnlyTruth) {
345 return;
346 }
347 const ActsTrk::GeometryContext* geoCtx{nullptr};
348 if (!SG::get(geoCtx, m_geoCtxKey, ctx).isSuccess()) {
349 return;
350 }
351 auto canvas = m_visualSvc->prepareCanvas(ctx, m_clientToken, extraLabel);
352 if (!canvas) {
353 m_plotsDone = true;
354 return;
355 }
356 canvas->add(std::move(primitives));
357
358
359 const Parameters segPars = SegmentFit::localSegmentPars(*geoCtx, segment);
360
361 for (const int view : {objViewEta, objViewPhi}) {
362 if ((view == objViewEta && !m_doEtaBucketViews) ||
363 (view == objViewPhi && !m_doPhiBucketViews)){
364 continue;
365 }
366 canvas->setAxisTitles(std::format("{:} [mm]", view == objViewEta ? 'y' : 'x'), "z [mm]");
367 if (!drawHits(*segment.parent()->parentBucket(), segment.measurements(),
368 *canvas, view)) {
369 continue;
370 }
371 for (const xAOD::MuonSegment* segment : truthSegs) {
372 canvas->add(drawLine(localSegmentPars(*segment), canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh),
373 truthColor, kDotted, view));
374 paintSimHits(ctx,*segment, *canvas, view);
375 }
376 writeChi2(segPars, segment.measurements(), *canvas);
377
378 canvas->add(drawLine(segPars, canvas->corner(Edges::yLow), canvas->corner(Edges::yHigh),
379 parLineColor, kDashed, view));
380
381 const Identifier canvasId{segment.parent()->getHitsInMax().front()->identify()};
382 std::string legendLabel=std::format("Event: {:}, chamber: {:}, #chi^{{2}} / nDoF: {:.2f} ({:d}), #{:}-view (:)",
383 ctx.eventID().event_number(), m_idHelperSvc->toStringChamber(canvasId),
384 segment.chi2() /std::max(1u, segment.nDoF()), segment.nDoF(),
385 view ==objViewEta ? "eta" : "phi", extraLabel);
386
387 canvas->add(drawLabel(legendLabel, 0.2, 0.96));
388 canvas->add(drawLabel(makeLabel(segPars),0.25, 0.91));
389 }
390 }
391
392 template<class SpacePointType>
393 const SpacePoint*
394 PatternVisualizationTool::drawHit(const SpacePointType& hit, Canvas_t& canvas,
395 const unsigned int view,
396 unsigned int fillStyle) const {
397
399 if ((view == objViewEta && !hit.measuresEta()) || (view == objViewPhi && !hit.measuresPhi())) {
400 return nullptr;
401 }
402
403 if (hit.type() != xAOD::UncalibMeasType::Other) {
404 canvas.expandPad(hit.localPosition()[view] - hit.driftRadius(),
405 hit.localPosition().z() - hit.driftRadius());
406 canvas.expandPad(hit.localPosition()[view] + hit.driftRadius(),
407 hit.localPosition().z() + hit.driftRadius());
408 }
409
410 const SpacePoint* underlyingSp{nullptr};
412 constexpr int invalidCalibFill = 3305;
413 if constexpr (std::is_same_v<SpacePointType, SpacePoint>) {
414 underlyingSp = &hit;
416 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(hit.primaryMeasurement());
417 if (dc->status() != Muon::MdtDriftCircleStatus::MdtStatusDriftTime) {
418 fillStyle = invalidCalibFill;
419 }
420 }
421 } else if constexpr(std::is_same_v<SpacePointType, CalibratedSpacePoint>) {
422 underlyingSp = hit.spacePoint();
423 if (hit.fitState() == CalibratedSpacePoint::State::Valid) {
424 fillStyle = fullFilling;
425 } else if (hit.fitState() == CalibratedSpacePoint::State::FailedCalib) {
426 fillStyle = invalidCalibFill;
427 } else {
428 fillStyle = hatchedFilling;
429 }
430 }
431 switch(hit.type()) {
433 const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(underlyingSp->primaryMeasurement());
434 canvas.add(drawDriftCircle(hit.localPosition(), dc->readoutElement()->innerTubeRadius(),
435 kBlack, hollowFilling));
436
437 const int circColor = isLabeled(*dc) ? truthColor : kBlue;
438 canvas.add(drawDriftCircle(hit.localPosition(), hit.driftRadius(), circColor, fillStyle));
439 break;
441 const auto* meas{static_cast<const xAOD::RpcMeasurement*>(underlyingSp->primaryMeasurement())};
442 const int boxColor = isLabeled(*meas) ? truthColor : kGreen +2;
443 const double boxWidth = 0.5*std::sqrt(12)*std::sqrt(underlyingSp->covariance()[view]);
444 canvas.add(drawBox(hit.localPosition(), boxWidth, 0.5*meas->readoutElement()->gasGapPitch(),
445 boxColor, fillStyle));
446 break;
448 const auto* meas{static_cast<const xAOD::TgcStrip*>(underlyingSp->primaryMeasurement())};
449 const int boxColor = isLabeled(*meas) ? truthColor : kCyan + 2;
450 const double boxWidth = 0.5*std::sqrt(12)*std::sqrt(underlyingSp->covariance()[view]);
451 canvas.add(drawBox(hit.localPosition(), boxWidth, 0.5*meas->readoutElement()->gasGapPitch(),
452 boxColor, fillStyle));
453 break;
455 const int boxColor = isLabeled(*underlyingSp->primaryMeasurement()) ? truthColor : kAquamarine;
456 const double boxWidth = 5*Gaudi::Units::mm;
457 canvas.add(drawBox(hit.localPosition(), boxWidth, 10.*Gaudi::Units::mm, boxColor, fillStyle));
458 break;
460 break;
462 const int boxColor = isLabeled(*underlyingSp->primaryMeasurement()) ? truthColor : kTeal;
463 const double boxWidth = 5*Gaudi::Units::mm;
464 canvas.add(drawBox(hit.localPosition(), boxWidth, 10.*Gaudi::Units::mm, boxColor, fillStyle));
465 break;
466 } default: {
467 ATH_MSG_WARNING("Please implement proper drawings of the new small wheel.. "<<__FILE__<<":"<<__LINE__);
468 break;
469 }
470 }
471 return underlyingSp;
472 }
473
474 template<class SpacePointType>
476 const std::vector<SpacePointType>& hitsToDraw,
477 Canvas_t& canvas,
478 unsigned int view) const {
479
480 SpacePointSet drawnPoints{};
481 for (const SpacePointType& hit : hitsToDraw) {
482 drawnPoints.insert(drawHit(*hit, canvas, view, fullFilling));
483 }
484 if (m_displayBucket) {
485 for (const SpacePointBucket::value_type& hit : bucket) {
486 // Don't redraw the other points
487 if (drawnPoints.count(hit.get())) {
488 continue;
489 }
490 drawHit(*hit, canvas, view, hollowFilling);
491 }
492 }
493 return drawnPoints.size() - drawnPoints.count(nullptr) > 1;
494 }
495 template<class SpacePointType>
497 const std::vector<SpacePointType>& hits,
498 Canvas_t& canvas,
499 const double legX, double startLegY,
500 const double endLegY) const {
501 const auto [pos, dir] = makeLine(pars);
502
503 for (const SpacePointType& hit : hits) {
504 const SpacePoint* underlyingSp{nullptr};
505 bool displayChi2{true};
506 if constexpr(std::is_same_v<SpacePointType, Segment::MeasType>) {
507 underlyingSp = hit->spacePoint();
508 displayChi2 = (hit->fitState() == CalibratedSpacePoint::State::Valid);
509 } else {
510 underlyingSp = hit;
511 }
512 const Identifier hitId = underlyingSp ? underlyingSp->identify(): Identifier{};
513 std::string legendstream{};
514 switch(hit->type()) {
516 const int driftSign{SeedingAux::strawSign(pos, dir, *hit)};
517 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
518 legendstream = std::format("ML: {:1d}, TL: {:1d}, T: {:3d}, {:}",
519 idHelper.multilayer(hitId), idHelper.tubeLayer(hitId),
520 idHelper.tube(hitId), driftSign == -1 ? "L" : "R");
521 break;
523 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
524 legendstream= std::format("DR: {:1d}, DZ: {:1d}, GAP: {:1d}, #eta/#phi: {:}/{:}",
525 idHelper.doubletR(hitId), idHelper.doubletZ(hitId), idHelper.gasGap(hitId),
526 hit->measuresEta() ? "si" : "nay", hit->measuresPhi() ? "si" : "nay");
527 break;
529 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
530 legendstream = std::format("ST: {:}, GAP: {:1d}, #eta/#phi: {:}/{:}",
531 m_idHelperSvc->stationNameString(hitId), idHelper.gasGap(hitId),
532 hit->measuresEta() ? "si" : "nay", hit->measuresPhi() ? "si" : "nay");
533 break;
535 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
536 const auto* clus = static_cast<const xAOD::MMCluster*>(underlyingSp->primaryMeasurement());
537 const MuonGMR4::StripDesign& design = clus->readoutElement()->stripLayer(clus->layerHash()).design();
538 legendstream = std::format("ML: {:1d}, GAP: {:1d}, {:}", idHelper.multilayer(hitId), idHelper.gasGap(hitId),
539 !design.hasStereoAngle() ? "X" : design.stereoAngle() > 0 ? "U" :"V");
540 break;
542 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
543 legendstream = std::format("ML: {:1d}, GAP: {:1d}, #eta/#phi: {:}/{:}",
544 idHelper.multilayer(hitId), idHelper.gasGap(hitId),
545 hit->measuresEta() ? "si" : "nay", hit->measuresPhi() ? "si" : "nay");
546 break;
548 legendstream = "Ext. constaint";
549 }
550 default:
551 break;
552 }
553 if (displayChi2) {
554 const double chi2 = SeedingAux::chi2Term(pos, dir,*hit);
555 legendstream+=std::format(", #chi^{{2}}: {:.2f}", chi2);
556 } else {
557 legendstream+=", #chi^{2}: ---";
558 }
559 canvas.add(drawLabel(legendstream, legX, startLegY, 14));
560 startLegY -= 0.05;
561 if (startLegY<= endLegY) {
562 break;
563 }
564 }
565 }
566}
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
This is a "hash" representation of an Identifier.
int multilayer(const Identifier &id) const
Access to components of the ID.
int tube(const Identifier &id) const
int tubeLayer(const Identifier &id) const
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
MuonReadoutElement is an abstract class representing the geometry of a muon detector.
std::string identString() const
Returns a string encoding the chamber index & the sector of the MS sector.
double stereoAngle() const
Returns the value of the stereo angle.
bool hasStereoAngle() const
Returns whether a stereo angle is defined.
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition SegmentSeed.h:14
const std::vector< HitType > & getHitsInMax() const
Returns the list of assigned hits.
const SpacePointBucket * parentBucket() const
Returns the bucket out of which the seed was formed.
Placeholder for what will later be the muon segment EDM representation.
unsigned int nDoF() const
Returns the number of degrees of freedom.
const SegmentSeed * parent() const
Returns the seed out of which the segment was built.
const MeasVec & measurements() const
Returns the associated measurements.
: The muon space point bucket represents a collection of points that will bre processed together in t...
const MuonGMR4::SpectrometerSector * msSector() const
returns th associated muonChamber
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
const xAOD::UncalibratedMeasurement * secondaryMeasurement() const
const Identifier & identify() const
: Identifier of the primary measurement
const Cov_t & covariance() const
Returns the covariance array.
const xAOD::UncalibratedMeasurement * primaryMeasurement() const
Gaudi::Property< std::string > m_subDir
Define the subdirectory in which the plots shall be saved.
Gaudi::Property< bool > m_doEtaBucketViews
Switch to visualize the eta view of the bucket event.
virtual StatusCode initialize() override final
Gaudi::Property< bool > m_accumlIsEta
Swtich toggling whether the accumulator view are in the eta or phi plane.
virtual void visualizeAccumulator(const EventContext &ctx, const MuonR4::HoughPlane &accumulator, const Acts::HoughTransformUtils::HoughAxisRanges &axisRanges, const MaximumVec &maxima, const std::string &extraLabel) const override final
virtual void visualizeSegment(const EventContext &ctx, const MuonR4::Segment &segment, const std::string &extraLabel) const override final
Gaudi::Property< unsigned int > m_canvasLimit
Maximum canvases to draw.
Gaudi::Property< bool > m_displayBucket
Display the surrounding hits from the bucket not part of the seed.
Gaudi::Property< std::string > m_canvasPrefix
Prefix of the individual canvas file names <MANDATORY>
virtual void visualizeBucket(const EventContext &ctx, const MuonR4::SpacePointBucket &bucket, const std::string &extraLabel) const override final
Gaudi::Property< bool > 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.
std::unordered_set< const xAOD::MuonSegment * > LabeledSegmentSet
virtual void visualizeSeed(const EventContext &ctx, const MuonR4::SegmentSeed &seed, const std::string &extraLabel) const override final
IRootVisualizationService::ClientToken m_clientToken
Token to present to the visualization service such that the display froms this tool are grouped toget...
std::vector< SegLinkDecor_t > m_truthLinkDecors
Gaudi::Property< bool > m_doPhiBucketViews
Switch to visualize the phi view of the bucket event.
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_truthLinkDecorKeys
Declaration of the dependency on the decorations.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service Handle to the IMuonIdHelperSvc.
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prepContainerKeys
Declare dependency on the prep data containers.
bool drawHits(const MuonR4::SpacePointBucket &bucket, const std::vector< SpacePointType > &hitsToDraw, Canvas_t &canvasDim, unsigned int view) const
Translates the Spacepoint information into TObjects that are dawn on the canvas & evaluates the size ...
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.
IRootVisualizationService::ICanvasObject Canvas_t
Gaudi::Property< std::set< std::string > > m_truthSegLinks
List of truth segment links to fetch.
void paintSimHits(const EventContext &ctx, const xAOD::MuonSegment &truthSeg, Canvas_t &canvas, const int view) const
Paints the truth sim hits associated with the segment.
ElementLink< xAOD::MuonSegmentContainer > SegLink_t
ServiceHandle< IRootVisualizationService > m_visualSvc
Service handle of the visualization service.
virtual bool isLabeled(const MuonR4::SpacePoint &hit) const override final
Fetches all labeled (e.g.
Gaudi::Property< bool > m_saveSummaryPDF
If set to true a summary Canvas is created.
const MuonR4::SpacePoint * drawHit(const SpacePointType &hit, Canvas_t &canvas, const unsigned int view, unsigned int fillStyle) const
Converts a Hit into a particular TBox/ TEllipse for drawing.
void writeChi2(const MuonR4::SegmentFit::Parameters &pars, const std::vector< SpacePointType > &hits, Canvas_t &canvas, const double legX=0.2, double startLegY=0.8, const double endLegY=0.3) const
Writes the chi2 of the hits onto the Canvas.
const MuonGMR4::MuonDetectorManager * m_detMgr
pointer to the Detector manager
Gaudi::Property< bool > m_paintTruthHits
Switch to visualize the truth hits.
std::atomic< bool > m_plotsDone
Flag toggling whether all Canvases have been exhausted.
SG::AuxElement::ConstAccessor< SegLinkVec_t > SegLinkDecor_t
int gasGap(const Identifier &id) const override
get the hashes
int doubletR(const Identifier &id) const
int doubletZ(const Identifier &id) const
Property holding a SG store/key/clid from which a ReadHandle is made.
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
int gasGap(const Identifier &id) const override
get the hashes
double chi2(TH1 *h0, TH1 *h1)
@ Mdt
MuonSpectrometer.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
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::string makeLabel(const Parameters &pars)
Dumps the parameters into a string in the form of TLatex.
double houghTanBeta(const Amg::Vector3D &v)
Returns the hough tanBeta [y] / [z].
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec
Acts::HoughTransformUtils::HoughPlane< HoughHitType > HoughPlane
double houghTanAlpha(const Amg::Vector3D &v)
: Returns the hough tanAlpha [x] / [z]
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
constexpr int objViewEta
ObjectView.
PatternVisualizationTool::LabeledSegmentSet LabeledSegmentSet
constexpr int hollowFilling
Filling codes for hollow / fullFilling / hatched filling.
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.
constexpr int hatchedFilling
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,.
std::unique_ptr< TEllipse > drawDriftCircle(const Amg::Vector3D &center, const double radius, const int color=kViolet, const int fillStyle=hollowFilling)
Create a TEllipse for drawing a drift circle.
constexpr int fullFilling
constexpr int objViewPhi
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.
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.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
std::vector< const SpacePoint * > SpacePointSet
vector of space points
Definition FitterTypes.h:38
MdtDriftCircle_v1 MdtDriftCircle
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9
RpcMeasurement_v1 RpcMeasurement
MMCluster_v1 MMCluster
MuonSegment_v1 MuonSegment
Reference the current persistent version:
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.