| 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 |  | 
|---|
| 45 | ClassImp(MObservatory); | 
|---|
| 46 |  | 
|---|
| 47 | using namespace std; | 
|---|
| 48 |  | 
|---|
| 49 | void 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 | MObservatory::MObservatory(const char *name, const char *title) | 
|---|
| 56 | { | 
|---|
| 57 | Init(name, title); | 
|---|
| 58 |  | 
|---|
| 59 | SetLocation(kMagic1); | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | MObservatory::MObservatory(LocationName_t key, const char *name, const char *title) | 
|---|
| 63 | { | 
|---|
| 64 | Init(name, title); | 
|---|
| 65 |  | 
|---|
| 66 | SetLocation(key); | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | // -------------------------------------------------------------------------- | 
|---|
| 70 | // | 
|---|
| 71 | // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED | 
|---|
| 72 | // ON IT! | 
|---|
| 73 | // | 
|---|
| 74 | void MObservatory::SetLocation(LocationName_t name) | 
|---|
| 75 | { | 
|---|
| 76 | switch (name) | 
|---|
| 77 | { | 
|---|
| 78 | // BE EXTREMLY CARFEFULL CHANGING THIS CLASS! | 
|---|
| 79 | // THE TRACKING SYSTEM IS BASED ON IT! | 
|---|
| 80 | case kMagic1: | 
|---|
| 81 | // Values taken from the GPS Receiver (avg 24h) | 
|---|
| 82 | // on 29/04/2004 at 17h30 in the counting house | 
|---|
| 83 | fLatitude  = MAstro::Dms2Rad(28, 45, 42.462, '+'); | 
|---|
| 84 | fLongitude = MAstro::Dms2Rad(17, 53, 26.525, '-'); | 
|---|
| 85 | fHeight    = 2199.4; // m | 
|---|
| 86 | fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)"; | 
|---|
| 87 | break; | 
|---|
| 88 |  | 
|---|
| 89 | case kWuerzburgCity: | 
|---|
| 90 | fLatitude  = MAstro::Dms2Rad(51, 38, 48.0); | 
|---|
| 91 | fLongitude = MAstro::Dms2Rad( 9, 56, 36.0); | 
|---|
| 92 | fHeight    = 300; | 
|---|
| 93 | fObservatoryName = "Wuerzburg City"; | 
|---|
| 94 | break; | 
|---|
| 95 |  | 
|---|
| 96 | case kTuorla: | 
|---|
| 97 | fLatitude  = MAstro::Dms2Rad(60, 24, 57.0); | 
|---|
| 98 | fLongitude = MAstro::Dms2Rad(22, 26, 42.0); | 
|---|
| 99 | fHeight    = 53; | 
|---|
| 100 | fObservatoryName = "Tuorla"; | 
|---|
| 101 | break; | 
|---|
| 102 | } | 
|---|
| 103 |  | 
|---|
| 104 | fSinLatitude = TMath::Sin(fLatitude); | 
|---|
| 105 | fCosLatitude = TMath::Cos(fLatitude); | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | void MObservatory::Print(Option_t *) const | 
|---|
| 109 | { | 
|---|
| 110 | *fLog << all; | 
|---|
| 111 | *fLog << underline << fObservatoryName << ":" << endl; | 
|---|
| 112 | *fLog << "Latitude:  " << TMath::Abs(fLatitude*kRad2Deg)  << " deg " << (fLatitude  > 0 ? "N" : "S") << endl; | 
|---|
| 113 | *fLog << "Longitude: " << TMath::Abs(fLongitude*kRad2Deg) << " deg " << (fLongitude < 0 ? "E" : "W") << endl; | 
|---|
| 114 | *fLog << "Height:    " << fHeight << "m" << endl; | 
|---|
| 115 | } | 
|---|
| 116 |  | 
|---|
| 117 | // -------------------------------------------------------------------------- | 
|---|
| 118 | // | 
|---|
| 119 | // Get the corresponding rotation angle of the sky coordinate system | 
|---|
| 120 | // seen with an Alt/Az telescope. | 
|---|
| 121 | // | 
|---|
| 122 | // For more information see MAstro::RotationAngle | 
|---|
| 123 | // | 
|---|
| 124 | void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const | 
|---|
| 125 | { | 
|---|
| 126 | MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi, sin, cos); | 
|---|
| 127 | } | 
|---|
| 128 |  | 
|---|
| 129 | // -------------------------------------------------------------------------- | 
|---|
| 130 | // | 
|---|
| 131 | // Get the corresponding rotation angle of the sky coordinate system | 
|---|
| 132 | // seen with an Alt/Az telescope. | 
|---|
| 133 | // | 
|---|
| 134 | // For more information see MAstro::RotationAngle | 
|---|
| 135 | // | 
|---|
| 136 | Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const | 
|---|
| 137 | { | 
|---|
| 138 | return MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi); | 
|---|
| 139 | } | 
|---|
| 140 |  | 
|---|
| 141 | // -------------------------------------------------------------------------- | 
|---|
| 142 | // | 
|---|
| 143 | // Get the time (as mjd) of sunrise/sunset at the day floor(mjd) | 
|---|
| 144 | // above/below alt[deg] | 
|---|
| 145 | // | 
|---|
| 146 | // For more information see MAstro::GetSunRiseSet | 
|---|
| 147 | // | 
|---|
| 148 | // A TArrayD(2) is returned with the sunrise in TArray[0] and the | 
|---|
| 149 | // sunset in TArrayD[1]. | 
|---|
| 150 | // | 
|---|
| 151 | TArrayD MObservatory::GetSunRiseSet(Double_t mjd, Double_t alt) const | 
|---|
| 152 | { | 
|---|
| 153 | return MAstro::GetSunRiseSet(mjd, GetLongitudeDeg(), GetLatitudeDeg(), alt); | 
|---|
| 154 | } | 
|---|
| 155 |  | 
|---|
| 156 | // -------------------------------------------------------------------------- | 
|---|
| 157 | // | 
|---|
| 158 | // Setup the observatory location from resource file: | 
|---|
| 159 | //    MObservatory.Name: Magic1, WuerzburgCity | 
|---|
| 160 | // | 
|---|
| 161 | Int_t MObservatory::ReadEnv(const TEnv &env, TString prefix, Bool_t print) | 
|---|
| 162 | { | 
|---|
| 163 | if (IsEnvDefined(env, prefix, "Name", print)) | 
|---|
| 164 | { | 
|---|
| 165 | TString name = GetEnvValue(env, prefix, "Name", "Magic1"); | 
|---|
| 166 | name = name.Strip(TString::kBoth); | 
|---|
| 167 |  | 
|---|
| 168 | if (name==(TString)"Magic1") | 
|---|
| 169 | { | 
|---|
| 170 | SetLocation(kMagic1); | 
|---|
| 171 | return kTRUE; | 
|---|
| 172 | } | 
|---|
| 173 |  | 
|---|
| 174 | if (name==(TString)"WuerzburgCity") | 
|---|
| 175 | { | 
|---|
| 176 | SetLocation(kWuerzburgCity); | 
|---|
| 177 | return kTRUE; | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | *fLog << err << "MObservatory::ReadEnv - ERROR: Observatory " << name << " unknown." << endl; | 
|---|
| 181 | return kERROR; | 
|---|
| 182 | } | 
|---|
| 183 |  | 
|---|
| 184 | return kFALSE; | 
|---|
| 185 |  | 
|---|
| 186 | } | 
|---|