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

Last change on this file since 9492 was 9371, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 5.4 KB
Line 
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// Double_t GetA() const
63//
64// Return the reflective area of the mirror
65//
66// ------------------------------------------------------------------------
67//
68// Double_t GetMaxR() const
69//
70// Return the maximum distance of a reflective point from the
71// mirror center
72//
73// ------------------------------------------------------------------------
74//
75// void Paint(Option_t *opt)
76//
77// Paint the mirror in x/y.
78//
79// The graphic should coincide with the action in HasHit
80//
81// ------------------------------------------------------------------------
82//
83// Int_t ReadM(const TObjArray &tok);
84//
85// Read the mirror's setup from a file. The first eight tokens should be
86// ignored. (This could be fixed!)
87//
88//////////////////////////////////////////////////////////////////////////////
89#include "MMirror.h"
90
91#include <TRandom.h>
92
93#include "MLog.h"
94
95#include "MQuaternion.h"
96
97ClassImp(MMirror);
98
99using namespace std;
100
101// --------------------------------------------------------------------------
102//
103// Return the TVector2 which is the x/y position of the mirror minus
104// q.XYvector/(;
105//
106TVector2 MMirror::operator-(const MQuaternion &q) const
107{
108 return TVector2(X()-q.X(), Y()-q.Y());
109}
110
111// --------------------------------------------------------------------------
112//
113// Return the TVector2 which is the difference of this mirror and the
114// given mirror
115//
116TVector2 MMirror::operator-(const MMirror &m) const
117{
118 return TVector2(X()-m.X(), Y()-m.Y());
119}
120
121// --------------------------------------------------------------------------
122//
123// Simulate the PSF. Therefor we smear out the given normal vector
124// with a gaussian.
125//
126// Returns a vector which can be added to the normal vector.
127//
128// FIXME: What is the correct focal distance to be given here?
129// Can the smearing be imporved?
130//
131TVector3 MMirror::SimPSF(const TVector3 &n, Double_t F, Double_t psf) const
132{
133 //const TVector3 n( x, y, -d) // Normal vector of the mirror
134 const TVector3 xy(-n.Y(), n.X(), 0); // Normal vector in x/y plane
135
136 Double_t gx, gy;
137 gRandom->Rannor(gx, gy); // 2D random Gauss distribution
138
139 psf /= 2; // The factor two because of the doubleing of the angle in the reflection
140 psf /= F; // Scale the Gauss to the size of the PSF
141 //psf *= n.Z(); //
142 psf *= n.Mag(); // This means that the PSF is measured in the focal distance
143
144 TVector3 dn(gx*psf, gy*psf, 0); // Instead of psf/F also atan(psf/F) might make sense
145
146 dn.Rotate(-n.Theta(), xy); // Tilt the gauss-vector to the normal vector
147
148 return dn; // Return the vector to be added to the normal vector
149}
150
151// --------------------------------------------------------------------------
152//
153void MMirror::Print(Option_t *o) const
154{
155 gLog << fPos.X() << " " << fPos.Y() << " " << fPos.Z() << " ";
156 gLog << fNorm.X() << " " << fNorm.Y() << " " << fNorm.Z() << " ";
157 gLog << fFocalLength << " ";
158 if (fSigmaPSF>0)
159 gLog << fSigmaPSF << " ";
160
161 const TString n = ClassName();
162
163 gLog << n(7, n.Length());
164}
Note: See TracBrowser for help on using the repository browser.