NAME

Raytrace - various raytrace related functions


SYNOPSIS

  use lib '/proj/axaf/simul/lib/perl';
  use Raytrace;
  ( $x, $y, $z ) = Raytrace::get_focus( $file );
  ( $cnt, $wt, $cnt_ghosts, $wt_ghosts ) = Raytrace::get_tot_wt( $file );
  $results = Raytrace::get_enen( $file, $type );
  %centroid_results = Raytrace::get_centroid( $file );


DESCRIPTION

The Raytrace module provides a galimaufry of routines for dealing with some raytrace issues. Generally, the routines will die with an appopriate error message upon error; the caller should use eval to catch the errors.


FUNCTIONS

get_tot_wt
  ( $cnt, $wt, $cnt_ghosts, $wt_ghosts ) = Raytrace::get_tot_wt( $file );

get_tot_wt parses a logfile generated by tot_wt and returns the count and weight of the rays. $cnt and $wt are the total count and weight including ghost rays. $cnt_ghosts, $wt_ghosts are the total count and weight for the ghost rays by themselves. (The number and count of non-ghost rays are $cnt - $cnt_ghosts, and $wt - $wt_ghosts, respectively.)

get_focus
  ( $x, $y, $z ) = Raytrace::get_focus( $file )

get_focus parses an output file create by the OSAC focus routine and sums the ``GENERAL SYSTEM FOCUS'' and the ``GLOBAL OPTIMAL FOCUS'' Z-plane coordinate. it assumes that ZOFF is wrt STD (as set in the .gi file).

get_enen
  $results = Raytrace::get_enen( $file, $type )

get_enen parses an output file created by the enen-p program, It returns a reference to a hash keyed off of either the radius (if $type is Raytrace::ENEN_R) or the fraction (if $type is Raytrace::ENEN_F). The elements of the hash are references to hashes containing the rest of the data, with the keys weight, n, and either fraction (if $type is Raytrace::ENEN_R ) or radius ( if $type is Raytrace::ENEN_F ).

Here's what it looks like:

  use Data::Dumper;
  $results = Raytrace::get_enen( $file, Raytrace::ENEN_F );
  print Dumper $results;

might result in

  $VAR1 = {
          '0.70000' => {
                         'n' => '26',
                         'weight' => '25.20000',
                         'radius' => '0.0372688'
                       },
          '0.40000' => {
                         'n' => '15',
                         'weight' => '14.40000',
                         'radius' => '0.0205026'
                       },
          '0.10000' => {
                         'n' => '4',
                         'weight' => '3.60000',
                         'radius' => '0.010121'
                       }
          };

By default the keys to the hash are strings, so if you try

  print Dumper $results->{0.7};

you'll get

  $VAR1 = undef;

To have them be floating point numbers, set $Raytrace::EnenFloatKeys to 1:

  $Raytrace::EnenFloatKeys = 1;
  $results = Raytrace::get_enen( $file, Raytrace::ENEN_F );
  print Dumper $results->{0.7};

results in

$VAR1 = { 'n' => '26', 'weight' => '25.20000', 'radius' => '0.0372688' };

Another example:

  $results = Raytrace::get_enen( $file, Raytrace::ENEN_R );
  foreach my $radius ( keys %$results )
  {
    print $results{$radius}{weight}, ' ', $results{$radius}{fraction};
  }

Upon error, it croak's; the calling routine should use eval to catch the error.

get_centroid
  %centroid_results = get_centroid( $file );

This parses the table output by the centroid routine. It returns a hash with the following keys: n, x_ave, y_ave, z_ave, x_dev, y_dev, z_dev, x_rms, y_rms, z_rms, and r_rms.


Author

Diab Jerius ( djerius@cfa.harvard.edu )


Revision

$Id: Raytrace.pm,v 1.11 2003/06/18 20:28:31 dj Exp $