GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
TGeoGearPointProperties.cc
1 #include <string>
2 #include <vector>
3 #include <iostream>
4 
5 #include "gear/GEAR.h"
6 #include "geartgeo/TGeoGearPointProperties.h"
7 #include "geartgeo/TGeoGeometryInitializer.h"
8 #include "TGeoVolume.h"
9 #include "TGeoManager.h"
10 #include "TGeoNode.h"
11 
12 namespace gear {
13 
14  TGeoGearPointProperties::TGeoGearPointProperties(TGeoManager *geoMgr){
15  _tgeomanager=geoMgr;
16  }
17 
18 // //vec getPosition returns the current position (if ID is known)
22  throw NotImplementedException("getCellID not implemented yet in TGeoGearPointProperties");
23  return 0;
24 
25  }
26 
27  // bool getMaterial (true if defined material, false if problem)
30  const std::string & TGeoGearPointProperties::getMaterialName(const Vector3D & pos) const {
31 
32  double position[3];
33  position[0] = pos[0];
34  position[1] = pos[1];
35  position[2] = pos[2];
36 
37  static std::string matName("unknown");
38  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
39  if(node)
40  matName=node->GetMedium()->GetMaterial()->GetName();
41  else
42  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
43  return matName;
44 
45  }
48  double TGeoGearPointProperties::getDensity(const Vector3D & pos) const {
49 
50  double position[3];
51  position[0] = pos[0];
52  position[1] = pos[1];
53  position[2] = pos[2];
54 
55  double density=0;
56  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
57  if(node)
58  density=node->GetMedium()->GetMaterial()->GetDensity();
59  else
60  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
61  return density;
62 
63  }
65 
66  double position[3];
67  position[0] = pos[0];
68  position[1] = pos[1];
69  position[2] = pos[2];
70 
71  double temperature=0;
72  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
73  if(node)
74  temperature=node->GetMedium()->GetMaterial()->GetTemperature();
75  else
76  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
77  return temperature;
78  }
79 
82  double TGeoGearPointProperties::getPressure(const Vector3D & pos) const {
83 
84  double position[3];
85  position[0] = pos[0];
86  position[1] = pos[1];
87  position[2] = pos[2];
88 
89  double pressure=0;
90  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
91  if(node)
92  pressure=node->GetMedium()->GetMaterial()->GetPressure();
93  else
94  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
95  return pressure;
96 
97  }
98 
101  double TGeoGearPointProperties::getRadlen(const Vector3D & pos) const {
102 
103  double position[3];
104  position[0] = pos[0];
105  position[1] = pos[1];
106  position[2] = pos[2];
107 
108  double radLen=0;
109  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
110  if(node)
111  radLen=node->GetMedium()->GetMaterial()->GetRadLen();
112  else
113  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
114  return radLen;
115  }
116 
119  double TGeoGearPointProperties::getIntlen(const Vector3D & pos) const {
120 
121  double position[3];
122  position[0] = pos[0];
123  position[1] = pos[1];
124  position[2] = pos[2];
125 
126  double intLen=0;
127  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
128  if(node)
129  intLen=node->GetMedium()->GetMaterial()->GetIntLen();
130  else
131  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
132  return intLen;
133  }
134 
138 
139  const Double_t global[3]={pos[0],pos[1],pos[2]};
140  Double_t local[3];
141 
142  _tgeomanager->MasterToLocal(global, local);
143 
144  return Vector3D(local[0],local[1],local[2]) ;
145 
146  }
147 
151  throw NotImplementedException("getB not implemented yet in TGeoGearPointProperties");
152  return Vector3D() ;
153  }
154 
158  throw NotImplementedException("getE not implemented yet in TGeoGearPointProperties");
159  return Vector3D();
160 
161  }
162 
165  std::vector<std::string> TGeoGearPointProperties::getListOfLogicalVolumes(const Vector3D & pos) const {
166 
167  double position[3];
168  position[0] = pos[0];
169  position[1] = pos[1];
170  position[2] = pos[2];
171  std::vector<std::string> names;
172  TGeoNode *node= _tgeomanager->FindNode(position[0],position[1],position[2]);
173  if(!node)
174  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
175 
176  TGeoVolume *cvol=_tgeomanager->GetCurrentVolume();
177  int count=0;
178  while(cvol)
179  {
180  const char *name=cvol->GetName();
181  names.push_back(name);
182  _tgeomanager->CdUp();
183  cvol=_tgeomanager->GetCurrentVolume();
184  if(name==_tgeomanager->GetTopVolume()->GetName())
185  break;
186  count++;
187  }
188  return names;
189  }
192  std::vector<std::string> TGeoGearPointProperties::getListOfPhysicalVolumes(const Vector3D & pos) const {
193 
194  double position[3];
195  position[0] = pos[0];
196  position[1] = pos[1];
197  position[2] = pos[2];
198 
199  std::vector<std::string> names;
200  TGeoNode *node=_tgeomanager->FindNode(position[0],position[1],position[2]);
201  if(!node)
202  throw OutsideGeometryException("No geometry node found at given location. Either there is no node placed here or position is outside of top volume.");
203 
204  int count=0;
205  while(node)
206  {
207  const char *name=node->GetName();
208  names.push_back(name);
209  _tgeomanager->CdUp();
210  node=_tgeomanager->GetCurrentNode();
211  if(name==_tgeomanager->GetTopNode()->GetName())
212  break;
213  count++;
214  }
215  return names;
216  }
217 
220  std::string TGeoGearPointProperties::getRegion(const Vector3D &) const {
221  throw NotImplementedException("getRegion not implemented yet in TGeoGearPointProperties");
222  return "";
223  }
227  throw NotImplementedException("isTracker not implemented yet in TGeoGearPointProperties");
228  return 0;
229  }
233  throw NotImplementedException("isCalorimeter not implemented yet in TGeoGearPointProperties");
234  return 0;
235 
236  }
237 
238 } // namespace gear
virtual bool isCalorimeter(const Vector3D &pos) const
True if region that contains pos is defined as a calorimeter.
virtual bool isTracker(const Vector3D &pos) const
True if region that contains pos is defined as a tracker.
virtual std::vector< std::string > getListOfLogicalVolumes(const Vector3D &pos) const
Names of (geant4) logical volumes in heirarchy starting at given pos ending with the world volume...
virtual Vector3D getLocalPosition(const Vector3D &pos) const
Position in local coordinate.
virtual double getTemperature(const Vector3D &pos) const
Name of material at pos.
virtual Vector3D getB(const Vector3D &pos) const
The magnetic field vector at pos in [Tesla].
virtual double getIntlen(const Vector3D &pos) const
Interaction length of material in mm at pos.
NotImplementedException used for features that are not implemented.
Definition: GEAR.h:81
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
Definition: Vector3D.h:18
long long long64
64 bit integer,e.g.to be used for cellids
Definition: GEAR.h:32
virtual double getDensity(const Vector3D &pos) const
Density in kg/m^3 at pos.
OutsideGeometryException used if user asks for info from geometry tree where no node is defined...
Definition: GEAR.h:118
virtual std::string getRegion(const Vector3D &pos) const
Names of (geant4) region that contains the given pos.
virtual double getPressure(const Vector3D &pos) const
Pressure in P at pos.
virtual double getRadlen(const Vector3D &pos) const
Radiation length of material in mm at pos.
virtual long64 getCellID(const Vector3D &pos) const
The cellID of the the sensitive detector at pos.
virtual const std::string & getMaterialName(const Vector3D &pos) const
Name of material at pos.
virtual std::vector< std::string > getListOfPhysicalVolumes(const Vector3D &pos) const
Names of (geant4) physical volumes in heirarchy starting at given pos ending with the world volume...
virtual Vector3D getE(const Vector3D &pos) const
The electric field vector at pos in [V/m].