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