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, 07/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2007
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MPointingDevCalc
|
---|
28 | //
|
---|
29 | // Calculates the pointing deviation from the starguider information.
|
---|
30 | //
|
---|
31 | // There are some quality parameters to steer which are the valid
|
---|
32 | // starguider data points:
|
---|
33 | //
|
---|
34 | // * MPointingDevCalc.NumMinStars: 8
|
---|
35 | // Minimum number of identified stars required to accep the data
|
---|
36 | //
|
---|
37 | // * MPointingDevCalc.NsbLevel: 3.0
|
---|
38 | // Minimum deviation (in rms) from the the mean allowed for the
|
---|
39 | // measured NSB (noise in the ccd camera)
|
---|
40 | //
|
---|
41 | // * MPointingDevCalc.NsbMin: 30
|
---|
42 | // - minimum NSB to be used in mean/rms calculation
|
---|
43 | //
|
---|
44 | // * MPointingDevCalc.NsbMax: 60
|
---|
45 | // - maximum NSB to be used in mean/rms calculation
|
---|
46 | //
|
---|
47 | // * MPointingDevCalc.MaxAbsDev: 15
|
---|
48 | // - Maximum absolute deviation which is consideres as valid (arcmin)
|
---|
49 | //
|
---|
50 | // Starguider data which doens't fullfill this requirements is ignored.
|
---|
51 | // If the measures NSB==0 (file too old, starguider didn't write down
|
---|
52 | // these values) the checks based on NSB and NumMinStar are skipped.
|
---|
53 | //
|
---|
54 | // The calculation of NSB mean and rms is reset for each file (ReInit)
|
---|
55 | //
|
---|
56 | // If your starguider data doesn't fullfill this requirement the latest
|
---|
57 | // value which could be correctly calculated is used instead. If the time
|
---|
58 | // for which no valid value can be calculated exceeds one minute
|
---|
59 | // the return value is reset to 0/0. The maximum time allowed without
|
---|
60 | // a valid value can be setup using:
|
---|
61 | //
|
---|
62 | // * MPointingDevCalc.MaxAge: 1
|
---|
63 | // Maximum time before the starguider is reset to 0/0 in minutes
|
---|
64 | //
|
---|
65 | // Note, that the starguider itself is not well calibrated. Therefore
|
---|
66 | // it is necessary to do a starguider calibration in our software.
|
---|
67 | //
|
---|
68 | // There are two options:
|
---|
69 | //
|
---|
70 | // * Simple starguider calibration using offsets in the camera plane
|
---|
71 | //
|
---|
72 | // The starguider is calibrated by taking its values (dZd/dAz)
|
---|
73 | // adding them to the source position, calculating the source position
|
---|
74 | // in the camera plane and adding the offsets. To switch off the
|
---|
75 | // full starguider calibration do:
|
---|
76 | //
|
---|
77 | // * MPointingDevCalc.PointingModels:
|
---|
78 | //
|
---|
79 | // To set the offsets (in units of degree) use
|
---|
80 | //
|
---|
81 | // * MPointingDevCalc.Dx: -0.001
|
---|
82 | // * MPointingDevCalc.Dy: -0.004
|
---|
83 | //
|
---|
84 | // * A starguider calibration using a pointing model calculated
|
---|
85 | // from calibration data, so called TPoints
|
---|
86 | //
|
---|
87 | // Because the pointing model can change from time to time
|
---|
88 | // you can give the run-number from which on a new pointing
|
---|
89 | // model is valid. The run itself is included, e.g.:
|
---|
90 | //
|
---|
91 | // * MPointingDevCalc.PointingModels: 85240 89180
|
---|
92 | // * MPointingDevCalc.FilePrefix: resources/starguider
|
---|
93 | //
|
---|
94 | // mean that for all runs<85240 the simple offset correction is used.
|
---|
95 | // For runs >=85240 and <89180 the file resources/starguider0085240.txt
|
---|
96 | // and for runs >=89180 the file resources/starguider0089180.txt is
|
---|
97 | // used. To setup a default file for all runs before 85240 setup
|
---|
98 | // a low number (eg. 0 or 1)
|
---|
99 | //
|
---|
100 | // In the case a pointing model is used additional offsets in
|
---|
101 | // the x/y-camera plane (in units of deg) can be set using the DX
|
---|
102 | // and DY parameters of the pointing model. The fDx and fDy data
|
---|
103 | // members of this class are ignored. To overwrite the starguider
|
---|
104 | // calibrated offset in either Az or Zd with a constant, you
|
---|
105 | // can use the PX/PY directive in the pointing model. (To enable
|
---|
106 | // the overwrite set the third column, the error, to a value
|
---|
107 | // greater than zero)
|
---|
108 | //
|
---|
109 | //
|
---|
110 | // At the PostProcessing step a table with statistics is print if the
|
---|
111 | // debug level is greater or equal 3 (in most applications it is switched
|
---|
112 | // on by -v3)
|
---|
113 | //
|
---|
114 | //
|
---|
115 | // Pointing Models:
|
---|
116 | // ----------------
|
---|
117 | //
|
---|
118 | // What we know so far about (maybe) important changes in cosy:
|
---|
119 | //
|
---|
120 | // 18.03.2006: The camera holding has been repaired and the camera got
|
---|
121 | // shifted a little bit.
|
---|
122 | //
|
---|
123 | // 16.04.2006: Around this date a roque lamp focussing hass been done
|
---|
124 | //
|
---|
125 | // 25.04.2006: A missalignment intrduced with the roque adjust has been
|
---|
126 | // corrected
|
---|
127 | //
|
---|
128 | // The starguider pointing model for the time before 18.3.2006 and after
|
---|
129 | // April 2006 (in fact there are no TPoints until 07/2006 to check it)
|
---|
130 | // and for the period 07/2006 to (at least) 06/2007 are very similar.
|
---|
131 | //
|
---|
132 | // The pointing model for the time between 18.3.2006 and 04/2006 is
|
---|
133 | // clearly different, mainly giving different Azimuth values between
|
---|
134 | // Zenith and roughly ~25deg, and a slight offset on both axes.
|
---|
135 | //
|
---|
136 | // 10.5.2006: pos1 -= pos0 commented (What was the mentioned fix?)
|
---|
137 | // 29.6.2006: repaired
|
---|
138 | //
|
---|
139 | // 23.3.2006: new starguider algorithm
|
---|
140 | //
|
---|
141 | // 17.3.2005: Fixed units of "nompos" in MDriveCom
|
---|
142 | //
|
---|
143 | //
|
---|
144 | // New pointing models have been installed (if the pointing model
|
---|
145 | // is different, than the previous one it might mean, that also
|
---|
146 | // the starguider calibration is different.) The date only means
|
---|
147 | // day-time (noon) at which the model has been changed.
|
---|
148 | //
|
---|
149 | // 29. Apr. 2004 ~25800
|
---|
150 | // 5. Aug. 2004 ~32000
|
---|
151 | // 19. Aug. 2004 ~33530
|
---|
152 | // 7. Jun. 2005 ~57650
|
---|
153 | // 8. Jun. 2005
|
---|
154 | // 9. Jun. 2005 ~57860
|
---|
155 | // 12. Sep. 2005 ~68338
|
---|
156 | // 24. Nov. 2005 ~75562
|
---|
157 | // 17. Oct. 2006 ~103130
|
---|
158 | // 17. Jun. 2007 ~248193
|
---|
159 | // 18. Oct. 2007 291104 // Correction for the offsets introduced by AMC
|
---|
160 | // 14. Jan. 2008 328198 // Complete new pointing model
|
---|
161 | // 11. Jun. 2008 (ca. 23:00)
|
---|
162 | //
|
---|
163 | // From 2.2.2006 beginnig of the night (21:05h, run >=81855) to 24.2.2006
|
---|
164 | // beginning of the the night (20:34h, run<83722) the LEDs did not work.
|
---|
165 | // In the time after this incident the shift crew often forgot to switch on
|
---|
166 | // the LEDs at the beginning of the night!
|
---|
167 | //
|
---|
168 | // [2006-03-07 00:10:58] In the daytime, we raised the position of the
|
---|
169 | // 9 o'clock LED by one screw hole to make it visible when the TPoint
|
---|
170 | // Lid is closed. (< run 84980)
|
---|
171 | //
|
---|
172 | // Mirror refocussing around 23.Apr.2006, from the Runbook.
|
---|
173 | //
|
---|
174 | // 25./26.4.2006: Run 89180
|
---|
175 | //
|
---|
176 | // (Note: The year here is not a typo!)
|
---|
177 | // [2007-04-25 23:50:39]
|
---|
178 | // Markus is performing AMC focussing.
|
---|
179 | //
|
---|
180 | // Mirror refocussing around 4.Aug.2007, from the Runbook:
|
---|
181 | //
|
---|
182 | // [2007-08-04 04:46:47]
|
---|
183 | // We finished with the focussing with Polaris. The images need to be
|
---|
184 | // analysed and new LUTs generated.
|
---|
185 | //
|
---|
186 | // [2007-08-04 23:47:30]
|
---|
187 | // Actually we see that the mispointing is always large; probably since
|
---|
188 | // the LUT tables have not yet been adjusted to the new focussing.
|
---|
189 | //
|
---|
190 | // [2007-08-03 23:07:58]
|
---|
191 | // Data taking stopped. Mirror focussing.
|
---|
192 | //
|
---|
193 | // [2007-08-05 00:09:16]
|
---|
194 | // We take some pictures on stars nearby Cyg X3 with the sbig camera;
|
---|
195 | // actually the spot doesn't look very nice... The pictures have been
|
---|
196 | // saved with name Deneb- and Sadr- Polaris seems a bit better. Should we
|
---|
197 | // have new LUT tables after the focussing?
|
---|
198 | //
|
---|
199 | // [2007-08-10 20:18:48]
|
---|
200 | // Tonight we take first images of Polaris with a new LUT file generated
|
---|
201 | // based on the recent focussing. The image will be analysed tomorrow and
|
---|
202 | // than new LUTs will be generated. For tonight the focussing is still not
|
---|
203 | // changed.
|
---|
204 | //
|
---|
205 | // [2007-08-14 20:57:59]
|
---|
206 | // The weather is fine. There is a group of hobby astronomers at the
|
---|
207 | // helicopter parking. Before data taking, we tried to check the new LUTs.
|
---|
208 | // However, because of technical problems with the new LUTs we had to
|
---|
209 | // postpone the measurements. We lost some 10 min of data taking because
|
---|
210 | // of this.
|
---|
211 | //
|
---|
212 | // [2007-08-14 22:29:37] Run 267253
|
---|
213 | // Before continuing the observation we perform a focussing test with the
|
---|
214 | // new LUTs from recent Polaris focussing. Note: Data on Her X-1 was taken
|
---|
215 | // with old focussing. We performed PSF measurements on Kornephorus (Zd
|
---|
216 | // 31.77, Az 264,67) first with old LUTs and then with new LUTs. We took
|
---|
217 | // T-points with both focussing. The first T-Point corresponds to the
|
---|
218 | // previous focussing and the second with the improved. Please check both
|
---|
219 | // T-points for eventual misspointing. We found big improvement of the PSF
|
---|
220 | // with the new LUTs and will therefore continue from now on with the new
|
---|
221 | // focussing. Having a first look at the SBIG pictures we see a slightly
|
---|
222 | // misspointing of ~0.1 deg with the new LUTs.
|
---|
223 | //
|
---|
224 | // [2007-08-14 22:46:10]
|
---|
225 | // Comparing the trigger rate with yesterday night we do not see an
|
---|
226 | // improvement with the new focussing.
|
---|
227 | //
|
---|
228 | // [2007-10-27 email]
|
---|
229 | // [...]
|
---|
230 | // When removing the cover of the motor all 4 nuts which fix the gear of
|
---|
231 | // the motor to the structure fell out. The motor was completely loose.
|
---|
232 | // [...]
|
---|
233 | // We checked also the second azimuth motor and .. the same situation.
|
---|
234 | // [...]
|
---|
235 | // Peter Sawallisch opened and fixed all 3 motors of MAGIC-I. We checked
|
---|
236 | // all critical screws that came to our minds and fixed them as much as
|
---|
237 | // possible with loctite and counter nuts. No damage whatsoever has been
|
---|
238 | // found.
|
---|
239 | //
|
---|
240 | //
|
---|
241 | // ToDo:
|
---|
242 | // -----
|
---|
243 | //
|
---|
244 | // * Is 0/0 the best assumption if the starguider partly fails?
|
---|
245 | //
|
---|
246 | //
|
---|
247 | // Input Container:
|
---|
248 | // MRawRunHeader
|
---|
249 | // MReportStarguider
|
---|
250 | //
|
---|
251 | // Output Container:
|
---|
252 | // MPointingDev
|
---|
253 | //
|
---|
254 | /////////////////////////////////////////////////////////////////////////////
|
---|
255 | #include "MPointingDevCalc.h"
|
---|
256 |
|
---|
257 | #include "MLog.h"
|
---|
258 | #include "MLogManip.h"
|
---|
259 |
|
---|
260 | #include "MParList.h"
|
---|
261 |
|
---|
262 | #include "MAstro.h"
|
---|
263 | #include "MPointing.h"
|
---|
264 | #include "MPointingDev.h"
|
---|
265 | #include "MRawRunHeader.h"
|
---|
266 | #include "MReportStarguider.h"
|
---|
267 |
|
---|
268 | ClassImp(MPointingDevCalc);
|
---|
269 |
|
---|
270 | using namespace std;
|
---|
271 |
|
---|
272 | const TString MPointingDevCalc::fgFilePrefix="resources/starguider";
|
---|
273 |
|
---|
274 | // --------------------------------------------------------------------------
|
---|
275 | //
|
---|
276 | // Destructor. Call Clear() and delete fPointingModels if any.
|
---|
277 | //
|
---|
278 | MPointingDevCalc::~MPointingDevCalc()
|
---|
279 | {
|
---|
280 | Clear();
|
---|
281 | }
|
---|
282 |
|
---|
283 | // --------------------------------------------------------------------------
|
---|
284 | //
|
---|
285 | // Delete fPointing and set pointing to NULL
|
---|
286 | //
|
---|
287 | void MPointingDevCalc::Clear(Option_t *o)
|
---|
288 | {
|
---|
289 | if (fPointing)
|
---|
290 | delete fPointing;
|
---|
291 |
|
---|
292 | fPointing = NULL;
|
---|
293 | }
|
---|
294 |
|
---|
295 | // --------------------------------------------------------------------------
|
---|
296 | //
|
---|
297 | // Sort the entries in fPoinitngModels
|
---|
298 | //
|
---|
299 | void MPointingDevCalc::SortPointingModels()
|
---|
300 | {
|
---|
301 | const int n = fPointingModels.GetSize();
|
---|
302 |
|
---|
303 | TArrayI idx(n);
|
---|
304 |
|
---|
305 | TMath::Sort(n, fPointingModels.GetArray(), idx.GetArray(), kFALSE);
|
---|
306 |
|
---|
307 | const TArrayI arr(fPointingModels);
|
---|
308 |
|
---|
309 | for (int i=0; i<n; i++)
|
---|
310 | fPointingModels[i] = arr[idx[i]];
|
---|
311 | }
|
---|
312 |
|
---|
313 | // --------------------------------------------------------------------------
|
---|
314 | //
|
---|
315 | // Set new pointing models
|
---|
316 | //
|
---|
317 | void MPointingDevCalc::SetPointingModels(const TString &models)
|
---|
318 | {
|
---|
319 | fPointingModels.Set(0);
|
---|
320 |
|
---|
321 | if (models.IsNull())
|
---|
322 | return;
|
---|
323 |
|
---|
324 | TObjArray *arr = models.Tokenize(" ");
|
---|
325 |
|
---|
326 | const int n = arr->GetEntries();
|
---|
327 | fPointingModels.Set(n);
|
---|
328 |
|
---|
329 | for (int i=0; i<n; i++)
|
---|
330 | fPointingModels[i] = atoi((*arr)[i]->GetName());
|
---|
331 |
|
---|
332 | delete arr;
|
---|
333 |
|
---|
334 | SortPointingModels();
|
---|
335 | }
|
---|
336 |
|
---|
337 | // --------------------------------------------------------------------------
|
---|
338 | //
|
---|
339 | // Return a string with the pointing models, seperated by a space.
|
---|
340 | //
|
---|
341 | TString MPointingDevCalc::GetPointingModels() const
|
---|
342 | {
|
---|
343 | TString rc;
|
---|
344 | for (int i=0; i<fPointingModels.GetSize(); i++)
|
---|
345 | rc += Form ("%d ", fPointingModels[i]);
|
---|
346 |
|
---|
347 | return rc;
|
---|
348 | }
|
---|
349 |
|
---|
350 | // --------------------------------------------------------------------------
|
---|
351 | //
|
---|
352 | // Add a number to the pointing models
|
---|
353 | //
|
---|
354 | void MPointingDevCalc::AddPointingModel(UInt_t runnum)
|
---|
355 | {
|
---|
356 | const int n = fPointingModels.GetSize();
|
---|
357 | for (int i=0; i<n; i++)
|
---|
358 | if ((UInt_t)fPointingModels[i]==runnum)
|
---|
359 | {
|
---|
360 | *fLog << warn << "WARNING - Pointing model " << runnum << " already in list... ignored." << endl;
|
---|
361 | return;
|
---|
362 | }
|
---|
363 |
|
---|
364 | fPointingModels.Set(n+1);
|
---|
365 | fPointingModels[n] = runnum;
|
---|
366 |
|
---|
367 | SortPointingModels();
|
---|
368 | }
|
---|
369 |
|
---|
370 | // --------------------------------------------------------------------------
|
---|
371 | //
|
---|
372 | // Find the highest number in the array which is lower or equal num.
|
---|
373 | //
|
---|
374 | UInt_t MPointingDevCalc::FindPointingModel(UInt_t num)
|
---|
375 | {
|
---|
376 | const int n = fPointingModels.GetSize();
|
---|
377 | if (n==0)
|
---|
378 | return (UInt_t)-1;
|
---|
379 |
|
---|
380 | // Loop over all pointing models
|
---|
381 | for (int i=0; i<n; i++)
|
---|
382 | {
|
---|
383 | // The number stored in the array did not yet overtake the runnumber
|
---|
384 | if ((UInt_t)fPointingModels[i]<num)
|
---|
385 | continue;
|
---|
386 |
|
---|
387 | // The first pointing model is later than this run: use a default
|
---|
388 | if (i==0)
|
---|
389 | return (UInt_t)-1;
|
---|
390 |
|
---|
391 | // The last entry in the array is the right one.
|
---|
392 | return fPointingModels[i-1];
|
---|
393 | }
|
---|
394 |
|
---|
395 | // Runnumber is after last entry of pointing models. Use the last one.
|
---|
396 | return fPointingModels[n-1];
|
---|
397 | }
|
---|
398 |
|
---|
399 | // --------------------------------------------------------------------------
|
---|
400 | //
|
---|
401 | // Clear the pointing model. If run-number >= 87751 read the new
|
---|
402 | // pointing model with fFilePrefix
|
---|
403 | //
|
---|
404 | Bool_t MPointingDevCalc::ReadPointingModel(const MRawRunHeader &run)
|
---|
405 | {
|
---|
406 | const UInt_t num = FindPointingModel(run.GetRunNumber());
|
---|
407 |
|
---|
408 | // No poinitng models are defined. Use simple dx/dy-calibration
|
---|
409 | if (num==(UInt_t)-1)
|
---|
410 | {
|
---|
411 | Clear();
|
---|
412 | return kTRUE;
|
---|
413 | }
|
---|
414 |
|
---|
415 | // compile the name for the starguider files
|
---|
416 | // The file with the number 00000000 is the default file
|
---|
417 | TString fname = Form("%s%08d.txt", fFilePrefix.Data(), num);
|
---|
418 |
|
---|
419 | if (!fPointing)
|
---|
420 | fPointing = new MPointing;
|
---|
421 |
|
---|
422 | if (fname==fPointing->GetName())
|
---|
423 | {
|
---|
424 | *fLog << inf << fname << " already loaded." << endl;
|
---|
425 | return kTRUE;
|
---|
426 | }
|
---|
427 |
|
---|
428 | return fPointing->Load(fname);
|
---|
429 | }
|
---|
430 |
|
---|
431 | // --------------------------------------------------------------------------
|
---|
432 | //
|
---|
433 | // Check the file/run type from the run-header and if it is a data file
|
---|
434 | // load starguider calibration.
|
---|
435 | //
|
---|
436 | Bool_t MPointingDevCalc::ReInit(MParList *plist)
|
---|
437 | {
|
---|
438 | MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
|
---|
439 | if (!run)
|
---|
440 | {
|
---|
441 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
---|
442 | return kFALSE;
|
---|
443 | }
|
---|
444 |
|
---|
445 | fNsbSum = 0;
|
---|
446 | fNsbSq = 0;
|
---|
447 | fNsbCount = 0;
|
---|
448 |
|
---|
449 | fRunType = run->GetRunType();
|
---|
450 |
|
---|
451 | switch (fRunType)
|
---|
452 | {
|
---|
453 | case MRawRunHeader::kRTData:
|
---|
454 | if (!fReport)
|
---|
455 | *fLog << warn << "MReportStarguider not found... skipped." << endl;
|
---|
456 | return ReadPointingModel(*run);
|
---|
457 |
|
---|
458 | case MRawRunHeader::kRTMonteCarlo:
|
---|
459 | return kTRUE;
|
---|
460 |
|
---|
461 | case MRawRunHeader::kRTPedestal:
|
---|
462 | *fLog << err << "Cannot work in a pedestal Run!... aborting." << endl;
|
---|
463 | return kFALSE;
|
---|
464 |
|
---|
465 | case MRawRunHeader::kRTCalibration:
|
---|
466 | *fLog << err << "Cannot work in a calibration Run!... aborting." << endl;
|
---|
467 | return kFALSE;
|
---|
468 |
|
---|
469 | default:
|
---|
470 | *fLog << err << "Run Type " << fRunType << " unknown!... aborting." << endl;
|
---|
471 | return kFALSE;
|
---|
472 | }
|
---|
473 |
|
---|
474 | return kTRUE;
|
---|
475 | }
|
---|
476 |
|
---|
477 | // --------------------------------------------------------------------------
|
---|
478 | //
|
---|
479 | // Search for 'MPointingPos'. Create if not found.
|
---|
480 | //
|
---|
481 | Int_t MPointingDevCalc::PreProcess(MParList *plist)
|
---|
482 | {
|
---|
483 | fDeviation = (MPointingDev*)plist->FindCreateObj("MPointingDev");
|
---|
484 | fReport = (MReportStarguider*)plist->FindObject("MReportStarguider");
|
---|
485 |
|
---|
486 | // We use kRTNone here as a placeholder for data runs.
|
---|
487 | fRunType = MRawRunHeader::kRTNone;
|
---|
488 | fLastMjd = -1;
|
---|
489 |
|
---|
490 | fSkip.Reset();
|
---|
491 |
|
---|
492 | return fDeviation ? kTRUE : kFALSE;
|
---|
493 | }
|
---|
494 |
|
---|
495 | // --------------------------------------------------------------------------
|
---|
496 | //
|
---|
497 | // Increase fSkip[i] by one. If the data in fDeviation is outdated (older
|
---|
498 | // than fMaxAge) and the current report should be skipped reset DevZdAz and
|
---|
499 | // DevXY and fSkip[6] is increased by one.
|
---|
500 | //
|
---|
501 | void MPointingDevCalc::Skip(Int_t i)
|
---|
502 | {
|
---|
503 | fSkip[i]++;
|
---|
504 |
|
---|
505 | const Double_t diff = (fReport->GetMjd()-fLastMjd)*1440; // [min] 1440=24*60
|
---|
506 | if (diff<fMaxAge && fLastMjd>0)
|
---|
507 | return;
|
---|
508 |
|
---|
509 | fDeviation->SetDevZdAz(0, 0);
|
---|
510 | fDeviation->SetDevXY(0, 0);
|
---|
511 | fSkip[6]++;
|
---|
512 | }
|
---|
513 |
|
---|
514 | // --------------------------------------------------------------------------
|
---|
515 | //
|
---|
516 | // Do a full starguider calibration using a pointing model for the starguider.
|
---|
517 | //
|
---|
518 | void MPointingDevCalc::DoCalibration(Double_t devzd, Double_t devaz) const
|
---|
519 | {
|
---|
520 | if (!fPointing)
|
---|
521 | {
|
---|
522 | // Do a simple starguider calibration using a simple offset in x and y
|
---|
523 | fDeviation->SetDevZdAz(devzd, devaz);
|
---|
524 |
|
---|
525 | // Linear starguider calibration taken from April/May data
|
---|
526 | // For calibration add MDriveReport::GetErrorZd/Az !
|
---|
527 | fDeviation->SetDevXY(fDx, fDy); // 1arcmin ~ 5mm
|
---|
528 |
|
---|
529 | return;
|
---|
530 | }
|
---|
531 |
|
---|
532 | // Get the nominal position the star is at the sky
|
---|
533 | // Unit: deg
|
---|
534 | ZdAz nom(fReport->GetNominalZd(), fReport->GetNominalAz());
|
---|
535 | nom *= TMath::DegToRad();
|
---|
536 |
|
---|
537 | // Get the mispointing measured by the telescope. It is
|
---|
538 | // calculate as follows:
|
---|
539 | //
|
---|
540 | // The mispointing measured by the starguider:
|
---|
541 | // ZdAz mis(devzd, devaz);
|
---|
542 | // mis *= TMath::DegToRad();
|
---|
543 |
|
---|
544 | // The pointing model is the conversion from the real pointing
|
---|
545 | // position of the telescope into the pointing position measured
|
---|
546 | // by the starguider.
|
---|
547 | //
|
---|
548 | // To keep as close to the fitted model we use the forward correction.
|
---|
549 |
|
---|
550 | // Position at which the starguider camera is pointing in real:
|
---|
551 | // pointing position = nominal position - dev
|
---|
552 | //
|
---|
553 | // The position measured as the starguider's pointing position
|
---|
554 | ZdAz pos(nom); // cpos = sao - dev
|
---|
555 | pos -= ZdAz(devzd, devaz)*TMath::DegToRad();
|
---|
556 |
|
---|
557 | // Now we convert the starguider's pointing position into the
|
---|
558 | // telescope pointing position (the pointing model converts
|
---|
559 | // the telescope pointing position into the starguider pointing
|
---|
560 | // position)
|
---|
561 | ZdAz point = fPointing->CorrectBack(pos); //FWD!!!
|
---|
562 |
|
---|
563 | // MSrcPosCalc uses the following condition to calculate the
|
---|
564 | // source position in the camera:
|
---|
565 | // real pointing pos = nominal pointing pos - dev
|
---|
566 | // --> dev = nominal - real
|
---|
567 | // Therefor we calculate dev as follows:
|
---|
568 | ZdAz dev(nom);
|
---|
569 | dev -= point;
|
---|
570 | dev *= TMath::RadToDeg();
|
---|
571 |
|
---|
572 | /*
|
---|
573 | // We chose the other way. It is less accurate because is is the
|
---|
574 | // other was than the poinitng model was fittet, but it is more
|
---|
575 | // accurate because the nominal (i.e. real) pointing position
|
---|
576 | // is less accurately known than the position returned by the
|
---|
577 | // starguider.
|
---|
578 | //
|
---|
579 | // Calculate the deviation which would be measured by the starguider
|
---|
580 | // if applied to a perfectly pointing telescope.
|
---|
581 | ZdAz dev = fPointing->Correct(nom);
|
---|
582 | dev -= nom;
|
---|
583 |
|
---|
584 | // Now add these offsets and the starguider measured offsets to
|
---|
585 | // the real pointing deviation of the telescope (note, that
|
---|
586 | // signs here are just conventions)
|
---|
587 | dev += ZdAz(devzd, devaz)*TMath::DegToRad(); // --> nom-mis
|
---|
588 | dev *= TMath::RadToDeg();
|
---|
589 | */
|
---|
590 |
|
---|
591 | // Check if the starguider pointing model requests overwriting
|
---|
592 | // of the values with constants (e.g. 0)
|
---|
593 | devaz = fPointing->IsPxValid() ? fPointing->GetPx() : dev.Az();
|
---|
594 | devzd = fPointing->IsPyValid() ? fPointing->GetPy() : dev.Zd();
|
---|
595 |
|
---|
596 | fDeviation->SetDevZdAz(devzd, devaz);
|
---|
597 | fDeviation->SetDevXY(fPointing->GetDxy());
|
---|
598 | }
|
---|
599 |
|
---|
600 | Int_t MPointingDevCalc::ProcessStarguiderReport()
|
---|
601 | {
|
---|
602 | Double_t devzd = fReport->GetDevZd(); // [arcmin]
|
---|
603 | Double_t devaz = fReport->GetDevAz(); // [arcmin]
|
---|
604 | if (devzd==0 && devaz==0)
|
---|
605 | {
|
---|
606 | Skip(1);
|
---|
607 | return kTRUE;
|
---|
608 | }
|
---|
609 |
|
---|
610 | if (!fReport->IsMonitoring())
|
---|
611 | {
|
---|
612 | Skip(2);
|
---|
613 | return kTRUE;
|
---|
614 | }
|
---|
615 |
|
---|
616 | devzd /= 60; // Convert from arcmin to deg
|
---|
617 | devaz /= 60; // Convert from arcmin to deg
|
---|
618 |
|
---|
619 | const Double_t nsb = fReport->GetSkyBrightness();
|
---|
620 | if (nsb>0)
|
---|
621 | {
|
---|
622 | if (nsb>fNsbMin && nsb<fNsbMax)
|
---|
623 | {
|
---|
624 | fNsbSum += nsb;
|
---|
625 | fNsbSq += nsb*nsb;
|
---|
626 | fNsbCount++;
|
---|
627 | }
|
---|
628 |
|
---|
629 | if (fNsbCount>0)
|
---|
630 | {
|
---|
631 | const Double_t sum = fNsbSum/fNsbCount;
|
---|
632 | const Double_t sq = fNsbSq /fNsbCount;
|
---|
633 |
|
---|
634 | const Double_t rms = fNsbLevel*TMath::Sqrt(sq - sum*sum);
|
---|
635 |
|
---|
636 | if (nsb<sum-rms || nsb>sum+rms)
|
---|
637 | {
|
---|
638 | Skip(3);
|
---|
639 | return kTRUE;
|
---|
640 | }
|
---|
641 | }
|
---|
642 |
|
---|
643 | if (fReport->GetNumIdentifiedStars()<fNumMinStars)
|
---|
644 | {
|
---|
645 | Skip(4);
|
---|
646 | return kTRUE;
|
---|
647 | }
|
---|
648 | }
|
---|
649 |
|
---|
650 | // >= 87751 (31.3.06 12:00)
|
---|
651 |
|
---|
652 | // Calculate absolute deviation
|
---|
653 | const Double_t dev = MAstro::GetDevAbs(fReport->GetNominalZd(), devzd, devaz);
|
---|
654 |
|
---|
655 | // Sanity check... larger deviation are strange and ignored
|
---|
656 | if (dev*60>fMaxAbsDev)
|
---|
657 | {
|
---|
658 | Skip(5);
|
---|
659 | return kTRUE;
|
---|
660 | }
|
---|
661 |
|
---|
662 | DoCalibration(devzd, devaz);
|
---|
663 |
|
---|
664 | fSkip[0]++;
|
---|
665 | fLastMjd = fReport->GetMjd();
|
---|
666 |
|
---|
667 | return kTRUE;
|
---|
668 | }
|
---|
669 |
|
---|
670 | // --------------------------------------------------------------------------
|
---|
671 | //
|
---|
672 | // See class description.
|
---|
673 | //
|
---|
674 | Int_t MPointingDevCalc::Process()
|
---|
675 | {
|
---|
676 | switch (fRunType)
|
---|
677 | {
|
---|
678 | case MRawRunHeader::kRTNone:
|
---|
679 | case MRawRunHeader::kRTData:
|
---|
680 | return fReport ? ProcessStarguiderReport() : kTRUE;
|
---|
681 |
|
---|
682 | case MRawRunHeader::kRTMonteCarlo:
|
---|
683 | fSkip[0]++;
|
---|
684 | fDeviation->SetDevZdAz(0, 0);
|
---|
685 | fDeviation->SetDevXY(0, 0);
|
---|
686 | return kTRUE;
|
---|
687 | }
|
---|
688 | return kTRUE;
|
---|
689 | }
|
---|
690 |
|
---|
691 | // --------------------------------------------------------------------------
|
---|
692 | //
|
---|
693 | // Print execution statistics
|
---|
694 | //
|
---|
695 | Int_t MPointingDevCalc::PostProcess()
|
---|
696 | {
|
---|
697 | if (GetNumExecutions()==0)
|
---|
698 | return kTRUE;
|
---|
699 |
|
---|
700 | *fLog << inf << endl;
|
---|
701 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
---|
702 | PrintSkipped(fSkip[1], "Starguider deviation not set, is exactly 0/0");
|
---|
703 | PrintSkipped(fSkip[2], "Starguider was not monitoring (eg. LEDs off)");
|
---|
704 | PrintSkipped(fSkip[3], Form("NSB out of %.1f sigma range", fNsbLevel));
|
---|
705 | PrintSkipped(fSkip[4], Form("Number of identified stars < %d", fNumMinStars));
|
---|
706 | PrintSkipped(fSkip[5], Form("Absolute deviation > %.1farcmin", fMaxAbsDev));
|
---|
707 | PrintSkipped(fSkip[6], Form("Events set to 0 because older than %.1fmin", fMaxAge));
|
---|
708 | *fLog << " " << (int)fSkip[0] << " (" << Form("%5.1f", 100.*fSkip[0]/GetNumExecutions()) << "%) Evts survived calculation!" << endl;
|
---|
709 | *fLog << endl;
|
---|
710 |
|
---|
711 | return kTRUE;
|
---|
712 | }
|
---|
713 |
|
---|
714 | // --------------------------------------------------------------------------
|
---|
715 | //
|
---|
716 | // MPointingDevCalc.NumMinStars: 8
|
---|
717 | // MPointingDevCalc.NsbLevel: 3.0
|
---|
718 | // MPointingDevCalc.NsbMin: 30
|
---|
719 | // MPointingDevCalc.NsbMax: 60
|
---|
720 | // MPointingDevCalc.MaxAbsDev: 15
|
---|
721 | // MPointingDevCalc.MaxAge: 1.0
|
---|
722 | // MPointingDevCalc.Dx: -0.001
|
---|
723 | // MPointingDevCalc.Dy: -0.004
|
---|
724 | //
|
---|
725 | // For a detailed description see the class reference.
|
---|
726 | //
|
---|
727 | Int_t MPointingDevCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
728 | {
|
---|
729 | Bool_t rc = kFALSE;
|
---|
730 | if (IsEnvDefined(env, prefix, "NumMinStars", print))
|
---|
731 | {
|
---|
732 | SetNumMinStars(GetEnvValue(env, prefix, "NumMinStars", (Int_t)fNumMinStars));
|
---|
733 | rc = kTRUE;
|
---|
734 | }
|
---|
735 | if (IsEnvDefined(env, prefix, "NsbLevel", print))
|
---|
736 | {
|
---|
737 | SetNsbLevel(GetEnvValue(env, prefix, "NsbLevel", fNsbLevel));
|
---|
738 | rc = kTRUE;
|
---|
739 | }
|
---|
740 | if (IsEnvDefined(env, prefix, "NsbMin", print))
|
---|
741 | {
|
---|
742 | SetNsbMin(GetEnvValue(env, prefix, "NsbMin", fNsbMin));
|
---|
743 | rc = kTRUE;
|
---|
744 | }
|
---|
745 | if (IsEnvDefined(env, prefix, "NsbMax", print))
|
---|
746 | {
|
---|
747 | SetNsbMax(GetEnvValue(env, prefix, "NsbMax", fNsbMax));
|
---|
748 | rc = kTRUE;
|
---|
749 | }
|
---|
750 | if (IsEnvDefined(env, prefix, "MaxAbsDev", print))
|
---|
751 | {
|
---|
752 | SetMaxAbsDev(GetEnvValue(env, prefix, "MaxAbsDev", fMaxAbsDev));
|
---|
753 | rc = kTRUE;
|
---|
754 | }
|
---|
755 | if (IsEnvDefined(env, prefix, "Dx", print))
|
---|
756 | {
|
---|
757 | fDx = GetEnvValue(env, prefix, "Dx", fDx);
|
---|
758 | rc = kTRUE;
|
---|
759 | }
|
---|
760 | if (IsEnvDefined(env, prefix, "Dy", print))
|
---|
761 | {
|
---|
762 | fDy = GetEnvValue(env, prefix, "Dy", fDy);
|
---|
763 | rc = kTRUE;
|
---|
764 | }
|
---|
765 | if (IsEnvDefined(env, prefix, "MaxAge", print))
|
---|
766 | {
|
---|
767 | fMaxAge = GetEnvValue(env, prefix, "MaxAge", fMaxAge);
|
---|
768 | rc = kTRUE;
|
---|
769 | }
|
---|
770 | if (IsEnvDefined(env, prefix, "FilePrefix", print))
|
---|
771 | {
|
---|
772 | fFilePrefix = GetEnvValue(env, prefix, "FilePrefix", fFilePrefix);
|
---|
773 | rc = kTRUE;
|
---|
774 | }
|
---|
775 | if (IsEnvDefined(env, prefix, "PointingModels", print))
|
---|
776 | {
|
---|
777 | SetPointingModels(GetEnvValue(env, prefix, "PointingModels", GetPointingModels()));
|
---|
778 | rc = kTRUE;
|
---|
779 | }
|
---|
780 |
|
---|
781 | return rc;
|
---|
782 | }
|
---|