GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > GRBP / V1-0-0
Constituent: grbpsiu     Tag: rad750
#include "GRBP_locate.h"
#include "GRBP_location.h"
#include "GRBP_gammaList.h"
#include "GRBP_gamma.h"
#include "GRBP_math.h"
#include "wrap.h"
#include "tmr.h"
#include "touch.h"
#include "PBI/Attribute.h"
#include "grbp_gamma_report.h"
#include "dprintf.h"
Include dependency graph for GRBP_locate.c:
Data Structures | |
struct | _Sdata |
Collects the static data used by these routines into one place. More... | |
Defines | |
#define | DO_CONVERGENCE |
#define | NULL ((void *)(0)) |
#define | CUTOFF_DISTANCE 0.99984769516 |
Defines a cutoff distance corresponding to 1 degree. All gammas closer than this to the seed location will be treated as if they were at the 1 degree. | |
#define | CUTOFF_WEIGHT2 ((180./M_PI) * (180./M_PI)) |
Defines the weight (squared) corresponding to the cutoff distance. | |
#define | ITERATIONS 10 |
Defines the maximum number of iterations when doing the location. | |
#define | report_location(_dx, _dy, _dz, _w2_sum) |
#define | report_new_line() |
Typedefs | |
typedef _Sdata | Sdata_t |
Typedef for struct _Sdata. | |
Functions | |
static __inline int | seed_find (GRBP_gammaAux *gammas, int beg, int end, int max) |
Find the gamma with the highest energy. | |
static __inline double | dot_product (double dx, double dy, double dz, double dx0, double dy0, double dz0) |
Computes the dot product between the specified gamma and the vector as defined by the direction cosines. | |
static __inline double | get_weight2 (double dot, double cutoff_distance, float cutoff_weight2, double one, float c0, float c1, float c2) |
Computes the distance depend weight squared. | |
static __inline void | complete (GRBP_location *loc, double dx0, double dy0, double dz0, double w2_sum) |
Completes the localization process by committing the answer to the GRBP_location structure. | |
static __inline double | normalize (double x, double y, double z, double one) |
Computes, but does not apply, the normalization for the specified unnormalized input vector. The user must multiply each of dx, dy and dz by this factor. | |
static __inline int | converged (double tolerance, double one, double dxn, double dyn, double dzn, double dx0, double dy0, double dz0) |
Checks if the 1 - dot product of the two sets of direction cosines is smaller than the convergence tolerance. | |
void | estimate (double loc[3], const GRBP_gamma *gammas, int beg, int end, int max, double zero, double one) |
Makes an estimate of the position based on the average of the input gammas. | |
void | GRBP_locateAll (GRBP_location *loc, const GRBP_location *guess, GRBP_gammaList *list) |
Calculates the position using only those photons in the energy selected list. | |
void | GRBP_locateSelected (GRBP_location *loc, const GRBP_location *guess, GRBP_gamma *gammas) |
Calculates the position using only those photons in the energy selected list. | |
Variables | |
const Sdata_t | Sdata |
This is ugly, but moving the constants to a static data structure like this improves the performance. |
CVS $Id: GRBP_locate.c,v 1.4 2007/08/10 20:47:53 russell Exp $
|
Completes the localization process by committing the answer to the GRBP_location structure.
|
|
Checks if the 1 - dot product of the two sets of direction cosines is smaller than the convergence tolerance.
|
|
Computes the dot product between the specified gamma and the vector as defined by the direction cosines.
|
|
Makes an estimate of the position based on the average of the input gammas.
|
|
Computes the distance depend weight squared.
1/(acos(dot)**2) = x/2 - 1/12 - x/120 - 31x/15120 ... The first term dominates, so the relevant quantity to measure the error is roughly the ratio of the last term to the first term
last/first = 31x**2/15120 This is largest when x is the largest, i.e. 4.4x10-2, or about 4.x10-6. Therefore, to 5-6 significant decimal digits, the first three terms are sufficient. Use of this expansion is > 5 times faster than calling the acos. The calculation is dominated by the floating point divide. Other than the leading term the remaining terms are essentially 1-3 cycle operations (multiply and add type instructions). A further optimization is to demand that the coefficients by extracted and passed into this routine. Modular coding would dictate that these coefficients be contained in this routine. However, the generated code insists on constantly fetching these values out of memory. By making the coefficients arguments to the routine, the generated PPC code for the expansion is the best that can be gotten.
float x = (one - dot);
8: fc 04 08 28 fsub f0,f4,f1 ; 1 1 - dot
c: fc 00 00 18 frsp f0,f0 ; 1 round to single precision
w2 = c0 / x + c1 + x * (c2);
10: ed a5 00 24 fdivs f13,f5,f0 ; 17 c0/x
14: ed ad 30 2a fadds f13,f13,f6 ; 1 + c1
18: ec 60 69 fa fmadds f3,f0,f7,f13 ; 1 + x * c2
; 21 cycles
|
|
Calculates the position using only those photons in the energy selected list.
|
|
Calculates the position using only those photons in the energy selected list.
|
|
Computes, but does not apply, the normalization for the specified unnormalized input vector. The user must multiply each of dx, dy and dz by this factor.
|
|
Find the gamma with the highest energy.
|
|
Initial value: { 0.0, 1.0, 1.0e-9, CUTOFF_DISTANCE, CUTOFF_WEIGHT2, {1.0/2.0, -1.0/12.0, -1.0/120.0} } To get convergence at the level of an arc minute need at tolerance of ~ 1.0 - cos (1 arcmin) = 4.23e-8, will pick 1e-9. |