Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4IntersectingCone Class Reference

#include <G4IntersectingCone.hh>

Public Member Functions

 G4IntersectingCone (const G4double r[2], const G4double z[2])
 
virtual ~G4IntersectingCone ()
 
G4int LineHitsCone (const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)
 
G4bool HitOn (const G4double r, const G4double z)
 
G4double RLo () const
 
G4double RHi () const
 
G4double ZLo () const
 
G4double ZHi () const
 
 G4IntersectingCone (__void__ &)
 

Protected Member Functions

G4int LineHitsCone1 (const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)
 
G4int LineHitsCone2 (const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)
 

Protected Attributes

G4double zLo
 
G4double zHi
 
G4double rLo
 
G4double rHi
 
G4bool type1
 
G4double A
 
G4double B
 

Detailed Description

Definition at line 51 of file G4IntersectingCone.hh.

Constructor & Destructor Documentation

G4IntersectingCone::G4IntersectingCone ( const G4double  r[2],
const G4double  z[2] 
)

Definition at line 46 of file G4IntersectingCone.cc.

48 {
49  const G4double halfCarTolerance
51 
52  //
53  // What type of cone are we?
54  //
55  type1 = (std::fabs(z[1]-z[0]) > std::fabs(r[1]-r[0]));
56 
57  if (type1)
58  {
59  B = (r[1]-r[0])/(z[1]-z[0]); // tube like
60  A = 0.5*( r[1]+r[0] - B*(z[1]+z[0]) );
61  }
62  else
63  {
64  B = (z[1]-z[0])/(r[1]-r[0]); // disk like
65  A = 0.5*( z[1]+z[0] - B*(r[1]+r[0]) );
66  }
67  //
68  // Calculate extent
69  //
70  if (r[0] < r[1])
71  {
72  rLo = r[0]-halfCarTolerance; rHi = r[1]+halfCarTolerance;
73  }
74  else
75  {
76  rLo = r[1]-halfCarTolerance; rHi = r[0]+halfCarTolerance;
77  }
78 
79  if (z[0] < z[1])
80  {
81  zLo = z[0]-halfCarTolerance; zHi = z[1]+halfCarTolerance;
82  }
83  else
84  {
85  zLo = z[1]-halfCarTolerance; zHi = z[0]+halfCarTolerance;
86  }
87 }
G4double GetSurfaceTolerance() const
tuple z
Definition: test.py:28
double G4double
Definition: G4Types.hh:76
static G4GeometryTolerance * GetInstance()

Here is the call graph for this function:

G4IntersectingCone::~G4IntersectingCone ( )
virtual

Definition at line 103 of file G4IntersectingCone.cc.

104 {
105 }
G4IntersectingCone::G4IntersectingCone ( __void__ &  )

Definition at line 94 of file G4IntersectingCone.cc.

95  : zLo(0.), zHi(0.), rLo(0.), rHi(0.), type1(false), A(0.), B(0.)
96 {
97 }

Member Function Documentation

G4bool G4IntersectingCone::HitOn ( const G4double  r,
const G4double  z 
)

Definition at line 114 of file G4IntersectingCone.cc.

116 {
117  //
118  // Be careful! The inequalities cannot be "<=" and ">=" here without
119  // punching a tiny hole in our shape!
120  //
121  if (type1)
122  {
123  if (z < zLo || z > zHi) return false;
124  }
125  else
126  {
127  if (r < rLo || r > rHi) return false;
128  }
129 
130  return true;
131 }

Here is the caller graph for this function:

G4int G4IntersectingCone::LineHitsCone ( const G4ThreeVector p,
const G4ThreeVector v,
G4double s1,
G4double s2 
)

Definition at line 140 of file G4IntersectingCone.cc.

