LALInspiral 5.0.3.1-eeff03c
TrigScanEThincaCommon.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Craig Robinson
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*-----------------------------------------------------------------------
21 *
22 * File Name: TrigScanEThincaCommon.c
23 *
24 * Author: Robinson, C. A. K.
25 *
26 *-----------------------------------------------------------------------
27 */
28
29#include <math.h>
30#include <lal/CoincInspiralEllipsoid.h>
31#include <lal/TrigScanEThincaCommon.h>
32
33/**
34 * \author Robinson, C. A. K.
35 * \file
36 *
37 * \brief Provides helper functions used in TrigScan and E-thinca.
38 *
39 * ### Description ###
40 *
41 * The function <tt>XLALCreateTriggerErrorList()</tt> creates a linked list of
42 * structures pointing to the trigger and their associated position vector and
43 * shape matrix. If required, the maximum difference in tC associated with the
44 * triggers in the list of \c SnglInspiralTable's will be passed back in
45 * \c tcMax.
46 *
47 * The function <tt>XLALDestroyTriggerErrorList()</tt> frees all memory associated
48 * with the \c TriggerErrorList, with the exception of the wrapped
49 * \c SnglInspiralTable's, which will normally still be required after
50 * TrigScan and E-thinca have completed.
51 *
52 */
53
55 REAL8 scaleFactor,
56 REAL8 *tcMax )
57
58{
59 REAL8 timeError = 0.0;
60
61 TriggerErrorList *errorListHead = NULL;
62 TriggerErrorList *thisErrorList = NULL;
63
64 SnglInspiralTable *currentTrigger = NULL;
65
66 if ( !tableHead )
68
69 if ( scaleFactor <= 0 )
71
72 /* Loop through triggers and assign each of them an error ellipsoid */
73 for (currentTrigger = tableHead; currentTrigger;
74 currentTrigger = currentTrigger->next)
75 {
76 REAL8 thisTimeError;
77
78 if (!errorListHead)
79 {
80 errorListHead = (TriggerErrorList *) LALCalloc(1, sizeof(TriggerErrorList));
81 thisErrorList = errorListHead;
82 }
83 else
84 {
85 thisErrorList->next = (TriggerErrorList *) LALCalloc(1, sizeof(TriggerErrorList));
86 thisErrorList = thisErrorList->next;
87 }
88 if ( !thisErrorList )
89 {
90 XLALDestroyTriggerErrorList( errorListHead );
92 }
93
94 thisErrorList->trigger = currentTrigger;
95 thisErrorList->err_matrix = XLALGetErrorMatrixFromSnglInspiral( currentTrigger,
96 scaleFactor );
97 if ( !thisErrorList->err_matrix )
98 {
99 XLALDestroyTriggerErrorList( errorListHead );
101 }
102
103 thisErrorList->position = XLALGetPositionFromSnglInspiral( currentTrigger );
104 if ( !thisErrorList->position )
105 {
106 XLALDestroyTriggerErrorList( errorListHead );
108 }
109 thisTimeError = XLALSnglInspiralTimeError(currentTrigger, scaleFactor );
110 if (thisTimeError > timeError)
111 {
112 timeError = thisTimeError;
113 }
114 }
115
116 /* Set the max timing error if required and return the list */
117 if ( tcMax ) *tcMax = timeError;
118 return errorListHead;
119}
120
121
123
124{
125
126 TriggerErrorList *thisErrorList;
127
128 thisErrorList = errorListHead;
129 while (thisErrorList)
130 {
131 errorListHead = thisErrorList->next;
132 if ( thisErrorList->err_matrix )
133 gsl_matrix_free( thisErrorList->err_matrix );
134
135 if ( thisErrorList->position )
136 gsl_vector_free( thisErrorList->position );
137
138 LALFree( thisErrorList );
139 thisErrorList = errorListHead;
140 }
141}
142
143
144/**
145 * Using the waveform metric components, translate an "e-thinca" treshold
146 * into a \f$\Delta t\f$ error interval.
147 */
148
149
151{
152 REAL8 a11 = table->Gamma[0] / eMatch;
153 REAL8 a12 = table->Gamma[1] / eMatch;
154 REAL8 a13 = table->Gamma[2] / eMatch;
155 REAL8 a22 = table->Gamma[3] / eMatch;
156 REAL8 a23 = table->Gamma[4] / eMatch;
157 REAL8 a33 = table->Gamma[5] / eMatch;
158 REAL8 x;
159 REAL8 denom;
160
161 x = (a23 * a23 - a22 * a33) * a22;
162 denom = (a12*a23 - a22*a13) * (a12*a23 - a22*a13)
163 - (a23*a23 - a22*a33) * (a12*a12 - a22*a11);
164
165 if (denom == 0)
167 if ((x < 0) ^ (denom < 0))
169
170 return sqrt( x / denom );
171}
#define LALCalloc(m, n)
#define LALFree(p)
gsl_matrix * XLALGetErrorMatrixFromSnglInspiral(SnglInspiralTable *event, REAL8 eMatch)
gsl_vector * XLALGetPositionFromSnglInspiral(SnglInspiralTable *table)
double REAL8
REAL8 XLALSnglInspiralTimeError(const SnglInspiralTable *table, REAL8 eMatch)
Using the waveform metric components, translate an "e-thinca" treshold into a error interval.
TriggerErrorList * XLALCreateTriggerErrorList(SnglInspiralTable *tableHead, REAL8 scaleFactor, REAL8 *tcMax)
void XLALDestroyTriggerErrorList(TriggerErrorList *errorListHead)
#define XLAL_ERROR_REAL8(...)
#define XLAL_ERROR_NULL(...)
XLAL_ENOMEM
XLAL_EFPINVAL
XLAL_EFAULT
XLAL_EFUNC
XLAL_EINVAL
XLAL_EFPDIV0
x
struct tagSnglInspiralTable * next
The TriggerErrorList is a linked list used within e-thinca.
struct tagTriggerErrorList * next
SnglInspiralTable * trigger