1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of CheObs, the Modular Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appears in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: CheObs Software Development, 2000-2009
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MMirror
|
---|
28 | //
|
---|
29 | // Note, that we could use basic geometry classes instead, but especially
|
---|
30 | // CanHit is time critical. So this class is (should be) optimized for
|
---|
31 | // execution speed.
|
---|
32 | //
|
---|
33 | // This base class provides the code to calculate a spherical mirror
|
---|
34 | // (ExecuteMirror) and to scatter in a way to get a proper PSF.
|
---|
35 | // Furthermore it stored the geometry of a mirror.
|
---|
36 | //
|
---|
37 | // ------------------------------------------------------------------------
|
---|
38 | //
|
---|
39 | // Bool_t CanHit(const MQuaternion &p) const;
|
---|
40 | //
|
---|
41 | // This is a very rough estimate of whether a photon at a position p
|
---|
42 | // can hit a mirror. The position might be off in z and the photon
|
---|
43 | // still has to follow its trajectory. Nevertheless we can fairly assume
|
---|
44 | // the the way to travel in x/y is pretty small so we can give a rather
|
---|
45 | // good estimate of whether the photon can hit.
|
---|
46 | //
|
---|
47 | // Never throw away a photon whihc can hit the mirror!
|
---|
48 | //
|
---|
49 | // ------------------------------------------------------------------------
|
---|
50 | //
|
---|
51 | // Bool_t HasHit(const MQuaternion &p) const;
|
---|
52 | //
|
---|
53 | // Check if the given position coincides with the mirror. The position
|
---|
54 | // is assumed to be the incident point on the mirror's surface.
|
---|
55 | //
|
---|
56 | // The coordinates are in the mirrors coordinate frame.
|
---|
57 | //
|
---|
58 | // The action should coincide with what is painted in Paint()
|
---|
59 | //
|
---|
60 | // ------------------------------------------------------------------------
|
---|
61 | //
|
---|
62 | // void Paint(Option_t *opt)
|
---|
63 | //
|
---|
64 | // Paint the mirror in x/y.
|
---|
65 | //
|
---|
66 | // The graphic should coincide with the action in HasHit
|
---|
67 | //
|
---|
68 | // ------------------------------------------------------------------------
|
---|
69 | //
|
---|
70 | // Int_t ReadM(const TObjArray &tok);
|
---|
71 | //
|
---|
72 | // Read the mirror's setup from a file. The first eight tokens should be
|
---|
73 | // ignored. (This could be fixed!)
|
---|
74 | //
|
---|
75 | //////////////////////////////////////////////////////////////////////////////
|
---|
76 | #include "MMirror.h"
|
---|
77 |
|
---|
78 | #include <TRandom.h>
|
---|
79 |
|
---|
80 | #include "MLog.h"
|
---|
81 |
|
---|
82 | #include "MQuaternion.h"
|
---|
83 |
|
---|
84 | ClassImp(MMirror);
|
---|
85 |
|
---|
86 | using namespace std;
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Return the TVector2 which is the x/y position of the mirror minus
|
---|
91 | // q.XYvector/(;
|
---|
92 | //
|
---|
93 | TVector2 MMirror::operator-(const MQuaternion &q) const
|
---|
94 | {
|
---|
95 | return TVector2(X()-q.X(), Y()-q.Y());
|
---|
96 | }
|
---|
97 |
|
---|
98 | // --------------------------------------------------------------------------
|
---|
99 | //
|
---|
100 | // Return the TVector2 which is the difference of this mirror and the
|
---|
101 | // given mirror
|
---|
102 | //
|
---|
103 | TVector2 MMirror::operator-(const MMirror &m) const
|
---|
104 | {
|
---|
105 | return TVector2(X()-m.X(), Y()-m.Y());
|
---|
106 | }
|
---|
107 |
|
---|
108 | // --------------------------------------------------------------------------
|
---|
109 | //
|
---|
110 | // Simulate the PSF. Therefor we smear out the given normal vector
|
---|
111 | // with a gaussian.
|
---|
112 | //
|
---|
113 | // Returns a vector which can be added to the normal vector.
|
---|
114 | //
|
---|
115 | // FIXME: What is the correct focal distance to be given here?
|
---|
116 | // Can the smearing be imporved?
|
---|
117 | //
|
---|
118 | TVector3 MMirror::SimPSF(const TVector3 &n, Double_t F, Double_t psf) const
|
---|
119 | {
|
---|
120 | //const TVector3 n( x, y, -d) // Normal vector of the mirror
|
---|
121 | const TVector3 xy(-n.Y(), n.X(), 0); // Normal vector in x/y plane
|
---|
122 |
|
---|
123 | Double_t gx, gy;
|
---|
124 | gRandom->Rannor(gx, gy); // 2D random Gauss distribution
|
---|
125 |
|
---|
126 | psf /= 2; // The factor two because of the doubleing of the angle in the reflection
|
---|
127 | psf /= F; // Scale the Gauss to the size of the PSF
|
---|
128 | psf *= n.Z(); // Normalize the addon vector to the normal vector
|
---|
129 | //psf *= n.Mag(); // Alternative! (Gaussian projected on the surface of a sphere)
|
---|
130 |
|
---|
131 | TVector3 dn(gx*psf, gy*psf, 0); // Instead of psf/F also atan(psf/F) might make sense
|
---|
132 |
|
---|
133 | dn.Rotate(-n.Theta(), xy); // Tilt the gauss-vector to the normal vector
|
---|
134 |
|
---|
135 | return dn; // Return the vector to be added to the normal vector
|
---|
136 | }
|
---|
137 |
|
---|
138 | void MMirror::Print(Option_t *o) const
|
---|
139 | {
|
---|
140 | gLog << fPos.X() << " " << fPos.Y() << " " << fPos.Z() << " ";
|
---|
141 | gLog << fNorm.X() << " " << fNorm.Y() << " " << fNorm.Z() << " ";
|
---|
142 | gLog << fFocalLength << " ";
|
---|
143 |
|
---|
144 | const TString n = ClassName();
|
---|
145 |
|
---|
146 | gLog << n(7, n.Length());
|
---|
147 | }
|
---|