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-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MReportDrive
|
---|
28 | //
|
---|
29 | // This is the class interpreting and storing the DRIVE-REPORT information.
|
---|
30 | //
|
---|
31 | // This is NOT the place to get the pointing position from. The class
|
---|
32 | // definition might change. But it is the place to calculate the
|
---|
33 | // correct pointing position from.
|
---|
34 | //
|
---|
35 | //
|
---|
36 | // Double_t fMjd; // Modified Julian Date send by the drive system
|
---|
37 | // This is the MJD as it was calculated by the drive system when the report
|
---|
38 | // was send.
|
---|
39 | //
|
---|
40 | // Double_t fRa; // [h] Right ascension
|
---|
41 | // Double_t fDec; // [deg] Declination
|
---|
42 | // Double_t fHa; // [h] Hour angle
|
---|
43 | // Currently this describes the nominal source position
|
---|
44 | //
|
---|
45 | // Double_t fNominalZd; // [deg] Nominal zenith distance
|
---|
46 | // Double_t fNominalAz; // [deg] Nominal azimuth
|
---|
47 | // The nominal local position like it was calculated in the last
|
---|
48 | // control loop for time at which the last shaftencoder value has changed
|
---|
49 | //
|
---|
50 | // Double_t fCurrentZd; // [deg] current zenith distance
|
---|
51 | // Double_t fCurrentAz; // [deg] current azimuth
|
---|
52 | // The current local position like it was calculated in the last
|
---|
53 | // control loop from interpolated shaftencoder values for time at which
|
---|
54 | // the last shaftencoder value has changed
|
---|
55 | //
|
---|
56 | // Double_t fErrorZd; // [?] system error in the zenith angle axis
|
---|
57 | // Double_t fErrorAz; // [?] sistem error in the azimuth angle axis
|
---|
58 | // The system error on both axis derived from the two values above. Be
|
---|
59 | // carefull, eg near the zenith we a huge deviation in azimuth
|
---|
60 | // while having a small deviation in zenith angle might be meaingless.
|
---|
61 | // Please use GetAbsError to get the absolute distance between the
|
---|
62 | // twopositions.
|
---|
63 | //
|
---|
64 | //
|
---|
65 | //////////////////////////////////////////////////////////////////////////////
|
---|
66 | #include "MReportDrive.h"
|
---|
67 |
|
---|
68 | #include "fits.h"
|
---|
69 |
|
---|
70 | #include "MLogManip.h"
|
---|
71 |
|
---|
72 | #include "MAstro.h"
|
---|
73 |
|
---|
74 | ClassImp(MReportDrive);
|
---|
75 |
|
---|
76 | using namespace std;
|
---|
77 |
|
---|
78 | // --------------------------------------------------------------------------
|
---|
79 | //
|
---|
80 | // Default construtor. Initialize identifier to "DRIVE-REPORT"
|
---|
81 | //
|
---|
82 | MReportDrive::MReportDrive() : MReport("DRIVE-REPORT"),
|
---|
83 | fMjd(0), fRa(0), fDec(0), fHa(0), fNominalZd(0), fNominalAz(0),
|
---|
84 | fCurrentZd(0), fCurrentAz(0), fErrorZd(0), fErrorAz(0)
|
---|
85 | {
|
---|
86 | fName = "MReportDrive";
|
---|
87 | fTitle = "Class for DRIVE-REPORT information (raw telescope position)";
|
---|
88 | }
|
---|
89 |
|
---|
90 | Bool_t MReportDrive::SetupReadingFits(fits &file)
|
---|
91 | {
|
---|
92 | return
|
---|
93 | file.SetRefAddress("Ra", fRa) &&
|
---|
94 | file.SetRefAddress("Dec", fDec) &&
|
---|
95 | file.SetRefAddress("Ha", fHa) &&
|
---|
96 | file.SetRefAddress("Az", fNominalAz) &&
|
---|
97 | file.SetRefAddress("Zd", fNominalZd) &&
|
---|
98 | file.SetRefAddress("dAz", fErrorAz) &&
|
---|
99 | file.SetRefAddress("dZd", fErrorZd);
|
---|
100 | }
|
---|
101 |
|
---|
102 | Int_t MReportDrive::InterpreteFits(const fits &fits)
|
---|
103 | {
|
---|
104 | fCurrentZd = fNominalZd - fErrorZd;
|
---|
105 | fCurrentAz = fNominalAz - fErrorAz;
|
---|
106 |
|
---|
107 | return kTRUE;
|
---|
108 | }
|
---|
109 |
|
---|
110 | // --------------------------------------------------------------------------
|
---|
111 | //
|
---|
112 | // Interprete the body of the DRIVE-REPORT string
|
---|
113 | //
|
---|
114 | Int_t MReportDrive::InterpreteBody(TString &str, Int_t ver)
|
---|
115 | {
|
---|
116 | MAstro::String2Angle(str, fRa);
|
---|
117 | MAstro::String2Angle(str, fDec);
|
---|
118 | MAstro::String2Angle(str, fHa);
|
---|
119 |
|
---|
120 | Int_t len;
|
---|
121 | Int_t n=sscanf(str.Data(), "%lf %n", &fMjd, &len);
|
---|
122 | if (n!=1)
|
---|
123 | {
|
---|
124 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
125 | return kCONTINUE;
|
---|
126 | }
|
---|
127 |
|
---|
128 | str.Remove(0, len);
|
---|
129 |
|
---|
130 | MAstro::String2Angle(str, fNominalZd);
|
---|
131 | MAstro::String2Angle(str, fNominalAz);
|
---|
132 | MAstro::String2Angle(str, fCurrentZd);
|
---|
133 | MAstro::String2Angle(str, fCurrentAz);
|
---|
134 |
|
---|
135 | n=sscanf(str.Data(), "%lf %lf %n", &fErrorZd, &fErrorAz, &len);
|
---|
136 | if (n!=2)
|
---|
137 | {
|
---|
138 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
139 | return kCONTINUE;
|
---|
140 | }
|
---|
141 |
|
---|
142 | str.Remove(0, len);
|
---|
143 | str = str.Strip(TString::kBoth);
|
---|
144 |
|
---|
145 | if (ver>=200802200)
|
---|
146 | {
|
---|
147 | Int_t dummy; // Cosy armed or not
|
---|
148 | n=sscanf(str.Data(), "%d %n", &dummy, &len);
|
---|
149 | if (n!=1)
|
---|
150 | {
|
---|
151 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
152 | return kCONTINUE;
|
---|
153 | }
|
---|
154 |
|
---|
155 | str.Remove(0, len);
|
---|
156 | str = str.Strip(TString::kBoth);
|
---|
157 | }
|
---|
158 |
|
---|
159 | if (ver>=200905170)
|
---|
160 | {
|
---|
161 | Int_t dummy; // Starguider switched on or not
|
---|
162 | n=sscanf(str.Data(), "%d %n", &dummy, &len);
|
---|
163 | if (n!=1)
|
---|
164 | {
|
---|
165 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
166 | return kCONTINUE;
|
---|
167 | }
|
---|
168 |
|
---|
169 | str.Remove(0, len);
|
---|
170 | str = str.Strip(TString::kBoth);
|
---|
171 | }
|
---|
172 |
|
---|
173 | return str.IsNull() ? kTRUE : kCONTINUE;
|
---|
174 | }
|
---|
175 |
|
---|
176 | // --------------------------------------------------------------------------
|
---|
177 | //
|
---|
178 | // GetAbsError [deg]
|
---|
179 | //
|
---|
180 | // Returns the absolute deviation from the nominal position calculated
|
---|
181 | // from the system error.
|
---|
182 | //
|
---|
183 | //
|
---|
184 | Double_t MReportDrive::GetAbsError() const
|
---|
185 | {
|
---|
186 | return MAstro::GetDevAbs(fNominalZd, fCurrentZd, fErrorAz);
|
---|
187 | }
|
---|
188 |
|
---|
189 | void MReportDrive::Print(Option_t *o) const
|
---|
190 | {
|
---|
191 | *fLog << GetDescriptor() << ": Mjd=" << fMjd << " Ra=" << fRa << " Dec=" << fDec;
|
---|
192 | *fLog << " dZd=" << fErrorZd << " dAz=" << fErrorAz << " D=" << GetAbsError() << endl;
|
---|
193 | }
|
---|