source: trunk/Mars/mastro/MObservatory.cc@ 10075

Last change on this file since 10075 was 9524, checked in by tbretz, 15 years ago
*** empty log message ***
File size: 6.8 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): 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 <TArrayD.h>
37#include <TVector3.h>
38
39#include "MTime.h"
40#include "MAstro.h"
41
42#include "MLog.h"
43#include "MLogManip.h"
44
45ClassImp(MObservatory);
46
47using namespace std;
48
49void MObservatory::Init(const char *name, const char *title)
50{
51 fName = name ? name : "MObservatory";
52 fTitle = title ? title : "Storage container for coordinates of an observatory";
53}
54
55// --------------------------------------------------------------------------
56//
57// Default constructor sets name and title of instace.
58// Default location is kMagic1
59//
60MObservatory::MObservatory(const char *name, const char *title)
61{
62 Init(name, title);
63
64 SetLocation(kMagic1);
65}
66
67// --------------------------------------------------------------------------
68//
69// For example "MObservator(MObservatory::kMagic1)"
70//
71MObservatory::MObservatory(LocationName_t key, const char *name, const char *title)
72{
73 Init(name, title);
74
75 SetLocation(key);
76}
77
78// --------------------------------------------------------------------------
79//
80// Calls SetLocation
81//
82MObservatory::MObservatory(Double_t lon, Double_t lat, const char *name)
83{
84 Init();
85
86 SetLocation(lon, lat, 0, name);
87}
88
89// --------------------------------------------------------------------------
90//
91// Calls SetLocation
92//
93MObservatory::MObservatory(Double_t lon, Double_t lat, Double_t h, const char *name)
94{
95 Init();
96
97 SetLocation(lon, lat, h, name);
98}
99
100// --------------------------------------------------------------------------
101//
102// BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
103// ON IT!
104//
105void MObservatory::SetLocation(LocationName_t name)
106{
107 switch (name)
108 {
109 // BE EXTREMLY CARFEFULL CHANGING THIS CLASS!
110 // THE TRACKING SYSTEM IS BASED ON IT!
111 case kMagic1:
112 // Values taken from the GPS Receiver (avg 24h)
113 // on 29/04/2004 at 17h30 in the counting house
114 fLatitude = MAstro::Dms2Rad(28, 45, 42.462, '+');
115 fLongitude = MAstro::Dms2Rad(17, 53, 26.525, '-');
116 fHeight = 2199.4; // m
117 fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
118 break;
119
120 case kWuerzburgCity:
121 fLatitude = MAstro::Dms2Rad(51, 38, 48.0);
122 fLongitude = MAstro::Dms2Rad( 9, 56, 36.0);
123 fHeight = 300;
124 fObservatoryName = "Wuerzburg City";
125 break;
126
127 case kTuorla:
128 fLatitude = MAstro::Dms2Rad(60, 24, 57.0);
129 fLongitude = MAstro::Dms2Rad(22, 26, 42.0);
130 fHeight = 53;
131 fObservatoryName = "Tuorla";
132 break;
133 }
134
135 fObservatoryKey = name;
136
137 fSinLatitude = TMath::Sin(fLatitude);
138 fCosLatitude = TMath::Cos(fLatitude);
139}
140
141// --------------------------------------------------------------------------
142//
143// Longitude/Latitude [rad]
144// Height [m]
145//
146void MObservatory::SetLocation(Double_t lon, Double_t lat, Double_t h, const char *name)
147{
148 fLongitude = lon;
149 fLatitude = lat;
150 fHeight = h;
151
152 fSinLatitude = TMath::Sin(fLatitude);
153 fCosLatitude = TMath::Cos(fLatitude);
154
155 if (name)
156 fObservatoryName = name;
157}
158
159void MObservatory::Print(Option_t *) const
160{
161 *fLog << all;
162 *fLog << underline << fObservatoryName << ":" << endl;
163 *fLog << "Latitude: " << TMath::Abs(fLatitude*kRad2Deg) << " deg " << (fLatitude > 0 ? "N" : "S") << endl;
164 *fLog << "Longitude: " << TMath::Abs(fLongitude*kRad2Deg) << " deg " << (fLongitude < 0 ? "E" : "W") << endl;
165 *fLog << "Height: " << fHeight << "m" << endl;
166}
167
168// --------------------------------------------------------------------------
169//
170// Get the corresponding rotation angle of the sky coordinate system
171// seen with an Alt/Az telescope.
172//
173// For more information see MAstro::RotationAngle
174//
175void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
176{
177 MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi, sin, cos);
178}
179
180// --------------------------------------------------------------------------
181//
182// Get the corresponding rotation angle of the sky coordinate system
183// seen with an Alt/Az telescope.
184//
185// For more information see MAstro::RotationAngle
186//
187Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
188{
189 return MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi);
190}
191
192// --------------------------------------------------------------------------
193//
194// Get the time (as mjd) of sunrise/sunset at the day floor(mjd)
195// above/below alt[deg]
196//
197// For more information see MAstro::GetSunRiseSet
198//
199// A TArrayD(2) is returned with the sunrise in TArray[0] and the
200// sunset in TArrayD[1].
201//
202TArrayD MObservatory::GetSunRiseSet(Double_t mjd, Double_t alt) const
203{
204 return MAstro::GetSunRiseSet(mjd, GetLongitudeDeg(), GetLatitudeDeg(), alt);
205}
206
207// --------------------------------------------------------------------------
208//
209// Setup the observatory location from resource file:
210// MObservatory.Name: Magic1, WuerzburgCity
211//
212Int_t MObservatory::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
213{
214 if (IsEnvDefined(env, prefix, "Name", print))
215 {
216 TString name = GetEnvValue(env, prefix, "Name", "Magic1");
217 name = name.Strip(TString::kBoth);
218
219 if (name==(TString)"Magic1")
220 {
221 SetLocation(kMagic1);
222 return kTRUE;
223 }
224
225 if (name==(TString)"WuerzburgCity")
226 {
227 SetLocation(kWuerzburgCity);
228 return kTRUE;
229 }
230
231 *fLog << err << "MObservatory::ReadEnv - ERROR: Observatory " << name << " unknown." << endl;
232 return kERROR;
233 }
234
235 return kFALSE;
236
237}
Note: See TracBrowser for help on using the repository browser.