Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation 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#include <TH1D.h>
6
7#include <array>
8#include <memory>
9#include <string>
10
11#include "ViewBase.hh"
12
13namespace Garfield {
14
15class Sensor;
16
17/// Plot the signal computed by a sensor as a ROOT histogram.
18
19class ViewSignal : public ViewBase {
20 public:
21 /// Constructor
22 ViewSignal();
23 /// Destructor
24 ~ViewSignal() = default;
25
26 /// Set the sensor from which to retrieve the signal.
27 void SetSensor(Sensor* s);
28
29 /** Plot the signal.
30 * \param label Identifier (weighting field) of the signal to be plotted.
31 * \param total Flag whether to plot the total induced signal.
32 * \param electron Flag whether to plot the electron-induced signal.
33 * \param ion Flag whether to plot the ion/hole-induced signal.
34 * \param delayed Flag whether to plot the delayed signal component.
35 * \param same Flag to keep existing plots on the canvas or not.
36 */
37 void PlotSignal(const std::string& label, const bool total = true,
38 const bool electron = false, const bool ion = false,
39 const bool delayed = false, const bool same = false);
40
41 /** Retrieve the histogram for the total, prompt and delayed induced charge or
42 * signal.. \param label Identifier (weighting field) of the signal to be
43 * plotted. \param h histogram to be returned \param electron Flag whether to
44 * plot the electron-induced signal. \param ion Flag whether to plot the
45 * ion/hole-induced signal. \param delayed Flag whether to plot the delayed
46 * signal component. \param same Flag to keep existing plots on the canvas or
47 * not. \param getsignal is true for plotting the induced signal and false for
48 * plotting the induced charge.
49 */
50
51 void Plot(const std::string& label, const bool getsignal,
52 const bool total = true, const bool delayed = true,
53 const bool same = false);
54
55 /** Retrieve the histogram for the total, prompt and delayed induced charge or
56 signal.
57 * \param h histogram to be returned
58 ('t': total, 'e': electron-induced, 'i': ion/hole-induced).
59 **/
60
61 TH1D* GetHistogram(const char h = 't') {
62 return h == 'e' ? m_hSignalElectrons.get()
63 : h == 'i' ? m_hSignalIons.get() : m_hSignal.get();
64 }
65
66 /// Set the x-axis limits explicitly.
67 void SetRangeX(const double xmin, const double xmax);
68 /// Remove the user-defined x-axis limits.
69 void UnsetRangeX() { m_userRangeX = false; }
70
71 /// Set the y-axis limits explicitly.
72 void SetRangeY(const double ymin, const double ymax);
73 /// Remove the user-defined y-axis limits.
74 void UnsetRangeY() { m_userRangeY = false; }
75
76 /// Override the default y-axis label.
77 void SetLabelY(const std::string& label) { m_labelY = label; }
78
79 /// Set the (ROOT) colour with which to draw the total signal.
80 void SetColourTotal(const short col) { m_colTotal = col; }
81 /// Set the (ROOT) colour with which to draw the electron component.
82 void SetColourElectrons(const short col) { m_colElectrons = col; }
83 /// Set the (ROOT) colour with hich to draw the hole/ion component.
84 void SetColourIons(const short col) { m_colIons = col; }
85 /// Set the (ROOT) colour with hich to draw the hole/ion component.
86 void SetColourHoles(const short col) { m_colIons = col; }
87
88 /// Set the (ROOT) colours with which to draw the delayed signal(s).
89 void SetColourDelayed(const short colTotal,
90 const short colElectrons = kYellow - 7,
91 const short colIons = kRed - 9) {
92 m_colDelayed = {colTotal, colElectrons, colIons};
93 }
94
95 private:
96 // Sensor.
97 Sensor* m_sensor = nullptr;
98
99 // Axis range.
100 double m_xmin = 0.;
101 double m_xmax = 0.;
102 bool m_userRangeX = false;
103 double m_ymin = 0.;
104 double m_ymax = 0.;
105 bool m_userRangeY = false;
106
107 // Axis label.
108 std::string m_labelY = "";
109
110 // Histograms.
111 std::unique_ptr<TH1D> m_hSignal;
112 std::unique_ptr<TH1D> m_hPromptSignal;
113
114 std::unique_ptr<TH1D> m_hCharge;
115 std::unique_ptr<TH1D> m_hPromptCharge;
116 std::unique_ptr<TH1D> m_hDelayedCharge;
117
118 std::unique_ptr<TH1D> m_hSignalElectrons;
119 std::unique_ptr<TH1D> m_hSignalIons;
120 std::unique_ptr<TH1D> m_hDelayedSignal;
121 std::unique_ptr<TH1D> m_hDelayedSignalElectrons;
122 std::unique_ptr<TH1D> m_hDelayedSignalIons;
123
124 // Colours.
125 short m_colTotal = kBlue + 3;
126 short m_colElectrons = kOrange - 3;
127 short m_colIons = kRed + 1;
128 std::array<short, 3> m_colDelayed{{kCyan + 2, kYellow - 7, kRed - 9}};
129};
130} // namespace Garfield
131#endif
Base class for visualization classes.
Definition: ViewBase.hh:18
Plot the signal computed by a sensor as a ROOT histogram.
Definition: ViewSignal.hh:19
void UnsetRangeY()
Remove the user-defined y-axis limits.
Definition: ViewSignal.hh:74
ViewSignal()
Constructor.
Definition: ViewSignal.cc:15
TH1D * GetHistogram(const char h='t')
Definition: ViewSignal.hh:61
void SetColourTotal(const short col)
Set the (ROOT) colour with which to draw the total signal.
Definition: ViewSignal.hh:80
~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:89
void SetColourIons(const short col)
Set the (ROOT) colour with hich to draw the hole/ion component.
Definition: ViewSignal.hh:84
void SetLabelY(const std::string &label)
Override the default y-axis label.
Definition: ViewSignal.hh:77
void SetSensor(Sensor *s)
Set the sensor from which to retrieve the signal.
Definition: ViewSignal.cc:17
void SetColourHoles(const short col)
Set the (ROOT) colour with hich to draw the hole/ion component.
Definition: ViewSignal.hh:86
void UnsetRangeX()
Remove the user-defined x-axis limits.
Definition: ViewSignal.hh:69
void SetRangeY(const double ymin, const double ymax)
Set the y-axis limits explicitly.
Definition: ViewSignal.cc:35
void SetRangeX(const double xmin, const double xmax)
Set the x-axis limits explicitly.
Definition: ViewSignal.cc:25
void PlotSignal(const std::string &label, const bool total=true, const bool electron=false, const bool ion=false, const bool delayed=false, const bool same=false)
Definition: ViewSignal.cc:45
void SetColourElectrons(const short col)
Set the (ROOT) colour with which to draw the electron component.
Definition: ViewSignal.hh:82
void Plot(const std::string &label, const bool getsignal, const bool total=true, const bool delayed=true, const bool same=false)
Definition: ViewSignal.cc:187