| 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): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MPointingPos
|
|---|
| 28 | //
|
|---|
| 29 | // In this container we store the corrected pointing position of the
|
|---|
| 30 | // telscope. The pointing coordinates are read into MReportDrive together
|
|---|
| 31 | // with its time.
|
|---|
| 32 | //
|
|---|
| 33 | // MPointingPosCalc afterwards calculates corrections and checks for the
|
|---|
| 34 | // cosistency of the coordinates. The result (the real coordinates)
|
|---|
| 35 | // are stored in this container. No further correction should be necessary
|
|---|
| 36 | // using MPointingPos.
|
|---|
| 37 | //
|
|---|
| 38 | // If you need the rotation angle of the starfield in the camera you can
|
|---|
| 39 | // get it from here.
|
|---|
| 40 | //
|
|---|
| 41 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 | #include "MPointingPos.h"
|
|---|
| 43 |
|
|---|
| 44 | #include "fits.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MLog.h"
|
|---|
| 47 |
|
|---|
| 48 | #include "MTime.h"
|
|---|
| 49 | #include "MAstro.h"
|
|---|
| 50 | #include "MString.h"
|
|---|
| 51 | #include "MObservatory.h"
|
|---|
| 52 | #include "MPointingDev.h"
|
|---|
| 53 | #include "MAstroSky2Local.h"
|
|---|
| 54 |
|
|---|
| 55 | ClassImp(MPointingPos);
|
|---|
| 56 |
|
|---|
| 57 | using namespace std;
|
|---|
| 58 |
|
|---|
| 59 | const TString MPointingPos::gsDefName = "MPointingPos";
|
|---|
| 60 | const TString MPointingPos::gsDefTitle = "Container storing the (corrected) telescope pointing position";
|
|---|
| 61 |
|
|---|
| 62 | Double_t MPointingPos::GetZdRad() const
|
|---|
| 63 | {
|
|---|
| 64 | return fZd*TMath::DegToRad();
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | Double_t MPointingPos::GetAzRad() const
|
|---|
| 68 | {
|
|---|
| 69 | return fAz*TMath::DegToRad();
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | Double_t MPointingPos::GetRaRad() const
|
|---|
| 73 | {
|
|---|
| 74 | return fRa*TMath::DegToRad()*15;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | Double_t MPointingPos::GetDecRad() const
|
|---|
| 78 | {
|
|---|
| 79 | return fDec*TMath::DegToRad();
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Get the corresponding rotation angle of the sky coordinate system
|
|---|
| 85 | // seen with an Alt/Az telescope calculated from the stored local
|
|---|
| 86 | // (Zd/Az) coordinates.
|
|---|
| 87 | //
|
|---|
| 88 | // Return angle [rad] in the range -pi, pi
|
|---|
| 89 | //
|
|---|
| 90 | // For more information see MAstro::RotationAngle
|
|---|
| 91 | //
|
|---|
| 92 | Double_t MPointingPos::RotationAngle(const MObservatory &o) const
|
|---|
| 93 | {
|
|---|
| 94 | return o.RotationAngle(fZd*TMath::DegToRad(), fAz*TMath::DegToRad());
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | // --------------------------------------------------------------------------
|
|---|
| 98 | //
|
|---|
| 99 | // Get the corresponding rotation angle of the sky coordinate system
|
|---|
| 100 | // seen with an Alt/Az telescope calculated from the stored sky
|
|---|
| 101 | // (Ra/Dec) coordinates.
|
|---|
| 102 | //
|
|---|
| 103 | // Return angle [rad] in the range -pi, pi
|
|---|
| 104 | //
|
|---|
| 105 | // For more information see MAstro::RotationAngle
|
|---|
| 106 | //
|
|---|
| 107 | Double_t MPointingPos::RotationAngle(const MObservatory &o, const MTime &t, const MPointingDev *dev) const
|
|---|
| 108 | {
|
|---|
| 109 | return dev ?
|
|---|
| 110 | MAstroSky2Local(t, o).RotationAngle(GetRaRad(), GetDecRad(), dev->GetDevZdRad(), dev->GetDevAzRad()):
|
|---|
| 111 | MAstroSky2Local(t, o).RotationAngle(GetRaRad(), GetDecRad());
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | TString MPointingPos::GetString(Option_t *o) const
|
|---|
| 115 | {
|
|---|
| 116 | TString opt(o);
|
|---|
| 117 |
|
|---|
| 118 | if (opt.IsNull())
|
|---|
| 119 | opt = "radeczdaz";
|
|---|
| 120 |
|
|---|
| 121 | TString rc;
|
|---|
| 122 |
|
|---|
| 123 | if (opt.Contains("ra", TString::kIgnoreCase))
|
|---|
| 124 | rc += MString::Format(" Ra=%s", MAstro::GetStringHor(fRa).Data());
|
|---|
| 125 |
|
|---|
| 126 | if (opt.Contains("ha", TString::kIgnoreCase))
|
|---|
| 127 | rc += MString::Format(" Ha=%s", MAstro::GetStringHor(fHa).Data());
|
|---|
| 128 |
|
|---|
| 129 | if (opt.Contains("dec", TString::kIgnoreCase))
|
|---|
| 130 | rc += MString::Format(" Dec=%s", MAstro::GetStringDeg(fDec).Data());
|
|---|
| 131 |
|
|---|
| 132 | if (opt.Contains("zd", TString::kIgnoreCase))
|
|---|
| 133 | rc += MString::Format(" Zd=%s", MAstro::GetStringDeg(fZd).Data());
|
|---|
| 134 |
|
|---|
| 135 | if (opt.Contains("az", TString::kIgnoreCase))
|
|---|
| 136 | rc += MString::Format(" Az=%s", MAstro::GetStringDeg(fAz).Data());
|
|---|
| 137 |
|
|---|
| 138 | if (fTitle!=gsDefTitle)
|
|---|
| 139 | rc += MString::Format(" <%s>", fTitle.Data());
|
|---|
| 140 |
|
|---|
| 141 | return rc.Strip(TString::kBoth);
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | void MPointingPos::Print(Option_t *o) const
|
|---|
| 145 | {
|
|---|
| 146 | *fLog << GetDescriptor() << ": " << GetString(o) << endl;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | Bool_t MPointingPos::SetupFits(fits &fin)
|
|---|
| 150 | {
|
|---|
| 151 | if (!fin.SetRefAddress(Form("%s.fZd", fName.Data()), fZd)) return kFALSE;
|
|---|
| 152 | if (!fin.SetRefAddress(Form("%s.fAz", fName.Data()), fAz)) return kFALSE;
|
|---|
| 153 | if (!fin.SetRefAddress(Form("%s.fRa", fName.Data()), fRa)) return kFALSE;
|
|---|
| 154 | if (!fin.SetRefAddress(Form("%s.fDec", fName.Data()), fDec)) return kFALSE;
|
|---|
| 155 | if (!fin.SetRefAddress(Form("%s.fHa", fName.Data()), fHa)) return kFALSE;
|
|---|
| 156 |
|
|---|
| 157 | return kTRUE;
|
|---|
| 158 | }
|
|---|