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