REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorGeometry.h
1
15
16#ifndef RestCore_TRestDetectorGeometry
17#define RestCore_TRestDetectorGeometry
18
19#include <TGeoManager.h>
20#include <TGeoMaterial.h>
21#include <TGeoVolume.h>
22#include <TObject.h>
23
24#include <iostream>
25#include <vector>
26
27#include "TRestDetectorGas.h"
28
29#if defined USE_Garfield
30
31#if defined USE_Garfield_OLD
32#include "ComponentBase.hh"
33#else
34#include "Component.hh"
35#endif
36
37#include "GeometryRoot.hh"
38#include "Sensor.hh"
39
40#if defined USE_Garfield_OLD
41typedef Garfield::ComponentBase Component;
42#else
43typedef Garfield::Component Component;
44#endif
45
46#endif
47
48class TRestDetectorGeometry : public TGeoManager {
49 protected:
50#if defined USE_Garfield
51 Garfield::GeometryRoot* fGfGeometry;
53 std::vector<Component*> vGfComponent;
54 std::vector<Garfield::Sensor*> vGfSensor;
55 TGeoNode* fDriftElec;
56 std::vector<TGeoNode*> vReadoutElec;
57
58#endif
59
60 public:
61 // Constructor
63 // Destructor
64 virtual ~TRestDetectorGeometry();
65
67 void InitGfGeometry();
68
69#if defined USE_Garfield
70
72 Garfield::GeometryRoot* GetGfGeometry() { return fGfGeometry; }
73
75 void SetGfGeoMedium(const char* geoMatName, TRestDetectorGas* gas) {
76 fGfGeometry->SetMedium(geoMatName, gas->GetGasMedium());
77 }
78
80 void AddGfComponent(Component* c) {
81 c->SetGeometry(fGfGeometry);
82 vGfComponent.push_back(c);
83 }
84
86 void AddGfSensor(Garfield::Sensor* s) { vGfSensor.push_back(s); }
87
89 void SetDriftElecNode(TGeoNode* n) { fDriftElec = n; }
90
92 void AddReadoutElecNode(TGeoNode* n) { vReadoutElec.push_back(n); }
93
95 TGeoNode* GetDriftElecNode() { return fDriftElec; }
96
98 int GetNReadoutElecNodes() { return vReadoutElec.size(); }
99
101 TGeoNode* GetReadoutElecNode(unsigned int i) {
102 if (i < vReadoutElec.size())
103 return vReadoutElec[i];
104 else
105 return nullptr;
106 }
107
109 Component* GetGfComponent(unsigned int i) {
110 if (i < vGfComponent.size())
111 return vGfComponent[i];
112 else
113 return nullptr;
114 }
115
117 int GetNbOfGfComponent() { return vGfComponent.size(); }
118
120 Garfield::Sensor* GetGfSensor(unsigned int i) {
121 if (i < vGfSensor.size())
122 return vGfSensor[i];
123 else
124 return nullptr;
125 }
126
128 int GetNbOfGfSensor() { return vGfSensor.size(); }
129
131 Garfield::Medium* GetGfMedium(double x, double y, double z) {
132 FindNode(x / 10., y / 10., z / 10.); // needed due to a bug in TGeoNavigator
133 return fGfGeometry->GetMedium(x / 10., y / 10., z / 10.);
134 } // mm to cm
135#endif
136
137 void PrintGeometry();
138
139 ClassDef(TRestDetectorGeometry, 1); // REST event superclass
140};
141
142#endif
MediumMagboltz * GetGasMedium() const
Return pointer to Garfield::MediumGas for gas properties.
void InitGfGeometry()
initialize Garfield::GeometryRoot geometry object