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