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 | // A square type spherical mirror
|
---|
30 | //
|
---|
31 | //////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MMirrorSquare.h"
|
---|
33 |
|
---|
34 | #include <stdlib.h> // atof (Ubuntu 8.10)
|
---|
35 |
|
---|
36 | #include <TMath.h>
|
---|
37 | #include <TObjArray.h>
|
---|
38 |
|
---|
39 | #include <TBox.h>
|
---|
40 | #include <TEllipse.h>
|
---|
41 | #include <TVirtualPad.h>
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 |
|
---|
45 | #include "MQuaternion.h"
|
---|
46 |
|
---|
47 | ClassImp(MMirrorSquare);
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | Double_t MMirrorSquare::GetMaxR() const
|
---|
52 | {
|
---|
53 | return TMath::Sqrt(2.)*fSideLength;
|
---|
54 | }
|
---|
55 |
|
---|
56 | // ------------------------------------------------------------------------
|
---|
57 | //
|
---|
58 | // This is a very rough estimate of whether a photon at a position p
|
---|
59 | // can hit a mirror. The position might be off in z and the photon
|
---|
60 | // still has to follow its trajectory. Nevertheless we can fairly assume
|
---|
61 | // the the way to travel in x/y is pretty small so we can give a rather
|
---|
62 | // good estimate of whether the photon can hit.
|
---|
63 | //
|
---|
64 | // never throw away a photon whihc can hit the mirror!
|
---|
65 | //
|
---|
66 | Bool_t MMirrorSquare::CanHit(const MQuaternion &p) const
|
---|
67 | {
|
---|
68 | // p is given in the reflectors coordinate frame. This is meant
|
---|
69 | // to be a fast check to sort out all mirrors which we can omit
|
---|
70 | // without time consuming calculations.
|
---|
71 |
|
---|
72 | // Check if this mirror can be hit at all
|
---|
73 | const Double_t dx = TMath::Abs(p.X()-X());
|
---|
74 | if (dx>fSideLength*1.05)
|
---|
75 | return kFALSE;
|
---|
76 |
|
---|
77 | const Double_t dy = TMath::Abs(p.Y()-Y());
|
---|
78 | if (dy>fSideLength*1.05)
|
---|
79 | return kFALSE;
|
---|
80 |
|
---|
81 | return kTRUE;
|
---|
82 | }
|
---|
83 |
|
---|
84 | // ------------------------------------------------------------------------
|
---|
85 | //
|
---|
86 | // Check if the given position coincides with the mirror. The position
|
---|
87 | // is assumed to be the incident point on the mirror's surface.
|
---|
88 | //
|
---|
89 | // The coordinates are in the mirrors coordinate frame.
|
---|
90 | //
|
---|
91 | // The action should coincide with what is painted in Paint()
|
---|
92 | //
|
---|
93 | Bool_t MMirrorSquare::HasHit(const MQuaternion &p) const
|
---|
94 | {
|
---|
95 | // p is the incident point in the mirror in the mirror's
|
---|
96 | // coordinate frame
|
---|
97 |
|
---|
98 | // Black spot in the mirror center (here we can fairly ignore
|
---|
99 | // the distance from the plane to the mirror surface, as long
|
---|
100 | // as the black spot does not become too large)
|
---|
101 | if (p.R2()<0.5*0.5)
|
---|
102 | return kFALSE;
|
---|
103 |
|
---|
104 | // Check if the photon has really hit the square mirror
|
---|
105 | if (TMath::Max(fabs(p.X()), fabs(p.Y()))>fSideLength)
|
---|
106 | return kFALSE;
|
---|
107 |
|
---|
108 | return kTRUE;
|
---|
109 | }
|
---|
110 |
|
---|
111 | // ------------------------------------------------------------------------
|
---|
112 | //
|
---|
113 | // Paint the mirror in x/y.
|
---|
114 | //
|
---|
115 | // The graphic should coincide with the action in HasHit
|
---|
116 | //
|
---|
117 | void MMirrorSquare::Paint(Option_t *opt)
|
---|
118 | {
|
---|
119 | TBox b;
|
---|
120 | TEllipse e;
|
---|
121 |
|
---|
122 | if (!TString(opt).Contains("line", TString::kIgnoreCase))
|
---|
123 | {
|
---|
124 | b.SetFillColor(17);
|
---|
125 | b.SetLineStyle(0);
|
---|
126 | e.SetLineStyle(0);
|
---|
127 | e.SetFillColor(gPad->GetFillColor());
|
---|
128 | }
|
---|
129 | else
|
---|
130 | {
|
---|
131 | b.SetFillStyle(0);
|
---|
132 | e.SetFillStyle(0);
|
---|
133 | }
|
---|
134 |
|
---|
135 | b.PaintBox(X()-fSideLength, Y()-fSideLength, X()+fSideLength, Y()+fSideLength);
|
---|
136 |
|
---|
137 | if (!TString(opt).Contains("border", TString::kIgnoreCase))
|
---|
138 | e.PaintEllipse(X(), Y(), 0.5, 0.5, 0, 360, 0);
|
---|
139 | }
|
---|
140 |
|
---|
141 | // ------------------------------------------------------------------------
|
---|
142 | //
|
---|
143 | // Print the contents of the mirror
|
---|
144 | //
|
---|
145 | void MMirrorSquare::Print(Option_t *o) const
|
---|
146 | {
|
---|
147 | MMirror::Print(o);
|
---|
148 | gLog << " " << fSideLength << endl;
|
---|
149 | }
|
---|
150 |
|
---|
151 | // ------------------------------------------------------------------------
|
---|
152 | //
|
---|
153 | // Read the mirror's setup from a file. The first eight tokens should be
|
---|
154 | // ignored. (This could be fixed!)
|
---|
155 | //
|
---|
156 | // Here we read: L
|
---|
157 | //
|
---|
158 | Int_t MMirrorSquare::ReadM(const TObjArray &tok)
|
---|
159 | {
|
---|
160 | if (tok.GetSize()<9)
|
---|
161 | return -1;
|
---|
162 |
|
---|
163 | Double_t l = atof(tok[8]->GetName());
|
---|
164 |
|
---|
165 | if (l<=0)
|
---|
166 | return -1;
|
---|
167 |
|
---|
168 | fSideLength = l/2;
|
---|
169 |
|
---|
170 | return 1;
|
---|
171 | }
|
---|