1 | #ifndef MARS_MFresnelLens
|
---|
2 | #define MARS_MFresnelLens
|
---|
3 |
|
---|
4 | #include <TVector3.h>
|
---|
5 |
|
---|
6 | #ifndef MARS_MOptics
|
---|
7 | #include "MOptics.h"
|
---|
8 | #endif
|
---|
9 | #ifndef MARS_MSpline3
|
---|
10 | #include "MSpline3.h"
|
---|
11 | #endif
|
---|
12 | #ifndef MARS_MQuaternion
|
---|
13 | #include "MQuaternion.h"
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | class MFresnelLens : public MOptics
|
---|
17 | {
|
---|
18 | public:
|
---|
19 | // --------------- Helper class ---------------------
|
---|
20 | // This is a TVector3 which is nromalized and takes theta and phi as arguent
|
---|
21 | // same as calling
|
---|
22 | // TVector3 v;
|
---|
23 | // v.SetMagThetaPhi(1, theta, phi);
|
---|
24 | class VectorNorm : public TVector3
|
---|
25 | {
|
---|
26 | public:
|
---|
27 | VectorNorm(double theta, double phi) :
|
---|
28 | TVector3(
|
---|
29 | sin(theta) * cos(phi),
|
---|
30 | sin(theta) * sin(phi),
|
---|
31 | cos(theta)
|
---|
32 | )
|
---|
33 | {
|
---|
34 | }
|
---|
35 | };
|
---|
36 |
|
---|
37 | // ----------- Properties of the grooves -------------
|
---|
38 |
|
---|
39 | struct Cone
|
---|
40 | {
|
---|
41 | double z; // z-coordinate of the peak of the cone (x=y=0)
|
---|
42 | double theta; // Opening angle of the cone [rad]
|
---|
43 | double tan_theta; // tan(theta)
|
---|
44 | double tan_theta2; // tan(theta)*tan(theta)
|
---|
45 | double h; // height of the slope (intersection point in the valley), h<0
|
---|
46 | double theta_norm; // theta angle of the normal vector corresponding to the cone surface
|
---|
47 | };
|
---|
48 |
|
---|
49 | struct Groove
|
---|
50 | {
|
---|
51 | double r; // Radius of the intersection point between slope and draft angle
|
---|
52 |
|
---|
53 | Cone slope; // Description of the slope angle
|
---|
54 | Cone draft; // Description of the draft angle
|
---|
55 | };
|
---|
56 |
|
---|
57 | private:
|
---|
58 |
|
---|
59 | // --------------------------------------------------
|
---|
60 |
|
---|
61 | Double_t fMaxR; //!
|
---|
62 |
|
---|
63 | // ------------- Properties of the lens --------------
|
---|
64 |
|
---|
65 | double fF; // Focal length
|
---|
66 | double fR; // Radius of lens
|
---|
67 | double fW; // Width of groove
|
---|
68 | double fH; // Thickness of lens
|
---|
69 | double fN; //! Reference refractive index for lens design
|
---|
70 | double fLambda; // Wavelength [nm] corresponding to fN (at which lens is optimized)
|
---|
71 | double fVc; //! Velocity of light within the lens material [cm/ns]
|
---|
72 | double fPSF; // Measure for the surface roughness
|
---|
73 |
|
---|
74 | std::vector<Groove> fGrooves; //! Collection of all grooves
|
---|
75 |
|
---|
76 | // ----------- Properties of the material -------------
|
---|
77 |
|
---|
78 | MSpline3 fAbsorptionLength; // Spline storing the absorption length vs wavelength
|
---|
79 |
|
---|
80 | // ----------------------------------------------------
|
---|
81 |
|
---|
82 | bool fSlopeAbsorption; //! Absorb rays which hit the slope surface
|
---|
83 | bool fDraftAbsorption; //! Absorb rays which hit the draft surface
|
---|
84 | bool fBottomReflection; //! Absorb rays which would be reflected at the exit surface
|
---|
85 | bool fDisableMultiEntry; //! Absorb upgoing rays inside the material which do not originate from the exit surface
|
---|
86 | bool fFresnelReflection; //! Disable Fresnel reflection
|
---|
87 | UInt_t fMinHits; //! Minimum number of surface contacts to define a successfull passage
|
---|
88 | UInt_t fMaxHits; //! Maximum number of surface contacts to define a successfull passage (0=unlimited)
|
---|
89 |
|
---|
90 | void InitMaxR();
|
---|
91 | void InitGeometry(double maxr, double width, double N0, double F, double d);
|
---|
92 | bool Transmission(double dt, double lambda) const;
|
---|
93 |
|
---|
94 | double CalcIntersection(const MQuaternion &p, const MQuaternion &u, const Cone &cone) const;
|
---|
95 | int FindPeak(size_t i, const MQuaternion &p, const MQuaternion &u) const;
|
---|
96 |
|
---|
97 | //int EnterGroove(int surface, double n0, double lambda, MQuaternion &pos, MQuaternion &dir) const;
|
---|
98 | //int LeavePeak(int surface, double n0, double lambda, MQuaternion &pos, MQuaternion &dir, double T0) const;
|
---|
99 |
|
---|
100 | int EnterGroove(int surface, double n0, MQuaternion &pos, MQuaternion &dir) const;
|
---|
101 | int LeavePeak(int surface, double n0, MQuaternion &pos, MQuaternion &dir, double T0) const;
|
---|
102 |
|
---|
103 | public:
|
---|
104 | MFresnelLens(const char *name=NULL, const char *title=NULL);
|
---|
105 |
|
---|
106 | Double_t GetMaxR() const { return fMaxR; }
|
---|
107 | Double_t GetA() const;
|
---|
108 |
|
---|
109 | virtual Bool_t CanHit(const MQuaternion &p) const;
|
---|
110 |
|
---|
111 | Int_t ExecuteOptics(MQuaternion &p, MQuaternion &u, const Short_t &) const;
|
---|
112 | Int_t TraceRay(std::vector<MQuaternion> &vec, MQuaternion &p, MQuaternion &u, const Short_t &wavelength, bool verbose=false) const;
|
---|
113 |
|
---|
114 | Bool_t IsValid() const { return fGrooves.size(); }
|
---|
115 |
|
---|
116 | // -----------------------------------------------------------
|
---|
117 |
|
---|
118 | void SetPSF(const double &psf) { fPSF = psf; }
|
---|
119 | void DefineLens(double F=50.21, double D=54.92, double w=0.01, double h=0.25, double lambda=546);
|
---|
120 |
|
---|
121 | Int_t ReadTransmission(const TString &file, float thickness, bool correction=true);
|
---|
122 |
|
---|
123 | // -----------------------------------------------------------
|
---|
124 |
|
---|
125 | void EnableSlopeAbsorption(bool abs=true) { fSlopeAbsorption = abs; }
|
---|
126 | void EnableDraftAbsorption(bool abs=true) { fDraftAbsorption = abs; }
|
---|
127 | void DisableBottomReflection(bool ref=true) { fBottomReflection = !ref; }
|
---|
128 | void DisableMultiEntry(bool mul=true) { fDisableMultiEntry = mul; }
|
---|
129 | void DisableFresnelReflection(bool ref=true) { fFresnelReflection = !ref; }
|
---|
130 |
|
---|
131 | void SetMinHits(UInt_t min) { fMinHits = min; }
|
---|
132 | void SetMaxHits(UInt_t max) { fMaxHits = max; }
|
---|
133 |
|
---|
134 | // -----------------------------------------------------------
|
---|
135 |
|
---|
136 | const std::vector<MFresnelLens::Groove> GetGrooves() const { return fGrooves; }
|
---|
137 | const Groove &GetGroove(int i) const { return fGrooves[i]; }
|
---|
138 | const Groove &operator[](int i) const { return fGrooves[i]; }
|
---|
139 | size_t GetNumGrooves() const { return fGrooves.size(); }
|
---|
140 |
|
---|
141 | // -----------------------------------------------------------
|
---|
142 |
|
---|
143 | static double RefractiveIndex(double lambda);
|
---|
144 | static double SlopeAngle(double r, double F, double n, double d);
|
---|
145 | static double DraftAngle(double r);
|
---|
146 |
|
---|
147 | static double SlopeAngleParabolic(double r, double F, double n0, double n1, double d);
|
---|
148 | static double SlopeAngleAspherical(double r);
|
---|
149 | static double SlopeAngleOptimized(double r, double F, double n);
|
---|
150 |
|
---|
151 | double SlopeAngle(const double &r) const
|
---|
152 | {
|
---|
153 | return SlopeAngle(r, fF, fN, fH);
|
---|
154 | }
|
---|
155 |
|
---|
156 | // -----------------------------------------------------------
|
---|
157 |
|
---|
158 | ClassDef(MFresnelLens, 1) // Parameter container storing the description of a fresnel lens
|
---|
159 | };
|
---|
160 |
|
---|
161 | #endif
|
---|