source: branches/FACT++_lidctrl_new_eth/drive/TPointStar.cc@ 19893

Last change on this file since 19893 was 18629, checked in by tbretz, 8 years ago
Disentengle from root and Mars were appropriate, some tidying.
File size: 4.1 KB
Line 
1#include "TPointStar.h"
2
3#include <iostream>
4#include <TMath.h>
5
6#include "MPointing.h"
7
8using namespace std;
9
10void TPointStar::Init(const char *name, const char *title)
11{
12 fName = name ? name : "TPointStar";
13 fTitle = title ? title : "A set of TPoints";
14}
15
16TPointStar::TPointStar(Double_t sel, Double_t saz, Double_t rel, Double_t raz) :
17 fStarAz(saz*TMath::DegToRad()),
18 fStarEl(sel*TMath::DegToRad()),
19 fRawAz(raz*TMath::DegToRad()),
20 fRawEl(rel*TMath::DegToRad()), fMag(-25)
21{
22 Init();
23}
24
25Double_t TPointStar::GetDEl() const { return (fRawEl-fStarEl)*TMath::RadToDeg(); }
26Double_t TPointStar::GetDZd() const { return -GetDEl(); }
27Double_t TPointStar::GetDAz() const { return (fRawAz-fStarAz)*TMath::RadToDeg(); }
28Double_t TPointStar::GetStarEl() const { return fStarEl*TMath::RadToDeg(); }
29Double_t TPointStar::GetStarZd() const { return 90.-fStarEl*TMath::RadToDeg(); }
30Double_t TPointStar::GetStarAz() const { return fStarAz*TMath::RadToDeg(); }
31Double_t TPointStar::GetRawEl() const { return fRawEl*TMath::RadToDeg(); }
32Double_t TPointStar::GetRawAz() const { return fRawAz*TMath::RadToDeg(); }
33Double_t TPointStar::GetRawZd() const { return 90.-fRawEl*TMath::RadToDeg(); }
34
35ZdAz TPointStar::GetStarZdAz() const { return ZdAz(TMath::Pi()/2-fStarEl, fStarAz); }
36AltAz TPointStar::GetStarAltAz() const { return AltAz(fStarEl, fStarAz); }
37
38ZdAz TPointStar::GetRawZdAz() const { return ZdAz(TMath::Pi()/2-fRawEl, fRawAz); }
39AltAz TPointStar::GetRawAltAz() const { return AltAz(fRawEl, fRawAz); }
40
41void TPointStar::Adjust(const MPointing &bend)
42{
43 AltAz p = bend(GetStarAltAz());
44 fStarEl = p.Alt();
45 fStarAz = p.Az();
46}
47
48void TPointStar::AdjustBack(const MPointing &bend)
49{
50 AltAz p = bend.CorrectBack(GetRawAltAz());
51 fRawEl = p.Alt();
52 fRawAz = p.Az();
53}
54
55Double_t TPointStar::GetResidual(Double_t *err) const
56{
57 const Double_t del = fRawEl-fStarEl;
58 const Double_t daz = fRawAz-fStarAz;
59
60 const double x = cos(fRawEl) * cos(fStarEl) * cos(fStarAz-fRawAz);
61 const double y = sin(fRawEl) * sin(fStarEl);
62
63 const Double_t d = x + y;
64
65 if (err)
66 {
67 // Error of one pixel in the CCD
68 const Double_t e1 = 45./3600*TMath::DegToRad() /4 * 0.5;
69
70 // Error of the SE readout
71 const Double_t e2 = 360./16384*TMath::DegToRad()/4 * 0.5;
72
73 const Double_t e11 = sin(del)+cos(fRawEl)*sin(fStarEl)*(1-cos(daz));
74 const Double_t e12 = cos(fRawEl)*cos(fStarEl)*sin(daz);
75
76 const Double_t e21 = -sin(del)+sin(fRawEl)*cos(fStarEl)*(1-cos(daz));
77 const Double_t e22 = -cos(fRawEl)*cos(fStarEl)*sin(daz);
78
79 const Double_t err1 = sqrt(1-d*d);
80 const Double_t err2 = (e11*e11 + e12*e12)*e1*e1;
81 const Double_t err3 = (e21*e21 + e22*e22)*e2*e2;
82
83 *err = sqrt(err2+err3)/err1 * TMath::RadToDeg();
84 }
85
86 const Double_t dist = acos(d);
87 return dist * TMath::RadToDeg();
88}
89
90istream &operator>>(istream &fin, TPointStar &set)
91{
92 TString str;
93 do
94 {
95 str.ReadLine(fin);
96 if (!fin)
97 return fin;
98 } while (str[0]=='#');
99
100 Float_t v[4], mag;
101 Int_t n = sscanf(str.Data(), "%f %f %f %f %*f %*f %*f %*f %*f %*f %f", v, v+1, v+2, v+3, &mag);
102 if (n<4)
103 {
104 cout << "Read: ERROR - Not enough numbers" << endl;
105 return fin;
106 }
107 set.fMag = n<5 ? -25 : mag;
108
109 set.fStarAz = v[0]*TMath::DegToRad();
110 set.fStarEl = v[1]*TMath::DegToRad();
111
112 set.fRawAz = v[2]*TMath::DegToRad();
113 set.fRawEl = v[3]*TMath::DegToRad();
114
115
116
117 if (fin)
118 {
119 Double_t res, err;
120 res = set.GetResidual(&err);
121 cout << "Read: " << v[0] << " " << v[1] << " : " << v[2] << " " << v[3] << " : " << v[2]-v[0] << " " << v[3]-v[1] << " : " << res << " " << err << " " << err/res << endl;
122 }
123
124 return fin;
125}
126
127ostream &operator<<(ostream &out, TPointStar &set)
128{
129 out << Form("%8.3f", set.fStarAz*TMath::RadToDeg()) << " ";
130 out << Form("%7.3f", set.fStarEl*TMath::RadToDeg()) << " ";
131 out << Form("%8.3f", set.fRawAz*TMath::RadToDeg()) << " ";
132 out << Form("%7.3f", set.fRawEl*TMath::RadToDeg()) << " ";
133 out << Form("%6.3f", set.fMag);
134
135 return out;
136}
Note: See TracBrowser for help on using the repository browser.