Modules/FdSimulation/TelescopeSimulatorKG/Mirror.cc
Go to the documentation of this file.
1 
10 #include "Mirror.h"
11 //#include "Photon.h"
12 #include "RTFunctions.h"
13 #include "RayTracer.h"
14 
15 #include <iostream>
16 
17 #include <utl/MathConstants.h>
18 #include <utl/AugerUnits.h>
19 #include <utl/ErrorLogger.h>
20 #include <utl/Photon.h>
21 #include <utl/Point.h>
22 #include <utl/Vector.h>
23 #include <utl/CoordinateSystemPtr.h>
24 
25 #include <fdet/Telescope.h>
26 #include <fdet/Mirror.h>
27 
28 #include <TPolyLine3D.h>
29 #include <TObjArray.h>
30 
31 using namespace TelescopeSimulatorKG;
32 using namespace utl;
33 using namespace std;
34 
36 
37  fRandom = &rndm;
38 
39  fTelCS = tel.GetTelescopeCoordinateSystem();
40  fOrigin = Point (0, 0, 0, fTelCS);
41 
42  const fdet::Mirror& mirror = tel.GetMirror();
43 
44  //const TabulatedFunction& fReflectivity = mirror.GetReflectivity();
45  fRCurv = mirror.GetRadiusOfCurvature();
46  fSigma = mirror.GetSigmaNormal();
47 
48 } // End of Mirror::Mirror
49 
50 
52 }
53 
54 
55 RTResult Mirror::Trace(const utl::Photon& photonIn, utl::Photon& photonOut ) {
56 
57  RTFunctions::IntersectionList intersections;
58  const int sphereStatus = RTFunctions::Sphere(fOrigin, fRCurv, photonIn, intersections);
59  if(sphereStatus<=0) {
60  ostringstream err;
61  err << "Missed Mirror : " << sphereStatus << " !!!";
62  ERROR(err);
63  return eAbsorbed;
64  }
65 
66  // always chose latter intersection, we want to hit inside of sphere
67  photonOut = intersections.back().first;
68  Vector normal(intersections.back().second);
69 
70  //RTFunctions::Normal(normal, fSigma, &fISeed, normAux); // todo not yet
71 
72  if(!RTFunctions::Reflection (photonOut, normal, photonOut)) {
73  INFO("Not reflected at mirror");
74  return eAbsorbed;
75  }
76 
77  return eOK;
78 
79 } // End of Mirror::Trace
80 
81 
82 TObjArray* Mirror::Draw() {
83 
84  TObjArray* objs = new TObjArray();
85 
86  int color = 1;
87  int size = 2;
88 
89  double width = 2.4*m;
90  int nSeg = 10;
91 
92  double segWidth = width/nSeg;
93 
94  for (int i=0; i<nSeg; i++) {
95 
96  for (int j=0; j<nSeg; j++) {
97 
98  double x_center = -(width-segWidth)/2 + (width-segWidth)/(nSeg-1)*i;
99  double y_center = -(width-segWidth)/2 + (width-segWidth)/(nSeg-1)*j;
100 
101  double x1 = x_center-segWidth/2;
102  double x2 = x_center+segWidth/2;
103  double y1 = y_center-segWidth/2;
104  double y2 = y_center+segWidth/2;
105 
106  double r1 = sqrt (x1*x1 + y1*y1);
107  double r2 = sqrt (x2*x2 + y1*y1);
108  double r3 = sqrt (x1*x1 + y2*y2);
109  double r4 = sqrt (x2*x2 + y2*y2);
110 
111  double z1 = - sqrt (fRCurv*fRCurv - r1*r1);
112  double z2 = - sqrt (fRCurv*fRCurv - r2*r2);
113  double z3 = - sqrt (fRCurv*fRCurv - r3*r3);
114  double z4 = - sqrt (fRCurv*fRCurv - r4*r4);
115 
116  TPolyLine3D *l1 = new TPolyLine3D (4);
117  l1->SetLineColor (color);
118  l1->SetLineWidth (size);
119  l1->SetPoint (0, x1,y1,z1);
120  l1->SetPoint (1, x2,y1,z2);
121  l1->SetPoint (2, x2,y2,z4);
122  l1->SetPoint (3, x1,y2,z3);
123  l1->SetPoint (4, x1,y1,z1);
124 
125  l1->Draw();
126  objs->AddLast(l1);
127 
128  }
129  }
130  return objs;
131 }
132 
133 
134 
135 // Configure (x)emacs for this file ...
136 // Local Variables:
137 // mode:c++
138 // compile-command: "make -C .. -k"
139 // End:
double GetSigmaNormal() const
Variable to model the mirror surface imperfection.
Point object.
Definition: Point.h:32
int Reflection(const utl::Photon &photonIn, const Vector &normal, utl::Photon &photonOut)
Definition: RTFunctions.cc:29
Mirror(utl::RandomEngine &rndm, const fdet::Telescope &tel)
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
int Sphere(const Point &origin, const double radius, const utl::Photon &photonIn, IntersectionList &intersection)
Definition: RTFunctions.cc:142
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
std::vector< PhotonNormalPair > IntersectionList
Definition: RTFunctions.h:28
double GetRadiusOfCurvature() const
Average radius of curvature for the segments.
Detector description interface for Telescope-related data.
Vector object.
Definition: Vector.h:30
const Mirror & GetMirror() const
Get the Mirror object that belongs to the telescope.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
RTResult Trace(const utl::Photon &photonIn, utl::Photon &photonOut)
constexpr double m
Definition: AugerUnits.h:121
Description of a mirror.

, generated on Tue Sep 26 2023.