1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MBending
|
---|
28 | //
|
---|
29 | // Double_t fIe ; // [rad] Index Error in Elevation
|
---|
30 | // Double_t fIa ; // [rad] Index Error in Azimuth
|
---|
31 | //
|
---|
32 | // Double_t fFlop ; // [rad] Vertical Sag
|
---|
33 | // * do not use if not data: Zd<0
|
---|
34 | //
|
---|
35 | // Double_t fNpae ; // [rad] Az-El Nonperpendicularity
|
---|
36 | //
|
---|
37 | // Double_t fCa ; // [rad] Left-Right Collimation Error
|
---|
38 | //
|
---|
39 | // Double_t fAn ; // [rad] Azimuth Axis Misalignment (N-S)
|
---|
40 | // Double_t fAw ; // [rad] Azimuth Axis Misalignment (E-W)
|
---|
41 | //
|
---|
42 | // Double_t fTf ; // [rad] Tube fluxture (sin)
|
---|
43 | // * same as ecec if no data: Zd<0
|
---|
44 | // Double_t fTx ; // [rad] Tube fluxture (tan)
|
---|
45 | // * do not use with NPAE if no data: Zd<0
|
---|
46 | //
|
---|
47 | // Double_t fNrx ; // [rad] Nasmyth rotator displacement, horizontan
|
---|
48 | // Double_t fNry ; // [rad] Nasmyth rotator displacement, vertical
|
---|
49 | //
|
---|
50 | // Double_t fCrx ; // [rad] Alt/Az Coude Displacement (N-S)
|
---|
51 | // Double_t fCry ; // [rad] Alt/Az Coude Displacement (E-W)
|
---|
52 | //
|
---|
53 | // Double_t fEces ; // [rad] Elevation Centering Error (sin)
|
---|
54 | // Double_t fAces ; // [rad] Azimuth Centering Error (sin)
|
---|
55 | // Double_t fEcec ; // [rad] Elevation Centering Error (cos)
|
---|
56 | // Double_t fAcec ; // [rad] Azimuth Centering Error (cos)
|
---|
57 | //
|
---|
58 | ////////////////////////////////////////////////////////////////////////////
|
---|
59 | #include "MBending.h"
|
---|
60 |
|
---|
61 | #include <fstream.h>
|
---|
62 | #include <iomanip.h>
|
---|
63 | #include <TVector3.h>
|
---|
64 |
|
---|
65 | #include <TMinuit.h>
|
---|
66 |
|
---|
67 | #include "MTime.h"
|
---|
68 |
|
---|
69 | ClassImp(MBending);
|
---|
70 |
|
---|
71 | #undef DEBUG
|
---|
72 | //#define DEBUG(txt) txt
|
---|
73 | #define DEBUG(txt)
|
---|
74 |
|
---|
75 | const Int_t MBending::fNumPar=19;
|
---|
76 |
|
---|
77 | void MBending::Init()
|
---|
78 | {
|
---|
79 | fCoeff = new Double_t*[fNumPar];
|
---|
80 | fName = new TString[fNumPar];
|
---|
81 | fDescr = new TString[fNumPar];
|
---|
82 |
|
---|
83 | fCoeff[ 0] = &fIa; fName[ 0] = "IA";
|
---|
84 | fCoeff[ 1] = &fIe; fName[ 1] = "IE";
|
---|
85 | fCoeff[ 2] = &fFlop; fName[ 2] = "FLOP";
|
---|
86 | fCoeff[ 3] = &fAn; fName[ 3] = "AN";
|
---|
87 | fCoeff[ 4] = &fAw; fName[ 4] = "AW";
|
---|
88 | fCoeff[ 5] = &fNpae; fName[ 5] = "NPAE";
|
---|
89 | fCoeff[ 6] = &fCa; fName[ 6] = "CA";
|
---|
90 | fCoeff[ 7] = &fTf; fName[ 7] = "TF";
|
---|
91 | fCoeff[ 8] = &fTx; fName[ 8] = "TX";
|
---|
92 | fCoeff[ 9] = &fEces; fName[ 9] = "ECES";
|
---|
93 | fCoeff[10] = &fAces; fName[10] = "ACES";
|
---|
94 | fCoeff[11] = &fEcec; fName[11] = "ECEC";
|
---|
95 | fCoeff[12] = &fAcec; fName[12] = "ACEC";
|
---|
96 | fCoeff[13] = &fNrx; fName[13] = "NRX";
|
---|
97 | fCoeff[14] = &fNry; fName[14] = "NRY";
|
---|
98 | fCoeff[15] = &fCrx; fName[15] = "CRX";
|
---|
99 | fCoeff[16] = &fCry; fName[16] = "CRY";
|
---|
100 | fCoeff[17] = &fMagic1; fName[17] = "MAGIC1";
|
---|
101 | fCoeff[18] = &fMagic2; fName[18] = "MAGIC2";
|
---|
102 |
|
---|
103 | fDescr[ 0] = "Index Error Azimuth";
|
---|
104 | fDescr[ 1] = "Index Error Zenith Distance";
|
---|
105 | fDescr[ 2] = "Vertical Sag";
|
---|
106 | fDescr[ 3] = "Azimuth Axis Misalignment (N-S)";
|
---|
107 | fDescr[ 4] = "Azimuth Axis Misalignment (E-W)";
|
---|
108 | fDescr[ 5] = "Az-El Nonperpendicularity";
|
---|
109 | fDescr[ 6] = "Left-Right Collimation Error";
|
---|
110 | fDescr[ 7] = "Tube fluxture (sin)";
|
---|
111 | fDescr[ 8] = "Tube fluxture (tan)";
|
---|
112 | fDescr[ 9] = "Elevation Centering Error (sin)";
|
---|
113 | fDescr[10] = "Azimuth Centering Error (sin)";
|
---|
114 | fDescr[11] = "Elevation Centering Error (cos)";
|
---|
115 | fDescr[12] = "Azimuth Centering Error (cos)";
|
---|
116 | fDescr[13] = "Nasmyth rotator displacement (horizontal)";
|
---|
117 | fDescr[14] = "Nasmyth rotator displacement (vertical)";
|
---|
118 | fDescr[15] = "Alt/Az Coude Displacement (N-S)";
|
---|
119 | fDescr[16] = "Alt/Az Coude Displacement (E-W)";
|
---|
120 | fDescr[17] = "n/a";
|
---|
121 | fDescr[18] = "n/a";
|
---|
122 | }
|
---|
123 | void MBending::Reset()
|
---|
124 | {
|
---|
125 | Clear();
|
---|
126 | }
|
---|
127 |
|
---|
128 | void MBending::Load(const char *name)
|
---|
129 | {
|
---|
130 | /*
|
---|
131 | ! MMT 1987 July 8
|
---|
132 | ! T 36 7.3622 41.448 -0.0481
|
---|
133 | ! IA -37.5465 20.80602
|
---|
134 | ! IE -13.9180 1.25217
|
---|
135 | ! NPAE +7.0751 26.44763
|
---|
136 | ! CA -6.9149 32.05358
|
---|
137 | ! AN +0.5053 1.40956
|
---|
138 | ! AW -2.2016 1.37480
|
---|
139 | ! END
|
---|
140 | */
|
---|
141 |
|
---|
142 | ifstream fin(name);
|
---|
143 | if (!fin)
|
---|
144 | {
|
---|
145 | cout << "Error: Cannot open file '" << name << "'" << endl;
|
---|
146 | return;
|
---|
147 | }
|
---|
148 |
|
---|
149 | char c;
|
---|
150 | while (fin && fin.get()!='\n');
|
---|
151 | fin >> c;
|
---|
152 |
|
---|
153 | if (c!='S' && c!='s')
|
---|
154 | {
|
---|
155 | cout << "Error: This in not a model correcting the star position (" << c << ")" << endl;
|
---|
156 | return;
|
---|
157 | }
|
---|
158 |
|
---|
159 | Clear();
|
---|
160 |
|
---|
161 | cout << endl;
|
---|
162 |
|
---|
163 | Double_t val;
|
---|
164 | fin >> val;
|
---|
165 | cout << "Number of observed stars: " << val << endl;
|
---|
166 | fin >> val;
|
---|
167 | cout << "Sky RMS: " << val << "\"" << endl;
|
---|
168 | fin >> val;
|
---|
169 | cout << "Refraction Constant A: " << val << "\"" << endl;
|
---|
170 | fin >> val;
|
---|
171 | cout << "Refraction Constant B: " << val << "\"" << endl;
|
---|
172 |
|
---|
173 | cout << endl;
|
---|
174 |
|
---|
175 | cout << " & = Name Value Sigma" << endl;
|
---|
176 | cout << "--------------------------------------------------" << endl;
|
---|
177 |
|
---|
178 | while (fin)
|
---|
179 | {
|
---|
180 | TString str;
|
---|
181 | fin >> str;
|
---|
182 |
|
---|
183 | if (str=="END")
|
---|
184 | break;
|
---|
185 |
|
---|
186 | if (str[0]=='&')
|
---|
187 | {
|
---|
188 | cout << " & ";
|
---|
189 | str.Remove(0);
|
---|
190 | }
|
---|
191 | else
|
---|
192 | cout << " ";
|
---|
193 |
|
---|
194 | if (str[1]=='=')
|
---|
195 | {
|
---|
196 | cout << "= ";
|
---|
197 | str.Remove(0);
|
---|
198 | }
|
---|
199 | else
|
---|
200 | cout << " ";
|
---|
201 |
|
---|
202 | fin >> val;
|
---|
203 | cout << str << "\t" << setw(11) << val << "° \t";
|
---|
204 | val *= kDeg2Rad;
|
---|
205 |
|
---|
206 | Double_t *dest=NULL;
|
---|
207 |
|
---|
208 | if (str=="IA") dest = &fIa;
|
---|
209 | if (str=="IE") dest = &fIe;
|
---|
210 | if (str=="FLOP") dest = &fFlop;
|
---|
211 | if (str=="NPAE") dest = &fNpae;
|
---|
212 | if (str=="CA") dest = &fCa;
|
---|
213 | if (str=="AN") dest = &fAn;
|
---|
214 | if (str=="AW") dest = &fAw;
|
---|
215 | if (str=="TF") dest = &fTf;
|
---|
216 | if (str=="TX") dest = &fTx;
|
---|
217 | if (str=="NRX") dest = &fNrx;
|
---|
218 | if (str=="NRY") dest = &fNry;
|
---|
219 | if (str=="CRX") dest = &fCrx;
|
---|
220 | if (str=="CRY") dest = &fCry;
|
---|
221 | if (str=="ECES") dest = &fEces;
|
---|
222 | if (str=="ACES") dest = &fAces;
|
---|
223 | if (str=="ECEC") dest = &fEcec;
|
---|
224 | if (str=="ACEC") dest = &fAcec;
|
---|
225 |
|
---|
226 | if (dest)
|
---|
227 | *dest = val;
|
---|
228 |
|
---|
229 | fin >> val;
|
---|
230 | cout << setw(9) << val << "°" << endl;
|
---|
231 |
|
---|
232 | // Find corresponding error
|
---|
233 | for (int i=0; i<MBending::GetNumPar(); i++)
|
---|
234 | if (dest==fCoeff[i])
|
---|
235 | {
|
---|
236 | fError[i] = val*kDeg2Rad;
|
---|
237 | break;
|
---|
238 | }
|
---|
239 | }
|
---|
240 | cout << endl;
|
---|
241 | }
|
---|
242 |
|
---|
243 | void MBending::Save(const char *name)
|
---|
244 | {
|
---|
245 | /*
|
---|
246 | ! MMT 1987 July 8
|
---|
247 | ! T 36 7.3622 41.448 -0.0481
|
---|
248 | ! IA -37.5465 20.80602
|
---|
249 | ! IE -13.9180 1.25217
|
---|
250 | ! NPAE +7.0751 26.44763
|
---|
251 | ! CA -6.9149 32.05358
|
---|
252 | ! AN +0.5053 1.40956
|
---|
253 | ! AW -2.2016 1.37480
|
---|
254 | ! END
|
---|
255 | */
|
---|
256 |
|
---|
257 | ofstream fout(name);
|
---|
258 | if (!fout)
|
---|
259 | {
|
---|
260 | cout << "Error: Cannot open file '" << name << "'" << endl;
|
---|
261 | return;
|
---|
262 | }
|
---|
263 |
|
---|
264 | MTime t;
|
---|
265 | t.Now();
|
---|
266 |
|
---|
267 | fout << "MAGIC1 " << t << endl;
|
---|
268 | fout << "S 00 000000 000000 0000000" << endl;
|
---|
269 | fout << setprecision(8);
|
---|
270 | for (int i=0; i<fNumPar; i++)
|
---|
271 | {
|
---|
272 | fout << " " << setw(6) << GetName(i) << " ";
|
---|
273 | fout << setw(13) << *fCoeff[i]*kRad2Deg << " ";
|
---|
274 | fout << setw(11) << fError[i]*kRad2Deg << endl;
|
---|
275 | }
|
---|
276 | fout << "END" << endl;
|
---|
277 | }
|
---|
278 |
|
---|
279 | Double_t MBending::Sign(Double_t val, Double_t alt)
|
---|
280 | {
|
---|
281 | // Some pointing corrections are defined as Delta ZA, which
|
---|
282 | // is (P. Wallace) defined [0,90]deg while Alt is defined
|
---|
283 | // [0,180]deg
|
---|
284 | return (TMath::Pi()/2-alt < 0 ? -val : val);
|
---|
285 | }
|
---|
286 |
|
---|
287 | AltAz MBending::AddOffsets(const AltAz &aa) const
|
---|
288 | {
|
---|
289 | // Correct [rad]
|
---|
290 | // zdaz [rad]
|
---|
291 | AltAz p = aa;
|
---|
292 |
|
---|
293 | const AltAz I(fIe, fIa);
|
---|
294 | p += I;
|
---|
295 |
|
---|
296 | return p;
|
---|
297 | }
|
---|
298 |
|
---|
299 | AltAz MBending::SubtractOffsets(const AltAz &aa) const
|
---|
300 | {
|
---|
301 | // Correct [rad]
|
---|
302 | // zdaz [rad]
|
---|
303 | AltAz p = aa;
|
---|
304 |
|
---|
305 | const AltAz I(fIe, fIa);
|
---|
306 | p -= I;
|
---|
307 |
|
---|
308 | return p;
|
---|
309 | }
|
---|
310 |
|
---|
311 | AltAz MBending::CalcAnAw(const AltAz &p, Int_t sign) const
|
---|
312 | {
|
---|
313 | // Corrections for AN and AW without approximations
|
---|
314 | // as done by Patrick Wallace. The approximation cannot
|
---|
315 | // be used for MAGIC because the correctioon angle
|
---|
316 | // AW (~1.5deg) is not small enough.
|
---|
317 |
|
---|
318 | // Vector in cartesian coordinates
|
---|
319 | TVector3 v(1., 1., 1.);
|
---|
320 |
|
---|
321 | // Set Azimuth and Elevation
|
---|
322 | v.SetPhi(p.Az());
|
---|
323 | v.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
324 |
|
---|
325 | // Rotate around the x- and y-axis
|
---|
326 | v.RotateY(sign*fAn);
|
---|
327 | v.RotateX(sign*fAw);
|
---|
328 |
|
---|
329 | // Calculate Delta Azimuth and Delta Elevation
|
---|
330 | AltAz d(TMath::Pi()/2-v.Theta(), v.Phi());
|
---|
331 | d -= p;
|
---|
332 | d *= sign;
|
---|
333 |
|
---|
334 | // Fix 'direction' of output depending on input vector
|
---|
335 | if (sign*p.Alt()>TMath::Pi()/2)
|
---|
336 | d.Alt(d.Alt()-TMath::Pi());
|
---|
337 |
|
---|
338 | // Align correction into [-180,180]
|
---|
339 | while (d.Az()>TMath::Pi())
|
---|
340 | d.Az(d.Az()-TMath::Pi()*2);
|
---|
341 | while (d.Az()<-TMath::Pi())
|
---|
342 | d.Az(d.Az()+TMath::Pi()*2);
|
---|
343 |
|
---|
344 | return d;
|
---|
345 | }
|
---|
346 |
|
---|
347 |
|
---|
348 | AltAz MBending::Correct(const AltAz &aa) const
|
---|
349 | {
|
---|
350 | // Correct [rad]
|
---|
351 | // zdaz [rad]
|
---|
352 | AltAz p = aa;
|
---|
353 |
|
---|
354 | DEBUG(cout << setprecision(16));
|
---|
355 | DEBUG(cout << "Bend7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
356 |
|
---|
357 | const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
358 | const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
359 | p += CRX;
|
---|
360 | p += CRY;
|
---|
361 |
|
---|
362 | DEBUG(cout << "Bend6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
363 |
|
---|
364 | const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
|
---|
365 | const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
|
---|
366 | p += NRX;
|
---|
367 | p += NRY;
|
---|
368 |
|
---|
369 | DEBUG(cout << "Bend5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
370 |
|
---|
371 | const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
|
---|
372 | const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
|
---|
373 | p += CES;
|
---|
374 | p += CEC;
|
---|
375 |
|
---|
376 | DEBUG(cout << "Bend4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
377 |
|
---|
378 | const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
|
---|
379 | const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
|
---|
380 | //p += TX;
|
---|
381 | p += TF;
|
---|
382 |
|
---|
383 |
|
---|
384 | DEBUG(cout << "Bend3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
385 |
|
---|
386 | /*
|
---|
387 | //New Corrections for NPAE and CA:
|
---|
388 | TVector3 v(1.,1.,1.); // Vector in cartesian coordinates
|
---|
389 |
|
---|
390 | //Set Azimuth and Elevation
|
---|
391 | v.SetPhi(p.Az());
|
---|
392 | v.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
393 | //Rotation Vectors:
|
---|
394 | TVector3 vNpae( cos(p.Az()), sin(p.Az()), 0);
|
---|
395 | TVector3 vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
|
---|
396 | //Rotate around the vectors vNpae and vCa
|
---|
397 | v.Rotate(fNpae, vNpae);
|
---|
398 | v.Rotate(fCa, vCa);
|
---|
399 |
|
---|
400 | p.Az(v.Phi());
|
---|
401 | p.Alt(TMath::Pi()/2-v.Theta());
|
---|
402 | */
|
---|
403 |
|
---|
404 | //Old correction terms for Npae and Ca:
|
---|
405 | const AltAz CA(0, -fCa/cos(p.Alt()));
|
---|
406 | p += CA;
|
---|
407 |
|
---|
408 | const AltAz NPAE(0, -fNpae*tan(p.Alt()));
|
---|
409 | p += NPAE;
|
---|
410 |
|
---|
411 | DEBUG(cout << "Bend2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
412 |
|
---|
413 | const AltAz ANAW(CalcAnAw(p, -1));
|
---|
414 | p += ANAW;
|
---|
415 |
|
---|
416 | /* Old correction terms for An and Aw:
|
---|
417 | const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
|
---|
418 | const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
|
---|
419 | p += AW;
|
---|
420 | p += AN;
|
---|
421 | */
|
---|
422 |
|
---|
423 | DEBUG(cout << "Bend1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
424 |
|
---|
425 | const AltAz FLOP(Sign(fFlop, p.Alt()), 0);
|
---|
426 | p += FLOP;
|
---|
427 |
|
---|
428 | const AltAz I(fIe, fIa);
|
---|
429 | p += I;
|
---|
430 |
|
---|
431 | DEBUG(cout << "Bend0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
432 |
|
---|
433 | return p;
|
---|
434 | }
|
---|
435 |
|
---|
436 | AltAz MBending::CorrectBack(const AltAz &aa) const
|
---|
437 | {
|
---|
438 | // Correct [rad]
|
---|
439 | // zdaz [rad]
|
---|
440 | AltAz p = aa;
|
---|
441 |
|
---|
442 | DEBUG(cout << setprecision(16));
|
---|
443 | DEBUG(cout << "Back0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
444 |
|
---|
445 | const AltAz I(fIe, fIa);
|
---|
446 | p -= I;
|
---|
447 |
|
---|
448 | const AltAz FLOP(Sign(fFlop, p.Alt()), 0);
|
---|
449 | p -= FLOP;
|
---|
450 |
|
---|
451 | DEBUG(cout << "Back1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
452 |
|
---|
453 | /* Old correction terms for An and Aw:
|
---|
454 | const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
|
---|
455 | const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
|
---|
456 | p -= AN;
|
---|
457 | p -= AW;
|
---|
458 | */
|
---|
459 |
|
---|
460 | const AltAz ANAW(CalcAnAw(p, -1));
|
---|
461 | p -= ANAW;
|
---|
462 |
|
---|
463 | DEBUG(cout << "Back2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
464 |
|
---|
465 | //Old Correction terms for Npae and Ca:
|
---|
466 | const AltAz NPAE(0, -fNpae*tan(p.Alt()));
|
---|
467 | p -= NPAE;
|
---|
468 |
|
---|
469 | const AltAz CA(0, -fCa/cos(p.Alt()));
|
---|
470 | p -= CA;
|
---|
471 |
|
---|
472 | /*
|
---|
473 | //New Correction term for Npae and Ca:
|
---|
474 | TVector3 v2(1.,1.,1.); // Vector in cartesian coordinates
|
---|
475 | //Set Azimuth and Elevation
|
---|
476 | v2.SetPhi(p.Az());
|
---|
477 | v2.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
478 | //Rotation Vectors:
|
---|
479 | TVector3 vNpae( cos(p.Az()), sin(p.Az()), 0);
|
---|
480 | TVector3 vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
|
---|
481 | //Rotate around the vectors vCa and vNpae
|
---|
482 | v2.Rotate(-fCa, vCa);
|
---|
483 | v2.Rotate(-fNpae, vNpae);
|
---|
484 |
|
---|
485 | p.Az(v2.Phi());
|
---|
486 | p.Alt(TMath::Pi()/2-v2.Theta());
|
---|
487 | */
|
---|
488 |
|
---|
489 | DEBUG(cout << "Back3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
490 |
|
---|
491 | const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
|
---|
492 | const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
|
---|
493 | p -= TF;
|
---|
494 | //p -= TX;
|
---|
495 |
|
---|
496 | DEBUG(cout << "Back4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
497 |
|
---|
498 | const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
|
---|
499 | const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
|
---|
500 | p -= CEC;
|
---|
501 | p -= CES;
|
---|
502 |
|
---|
503 | DEBUG(cout << "Back5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
504 |
|
---|
505 | const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
|
---|
506 | const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
|
---|
507 | p -= NRY;
|
---|
508 | p -= NRX;
|
---|
509 |
|
---|
510 | DEBUG(cout << "Back6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
511 |
|
---|
512 | const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
513 | const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
514 | p -= CRY;
|
---|
515 | p -= CRX;
|
---|
516 |
|
---|
517 | DEBUG(cout << "Back7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
518 |
|
---|
519 | return p;
|
---|
520 | }
|
---|
521 |
|
---|
522 | ZdAz MBending::Correct(const ZdAz &zdaz) const
|
---|
523 | {
|
---|
524 | // Correct [rad]
|
---|
525 | // zdaz [rad]
|
---|
526 | AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
|
---|
527 | AltAz c = Correct(p);
|
---|
528 | return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
|
---|
529 | }
|
---|
530 |
|
---|
531 | ZdAz MBending::CorrectBack(const ZdAz &zdaz) const
|
---|
532 | {
|
---|
533 | // Correct [rad]
|
---|
534 | // zdaz [rad]
|
---|
535 | AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
|
---|
536 | AltAz c = CorrectBack(p);
|
---|
537 | return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
|
---|
538 | }
|
---|
539 |
|
---|
540 | void MBending::SetParameters(const Double_t *par, Int_t n)
|
---|
541 | {
|
---|
542 | Clear();
|
---|
543 |
|
---|
544 | while (n--)
|
---|
545 | *fCoeff[n] = par[n]/kRad2Deg;
|
---|
546 | }
|
---|
547 |
|
---|
548 | void MBending::GetParameters(Double_t *par, Int_t n) const
|
---|
549 | {
|
---|
550 | while (n--)
|
---|
551 | par[n] = *fCoeff[n]*kRad2Deg;
|
---|
552 | }
|
---|
553 |
|
---|
554 | void MBending::SetMinuitParameters(TMinuit &m, Int_t n=-1) const
|
---|
555 | {
|
---|
556 | if (n<0)
|
---|
557 | n = fNumPar;
|
---|
558 |
|
---|
559 | Int_t ierflg = 0;
|
---|
560 |
|
---|
561 | while (n--)
|
---|
562 | m.mnparm(n, fName[n], *fCoeff[n]*kRad2Deg, 1, -360, 360, ierflg);
|
---|
563 | }
|
---|
564 |
|
---|
565 | void MBending::GetMinuitParameters(TMinuit &m, Int_t n=-1)
|
---|
566 | {
|
---|
567 | if (n<0 || n>m.GetNumPars())
|
---|
568 | n = m.GetNumPars();
|
---|
569 |
|
---|
570 | while (n--)
|
---|
571 | {
|
---|
572 | m.GetParameter(n, *fCoeff[n], fError[n]);
|
---|
573 | *fCoeff[n] /= kRad2Deg;
|
---|
574 | fError[n] /= kRad2Deg;
|
---|
575 | }
|
---|
576 | }
|
---|
577 | /*
|
---|
578 | void FormatPar(TMinuit &m, Int_t n)
|
---|
579 | {
|
---|
580 | Double_t par, err;
|
---|
581 | m.GetParameter(n, par, err);
|
---|
582 |
|
---|
583 | int expp = (int)log10(par);
|
---|
584 | int expe = (int)log10(err);
|
---|
585 |
|
---|
586 | if (err<2*pow(10, expe))
|
---|
587 | expe--;
|
---|
588 |
|
---|
589 | Int_t exp = expe>expp ? expp : expe;
|
---|
590 |
|
---|
591 | par = (int)(par/pow(10, exp)) * pow(10, exp);
|
---|
592 | err = (int)(err/pow(10, exp)) * pow(10, exp);
|
---|
593 |
|
---|
594 | cout << par << " +- " << err << flush;
|
---|
595 | }
|
---|
596 | */
|
---|
597 | void MBending::PrintMinuitParameters(TMinuit &m, Int_t n=-1) const
|
---|
598 | {
|
---|
599 | if (n<0)
|
---|
600 | n = m.GetNumPars();
|
---|
601 |
|
---|
602 | cout << setprecision(3);
|
---|
603 |
|
---|
604 | Double_t par, err;
|
---|
605 |
|
---|
606 | while (n--)
|
---|
607 | {
|
---|
608 | m.GetParameter(n, par, err);
|
---|
609 | cout << Form(" %2d %6s: ", n, (const char*)fName[n]);
|
---|
610 | cout << setw(8) << par << " \xb1 " << setw(6) << err << endl;
|
---|
611 | }
|
---|
612 | }
|
---|