source: trunk/Cosy/tpoint/TPointStar.cc@ 17689

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