Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
HeedFieldMap.cpp
Go to the documentation of this file.
1#include <iostream>
2
3#include "Garfield/Sensor.hh"
4
6
7#include "HeedFieldMap.h"
8
9namespace Heed {
10
11void HeedFieldMap::field_map(const point& pt, vec& efield, vec& bfield,
12 vfloat& mrange) const {
13
14 const double x = pt.v.x * conv + m_x;
15 const double y = pt.v.y * conv + m_y;
16 const double z = pt.v.z * conv + m_z;
17
18 // Initialise the electric and magnetic field.
19 efield.x = bfield.x = 0.;
20 efield.y = bfield.y = 0.;
21 efield.z = bfield.z = 0.;
22 mrange = DBL_MAX;
23
24 if (!m_sensor) {
25 std::cerr << "HeedFieldMap::field_map: Sensor not defined.\n";
26 return;
27 }
28
29 if (m_useEfield) {
30 double ex = 0., ey = 0., ez = 0.;
31 int status = 0;
32 Garfield::Medium* m = nullptr;
33 m_sensor->ElectricField(x, y, z, ex, ey, ez, m, status);
34 efield.x = ex * 1.e-7;
35 efield.y = ey * 1.e-7;
36 efield.z = ez * 1.e-7;
37 }
38
39 if (m_useBfield) {
40 double bx = 0., by = 0., bz = 0.;
41 int status = 0;
42 m_sensor->MagneticField(x, y, z, bx, by, bz, status);
43 bfield.x = bx * 1.e-3;
44 bfield.y = by * 1.e-3;
45 bfield.z = bz * 1.e-3;
46 }
47}
48
49bool HeedFieldMap::inside(const point& pt) {
50
51 const double x = pt.v.x * conv + m_x;
52 const double y = pt.v.y * conv + m_y;
53 const double z = pt.v.z * conv + m_z;
54 // Check if the point is inside the drift area.
55 if (!m_sensor->IsInArea(x, y, z)) return false;
56 // Check if the point is inside a medium.
57 Garfield::Medium* m = nullptr;
58 if (!m_sensor->GetMedium(x, y, z, m) || !m) return false;
59 return m->IsIonisable();
60}
61
62}
Abstract base class for media.
Definition: Medium.hh:13
bool IsIonisable() const
Is charge deposition by charged particles/photon enabled in this medium?
Definition: Medium.hh:78
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
Get the magnetic field at (x, y, z).
Definition: Sensor.cc:116
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&medium, int &status)
Get the drift field and potential at (x, y, z).
Definition: Sensor.cc:65
bool IsInArea(const double x, const double y, const double z)
Check if a point is inside the user area.
Definition: Sensor.cc:254
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Get the medium at (x, y, z).
Definition: Sensor.cc:159
bool inside(const point &pt)
void field_map(const point &pt, vec &efield, vec &bfield, vfloat &mrange) const
Point.
Definition: vec.h:368
vec v
Definition: vec.h:370
Definition: vec.h:179
vfloat x
Definition: vec.h:192
vfloat z
Definition: vec.h:194
vfloat y
Definition: vec.h:193
Definition: BGMesh.cpp:6
double vfloat
Definition: vfloat.h:16