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

Last change on this file since 9391 was 5110, checked in by moralejo, 20 years ago
Commited to CVS all changes to adapt headers to current C++ syntaxis
File size: 4.3 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->getline(dummy, sizeof(dummy), '\n');
22 cout << dummy << "\n";
23 if(in->eof()) return(in->good());
24
25 in->getline(dummy, sizeof(dummy), '\n');
26 if(verbose) cout << dummy << "\n";
27 if(in->eof()) return(in->good());
28
29 in->getline(dummy, sizeof(dummy), '\n');
30 if(verbose) cout << dummy << "\n";
31 sscanf(dummy, "%d %d %d %d %d %f", &ira_hours , &ira_min, &ira_sec,
32 &idec_degrees, &idec_arcmin, &dec_arcsec);
33 cout << "Position RA DEC: "<< ira_hours << " " << ira_min << " " << ira_sec << " " <<
34 idec_degrees << " " << idec_arcmin << " " << dec_arcsec << "\n";
35 if(in->eof()) return(in->good());
36
37 in->getline(dummy, sizeof(dummy), '\n');
38 if(verbose) cout << dummy << "\n";
39 if(in->eof()) return(in->good());
40
41 in->getline(dummy, sizeof(dummy), '\n');
42 if(verbose) cout << dummy << "\n";
43 sscanf(dummy, "%f", &catalog_fov_deg);
44 cout << "FOV Radius:" << catalog_fov_deg << " degrees\n";
45 if(in->eof()) return(in->good());
46
47 in->getline(dummy, sizeof(dummy), '\n');
48 if(verbose) cout << dummy << "\n";
49 if(in->eof()) return(in->good());
50
51 in->getline(dummy, sizeof(dummy), '\n');
52 if(verbose) cout << dummy << "\n";
53 sscanf(dummy, "%f", &integtime_s);
54 cout << "Integration Time:" << integtime_s << " s\n";
55 if(in->eof()) return(in->good());
56
57 in->getline(dummy, sizeof(dummy), '\n');
58 if(verbose) cout << dummy << "\n";
59 if(in->eof()) return(in->good());
60
61 in->getline(dummy, sizeof(dummy), '\n');
62 if(verbose) cout << dummy << "\n";
63 sscanf(dummy, "%f", &mirr_radius_m);
64 cout << "Mirror Radius:" << mirr_radius_m << " m\n";
65 if(in->eof()) return(in->good());
66
67 in->getline(dummy, sizeof(dummy), '\n');
68 if(verbose) cout << dummy << "\n";
69 if(in->eof()) return(in->good());
70
71 in->getline(dummy, sizeof(dummy), '\n');
72 if(verbose) cout << dummy << "\n";
73 sscanf( dummy, "%s", datapath);
74 cout << "Catalog Data Path: " << datapath << "\n";
75 if(in->eof()) return(in->good());
76
77 in->getline(dummy, sizeof(dummy), '\n');
78 if(verbose) cout << dummy << "\n";
79 if(in->eof()) return(in->good());
80
81 in->getline(dummy, sizeof(dummy), '\n');
82 if(verbose) cout << dummy << "\n";
83 sscanf( dummy, "%d", &verbose);
84 cout << "Verbosity: " << verbose << "\n";
85
86 in->getline(dummy, sizeof(dummy), '\n');
87 if(verbose) cout << dummy << "\n";
88 if(in->eof()) return(in->good());
89
90 in->getline(dummy, sizeof(dummy), '\n');
91 if(verbose) cout << dummy << "\n";
92 sscanf(dummy, "%s", output_file);
93 cout << "Output Files : cer" << output_file << " and sta"<<output_file<<endl;
94 if(in->eof()) return(in->good());
95
96 ct_ra_h = ira_hours + ira_min/60. + ira_sec/3600.;
97 ct_dec_deg = idec_degrees + idec_arcmin/60. + dec_arcsec/3600.;
98 ct_ra_rad = ct_ra_h * PI / 12.;
99 ct_dec_rad = ct_dec_deg * PI / 180.;
100
101 return(in->good());
102}
103
104void parameters::usage(ostream *out){
105 *out << "Starfield Generator Parameters, Date: ......, Comment: ....\n";
106 *out << "Center of FOV: ira_hours ira_min ira_sec idec_degrees idec_arcmin dec_arcsec:\n";
107 *out << "05 34 32 +22 00 52.1 \n";
108 *out << "Radius of the FOV for the catalog readout (degrees):\n";
109 *out << "2.0\n";
110 *out << "Integration time for the calculation of the number of photons (seconds):\n";
111 *out << "50e-9\n";
112 *out << "Mirror radius for the generation of random impact points (meters):\n";
113 *out << "10.0\n";
114 *out << "Path inside which the star catalog data can be found:\n";
115 *out << "/usr/users/xy/stardata\n";
116 *out << "Verbosity level (0 = not verbose, 1 = verbose, 2 = very verbose, 3 = very very ...):\n";
117 *out << "0\n";
118 return;
119}
120
121int parameters::printparameters(ostream *out){ // write the parameters to the stream
122 out->setf(ios::adjustfield);
123 out->width(PRINTWIDTH);
124 *out << "optical axis RA (h)" << ct_ra_h; out->width(PRINTWIDTH);
125 *out << "optical axis DEC (deg)" << ct_dec_deg; out->width(PRINTWIDTH);
126 *out << "\n";
127 return(0);
128}
129// reminder:
130// some of the things from star.h should go into the parameters file
131
132
Note: See TracBrowser for help on using the repository browser.