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

Last change on this file since 3457 was 3366, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.2 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 "MAstro.h"
37
38#include "MLog.h"
39#include "MLogManip.h"
40
41ClassImp(MObservatory);
42
43using namespace std;
44
45void MObservatory::Init(const char *name, const char *title)
46{
47 fName = name ? name : "MObservatory";
48 fTitle = title ? title : "Storage container for coordinates of an observatory";
49}
50
51MObservatory::MObservatory(const char *name, const char *title)
52{
53 Init(name, title);
54
55 SetLocation(kMagic1);
56}
57
58MObservatory::MObservatory(LocationName_t key, const char *name, const char *title)
59{
60 Init(name, title);
61
62 SetLocation(key);
63}
64
65// --------------------------------------------------------------------------
66//
67// BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
68// ON IT!
69//
70void MObservatory::SetLocation(LocationName_t name)
71{
72 switch (name)
73 {
74 // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM
75 // IS BASED ON IT!
76 case kMagic1:
77 // Values taken from the GPS Receiver (avg 20h)
78 // on 26/11/2003 at 17h30 in the counting house
79 fLatitude = MAstro::Dms2Rad(28, 45, 42.576, '+');
80 fLongitude = MAstro::Dms2Rad(17, 53, 26.460, '-');
81 fHeight = 2196.5; // m
82 fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
83 break;
84
85 case kWuerzburgCity:
86 fLatitude = MAstro::Dms2Rad(51, 38, 48.0);
87 fLongitude = MAstro::Dms2Rad( 9, 56, 36.0);
88 fHeight = 300;
89 fObservatoryName = "Wuerzburg City";
90 break;
91 }
92
93 fSinLatitude = TMath::Sin(fLatitude);
94 fCosLatitude = TMath::Cos(fLatitude);
95}
96
97void MObservatory::Print(Option_t *) const
98{
99 *fLog << all;
100 *fLog << fObservatoryName << endl;
101 *fLog << "Latitude " << (fLatitude > 0 ? (fLatitude*kRad2Deg) : -(fLatitude*kRad2Deg)) << " deg " << (fLatitude > 0 ? "W" : "E") << endl;
102 *fLog << "Longitude " << (fLongitude > 0 ? (fLongitude*kRad2Deg) : -(fLongitude*kRad2Deg)) <<" deg " << (fLongitude < 0 ? "N" : "S") << endl;
103 *fLog << "Height " << fHeight << "m" << endl;
104}
105
106// --------------------------------------------------------------------------
107//
108// RotationAngle
109//
110// calculates the angle for the rotation of the sky image in the camera;
111// this angle is a function of the local coordinates
112//
113// theta [rad]: polar angle/zenith distance
114// phi [rad]: rotation angle/azimuth
115//
116// Return sin/cos component of angle
117//
118// calculate rotation angle alpha of sky image in camera
119// (see TDAS 00-11, eqs. (18) and (20))
120//
121void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
122{
123 const Double_t sint = TMath::Sin(theta);
124 const Double_t cost = TMath::Cos(theta);
125
126 const Double_t sinl = fSinLatitude*sint;
127 const Double_t cosl = fCosLatitude*cost;
128
129 const Double_t sinp = TMath::Sin(phi);
130 const Double_t cosp = TMath::Cos(phi);
131
132 const Double_t v1 = sint*sinp;
133 const Double_t v2 = cosl - sinl*cosp;
134
135 const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
136
137 sin = (fCosLatitude*sinp) / denom;
138 cos = sinl + cosl*cosp / denom;
139}
140
141// --------------------------------------------------------------------------
142//
143// RotationAngle
144//
145// calculates the angle for the rotation of the sky image in the camera;
146// this angle is a function of the local coordinates
147//
148// theta [rad]: polar angle/zenith distance
149// phi [rad]: rotation angle/azimuth
150//
151// Return RotationAngle in rad
152//
153// calculate rotation angle alpha of sky image in camera
154// (see TDAS 00-11, eqs. (18) and (20))
155//
156Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
157{
158 const Double_t sint = TMath::Sin(theta);
159 const Double_t cost = TMath::Cos(theta);
160
161 const Double_t sinp = TMath::Sin(phi);
162 const Double_t cosp = TMath::Cos(phi);
163
164 const Double_t v1 = sint*sinp;
165 const Double_t v2 = fCosLatitude*cost - fSinLatitude*sint*cosp;
166
167 const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
168
169 return TMath::ASin((fCosLatitude*sinp) / denom);
170}
Note: See TracBrowser for help on using the repository browser.