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

Last change on this file since 6965 was 4966, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 6.5 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_TVector3
9#include <TVector3.h>
10#endif
11
12#ifndef MARS_MParContainer
13#include "MParContainer.h"
14#endif
15
16// ---------------------------------------------------
17// FIXME: Replace coord.h completely with this!
18#ifndef __MARS__
19#include "coord.h"
20#else
21#include <TVector2.h>
22class AltAz : public TVector2
23{
24public:
25 AltAz(Double_t alt, Double_t az) : TVector2(alt, az)
26 {
27 }
28 Double_t Alt() const { return fX; }
29 Double_t Az() const { return fY; }
30 ClassDef(AltAz, 1)
31};
32
33class ZdAz : public TVector2
34{
35public:
36 ZdAz(Double_t zd, Double_t az) : TVector2(zd, az)
37 {
38 }
39 Double_t Zd() const { return fX; }
40 Double_t Az() const { return fY; }
41 ClassDef(ZdAz, 1)
42};
43#endif
44// ---------------------------------------------------
45
46class TMinuit;
47
48class MPointing : public MParContainer
49{
50private:
51 static const Int_t fNumPar;
52
53 Double_t fIe ; // [rad] Index Error in Elevation
54 Double_t fIa ; // [rad] Index Error in Azimuth
55 Double_t fFlop ; // [rad] Vertical Sag
56 Double_t fNpae ; // [rad] Az-El Nonperpendicularity
57 Double_t fCa ; // [rad] Left-Right Collimation Error
58 Double_t fAn ; // [rad] Azimuth Axis Misalignment (N-S)
59 Double_t fAw ; // [rad] Azimuth Axis Misalignment (E-W)
60 Double_t fTf ; // [rad] Tube fluxture (sin)
61 Double_t fTx ; // [rad] Tube fluxture (tan)
62 Double_t fNrx ; // [rad] Nasmyth rotator displacement, horizontal
63 Double_t fNry ; // [rad] Nasmyth rotator displacement, vertical
64 Double_t fCrx ; // [rad] Alt/Az Coude Displacement (N-S)
65 Double_t fCry ; // [rad] Alt/Az Coude Displacement (E-W)
66 Double_t fEces ; // [rad] Elevation Centering Error (sin)
67 Double_t fAces ; // [rad] Azimuth Centering Error (sin)
68 Double_t fEcec ; // [rad] Elevation Centering Error (cos)
69 Double_t fAcec ; // [rad] Azimuth Centering Error (cos)
70 Double_t fMagic1; // [rad] Magic Term (what is it?)
71 Double_t fMagic2; // [rad] Magic Term (what is it?)
72
73 Double_t **fCoeff; //!
74 TString *fNames; //!
75 TString *fDescr; //!
76
77 TArrayD fError;
78
79 void Init(const char *name=0, const char *title=0);
80
81 void Clear(Option_t *o="")
82 {
83 for (int i=0; i<fNumPar; i++)
84 {
85 *fCoeff[i] = 0;
86 fError[i] = 0;
87 }
88 }
89
90 static Double_t Sign(Double_t val, Double_t alt);
91 AltAz CalcAnAw(const AltAz &p, Int_t sign) const;
92
93public:
94 MPointing() { fError.Set(fNumPar); Init(); Clear(); }
95 MPointing(const char *name) { fError.Set(fNumPar); Init(); Clear(); Load(name); }
96 virtual ~MPointing() { delete fNames; delete fCoeff; delete fDescr; }
97
98 void Load(const char *name);
99 void Save(const char *name);
100
101 void Reset();
102
103 ZdAz Correct(const ZdAz &zdaz) const;
104 AltAz Correct(const AltAz &aaz) const;
105 TVector3 Correct(const TVector3 &v) const;
106
107 ZdAz CorrectBack(const ZdAz &zdaz) const;
108 AltAz CorrectBack(const AltAz &aaz) const;
109 TVector3 CorrectBack(const TVector3 &v) const;
110
111 ZdAz operator()(const ZdAz &zdaz) const { return Correct(zdaz); }
112 AltAz operator()(const AltAz &aaz) const { return Correct(aaz); }
113 TVector3 operator()(const TVector3 &v) const { return Correct(v); }
114
115 ZdAz operator()(const ZdAz &zdaz, void (*fcn)(ZdAz &zdaz, Double_t *par)) const
116 {
117 Double_t par[fNumPar];
118 GetParameters(par);
119 ZdAz za = zdaz;
120 fcn(za, par);
121 return za;
122 }
123
124 AltAz operator()(const AltAz &aaz, void (*fcn)(AltAz &aaz, Double_t *par)) const
125 {
126 Double_t par[fNumPar];
127 GetParameters(par);
128 AltAz aa = aaz;
129 fcn(aa, par);
130 return aa;
131 }
132
133 TVector3 operator()(const TVector3 &aaz, void (*fcn)(TVector3 &aaz, Double_t *par)) const
134 {
135 Double_t par[fNumPar];
136 GetParameters(par);
137 TVector3 v = aaz;
138 fcn(v, par);
139 return v;
140 }
141
142 AltAz AddOffsets(const AltAz &aa) const;
143 ZdAz AddOffsets(const ZdAz &zdaz) const
144 {
145 AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
146 AltAz c = AddOffsets(p);
147 return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
148 }
149 TVector3 AddOffsets(const TVector3 &v) const
150 {
151 AltAz p(TMath::Pi()/2-v.Theta(), v.Phi());
152 AltAz c = AddOffsets(p);
153 TVector3 rc;
154 rc.SetMagThetaPhi(1, TMath::Pi()/2-c.Alt(), c.Az());
155 return rc;
156 }
157
158 AltAz SubtractOffsets(const AltAz &aa) const;
159 ZdAz SubtractOffsets(const ZdAz &zdaz) const
160 {
161 AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
162 AltAz c = SubtractOffsets(p);
163 return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
164 }
165 TVector3 SubtractOffsets(const TVector3 &v) const
166 {
167 AltAz p(TMath::Pi()/2-v.Theta(), v.Phi());
168 AltAz c = SubtractOffsets(p);
169 TVector3 rc;
170 rc.SetMagThetaPhi(1, TMath::Pi()/2-c.Alt(), c.Az());
171 return rc;
172 }
173
174 void SetParameters(const Double_t *par, Int_t n=fNumPar);
175 void GetParameters(Double_t *par, Int_t n=fNumPar) const;
176
177 void SetParameters(const TArrayD &par)
178 {
179 SetParameters(par.GetArray(), par.GetSize());
180 }
181 void GetParameters(TArrayD &par) const
182 {
183 par.Set(fNumPar);
184 GetParameters(par.GetArray());
185 }
186 void GetError(TArrayD &par) const
187 {
188 par = fError;
189 for (int i=0; i<fNumPar; i++)
190 par[i] *= TMath::RadToDeg();
191 }
192
193 void SetMinuitParameters(TMinuit &m, Int_t n=-1) const;
194 void GetMinuitParameters(TMinuit &m, Int_t n=-1);
195 void PrintMinuitParameters(TMinuit &m, Int_t n=-1) const;
196
197 const TString &GetVarName(int i) const { return fNames[i]; }
198 const TString &GetDescription(int i) const { return fDescr[i]; }
199
200 /*
201 Double_t GetIe() const { return fIe; }
202 Double_t GetIa() const { return fIa; }
203 Double_t GetCa() const { return fCa; }
204 Double_t GetAn() const { return fAn; }
205 Double_t GetAw() const { return fAw; }
206 Double_t GetNrx() const { return fNrx; }
207 Double_t GetNry() const { return fNry; }
208 Double_t GetCrx() const { return fNrx; }
209 Double_t GetCry() const { return fNry; }
210 Double_t GetEces() const { return fEces; }
211 Double_t GetEcec() const { return fEcec; }
212 Double_t GetAces() const { return fAces; }
213 Double_t GetAcec() const { return fAcec; }
214 Double_t GetNpae() const { return fNpae; }
215 */
216
217 static const Int_t GetNumPar() { return fNumPar; }
218
219 ClassDef(MPointing, 1) // Pointing Model for MAGIC
220};
221
222#endif
Note: See TracBrowser for help on using the repository browser.