source: trunk/Mars/mpointing/MPointing.h@ 10047

Last change on this file since 10047 was 8915, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 10.6 KB
Line 
1#ifndef MARS_MPointing
2#define MARS_MPointing
3
4#ifndef ROOT_TArrayD
5#include <TArrayD.h>
6#endif
7
8#ifndef ROOT_TVector2
9#include <TVector2.h>
10#endif
11
12#ifndef ROOT_TVector3
13#include <TVector3.h>
14#endif
15
16#ifndef MARS_MParContainer
17#include "MParContainer.h"
18#endif
19
20// ---------------------------------------------------
21
22#define XY TVector2
23
24inline TVector2 Div(const TVector2 &v1, const TVector2 &v2)
25{
26 return TVector2(v1.X()/v2.X(), v1.Y()/v2.Y());
27}
28inline TVector2 Mul(const TVector2 &v1, const TVector2 &v2)
29{
30 return TVector2(v1.X()*v2.X(), v1.Y()*v2.Y());
31}
32
33inline TVector2 operator-(const TVector2 &v) { return TVector2(-v.X(), -v.Y()); }
34
35class AltAz : public XY
36{
37public:
38 AltAz(double alt=0, double az=0) : XY(alt, az) {}
39
40 double Alt() const { return fX; }
41 double Az() const { return fY; }
42
43 void operator*=(double c) { fX*=c; fY*=c; }
44 void operator/=(double c) { fX*=c; fY*=c; }
45
46 void Alt(double d) { fX=d; }
47 void Az(double d) { fY=d; }
48 void operator*=(const XY &c) { fX*=c.X(); fY*=c.Y(); }
49 void operator/=(const XY &c) { fX/=c.X(); fY/=c.Y(); }
50 void operator-=(const AltAz &c) { fX-=c.fX; fY-=c.fY; }
51 void operator+=(const AltAz &c) { fX+=c.fX; fY+=c.fY; }
52
53 AltAz operator/(double c) const { return AltAz(fX/c, fY/c); }
54 AltAz operator*(double c) const { return AltAz(fX*c, fY*c); }
55 AltAz operator*(const XY &c) const { return AltAz(fX*c.X(), fY*c.Y()); }
56 AltAz operator/(const XY &c) const { return AltAz(fX/c.X(), fY/c.Y()); }
57 AltAz operator+(const AltAz &c) const { return AltAz(fX+c.fX, fY+c.fY); }
58 AltAz operator-(const AltAz &c) const { return AltAz(fX-c.fX, fY-c.fY); }
59 AltAz operator-() const { return AltAz(-fX, -fY); }
60
61 ClassDef(AltAz, 0)
62};
63
64class ZdAz : public XY
65{
66public:
67 ZdAz(double zd=0, double az=0) : XY(zd, az) {}
68 ZdAz(const ZdAz &c) : XY(c) {}
69
70 void operator*=(double c) { fX*=c; fY*=c; }
71 void operator/=(double c) { fX*=c; fY*=c; }
72
73 double Zd() const { return fX; }
74 double Az() const { return fY; }
75
76 void Zd(double d) { fX=d; }
77 void Az(double d) { fY=d; }
78 void operator*=(const XY &c) { fX*=c.X(); fY*=c.Y(); }
79 void operator/=(const XY &c) { fX/=c.X(); fY/=c.Y(); }
80 void operator-=(const ZdAz &c) { fX-=c.fX; fY-=c.fY; }
81 void operator+=(const ZdAz &c) { fX+=c.fX; fY+=c.fY; }
82
83 ZdAz operator/(double c) const { return ZdAz(fX/c, fY/c); }
84 ZdAz operator*(double c) const { return ZdAz(fX*c, fY*c); }
85 ZdAz operator*(const XY &c) const { return ZdAz(fX*c.X(), fY*c.Y()); }
86 ZdAz operator/(const XY &c) const { return ZdAz(fX/c.X(), fY/c.Y()); }
87 ZdAz operator+(const ZdAz &c) const { return ZdAz(fX+c.fX, fY+c.fY); }
88 ZdAz operator-(const ZdAz &c) const { return ZdAz(fX-c.fX, fY-c.fY); }
89 ZdAz operator-() const { return ZdAz(-fX, -fY); }
90
91 // MSlewing only?!?
92 double Ratio() const { return fX/fY; }
93 void Round();
94 void Abs();
95
96 ClassDef(ZdAz, 0)
97};
98
99class RaDec : public XY
100{
101public:
102 RaDec(double ra=0, double dec=0) : XY(ra, dec) {}
103
104 double Ra() const { return fX; }
105 double Dec() const { return fY; }
106
107 void operator*=(double c) { fX*=c; fY*=c; }
108 void operator/=(double c) { fX*=c; fY*=c; }
109
110 void Ra(double x) { fX = x; }
111 void Dec(double y) { fY = y; }
112
113 RaDec operator/(double c) const { return RaDec(fX/c, fY/c); }
114 RaDec operator*(double c) const { return RaDec(fX*c, fY*c); }
115 RaDec operator*(const XY &c) const { return RaDec(fX*c.X(), fY*c.Y()); }
116 RaDec operator+(const RaDec &c) const { return RaDec(fX+c.fX, fY+c.fY); }
117 RaDec operator-(const RaDec &c) const { return RaDec(fX-c.fX, fY-c.fY); }
118 RaDec operator-() const { return RaDec(-fX, -fY); }
119
120 ClassDef(RaDec, 0)
121};
122
123// ---------------------------------------------------
124
125class TMinuit;
126
127class MPointing : public MParContainer
128{
129private:
130 enum {
131 kIA, // [rad] Index Error in Elevation
132 kIE, // [rad] Index Error in Azimuth
133 kFLOP, // [rad] Vertical Sag
134 kAN, // [rad] Az-El Nonperpendicularity
135 kAW, // [rad] Left-Right Collimation Error
136 kNPAE, // [rad] Azimuth Axis Misalignment (N-S)
137 kCA, // [rad] Azimuth Axis Misalignment (E-W)
138 kTF, // [rad] Tube fluxture (sin)
139 kTX, // [rad] Tube fluxture (tan)
140 kECES, // [rad] Nasmyth rotator displacement, horizontal
141 kACES, // [rad] Nasmyth rotator displacement, vertical
142 kECEC, // [rad] Alt/Az Coude Displacement (N-S)
143 kACEC, // [rad] Alt/Az Coude Displacement (E-W)
144 kNRX, // [rad] Elevation Centering Error (sin)
145 kNRY, // [rad] Azimuth Centering Error (sin)
146 kCRX, // [rad] Elevation Centering Error (cos)
147 kCRY, // [rad] Azimuth Centering Error (cos)
148 kMAGIC1, // [rad] Magic Term (what is it?)
149 kMAGIC2, // [rad] Magic Term (what is it?)
150 kPX, // [rad] Starguider calibration fixed offset x
151 kPY, // [rad] Starguider calibration fixed offset y
152 kDX, // [rad] Starguider calibration additional offset dx
153 kDY, // [rad] Starguider calibration additional offset dy
154 kNumPar // Number of elements
155 };
156
157
158 Double_t fIe ; // [rad] Index Error in Elevation
159 Double_t fIa ; // [rad] Index Error in Azimuth
160 Double_t fFlop ; // [rad] Vertical Sag
161 Double_t fNpae ; // [rad] Az-El Nonperpendicularity
162 Double_t fCa ; // [rad] Left-Right Collimation Error
163 Double_t fAn ; // [rad] Azimuth Axis Misalignment (N-S)
164 Double_t fAw ; // [rad] Azimuth Axis Misalignment (E-W)
165 Double_t fTf ; // [rad] Tube fluxture (sin)
166 Double_t fTx ; // [rad] Tube fluxture (tan)
167 Double_t fNrx ; // [rad] Nasmyth rotator displacement, horizontal
168 Double_t fNry ; // [rad] Nasmyth rotator displacement, vertical
169 Double_t fCrx ; // [rad] Alt/Az Coude Displacement (N-S)
170 Double_t fCry ; // [rad] Alt/Az Coude Displacement (E-W)
171 Double_t fEces ; // [rad] Elevation Centering Error (sin)
172 Double_t fAces ; // [rad] Azimuth Centering Error (sin)
173 Double_t fEcec ; // [rad] Elevation Centering Error (cos)
174 Double_t fAcec ; // [rad] Azimuth Centering Error (cos)
175 Double_t fMagic1; // [rad] Magic Term (what is it?)
176 Double_t fMagic2; // [rad] Magic Term (what is it?)
177
178 Double_t fPx; // [rad] Starguider calibration fixed offset x
179 Double_t fPy; // [rad] Starguider calibration fixed offset y
180 Double_t fDx; // [rad] Starguider calibration additional offset dx
181 Double_t fDy; // [rad] Starguider calibration additional offset dy
182
183 Double_t **fCoeff; //!
184 TString *fNames; //!
185 TString *fDescr; //!
186
187 TArrayD fError;
188
189 void Init(const char *name=0, const char *title=0);
190
191 void Clear(Option_t *o="")
192 {
193 for (int i=0; i<kNumPar; i++)
194 {
195 *fCoeff[i] = 0;
196 fError[i] = -1;
197 }
198 }
199
200 static Double_t Sign(Double_t val, Double_t alt);
201 AltAz CalcAnAw(const AltAz &p, Int_t sign) const;
202
203public:
204 MPointing() : fError(kNumPar) { Init(); Clear(); }
205 MPointing(const char *name) : fError(kNumPar) { Init(); Clear(); Load(name); }
206 virtual ~MPointing() { delete [] fNames; delete [] fCoeff; delete [] fDescr; }
207
208 Bool_t Load(const char *name);
209 Bool_t Save(const char *name);
210
211 void Reset();
212
213 ZdAz Correct(const ZdAz &zdaz) const;
214 AltAz Correct(const AltAz &aaz) const;
215 TVector3 Correct(const TVector3 &v) const;
216
217 ZdAz CorrectBack(const ZdAz &zdaz) const;
218 AltAz CorrectBack(const AltAz &aaz) const;
219 TVector3 CorrectBack(const TVector3 &v) const;
220
221 ZdAz operator()(const ZdAz &zdaz) const { return Correct(zdaz); }
222 AltAz operator()(const AltAz &aaz) const { return Correct(aaz); }
223 TVector3 operator()(const TVector3 &v) const { return Correct(v); }
224
225 ZdAz operator()(const ZdAz &zdaz, void (*fcn)(ZdAz &zdaz, Double_t *par)) const
226 {
227 Double_t par[kNumPar];
228 GetParameters(par);
229 ZdAz za = zdaz;
230 fcn(za, par);
231 return za;
232 }
233
234 AltAz operator()(const AltAz &aaz, void (*fcn)(AltAz &aaz, Double_t *par)) const
235 {
236 Double_t par[kNumPar];
237 GetParameters(par);
238 AltAz aa = aaz;
239 fcn(aa, par);
240 return aa;
241 }
242
243 TVector3 operator()(const TVector3 &aaz, void (*fcn)(TVector3 &aaz, Double_t *par)) const
244 {
245 Double_t par[kNumPar];
246 GetParameters(par);
247 TVector3 v = aaz;
248 fcn(v, par);
249 return v;
250 }
251
252 AltAz AddOffsets(const AltAz &aa) const;
253 ZdAz AddOffsets(const ZdAz &zdaz) const;
254 TVector3 AddOffsets(const TVector3 &v) const;
255
256 AltAz SubtractOffsets(const AltAz &aa) const;
257 ZdAz SubtractOffsets(const ZdAz &zdaz) const;
258 TVector3 SubtractOffsets(const TVector3 &v) const;
259
260 void SetParameters(const Double_t *par, Int_t n=kNumPar);
261 void GetParameters(Double_t *par, Int_t n=kNumPar) const;
262
263 void SetParameters(const TArrayD &par)
264 {
265 SetParameters(par.GetArray(), par.GetSize());
266 }
267 void GetParameters(TArrayD &par) const
268 {
269 par.Set(kNumPar);
270 GetParameters(par.GetArray());
271 }
272 void GetError(TArrayD &par) const;
273
274 Double_t &operator[](UInt_t i) { return *fCoeff[i]; }
275
276 void SetMinuitParameters(TMinuit &m, Int_t n=-1) const;
277 void GetMinuitParameters(TMinuit &m, Int_t n=-1);
278 void PrintMinuitParameters(TMinuit &m, Int_t n=-1) const;
279
280 const TString &GetVarName(int i) const { return fNames[i]; }
281 const TString &GetDescription(int i) const { return fDescr[i]; }
282
283 /*
284 Double_t GetIe() const { return fIe; }
285 Double_t GetIa() const { return fIa; }
286 Double_t GetCa() const { return fCa; }
287 Double_t GetAn() const { return fAn; }
288 Double_t GetAw() const { return fAw; }
289 Double_t GetNrx() const { return fNrx; }
290 Double_t GetNry() const { return fNry; }
291 Double_t GetCrx() const { return fNrx; }
292 Double_t GetCry() const { return fNry; }
293 Double_t GetEces() const { return fEces; }
294 Double_t GetEcec() const { return fEcec; }
295 Double_t GetAces() const { return fAces; }
296 Double_t GetAcec() const { return fAcec; }
297 Double_t GetNpae() const { return fNpae; }
298 */
299
300 TVector2 GetDxy() const;// { return TVector2(fDx, fDy)*TMath::RadToDeg(); }
301
302 Double_t GetPx() const;// { return fPx*TMath::RadToDeg(); }
303 Double_t GetPy() const;// { return fPy*TMath::RadToDeg(); }
304
305 Bool_t IsPxValid() const { return fError[kPX]>0; }
306 Bool_t IsPyValid() const { return fError[kPY]>0; }
307
308 static const Int_t GetNumPar() { return kNumPar; }
309
310 ClassDef(MPointing, 2) // Pointing Model for MAGIC
311};
312
313#endif
Note: See TracBrowser for help on using the repository browser.