Garfield++ v2r0
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 "Sensor.hh"
4
6
7#include "HeedFieldMap.h"
8
9namespace Heed {
10
11const double HeedFieldMap::conv = 1. / CLHEP::cm;
12
14 : m_x(0.),
15 m_y(0.),
16 m_z(0.),
17 m_sensor(NULL),
18 m_useEfield(false),
19 m_useBfield(false) {}
20
21void HeedFieldMap::field_map(const point& pt, vec& efield, vec& bfield,
22 vfloat& mrange) const {
23
24 const double x = pt.v.x * conv + m_x;
25 const double y = pt.v.y * conv + m_y;
26 const double z = pt.v.z * conv + m_z;
27
28 // Initialise the electric and magnetic field.
29 efield = vec(0., 0., 0.);
30 bfield = vec(0., 0., 0.);
31 mrange = DBL_MAX;
32
33 if (!m_sensor) {
34 std::cerr << "HeedFieldMap::field_map: Sensor not defined.\n";
35 return;
36 }
37
38 if (m_useEfield) {
39 double ex = 0., ey = 0., ez = 0.;
40 int status = 0;
41 Garfield::Medium* m = NULL;
42 m_sensor->ElectricField(x, y, z, ex, ey, ez, m, status);
43 efield.x = ex * 1.e-7;
44 efield.y = ey * 1.e-7;
45 efield.z = ez * 1.e-7;
46 }
47
48 if (m_useBfield) {
49 double bx = 0., by = 0., bz = 0.;
50 int status = 0;
51 m_sensor->MagneticField(x, y, z, bx, by, bz, status);
52 bfield.x = bx * 1.e-3;
53 bfield.y = by * 1.e-3;
54 bfield.z = bz * 1.e-3;
55 }
56}
57
58bool HeedFieldMap::inside(const point& pt) {
59
60 const double x = pt.v.x * conv + m_x;
61 const double y = pt.v.y * conv + m_y;
62 const double z = pt.v.z * conv + m_z;
63 // Check if the point is inside the drift area.
64 if (!m_sensor->IsInArea(x, y, z)) return false;
65 // Check if the point is inside a medium.
66 Garfield::Medium* m = NULL;
67 if (!m_sensor->GetMedium(x, y, z, m) || !m) return false;
68 return m->IsIonisable();
69}
70
71}
Abstract base class for media.
Definition: Medium.hh:11
bool IsIonisable() const
Definition: Medium.hh:59
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:101
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:48
bool IsInArea(const double x, const double y, const double z)
Check if a point is inside the user area.
Definition: Sensor.cc:264
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Get the medium at (x, y, z).
Definition: Sensor.cc:150
bool inside(const point &pt)
void field_map(const point &pt, vec &efield, vec &bfield, vfloat &mrange) const
Point.
Definition: vec.h:374
vec v
Definition: vec.h:376
Definition: vec.h:186
vfloat x
Definition: vec.h:203
vfloat z
Definition: vec.h:203
vfloat y
Definition: vec.h:203
Definition: BGMesh.cpp:5
double vfloat
Definition: vfloat.h:16