ATLAS Offline Software
PatternVisualizationTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONR4_MUONPATTERNRECOGNITIONTEST_PATTERNVISUALIZATIONTOOL_H
5 #define MUONR4_MUONPATTERNRECOGNITIONTEST_PATTERNVISUALIZATIONTOOL_H
6 
9 
12 
17 
19 
20 #include "TCanvas.h"
21 #include "TFile.h"
22 #include <mutex>
23 
24 namespace MuonR4 {
25  class SpacePoint;
26 }
27 
28 namespace MuonValR4 {
29  class PatternVisualizationTool : public extends<AthAlgTool, IPatternVisualizationTool> {
30  public:
31 
32  PatternVisualizationTool(const std::string& type, const std::string& name, const IInterface* parent);
33 
34  virtual StatusCode initialize() override final;
35  virtual StatusCode finalize() override final;
36 
37  virtual void visualizeBucket(const EventContext& ctx,
38  const MuonR4::SpacePointBucket& bucket,
39  const std::string& extraLabel) const override final;
40  virtual void visualizeBucket(const EventContext& ctx,
41  const MuonR4::SpacePointBucket& bucket,
42  const std::string& extraLabel,
43  PrimitiveVec&& extraPaints) const override final;
44 
45  virtual void visualizeSeed(const EventContext& ctx,
46  const MuonR4::SegmentSeed& seed,
47  const std::string& extraLabel) const override final;
48 
49 
50  virtual void visualizeSeed(const EventContext& ctx,
51  const MuonR4::SegmentSeed& seed,
52  const std::string& extraLabel,
53  PrimitiveVec&& extraPaints) const override final;
54 
55 
56  virtual void visualizeAccumulator(const EventContext& ctx,
57  const MuonR4::HoughPlane& accumulator,
58  const Acts::HoughTransformUtils::HoughAxisRanges& axisRanges,
59  const MaximumVec& maxima,
60  const std::string& extraLabel) const override final;
61 
62  virtual void visualizeAccumulator(const EventContext& ctx,
63  const MuonR4::HoughPlane& accumulator,
64  const Acts::HoughTransformUtils::HoughAxisRanges& axisRanges,
65  const MaximumVec& maxima,
66  const std::string& extraLabel,
67  PrimitiveVec&& extraPaints) const override final;
68 
69  virtual void visualizeSegment(const EventContext& ctx,
70  const MuonR4::Segment& segment,
71  const std::string& extraLabel) const override final;
72 
73  virtual void visualizeSegment(const EventContext& ctx,
74  const MuonR4::Segment& segment,
75  const std::string& extraLabel,
76  PrimitiveVec&& extraPaints) const override final;
77 
78 
79  using TruthSegmentSet = std::unordered_set<const xAOD::MuonSegment*>;
83  virtual TruthSegmentSet fetchTruthSegs(const std::vector<const MuonR4::SpacePoint*>& hits) const override final;
84  virtual TruthSegmentSet fetchTruthSegs(const std::vector<const xAOD::UncalibratedMeasurement*>& hits) const override final;
85 
88  virtual bool isTruthMatched(const MuonR4::SpacePoint& hit) const override final;
89  virtual bool isTruthMatched(const xAOD::UncalibratedMeasurement& hit) const override final;
90  private:
92  void closeSummaryCanvas() const;
99  std::unique_ptr<TCanvas> makeCanvas(const EventContext& ctx,
100  const std::array<double, 4>& canvasDim,
101  const int view) const;
102 
109  void saveCanvas(const EventContext& ctx,
110  const Identifier& chambId,
111  TCanvas& canvas,
112  const std::string& extraLabel) const;
113 
124  template<class SpacePointType>
125  bool drawHits(const MuonR4::SpacePointBucket& bucket,
126  const std::vector<SpacePointType>& hitsToDraw,
127  PrimitiveVec& primitivesToPush,
128  std::array<double, 4>& canvasDim,
129  unsigned int view) const;
130 
140  template<class SpacePointType>
141  const MuonR4::SpacePoint* drawHit(const SpacePointType& hit,
142  PrimitiveVec& primitives,
143  std::array<double, 4>& canvasDim,
144  const unsigned int view,
145  unsigned int fillStyle) const;
154  template<class SpacePointType>
156  const std::vector<SpacePointType>& hits,
157  PrimitiveVec& primitivesToPush,
158  const double legX = 0.15, double startLegY = 0.8,
159  const double endLegY = 0.3) const;
160 
162  Gaudi::Property<unsigned int> m_canvasLimit{this, "CanvasLimits", 5000};
164  Gaudi::Property<bool> m_saveSinglePDFs{this, "saveSinglePDFs", false};
167  Gaudi::Property<bool> m_saveSummaryPDF{this, "saveSummaryPDF", false};
169  Gaudi::Property<std::string> m_allCanName{this, "AllCanvasName", "AllPatternPlots"};
171  Gaudi::Property<std::string> m_canvasPrefix{this, "CanvasPreFix", ""};
173  Gaudi::Property<bool> m_displayBucket{this, "displayBucket", true};
175  Gaudi::Property<double> m_canvasExtraScale{this, "CanvasExtraScale" , 1.3};
178  Gaudi::Property<bool> m_accumlIsEta{this, "AccumulatorsInEtaPlane", true};
180  Gaudi::Property<bool> m_doEtaBucketViews{this,"doEtaBucketViews", true};
182  Gaudi::Property<bool> m_doPhiBucketViews{this,"doPhiBucketViews", true};
186  Gaudi::Property<std::set<std::string>> m_truthSegLinks{this, "TruthSegDecors", {}};
190  using SegLinkVec_t = std::vector<SegLink_t>;
192  std::vector<SegLinkDecor_t> m_truthLinkDecors{};
193 
194  Gaudi::Property<unsigned> m_canvasWidth{this, "CanvasWidth", 800};
195  Gaudi::Property<unsigned> m_canvasHeight{this, "CanvasHeight", 600};
196 
197  Gaudi::Property<bool> m_displayOnlyTruth{this, "displayTruthOnly", false};
198 
199 
203  SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
205  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
206 
208  mutable std::unique_ptr<TCanvas> m_allCan ATLAS_THREAD_SAFE{};
209  mutable std::unique_ptr<TFile> m_outFile ATLAS_THREAD_SAFE{};
211  mutable std::atomic<unsigned int> m_canvCounter ATLAS_THREAD_SAFE{0};
212  };
213 
214 }
215 
216 #endif
ReadHandleKeyArray.h
MuonValR4::PatternVisualizationTool::m_detMgr
const MuonGMR4::MuonDetectorManager * m_detMgr
pointer to the Detector manager
Definition: PatternVisualizationTool.h:201
MuonR4::PrimitiveVec
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec
Definition: SegmentFittingAlg.cxx:60
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
MuonValR4::PatternVisualizationTool::m_canvasWidth
Gaudi::Property< unsigned > m_canvasWidth
Definition: PatternVisualizationTool.h:194
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
MuonR4::SegmentFit::Parameters
AmgVector(toInt(ParamDefs::nPars)) Parameters
Definition: MuonHoughDefs.h:48
MuonR4::SpacePointBucket
: The muon space point bucket represents a collection of points that will bre processed together in t...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:21
IPatternVisualizationTool.h
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
MuonValR4::PatternVisualizationTool::s_mutex
static std::mutex s_mutex
Definition: PatternVisualizationTool.h:207
ActsGeometryContext.h
MuonValR4::PatternVisualizationTool::isTruthMatched
virtual bool isTruthMatched(const MuonR4::SpacePoint &hit) const override final
Returns whether the hit has been used in the truth-segment building.
Definition: PatternVisualizationTool.cxx:102
MuonValR4::PatternVisualizationTool::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Geometry context key to retrieve the alignment.
Definition: PatternVisualizationTool.h:203
MuonValR4::PatternVisualizationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service Handle to the IMuonIdHelperSvc.
Definition: PatternVisualizationTool.h:205
MuonValR4::PatternVisualizationTool::m_canvasPrefix
Gaudi::Property< std::string > m_canvasPrefix
Prefix of the individual canvas file names <MANDATORY>
Definition: PatternVisualizationTool.h:171
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
MuonValR4::PatternVisualizationTool::TruthSegmentSet
std::unordered_set< const xAOD::MuonSegment * > TruthSegmentSet
Definition: PatternVisualizationTool.h:79
MuonR4::Segment
Placeholder for what will later be the muon segment EDM representation.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:19
MuonValR4::PatternVisualizationTool::finalize
virtual StatusCode finalize() override final
Definition: PatternVisualizationTool.cxx:98
MuonValR4::PatternVisualizationTool::visualizeSegment
virtual void visualizeSegment(const EventContext &ctx, const MuonR4::Segment &segment, const std::string &extraLabel) const override final
Definition: PatternVisualizationTool.cxx:362
MuonValR4::PatternVisualizationTool::writeChi2
void writeChi2(const MuonR4::SegmentFit::Parameters &pars, const std::vector< SpacePointType > &hits, PrimitiveVec &primitivesToPush, const double legX=0.15, double startLegY=0.8, const double endLegY=0.3) const
Writes the chi2 of the hits onto the Canvas.
Definition: PatternVisualizationTool.cxx:558
MuonValR4::PatternVisualizationTool::saveCanvas
void saveCanvas(const EventContext &ctx, const Identifier &chambId, TCanvas &canvas, const std::string &extraLabel) const
Saves the Canvas as pdf & also into the ROOT file.
Definition: PatternVisualizationTool.cxx:662
MuonR4::HoughPlane
Acts::HoughTransformUtils::HoughPlane< HoughHitType > HoughPlane
Definition: MuonHoughDefs.h:20
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
MuonValR4::PatternVisualizationTool::fetchTruthSegs
virtual TruthSegmentSet fetchTruthSegs(const std::vector< const MuonR4::SpacePoint * > &hits) const override final
Fetches all truth segments where at least one measurement in the list was used to build them.
Definition: PatternVisualizationTool.cxx:113
MuonValR4::PatternVisualizationTool::makeCanvas
std::unique_ptr< TCanvas > makeCanvas(const EventContext &ctx, const std::array< double, 4 > &canvasDim, const int view) const
Create a new Canvas & draw the underlying frame.
Definition: PatternVisualizationTool.cxx:649
SG::ReadHandleKey< ActsGeometryContext >
MuonValR4::PatternVisualizationTool::m_truthLinkDecorKeys
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_truthLinkDecorKeys
Declaration of the dependency on the decorations.
Definition: PatternVisualizationTool.h:188
MuonValR4::PatternVisualizationTool::m_prepContainerKeys
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prepContainerKeys
Declare dependency on the prep data containers.
Definition: PatternVisualizationTool.h:184
MuonValR4::PatternVisualizationTool::m_displayOnlyTruth
Gaudi::Property< bool > m_displayOnlyTruth
Definition: PatternVisualizationTool.h:197
MuonValR4::PatternVisualizationTool::m_canvasExtraScale
Gaudi::Property< double > m_canvasExtraScale
Extra safety margin to zoom out from the Canvas.
Definition: PatternVisualizationTool.h:175
SpacePoint
Definition: Trigger/TrigAccel/TrigCudaFitter/src/SpacePoint.h:7
MuonSegmentContainer.h
MuonValR4::PatternVisualizationTool::visualizeSeed
virtual void visualizeSeed(const EventContext &ctx, const MuonR4::SegmentSeed &seed, const std::string &extraLabel) const override final
Definition: PatternVisualizationTool.cxx:220
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
MuonValR4::PatternVisualizationTool::visualizeAccumulator
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
Definition: PatternVisualizationTool.cxx:135
DeMoAtlasDataLoss.canvas
dictionary canvas
Definition: DeMoAtlasDataLoss.py:187
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonValR4::PatternVisualizationTool::drawHit
const MuonR4::SpacePoint * drawHit(const SpacePointType &hit, PrimitiveVec &primitives, std::array< double, 4 > &canvasDim, const unsigned int view, unsigned int fillStyle) const
Converts a Hit into a particular TBox/ TEllipse for drawing.
AthAlgTool.h
UncalibratedMeasurementContainer.h
MuonDetectorManager.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MuonValR4::PatternVisualizationTool::m_doEtaBucketViews
Gaudi::Property< bool > m_doEtaBucketViews
Switch to visualize the eta view of the bucket event.
Definition: PatternVisualizationTool.h:180
MuonValR4::PatternVisualizationTool::m_saveSinglePDFs
Gaudi::Property< bool > m_saveSinglePDFs
If set to true each canvas is saved into a dedicated pdf file.
Definition: PatternVisualizationTool.h:164
MuonValR4::PatternVisualizationTool::drawHits
bool drawHits(const MuonR4::SpacePointBucket &bucket, const std::vector< SpacePointType > &hitsToDraw, PrimitiveVec &primitivesToPush, std::array< double, 4 > &canvasDim, unsigned int view) const
Translates the Spacepoint information into TObjects that are dawn on the canvas & evaluates the size ...
Definition: PatternVisualizationTool.cxx:522
MuonValR4::PatternVisualizationTool::SegLinkVec_t
std::vector< SegLink_t > SegLinkVec_t
Definition: PatternVisualizationTool.h:190
MuonValR4::PatternVisualizationTool::m_canvasLimit
Gaudi::Property< unsigned int > m_canvasLimit
Maximum canvases to draw.
Definition: PatternVisualizationTool.h:162
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:18
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
MuonValR4::PatternVisualizationTool::initialize
virtual StatusCode initialize() override final
Definition: PatternVisualizationTool.cxx:61
MuonValR4::PatternVisualizationTool::ATLAS_THREAD_SAFE
std::unique_ptr< TCanvas > m_allCan ATLAS_THREAD_SAFE
Definition: PatternVisualizationTool.h:208
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonValR4::PatternVisualizationTool::m_saveSummaryPDF
Gaudi::Property< bool > m_saveSummaryPDF
If set to true a summary Canvas is created.
Definition: PatternVisualizationTool.h:167
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonValR4::PatternVisualizationTool::m_doPhiBucketViews
Gaudi::Property< bool > m_doPhiBucketViews
Switch to visualize the phi view of the bucket event.
Definition: PatternVisualizationTool.h:182
HoughEventData.h
MuonValR4::PatternVisualizationTool::closeSummaryCanvas
void closeSummaryCanvas() const
Closes the summary canvas & closes the associated ROOT file.
Definition: PatternVisualizationTool.cxx:639
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonValR4::PatternVisualizationTool
Definition: PatternVisualizationTool.h:29
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
MuonValR4::PatternVisualizationTool::m_displayBucket
Gaudi::Property< bool > m_displayBucket
Display the surrounding hits from the bucket not part of the seed.
Definition: PatternVisualizationTool.h:173
MuonValR4::PatternVisualizationTool::m_canvasHeight
Gaudi::Property< unsigned > m_canvasHeight
Definition: PatternVisualizationTool.h:195
MuonValR4::PatternVisualizationTool::m_truthLinkDecors
std::vector< SegLinkDecor_t > m_truthLinkDecors
Definition: PatternVisualizationTool.h:192
MuonValR4::PatternVisualizationTool::PatternVisualizationTool
PatternVisualizationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PatternVisualizationTool.cxx:58
MuonValR4::PatternVisualizationTool::m_accumlIsEta
Gaudi::Property< bool > m_accumlIsEta
Swtich toggling whether the accumulator view are in the eta or phi plane.
Definition: PatternVisualizationTool.h:178
MuonValR4::PatternVisualizationTool::visualizeBucket
virtual void visualizeBucket(const EventContext &ctx, const MuonR4::SpacePointBucket &bucket, const std::string &extraLabel) const override final
Definition: PatternVisualizationTool.cxx:295
ReadDecorHandleKeyArray.h
MuonValR4::PatternVisualizationTool::m_truthSegLinks
Gaudi::Property< std::set< std::string > > m_truthSegLinks
List of truth segment links to fetch.
Definition: PatternVisualizationTool.h:186
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
MuonValR4::PatternVisualizationTool::m_allCanName
Gaudi::Property< std::string > m_allCanName
Name of the summary canvas & the ROOT file to save the monitoring plots.
Definition: PatternVisualizationTool.h:169
ServiceHandle< Muon::IMuonIdHelperSvc >
drawFromPickle.view
view
Definition: drawFromPickle.py:294
Identifier
Definition: IdentifierFieldParser.cxx:14