source: trunk/MagicSoft/Mars/mpointing/MPointing.h@ 8801

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