| 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 |
|
|---|
| 97 | ClassImp(MMirror);
|
|---|
| 98 |
|
|---|
| 99 | using namespace std;
|
|---|
| 100 |
|
|---|
| 101 | void MMirror::SetShape(Char_t c)
|
|---|
| 102 | {
|
|---|
| 103 | switch (toupper(c))
|
|---|
| 104 | {
|
|---|
| 105 | case 'S':
|
|---|
| 106 | fShape = 0;
|
|---|
| 107 | break;
|
|---|
| 108 |
|
|---|
| 109 | case 'P':
|
|---|
| 110 | fShape = 1;
|
|---|
| 111 | break;
|
|---|
| 112 |
|
|---|
| 113 | default:
|
|---|
| 114 | fShape = 0;
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | // --------------------------------------------------------------------------
|
|---|
| 119 | //
|
|---|
| 120 | // Return the TVector2 which is the x/y position of the mirror minus
|
|---|
| 121 | // q.XYvector/(;
|
|---|
| 122 | //
|
|---|
| 123 | TVector2 MMirror::operator-(const MQuaternion &q) const
|
|---|
| 124 | {
|
|---|
| 125 | return TVector2(X()-q.X(), Y()-q.Y());
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | // --------------------------------------------------------------------------
|
|---|
| 129 | //
|
|---|
| 130 | // Return the TVector2 which is the difference of this mirror and the
|
|---|
| 131 | // given mirror
|
|---|
| 132 | //
|
|---|
| 133 | TVector2 MMirror::operator-(const MMirror &m) const
|
|---|
| 134 | {
|
|---|
| 135 | return TVector2(X()-m.X(), Y()-m.Y());
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | // --------------------------------------------------------------------------
|
|---|
| 139 | //
|
|---|
| 140 | // Simulate the PSF. Therefor we smear out the given normal vector
|
|---|
| 141 | // with a gaussian.
|
|---|
| 142 | //
|
|---|
| 143 | // Returns a vector which can be added to the normal vector.
|
|---|
| 144 | //
|
|---|
| 145 | // FIXME: What is the correct focal distance to be given here?
|
|---|
| 146 | // Can the smearing be imporved?
|
|---|
| 147 | //
|
|---|
| 148 | TVector3 MMirror::SimPSF(const TVector3 &n, Double_t F, Double_t psf) const
|
|---|
| 149 | {
|
|---|
| 150 | //const TVector3 n( x, y, -d) // Normal vector of the mirror
|
|---|
| 151 | const TVector3 xy(-n.Y(), n.X(), 0); // Normal vector in x/y plane
|
|---|
| 152 |
|
|---|
| 153 | Double_t gx, gy;
|
|---|
| 154 | gRandom->Rannor(gx, gy); // 2D random Gauss distribution
|
|---|
| 155 |
|
|---|
| 156 | psf /= 2; // The factor two because of the doubleing of the angle in the reflection
|
|---|
| 157 | psf /= F; // Scale the Gauss to the size of the PSF
|
|---|
| 158 | //psf *= n.Z(); //
|
|---|
| 159 | psf *= n.Mag(); // This means that the PSF is measured in the focal distance
|
|---|
| 160 |
|
|---|
| 161 | TVector3 dn(gx*psf, gy*psf, 0); // Instead of psf/F also atan(psf/F) might make sense
|
|---|
| 162 |
|
|---|
| 163 | dn.Rotate(-n.Theta(), xy); // Tilt the gauss-vector to the normal vector
|
|---|
| 164 |
|
|---|
| 165 | return dn; // Return the vector to be added to the normal vector
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | // --------------------------------------------------------------------------
|
|---|
| 169 | //
|
|---|
| 170 | void MMirror::Print(Option_t *o) const
|
|---|
| 171 | {
|
|---|
| 172 | gLog << fPos.X() << " " << fPos.Y() << " " << fPos.Z() << " ";
|
|---|
| 173 | gLog << fNorm.X() << " " << fNorm.Y() << " " << fNorm.Z() << " ";
|
|---|
| 174 | gLog << fFocalLength << " ";
|
|---|
| 175 | if (fSigmaPSF>0)
|
|---|
| 176 | gLog << fSigmaPSF << " ";
|
|---|
| 177 |
|
|---|
| 178 | const TString n = ClassName();
|
|---|
| 179 |
|
|---|
| 180 | gLog << n(7, n.Length());
|
|---|
| 181 | }
|
|---|