source: trunk/MagicSoft/Mars/msimreflector/MMirrorDisk.cc@ 9239

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