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 "timer.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 | Timer t;
|
---|
265 | t.Now();
|
---|
266 |
|
---|
267 | fout << "MAGIC1 " << t.GetTimeStr() << 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::Correct(const AltAz &aa) const
|
---|
288 | {
|
---|
289 | // Correct [rad]
|
---|
290 | // zdaz [rad]
|
---|
291 | AltAz p = aa;
|
---|
292 |
|
---|
293 | DEBUG(cout << setprecision(16));
|
---|
294 | DEBUG(cout << "Bend7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
295 |
|
---|
296 | const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
297 | const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
298 | p += CRX;
|
---|
299 | p += CRY;
|
---|
300 |
|
---|
301 | DEBUG(cout << "Bend6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
302 |
|
---|
303 | const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
|
---|
304 | const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
|
---|
305 | p += NRX;
|
---|
306 | p += NRY;
|
---|
307 |
|
---|
308 | DEBUG(cout << "Bend5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
309 |
|
---|
310 | const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
|
---|
311 | const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
|
---|
312 | p += CES;
|
---|
313 | p += CEC;
|
---|
314 |
|
---|
315 | DEBUG(cout << "Bend4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
316 |
|
---|
317 | const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
|
---|
318 | const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
|
---|
319 | //p += TX;
|
---|
320 | p += TF;
|
---|
321 |
|
---|
322 |
|
---|
323 | DEBUG(cout << "Bend3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
324 |
|
---|
325 | /*
|
---|
326 | //New Corrections for NPAE and CA:
|
---|
327 | TVector3 v(1.,1.,1.); // Vector in cartesian coordinates
|
---|
328 |
|
---|
329 | //Set Azimuth and Elevation
|
---|
330 | v.SetPhi(p.Az());
|
---|
331 | v.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
332 | //Rotation Vectors:
|
---|
333 | TVector3 vNpae( cos(p.Az()), sin(p.Az()), 0);
|
---|
334 | TVector3 vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
|
---|
335 | //Rotate around the vectors vNpae and vCa
|
---|
336 | v.Rotate(fNpae, vNpae);
|
---|
337 | v.Rotate(fCa, vCa);
|
---|
338 |
|
---|
339 | p.Az(v.Phi());
|
---|
340 | p.Alt(TMath::Pi()/2-v.Theta());
|
---|
341 | */
|
---|
342 |
|
---|
343 | //Old correction terms for Npae and Ca:
|
---|
344 | const AltAz CA(0, -fCa/cos(p.Alt()));
|
---|
345 | p += CA;
|
---|
346 |
|
---|
347 | const AltAz NPAE(0, -fNpae*tan(p.Alt()));
|
---|
348 | p += NPAE;
|
---|
349 |
|
---|
350 | DEBUG(cout << "Bend2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
351 |
|
---|
352 | // New Corrections for AW and AN:
|
---|
353 | TVector3 v2(1.,1.,1.); // Vector in cartesian coordinates
|
---|
354 | // Set Azimuth and Elevation
|
---|
355 | v2.SetPhi(p.Az());
|
---|
356 | v2.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
357 | // Rotate around the x- and y-axis
|
---|
358 | v2.RotateX(fAw);
|
---|
359 | v2.RotateY(fAn);
|
---|
360 | // Get Azimuth and Elevation
|
---|
361 | p.Az(v2.Phi());
|
---|
362 | p.Alt(TMath::Pi()/2-v2.Theta());
|
---|
363 |
|
---|
364 | /*
|
---|
365 | // Old correction terms for An and Aw:
|
---|
366 | cout << fAw << " " << cos(p.Az()) << " " << tan(p.Alt()) << endl;
|
---|
367 | cout << fAw* cos(p.Az())*tan(p.Alt())*180/3.1415 << endl;
|
---|
368 |
|
---|
369 | const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
|
---|
370 | const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
|
---|
371 | p += AW;
|
---|
372 | p += AN;
|
---|
373 | */
|
---|
374 |
|
---|
375 |
|
---|
376 |
|
---|
377 |
|
---|
378 | DEBUG(cout << "Bend1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
379 |
|
---|
380 | const AltAz FLOP(Sign(fFlop, p.Alt()), 0);
|
---|
381 | p += FLOP;
|
---|
382 |
|
---|
383 | const AltAz I(fIe, fIa);
|
---|
384 | p += I;
|
---|
385 |
|
---|
386 | DEBUG(cout << "Bend0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
387 |
|
---|
388 | return p;
|
---|
389 | }
|
---|
390 |
|
---|
391 | AltAz MBending::AddOffsets(const AltAz &aa) const
|
---|
392 | {
|
---|
393 | // Correct [rad]
|
---|
394 | // zdaz [rad]
|
---|
395 | AltAz p = aa;
|
---|
396 |
|
---|
397 | const AltAz I(fIe, fIa);
|
---|
398 | p += I;
|
---|
399 |
|
---|
400 | return p;
|
---|
401 | }
|
---|
402 |
|
---|
403 | AltAz MBending::CorrectBack(const AltAz &aa) const
|
---|
404 | {
|
---|
405 | // Correct [rad]
|
---|
406 | // zdaz [rad]
|
---|
407 | AltAz p = aa;
|
---|
408 |
|
---|
409 | DEBUG(cout << setprecision(16));
|
---|
410 | DEBUG(cout << "Back0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
411 |
|
---|
412 | const AltAz I(fIe, fIa);
|
---|
413 | p -= I;
|
---|
414 |
|
---|
415 | const AltAz FLOP(Sign(fFlop, p.Alt()), 0);
|
---|
416 | p -= FLOP;
|
---|
417 |
|
---|
418 | DEBUG(cout << "Back1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
419 |
|
---|
420 | /*
|
---|
421 | //Old correction terms for An and Aw:
|
---|
422 | const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt()));
|
---|
423 | const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt()));
|
---|
424 | p -= AN;
|
---|
425 | p -= AW;
|
---|
426 | */
|
---|
427 |
|
---|
428 | // New Corrections for AN and AW:
|
---|
429 | TVector3 v(1.,1.,1.); // Vector in cartesian coordinates
|
---|
430 | // Set Azimuth and Elevation
|
---|
431 | v.SetPhi(p.Az());
|
---|
432 | v.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
433 | // Rotate around the x- and y-axis
|
---|
434 | v.RotateY(-fAn);
|
---|
435 | v.RotateX(-fAw);
|
---|
436 | // Get Azimuth and Elevation
|
---|
437 | p.Az(v.Phi());
|
---|
438 | p.Alt(TMath::Pi()/2-v.Theta());
|
---|
439 |
|
---|
440 |
|
---|
441 | DEBUG(cout << "Back2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
442 |
|
---|
443 | //Old Correction terms for Npae and Ca:
|
---|
444 | const AltAz NPAE(0, -fNpae*tan(p.Alt()));
|
---|
445 | p -= NPAE;
|
---|
446 |
|
---|
447 | const AltAz CA(0, -fCa/cos(p.Alt()));
|
---|
448 | p -= CA;
|
---|
449 |
|
---|
450 | /*
|
---|
451 | //New Correction term for Npae and Ca:
|
---|
452 | TVector3 v2(1.,1.,1.); // Vector in cartesian coordinates
|
---|
453 | //Set Azimuth and Elevation
|
---|
454 | v2.SetPhi(p.Az());
|
---|
455 | v2.SetTheta(TMath::Pi()/2-p.Alt());
|
---|
456 | //Rotation Vectors:
|
---|
457 | TVector3 vNpae( cos(p.Az()), sin(p.Az()), 0);
|
---|
458 | TVector3 vCa( -cos(p.Az())*cos(p.Alt()), -sin(p.Az())*cos(p.Alt()), sin(p.Alt()));
|
---|
459 | //Rotate around the vectors vCa and vNpae
|
---|
460 | v2.Rotate(-fCa, vCa);
|
---|
461 | v2.Rotate(-fNpae, vNpae);
|
---|
462 |
|
---|
463 | p.Az(v2.Phi());
|
---|
464 | p.Alt(TMath::Pi()/2-v2.Theta());
|
---|
465 | */
|
---|
466 |
|
---|
467 | DEBUG(cout << "Back3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
468 |
|
---|
469 | const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0);
|
---|
470 | const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0);
|
---|
471 | p -= TF;
|
---|
472 | //p -= TX;
|
---|
473 |
|
---|
474 | DEBUG(cout << "Back4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
475 |
|
---|
476 | const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az()));
|
---|
477 | const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az()));
|
---|
478 | p -= CEC;
|
---|
479 | p -= CES;
|
---|
480 |
|
---|
481 | DEBUG(cout << "Back5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
482 |
|
---|
483 | const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt()));
|
---|
484 | const AltAz NRX(fNrx*sin(p.Alt()), -fNrx);
|
---|
485 | p -= NRY;
|
---|
486 | p -= NRX;
|
---|
487 |
|
---|
488 | DEBUG(cout << "Back6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
489 |
|
---|
490 | const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
491 | const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt()));
|
---|
492 | p -= CRY;
|
---|
493 | p -= CRX;
|
---|
494 |
|
---|
495 | DEBUG(cout << "Back7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl);
|
---|
496 |
|
---|
497 | return p;
|
---|
498 | }
|
---|
499 |
|
---|
500 | AltAz MBending::SubtractOffsets(const AltAz &aa) const
|
---|
501 | {
|
---|
502 | // Correct [rad]
|
---|
503 | // zdaz [rad]
|
---|
504 | AltAz p = aa;
|
---|
505 |
|
---|
506 | const AltAz I(fIe, fIa);
|
---|
507 | p -= I;
|
---|
508 |
|
---|
509 | return p;
|
---|
510 | }
|
---|
511 |
|
---|
512 |
|
---|
513 | ZdAz MBending::Correct(const ZdAz &zdaz) const
|
---|
514 | {
|
---|
515 | // Correct [rad]
|
---|
516 | // zdaz [rad]
|
---|
517 | AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
|
---|
518 | AltAz c = Correct(p);
|
---|
519 | return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
|
---|
520 | }
|
---|
521 |
|
---|
522 | ZdAz MBending::CorrectBack(const ZdAz &zdaz) const
|
---|
523 | {
|
---|
524 | // Correct [rad]
|
---|
525 | // zdaz [rad]
|
---|
526 | AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az());
|
---|
527 | AltAz c = CorrectBack(p);
|
---|
528 | return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
|
---|
529 | }
|
---|
530 |
|
---|
531 | void MBending::SetParameters(const Double_t *par, Int_t n)
|
---|
532 | {
|
---|
533 | Clear();
|
---|
534 |
|
---|
535 | while (n--)
|
---|
536 | *fCoeff[n] = par[n]/kRad2Deg;
|
---|
537 | }
|
---|
538 |
|
---|
539 | void MBending::GetParameters(Double_t *par, Int_t n) const
|
---|
540 | {
|
---|
541 | while (n--)
|
---|
542 | par[n] = *fCoeff[n]*kRad2Deg;
|
---|
543 | }
|
---|
544 |
|
---|
545 | void MBending::SetMinuitParameters(TMinuit &m, Int_t n=-1) const
|
---|
546 | {
|
---|
547 | if (n<0)
|
---|
548 | n = fNumPar;
|
---|
549 |
|
---|
550 | Int_t ierflg = 0;
|
---|
551 |
|
---|
552 | while (n--)
|
---|
553 | m.mnparm(n, fName[n], *fCoeff[n]*kRad2Deg, 1, -360, 360, ierflg);
|
---|
554 | }
|
---|
555 |
|
---|
556 | void MBending::GetMinuitParameters(TMinuit &m, Int_t n=-1)
|
---|
557 | {
|
---|
558 | if (n<0 || n>m.GetNumPars())
|
---|
559 | n = m.GetNumPars();
|
---|
560 |
|
---|
561 | while (n--)
|
---|
562 | {
|
---|
563 | m.GetParameter(n, *fCoeff[n], fError[n]);
|
---|
564 | *fCoeff[n] /= kRad2Deg;
|
---|
565 | fError[n] /= kRad2Deg;
|
---|
566 | }
|
---|
567 | }
|
---|
568 | /*
|
---|
569 | void FormatPar(TMinuit &m, Int_t n)
|
---|
570 | {
|
---|
571 | Double_t par, err;
|
---|
572 | m.GetParameter(n, par, err);
|
---|
573 |
|
---|
574 | int expp = (int)log10(par);
|
---|
575 | int expe = (int)log10(err);
|
---|
576 |
|
---|
577 | if (err<2*pow(10, expe))
|
---|
578 | expe--;
|
---|
579 |
|
---|
580 | Int_t exp = expe>expp ? expp : expe;
|
---|
581 |
|
---|
582 | par = (int)(par/pow(10, exp)) * pow(10, exp);
|
---|
583 | err = (int)(err/pow(10, exp)) * pow(10, exp);
|
---|
584 |
|
---|
585 | cout << par << " +- " << err << flush;
|
---|
586 | }
|
---|
587 | */
|
---|
588 | void MBending::PrintMinuitParameters(TMinuit &m, Int_t n=-1) const
|
---|
589 | {
|
---|
590 | if (n<0)
|
---|
591 | n = m.GetNumPars();
|
---|
592 |
|
---|
593 | cout << setprecision(3);
|
---|
594 |
|
---|
595 | Double_t par, err;
|
---|
596 |
|
---|
597 | while (n--)
|
---|
598 | {
|
---|
599 | m.GetParameter(n, par, err);
|
---|
600 | cout << Form(" %2d %6s: ", n, (const char*)fName[n]);
|
---|
601 | cout << setw(8) << par << " \xb1 " << setw(6) << err << endl;
|
---|
602 | }
|
---|
603 | }
|
---|