LALApps 10.1.0.1-eeff03c
effdist.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Patrick Brady, Reinhard Prix, 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#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <math.h>
24#include <lal/LALConstants.h>
25
26#define NLINES 16000
27#define SNR 8.0
28
29#define USAGE "Usage: %s [options]\n"\
30 "--help Print this help message\n" \
31 "--masses m1 m1 Masses of binary elements\n" \
32 "--spectrum filename File containing amplitude spectrum m/rtHz \n" \
33 "--length arm_length Length of the arm in meters \n" \
34
35int main ( int argc, char *argv[])
36{
37 FILE *fpin = NULL;
38 int i,nlines=NLINES,arg=1,record=0;
39 float f[NLINES],amp[NLINES],dum1;
40 float m1, m2, eta, mtot, mu, arm_length=1.0;
41 float ins_amp,d_optimal;
42
43 m1 = m2 = 1.4;
44
45 /*******************************************************************
46 * PARSE ARGUMENTS (arg stores the current position) *
47 *******************************************************************/
48
49 if (argc <= 1){
50 fprintf(stderr, USAGE, *argv );
51 return 0;
52 }
53
54 while ( arg < argc ) {
55 /*********************************************************
56 * File containing veto information metadata
57 *********************************************************/
58 if ( !strcmp( argv[arg], "--help" ) ) {
59 fprintf(stderr, USAGE, *argv );
60 return 0;
61 }
62 /*********************************************************
63 * Masses
64 *********************************************************/
65 else if ( !strcmp( argv[arg], "--masses" ) ) {
66 arg++;
67 m1 = atof(argv[arg++]);
68 m2 = atof(argv[arg++]);
69 }
70 /*********************************************************
71 * Armlength
72 *********************************************************/
73 else if ( !strcmp( argv[arg], "--length" ) ) {
74 arg++;
75 arm_length = atof(argv[arg++]);
76 }
77 /*********************************************************
78 * Spectrum [m / sqert(Hz)]
79 *********************************************************/
80 else if ( !strcmp( argv[arg], "--spectrum" ) ) {
81 arg++;
82 fpin=fopen(argv[arg++],"r");
83 }
84 /*********************************************************
85 * Switch to generate output for plotting later
86 *********************************************************/
87 else if ( !strcmp( argv[arg], "--record" ) ) {
88 arg++;
89 record=1;
90 }
91 /* Check for unrecognized options. */
92 else if ( argv[arg][0] == '-' ) {
93 fprintf(stderr, USAGE, *argv );
94 return 1;
95 }
96 } /* End of argument parsing loop. */
97
98
99 /* Compute the inspiral parameters */
100 mtot = m1+m2;
101 eta = m1*m2/(mtot*mtot);
102 mu = eta * mtot;
103 ins_amp = (LAL_MTSUN_SI * LAL_C_SI / (1.0e6 * LAL_PC_SI))
104 * sqrt( 5.0*mu / 96.0 ) * ( pow( mtot/(LAL_PI*LAL_PI) , 0.33333 ) /
105 pow(LAL_MTSUN_SI, 1.0 / 6.0) ) ;
106
107 /* Do the integral over frequency */
108 dum1=0;
109 for(i=1;i<nlines;i++){
110 if ( fscanf(fpin,"%f %f",&f[i],&amp[i]) == EOF )
111 break;
112 dum1+=pow(f[i],-7.0/3.0)/(amp[i]*amp[i]);
113 /* Assume ISCO is at 200 (20 Msun / mtot) Hz */
114 if (f[i] * mtot > 4000)
115 break;
116 }
117
118 /* print the information to stderr */
119 d_optimal= arm_length*ins_amp*sqrt(2.0 * dum1)/SNR;
120 fprintf(stderr,"Sensitive to optimally oriented binary at %0.4f Mpc\n",
121 d_optimal);
122 fprintf(stderr,"Effective sensitivity over sky %0.4f Mpc\n",
123 d_optimal/sqrt(5.0));
124
125 /* and to stdout if desired */
126 if ( record ){
127 fprintf(stdout,"%f %f\n",mtot,d_optimal);
128 }
129
130 return 1;
131}
#define fscanf
#define fprintf
int main(int argc, char *argv[])
Definition: effdist.c:35
#define USAGE
Definition: effdist.c:29
#define NLINES
Definition: effdist.c:26
#define SNR
Definition: effdist.c:27
#define LAL_PI
#define LAL_MTSUN_SI
#define LAL_PC_SI
int i
Definition: inspinj.c:596
list mu
f
eta
m2
m1
int LAL_C_SI