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 descries 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 "MLogManip.h"
|
---|
69 |
|
---|
70 | #include "MAstro.h"
|
---|
71 |
|
---|
72 | ClassImp(MReportDrive);
|
---|
73 |
|
---|
74 | using namespace std;
|
---|
75 |
|
---|
76 | // --------------------------------------------------------------------------
|
---|
77 | //
|
---|
78 | // Default construtor. Initialize identifier to "DRIVE-REPORT"
|
---|
79 | //
|
---|
80 | MReportDrive::MReportDrive() : MReport("DRIVE-REPORT")
|
---|
81 | {
|
---|
82 | fName = "MReportDrive";
|
---|
83 | fTitle = "Class for DRIVE-REPORT information";
|
---|
84 | }
|
---|
85 |
|
---|
86 | // --------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | // Interprete the body of the DRIVE-REPORT string
|
---|
89 | //
|
---|
90 | Int_t MReportDrive::InterpreteBody(TString &str)
|
---|
91 | {
|
---|
92 | MAstro::String2Angle(str, fRa);
|
---|
93 | MAstro::String2Angle(str, fDec);
|
---|
94 | MAstro::String2Angle(str, fHa);
|
---|
95 |
|
---|
96 | Int_t len;
|
---|
97 | Int_t n=sscanf(str.Data(), "%lf %n", &fMjd, &len);
|
---|
98 | if (n!=1)
|
---|
99 | {
|
---|
100 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
101 | return kCONTINUE;
|
---|
102 | }
|
---|
103 |
|
---|
104 | str.Remove(0, len);
|
---|
105 |
|
---|
106 | MAstro::String2Angle(str, fNominalZd);
|
---|
107 | MAstro::String2Angle(str, fNominalAz);
|
---|
108 | MAstro::String2Angle(str, fCurrentZd);
|
---|
109 | MAstro::String2Angle(str, fCurrentAz);
|
---|
110 |
|
---|
111 | n=sscanf(str.Data(), "%lf %lf %n", &fErrorZd, &fErrorAz, &len);
|
---|
112 | if (n!=2)
|
---|
113 | {
|
---|
114 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
115 | return kCONTINUE;
|
---|
116 | }
|
---|
117 |
|
---|
118 | str.Remove(0, len);
|
---|
119 |
|
---|
120 | str = str.Strip(TString::kBoth);
|
---|
121 |
|
---|
122 | return str.IsNull() ? kTRUE : kCONTINUE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | // --------------------------------------------------------------------------
|
---|
126 | //
|
---|
127 | // Returns the absolute deviation from the nominal position calculated
|
---|
128 | // from the system error.
|
---|
129 | //
|
---|
130 | Double_t MReportDrive::GetAbsError() const
|
---|
131 | {
|
---|
132 | const Double_t pzd = fNominalZd*TMath::DegToRad();
|
---|
133 | const Double_t azd = fErrorZd *TMath::DegToRad();
|
---|
134 | const Double_t aaz = fErrorAz *TMath::DegToRad();
|
---|
135 |
|
---|
136 | const double el = TMath::Pi()/2-pzd;
|
---|
137 |
|
---|
138 | const double dphi2 = aaz/2.;
|
---|
139 | const double cos2 = cos(dphi2)*cos(dphi2);
|
---|
140 | const double sin2 = sin(dphi2)*sin(dphi2);
|
---|
141 | const double d = cos(azd)*cos2 - cos(2*el)*sin2;
|
---|
142 |
|
---|
143 | //
|
---|
144 | // Original:
|
---|
145 | // cos(Zd1)*cos(Zd2)+sin(Zd1)*sin(Zd2)*cos(dAz)
|
---|
146 | //
|
---|
147 | // Correct:
|
---|
148 | // const double d = cos(azd)*cos2 - cos(el1+el2)*sin2;
|
---|
149 | //
|
---|
150 | // Estimated:
|
---|
151 | // const double d = cos(azd)*cos2 - cos(2*el)*sin2;
|
---|
152 | //
|
---|
153 |
|
---|
154 | return acos(d)*TMath::RadToDeg();
|
---|
155 | }
|
---|