Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ViewFEMesh Class Reference

#include <ViewFEMesh.hh>

Public Member Functions

 ViewFEMesh ()
 
 ~ViewFEMesh ()
 
TCanvas * GetCanvas ()
 
void SetCanvas (TCanvas *c)
 
void SetComponent (ComponentFieldMap *comp)
 
void SetArea ()
 
void SetArea (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
 
void SetDefaultProjection ()
 
void SetPlane (double fx, double fy, double fz, double x0, double y0, double z0)
 
void SetXaxis (TGaxis *ax)
 
void SetYaxis (TGaxis *ay)
 
void SetXaxisTitle (const char *xtitle)
 
void SetYaxisTitle (const char *ytitle)
 
void EnableAxes ()
 
void DisableAxes ()
 
bool Plot ()
 
void SetFillMesh (bool f)
 
void SetColor (int matID, int colorID)
 
void SetFillColor (int matID, int colorID)
 
void SetViewDrift (ViewDrift *vd)
 
void SetFillMeshWithBorders ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 
void CreateDefaultAxes ()
 
void DisableMaterial (int materialID)
 

Detailed Description

Definition at line 25 of file ViewFEMesh.hh.

Constructor & Destructor Documentation

◆ ViewFEMesh()

Garfield::ViewFEMesh::ViewFEMesh ( )

Definition at line 13 of file ViewFEMesh.cc.

14 : className("ViewCell"),
15 label("Cell Layout"),
16 debug(false),
17 fillMesh(false),
18 canvas(0),
19 hasExternalCanvas(false),
20 hasUserArea(false),
21 xMin(-1.),
22 yMin(-1.),
23 zMin(-1.),
24 xMax(1.),
25 yMax(1.),
26 zMax(1.),
27 component(0),
28 viewDrift(0),
29 plotMeshBorders(false),
30 xaxis(0),
31 yaxis(0),
32 axes(0),
33 drawAxes(false) {
34
37
38 // Create a blank histogram for the axes.
39 axes = new TH2D();
40 axes->SetStats(false);
41 axes->GetXaxis()->SetTitle("x");
42 axes->GetYaxis()->SetTitle("y");
43}
PlottingEngineRoot plottingEngine

◆ ~ViewFEMesh()

Garfield::ViewFEMesh::~ViewFEMesh ( )

Definition at line 45 of file ViewFEMesh.cc.

45 {
46
47 if (!hasExternalCanvas && canvas != 0) delete canvas;
48}

Member Function Documentation

◆ CreateDefaultAxes()

void Garfield::ViewFEMesh::CreateDefaultAxes ( )

Definition at line 222 of file ViewFEMesh.cc.

222 {
223
224 // Create a new x and y axis
225 xaxis = new TGaxis(
226 xMin + std::abs(xMax - xMin) * 0.1, yMin + std::abs(yMax - yMin) * 0.1,
227 xMax - std::abs(xMax - xMin) * 0.1, yMin + std::abs(yMax - yMin) * 0.1,
228 xMin + std::abs(xMax - xMin) * 0.1, xMax - std::abs(xMax - xMin) * 0.1,
229 2405, "x");
230 yaxis = new TGaxis(
231 xMin + std::abs(xMax - xMin) * 0.1, yMin + std::abs(yMax - yMin) * 0.1,
232 xMin + std::abs(xMax - xMin) * 0.1, yMax - std::abs(yMax - yMin) * 0.1,
233 yMin + std::abs(yMax - yMin) * 0.1, yMax - std::abs(yMax - yMin) * 0.1,
234 2405, "y");
235
236 // Label sizes
237 xaxis->SetLabelSize(0.025);
238 yaxis->SetLabelSize(0.025);
239
240 // Titles
241 xaxis->SetTitleSize(0.03);
242 xaxis->SetTitle("x [cm]");
243 yaxis->SetTitleSize(0.03);
244 yaxis->SetTitle("y [cm]");
245}

◆ DisableAxes()

void Garfield::ViewFEMesh::DisableAxes ( )
inline

Definition at line 54 of file ViewFEMesh.hh.

54{ drawAxes = false; }

◆ DisableDebugging()

void Garfield::ViewFEMesh::DisableDebugging ( )
inline

Definition at line 78 of file ViewFEMesh.hh.

78{ debug = false; }

◆ DisableMaterial()

void Garfield::ViewFEMesh::DisableMaterial ( int  materialID)
inline

Definition at line 84 of file ViewFEMesh.hh.

84{ disabledMaterial[materialID] = true; }

◆ EnableAxes()

void Garfield::ViewFEMesh::EnableAxes ( )
inline

Definition at line 53 of file ViewFEMesh.hh.

53{ drawAxes = true; }

◆ EnableDebugging()

void Garfield::ViewFEMesh::EnableDebugging ( )
inline

Definition at line 77 of file ViewFEMesh.hh.

77{ debug = true; }

◆ GetCanvas()

TCanvas * Garfield::ViewFEMesh::GetCanvas ( )

Definition at line 72 of file ViewFEMesh.cc.

72{ return canvas; }

◆ Plot()

bool Garfield::ViewFEMesh::Plot ( )

Definition at line 97 of file ViewFEMesh.cc.

97 {
98
99 if (component == 0) {
100 std::cerr << className << "::Plot:\n";
101 std::cerr << " Component is not defined.\n";
102 return false;
103 }
104
105 double pmin = 0., pmax = 0.;
106 if (!component->GetVoltageRange(pmin, pmax)) {
107 std::cerr << className << "::Plot:\n";
108 std::cerr << " Component is not ready.\n";
109 return false;
110 }
111
112 // Get the bounding box.
113 if (!hasUserArea) {
114 std::cerr << className << "::Plot:\n";
115 std::cerr << " Bounding box cannot be determined.\n";
116 std::cerr << " Call SetArea first.\n";
117 return false;
118 }
119
120 // Set up a canvas if one does not already exist.
121 if (canvas == 0) {
122 canvas = new TCanvas();
123 canvas->SetTitle(label.c_str());
124 if (hasExternalCanvas) hasExternalCanvas = false;
125 }
126 canvas->Range(xMin, yMin, xMax, yMax);
127
128 // Plot the elements
129 ComponentCST* componentCST = dynamic_cast<ComponentCST*>(component);
130 if (componentCST != 0) {
131 std::cout << className << "::Plot:\n";
132 std::cout << " The given component is a CST component.\n";
133 std::cout << " Method PlotCST is called now!.\n";
134 DrawCST(componentCST);
135 } else {
136 DrawElements();
137 }
138 canvas->Update();
139
140 return true;
141}
bool GetVoltageRange(double &vmin, double &vmax)

◆ SetArea() [1/2]

void Garfield::ViewFEMesh::SetArea ( )

Definition at line 93 of file ViewFEMesh.cc.

93{ hasUserArea = false; }

◆ SetArea() [2/2]

void Garfield::ViewFEMesh::SetArea ( double  xmin,
double  ymin,
double  zmin,
double  xmax,
double  ymax,
double  zmax 
)

Definition at line 74 of file ViewFEMesh.cc.

75 {
76
77 // Check range, assign if non-null
78 if (xmin == xmax || ymin == ymax) {
79 std::cout << className << "::SetArea:\n";
80 std::cout << " Null area range not permitted.\n";
81 return;
82 }
83 xMin = std::min(xmin, xmax);
84 yMin = std::min(ymin, ymax);
85 zMin = std::min(zmin, zmax);
86 xMax = std::max(xmin, xmax);
87 yMax = std::max(ymin, ymax);
88 zMax = std::max(zmin, zmax);
89
90 hasUserArea = true;
91}

◆ SetCanvas()

void Garfield::ViewFEMesh::SetCanvas ( TCanvas *  c)

Definition at line 61 of file ViewFEMesh.cc.

61 {
62
63 if (c == 0) return;
64 if (!hasExternalCanvas && canvas != 0) {
65 delete canvas;
66 canvas = 0;
67 }
68 canvas = c;
69 hasExternalCanvas = true;
70}

◆ SetColor()

void Garfield::ViewFEMesh::SetColor ( int  matID,
int  colorID 
)
inline

Definition at line 64 of file ViewFEMesh.hh.

64{ colorMap[matID] = colorID; }

◆ SetComponent()

void Garfield::ViewFEMesh::SetComponent ( ComponentFieldMap comp)

Definition at line 50 of file ViewFEMesh.cc.

50 {
51
52 if (comp == 0) {
53 std::cerr << className << "::SetComponent:\n";
54 std::cerr << " Component pointer is null.\n";
55 return;
56 }
57
58 component = comp;
59}

◆ SetDefaultProjection()

void Garfield::ViewFEMesh::SetDefaultProjection ( )

Definition at line 185 of file ViewFEMesh.cc.

185 {
186
187 // Default projection: x-y at z=0
188 project[0][0] = 1;
189 project[1][0] = 0;
190 project[2][0] = 0;
191 project[0][1] = 0;
192 project[1][1] = 1;
193 project[2][1] = 0;
194 project[0][2] = 0;
195 project[1][2] = 0;
196 project[2][2] = 0;
197
198 // Plane description
199 plane[0] = 0;
200 plane[1] = 0;
201 plane[2] = 1;
202 plane[3] = 0;
203}

Referenced by ViewFEMesh().

◆ SetFillColor()

void Garfield::ViewFEMesh::SetFillColor ( int  matID,
int  colorID 
)
inline

Definition at line 65 of file ViewFEMesh.hh.

65{ colorMap_fill[matID] = colorID; }

◆ SetFillMesh()

void Garfield::ViewFEMesh::SetFillMesh ( bool  f)
inline

Definition at line 60 of file ViewFEMesh.hh.

60{ fillMesh = f; }

◆ SetFillMeshWithBorders()

void Garfield::ViewFEMesh::SetFillMeshWithBorders ( )
inline

Definition at line 71 of file ViewFEMesh.hh.

71 {
72 plotMeshBorders = true;
73 fillMesh = true;
74 }

◆ SetPlane()

void Garfield::ViewFEMesh::SetPlane ( double  fx,
double  fy,
double  fz,
double  x0,
double  y0,
double  z0 
)

Definition at line 145 of file ViewFEMesh.cc.

146 {
147
148 // Calculate 2 in-plane vectors for the normal vector
149 double fnorm = sqrt(fx * fx + fy * fy + fz * fz);
150 double dist = fx * x0 + fy * y0 + fz * z0;
151 if (fnorm > 0 && fx * fx + fz * fz > 0) {
152 project[0][0] = fz / sqrt(fx * fx + fz * fz);
153 project[0][1] = 0;
154 project[0][2] = -fx / sqrt(fx * fx + fz * fz);
155 project[1][0] = -fx * fy / (sqrt(fx * fx + fz * fz) * fnorm);
156 project[1][1] = (fx * fx + fz * fz) / (sqrt(fx * fx + fz * fz) * fnorm);
157 project[1][2] = -fy * fz / (sqrt(fx * fx + fz * fz) * fnorm);
158 project[2][0] = dist * fx / (fnorm * fnorm);
159 project[2][1] = dist * fy / (fnorm * fnorm);
160 project[2][2] = dist * fz / (fnorm * fnorm);
161 } else if (fnorm > 0 && fy * fy + fz * fz > 0) {
162 project[0][0] = (fy * fy + fz * fz) / (sqrt(fy * fy + fz * fz) * fnorm);
163 project[0][1] = -fx * fz / (sqrt(fy * fy + fz * fz) * fnorm);
164 project[0][2] = -fy * fz / (sqrt(fy * fy + fz * fz) * fnorm);
165 project[1][0] = 0;
166 project[1][1] = fz / sqrt(fy * fy + fz * fz);
167 project[1][2] = -fy / sqrt(fy * fy + fz * fz);
168 project[2][0] = dist * fx / (fnorm * fnorm);
169 project[2][1] = dist * fy / (fnorm * fnorm);
170 project[2][2] = dist * fz / (fnorm * fnorm);
171 } else {
172 std::cout << className << "::SetPlane:\n";
173 std::cout << " Normal vector has zero norm.\n";
174 std::cout << " No new projection set.\n";
175 }
176
177 // Store the plane description
178 plane[0] = fx;
179 plane[1] = fy;
180 plane[2] = fz;
181 plane[3] = dist;
182}
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313

◆ SetViewDrift()

void Garfield::ViewFEMesh::SetViewDrift ( ViewDrift vd)
inline

Definition at line 68 of file ViewFEMesh.hh.

68{ viewDrift = vd; }

◆ SetXaxis()

void Garfield::ViewFEMesh::SetXaxis ( TGaxis *  ax)

Definition at line 206 of file ViewFEMesh.cc.

206{ xaxis = ax; }

◆ SetXaxisTitle()

void Garfield::ViewFEMesh::SetXaxisTitle ( const char *  xtitle)

Definition at line 212 of file ViewFEMesh.cc.

212 {
213 axes->GetXaxis()->SetTitle(xtitle);
214}

◆ SetYaxis()

void Garfield::ViewFEMesh::SetYaxis ( TGaxis *  ay)

Definition at line 209 of file ViewFEMesh.cc.

209{ yaxis = ay; }

◆ SetYaxisTitle()

void Garfield::ViewFEMesh::SetYaxisTitle ( const char *  ytitle)

Definition at line 217 of file ViewFEMesh.cc.

217 {
218 axes->GetYaxis()->SetTitle(ytitle);
219}

The documentation for this class was generated from the following files: