source: trunk/MagicSoft/Cosy/bend.cc@ 7940

Last change on this file since 7940 was 1953, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.4 KB
Line 
1#include <iomanip.h>
2#include <iostream.h>
3
4#include <MBending.h>
5
6/* ---------------------------------------------------------------------- */
7
8int main(int argc, char **argv)
9{
10 cout << "-" << endl;
11 cout << "Trying to open prepos.txt.." << endl;
12 ifstream fin("prepos.txt");
13 if (!fin)
14 {
15 cout << "ERROR: Predifined posiion in 'prepos.txt' not found." << endl;
16 return 1;
17 }
18
19 cout << "-" << endl;
20 cout << "Initializing bending correction from bending.txt.." << endl;
21 cout << "-" << endl;
22 MBending bend("bending.txt");
23 cout << "-" << endl;
24 cout << "Calculate system coordinates for predefined positions..." << endl;
25 cout << "-" << endl;
26
27 ofstream fout("prepos_system.txt");
28 if (!fout)
29 {
30 cout << "ERROR: Cannot open prepos_system.txt for writing." << endl;
31 return 1;
32 }
33
34 fout << setprecision(12);
35
36 while (1)
37 {
38 TString str;
39 Double_t zd, az;
40 fin >> str >> zd >> az;
41 if (!fin)
42 break;
43
44 cout << setprecision(7);
45 cout << " -- " << str << " --" << endl;
46
47 ZdAz za(zd, az);
48
49 ZdAz orig = za;
50
51 cout << "Pointing: \t" << za.Zd() << "\t" << za.Az() << endl;
52
53 za = bend(za*kDeg2Rad)*kRad2Deg;
54
55 cout << "Bended: \t" << za.Zd() << "\t" << za.Az() << endl;
56 fout << str << " " << za.Zd() << " " << za.Az() << endl;
57
58 za = bend.CorrectBack(za*kDeg2Rad)*kRad2Deg;
59 cout << "Rebended: \t" << za.Zd() << "\t" << za.Az() << endl;
60
61 za -= orig;
62
63 if (za.Zd()*3600<.5)
64 za.Zd(0);
65 if (za.Az()*3600<.5)
66 za.Az(0);
67
68 cout << setprecision(3);
69 cout << "Diff: \t" << za.Zd()*3600 << "\"\t" << za.Az()*3600 << "\"" << endl;
70
71 }
72 cout << "-" << endl;
73
74
75 Double_t min=360;
76 Double_t mini=0;
77 Double_t minj=0;
78 for (int i=-120; i<=120; i++)
79 for (int j=-120; j<=120; j++)
80 {
81 ZdAz za(i/3600., j/3600.);
82 ZdAz orig = za;
83 za = bend(za*kDeg2Rad)*kRad2Deg;
84 za = bend.CorrectBack(za*kDeg2Rad)*kRad2Deg;
85 za -= orig;
86 if (fabs(za.Zd())<min)
87 {
88 min = fabs(za.Zd());
89 mini = i;
90 minj = j;
91 }
92 }
93 cout << "Minimum Distance to Zenith: " << min*3600 << "\"";
94 cout << " @ " << mini << "\" " << minj << "\"" << endl;
95 cout << "-" << endl;
96
97 return 0;
98}
Note: See TracBrowser for help on using the repository browser.