143 {
144  if (type1)
145  {
146  return LineHitsCone1( p, v, s1, s2 );
147  }
148  else
149  {
150  return LineHitsCone2( p, v, s1, s2 );
151  }
152 }
G4int LineHitsCone1(const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)
G4int LineHitsCone2(const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4IntersectingCone::LineHitsCone1 ( const G4ThreeVector p,
const G4ThreeVector v,
G4double s1,
G4double s2 
)
protected

Definition at line 214 of file G4IntersectingCone.cc.

217 {
218  static const G4double EPS = DBL_EPSILON; // Precision constant,
219  // originally it was 1E-6
220  G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
221  G4double tx = v.x(), ty = v.y(), tz = v.z();
222 
223  G4double a = tx*tx + ty*ty - sqr(B*tz);
224  G4double b = 2*( x0*tx + y0*ty - (A*B + B*B*z0)*tz);
225  G4double c = x0*x0 + y0*y0 - sqr(A + B*z0);
226 
227  G4double radical = b*b - 4*a*c;
228 
229  if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
230 
231  if (radical < EPS*std::fabs(b))
232  {
233  //
234  // The radical is roughly zero: check for special, very rare, cases
235  //
236  if (std::fabs(a) > 1/kInfinity)
237  {
238  if(B==0.) { return 0; }
239  if ( std::fabs(x0*ty - y0*tx) < std::fabs(EPS/B) )
240  {
241  *s1 = -0.5*b/a;
242  return 1;
243  }
244  return 0;
245  }
246  }
247  else
248  {
249  radical = std::sqrt(radical);
250  }
251 
252  if (a > 1/kInfinity)
253  {
254  G4double sa, sb, q = -0.5*( b + (b < 0 ? -radical : +radical) );
255  sa = q/a;
256  sb = c/q;
257  if (sa < sb) { *s1 = sa; *s2 = sb; } else { *s1 = sb; *s2 = sa; }
258  if (A + B*(z0+(*s1)*tz) < 0) { return 0; }
259  return 2;
260  }
261  else if (a < -1/kInfinity)
262  {
263  G4double sa, sb, q = -0.5*( b + (b < 0 ? -radical : +radical) );
264  sa = q/a;
265  sb = c/q;
266  *s1 = (B*tz > 0)^(sa > sb) ? sb : sa;
267  return 1;
268  }
269  else if (std::fabs(b) < 1/kInfinity)
270  {
271  return 0;
272  }
273  else
274  {
275  *s1 = -c/b;
276  if (A + B*(z0+(*s1)*tz) < 0) { return 0; }
277  return 1;
278  }
279 }
static const G4double kInfinity
Definition: geomdefs.hh:42
double x() const
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
double z() const
tuple b
Definition: test.py:12
#define DBL_EPSILON
Definition: templates.hh:87
double y() const
#define EPS
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4IntersectingCone::LineHitsCone2 ( const G4ThreeVector p,
const G4ThreeVector v,
G4double s1,
G4double s2 
)
protected

Definition at line 306 of file G4IntersectingCone.cc.

309 {
310  static const G4double EPS = DBL_EPSILON; // Precision constant,
311  // originally it was 1E-6
312  G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
313  G4double tx = v.x(), ty = v.y(), tz = v.z();
314 
315  // Special case which might not be so rare: B = 0 (precisely)
316  //
317  if (B==0)
318  {
319  if (std::fabs(tz) < 1/kInfinity) { return 0; }
320 
321  *s1 = (A-z0)/tz;
322  return 1;
323  }
324 
325  G4double B2 = B*B;
326 
327  G4double a = tz*tz - B2*(tx*tx + ty*ty);
328  G4double b = 2*( (z0-A)*tz - B2*(x0*tx + y0*ty) );
329  G4double c = sqr(z0-A) - B2*( x0*x0 + y0*y0 );
330 
331  G4double radical = b*b - 4*a*c;
332 
333  if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
334 
335  if (radical < EPS*std::fabs(b))
336  {
337  //
338  // The radical is roughly zero: check for special, very rare, cases
339  //
340  if (std::fabs(a) > 1/kInfinity)
341  {
342  if ( std::fabs(x0*ty - y0*tx) < std::fabs(EPS/B) )
343  {
344  *s1 = -0.5*b/a;
345  return 1;
346  }
347  return 0;
348  }
349  }
350  else
351  {
352  radical = std::sqrt(radical);
353  }
354 
355  if (a < -1/kInfinity)
356  {
357  G4double sa, sb, q = -0.5*( b + (b < 0 ? -radical : +radical) );
358  sa = q/a;
359  sb = c/q;
360  if (sa < sb) { *s1 = sa; *s2 = sb; } else { *s1 = sb; *s2 = sa; }
361  if ((z0 + (*s1)*tz - A)/B < 0) { return 0; }
362  return 2;
363  }
364  else if (a > 1/kInfinity)
365  {
366  G4double sa, sb, q = -0.5*( b + (b < 0 ? -radical : +radical) );
367  sa = q/a;
368  sb = c/q;
369  *s1 = (tz*B > 0)^(sa > sb) ? sb : sa;
370  return 1;
371  }
372  else if (std::fabs(b) < 1/kInfinity)
373  {
374  return 0;
375  }
376  else
377  {
378  *s1 = -c/b;
379  if ((z0 + (*s1)*tz - A)/B < 0) { return 0; }
380  return 1;
381  }
382 }
static const G4double kInfinity
Definition: geomdefs.hh:42
double x() const
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
double z() const
tuple b
Definition: test.py:12
#define DBL_EPSILON
Definition: templates.hh:87
double y() const
#define EPS
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4IntersectingCone::RHi ( ) const
inline

Definition at line 64 of file G4IntersectingCone.hh.

64 { return rHi; }
G4double G4IntersectingCone::RLo ( ) const
inline

Definition at line 63 of file G4IntersectingCone.hh.

63 { return rLo; }
G4double G4IntersectingCone::ZHi ( ) const
inline

Definition at line 66 of file G4IntersectingCone.hh.

66 { return zHi; }

Here is the caller graph for this function:

G4double G4IntersectingCone::ZLo ( ) const
inline

Definition at line 65 of file G4IntersectingCone.hh.

65 { return zLo; }

Here is the caller graph for this function:

Member Data Documentation

G4double G4IntersectingCone::A
protected

Definition at line 83 of file G4IntersectingCone.hh.

G4double G4IntersectingCone::B
protected

Definition at line 83 of file G4IntersectingCone.hh.

G4double G4IntersectingCone::rHi
protected

Definition at line 78 of file G4IntersectingCone.hh.

G4double G4IntersectingCone::rLo
protected

Definition at line 78 of file G4IntersectingCone.hh.

G4bool G4IntersectingCone::type1
protected

Definition at line 81 of file G4IntersectingCone.hh.

G4double G4IntersectingCone::zHi
protected

Definition at line 78 of file G4IntersectingCone.hh.

G4double G4IntersectingCone::zLo
protected

Definition at line 78 of file G4IntersectingCone.hh.


The documentation for this class was generated from the following files: