GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
CGAGearPointProperties.cc
1 #include <string>
2 #include <vector>
3 #include <iostream>
4 
5 #include "gear/GEAR.h"
6 #include "gearcga/CGAGearPointProperties.h"
7 #include "gearcga/CGAGeometryInitializer.h"
8 #include "CGADefs.h"
9 
10 namespace gear {
11 
12  CGAGearPointProperties::CGAGearPointProperties(std::string steer,
13  std::string model, std::string setup, std::string host,
14  std::string user, std::string password) {
15 
16  CGAGeometryInitializer::GetCGAGeometryInitializer(steer, model,
17  setup, host, user, password);
18 
19  }
20 
21  //vec getPosition returns the current position (if ID is known)
24  long64 CGAGearPointProperties::getCellID(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
25 
26  double x, y, z;
27  int flag;
28  x = pos[0];
29  y = pos[1];
30  z = pos[2];
31  cell_ids cellIDs = CGAGetCellId(x, y, z, flag, 0.0, 0.0, 1.0);
32 
33  char text[2048];
34  sprintf(text, "CGAGearPointProperties::getCellID: Point (%f, %f, %f) ",
35  x , y , z);
36  if(cellIDs.id0 < 0) {
37  throw gear::Exception((const std::string)(text) +
38  " is outside of world volume." );
39  }
40  else if(flag == -1) {
41  throw gear::Exception((const std::string)(text) +
42  " is outside of sensitive volume");
43  }
44  else if(flag == 0)
45  std::cout << text <<
46  " is in guard-ring. Returning CellID of nearest cell."
47  << std::endl;
48 
49  int SHIFT_A_64 = 0;
50  int SHIFT_B_64 = 32;
51 
52  unsigned long long MASK_A_64 = 0x00000000FFFFFFFFLL;
53  unsigned long long MASK_B_64 = 0xFFFFFFFF00000000LL;
54 
55  long64 result = (unsigned long long) (
56  ((((unsigned long long)(cellIDs.id0))<<SHIFT_A_64)&MASK_A_64)|
57  ((((unsigned long long)(cellIDs.id1))<<SHIFT_B_64)&MASK_B_64)
58  );
59 
60  return result;
61  }
62 
63  // bool getMaterial (true if defined material, false if problem)
66  const std::string & CGAGearPointProperties::getMaterialName(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
67 
68  static std::string matName("unknown");
69 
70  double position[3];
71  position[0] = pos[0];
72  position[1] = pos[1];
73  position[2] = pos[2];
74 
75  matName = CGAGetMaterialName(position);
76 
77  return matName;
78 
79  }
82  double CGAGearPointProperties::getDensity(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
83 
84  double position[3];
85  position[0] = pos[0];
86  position[1] = pos[1];
87  position[2] = pos[2];
88 
89  return CGAGetDensity(position);
90  }
91 
92 // /** Name of material at pos.
93 // */
94 // public double getState( const Vector3D& pos) const throws NotImplementedException ;
97  double CGAGearPointProperties::getTemperature(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
98 
99  double position[3];
100  position[0] = pos[0];
101  position[1] = pos[1];
102  position[2] = pos[2];
103 
104  return CGAGetTemperature(position);
105  }
106 
109  double CGAGearPointProperties::getPressure(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
110 
111  double position[3];
112  position[0] = pos[0];
113  position[1] = pos[1];
114  position[2] = pos[2];
115 
116  return CGAGetPressure(position);
117 
118  }
119 
122  double CGAGearPointProperties::getRadlen(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
123 
124  double position[3];
125  position[0] = pos[0];
126  position[1] = pos[1];
127  position[2] = pos[2];
128 
129  return CGAGetRadLen(position);
130  }
131 
134  double CGAGearPointProperties::getIntlen(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
135 
136  double position[3];
137  position[0] = pos[0];
138  position[1] = pos[1];
139  position[2] = pos[2];
140 
141  return CGAGetIntLen(position);
142  }
143 
147 
148  double position[3];
149  position[0] = pos[0];
150  position[1] = pos[1];
151  position[2] = pos[2];
152 
153  std::vector<double> result = CGAGetLocalPosition(position);
154 
155  return Vector3D(result[0], result[1], result[2]);
156  }
157 
160  Vector3D CGAGearPointProperties::getB(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
161 
162  double position[3];
163  position[0] = pos[0];
164  position[1] = pos[1];
165  position[2] = pos[2];
166 
167  std::vector<double> result = CGAGetB(position);
168 
169  return Vector3D(result[0], result[1], result[2]);
170 
171  }
172 
175  Vector3D CGAGearPointProperties::getE(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
176 
177  double position[3];
178  position[0] = pos[0];
179  position[1] = pos[1];
180  position[2] = pos[2];
181 
182  std::vector<double> result = CGAGetE(position);
183 
184  return Vector3D(result[0], result[1], result[2]);
185  }
186 
189  std::vector<std::string> CGAGearPointProperties::getListOfLogicalVolumes(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
190 
191  double position[3];
192  position[0] = pos[0];
193  position[1] = pos[1];
194  position[2] = pos[2];
195 
196  return CGAGetListOfLogicalVolumes(position);
197  }
200  std::vector<std::string> CGAGearPointProperties::getListOfPhysicalVolumes(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
201 
202  double position[3];
203  position[0] = pos[0];
204  position[1] = pos[1];
205  position[2] = pos[2];
206 
207  return CGAGetListOfPhysicalVolumes(position);
208  }
209 
212  std::string CGAGearPointProperties::getRegion(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
213 
214  double position[3];
215  position[0] = pos[0];
216  position[1] = pos[1];
217  position[2] = pos[2];
218 
219  return CGAGetRegionName(position);
220  }
221 
224  bool CGAGearPointProperties::isTracker(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
225 
226  double position[3];
227  position[0] = pos[0];
228  position[1] = pos[1];
229  position[2] = pos[2];
230 
231  return CGAIsTracker(position);
232  }
233 
236  bool CGAGearPointProperties::isCalorimeter(const Vector3D & pos) const throw (NotImplementedException, std::exception ) {
237 
238  double position[3];
239  position[0] = pos[0];
240  position[1] = pos[1];
241  position[2] = pos[2];
242 
243  return CGAIsCalorimeter(position);
244  }
245 
246 } // namespace gear
virtual double getPressure(const Vector3D &pos) const
Pressure in P at pos.
virtual Vector3D getB(const Vector3D &pos) const
The magnetic field vector at pos in [Tesla].
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...
Base exception class for GEAR - all other exceptions extend this.
Definition: GEAR.h:41
virtual double getDensity(const Vector3D &pos) const
Density in kg/m^3 at pos.
virtual Vector3D getLocalPosition(const Vector3D &pos) const
Position in local coordinate.
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 bool isTracker(const Vector3D &pos) const
True if region that contains pos is defined as a tracker.
virtual long64 getCellID(const Vector3D &pos) const
The cellID of the the sensitive detector at pos.
virtual bool isCalorimeter(const Vector3D &pos) const
True if region that contains pos is defined as a calorimeter.
virtual Vector3D getE(const Vector3D &pos) const
The electric field vector at pos in [V/m].
virtual std::string getRegion(const Vector3D &pos) const
Names of (geant4) region that contains the given pos.
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 const std::string & getMaterialName(const Vector3D &pos) const
Name of material at pos.
virtual double getIntlen(const Vector3D &pos) const
Interaction length of material in mm at pos.
virtual double getTemperature(const Vector3D &pos) const
Name of material at pos.
virtual double getRadlen(const Vector3D &pos) const
Radiation length of material in mm at pos.