1 | #include "FlatSurface.h" |
---|
2 | |
---|
3 | #include <float.h> |
---|
4 | using namespace G4FresnelLens; |
---|
5 | |
---|
6 | //__________________________________________________________________________________ |
---|
7 | FlatSurface::FlatSurface(double zpos, double rhomax) : ParametricSurface(zpos, rhomax) { |
---|
8 | Configure(); |
---|
9 | } |
---|
10 | |
---|
11 | //__________________________________________________________________________________ |
---|
12 | void FlatSurface::Configure(){ |
---|
13 | fZ1=fZ2=fZmin=fZmax=fZpos; |
---|
14 | } |
---|
15 | |
---|
16 | //__________________________________________________________________________________ |
---|
17 | double FlatSurface::DistanceToSurf(const G4ThreeVector& p, const G4ThreeVector& v){ |
---|
18 | if(v.z()==0) return kInfinity; |
---|
19 | |
---|
20 | double dz=fZpos-p.z(); |
---|
21 | double cos_theta=v.cosTheta(); |
---|
22 | double dist = dz/cos_theta; |
---|
23 | if( dist<0 ) return kInfinity; |
---|
24 | if ( (p+v*dist).perp2()<=fR*fR) return dist; |
---|
25 | |
---|
26 | return kInfinity; |
---|
27 | } |
---|
28 | |
---|
29 | //__________________________________________________________________________________ |
---|
30 | double FlatSurface::DistanceToSurfSafe(const G4ThreeVector& p){ |
---|
31 | double perp = p.perp(); |
---|
32 | if(perp<=fR) return fabs(p.z()-fZpos); |
---|
33 | |
---|
34 | double drho1 = p.perp()-fR; |
---|
35 | double dz1 = fZpos - p.z(); |
---|
36 | return sqrt(drho1*drho1 + dz1*dz1); |
---|
37 | } |
---|
38 | |
---|
39 | //__________________________________________________________________________________ |
---|
40 | EInside FlatSurface::Inside(double rho, double z, FSIntersectedSegment* intseg){ |
---|
41 | if ( intseg ) FillSegment(rho, intseg); |
---|
42 | |
---|
43 | if ( rho>(fR+kTolerance) || z>(fZpos+kHalfTolerance) ) return kOutside; |
---|
44 | if ( z<(fZpos-kHalfTolerance) ) return kInside; |
---|
45 | return kSurface; |
---|
46 | } |
---|