Garfield++ 4.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 <map>
5
6#include <TGeoManager.h>
7#include <TGeoMaterial.h>
8
9#include "Geometry.hh"
10
11namespace Garfield {
12
13/// Use a geometry defined using the ROOT TGeo package.
14
15class GeometryRoot : public Geometry {
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,
26 const bool tesselated = false) const override;
27
28 /// Get the number of materials defined in the ROOT geometry.
29 unsigned int GetNumberOfMaterials();
30 /// Get a pointer to the ROOT material with a given index.
31 TGeoMaterial* GetMaterial(const unsigned int i);
32 /// Get a pointer to the ROOT material with a given name.
33 TGeoMaterial* GetMaterial(const char* name);
34 /// Associate a ROOT material with a Garfield medium.
35 void SetMedium(const unsigned int imat, Medium* med);
36 /// Associate a ROOT material with a Garfield medium.
37 void SetMedium(const char* mat, Medium* med);
38
39 bool IsInside(const double x, const double y, const double z,
40 const bool tesselated = false) const override;
41 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
42 double& ymax, double& zmax) override;
43
44 /// Switch debugging and warning messages on/off.
45 void EnableDebugging(const bool on = true) { m_debug = on; }
46
47 protected:
48 // ROOT geometry manager
49 TGeoManager* m_geoManager = nullptr;
50
51 // List of ROOT materials associated to Garfield media
52 std::map<std::string, Medium*> m_materials;
53
54 // Switch on/off debugging messages.
55 bool m_debug = false;
56 void PrintGeoNotDefined(const std::string& fcn) const;
57};
58}
59
60#endif
Use a geometry defined using the ROOT TGeo package.
Definition: GeometryRoot.hh:15
TGeoManager * m_geoManager
Definition: GeometryRoot.hh:49
unsigned int GetNumberOfMaterials()
Get the number of materials defined in the ROOT geometry.
Definition: GeometryRoot.cc:36
GeometryRoot()
Constructor.
Definition: GeometryRoot.cc:12
bool IsInside(const double x, const double y, const double z, const bool tesselated=false) const override
Check if a point is inside the geometry.
void SetMedium(const unsigned int imat, Medium *med)
Associate a ROOT material with a Garfield medium.
Definition: GeometryRoot.cc:63
void PrintGeoNotDefined(const std::string &fcn) const
void EnableDebugging(const bool on=true)
Switch debugging and warning messages on/off.
Definition: GeometryRoot.hh:45
std::map< std::string, Medium * > m_materials
Definition: GeometryRoot.hh:52
void SetGeometry(TGeoManager *geoman)
Set the geometry (pointer to ROOT TGeoManager).
Definition: GeometryRoot.cc:14
TGeoMaterial * GetMaterial(const unsigned int i)
Get a pointer to the ROOT material with a given index.
Definition: GeometryRoot.cc:45
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
Medium * GetMedium(const double x, const double y, const double z, const bool tesselated=false) const override
Retrieve the medium at a given point.
Definition: GeometryRoot.cc:23
Abstract base class for geometry classes.
Definition: Geometry.hh:13
Abstract base class for media.
Definition: Medium.hh:13