ATLAS Offline Software
Loading...
Searching...
No Matches
VisualizationHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
7#include <format>
8
9namespace MuonValR4{
10 using namespace MuonR4;
11 using namespace SegmentFit;
12
13 std::vector<std::unique_ptr<TObject>> clone(const std::vector<std::unique_ptr<TObject>>& cloneMe) {
14 std::vector<std::unique_ptr<TObject>> cloned{};
15 for (auto& obj : cloneMe) {
16 cloned.emplace_back(obj->Clone());
17 }
18 return cloned;
19 }
20 std::unique_ptr<TEllipse> drawDriftCircle(const Amg::Vector3D& center,
21 const double radius, const int color,
22 const int fillStyle) {
23 auto ellipse = std::make_unique<TEllipse>(center.y(), center.z(), radius);
24 ellipse->SetLineColor(color);
25 ellipse->SetFillStyle(fillStyle);
26 ellipse->SetLineWidth(1);
27 ellipse->SetFillColorAlpha(color, 0.2);
28 return ellipse;
29 }
30 std::unique_ptr<TArrow> drawArrow(const Amg::Vector3D& start, const Amg::Vector3D& dir,
31 const int color, const int lineStyle, const int view){
32 constexpr double arrowLength = 2.*Gaudi::Units::cm;
33 const Amg::Vector3D end = start + (arrowLength / std::hypot(dir[view], dir.z()) ) * dir;
34 auto arrow = std::make_unique<TArrow>(start[view], start.z(), end[view], end.z(),0.01);
35 arrow->SetLineColor(color);
36 arrow->SetLineWidth(2);
37 arrow->SetLineStyle(lineStyle);
38 return arrow;
39 }
40 std::unique_ptr<TLatex> drawLabel(const std::string& text,
41 const double xPos, const double yPos,
42 const double textSize,
43 const bool useNDC,
44 const int color) {
45 auto tl = std::make_unique<TLatex>(xPos, yPos, text.c_str());
46 tl->SetTextFont(43);
47 if(useNDC){
48 tl->SetNDC();
49 }
50 tl->SetTextSize(textSize);
51 tl->SetTextColor(color);
52 return tl;
53 }
54 std::unique_ptr<TBox> drawBox(const Amg::Vector3D& boxCenter,
55 const double boxWidth, const double boxHeight,
56 const int color, const int fillStyle,
57 const int view) {
58 return drawBox(boxCenter[view] - 0.5*boxWidth, boxCenter.z() - 0.5*boxHeight,
59 boxCenter[view] + 0.5*boxWidth, boxCenter.z() + 0.5*boxHeight,
60 color, fillStyle);
61 }
62 std::unique_ptr<TBox> drawBox(const double x1, const double y1,
63 const double x2, const double y2,
64 const int color, const int fillStyle) {
65 auto box = std::make_unique<TBox>(x1,y1,x2,y2);
66 box->SetFillColor(color);
67 box->SetLineColor(color);
68 box->SetFillStyle(fillStyle);
69 box->SetFillColorAlpha(color, 0.8);
70 return box;
71 }
72 std::unique_ptr<TLine> drawLine(const Parameters& pars,
73 const double lowEnd, const double highEnd,
74 const int color, const int lineStyle,
75 const int view) {
76 const auto [pos, dir] = makeLine(pars);
77 return drawLine(pos + Amg::intersect<3>(pos,dir,Amg::Vector3D::UnitZ(), lowEnd).value_or(0.)* dir,
78 pos + Amg::intersect<3>(pos,dir,Amg::Vector3D::UnitZ(), highEnd).value_or(0.)* dir,
79 color, lineStyle, view);
80 }
81 std::unique_ptr<TLine> drawLine(const Amg::Vector3D& lowEnd,
82 const Amg::Vector3D& highEnd,
83 const int color, const int lineStyle,
84 const int view) {
85 const double x1 = lowEnd[view];
86 const double y1 = lowEnd[Amg::z];
87 const double x2 = highEnd[view];
88 const double y2 = highEnd[Amg::z];
89
90 auto seedLine = std::make_unique<TLine>(x1, y1, x2, y2);
91 seedLine->SetLineColor(color);
92 seedLine->SetLineWidth(2);
93 seedLine->SetLineStyle(lineStyle);
94 return seedLine;
95
96 }
97 std::unique_ptr<TLatex> drawAtlasLabel(const double xPos, const double yPos,
98 const std::string& status) {
99 return drawLabel( "#font[72]{ATLAS} "+status, xPos, yPos);
100 }
101 std::unique_ptr<TLatex> drawLumiSqrtS(const double xPos,
102 const double yPos,
103 const std::string_view sqrtS,
104 const std::string_view lumi) {
105 return drawLabel(std::format("#sqrt{{s}}={0} TeV {1}{2}", sqrtS, lumi, lumi.empty() ? "" : "fb^{-1}"), xPos, yPos);
106 }
107}
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
Eigen::Matrix< double, 3, 1 > Vector3D
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
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
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.
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::vector< std::unique_ptr< TObject > > clone(const std::vector< std::unique_ptr< TObject > > &cloneMe)
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.
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< TLatex > drawLumiSqrtS(const double xPos, const double yPos, const std::string_view sqrtS="14", const std::string_view lumi="")
Create a luminosity sqrtS label.
std::unique_ptr< TLatex > drawAtlasLabel(const double xPos, const double yPos, const std::string &status="Internal")
Create a ATLAS label.
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.