- Timestamp:
- 09/17/04 18:36:25 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Starfield/starfield.cxx
r432 r5110 4 4 // (c) 2000 D. Petry 5 5 // 6 // 15/09/2004, A. Moralejo: 7 // - Adapted to gcc 3.2 under root 3.05.07 8 // - Fixed algorithm to calculate director cosines of incident photons. 9 // Former algorithm resulted in mirrored images on the camera (which we 10 // must not have after reflection on a parabollic dish). 11 // 6 12 ///////////////////////////////////////////////////////////////////////// 7 13 … … 9 15 #include "starfield.h" 10 16 11 #define PROGRAMID "$Id: starfield.cxx,v 1. 3 2000-09-21 10:31:36 haraldExp $"17 #define PROGRAMID "$Id: starfield.cxx,v 1.4 2004-09-17 17:36:25 moralejo Exp $" 12 18 13 19 ///////////////////////////////////////////////////////////////////////// 14 20 15 main(int argc, char **argv)21 int main(int argc, char **argv) 16 22 { 17 23 … … 32 38 float lmin_nm[4] = {ULMIN_nm, BLMIN_nm, VLMIN_nm, RLMIN_nm}; // wave band definitions 33 39 float lmax_nm[4] = {ULMAX_nm, BLMAX_nm, VLMAX_nm, RLMAX_nm}; 34 float theta_rad, costheta, phi_rad, randtime, lambda_nm, xdum_m, ydum_m; 40 float theta_rad, costheta, sintheta, phi_rad, randtime, lambda_nm, xdum_m, ydum_m; 41 float cosa, cosA, sinA; 35 42 float angdist; 36 43 … … 88 95 cout << "<Goddard Space Flight Center, Flight Dynamics Division (1998)>\n"; 89 96 90 angdist = fmod( pars.catalog_fov_deg / cos( pars.ct_dec_rad ), 360.); 97 angdist = fmod( (float) (pars.catalog_fov_deg/cos( pars.ct_dec_rad )), 98 (float) 360.); 91 99 92 100 if(angdist > 180.){ // too near to the pole, have to loop over all files … … 192 200 } 193 201 194 stars[i].u = -1. * cos( stars[i].dec_rad ) * sin( stars[i].ra_rad - pars.ct_ra_rad ) / costheta; 195 196 stars[i].v = -1. * ( sin( pars.ct_dec_rad ) * cos( stars[i].dec_rad ) * 197 cos( stars[i].ra_rad - pars.ct_ra_rad ) - 198 cos( pars.ct_dec_rad ) * sin( stars[i].dec_rad ) 199 ) / costheta; 200 202 sintheta = sqrt(1.-costheta*costheta); 203 204 // 205 // A. Moralejo, 15/09/2004 206 // We want the director cosines of the down-going versors along the photon 207 // incident directions. This is what the Reflector program expects (also from the 208 // normal Corsika output). We have used simple spherical trigonometry to obtain 209 // the formulae. 210 // 211 212 // "cosa" is the cosine of the angle "a" between the star direction and the direction 213 // defined by declination = 0 and right ascension = ct_ra. "a" is one of the sides of 214 // a spherical triangle. It is a quantity needed for the calculations. 215 216 cosa = cos( stars[i].ra_rad - pars.ct_ra_rad ) * cos( stars[i].dec_rad ); 217 218 // cosA is the angle between the great circle of constant right ascension = ct_ra and 219 // the great circle defined by the star direction and the telescope direction. "A" would 220 // be the angle opposite to the side "a" of a spherical triangle (see above) 221 222 cosA = (cosa - costheta*cos(pars.ct_dec_rad)) / (sintheta*sin(pars.ct_dec_rad)); 223 224 // We now want A to be defined in the 0 - 2pi range, so that it becomes the azimuth angle 225 // of the star in a system defined by the telescope direction. "A" will be defined between 226 // 0 and pi if sin (star_ra - ct_ra) > 0, and between pi and 2 pi otherwise. 227 228 sinA = sqrt (1.-cosA*cosA); 229 if ( sin(stars[i].ra_rad - pars.ct_ra_rad ) < 0. ) 230 sinA *= -1.; 231 232 stars[i].u = -1. * sintheta * cosA; 233 stars[i].v = -1. * sintheta * sinA; 234 235 236 // Old implementation, commented out 15/09/2004: 237 // 238 // This produced director cosines which, when fed to reflector, makes on the camera plane 239 // a mirror-inverted image of the FOV (with respect to what one would see "by eye"). That 240 // is NOT what we want! After reflection on the parabollic mirror, the image on the camera 241 // is NOT mirrored, but just rotated by 180 degree. The new implementation above produces 242 // the correct FOV (tested with Reflector 0.6) 243 // 244 // stars[i].u = -1. * cos( stars[i].dec_rad ) * sin( stars[i].ra_rad - pars.ct_ra_rad ) / costheta; 245 // stars[i].v = -1. * ( sin( pars.ct_dec_rad ) * cos( stars[i].dec_rad ) * 246 // cos( stars[i].ra_rad - pars.ct_ra_rad ) - 247 // cos( pars.ct_dec_rad ) * sin( stars[i].dec_rad ) 248 // ) / costheta; 249 250 201 251 // calculate the "zenith angle" theta and "azimuth" phi of the star assuming 202 252 // the telecope points at the zenith … … 211 261 phi_rad = 2.*PI - acos(stars[i].u); 212 262 } 213 263 214 264 // calculate number of photons 215 265 … … 289 339 290 340 convertcorsika( 291 ((int)pars.ct_ra_h*10)*1000 + (int)( abs(pars.ct_dec_deg)*10), // the file id341 ((int)pars.ct_ra_h*10)*1000 + (int)(fabs(pars.ct_dec_deg)*10), // the file id 292 342 totalphotinside, photons, pars.integtime_s, pars.verbose, pars.output_file); 293 343
Note:
See TracChangeset
for help on using the changeset viewer.