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): Benjamin Riegel, 01/2005 <mailto:riegel@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2005
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | //////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MReportStarguider
|
---|
29 | //
|
---|
30 | // This is the class interpreting and storing the STARG-REPORT information.
|
---|
31 | //
|
---|
32 | // This is the place to get the azimuth-/zenith mispointing of the telescope
|
---|
33 | // given by the starguider-camera.
|
---|
34 | //
|
---|
35 | //
|
---|
36 | // Starguider reports are available since 2004/11/17.
|
---|
37 | // The nomnial pointing position is available since 2005/03/22
|
---|
38 | // The sky brightness and the number of identified stars since 2005/03/17
|
---|
39 | //
|
---|
40 | //
|
---|
41 | // Class Version 1:
|
---|
42 | // ----------------
|
---|
43 | // + Double_t fDevAz; // [arcmin] azimuth mispointing
|
---|
44 | // + Double_t fDevZd; // [arcmin] zenith mispointing
|
---|
45 | //
|
---|
46 | //
|
---|
47 | // Class Version 2:
|
---|
48 | // ----------------
|
---|
49 | // + Double_t fNominalZd; // [deg] Nominal zenith distance
|
---|
50 | // + Double_t fNominalAz; // [deg] Nominal azimuth
|
---|
51 | //
|
---|
52 | // + Float_t fCameraCenterX; // [CCD pix] PMT Camera center found
|
---|
53 | // + Float_t fCameraCenterY; // [CCD pix] PMT Camera center found
|
---|
54 | //
|
---|
55 | // + UInt_t fNumIdentifiedStars; // Number of stars identified by starguider algorithm
|
---|
56 | //
|
---|
57 | // + Double_t fSkyBrightness; // [au] Sky Brightness as calcualted from the CCD image
|
---|
58 | // + Double_t fMjd; // Modified Julian Date matching the nominal position
|
---|
59 | //
|
---|
60 | //
|
---|
61 | // Class Version 3:
|
---|
62 | // ----------------
|
---|
63 | // + UInt_t fNumCorrelatedStars; // Number of correlated stars identified by starguider algorithm
|
---|
64 | //
|
---|
65 | //////////////////////////////////////////////////////////////////////////////
|
---|
66 | #include "MReportStarguider.h"
|
---|
67 |
|
---|
68 | #include "MLogManip.h"
|
---|
69 |
|
---|
70 | #include "MAstro.h"
|
---|
71 |
|
---|
72 | ClassImp(MReportStarguider);
|
---|
73 |
|
---|
74 | using namespace std;
|
---|
75 |
|
---|
76 | // --------------------------------------------------------------------------
|
---|
77 | //
|
---|
78 | // Default constructor. Initialize identifier to "STARG-REPORT"
|
---|
79 | //
|
---|
80 | MReportStarguider::MReportStarguider() : MReport("STARG-REPORT")/*,
|
---|
81 | fDevAz(0), fDevZd(0), fNominalZd(0), fNominalAz(0),
|
---|
82 | fCameraCenterX(0), fCameraCenterY(0), fNumIdentifiedStars(0),
|
---|
83 | fNumCorrelatedStars(0), fSkyBrightness(0)*/
|
---|
84 | {
|
---|
85 | fName = "MReportStarguider";
|
---|
86 | fTitle = "Class for STARG-REPORT information (telescope mispointing)";
|
---|
87 |
|
---|
88 | Clear();
|
---|
89 | }
|
---|
90 |
|
---|
91 | // --------------------------------------------------------------------------
|
---|
92 | //
|
---|
93 | // Interprete the body of the STARG-REPORT string
|
---|
94 | //
|
---|
95 | void MReportStarguider::Clear(Option_t *o)
|
---|
96 | {
|
---|
97 | fDevAz = 0;
|
---|
98 | fDevZd = 0;
|
---|
99 |
|
---|
100 | fNominalZd = 0;
|
---|
101 | fNominalAz = 0;
|
---|
102 |
|
---|
103 | fCameraCenterX = 0;
|
---|
104 | fCameraCenterY = 0;
|
---|
105 |
|
---|
106 | fNumIdentifiedStars = 0;
|
---|
107 | fNumCorrelatedStars = 0;
|
---|
108 |
|
---|
109 | fSkyBrightness = 0;
|
---|
110 | }
|
---|
111 |
|
---|
112 | // --------------------------------------------------------------------------
|
---|
113 | //
|
---|
114 | // Interprete the body of the STARG-REPORT string
|
---|
115 | //
|
---|
116 | Int_t MReportStarguider::InterpreteBody(TString &str, Int_t ver)
|
---|
117 | {
|
---|
118 | Int_t len;
|
---|
119 | Int_t n=sscanf(str.Data(), "%lf %lf %n", &fDevZd, &fDevAz, &len);
|
---|
120 | if (n!=2)
|
---|
121 | {
|
---|
122 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
123 | return kCONTINUE;
|
---|
124 | }
|
---|
125 |
|
---|
126 | str.Remove(0, len);
|
---|
127 | str = str.Strip(TString::kBoth);
|
---|
128 |
|
---|
129 | if (ver<200503170)
|
---|
130 | {
|
---|
131 | // Fix a problem with the units
|
---|
132 | fDevAz *= 60./TMath::RadToDeg();
|
---|
133 | fDevZd *= 60./TMath::RadToDeg();
|
---|
134 | return str.IsNull() ? kTRUE : kCONTINUE;
|
---|
135 | }
|
---|
136 |
|
---|
137 | MAstro::String2Angle(str, fNominalZd); // Nom Zd
|
---|
138 | MAstro::String2Angle(str, fNominalAz); // Nom Az
|
---|
139 |
|
---|
140 | if (ver<200503220)
|
---|
141 | {
|
---|
142 | // Until a fix in the software the written position was nonsense
|
---|
143 | fNominalZd = 0;
|
---|
144 | fNominalAz = 0;
|
---|
145 | }
|
---|
146 |
|
---|
147 | n=sscanf(str.Data(), "%f %f %d %lf %lf %n",
|
---|
148 | &fCameraCenterX, &fCameraCenterY, &fNumIdentifiedStars,
|
---|
149 | &fSkyBrightness, &fMjd, &len);
|
---|
150 | if (n!=5)
|
---|
151 | {
|
---|
152 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
153 | return kCONTINUE;
|
---|
154 | }
|
---|
155 |
|
---|
156 | str.Remove(0, len);
|
---|
157 | str = str.Strip(TString::kBoth);
|
---|
158 |
|
---|
159 | // Seems that hasn't yet been implemented
|
---|
160 | if ((ver>=200508290 && ver<200509300) ||
|
---|
161 | (ver>=200603080))
|
---|
162 | {
|
---|
163 | // For the moment this are only placeholders....
|
---|
164 | Float_t dx, dy;
|
---|
165 | n=sscanf(str.Data(), "%f %f %n", &dx, &dy, &len);
|
---|
166 | if (n!=2 && ((n!=0&&n!=EOF) || ver!=200603080))
|
---|
167 | {
|
---|
168 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
169 | return kCONTINUE;
|
---|
170 | }
|
---|
171 |
|
---|
172 | str.Remove(0, len);
|
---|
173 | str = str.Strip(TString::kBoth);
|
---|
174 | }
|
---|
175 |
|
---|
176 | if (ver>=200605080)
|
---|
177 | {
|
---|
178 | fNumCorrelatedStars = fNumIdentifiedStars;
|
---|
179 | n=sscanf(str.Data(), "%df %n", &fNumIdentifiedStars, &len);
|
---|
180 | if (n!=1)
|
---|
181 | {
|
---|
182 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
183 | *fLog << str << endl;
|
---|
184 | return kCONTINUE;
|
---|
185 | }
|
---|
186 |
|
---|
187 | str.Remove(0, len);
|
---|
188 | str = str.Strip(TString::kBoth);
|
---|
189 | }
|
---|
190 |
|
---|
191 | return str.IsNull() ? kTRUE : kCONTINUE;
|
---|
192 | }
|
---|
193 |
|
---|
194 | Double_t MReportStarguider::GetDevAbs() const
|
---|
195 | {
|
---|
196 | return MAstro::GetDevAbs(fNominalZd, fDevZd/60, fDevAz/60)*60;
|
---|
197 | /*
|
---|
198 | // For the algorithm see also MReportDrive
|
---|
199 | const Double_t pzd = fNominalZd * TMath::DegToRad();
|
---|
200 | const Double_t azd = fDevZd/60 * TMath::DegToRad();
|
---|
201 | const Double_t aaz = fDevAz/60 * TMath::DegToRad();
|
---|
202 |
|
---|
203 | const double el = TMath::Pi()/2-pzd;
|
---|
204 |
|
---|
205 | const double dphi2 = aaz/2.;
|
---|
206 | const double cos2 = cos(dphi2)*cos(dphi2);
|
---|
207 | const double sin2 = sin(dphi2)*sin(dphi2);
|
---|
208 | const double d = cos(azd)*cos2 - cos(2*el)*sin2;
|
---|
209 |
|
---|
210 | return acos(d)*TMath::RadToDeg()*60;
|
---|
211 | */
|
---|
212 | }
|
---|
213 |
|
---|
214 | void MReportStarguider::Print(Option_t *o) const
|
---|
215 | {
|
---|
216 | *fLog << GetDescriptor() << ":" << endl;
|
---|
217 | *fLog << " DevZd=" << fDevZd << " DevAz=" << fDevAz << endl;
|
---|
218 | *fLog << " NominalZd=" << fNominalZd << " NominalAz=" << fDevAz << " MJD=" << fMjd << endl;
|
---|
219 | *fLog << " CameraCenterX=" << fCameraCenterX << " CameraCenterY=" << fCameraCenterY << endl;
|
---|
220 | *fLog << " NumIdentifiedStars=" << fNumIdentifiedStars << endl;
|
---|
221 | *fLog << " NumIdentifiedStars=" << fNumIdentifiedStars << " SkyBrightness=" << fSkyBrightness << endl;
|
---|
222 | }
|
---|