source: trunk/MagicSoft/Mars/mastro/MObservatory.cc@ 8886

Last change on this file since 8886 was 8337, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 6.7 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 fSinLatitude = TMath::Sin(fLatitude);
136 fCosLatitude = TMath::Cos(fLatitude);
137}
138
139// --------------------------------------------------------------------------
140//
141// Longitude/Latitude [rad]
142// Height [m]
143//
144void MObservatory::SetLocation(Double_t lon, Double_t lat, Double_t h, const char *name)
145{
146 fLongitude = lon;
147 fLatitude = lat;
148 fHeight = h;
149
150 fSinLatitude = TMath::Sin(fLatitude);
151 fCosLatitude = TMath::Cos(fLatitude);
152
153 if (name)
154 fObservatoryName = name;
155}
156
157void MObservatory::Print(Option_t *) const
158{
159 *fLog << all;
160 *fLog << underline << fObservatoryName << ":" << endl;
161 *fLog << "Latitude: " << TMath::Abs(fLatitude*kRad2Deg) << " deg " << (fLatitude > 0 ? "N" : "S") << endl;
162 *fLog << "Longitude: " << TMath::Abs(fLongitude*kRad2Deg) << " deg " << (fLongitude < 0 ? "E" : "W") << endl;
163 *fLog << "Height: " << fHeight << "m" << endl;
164}
165
166// --------------------------------------------------------------------------
167//
168// Get the corresponding rotation angle of the sky coordinate system
169// seen with an Alt/Az telescope.
170//
171// For more information see MAstro::RotationAngle
172//
173void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
174{
175 MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi, sin, cos);
176}
177
178// --------------------------------------------------------------------------
179//
180// Get the corresponding rotation angle of the sky coordinate system
181// seen with an Alt/Az telescope.
182//
183// For more information see MAstro::RotationAngle
184//
185Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
186{
187 return MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi);
188}
189
190// --------------------------------------------------------------------------
191//
192// Get the time (as mjd) of sunrise/sunset at the day floor(mjd)
193// above/below alt[deg]
194//
195// For more information see MAstro::GetSunRiseSet
196//
197// A TArrayD(2) is returned with the sunrise in TArray[0] and the
198// sunset in TArrayD[1].
199//
200TArrayD MObservatory::GetSunRiseSet(Double_t mjd, Double_t alt) const
201{
202 return MAstro::GetSunRiseSet(mjd, GetLongitudeDeg(), GetLatitudeDeg(), alt);
203}
204
205// --------------------------------------------------------------------------
206//
207// Setup the observatory location from resource file:
208// MObservatory.Name: Magic1, WuerzburgCity
209//
210Int_t MObservatory::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
211{
212 if (IsEnvDefined(env, prefix, "Name", print))
213 {
214 TString name = GetEnvValue(env, prefix, "Name", "Magic1");
215 name = name.Strip(TString::kBoth);
216
217 if (name==(TString)"Magic1")
218 {
219 SetLocation(kMagic1);
220 return kTRUE;
221 }
222
223 if (name==(TString)"WuerzburgCity")
224 {
225 SetLocation(kWuerzburgCity);
226 return kTRUE;
227 }
228
229 *fLog << err << "MObservatory::ReadEnv - ERROR: Observatory " << name << " unknown." << endl;
230 return kERROR;
231 }
232
233 return kFALSE;
234
235}
Note: See TracBrowser for help on using the repository browser.