ATLAS Offline Software
Loading...
Searching...
No Matches
VisualizationHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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 unsigned int fontSize) {
43 auto tl = std::make_unique<TLatex>(xPos, yPos, text.c_str());
44 tl->SetTextFont(43);
45 tl->SetTextSize(fontSize);
46 return tl;
47 }
48 std::unique_ptr<TLatex> drawLabelNDC(const std::string& text,
49 const double xPos, const double yPos,
50 const unsigned int fontSize) {
51 auto tl = std::make_unique<TLatex>(xPos, yPos, text.c_str());
52 tl->SetNDC();
53 tl->SetTextFont(43);
54 tl->SetTextSize(fontSize);
55 return tl;
56 }
57 std::unique_ptr<TBox> drawBox(const Amg::Vector3D& boxCenter,
58 const double boxWidth, const double boxHeight,
59 const int color, const int fillStyle,
60 const int view) {
61 return drawBox(boxCenter[view] - 0.5*boxWidth, boxCenter.z() - 0.5*boxHeight,
62 boxCenter[view] + 0.5*boxWidth, boxCenter.z() + 0.5*boxHeight,
63 color, fillStyle);
64 }
65 std::unique_ptr<TBox> drawBox(const double x1, const double y1,
66 const double x2, const double y2,
67 const int color, const int fillStyle) {
68 auto box = std::make_unique<TBox>(x1,y1,x2,y2);
69 box->SetFillColor(color);
70 box->SetLineColor(color);
71 box->SetFillStyle(fillStyle);
72 box->SetFillColorAlpha(color, 0.8);
73 return box;
74 }
75 std::unique_ptr<TLine> drawLine(const Parameters& pars,
76 const double lowEnd, const double highEnd,
77 const int color, const int lineStyle,
78 const int view) {
79 const auto [pos, dir] = makeLine(pars);
80 return drawLine(pos + Amg::intersect<3>(pos,dir,Amg::Vector3D::UnitZ(), lowEnd).value_or(0.)* dir,
81 pos + Amg::intersect<3>(pos,dir,Amg::Vector3D::UnitZ(), highEnd).value_or(0.)* dir,
82 color, lineStyle, view);
83 }
84 std::unique_ptr<TLine> drawLine(const Amg::Vector3D& lowEnd,
85 const Amg::Vector3D& highEnd,
86 const int color, const int lineStyle,
87 const int view) {
88 const double x1 = lowEnd[view];
89 const double y1 = lowEnd[Amg::z];
90 const double x2 = highEnd[view];
91 const double y2 = highEnd[Amg::z];
92
93 auto seedLine = std::make_unique<TLine>(x1, y1, x2, y2);
94 seedLine->SetLineColor(color);
95 seedLine->SetLineWidth(2);
96 seedLine->SetLineStyle(lineStyle);
97 return seedLine;
98
99 }
100 std::unique_ptr<TLatex> drawAtlasLabel(const double xPos, const double yPos,
101 const std::string& status) {
102 return drawLabelNDC( "#font[72]{ATLAS} "+status, xPos, yPos);
103 }
104 std::unique_ptr<TLatex> drawLumiSqrtS(const double xPos,
105 const double yPos,
106 const std::string_view sqrtS,
107 const std::string_view lumi) {
108 return drawLabelNDC(std::format("#sqrt{{s}}={0} TeV {1}{2}", sqrtS, lumi, lumi.empty() ? "" : "fb^{-1}"), xPos, yPos);
109 }
110}
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::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 > drawLabel(const std::string &text, const double xPos, const double yPos, const unsigned int fontSize=18)
Create a TLatex label,.
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.
std::unique_ptr< TLatex > drawLabelNDC(const std::string &text, const double xPos, const double yPos, const unsigned int fontSize=18)
Create a TLatex label,.