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

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