Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
ViewSignal.hh
Go to the documentation of this file.
1#ifndef G_VIEW_SIGNAL
2#define G_VIEW_SIGNAL
3
4#include <Rtypes.h>
5
6#include <array>
7#include <string>
8
10
11class TH1;
12class TH1D;
13
14namespace Garfield {
15
16class Sensor;
17
19
20class ViewSignal : public ViewBase {
21 public:
23 ViewSignal() : ViewSignal(nullptr) {}
25 ViewSignal(Sensor* sensor);
27 ~ViewSignal() = default;
28
30 void SetSensor(Sensor* s);
31
48
49 void PlotSignal(const std::string& label, const std::string& optTotal = "t",
50 const std::string& optPrompt = "",
51 const std::string& optDelayed = "", const bool same = false);
52
54 void SetRangeX(const double xmin, const double xmax);
56 void UnsetRangeX() { m_userRangeX = false; }
57
59 void SetRangeY(const double ymin, const double ymax);
61 void UnsetRangeY() { m_userRangeY = false; }
62
64 void SetLabelY(const std::string& label) { m_labelY = label; }
65
67 void EnableLegend(const bool on = true) { m_legend = on; }
68
70 void SetColourTotal(const short col) { m_colTotal = col; }
72 void SetColourElectrons(const short col) { m_colElectrons = col; }
74 void SetColourIons(const short col) { m_colIons = col; }
76 void SetColourHoles(const short col) { m_colIons = col; }
77
79 void SetColourDelayed(const short colTotal,
80 const short colElectrons = kYellow - 7,
81 const short colIons = kRed - 9) {
82 m_colDelayed = {colTotal, colElectrons, colIons};
83 }
84
85 private:
86 // Sensor.
87 Sensor* m_sensor = nullptr;
88
89 // Axis range.
90 double m_xmin = 0.;
91 double m_xmax = 0.;
92 bool m_userRangeX = false;
93 double m_ymin = 0.;
94 double m_ymax = 0.;
95 bool m_userRangeY = false;
96
97 // Axis label.
98 std::string m_labelY = "";
99
100 bool m_legend = false;
101
102 // Colours.
103 short m_colTotal = kBlue + 3;
104 short m_colElectrons = kOrange - 3;
105 short m_colIons = kRed + 1;
106 std::array<short, 6> m_colDelayed{
107 {kCyan + 2, kYellow - 7, kRed - 9, kGreen + 1, kYellow - 4, kRed - 9}};
108
109 std::array<short, 3> m_colPrompt{{kAzure + 10, kRed - 4, kMagenta + 2}};
110
111 TH1* DrawHistogram(TH1D& h, const std::string& opt,
112 const std::string& ylabel);
113};
114} // namespace Garfield
115#endif
ViewBase()=delete
Default constructor.
void UnsetRangeY()
Remove the user-defined y-axis limits.
Definition ViewSignal.hh:61
ViewSignal()
Default constructor.
Definition ViewSignal.hh:23
std::array< short, 3 > m_colPrompt
std::array< short, 6 > m_colDelayed
void SetColourTotal(const short col)
Set the (ROOT) colour with which to draw the total signal.
Definition ViewSignal.hh:70
~ViewSignal()=default
Destructor.
void SetColourDelayed(const short colTotal, const short colElectrons=kYellow - 7, const short colIons=kRed - 9)
Set the (ROOT) colours with which to draw the delayed signal(s).
Definition ViewSignal.hh:79
ViewSignal(Sensor *sensor)
Constructor.
void EnableLegend(const bool on=true)
Draw a legend on the plot or not.
Definition ViewSignal.hh:67
void SetColourIons(const short col)
Set the (ROOT) colour with which to draw the hole/ion component.
Definition ViewSignal.hh:74
void SetLabelY(const std::string &label)
Override the default y-axis label.
Definition ViewSignal.hh:64
void SetSensor(Sensor *s)
Set the sensor from which to retrieve the signal.
TH1 * DrawHistogram(TH1D &h, const std::string &opt, const std::string &ylabel)
std::string m_labelY
Definition ViewSignal.hh:98
void SetColourHoles(const short col)
Set the (ROOT) colour with which to draw the hole/ion component.
Definition ViewSignal.hh:76
void UnsetRangeX()
Remove the user-defined x-axis limits.
Definition ViewSignal.hh:56
void SetRangeY(const double ymin, const double ymax)
Set the y-axis limits explicitly.
void SetRangeX(const double xmin, const double xmax)
Set the x-axis limits explicitly.
void SetColourElectrons(const short col)
Set the (ROOT) colour with which to draw the electron component.
Definition ViewSignal.hh:72
void PlotSignal(const std::string &label, const std::string &optTotal="t", const std::string &optPrompt="", const std::string &optDelayed="", const bool same=false)
Plot the signal.