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-2009
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MMirrorHex
|
---|
28 | //
|
---|
29 | // A hexagonal spherical mirror
|
---|
30 | //
|
---|
31 | //////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MMirrorHex.h"
|
---|
33 |
|
---|
34 | #include <TEllipse.h>
|
---|
35 | #include <TVirtualPad.h>
|
---|
36 |
|
---|
37 | #include "MHexagon.h"
|
---|
38 | #include "MQuaternion.h"
|
---|
39 |
|
---|
40 | ClassImp(MMirrorHex);
|
---|
41 |
|
---|
42 | using namespace std;
|
---|
43 |
|
---|
44 | const Double_t MMirrorHex::fgCos30 = TMath::Cos(30*TMath::DegToRad());
|
---|
45 | const Double_t MMirrorHex::fgCos60 = TMath::Cos(60*TMath::DegToRad());
|
---|
46 | const Double_t MMirrorHex::fgSin60 = TMath::Sin(60*TMath::DegToRad());
|
---|
47 |
|
---|
48 | // ------------------------------------------------------------------------
|
---|
49 | //
|
---|
50 | // This is a very rough estimate of whether a photon at a position p
|
---|
51 | // can hit a mirror. The position might be off in z and the photon
|
---|
52 | // still has to follow its trajectory. Nevertheless we can fairly assume
|
---|
53 | // the the way to travel in x/y is pretty small so we can give a rather
|
---|
54 | // good estimate of whether the photon can hit.
|
---|
55 | //
|
---|
56 | // never throw away a photon whihc can hit the mirror!
|
---|
57 | //
|
---|
58 | Bool_t MMirrorHex::CanHit(const MQuaternion &p) const
|
---|
59 | {
|
---|
60 | // p is given in the reflectors coordinate frame. This is meant
|
---|
61 | // to be a fast check to sort out all mirrors which we can omit
|
---|
62 | // without time consuming calculations.
|
---|
63 |
|
---|
64 | return TMath::Hypot(p.X()-X(), p.Y()-X())<1.05*fMaxR;
|
---|
65 | }
|
---|
66 |
|
---|
67 | // ------------------------------------------------------------------------
|
---|
68 | //
|
---|
69 | // Check if the given position coincides with the mirror. The position
|
---|
70 | // is assumed to be the incident point on the mirror's surface.
|
---|
71 | //
|
---|
72 | // The coordinates are in the mirrors coordinate frame.
|
---|
73 | //
|
---|
74 | // The action should coincide with what is painted in Paint()
|
---|
75 | //
|
---|
76 | Bool_t MMirrorHex::HasHit(const MQuaternion &p) const
|
---|
77 | {
|
---|
78 | // p is the incident point in the mirror in the mirror's
|
---|
79 | // coordinate frame
|
---|
80 |
|
---|
81 | // Black spot in the mirror center (here we can fairly ignore
|
---|
82 | // the distance from the plane to the mirror surface, as long
|
---|
83 | // as the black spot does not become too large)
|
---|
84 | if (p.R2()<0.5*0.5)
|
---|
85 | return kFALSE;
|
---|
86 |
|
---|
87 | //
|
---|
88 | // Now check if point is outside of hexagon; just check x coordinate
|
---|
89 | // in three coordinate systems: the default one, in which two sides of
|
---|
90 | // the hexagon are paralel to the y axis (see camera displays) and two
|
---|
91 | // more, rotated with respect to that one by +- 60 degrees.
|
---|
92 | //
|
---|
93 | if (TMath::Abs(X())>fD/*/2*/)
|
---|
94 | return kFALSE;
|
---|
95 |
|
---|
96 | const Double_t dxc = p.X()*fgCos60;
|
---|
97 | const Double_t dys = p.Y()*fgSin60;
|
---|
98 |
|
---|
99 | if (TMath::Abs(dxc+dys)>fD/*/2*/)
|
---|
100 | return kFALSE;
|
---|
101 |
|
---|
102 | if (TMath::Abs(dxc-dys)>fD/*/2*/)
|
---|
103 | return kFALSE;
|
---|
104 |
|
---|
105 | return kTRUE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | // ------------------------------------------------------------------------
|
---|
109 | //
|
---|
110 | // Paint the mirror in x/y.
|
---|
111 | //
|
---|
112 | // The graphic should coincide with the action in HasHit
|
---|
113 | //
|
---|
114 | void MMirrorHex::Paint(Option_t *opt)
|
---|
115 | {
|
---|
116 | MHexagon h;
|
---|
117 | TEllipse e;
|
---|
118 | if (!TString(opt).Contains("line", TString::kIgnoreCase))
|
---|
119 | {
|
---|
120 | h.SetLineStyle(0);
|
---|
121 | h.SetFillColor(17);
|
---|
122 | e.SetLineStyle(0);
|
---|
123 | e.SetFillColor(gPad->GetFillColor());
|
---|
124 | }
|
---|
125 | else
|
---|
126 | {
|
---|
127 | h.SetFillStyle(0);
|
---|
128 | e.SetFillStyle(0);
|
---|
129 | }
|
---|
130 |
|
---|
131 | h.PaintHexagon(X(), Y(), fD*2);
|
---|
132 |
|
---|
133 | if (!TString(opt).Contains("border", TString::kIgnoreCase))
|
---|
134 | e.PaintEllipse(X(), Y(), 0.5, 0.5, 0, 360, 0);
|
---|
135 | }
|
---|
136 |
|
---|
137 | // ------------------------------------------------------------------------
|
---|
138 | //
|
---|
139 | // Read the mirror's setup from a file. The first eight tokens should be
|
---|
140 | // ignored. (This could be fixed!)
|
---|
141 | //
|
---|
142 | // Here we read: D
|
---|
143 | //
|
---|
144 | Int_t MMirrorHex::ReadM(const TObjArray &tok)
|
---|
145 | {
|
---|
146 | if (tok.GetSize()<9)
|
---|
147 | return -1;
|
---|
148 |
|
---|
149 | const Double_t d = atof(tok[8]->GetName());
|
---|
150 |
|
---|
151 | if (d<=0)
|
---|
152 | return -1;
|
---|
153 |
|
---|
154 | SetD(d);
|
---|
155 |
|
---|
156 | return 1;
|
---|
157 | }
|
---|