FACT++  1.0
TPointStar.cc
Go to the documentation of this file.
1 #include "TPointStar.h"
2 
3 #include <iostream>
4 #include <TMath.h>
5 
6 #include "MPointing.h"
7 
8 using namespace std;
9 
10 void TPointStar::Init(const char *name, const char *title)
11 {
12  fName = name ? name : "TPointStar";
13  fTitle = title ? title : "A set of TPoints";
14 }
15 
16 TPointStar::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 
25 Double_t TPointStar::GetDEl() const { return (fRawEl-fStarEl)*TMath::RadToDeg(); }
26 Double_t TPointStar::GetDZd() const { return -GetDEl(); }
27 Double_t TPointStar::GetDAz() const { return (fRawAz-fStarAz)*TMath::RadToDeg(); }
28 Double_t TPointStar::GetStarEl() const { return fStarEl*TMath::RadToDeg(); }
29 Double_t TPointStar::GetStarZd() const { return 90.-fStarEl*TMath::RadToDeg(); }
30 Double_t TPointStar::GetStarAz() const { return fStarAz*TMath::RadToDeg(); }
31 Double_t TPointStar::GetRawEl() const { return fRawEl*TMath::RadToDeg(); }
32 Double_t TPointStar::GetRawAz() const { return fRawAz*TMath::RadToDeg(); }
33 Double_t TPointStar::GetRawZd() const { return 90.-fRawEl*TMath::RadToDeg(); }
34 
35 ZdAz TPointStar::GetStarZdAz() const { return ZdAz(TMath::Pi()/2-fStarEl, fStarAz); }
37 
38 ZdAz TPointStar::GetRawZdAz() const { return ZdAz(TMath::Pi()/2-fRawEl, fRawAz); }
40 
41 void TPointStar::Adjust(const MPointing &bend)
42 {
43  AltAz p = bend(GetStarAltAz());
44  fStarEl = p.Alt();
45  fStarAz = p.Az();
46 }
47 
49 {
50  AltAz p = bend.CorrectBack(GetRawAltAz());
51  fRawEl = p.Alt();
52  fRawAz = p.Az();
53 }
54 
55 Double_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 
90 istream &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 
127 ostream &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 }
Double_t GetStarZd() const
Definition: TPointStar.cc:29
Double_t GetDAz() const
Definition: TPointStar.cc:27
friend std::ostream & operator<<(std::ostream &fout, TPointStar &set)
Definition: TPointStar.cc:127
Double_t fStarAz
Definition: TPointStar.h:18
Double_t fRawAz
Definition: TPointStar.h:21
double Alt() const
Definition: MPointing.h:40
char str[80]
Definition: test_client.c:7
Double_t GetDZd() const
Definition: TPointStar.cc:26
TPointStar(const char *name, const char *title=0)
Definition: TPointStar.h:28
float mag
Definition: HeadersSQM.h:89
void Init(const char *name=0, const char *title=0)
Definition: TPointStar.cc:10
Double_t GetResidual(Double_t *err=0) const
Definition: TPointStar.cc:55
ZdAz CorrectBack(const ZdAz &zdaz) const
Definition: MPointing.cc:726
STL namespace.
AltAz GetStarAltAz() const
Definition: TPointStar.cc:36
Double_t GetRawZd() const
Definition: TPointStar.cc:33
Double_t GetDEl() const
Definition: TPointStar.cc:25
Double_t fRawEl
Definition: TPointStar.h:22
AltAz GetRawAltAz() const
Definition: TPointStar.cc:39
ZdAz GetRawZdAz() const
Definition: TPointStar.cc:38
std::string Form(const char *fmt,...)
Definition: tools.cc:45
void Adjust(const MPointing &bend)
Definition: TPointStar.cc:41
Definition: MPointing.h:64
Double_t GetStarAz() const
Definition: TPointStar.cc:30
ZdAz GetStarZdAz() const
Definition: TPointStar.cc:35
Double_t GetRawAz() const
Definition: TPointStar.cc:32
Double_t GetStarEl() const
Definition: TPointStar.cc:28
double Az() const
Definition: MPointing.h:41
Double_t fStarEl
Definition: TPointStar.h:19
Double_t GetRawEl() const
Definition: TPointStar.cc:31
void AdjustBack(const MPointing &bend)
Definition: TPointStar.cc:48
friend std::istream & operator>>(std::istream &fin, TPointStar &set)
Definition: TPointStar.cc:90
Double_t fMag
Definition: TPointStar.h:24