source: trunk/Cosy/bend.cc@ 10954

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