Best Geometric Focus
Introduction
The best geometric focus calculation can be made from the GUI ( Menu > Analysis > Best Geometric Focus ) and from the scripting language using the BestFocus subroutine.
Performing this analysis using the scripting language can be quite useful because the calculation and any element re-positioning can be done in a single step. In this article, the detector element is automatically re-positioned at the best focus position of a singlet found using the scripting language.
Download the FRED file: computeBestFocus.frd
Script Pseudo-code
The script demonstrating the geometric best focus calculation performs the following steps:
- Specify the detector surface and the coordinate system of the best focus results
- Delete existing rays and raytrace the sources
- Wait for 3 seconds to show the result in the 3D view
- Compute the best focus
- Loop over the ray buffer to get the ray count
- Move the detector entity to the best focus position
- Delete existing rays and raytrace the sources to show the new position in the 3D view
- Print the best focus results to the output window
Note that the BestFocus subroutine places the results of the calculation into a data structure of the type T_BESTFOCUS.