Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ViewMedium.hh
Go to the documentation of this file.
1#ifndef G_VIEW_MEDIUM
2#define G_VIEW_MEDIUM
3
4#include <string>
5#include <vector>
6
7#include <TF1.h>
8#include <TGraph.h>
9
10#include "ViewBase.hh"
12
13namespace Garfield {
14
15class Medium;
16
17/// Plot transport coefficients as function of electric and magnetic field.
18
19class ViewMedium : public ViewBase {
20 public:
21 /// Constructor.
22 ViewMedium();
23 /// Destructor.
24 ~ViewMedium() = default;
25
26 /// Set the medium from which to retrieve the transport coefficients.
27 void SetMedium(Medium* m);
28
29 /// Try to choose the x-axis range based on the field grid.
30 void EnableAutoRangeX(const bool on = true) { m_autoRangeX = on; }
31 /// Set the limits of the electric field.
32 void SetRangeE(const double emin, const double emax, const bool logscale);
33 /// Set the limits of the magnetic field.
34 void SetRangeB(const double bmin, const double bmax, const bool logscale);
35 /// Set the limits of the angle between electric and magnetic field.
36 void SetRangeA(const double amin, const double amax, const bool logscale);
37 /// Choose the y-axis range based on the function's minima/maxima.
38 void EnableAutoRangeY(const bool on = true) { m_autoRangeY = on; }
39 /// Set the range of the function (velocity etc.) to be plotted.
40 void SetRangeY(const double ymin, const double ymax,
41 const bool logscale = false);
42
43 /// Set the electric field to use when plotting as function of B or angle.
44 void SetElectricField(const double efield) { m_efield = efield; }
45 /// Set the magnetic field to use when plotting as function of E or angle.
46 void SetMagneticField(const double bfield) { m_bfield = bfield; }
47 /// Set the angle to use when plotting as function of E or B.
48 void SetAngle(const double angle) { m_angle = angle; }
49
50 void PlotElectronVelocity(const char xaxis, const bool same = false);
51 void PlotHoleVelocity(const char xaxis, const bool same = false);
52 void PlotIonVelocity(const char xaxis, const bool same = false);
53 void PlotElectronDiffusion(const char xaxis, const bool same = false);
54 void PlotHoleDiffusion(const char xaxis, const bool same = false);
55 void PlotIonDiffusion(const char xaxis, const bool same = false);
56 void PlotElectronTownsend(const char xaxis, const bool same = false);
57 void PlotHoleTownsend(const char xaxis, const bool same = false);
58 void PlotElectronAttachment(const char xaxis, const bool same = false);
59 void PlotHoleAttachment(const char xaxis, const bool same = false);
60 void PlotElectronLorentzAngle(const char xaxis, const bool same = false);
62
63 double EvaluateFunction(double* pos, double* par);
64
65 enum Property {
84 };
85
86 private:
87 Medium* m_medium = nullptr;
88
89 // X-axis ranges
90 double m_eMin = 100., m_eMax = 100000.;
91 double m_bMin = 0., m_bMax = 2.;
92 double m_aMin = 0., m_aMax = Pi;
93 bool m_logE = true;
94 bool m_logB = false;
95 bool m_logA = false;
96 bool m_autoRangeX = true;
97 // Y-axis range
98 double m_yMin = 0., m_yMax = 1.;
99 bool m_logY = false;
100 bool m_autoRangeY = true;
101
102 // E-field to use when plotting as function of B-field or angle.
103 double m_efield = 1000.;
104 // B-field to use when plotting as function of E-field or angle.
105 double m_bfield = 0.;
106 // Angle to use when plotting as function of E-field or B-field.
107 double m_angle = HalfPi;
108
109 // Functions
110 std::vector<TF1> m_functions;
111 // Graphs
112 std::vector<TGraph*> m_graphs;
113 // Labels
114 std::vector<std::pair<std::string, int> > m_labels;
115
116 void SetupCanvas();
117 void AddFunction(const bool keep, const Property type, const char xaxis);
118 void GetAxisRangeX(const std::vector<double>& efields,
119 const std::vector<double>& bfields,
120 const std::vector<double>& angles, const char xaxis,
121 double& xmin, double& max, bool& logx) const;
122 int GetColor(const Property property) const;
123 std::string GetLabelX(const char xaxis) const;
124 std::string GetLabelY(const Property property) const;
125 std::string GetLegend(const Property property) const;
126};
127}
128#endif
Abstract base class for media.
Definition: Medium.hh:13
Base class for visualization classes.
Definition: ViewBase.hh:10
Plot transport coefficients as function of electric and magnetic field.
Definition: ViewMedium.hh:19
double EvaluateFunction(double *pos, double *par)
Definition: ViewMedium.cc:406
void SetRangeY(const double ymin, const double ymax, const bool logscale=false)
Set the range of the function (velocity etc.) to be plotted.
Definition: ViewMedium.cc:77
void SetAngle(const double angle)
Set the angle to use when plotting as function of E or B.
Definition: ViewMedium.hh:48
void SetRangeB(const double bmin, const double bmax, const bool logscale)
Set the limits of the magnetic field.
Definition: ViewMedium.cc:55
void PlotIonVelocity(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:103
void PlotElectronTownsend(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:126
void SetMedium(Medium *m)
Set the medium from which to retrieve the transport coefficients.
Definition: ViewMedium.cc:34
void PlotHoleVelocity(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:96
void SetMagneticField(const double bfield)
Set the magnetic field to use when plotting as function of E or angle.
Definition: ViewMedium.hh:46
void PlotHoleDiffusion(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:114
~ViewMedium()=default
Destructor.
void PlotElectronAttachment(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:136
void PlotIonDiffusion(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:120
void PlotElectronCrossSections()
Definition: ViewMedium.cc:151
void PlotElectronLorentzAngle(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:146
void PlotElectronVelocity(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:89
void EnableAutoRangeY(const bool on=true)
Choose the y-axis range based on the function's minima/maxima.
Definition: ViewMedium.hh:38
void SetRangeE(const double emin, const double emax, const bool logscale)
Set the limits of the electric field.
Definition: ViewMedium.cc:43
void SetElectricField(const double efield)
Set the electric field to use when plotting as function of B or angle.
Definition: ViewMedium.hh:44
void PlotHoleAttachment(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:141
void SetRangeA(const double amin, const double amax, const bool logscale)
Set the limits of the angle between electric and magnetic field.
Definition: ViewMedium.cc:66
void EnableAutoRangeX(const bool on=true)
Try to choose the x-axis range based on the field grid.
Definition: ViewMedium.hh:30
ViewMedium()
Constructor.
Definition: ViewMedium.cc:32
void PlotElectronDiffusion(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:108
void PlotHoleTownsend(const char xaxis, const bool same=false)
Definition: ViewMedium.cc:131