source: trunk/MagicSoft/Mars/mreport/MReportStarguider.cc@ 9410

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