source: trunk/MagicSoft/Simulation/Detector/Starfield/parameters.cxx@ 1000

Last change on this file since 1000 was 431, checked in by harald, 24 years ago
Oscar changed the code just to run it on alpha machines. I just commit the changes due to problems with the repository.
File size: 4.4 KB
Line 
1#include "parameters.h"
2
3parameters::parameters(){ // constructor (put invalid values)
4 ct_ra_h = -999.;
5 ct_dec_deg = -999.;
6 ct_ra_rad = -999.;
7 ct_dec_rad = -999.;
8 catalog_fov_deg = -999.;
9 integtime_s = -999.;
10 mirr_radius_m = -999.;
11 sprintf(datapath, ".");
12 verbose = 0;
13}
14
15int parameters::readparameters(ifstream *in){ // read the parameter file
16 int ira_hours, ira_min, ira_sec;
17 int idec_degrees, idec_arcmin;
18 float dec_arcsec;
19 char dummy[160];
20
21 in->ipfx(1); // tell the io system that we are reading formatted
22
23 in->getline(dummy, sizeof(dummy), '\n');
24 cout << dummy << "\n";
25 if(in->eof()) return(in->good());
26
27 in->getline(dummy, sizeof(dummy), '\n');
28 if(verbose) cout << dummy << "\n";
29 if(in->eof()) return(in->good());
30
31 in->getline(dummy, sizeof(dummy), '\n');
32 if(verbose) cout << dummy << "\n";
33 sscanf(dummy, "%d %d %d %d %d %f", &ira_hours , &ira_min, &ira_sec,
34 &idec_degrees, &idec_arcmin, &dec_arcsec);
35 cout << "Position RA DEC: "<< ira_hours << " " << ira_min << " " << ira_sec << " " <<
36 idec_degrees << " " << idec_arcmin << " " << dec_arcsec << "\n";
37 if(in->eof()) return(in->good());
38
39 in->getline(dummy, sizeof(dummy), '\n');
40 if(verbose) cout << dummy << "\n";
41 if(in->eof()) return(in->good());
42
43 in->getline(dummy, sizeof(dummy), '\n');
44 if(verbose) cout << dummy << "\n";
45 sscanf(dummy, "%f", &catalog_fov_deg);
46 cout << "FOV Radius:" << catalog_fov_deg << " degrees\n";
47 if(in->eof()) return(in->good());
48
49 in->getline(dummy, sizeof(dummy), '\n');
50 if(verbose) cout << dummy << "\n";
51 if(in->eof()) return(in->good());
52
53 in->getline(dummy, sizeof(dummy), '\n');
54 if(verbose) cout << dummy << "\n";
55 sscanf(dummy, "%f", &integtime_s);
56 cout << "Integration Time:" << integtime_s << " s\n";
57 if(in->eof()) return(in->good());
58
59 in->getline(dummy, sizeof(dummy), '\n');
60 if(verbose) cout << dummy << "\n";
61 if(in->eof()) return(in->good());
62
63 in->getline(dummy, sizeof(dummy), '\n');
64 if(verbose) cout << dummy << "\n";
65 sscanf(dummy, "%f", &mirr_radius_m);
66 cout << "Mirror Radius:" << mirr_radius_m << " m\n";
67 if(in->eof()) return(in->good());
68
69 in->getline(dummy, sizeof(dummy), '\n');
70 if(verbose) cout << dummy << "\n";
71 if(in->eof()) return(in->good());
72
73 in->getline(dummy, sizeof(dummy), '\n');
74 if(verbose) cout << dummy << "\n";
75 sscanf( dummy, "%s", datapath);
76 cout << "Catalog Data Path: " << datapath << "\n";
77 if(in->eof()) return(in->good());
78
79 in->getline(dummy, sizeof(dummy), '\n');
80 if(verbose) cout << dummy << "\n";
81 if(in->eof()) return(in->good());
82
83 in->getline(dummy, sizeof(dummy), '\n');
84 if(verbose) cout << dummy << "\n";
85 sscanf( dummy, "%d", &verbose);
86 cout << "Verbosity: " << verbose << "\n";
87
88 in->getline(dummy, sizeof(dummy), '\n');
89 if(verbose) cout << dummy << "\n";
90 if(in->eof()) return(in->good());
91
92 in->getline(dummy, sizeof(dummy), '\n');
93 if(verbose) cout << dummy << "\n";
94 sscanf(dummy, "%s", output_file);
95 cout << "Output Files : cer" << output_file << " and sta"<<output_file<<endl;
96 if(in->eof()) return(in->good());
97
98 ct_ra_h = ira_hours + ira_min/60. + ira_sec/3600.;
99 ct_dec_deg = idec_degrees + idec_arcmin/60. + dec_arcsec/3600.;
100 ct_ra_rad = ct_ra_h * PI / 12.;
101 ct_dec_rad = ct_dec_deg * PI / 180.;
102
103 return(in->good());
104}
105
106void parameters::usage(ostream *out){
107 *out << "Starfield Generator Parameters, Date: ......, Comment: ....\n";
108 *out << "Center of FOV: ira_hours ira_min ira_sec idec_degrees idec_arcmin dec_arcsec:\n";
109 *out << "05 34 32 +22 00 52.1 \n";
110 *out << "Radius of the FOV for the catalog readout (degrees):\n";
111 *out << "2.0\n";
112 *out << "Integration time for the calculation of the number of photons (seconds):\n";
113 *out << "50e-9\n";
114 *out << "Mirror radius for the generation of random impact points (meters):\n";
115 *out << "10.0\n";
116 *out << "Path inside which the star catalog data can be found:\n";
117 *out << "/usr/users/xy/stardata\n";
118 *out << "Verbosity level (0 = not verbose, 1 = verbose, 2 = very verbose, 3 = very very ...):\n";
119 *out << "0\n";
120 return;
121}
122
123int parameters::printparameters(ostream *out){ // write the parameters to the stream
124 out->setf(ios::adjustfield);
125 out->width(PRINTWIDTH);
126 *out << "optical axis RA (h)" << ct_ra_h; out->width(PRINTWIDTH);
127 *out << "optical axis DEC (deg)" << ct_dec_deg; out->width(PRINTWIDTH);
128 *out << "\n";
129 return(0);
130}
131// reminder:
132// some of the things from star.h should go into the parameters file
133
134
Note: See TracBrowser for help on using the repository browser.