Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALApps 10.1.0.1-ea7c608
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
coinj.c
Go to the documentation of this file.
1/**********************************************************************
2* Copyright (C) 2009 John Veitch, Stephen Fairhurst
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 <config.h>
23#include <math.h>
24#include <string.h>
25
26#include <LALAppsVCSInfo.h>
27#include <lal/LALNoiseModels.h>
28#include <lal/LALStdio.h>
29#include <lal/LALgetopt.h>
30#include <lal/LALStdlib.h>
31#include <lal/LIGOLwXML.h>
32#include <lal/LIGOLwXMLRead.h>
33#include <lal/Date.h>
34#include <lal/FindChirp.h>
35#include <lal/Units.h>
36#include <lal/FrequencySeries.h>
37#include <lal/TimeSeries.h>
38#include <lal/TimeFreqFFT.h>
39#include <lal/InspiralInjectionParams.h>
40#include <lal/VectorOps.h>
41#include <lal/LALFrStream.h>
42#include <lal/LALDetectors.h>
43#include <lal/LALFrameIO.h>
44
45#define PROGRAM_NAME "coinj"
46
47#define USAGE \
48"lalpps_coinj [options]\n\
49--help display this message \n\
50--input <injection.xml> Specify input SimInspiralTable xml file\n\
51--output-path OUTPUTPATH directory path where frames are going to be written to\n\
52--skip-ascii-output skip generation of ASCII txt output file\n\
53--response-type TYPE TYPE of injection, [ strain | etmx | etmy ]\n\
54--frames Create h(t) frame files\n\n\
55[--maxSNR snrhigh --minSNR snrlow Adjust injections to have combined SNR between snrlow and snrhigh in the H1H2L1V1 network]\n\
56[--SNR snr adjust distance to get precisely this snr]\n\
57[--GPSstart A --GPSend B Only generate waveforms for injection between GPS seconds A and B (int)]\n\
58[--max-chirp-dist DIST Set the maximum chirp distance in H, L or V to DIST]\n\
59lalapps_coinj: create coherent injection files for LIGO and VIRGO\n"
60
61#ifdef __GNUC__
62#define UNUSED __attribute__ ((unused))
63#else
64#define UNUSED
65#endif
66
67extern int vrbflg;
68
69typedef enum
70{
77
78typedef struct actuationparameters
79{
88
90
91double chirpDist(SimInspiralTable *inj, char ifo);
92double chirpDist(SimInspiralTable *inj, char ifo){
93 /* eff_dist(IFO)*(2.8*0.25^(3/5)/mchirp)^(5/6) */
94 double eff_dist=0.0;
95 if(!inj) {printf("Null pointer passed to chirpDist!\n"); exit(1);}
96 switch (ifo)
97 {
98 case 'H': {eff_dist=inj->eff_dist_h; break;}
99 case 'L': {eff_dist=inj->eff_dist_l; break;}
100 case 'G': {eff_dist=inj->eff_dist_g; break;}
101 case 'T': {eff_dist=inj->eff_dist_t; break;}
102 case 'V': {eff_dist=inj->eff_dist_v; break;}
103 default: {printf("ERROR: Unknown IFO code %c\n",ifo);}
104 }
105 return( eff_dist*pow(1.218/inj->mchirp , (5./6.)));
106}
107
108int main(int argc, char *argv[])
109{
111 CHAR inputfile[FILENAME_MAX];
112 CHAR outputpath[1000];
113 CHAR injtype[30];
114 CHAR det_name[10];
115 INT8 detectorFlags;
116 LIGOTimeGPS inj_epoch;
117 REAL8 deltaT= 1.0/16384.0;
118 REAL8 injLength=100.0; /* Ten seconds at end */
119 REAL8 LeadupTime=95.0;
120 REAL8 dynRange=1.0/3.0e-23;
121 int result;
122
123 UINT4 Nsamples,det_idx,i,inj_num=0;
125 ActuationParametersType actData = {0,0,0,0,0,0,0};
126 ResponseType injectionResponse=noResponse;
127 FILE * outfile;
129 CHAR outfilename[FILENAME_MAX];
130 CHAR fname[FILENAME_MAX];
131
132 const LALUnit strainPerCount={0,{0,0,0,0,0,1,-1},{0,0,0,0,0,0,0}};
133 const LALUnit countPerStrain={0,{0,0,0,0,0,-1,1},{0,0,0,0,0,0,0}};
134 NoiseFunc *PSD = NULL;
135 REAL8 PSDscale=1.0;
136 int c;
137 int repeatLoop=0;
138 int hitTarget=0;
139 SimInspiralTable *injTable=NULL;
140 SimInspiralTable this_injection;
141 SimInspiralTable *headTable=NULL;
142 REAL4TimeSeries *TimeSeries;
143 double max_chirp_dist=0.0;
144
145 REAL4TimeSeries *actuationTimeSeries;
147 COMPLEX8FrequencySeries *actuationResp;
148 COMPLEX8FrequencySeries *transfer;
149 COMPLEX8Vector *unity;
150
151 FrOutPar UNUSED VirgoOutPars;
152 CHAR VirgoParsSource[100];
153 CHAR VirgoParsInfo[100];
154 REAL8 NetworkSNR=0.0;
155 INT4 makeFrames=0;
156 INT4 outputRaw=0;
157 INT4 skipASCIIoutput=0;
159 REAL8 mySNRsq,mySNR;
160 REAL4FFTPlan *fwd_plan;
161 REAL8 minSNR=0.0,maxSNR=0.0;
162 REAL8 UNUSED maxRatio=1.0, UNUSED minRatio=1.0;
163 REAL8 targetSNR=0.0;
164 INT4 GPSstart=0,GPSend=2147483647;
165 int UNUSED SNROK=1;
166 int rewriteXML=0;
167 LALFrameH *frame;
168
169 struct LALoption long_options[]=
170 {
171 {"help", no_argument, 0, 'h'},
172 {"input",required_argument,0, 'i'},
173 {"output-path",required_argument,0,'o'},
174 {"skip-ascii-output",no_argument,&skipASCIIoutput,'A'},
175 {"response-type",required_argument,0,'r'},
176 {"frames",no_argument,&makeFrames,'F'},
177 {"rawstrain",no_argument,&outputRaw,'s'},
178 {"verbose",no_argument,&vrbflg,1},
179 {"minSNR",required_argument,0,2},
180 {"maxSNR",required_argument,0,3},
181 {"SNR",required_argument,0,6},
182 {"GPSstart",required_argument,0,4},
183 {"GPSend",required_argument,0,5},
184 {"max-chirp-dist",required_argument,0,'d'},
185 {0,0,0,0}
186 };
187
188 /*taken from Calibration CVS file:
189 * calibration/frequencydomain/runs/S5/H1/model/V3/H1DARMparams_849677446.m */
197
198 /*taken from Calibration CVS file:
199 * calibration/frequencydomain/runs/S5/H2/model/V3/H2DARMparams_849678155.m */
207
208 /*taken from Calibration CVS file:
209 * calibration/frequencydomain/runs/S5/L1/model/V3/L1DARMparams_841930071.m */
217
218
219/*******************************************************************************/
220
221/* Process input arguments */
222 while(1)
223 {
224 int option_idx=0;
225 c=LALgetopt_long_only(argc,argv,"hFi:d:",long_options,&option_idx);
226 if(c==-1) break;
227 switch(c)
228 {
229 case 'h':
230 fprintf(stderr,USAGE);
231 exit(0);
232 break;
233 case 'i':
234 strncpy(inputfile,LALoptarg,FILENAME_MAX-1);
235 break;
236 case 'o':
237 strncpy(outputpath,LALoptarg,999);
238 break;
239 case 'r':
240 if(!strcmp("strain",LALoptarg)) injectionResponse = unityResponse;
241 else if(!strcmp("etmx",LALoptarg)) injectionResponse = actuationX;
242 else if(!strcmp("etmy",LALoptarg)) injectionResponse = actuationY;
243 else {fprintf(stderr,"Invalid argument to response-type: %s\nResponse type must be strain, etmy or etmx\n", \
244 LALoptarg); exit(1);}
245 break;
246 case 2:
247 minSNR=atof(LALoptarg);
248 fprintf(stderr,"Using minimum SNR of %f\n",minSNR);
249 break;
250 case 3:
251 maxSNR=atof(LALoptarg);
252 fprintf(stderr,"Using maximum SNR of %f\n",maxSNR);
253 break;
254 case 4:
255 GPSstart=atoi(LALoptarg);
256 break;
257 case 5:
258 GPSend=atoi(LALoptarg);
259 break;
260 case 6:
261 targetSNR=atof(LALoptarg);
262 fprintf(stderr,"Target SNR = %lf\n",targetSNR);
263 break;
264 case 'd':
265 max_chirp_dist=atof(LALoptarg);
266 fprintf(stderr,"Using maximum chirp distance of %lf\n",max_chirp_dist);
267 break;
268 }
269 }
270
271 if(minSNR!=0 && maxSNR!=0 && (maxSNR<minSNR)){
272 fprintf(stderr,"Error: minSNR must be less than maxSNR\n");
273 exit(1);
274 if(targetSNR!=0.0 && (targetSNR<minSNR || targetSNR>maxSNR)){
275 fprintf(stderr,"Target SNR %lf is not in range %lf to %lf, ignoring min and max\n",targetSNR,minSNR,maxSNR);
276 }
277 }
278
279 memset(&status,0,sizeof(status));
280
281 /* Read in the input XML */
282 injTable = XLALSimInspiralTableFromLIGOLw(inputfile);
283 headTable=injTable;
284 Nsamples = (UINT4)injLength/deltaT;
285
286 do{
287 memcpy(&this_injection,injTable,sizeof(SimInspiralTable));
288 this_injection.next=NULL;
289 NetworkSNR=0.0;
290 /* Set epoch */
291 memcpy(&inj_epoch,&(this_injection.geocent_end_time),sizeof(LIGOTimeGPS));
292 inj_epoch = this_injection.geocent_end_time;
293 XLALGPSAdd(&inj_epoch, -LeadupTime);
294 inj_epoch.gpsNanoSeconds=0;
295 SNROK=0; /* Reset this to 0 = OK */
296 minRatio=2.0;
297 maxRatio=0.0;
298 repeatLoop=0;
299 /* Loop over detectors */
300 for(det_idx=0;det_idx<LAL_NUM_IFO;det_idx++){
301 /* Only generate within chosen bounds, if specified */
302 if((this_injection.geocent_end_time.gpsSeconds-(int)LeadupTime )<GPSstart || (this_injection.geocent_end_time.gpsSeconds-(int)LeadupTime)>GPSend) continue;
303
304 if(det_idx==LAL_IFO_T1||det_idx==LAL_IFO_G1||det_idx==LAL_IFO_H2) continue; /* Don't generate for GEO or TAMA */
305
306 switch(det_idx)
307 {
308 case LAL_IFO_H1: sprintf(det_name,"H1"); PSD=&LALLIGOIPsd; PSDscale=9E-46; detectorFlags = LAL_LHO_4K_DETECTOR_BIT; break;
309 case LAL_IFO_H2: sprintf(det_name,"H2"); PSD=&LALLIGOIPsd; PSDscale=9E-46; detectorFlags = LAL_LHO_2K_DETECTOR_BIT; break;
310 case LAL_IFO_L1: sprintf(det_name,"L1"); PSD=&LALLIGOIPsd; PSDscale=9E-46; detectorFlags = LAL_LLO_4K_DETECTOR_BIT; break;
311 case LAL_IFO_V1: sprintf(det_name,"V1"); PSD=&LALVIRGOPsd; PSDscale=1.0; detectorFlags = LAL_VIRGO_DETECTOR_BIT; break;
312 case LAL_IFO_G1: sprintf(det_name,"G1"); PSD=&LALGEOPsd; PSDscale=1E-46; detectorFlags = LAL_GEO_600_DETECTOR_BIT; break;
313 case LAL_IFO_T1: sprintf(det_name,"T1"); PSD=&LALTAMAPsd; PSDscale=75E-46; detectorFlags = LAL_TAMA_300_DETECTOR_BIT; break;
314 default: fprintf(stderr,"Unknown IFO\n"); exit(1); break;
315 }
316
317 TimeSeries=XLALCreateREAL4TimeSeries(det_name,&inj_epoch,0.0,deltaT,&lalADCCountUnit,(size_t)Nsamples);
318 for(i=0;i<Nsamples;i++) TimeSeries->data->data[i]=0.0;
319 resp = XLALCreateCOMPLEX8FrequencySeries("response",&inj_epoch,0.0,1.0/injLength,&strainPerCount,(size_t)Nsamples/2+1);
320 for(i=0;i<resp->data->length;i++) {resp->data->data[i] = (REAL4)1.0/dynRange;}
321
322 /* Create h(t) time series for this detector */
323 LAL_CALL( LALFindChirpInjectSignals(&status,TimeSeries,&this_injection,resp) , &status);
324
326
327 if(det_idx==LAL_IFO_V1 && injectionResponse!=unityResponse){
328 actuationTimeSeries=NULL;
329 goto calcSNRandwriteFrames;
330 }
331
332 /* -=-=-=-=-=-=- Prepare actuations -=-=-=-=-=-=- */
333
334 if(injectionResponse==actuationX || injectionResponse==actuationY) actData=actuationParams[det_idx];
335 actuationResp = XLALCreateCOMPLEX8FrequencySeries("actuationResponse",&inj_epoch,0.0,1.0/(2.0*injLength),&strainPerCount,(size_t)Nsamples/2+1);
336 /* Create actuation response */
337 switch(injectionResponse){
338 case unityResponse:
339 sprintf(injtype,"STRAIN");
340 for(i=0;i<actuationResp->data->length;i++){actuationResp->data->data[i] = 1.0;}
341 break;
342 case actuationX:
343 sprintf(injtype,"ETMX");
344 actuationResp=generateActuation(actuationResp,actData.ETMXcal/actData.length,actData.pendFX,actData.pendQX);
345 break;
346 case actuationY:
347 sprintf(injtype,"ETMY");
348 actuationResp=generateActuation(actuationResp,actData.ETMYcal/actData.length,actData.pendFY,actData.pendQY);
349 break;
350 default:
351 fprintf(stderr,"Must specify response function: strain, etmy or etmx\n"); exit(1);
352 break;
353 }
354
355
356
357 if(injectionResponse!=unityResponse) {
358 actuationTimeSeries=XLALCreateREAL4TimeSeries(det_name,&inj_epoch,0.0,deltaT,&lalADCCountUnit,(size_t)Nsamples);
359 unity = XLALCreateCOMPLEX8Vector(actuationResp->data->length);
360 transfer = XLALCreateCOMPLEX8FrequencySeries("transfer",&inj_epoch,0.0,1.0/(2.0*injLength),&countPerStrain,(size_t)Nsamples/2+1);
361 for(i=0;i<unity->length;i++) {unity->data[i] = 1.0;}
362 XLALCCVectorDivide(transfer->data,unity,actuationResp->data);
363 for(i=0;i<Nsamples;i++) actuationTimeSeries->data->data[i]=TimeSeries->data->data[i];
364 actuationTimeSeries = XLALRespFilt(actuationTimeSeries,transfer);
367 for(i=0;i<actuationTimeSeries->data->length;i++) actuationTimeSeries->data->data[i]/=dynRange;
368 }
369 else actuationTimeSeries=TimeSeries;
370
372
373 /* Output the actuation time series */
374 /*sprintf(outfilename,"HWINJ_%i_%s_%i_%s.out",inj_num,injtype,inj_epoch.gpsSeconds,det_name);*/
375 char massBin[5];
376 if(this_injection.mass1<2.0 && this_injection.mass2<2.0) sprintf(massBin,"BNS");
377 else if(this_injection.mass1<2.0 || this_injection.mass2<2.0) sprintf(massBin,"NSBH");
378 else sprintf(massBin,"BBH");
379
380 if (!(skipASCIIoutput)){
381 result = snprintf(outfilename,sizeof(outfilename),"%s%s%i_CBC_%s_%i_%s_%s.txt",outputpath,"/",inj_epoch.gpsSeconds,massBin,inj_num,injtype,det_name);
382 if (result < 0 || (size_t)result > sizeof(outfilename) - 1)
383 {
384 fprintf(stderr, "ERROR: file name too long: '%s'\n", outfilename);
385 exit(1);
386 }
387 outfile=fopen(outfilename,"w");
388 fprintf(stdout,"Injected signal %i for %s into file %s\n",inj_num,det_name,outfilename);
389 for(i=0;i<actuationTimeSeries->data->length;i++) fprintf(outfile,"%10.10e\n",actuationTimeSeries->data->data[i]);
390 fclose(outfile);
391 };
392
393 calcSNRandwriteFrames:
394
395 /* Calculate SNR for this injection */
396 fwd_plan = XLALCreateForwardREAL4FFTPlan( TimeSeries->data->length, 0 );
397 fftData = XLALCreateCOMPLEX8FrequencySeries(TimeSeries->name,&(TimeSeries->epoch),0,1.0/TimeSeries->deltaT,&lalDimensionlessUnit,TimeSeries->data->length/2 +1);
398 XLALREAL4TimeFreqFFT(fftData,TimeSeries,fwd_plan);
399 XLALDestroyREAL4FFTPlan(fwd_plan);
400
401 mySNRsq = 0.0;
402 mySNR=0.0;
403 for(i=1;i<fftData->data->length;i++){
404 REAL8 freq;
405 REAL8 sim_psd_value=0;
406 freq = fftData->deltaF * i;
407 PSD( &status, &sim_psd_value, freq );
408 mySNRsq += crealf(fftData->data->data[i]) * crealf(fftData->data->data[i]) /
409 (sim_psd_value*PSDscale);
410 mySNRsq += cimagf(fftData->data->data[i]) * cimagf(fftData->data->data[i]) /
411 (sim_psd_value*PSDscale);
412 }
413 mySNRsq *= 4.0*fftData->deltaF;
415 if(det_idx==LAL_IFO_H2) mySNRsq/=4.0;
416 mySNR = sqrt(mySNRsq)/dynRange;
417 fprintf(stdout,"SNR in design %s of injection %i = %lf\n",det_name,inj_num,mySNR);
418
419 for(i=0;i<TimeSeries->data->length;i++) {
420 TimeSeries->data->data[i]=TimeSeries->data->data[i]/dynRange +0.0;
421 }
422 NetworkSNR+=mySNR*mySNR;
423
424 if(makeFrames){ /* Also output frames for Virgo */
425 sprintf(VirgoParsSource,"%s-INSP%i",det_name,inj_num);
426 VirgoOutPars.source=VirgoParsSource;
427 sprintf(VirgoParsInfo,"HWINJ-STRAIN");
428 VirgoOutPars.description=VirgoParsInfo;
429 VirgoOutPars.type=ProcDataChannel;
430 VirgoOutPars.nframes=(UINT4)injLength;
431 VirgoOutPars.frame=0;
432 VirgoOutPars.run=2;
433 fprintf(stdout,"Generating frame file for %s-%s-%i\n",VirgoParsSource,VirgoParsInfo,TimeSeries->epoch.gpsSeconds);
434 /* LALFrWriteREAL4TimeSeries(&status,TimeSeries,&VirgoOutPars); */
435 /* define frame */
436 frame = XLALFrameNew( &TimeSeries->epoch, injLength, "HWINJ-STRAIN", 0, 1, detectorFlags );
437 /* add time series as a channel to the frame */
438 XLALFrameAddREAL4TimeSeriesSimData( frame, TimeSeries );
439 /* write frame */
440 result = snprintf(fname,sizeof(fname),"%s%s%s-INSP%i_HWINJ_STRAIN-%i-%i.gwf",outputpath,"/",det_name, inj_num, inj_epoch.gpsSeconds, (UINT4)injLength);
441 if (result < 0 || (size_t)result > sizeof(fname) - 1)
442 {
443 fprintf( stderr, "ERROR: file name too long: '%s'\n", fname );
444 exit( 1 );
445 }
446 /*sprintf(fname, "%s%s%s",outputpath, "/", fname);*/
447 if (XLALFrameWrite( frame, fname) != 0)
448 {
449 fprintf( stderr, "ERROR: Cannot save frame file: '%s'\n", fname );
450 exit( 1 );
451 }
452
453 /* clear frame */
454 XLALFrameFree( frame );
455
456
457 }
458
459 if(TimeSeries==actuationTimeSeries) XLALDestroyREAL4TimeSeries(TimeSeries);
460 else {
461 if(injectionResponse) XLALDestroyREAL4TimeSeries(actuationTimeSeries);
462 XLALDestroyREAL4TimeSeries(TimeSeries);
463 }
464} /* End loop over detectors */
465
466 /*fprintf(stdout,"Finished injecting signal %i, network SNR %f\n",inj_num,sqrt(NetworkSNR));*/
467 NetworkSNR=sqrt(NetworkSNR);
468 if(NetworkSNR!=0.0){ /* Check the SNR if we did this injection */
469 if(targetSNR!=0.0 && repeatLoop==0 && hitTarget==0) {
470 injTable->distance*=(REAL4)(NetworkSNR/targetSNR);
471 injTable->eff_dist_h*=(REAL4)(NetworkSNR/targetSNR);
472 injTable->eff_dist_l*=(REAL4)(NetworkSNR/targetSNR);
473 injTable->eff_dist_v*=(REAL4)(NetworkSNR/targetSNR);
474 injTable->eff_dist_g*=(REAL4)(NetworkSNR/targetSNR);
475 injTable->eff_dist_t*=(REAL4)(NetworkSNR/targetSNR);
476 rewriteXML=1; repeatLoop=1; hitTarget=1;}
477 else {repeatLoop=0; hitTarget=0;}
478 if(targetSNR==0.0 && minSNR>NetworkSNR) {
479 injTable->distance*=(REAL4)(0.99*NetworkSNR/minSNR);
480 injTable->eff_dist_h*=(REAL4)(0.99*NetworkSNR/minSNR);
481 injTable->eff_dist_l*=(REAL4)(0.99*NetworkSNR/minSNR);
482 injTable->eff_dist_v*=(REAL4)(0.99*NetworkSNR/minSNR);
483 injTable->eff_dist_t*=(REAL4)(0.99*NetworkSNR/minSNR);
484 injTable->eff_dist_g*=(REAL4)(0.99*NetworkSNR/minSNR);
485 rewriteXML=1; repeatLoop=1;}
486 else {
487 if(targetSNR==0.0 && maxSNR!=0.0 && maxSNR<NetworkSNR) {
488 injTable->distance*=(1.01*NetworkSNR/maxSNR);
489 injTable->eff_dist_h*=(1.01*NetworkSNR/maxSNR);
490 injTable->eff_dist_l*=(1.01*NetworkSNR/maxSNR);
491 injTable->eff_dist_v*=(1.01*NetworkSNR/maxSNR);
492 injTable->eff_dist_t*=(1.01*NetworkSNR/maxSNR);
493 injTable->eff_dist_g*=(1.01*NetworkSNR/maxSNR);
494 /*injTable->distance+=0.01;*/
495 rewriteXML=1;
496 repeatLoop=1;
497 fprintf(stderr,"Multiplying by %lf to get from %lf to target\n",1.01*(NetworkSNR/maxSNR),NetworkSNR);}
498 }
499 }
500 if(max_chirp_dist!=0.0 && (maxSNR==0 || (maxSNR!=0 && (maxSNR>NetworkSNR) ) ) ){
501 double this_max=0.0;
502 double second_max=0.0;
503 char ifostr[]="HLV";
504 for(int cidx=0;cidx<3;cidx++)
505 {
506 if(this_max<chirpDist(injTable,ifostr[cidx])) this_max=chirpDist(injTable,ifostr[cidx]);
507 }
508 for(int cidx=0;cidx<3;cidx++)
509 if(second_max<chirpDist(injTable,ifostr[cidx]) && chirpDist(injTable,ifostr[cidx])<this_max) second_max=chirpDist(injTable,ifostr[cidx]);
510 if(second_max>max_chirp_dist){
511 injTable->distance*=0.95*(max_chirp_dist/second_max);
512 injTable->eff_dist_h*=0.95*max_chirp_dist/second_max;
513 injTable->eff_dist_l*=0.95*max_chirp_dist/second_max;
514 injTable->eff_dist_v*=0.95*max_chirp_dist/second_max;
515 injTable->eff_dist_t*=0.95*max_chirp_dist/second_max;
516 injTable->eff_dist_g*=0.95*max_chirp_dist/second_max;
517 rewriteXML=1; repeatLoop=1;
518 fprintf(stderr,"MCD: Multiplying distance by %lf to get from %lf to target\n",0.95*max_chirp_dist/second_max,second_max);
519 }
520 }
521 if(repeatLoop==1) fprintf(stderr,"Reinjecting with new distance %f for desired SNR\n\n",injTable->distance);
522
523 if(repeatLoop==0){
524 fprintf(stderr,"\nNetwork SNR of %i = %lf\n",inj_num,NetworkSNR);
525 injTable=injTable->next;
526 inj_num++;
527 }
528
529
530 }while(injTable!=NULL);
531
532 /* If the distances were adjusted, re-write the SimInspiral table */
533 if(rewriteXML){
534 fprintf(stderr,"Overwriting %s with adjusted distances\n",inputfile);
535 inputfile[strlen(inputfile)-4] = 0; /* Cut off the .xml */
536 strncat(inputfile,"_adj.xml",FILENAME_MAX-1);
537 xmlfp=XLALOpenLIGOLwXMLFile(inputfile);
538 if(xmlfp==NULL) fprintf(stderr,"Error! Cannot open %s for writing\n",inputfile);
541 }
542
543 return(0);
544}
void LALFindChirpInjectSignals(LALStatus *status, REAL4TimeSeries *chan, SimInspiralTable *events, COMPLEX8FrequencySeries *resp)
#define LAL_CALL(function, statusptr)
#define ProcDataChannel
int LALgetopt_long_only(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
char * LALoptarg
#define no_argument
#define required_argument
int XLALCloseLIGOLwXMLFile(LIGOLwXMLStream *xml)
LIGOLwXMLStream * XLALOpenLIGOLwXMLFile(const char *path)
int XLALWriteLIGOLwXMLSimInspiralTable(LIGOLwXMLStream *, const SimInspiralTable *)
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *fileName)
LAL_IFO_G1
LAL_NUM_IFO
LAL_IFO_H1
LAL_IFO_H2
LAL_IFO_T1
LAL_IFO_V1
LAL_IFO_L1
#define fprintf
REAL8 dynRange
Definition: blindinj.c:122
ActuationParameters actuationParams[LAL_NUM_IFO]
Definition: blindinj.c:121
int main(int argc, char *argv[])
Definition: coinj.c:108
double chirpDist(SimInspiralTable *inj, char ifo)
Definition: coinj.c:92
#define USAGE
Definition: coinj.c:47
int vrbflg
defined in lal/lib/std/LALError.c
void() NoiseFunc(LALStatus *status, REAL8 *psd, REAL8 f)
Definition: coinj.c:89
ResponseType
Definition: coinj.c:70
@ design
Definition: coinj.c:73
@ actuationX
Definition: coinj.c:74
@ unityResponse
Definition: coinj.c:72
@ noResponse
Definition: coinj.c:71
@ actuationY
Definition: coinj.c:75
static LALUnit strainPerCount
Definition: getresp.c:41
REAL4TimeSeries * XLALRespFilt(REAL4TimeSeries *strain, COMPLEX8FrequencySeries *transfer)
void XLALDestroyCOMPLEX8FrequencySeries(COMPLEX8FrequencySeries *series)
COMPLEX8FrequencySeries * XLALCreateCOMPLEX8FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
COMPLEX8FrequencySeries * generateActuation(COMPLEX8FrequencySeries *resp, REAL4 ETMcal, REAL4 pendF, REAL4 pendQ)
double REAL8
#define XLAL_INIT_DECL(var,...)
int64_t INT8
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
#define LAL_GEO_600_DETECTOR_BIT
#define LAL_LLO_4K_DETECTOR_BIT
#define LAL_TAMA_300_DETECTOR_BIT
#define LAL_VIRGO_DETECTOR_BIT
#define LAL_LHO_2K_DETECTOR_BIT
#define LAL_LHO_4K_DETECTOR_BIT
LALFrameUFrameH LALFrameH
int XLALFrameWrite(LALFrameH *frame, const char *fname)
int XLALFrameAddREAL4TimeSeriesSimData(LALFrameH *frame, const REAL4TimeSeries *series)
LALFrameH * XLALFrameNew(const LIGOTimeGPS *epoch, double duration, const char *project, int run, int frnum, INT8 detectorFlags)
void XLALFrameFree(LALFrameH *frame)
void LALTAMAPsd(LALStatus *status, REAL8 *shf, REAL8 x)
void LALGEOPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
void LALLIGOIPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
void LALVIRGOPsd(LALStatus *status, REAL8 *shf, REAL8 x)
REAL4FFTPlan * XLALCreateForwardREAL4FFTPlan(UINT4 size, int measurelvl)
void XLALDestroyREAL4FFTPlan(REAL4FFTPlan *plan)
int XLALREAL4TimeFreqFFT(COMPLEX8FrequencySeries *freq, const REAL4TimeSeries *tser, const REAL4FFTPlan *plan)
REAL4TimeSeries * XLALCreateREAL4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
void XLALDestroyREAL4TimeSeries(REAL4TimeSeries *series)
const LALUnit lalADCCountUnit
const LALUnit lalDimensionlessUnit
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
void XLALDestroyCOMPLEX8Vector(COMPLEX8Vector *vector)
COMPLEX8Vector * XLALCCVectorDivide(COMPLEX8Vector *out, const COMPLEX8Vector *in1, const COMPLEX8Vector *in2)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
char * ifo
Definition: gwf2xml.c:57
REAL4 minSNR
Definition: inspinj.c:497
static LALStatus status
Definition: inspinj.c:552
REAL4 maxSNR
Definition: inspinj.c:498
int i
Definition: inspinj.c:596
f
c
psd
float freq
LIGOLwXMLStream * xmlfp
Definition: spininj.c:210
CHAR fname[256]
Definition: spininj.c:211
COMPLEX8Sequence * data
COMPLEX8 * data
INT4 gpsNanoSeconds
CHAR name[LALNameLength]
REAL4Sequence * data
LIGOTimeGPS epoch
REAL4 * data
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next
double deltaT