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): Robert Wagner 10/2002 <mailto:magicsoft@rwagner.de>
|
---|
19 | ! Author(s): Thomas Bretz 2/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2002-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MObservatory
|
---|
29 | //
|
---|
30 | // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
|
---|
31 | // ON IT!
|
---|
32 | //
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 | #include "MObservatory.h"
|
---|
35 |
|
---|
36 | #include <TVector3.h>
|
---|
37 |
|
---|
38 | #include "MTime.h"
|
---|
39 | #include "MAstro.h"
|
---|
40 |
|
---|
41 | #include "MLog.h"
|
---|
42 | #include "MLogManip.h"
|
---|
43 |
|
---|
44 | ClassImp(MObservatory);
|
---|
45 |
|
---|
46 | using namespace std;
|
---|
47 |
|
---|
48 | void MObservatory::Init(const char *name, const char *title)
|
---|
49 | {
|
---|
50 | fName = name ? name : "MObservatory";
|
---|
51 | fTitle = title ? title : "Storage container for coordinates of an observatory";
|
---|
52 | }
|
---|
53 |
|
---|
54 | MObservatory::MObservatory(const char *name, const char *title)
|
---|
55 | {
|
---|
56 | Init(name, title);
|
---|
57 |
|
---|
58 | SetLocation(kMagic1);
|
---|
59 | }
|
---|
60 |
|
---|
61 | MObservatory::MObservatory(LocationName_t key, const char *name, const char *title)
|
---|
62 | {
|
---|
63 | Init(name, title);
|
---|
64 |
|
---|
65 | SetLocation(key);
|
---|
66 | }
|
---|
67 |
|
---|
68 | // --------------------------------------------------------------------------
|
---|
69 | //
|
---|
70 | // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
|
---|
71 | // ON IT!
|
---|
72 | //
|
---|
73 | void MObservatory::SetLocation(LocationName_t name)
|
---|
74 | {
|
---|
75 | switch (name)
|
---|
76 | {
|
---|
77 | // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM
|
---|
78 | // IS BASED ON IT!
|
---|
79 | case kMagic1:
|
---|
80 | // Values taken from the GPS Receiver (avg 20h)
|
---|
81 | // on 26/11/2003 at 17h30 in the counting house
|
---|
82 | fLatitude = MAstro::Dms2Rad(28, 45, 42.576, '+');
|
---|
83 | fLongitude = MAstro::Dms2Rad(17, 53, 26.460, '-');
|
---|
84 | fHeight = 2196.5; // m
|
---|
85 | fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
|
---|
86 | break;
|
---|
87 |
|
---|
88 | case kWuerzburgCity:
|
---|
89 | fLatitude = MAstro::Dms2Rad(51, 38, 48.0);
|
---|
90 | fLongitude = MAstro::Dms2Rad( 9, 56, 36.0);
|
---|
91 | fHeight = 300;
|
---|
92 | fObservatoryName = "Wuerzburg City";
|
---|
93 | break;
|
---|
94 | }
|
---|
95 |
|
---|
96 | fSinLatitude = TMath::Sin(fLatitude);
|
---|
97 | fCosLatitude = TMath::Cos(fLatitude);
|
---|
98 | }
|
---|
99 |
|
---|
100 | void MObservatory::Print(Option_t *) const
|
---|
101 | {
|
---|
102 | *fLog << all;
|
---|
103 | *fLog << fObservatoryName << endl;
|
---|
104 | *fLog << "Latitude " << (fLatitude > 0 ? (fLatitude*kRad2Deg) : -(fLatitude*kRad2Deg)) << " deg " << (fLatitude > 0 ? "W" : "E") << endl;
|
---|
105 | *fLog << "Longitude " << (fLongitude > 0 ? (fLongitude*kRad2Deg) : -(fLongitude*kRad2Deg)) <<" deg " << (fLongitude < 0 ? "N" : "S") << endl;
|
---|
106 | *fLog << "Height " << fHeight << "m" << endl;
|
---|
107 | }
|
---|
108 |
|
---|
109 | // --------------------------------------------------------------------------
|
---|
110 | //
|
---|
111 | // RotationAngle
|
---|
112 | //
|
---|
113 | // calculates the angle for the rotation of the sky image in the camera;
|
---|
114 | // this angle is a function of the local coordinates
|
---|
115 | //
|
---|
116 | // theta [rad]: polar angle/zenith distance
|
---|
117 | // phi [rad]: rotation angle/azimuth
|
---|
118 | //
|
---|
119 | // Return sin/cos component of angle
|
---|
120 | //
|
---|
121 | // calculate rotation angle alpha of sky image in camera
|
---|
122 | // (see TDAS 00-11, eqs. (18) and (20))
|
---|
123 | //
|
---|
124 | void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
|
---|
125 | {
|
---|
126 | const Double_t sint = TMath::Sin(theta);
|
---|
127 | const Double_t cost = TMath::Cos(theta);
|
---|
128 |
|
---|
129 | const Double_t sinl = fSinLatitude*sint;
|
---|
130 | const Double_t cosl = fCosLatitude*cost;
|
---|
131 |
|
---|
132 | const Double_t sinp = TMath::Sin(phi);
|
---|
133 | const Double_t cosp = TMath::Cos(phi);
|
---|
134 |
|
---|
135 | const Double_t v1 = sint*sinp;
|
---|
136 | const Double_t v2 = cosl - sinl*cosp;
|
---|
137 |
|
---|
138 | const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
|
---|
139 |
|
---|
140 | sin = (fCosLatitude*sinp) / denom;
|
---|
141 | cos = sinl + cosl*cosp / denom;
|
---|
142 | }
|
---|
143 |
|
---|
144 | // --------------------------------------------------------------------------
|
---|
145 | //
|
---|
146 | // RotationAngle
|
---|
147 | //
|
---|
148 | // calculates the angle for the rotation of the sky image in the camera;
|
---|
149 | // this angle is a function of the local coordinates
|
---|
150 | //
|
---|
151 | // theta [rad]: polar angle/zenith distance
|
---|
152 | // phi [rad]: rotation angle/azimuth
|
---|
153 | //
|
---|
154 | // Return RotationAngle in rad
|
---|
155 | //
|
---|
156 | // calculate rotation angle alpha of sky image in camera
|
---|
157 | // (see TDAS 00-11, eqs. (18) and (20))
|
---|
158 | //
|
---|
159 | Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
|
---|
160 | {
|
---|
161 | const Double_t sint = TMath::Sin(theta);
|
---|
162 | const Double_t cost = TMath::Cos(theta);
|
---|
163 |
|
---|
164 | const Double_t sinp = TMath::Sin(phi);
|
---|
165 | const Double_t cosp = TMath::Cos(phi);
|
---|
166 |
|
---|
167 | const Double_t v1 = sint*sinp;
|
---|
168 | const Double_t v2 = fCosLatitude*cost - fSinLatitude*sint*cosp;
|
---|
169 |
|
---|
170 | const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
|
---|
171 |
|
---|
172 | return TMath::ASin((fCosLatitude*sinp) / denom);
|
---|
173 | }
|
---|
174 |
|
---|
175 | // --------------------------------------------------------------------------
|
---|
176 | //
|
---|
177 | // RotationAngle
|
---|
178 | //
|
---|
179 | // calculates the angle for the rotation of the sky image in the camera;
|
---|
180 | // this angle is a function of the sky coordinates, the observatory
|
---|
181 | // location and the time
|
---|
182 | //
|
---|
183 | // ra [rad]: Right ascension
|
---|
184 | // dec [rad]: Declination
|
---|
185 | //
|
---|
186 | // Return RotationAngle in rad
|
---|
187 | //
|
---|
188 | Double_t MObservatory::RotationAngle(Double_t ra, Double_t dec, const MTime &t) const
|
---|
189 | {
|
---|
190 | const Double_t alpha = t.GetGmst() + GetElong();
|
---|
191 |
|
---|
192 | TVector3 v;
|
---|
193 | v.SetMagThetaPhi(1, TMath::Pi()/2-dec, alpha-ra);
|
---|
194 | v.RotateY(GetPhi()-TMath::Pi()/2);
|
---|
195 |
|
---|
196 | return RotationAngle(v.Theta(), v.Phi());
|
---|
197 | }
|
---|