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

Last change on this file since 13710 was 10066, checked in by tbretz, 14 years ago
Propagate the TPoint file name to the output in telesto.
File size: 4.8 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 /*
65 TVector3 v1, v2;
66 v1.SetMagThetaPhi(1, TMath::Pi()/2-fRawEl, fRawAz);
67 v2.SetMagThetaPhi(1, TMath::Pi()/2-fStarEl, fStarAz);
68
69 return v1.Angle(v2)*TMath::RadToDeg();
70 */
71
72 const Double_t del = fRawEl-fStarEl;
73 const Double_t daz = fRawAz-fStarAz;
74
75 /*
76 const Double_t dphi2 = daz/2.;
77 const Double_t cos2 = cos(dphi2)*cos(dphi2);
78 const Double_t sin2 = sin(dphi2)*sin(dphi2);
79 const Double_t d = cos(del)*cos2 - cos(fRawEl+fStarEl)*sin2;
80 */
81 const Double_t d = cos(del) - cos(fRawEl)*cos(fStarEl)*(1.-cos(daz));
82
83 if (err)
84 {
85 // Error of one pixel in the CCD
86 const Double_t e1 = 32./3600*TMath::DegToRad() * 0.5;
87
88 // Error of one SE unit
89 const Double_t e2 = 360./16384*TMath::DegToRad() * 0.5;
90
91 const Double_t e11 = sin(del)+cos(fRawEl)*sin(fStarEl)*(1-cos(daz));
92 const Double_t e12 = cos(fRawEl)*cos(fStarEl)*sin(daz);
93
94 const Double_t e21 = -sin(del)+sin(fRawEl)*cos(fStarEl)*(1-cos(daz));
95 const Double_t e22 = -cos(fRawEl)*cos(fStarEl)*sin(daz);
96
97 const Double_t err1 = sqrt(1-d*d);
98 const Double_t err2 = (e11*e11 + e12*e12)*e1*e1;
99 const Double_t err3 = (e21*e21 + e22*e22)*e2*e2;
100
101 *err = sqrt(err2+err3)/err1 * TMath::RadToDeg();
102 }
103
104 const Double_t dist = acos(d);
105 return dist * TMath::RadToDeg();
106 }
107
108istream &operator>>(istream &fin, TPointStar &set)
109{
110 TString str;
111 do
112 {
113 str.ReadLine(fin);
114 if (!fin)
115 return fin;
116 } while (str[0]=='#');
117
118 Float_t v[4], mag;
119 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);
120 if (n<4)
121 {
122 gLog << err << "Read: ERROR - Not enough numbers" << endl;
123 return fin;
124 }
125 set.fMag = n<5 ? -25 : mag;
126
127 set.fStarAz = v[0]*TMath::DegToRad();
128 set.fStarEl = v[1]*TMath::DegToRad();
129
130 set.fRawAz = v[2]*TMath::DegToRad();
131 set.fRawEl = v[3]*TMath::DegToRad();
132
133 if (fin)
134 {
135 Double_t res, err;
136 res = set.GetResidual(&err);
137 gLog << inf << "Read: " << v[0] << " " << v[1] << " : " << v[2] << " " << v[3] << " : " << v[2]-v[0] << " " << v[3]-v[1] << " : " << res << " " << err << " " << err/res << endl;
138 }
139
140 return fin;
141}
142
143ostream &operator<<(ostream &out, TPointStar &set)
144{
145 out << Form("%8.3f", set.fStarAz*TMath::RadToDeg()) << " ";
146 out << Form("%7.3f", set.fStarEl*TMath::RadToDeg()) << " ";
147 out << Form("%8.3f", set.fRawAz*TMath::RadToDeg()) << " ";
148 out << Form("%7.3f", set.fRawEl*TMath::RadToDeg()) << " ";
149 out << Form("%6.3f", set.fMag);
150
151 return out;
152}
Note: See TracBrowser for help on using the repository browser.