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 | // MParContainer
|
---|
104 | Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
|
---|
105 |
|
---|
106 | public:
|
---|
107 | MFresnelLens(const char *name=NULL, const char *title=NULL);
|
---|
108 |
|
---|
109 | Double_t GetMaxR() const { return fMaxR; }
|
---|
110 | Double_t GetA() const;
|
---|
111 |
|
---|
112 | virtual Bool_t CanHit(const MQuaternion &p) const;
|
---|
113 |
|
---|
114 | Int_t ExecuteOptics(MQuaternion &p, MQuaternion &u, const Short_t &) const;
|
---|
115 | Int_t TraceRay(std::vector<MQuaternion> &vec, MQuaternion &p, MQuaternion &u, const Short_t &wavelength, bool verbose=false) const;
|
---|
116 |
|
---|
117 | Bool_t IsValid() const { return fGrooves.size(); }
|
---|
118 |
|
---|
119 | // -----------------------------------------------------------
|
---|
120 |
|
---|
121 | void SetPSF(const double &psf) { fPSF = psf; }
|
---|
122 | void DefineLens(double F=50.21, double D=54.92, double w=0.01, double h=0.25, double lambda=546);
|
---|
123 |
|
---|
124 | Int_t ReadTransmission(const TString &file, float thickness, bool correction=true);
|
---|
125 |
|
---|
126 | // -----------------------------------------------------------
|
---|
127 |
|
---|
128 | void EnableSlopeAbsorption(bool abs=true) { fSlopeAbsorption = abs; }
|
---|
129 | void EnableDraftAbsorption(bool abs=true) { fDraftAbsorption = abs; }
|
---|
130 | void DisableBottomReflection(bool ref=true) { fBottomReflection = !ref; }
|
---|
131 | void DisableMultiEntry(bool mul=true) { fDisableMultiEntry = mul; }
|
---|
132 | void DisableFresnelReflection(bool ref=true) { fFresnelReflection = !ref; }
|
---|
133 |
|
---|
134 | void SetMinHits(UInt_t min) { fMinHits = min; }
|
---|
135 | void SetMaxHits(UInt_t max) { fMaxHits = max; }
|
---|
136 |
|
---|
137 | // -----------------------------------------------------------
|
---|
138 |
|
---|
139 | const std::vector<MFresnelLens::Groove> GetGrooves() const { return fGrooves; }
|
---|
140 | const Groove &GetGroove(int i) const { return fGrooves[i]; }
|
---|
141 | const Groove &operator[](int i) const { return fGrooves[i]; }
|
---|
142 | size_t GetNumGrooves() const { return fGrooves.size(); }
|
---|
143 |
|
---|
144 | // -----------------------------------------------------------
|
---|
145 |
|
---|
146 | static double RefractiveIndex(double lambda);
|
---|
147 | static double SlopeAngle(double r, double F, double n, double d);
|
---|
148 | static double DraftAngle(double r);
|
---|
149 |
|
---|
150 | static double SlopeAngleParabolic(double r, double F, double n0, double n1, double d);
|
---|
151 | static double SlopeAngleAspherical(double r);
|
---|
152 | static double SlopeAngleOptimized(double r, double F, double n);
|
---|
153 |
|
---|
154 | double SlopeAngle(const double &r) const
|
---|
155 | {
|
---|
156 | return SlopeAngle(r, fF, fN, fH);
|
---|
157 | }
|
---|
158 |
|
---|
159 | // -----------------------------------------------------------
|
---|
160 |
|
---|
161 | ClassDef(MFresnelLens, 1) // Parameter container storing the description of a fresnel lens
|
---|
162 | };
|
---|
163 |
|
---|
164 | #endif
|
---|