Garfield++ 3.0
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 public:
17 /// Constructor
19 /// Destructor
21
22 /// Set the geometry (pointer to ROOT TGeoManager).
23 void SetGeometry(TGeoManager* geoman);
24
25 Medium* GetMedium(const double x, const double y, const double z) const override;
26
27 /// Get the number of materials defined in the ROOT geometry.
28 unsigned int GetNumberOfMaterials();
29 /// Get pointer to ROOT material with given index.
30 TGeoMaterial* GetMaterial(const unsigned int i);
31 /// Get pointer to ROOT material with given name.
32 TGeoMaterial* GetMaterial(const char* name);
33 /// Associate a ROOT material with Garfield medium.
34 void SetMedium(const unsigned int imat, Medium* med);
35 /// Associate a ROOT material with Garfield medium.
36 void SetMedium(const char* mat, Medium* med);
37
38 bool IsInside(const double x, const double y, const double z) const override {
39 if (m_geoManager) {
40 m_geoManager->SetCurrentPoint(x, y, z);
41 return !m_geoManager->IsOutside();
42 }
43 return false;
44 }
45
46 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
47 double& ymax, double& zmax) override;
48
49 /// Switch debugging and warning messages on/off.
50 void EnableDebugging(const bool on = true) { m_debug = on; }
51
52 protected:
53 // ROOT geometry manager
54 TGeoManager* m_geoManager = nullptr;
55
56 // List of ROOT materials associated to Garfield media
57 struct material {
58 std::string name;
60 };
61 std::vector<material> m_materials;
62
63 // Switch on/off debugging messages
64 bool m_debug = false;
65 void PrintGeoNotDefined(const std::string& fcn) const;
66};
67}
68
69#endif
Abstract base class for geometry classes.
Definition: GeometryBase.hh:13
Use a geometry defined using the ROOT TGeo package.
Definition: GeometryRoot.hh:15
TGeoManager * m_geoManager
Definition: GeometryRoot.hh:54
unsigned int GetNumberOfMaterials()
Get the number of materials defined in the ROOT geometry.
Definition: GeometryRoot.cc:41
std::vector< material > m_materials
Definition: GeometryRoot.hh:61
GeometryRoot()
Constructor.
Definition: GeometryRoot.cc:12
void SetMedium(const unsigned int imat, Medium *med)
Associate a ROOT material with Garfield medium.
Definition: GeometryRoot.cc:68
void PrintGeoNotDefined(const std::string &fcn) const
void EnableDebugging(const bool on=true)
Switch debugging and warning messages on/off.
Definition: GeometryRoot.hh:50
bool IsInside(const double x, const double y, const double z) const override
Check if a point is inside the geometry.
Definition: GeometryRoot.hh:38
void SetGeometry(TGeoManager *geoman)
Set the geometry (pointer to ROOT TGeoManager).
Definition: GeometryRoot.cc:14
Medium * GetMedium(const double x, const double y, const double z) const override
Retrieve the medium at a given point.
Definition: GeometryRoot.cc:24
TGeoMaterial * GetMaterial(const unsigned int i)
Get pointer to ROOT material with given index.
Definition: GeometryRoot.cc:50
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box (envelope of the geometry).
~GeometryRoot()
Destructor.
Definition: GeometryRoot.hh:20
Abstract base class for media.
Definition: Medium.hh:13