Ignore:
Timestamp:
09/17/04 18:36:25 (20 years ago)
Author:
moralejo
Message:
 Commited to CVS all changes to adapt headers to current C++ syntaxis
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Simulation/Detector/Starfield/starfield.cxx

    r432 r5110  
    44// (c) 2000 D. Petry
    55//
     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//
    612/////////////////////////////////////////////////////////////////////////
    713
     
    915#include "starfield.h"
    1016
    11 #define PROGRAMID "$Id: starfield.cxx,v 1.3 2000-09-21 10:31:36 harald Exp $"
     17#define PROGRAMID "$Id: starfield.cxx,v 1.4 2004-09-17 17:36:25 moralejo Exp $"
    1218
    1319/////////////////////////////////////////////////////////////////////////
    1420
    15 main(int argc, char **argv)
     21int main(int argc, char **argv)
    1622{
    1723
     
    3238  float lmin_nm[4] = {ULMIN_nm, BLMIN_nm, VLMIN_nm, RLMIN_nm}; // wave band definitions
    3339  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;
    3542  float angdist;
    3643
     
    8895  cout << "<Goddard Space Flight Center, Flight Dynamics Division (1998)>\n";
    8996
    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.);
    9199
    92100  if(angdist > 180.){ // too near to the pole, have to loop over all files
     
    192200    }
    193201   
    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
    201251    // calculate the "zenith angle" theta and "azimuth" phi of the star assuming
    202252    // the telecope points at the zenith
     
    211261      phi_rad = 2.*PI - acos(stars[i].u);
    212262    }
    213    
     263
    214264    // calculate number of photons
    215265   
     
    289339
    290340  convertcorsika(
    291                  ((int)pars.ct_ra_h*10)*1000 + (int)(abs(pars.ct_dec_deg)*10), // the file id
     341                 ((int)pars.ct_ra_h*10)*1000 + (int)(fabs(pars.ct_dec_deg)*10), // the file id
    292342                 totalphotinside, photons, pars.integtime_s, pars.verbose, pars.output_file);
    293343
Note: See TracChangeset for help on using the changeset viewer.