Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GeometryRoot.hh
Go to the documentation of this file.
1#ifndef G_GEOMETRY_ROOT_H
2#define G_GEOMETRY_ROOT_H
3
4#include <vector>
5
6#include <TGeoManager.h>
7#include <TGeoMaterial.h>
8
9#include "GeometryBase.hh"
10
11namespace Garfield {
12
13/// Use a geometry defined using the ROOT TGeo package.
14
15class GeometryRoot : public GeometryBase {
16
17 public:
18 /// Constructor
20 /// Destructor
22
23 /// Set the geometry (pointer to ROOT TGeoManager).
24 void SetGeometry(TGeoManager* geoman);
25
26 // Get the medium at a given point (x, y, z)
27 Medium* GetMedium(const double x, const double y,
28 const double z) const;
29
30 /// Get the number of materials defined in the ROOT geometry.
31 unsigned int GetNumberOfMaterials();
32 /// Get pointer to ROOT material with given index.
33 TGeoMaterial* GetMaterial(const unsigned int i);
34 /// Get pointer to ROOT material with given name.
35 TGeoMaterial* GetMaterial(const char* name);
36 // Associate a ROOT material with Garfield medium.
37 void SetMedium(const unsigned int imat, Medium* med);
38 void SetMedium(const char* mat, Medium* med);
39
40 bool IsInside(const double x, const double y, const double z) const {
41
42 if (m_geoManager) {
43 m_geoManager->SetCurrentPoint(x, y, z);
44 return !m_geoManager->IsOutside();
45 }
46 return false;
47 }
48
49 // Bounding box (envelope of geometry)
50 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
51 double& ymax, double& zmax);
52
53 // Switch on/off debugging and warning messages
54 void EnableDebugging() { m_debug = true; }
55 void DisableDebugging() { m_debug = false; }
56
57 protected:
58 // ROOT geometry manager
59 TGeoManager* m_geoManager;
60
61 // List of ROOT materials associated to Garfield media
62 struct material {
63 std::string name;
65 };
66 std::vector<material> m_materials;
67
68 // Switch on/off debugging messages
69 bool m_debug;
70};
71}
72
73#endif
Abstract base class for geometry classes.
Definition: GeometryBase.hh:12
Use a geometry defined using the ROOT TGeo package.
Definition: GeometryRoot.hh:15
TGeoManager * m_geoManager
Definition: GeometryRoot.hh:59
unsigned int GetNumberOfMaterials()
Get the number of materials defined in the ROOT geometry.
Definition: GeometryRoot.cc:47
std::vector< material > m_materials
Definition: GeometryRoot.hh:66
GeometryRoot()
Constructor.
Definition: GeometryRoot.cc:12
void SetMedium(const unsigned int imat, Medium *med)
Definition: GeometryRoot.cc:83
bool IsInside(const double x, const double y, const double z) const
Definition: GeometryRoot.hh:40
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
void SetGeometry(TGeoManager *geoman)
Set the geometry (pointer to ROOT TGeoManager).
Definition: GeometryRoot.cc:18
TGeoMaterial * GetMaterial(const unsigned int i)
Get pointer to ROOT material with given index.
Definition: GeometryRoot.cc:59
~GeometryRoot()
Destructor.
Definition: GeometryRoot.hh:21
Medium * GetMedium(const double x, const double y, const double z) const
Definition: GeometryRoot.cc:29
Abstract base class for media.
Definition: Medium.hh:11