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 LabeledSegmentSet = std::unordered_set<const xAOD::MuonSegment*>;
80 
83  virtual LabeledSegmentSet getLabeledSegments(const std::vector<const MuonR4::SpacePoint*>& hits) const override final;
84  virtual LabeledSegmentSet getLabeledSegments(const std::vector<const xAOD::UncalibratedMeasurement*>& hits) const override final;
85 
88  virtual bool isLabeled(const MuonR4::SpacePoint& hit) const override final;
89  virtual bool isLabeled(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.2, double startLegY = 0.8,
159  const double endLegY = 0.3) const;
160 
165  void drawPrimitives(const TCanvas& can,
166  PrimitiveVec& primitives) const;
168  Gaudi::Property<unsigned int> m_canvasLimit{this, "CanvasLimits", 5000};
170  Gaudi::Property<bool> m_saveSinglePDFs{this, "saveSinglePDFs", false};
173  Gaudi::Property<bool> m_saveSummaryPDF{this, "saveSummaryPDF", false};
175  Gaudi::Property<std::string> m_allCanName{this, "AllCanvasName", "AllPatternPlots"};
177  Gaudi::Property<std::string> m_canvasPrefix{this, "CanvasPreFix", ""};
179  Gaudi::Property<bool> m_displayBucket{this, "displayBucket", true};
181  Gaudi::Property<double> m_canvasExtraScale{this, "CanvasExtraScale" , 1.5};
184  Gaudi::Property<bool> m_accumlIsEta{this, "AccumulatorsInEtaPlane", true};
186  Gaudi::Property<bool> m_doEtaBucketViews{this,"doEtaBucketViews", true};
188  Gaudi::Property<bool> m_doPhiBucketViews{this,"doPhiBucketViews", true};
190  Gaudi::Property<std::string> m_AtlasLabel{this, "AtlasLabel", "Internal"};
192  Gaudi::Property<std::string> m_sqrtSLabel{this, "SqrtSLabel", "14"};
194  Gaudi::Property<std::string> m_lumiLabel{this, "LumiLabel", ""};
198  Gaudi::Property<std::set<std::string>> m_truthSegLinks{this, "TruthSegDecors", {}};
202  using SegLinkVec_t = std::vector<SegLink_t>;
204  std::vector<SegLinkDecor_t> m_truthLinkDecors{};
205 
206  Gaudi::Property<unsigned> m_canvasWidth{this, "CanvasWidth", 800};
207  Gaudi::Property<unsigned> m_canvasHeight{this, "CanvasHeight", 600};
208 
209  Gaudi::Property<bool> m_displayOnlyTruth{this, "displayTruthOnly", false};
210 
211 
215  SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
217  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
218 
220  mutable std::unique_ptr<TCanvas> m_allCan ATLAS_THREAD_SAFE{};
221  mutable std::unique_ptr<TFile> m_outFile ATLAS_THREAD_SAFE{};
223  mutable std::atomic<unsigned int> m_canvCounter ATLAS_THREAD_SAFE{0};
224  };
225 
226 }
227 
228 #endif
ReadHandleKeyArray.h
MuonValR4::PatternVisualizationTool::m_detMgr
const MuonGMR4::MuonDetectorManager * m_detMgr
pointer to the Detector manager
Definition: PatternVisualizationTool.h:213
MuonR4::PrimitiveVec
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec
Definition: SegmentFittingAlg.cxx:57
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
MuonValR4::PatternVisualizationTool::m_canvasWidth
Gaudi::Property< unsigned > m_canvasWidth
Definition: PatternVisualizationTool.h:206
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:219
ActsGeometryContext.h
MuonValR4::PatternVisualizationTool::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Geometry context key to retrieve the alignment.
Definition: PatternVisualizationTool.h:215
MuonValR4::PatternVisualizationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service Handle to the IMuonIdHelperSvc.
Definition: PatternVisualizationTool.h:217
MuonValR4::PatternVisualizationTool::m_canvasPrefix
Gaudi::Property< std::string > m_canvasPrefix
Prefix of the individual canvas file names <MANDATORY>
Definition: PatternVisualizationTool.h:177
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
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:104
MuonValR4::PatternVisualizationTool::visualizeSegment
virtual void visualizeSegment(const EventContext &ctx, const MuonR4::Segment &segment, const std::string &extraLabel) const override final
Definition: PatternVisualizationTool.cxx:400
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:706
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::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:693
SG::ReadHandleKey< ActsGeometryContext >
MuonValR4::PatternVisualizationTool::m_truthLinkDecorKeys
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_truthLinkDecorKeys
Declaration of the dependency on the decorations.
Definition: PatternVisualizationTool.h:200
MuonValR4::PatternVisualizationTool::m_prepContainerKeys
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prepContainerKeys
Declare dependency on the prep data containers.
Definition: PatternVisualizationTool.h:196
MuonValR4::PatternVisualizationTool::getLabeledSegments
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.
Definition: PatternVisualizationTool.cxx:119
MuonValR4::PatternVisualizationTool::m_displayOnlyTruth
Gaudi::Property< bool > m_displayOnlyTruth
Definition: PatternVisualizationTool.h:209
MuonValR4::PatternVisualizationTool::m_canvasExtraScale
Gaudi::Property< double > m_canvasExtraScale
Extra safety margin to zoom out from the Canvas.
Definition: PatternVisualizationTool.h:181
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:251
PlotPulseshapeFromCool.can
can
Definition: PlotPulseshapeFromCool.py:91
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:162
MuonValR4::PatternVisualizationTool::m_sqrtSLabel
Gaudi::Property< std::string > m_sqrtSLabel
Centre of mass energy label.
Definition: PatternVisualizationTool.h:192
DeMoAtlasDataLoss.canvas
dictionary canvas
Definition: DeMoAtlasDataLoss.py:187
MuonValR4::PatternVisualizationTool::isLabeled
virtual bool isLabeled(const MuonR4::SpacePoint &hit) const override final
Fetches all labeled (e.g.
Definition: PatternVisualizationTool.cxx:108
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::writeChi2
void writeChi2(const MuonR4::SegmentFit::Parameters &pars, const std::vector< SpacePointType > &hits, PrimitiveVec &primitivesToPush, const double legX=0.2, double startLegY=0.8, const double endLegY=0.3) const
Writes the chi2 of the hits onto the Canvas.
Definition: PatternVisualizationTool.cxx:617
MuonValR4::PatternVisualizationTool::m_doEtaBucketViews
Gaudi::Property< bool > m_doEtaBucketViews
Switch to visualize the eta view of the bucket event.
Definition: PatternVisualizationTool.h:186
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:170
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:570
MuonValR4::PatternVisualizationTool::SegLinkVec_t
std::vector< SegLink_t > SegLinkVec_t
Definition: PatternVisualizationTool.h:202
MuonValR4::PatternVisualizationTool::m_canvasLimit
Gaudi::Property< unsigned int > m_canvasLimit
Maximum canvases to draw.
Definition: PatternVisualizationTool.h:168
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:62
MuonValR4::PatternVisualizationTool::ATLAS_THREAD_SAFE
std::unique_ptr< TCanvas > m_allCan ATLAS_THREAD_SAFE
Definition: PatternVisualizationTool.h:220
MuonValR4::PatternVisualizationTool::LabeledSegmentSet
std::unordered_set< const xAOD::MuonSegment * > LabeledSegmentSet
Definition: PatternVisualizationTool.h:79
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonValR4::PatternVisualizationTool::m_AtlasLabel
Gaudi::Property< std::string > m_AtlasLabel
ATLAS label (Internal / Prelimnary / Simulation)
Definition: PatternVisualizationTool.h:190
MuonValR4::PatternVisualizationTool::m_saveSummaryPDF
Gaudi::Property< bool > m_saveSummaryPDF
If set to true a summary Canvas is created.
Definition: PatternVisualizationTool.h:173
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonValR4::PatternVisualizationTool::m_lumiLabel
Gaudi::Property< std::string > m_lumiLabel
Luminosity label.
Definition: PatternVisualizationTool.h:194
MuonValR4::PatternVisualizationTool::m_doPhiBucketViews
Gaudi::Property< bool > m_doPhiBucketViews
Switch to visualize the phi view of the bucket event.
Definition: PatternVisualizationTool.h:188
MuonValR4::PatternVisualizationTool::drawPrimitives
void drawPrimitives(const TCanvas &can, PrimitiveVec &primitives) const
Draw the various primitives onto the Canvas.
Definition: PatternVisualizationTool.cxx:141
HoughEventData.h
MuonValR4::PatternVisualizationTool::closeSummaryCanvas
void closeSummaryCanvas() const
Closes the summary canvas & closes the associated ROOT file.
Definition: PatternVisualizationTool.cxx:683
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:179
MuonValR4::PatternVisualizationTool::m_canvasHeight
Gaudi::Property< unsigned > m_canvasHeight
Definition: PatternVisualizationTool.h:207
MuonValR4::PatternVisualizationTool::m_truthLinkDecors
std::vector< SegLinkDecor_t > m_truthLinkDecors
Definition: PatternVisualizationTool.h:204
MuonValR4::PatternVisualizationTool::PatternVisualizationTool
PatternVisualizationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PatternVisualizationTool.cxx:59
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:184
MuonValR4::PatternVisualizationTool::visualizeBucket
virtual void visualizeBucket(const EventContext &ctx, const MuonR4::SpacePointBucket &bucket, const std::string &extraLabel) const override final
Definition: PatternVisualizationTool.cxx:329
ReadDecorHandleKeyArray.h
MuonValR4::PatternVisualizationTool::m_truthSegLinks
Gaudi::Property< std::set< std::string > > m_truthSegLinks
List of truth segment links to fetch.
Definition: PatternVisualizationTool.h:198
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:175
ServiceHandle< Muon::IMuonIdHelperSvc >
drawFromPickle.view
view
Definition: drawFromPickle.py:294
Identifier
Definition: IdentifierFieldParser.cxx:14