source: trunk/MagicSoft/Mars/msimreflector/MMirror.cc@ 9239

Last change on this file since 9239 was 9236, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC 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 appear 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 11/2008 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: Software Development, 2000-2008
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 "MQuaternion.h"
81
82ClassImp(MMirror);
83
84using namespace std;
85
86// --------------------------------------------------------------------------
87//
88// Return the TVector2 which is the x/y position of the mirror minus
89// q.XYvector/(;
90//
91TVector2 MMirror::operator-(const MQuaternion &q) const
92{
93 return TVector2(X()-q.X(), Y()-q.Y());
94}
95
96// --------------------------------------------------------------------------
97//
98// Return the TVector2 which is the difference of this mirror and the
99// given mirror
100//
101TVector2 MMirror::operator-(const MMirror &m) const
102{
103 return TVector2(X()-m.X(), Y()-m.Y());
104}
105
106// --------------------------------------------------------------------------
107//
108// Simulate the PSF. Therefor we smear out the given normal vector
109// with a gaussian.
110//
111// Returns a vector which can be added to the normal vector.
112//
113// FIXME: What is the correct focal distance to be given here?
114// Can the smearing be imporved?
115//
116TVector3 MMirror::SimPSF(const TVector3 &n, Double_t F, Double_t psf) const
117{
118 //const TVector3 n( x, y, -d) // Normal vector of the mirror
119 const TVector3 xy(-n.Y(), n.X(), 0); // Normal vector in x/y plane
120
121 Double_t gx, gy;
122 gRandom->Rannor(gx, gy); // 2D random Gauss distribution
123
124 psf /= 2; // The factor two because of the doubleing of the angle in the reflection
125 psf /= F; // Scale the Gauss to the size of the PSF
126 psf *= n.Z(); // Normalize the addon vector to the normal vector
127 //psf *= n.Mag(); // Alternative! (Gaussian projected on the surface of a sphere)
128
129 TVector3 dn(gx*psf, gy*psf, 0); // Instead of psf/F also atan(psf/F) might make sense
130
131 dn.Rotate(-n.Theta(), xy); // Tilt the gauss-vector to the normal vector
132
133 return dn; // Return the vector to be added to the normal vector
134}
Note: See TracBrowser for help on using the repository browser.