Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
CoarseTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Bernd Machenschalk, David Churches, Duncan Brown, Jolien Creighton, B.S. Sathyaprakash, Thomas Cokelaer
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 * \author Churches, D. K. and Sathyaprakash, B. S., Cokelaer, T
22 * \file
23 * \ingroup LALInspiralBank_h
24 *
25 * \brief Test code for the inspiral modules.
26 *
27 * A template bank can be created either using
28 * a full range for component masses of the binary \f$m_1\f$ and \f$m_2\f$, that is
29 * <tt>(mMin,mMax),</tt> OR minimum value of the component masses \c mMin and
30 * maximum value of the total mass <tt>MMax.</tt> In the first case chirptimes
31 * satisfying the constraint \c mMin\ \f$\le m_1, m_2 \le\f$\ \c mMax are accepted
32 * as valid systems. In the second case chirptimes satisfying the
33 * constraint \c mMin\ \f$\le m_1, m_2,\f$ and \c MMax\f$\le m=m_1+m_2,\f$
34 * are treated as valid. Users are expected to provide both \c mMax and \c MMax.
35 *
36 * For \c LALLIGOIPsd the choice \c mMin\f$=1M_\odot\f$ \c mMax\f$=20 M_\odot\f$
37 * gives 2292 templates, while the same \c mMin but choosing \c MMax\f$=40 M_\odot\f$
38 * instead gives 2512 templates -- about 10\% incrase. However, the extra templates are ALL
39 * short-lived templates and therefore potentially trigger a large number of false alarms,
40 * as noted by Brown in E7 analysis.
41 *
42 * This test code creates a template bank and stores it into CoarseTest.out . Then, it creates
43 * a finer template bank around a sub-set of the original template bank and stores it in the
44 * same output file.
45 *
46 * ### Usage ###
47 *
48 * Input the following values of the InspiralCoarseBankIn structure to
49 * create a template bank:
50 *
51 * <ul>
52 * <li> Minimum component mass in solar masses.
53 * <tt>mMin = 1.0;</tt>
54 *
55 * </li><li> Maximum component mass in solar masses.
56 * <tt>mMax = 20.0;</tt>
57 *
58 * </li><li> Maximum total mass. <tt>This should be specified independently of
59 * whether or not mMax is specified.</tt> It is used in setting up a
60 * rectangular area in the space of chirptimes where the templates will
61 * be laid.
62 * <tt>MMax = 40.0; </tt>
63 *
64 * </li><li> The type of search space.
65 * <tt>massRange = MinComponentMassMaxTotalMass;</tt> OR
66 * <tt>massRange = MinMaxComponentMasses;</tt>
67 *
68 * </li><li> Coarse bank minimal match
69 * <tt>coarseIn->mmCoarse = 0.80;</tt>
70 *
71 * </li><li> Fine bank minimal match
72 * <tt>mmFine = 0.97;</tt>
73 *
74 * </li><li> Lower frequency cutoff
75 * <tt>fLower = 40.;</tt>
76 *
77 * </li><li> Upper frequency cutoff
78 * <tt>fUpper = 1024L;</tt>
79 *
80 * </li><li> Whether or not lso should be used as an upper frequency cutoff
81 * (Currently not used; so please specify \c fUpper.
82 * <tt>coarseIn->iflso = 0;</tt>
83 *
84 * </li><li> Sampling rate
85 * <tt>tSampling = 4000L;</tt>
86 *
87 * </li><li> Space in which templates should be created: whether \f$(\tau_0,\tau_2)\f$
88 * or \f$(\tau_0, \tau_3).\f$
89 * <tt>coarseIn->space = Tau0Tau2;</tt> OR
90 * <tt>coarseIn->space = Tau0Tau3;</tt> OR
91 *
92 * </li><li> Order and type of the approximant to be used in template generation.
93 * These members will NOT be used in creating a template bank but in
94 * filling up the \c InspiralTemplate structure created by the bank.
95 *
96 * <tt>order = twoPN;</tt>
97 * <tt>coarseIn->approximant = TaylorT1;</tt>
98 *
99 * </li><li> minimum value of eta
100 * <tt>etamin = mMin * ( MMax - mMin)/pow(MMax,2.);</tt>
101 *
102 * </li><li> Finally, fill the psd structure (see test code for an example).
103 * This involves allocating memory to vector <tt>shf.data</tt> and filling it with
104 * noise PSD as also choosing the starting frequency and the frequency resolution.
105 * </li>
106 * </ul>
107 *
108 * \code
109 * CoarseTest
110 * \endcode
111 *
112 * ### Description ###
113 *
114 * This test code gives an example of how one calls \c LALInspiralCreateCoarseBank
115 * and \c LALInspiralCreateFineBank modules.
116 *
117 */
118
119/** \cond DONT_DOXYGEN */
120
121#include <stdio.h>
122#include <lal/LALInspiralBank.h>
123#include <lal/LALNoiseModels.h>
124#include <lal/AVFactories.h>
125
126
127/* Nlist = expected number of coarse grid templates; if not sufficient increase */
128
129int
130main ( void )
131{
132 InspiralTemplateList *coarseList=NULL;
133 InspiralTemplateList *fineList=NULL;
134 static LALStatus status;
135 InspiralCoarseBankIn *coarseIn=NULL;
136 InspiralFineBankIn *fineIn=NULL;
137 INT4 i, j, clist=0, flist=0;
138 UINT4 numPSDpts = 262144;
139 void (*noisemodel)(LALStatus*,REAL8*,REAL8) = LALLIGOIPsd;
140 FILE *fpr;
141
142 /* output filename*/
143 fpr = fopen("CoarseTest.out", "w");
144
145 /* define the two template banks*/
148
149 coarseIn->gridSpacing = Hexagonal;
150 /* fill the coarseBankIn structure */
151 coarseIn->mMin = 1.0;
152 coarseIn->mMax = 30.0;
153 coarseIn->MMax = coarseIn->mMax * 2.0;
155 /* coarseIn->massRange = MinMaxComponentMass; */
156 coarseIn->mmCoarse = 0.95;
157 coarseIn->mmFine = 0.97;
158 coarseIn->fLower = 40.;
159 coarseIn->fUpper = 2000;
160 coarseIn->iflso = 0;
161 coarseIn->tSampling = 4096.L;
162 coarseIn->order = LAL_PNORDER_TWO;
163 coarseIn->approximant = TaylorT3;
164 coarseIn->space = Tau0Tau3;
165
166 /* minimum value of eta */
167 coarseIn->etamin = coarseIn->mMin * ( coarseIn->MMax - coarseIn->mMin) /
168 pow(coarseIn->MMax,2.);
169
170 /* fill the psd */
171 memset( &(coarseIn->shf), 0, sizeof(REAL8FrequencySeries) );
172 coarseIn->shf.f0 = 0;
173 LALDCreateVector(&status, &(coarseIn->shf.data), numPSDpts );
174 coarseIn->shf.deltaF = coarseIn->tSampling / ( 2.L * (REAL8) coarseIn->shf.data->length + 1.L);
175 LALNoiseSpectralDensity (&status, coarseIn->shf.data, noisemodel, coarseIn->shf.deltaF );
176
177 /* create and save the coarse bank */
178 coarseIn->iflso = 0.;
179 LALInspiralCreateCoarseBank(&status, &coarseList, &clist, *coarseIn);
180 fprintf(fpr, "#clist=%d\n",clist);
181 for (i=0; i<clist; i++)
182 {
183 fprintf(fpr, "%e %e %e %e %e %e %e\n",
184 coarseList[i].params.t0,
185 coarseList[i].params.t3,
186 coarseList[i].params.t2,
187 coarseList[i].params.totalMass,
188 coarseList[i].params.eta,
189 coarseList[i].params.mass1,
190 coarseList[i].params.mass2);
191 }
192
193 fprintf(fpr, "&\n");
194
195 /* Then creates the finer bank around some of the original template bank*/
196 fineIn->coarseIn = *coarseIn;
197 for (j=0; j<clist; j+=48)
198 {
199 fineIn->templateList = coarseList[j];
200 LALInspiralCreateFineBank(&status, &fineList, &flist, *fineIn);
201 fprintf(fpr, "#flist=%d\n",flist);
202 for (i=0; i<flist; i++) {
203 fprintf(fpr, "%e %e %e %e %e %e %e\n",
204 fineList[i].params.t0,
205 fineList[i].params.t3,
206 fineList[i].params.t2,
207 fineList[i].params.totalMass,
208 fineList[i].params.eta,
209 fineList[i].params.mass1,
210 fineList[i].params.mass2);
211 }
212 if (fineList!=NULL) LALFree(fineList);
213 fineList = NULL;
214 flist = 0;
215 }
216 fclose(fpr);
217 LALDDestroyVector(&status, &(coarseIn->shf.data) );
218 if (fineList!=NULL) LALFree(fineList);
219 if (coarseList!=NULL) LALFree(coarseList);
220 if (coarseIn!=NULL) LALFree(coarseIn);
221 if (fineIn!=NULL) LALFree(fineIn);
223
224 return(0);
225}
226/** \endcond */
void LALCheckMemoryLeaks(void)
#define LALMalloc(n)
#define LALFree(p)
#define fprintf
double i
double REAL8
uint32_t UINT4
int32_t INT4
void LALInspiralCreateFineBank(LALStatus *status, InspiralTemplateList **outlist, INT4 *nlist, InspiralFineBankIn fineIn)
Function to create a fine grid of templates.
void LALInspiralCreateCoarseBank(LALStatus *status, InspiralTemplateList **list, INT4 *nlist, InspiralCoarseBankIn bankIn)
@ MinComponentMassMaxTotalMass
@ Hexagonal
UNDOCUMENTED.
@ Tau0Tau3
space of chirptimes
void LALNoiseSpectralDensity(LALStatus *status, REAL8Vector *psd, void(*NoisePsd)(LALStatus *status, REAL8 *shf, REAL8 f), REAL8 df)
void LALLIGOIPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
TaylorT3
LAL_PNORDER_TWO
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
Input for choosing a template bank.
REAL8 mmFine
Fine grid minimal match.
REAL8 mMin
minimum mass of components to search for
REAL8 mMax
maximum mass of components to search for
InspiralBankMassRange massRange
enum that determines whether templates should be chosen using fixed ranges for component masses or to...
REAL8 tSampling
Sampling rate.
GridSpacing gridSpacing
Type of gridspacing required.
REAL8FrequencySeries shf
Frequency series containing the PSD.
LALPNOrder order
Post-Newtonian order of the waveform.
INT4 iflso
iflso is an integer that tells whether to compute the moments using an upper limit defined by flso; t...
REAL8 MMax
alternatively, maximum total mass of binary to search for
REAL8 etamin
minimum value of eta in our search
REAL8 fUpper
Upper frequency cutoff.
REAL8 fLower
Lower frequency cutoff.
Approximant approximant
Approximant of the waveform.
REAL8 mmCoarse
Coarse grid minimal match.
CoordinateSpace space
enum that decides whether to use or in constructing the template bank
Structure needed by the function LALInspiralCreateFineBank.
InspiralCoarseBankIn coarseIn
input structure that contains useful necessary parameters to construct a fine-mesh
InspiralTemplateList templateList
A list containing all the fine-mesh templates.
A grid of inspiral templates (ie a template list).
REAL8Sequence * data
LALDict * params
int main(int argc, char **argv)
Definition: version.c:32