1 | #ifndef __CYLINDRICSURFACE__ |
---|
2 | #define __CYLINDRICSURFACE__ |
---|
3 | |
---|
4 | #include "ParametricSurface.h" |
---|
5 | |
---|
6 | namespace G4FresnelLens{ |
---|
7 | |
---|
8 | class CylindricSurface : public ParametricSurface |
---|
9 | { |
---|
10 | public: |
---|
11 | CylindricSurface(double z1=0., double z2=0., double rmax=0.); |
---|
12 | ~CylindricSurface(); |
---|
13 | |
---|
14 | void Configure(); |
---|
15 | double PointOnSurf(double x); |
---|
16 | double PointOnSurf2(double x); |
---|
17 | double DistanceToSurf(const G4ThreeVector& p, const G4ThreeVector& v); |
---|
18 | double DistanceToSurfSafe(const G4ThreeVector& p); |
---|
19 | double Derivative(double x); |
---|
20 | EInside Inside(double rho, double z, FSIntersectedSegment *intSeg=0); |
---|
21 | virtual void FillSegment(double rho, FSIntersectedSegment *intS); |
---|
22 | bool Normal(FSIntersectedSegment* ints, const G4ThreeVector& p, double up, G4ThreeVector* norm); |
---|
23 | bool operator==(SSurface&); |
---|
24 | |
---|
25 | void SetZ(double zmin, double zmax); //keeps direction |
---|
26 | void print(); |
---|
27 | protected: |
---|
28 | void GuessParameters(int n, int tn, int* idx, double* rho, double* z, bool minimum){}; |
---|
29 | |
---|
30 | private: |
---|
31 | int fDirection; // +1 up of -1 for down |
---|
32 | }; |
---|
33 | |
---|
34 | //__________________________________________________________________________________ |
---|
35 | inline double CylindricSurface::PointOnSurf(double x){ |
---|
36 | printf("should not be called\n"); |
---|
37 | return fZmin; |
---|
38 | } |
---|
39 | |
---|
40 | //__________________________________________________________________________________ |
---|
41 | inline double CylindricSurface::PointOnSurf2(double x2){ |
---|
42 | printf("should not be called\n"); |
---|
43 | return fZmin; |
---|
44 | } |
---|
45 | |
---|
46 | //__________________________________________________________________________________ |
---|
47 | inline double CylindricSurface::Derivative(double x){ |
---|
48 | return fDirection*DBL_MAX; |
---|
49 | } |
---|
50 | |
---|
51 | //______________________________________________________________________________________________________________________ |
---|
52 | inline void CylindricSurface::FillSegment(double rho, FSIntersectedSegment *intSeg){ |
---|
53 | intSeg->surf=this; |
---|
54 | intSeg->perp=rho; |
---|
55 | } |
---|
56 | |
---|
57 | //______________________________________________________________________________________________________________________ |
---|
58 | inline EInside CylindricSurface::Inside(double rho, double z, FSIntersectedSegment *intSeg){ |
---|
59 | if ( z>(fZmax+kHalfTolerance) || rho>fR+kHalfTolerance ) return kOutside; |
---|
60 | if ( rho<fR-kHalfTolerance || z<(fZmin-kHalfTolerance) ) return kInside; |
---|
61 | if (intSeg) FillSegment(rho, intSeg); |
---|
62 | return kSurface; |
---|
63 | } |
---|
64 | |
---|
65 | //______________________________________________________________________________________________________________________ |
---|
66 | inline void CylindricSurface::SetZ(double zmin, double zmax){ |
---|
67 | fZmin=zmin; |
---|
68 | fZmax=zmax; |
---|
69 | if (fDirection>0){ |
---|
70 | fZ1=fZmin; |
---|
71 | fZ2=fZmax; |
---|
72 | } |
---|
73 | else { |
---|
74 | fZ1=fZmax; |
---|
75 | fZ2=fZmin; |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | //______________________________________________________________________________________________________________________ |
---|
80 | inline void CylindricSurface::print(){ |
---|
81 | printf("cyl surface\tr=%g \tz(%g, %g)\tup=%i\tmin/max=%g/%g\n", fR, fZ1, fZ2, fDirection, fZmin, fZmax); |
---|
82 | } |
---|
83 | |
---|
84 | //______________________________________________________________________________ |
---|
85 | inline bool CylindricSurface::Normal(FSIntersectedSegment* ints, const G4ThreeVector& p, double out, G4ThreeVector* norm){ |
---|
86 | double invperp=-fDirection*out/p.perp(); |
---|
87 | norm->set(p.x()*invperp,p.y()*invperp,0.); |
---|
88 | return true; |
---|
89 | } |
---|
90 | |
---|
91 | }; |
---|
92 | |
---|
93 | #endif |
---|