Lens.cc
Go to the documentation of this file.
1 
10 #include "Lens.h"
11 #include "RTFunctions.h"
12 
13 #include <TPolyLine3D.h>
14 #include <TObjArray.h>
15 
16 #include <utl/MathConstants.h>
17 #include <utl/AugerUnits.h>
18 
19 #include <utl/Photon.h>
20 #include <utl/Point.h>
21 #include <utl/Vector.h>
22 #include <utl/RandomEngine.h>
23 #include <utl/CoordinateSystemPtr.h>
24 
25 #include <fdet/Telescope.h>
26 #include <fdet/Corrector.h>
27 
28 #include <det/Detector.h>
29 
30 #include <atm/Atmosphere.h>
31 #include <atm/ProfileResult.h>
32 
33 #include <iostream>
34 #include <sstream>
35 #include <utility>
36 
37 using namespace TelescopeSimulatorKG;
38 using namespace utl;
39 using namespace std;
40 
41 
43 
44  fRandom = &rndm;
45 
46  const fdet::Corrector& corrector = tel.GetCorrector();
47 
48  fTelCS = tel.GetTelescopeCoordinateSystem();
49  fOrigin = Point (0,0,0, fTelCS);
50 
51  fR1 = corrector.GetInnerRadius();
52  fR2 = corrector.GetOuterRadius();
53 
54  // const double Tm = corrector.GetMeanLensThickness(); // average lens thickness
55  fSigRho = corrector.GetSigmaNormal();
56  fRefractiveIndex = &(corrector.GetRefractiveIndex());
57  fTransmittance = &(corrector.GetTransmittance());
58 
59  // air refractive index
60  const atm::ProfileResult & refractiveIndexVsHeight =
61  det::Detector::GetInstance().GetAtmosphere().EvaluateRefractionIndexVsHeight();
62  fInd1 = refractiveIndexVsHeight.Y(refractiveIndexVsHeight.MinX());
63 
64 } // End of Lens::Lens
65 
66 
70 RTResult Lens::Trace(const utl::Photon& photonIn, utl::Photon& photonOut) {
71 
72  const Vector& nIn = photonIn.GetDirection();
73  const Point& pIn = photonIn.GetPosition();
74  double lambda = photonIn.GetWavelength();
75 
76  if (nIn.GetZ(fTelCS)>0) {
77  // the light is going out of the telescope
78  photonOut = photonIn;
79  return eInvalidLens;
80  }
81 
82  const double x = pIn.GetX(fTelCS);
83  const double y = pIn.GetY(fTelCS);
84  const double r2 = x*x + y*y;
85  const double r = sqrt(r2);
86  if (r > fR2) {
87  photonOut = photonIn;
88  return eMissedDiaphragm; //the light don't pass through the aperture window
89  }
90 
91  if (r < fR1) {
92  photonOut = photonIn;
93  // the light went through the aperture window,
94  return eOK;
95  }
96 
97  const Vector normal1 = Curvature(x, y);
98  const double z = Profile(r);
99 
100  // calculate the direction of the light inside the corrector lens
101  const double r_index_12 = fInd1 / fRefractiveIndex->Y(lambda);
102  //double r_index_12 = 1.0/1.5;
103  RTFunctions::PhotonList photonsRefracted;
104  RTFunctions::Refraction(r_index_12, photonIn, normal1, photonsRefracted);
105  if (photonsRefracted.size() != 2) {
106  return eReflectedByLens;
107  }
108  Photon photonRefracted = photonsRefracted[0];
109 
110  const double cosThetaPhoton = - photonRefracted.GetDirection().GetCosTheta(fTelCS);
111  const double thickness = z / cosThetaPhoton;
112 
113  if (fTransmittance->Y(lambda) == 0)
114  return eAbsorbedByLens;
115 
116  const double internal_absorption = exp(thickness/(1.*cm)*log(fTransmittance->Y(lambda)));
117 
118  // introduces imperfections at corrector ring surface
119  // fRt->Normal(n1, fSigRho, &fISeed, n); // NOT DONE
120 
121 
122 
123  // ------------- SECOND SURFACE of corrector ring ------------
124  // calculate the position of light at the second surface of the lens.
125  photonRefracted.SetPosition(photonRefracted.GetPosition() + thickness * photonRefracted.GetDirection());
126 
127  // fRt->Normal(n1, fSigRho, &fISeed, n); // NOT DONE YET
128  Vector normal2 (0., 0., 1., fTelCS); //second surface is plane.
129  Vector nOut;
130  RTFunctions::PhotonList photonsOut;
131  RTFunctions::Refraction(1 / r_index_12, photonRefracted, normal2, photonsOut);
132  if (photonsOut.size() != 2) {
133  return eReflectedByLens; // total internal reflection inside lens
134  }
135 
136  photonOut = photonsOut[0];
137  const double weight = photonOut.GetWeight();
138  photonOut.SetWeight(weight*internal_absorption);
139 
140  return eOK;
141 } // End of Lens::Trace
142 
143 
144 TObjArray* Lens::Draw() {
145 
146  TObjArray* objs = new TObjArray();
147 
148  int color = 1;
149  int width = 2;
150 
151  int nSeg = 15;
152  for (int i=0; i<nSeg; i++) {
153 
154  double theta_1 = 360.*deg/nSeg * i;
155  double theta_2 = 360.*deg/nSeg * (i+1);
156 
157  TPolyLine3D *l_in = new TPolyLine3D (1);
158  l_in->SetPoint (0, cos(theta_1)*fR1, sin(theta_1)*fR1, 0);
159  l_in->SetPoint (1, cos(theta_2)*fR1, sin(theta_2)*fR1, 0);
160  l_in->SetLineColor(color);
161  l_in->SetLineWidth(width);
162  l_in->Draw();
163  objs->AddLast(l_in);
164 
165  TPolyLine3D *l_out = new TPolyLine3D (1);
166  l_out->SetPoint (0, cos(theta_1)*fR2, sin(theta_1)*fR2, 0);
167  l_out->SetPoint (1, cos(theta_2)*fR2, sin(theta_2)*fR2, 0);
168  l_out->SetLineColor(color);
169  l_out->SetLineWidth(width);
170  l_out->Draw();
171  objs->AddLast(l_out);
172 
173  TPolyLine3D *l_seg = new TPolyLine3D (1);
174  l_seg->SetPoint (0, cos(theta_1)*fR1, sin(theta_1)*fR1, 0);
175  l_seg->SetPoint (1, cos(theta_1)*fR2, sin(theta_1)*fR2, 0);
176  l_seg->SetLineColor(color);
177  l_seg->SetLineWidth(width);
178  l_seg->Draw();
179  objs->AddLast(l_seg);
180  }
181  return objs;
182 }
183 
184 
185 // thikness profile as a function of radial distance
186 Vector Lens::Curvature(const double x, const double y) const {
187 
188  const double r = sqrt(x*x + y*y);
189 
190  static const double f = 3.4*m - 1.743*m;
191  static const double Rd = .85*m;
192  //static const double z0 = 10.*mm;
193  static const double A = 3./2. * Rd*Rd;
194  static const double n = 1.5;
195 
196  static const double denominator = 32.*(n-1.)*f*f*f;
197  static const double a1 = 1./denominator; // r^4
198  static const double a2 = A/denominator; // r^2
199 
200  double dTdr = 4.*a1*r*r*r - 2.*a2*r;
201  // dTdr *= .9; ///// this would be a bit better
202 
203  /*
204  // Tilos KA prototyp
205  double dTdr = 6.*4.e-18 * mm * pow(r,5) * pow (mm,-6);
206  */
207 
208 
209  // new KG default from GAP ...
210 
211  double nr = dTdr;
212  double nz = 1.;
213  double norm = sqrt (nr*nr + nz*nz);
214 
215  nr /= norm;
216  nz /= norm;
217 
218  double phi = atan2(y,x);
219 
220  return Vector (-nr*cos(phi), -nr*sin(phi), nz, fTelCS);
221 
222 
223  /*
224  // old FDSim code:
225  double r2 = r*r;
226  double aux = 2*(-1.2461221E-02 + 2*8.6476346E-03*r2 + 3*2.0361284E-03*r2*r2);
227 
228  Vector norm = Vector (-x*aux, -y*aux, 1.0, fTelCS);
229  norm.Normalize();
230 
231  return norm;
232  */
233 
234 }
235 
236 
237 // thikness profile as a function of radial distance
238 double Lens::Profile(const double r) const {
239 
240  double r2 = r*r;
241 
242  /*
243  // Tilos KA prototyp
244  r2 /= (mm*mm);
245  double z = 4.e-18*mm * pow (r2,3) + 0.91*mm;
246  */
247 
248 
249  // new KG default from GAP ...
250  static const double f = 3.4*m - 1.743*m;
251  static const double Rd = .85*m;
252  static const double A = 3./2. * Rd*Rd;
253  static const double n = 1.5;
254 
255  static const double denominator = 32.*(n-1.)*f*f*f;
256  static const double a1 = 1./denominator; // r^4
257  static const double a2 = A/denominator; // r^2
258 
259  static const double z0 = 10.*mm;
260 
261  double z = z0 + a1*r2*r2 - a2*r2;
262 
263 
264  /*
265  // old FDSim code:
266  double aux = 2*(-1.2461221E-02 + 2*8.6476346E-03*r2 + 3*2.0361284E-03*r2*r2);
267 
268  Vector norm = Vector (-x*aux, -y*aux, 1.0, fTelCS);
269  norm.Normalize();
270 
271  double z = sqrt (pow(norm.GetX (fTelCS),2) + pow(norm.GetY (fTelCS),2));
272  */
273 
274  return z;
275 
276 } // End of Lens::Profile
277 
278 
279 
280 // Configure (x)emacs for this file ...
281 // Local Variables:
282 // mode:c++
283 // compile-command: "make -C .. -k"
284 // End:
constexpr double mm
Definition: AugerUnits.h:113
Point object.
Definition: Point.h:32
double GetInnerRadius() const
Inner radius of the ring.
Definition: Corrector.cc:78
std::vector< utl::Photon > PhotonList
Definition: RTFunctions.h:21
const Corrector & GetCorrector() const
Get the Corrector (corrector ring) object that belongs to the telescope.
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
Definition: BasicVector.h:251
const utl::TabulatedFunction & GetTransmittance() const
Transmittance as a function of the wavelength.
Definition: Corrector.cc:110
double GetWeight() const
weight assigned to the photon
Definition: Photon.h:21
void SetPosition(const utl::Point &p)
Definition: Photon.h:33
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
double GetSigmaNormal() const
Variable to model the lens surface imperfection.
Definition: Corrector.cc:102
utl::Vector Curvature(const double x, const double y) const
Definition: Lens.cc:186
constexpr double deg
Definition: AugerUnits.h:140
double GetOuterRadius() const
Outer radius of the ring.
Definition: Corrector.cc:86
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
void SetWeight(const double w)
source of the photons. Should use Eye::LightSource enum types
Definition: Photon.h:31
Description of a corrector ring.
Definition: Corrector.h:36
double Profile(const double r) const
Definition: Lens.cc:238
RTResult Trace(const utl::Photon &photonIn, utl::Photon &photonOut)
Definition: Lens.cc:70
const utl::Vector & GetDirection() const
Definition: Photon.h:26
int Refraction(const double n12, const utl::Photon &photonIn, const Vector &normal, PhotonList &photonsOut)
Definition: RTFunctions.cc:61
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
const utl::TabulatedFunction & GetRefractiveIndex() const
Index of refraction as a funcction of the wavelength.
Definition: Corrector.cc:118
Detector description interface for Telescope-related data.
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
double norm(utl::Vector x)
Lens(utl::RandomEngine &rndm, const fdet::Telescope &tel)
Definition: Lens.cc:42
constexpr double cm
Definition: AugerUnits.h:117
Vector object.
Definition: Vector.h:30
TObjArray * Draw()
Definition: Lens.cc:144
double GetWavelength() const
Definition: Photon.h:27
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
constexpr double m
Definition: AugerUnits.h:121
const utl::Point & GetPosition() const
Definition: Photon.h:25

, generated on Tue Sep 26 2023.