00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <config.h>
00034
00035 #if !defined HAVE_GSL_GSL_FFT_REAL_H || !defined HAVE_LIBGSL
00036 int main( void ) { fprintf( stderr, "no gsl: disabled\n" ); return 77; }
00037 #else
00038
00039 #include <math.h>
00040 #include <ctype.h>
00041 #include <assert.h>
00042 #include <string.h>
00043 #include <getopt.h>
00044 #include <time.h>
00045 #include <lalapps.h>
00046 #include <processtable.h>
00047 #include <gsl/gsl_errno.h>
00048 #include <gsl/gsl_math.h>
00049 #include <gsl/gsl_roots.h>
00050 #include <lal/LALStdio.h>
00051 #include <lal/LALStdlib.h>
00052 #include <lal/LALConstants.h>
00053 #include <lal/LIGOMetadataTables.h>
00054 #include <lal/LIGOMetadataUtils.h>
00055 #include <lal/LIGOLwXML.h>
00056 #include <lal/Date.h>
00057 #include <lal/SkyCoordinates.h>
00058 #include <lal/GeneratePPNInspiral.h>
00059 #include <lal/GenerateInspiral.h>
00060 #include <lal/DetectorSite.h>
00061 #include <lal/DetResponse.h>
00062 #include <lal/TimeDelay.h>
00063
00064 RCSID( "$Id: bbhinj.c,v 1.19 2007/06/21 22:59:06 dkeppel Exp $" );
00065 #define CVS_ID_STRING "$Id: bbhinj.c,v 1.19 2007/06/21 22:59:06 dkeppel Exp $"
00066 #define CVS_NAME_STRING "$Name: $"
00067 #define CVS_REVISION "$Revision: 1.19 $"
00068 #define CVS_SOURCE "$Source: /usr/local/cvs/lscsoft/lalapps/src/inspiral/bbhinj.c,v $"
00069 #define CVS_DATE "$Date: 2007/06/21 22:59:06 $"
00070 #define PROGRAM_NAME "bbhinj"
00071
00072 #define USAGE \
00073 "lalapps_bbhinj [options]\n"\
00074 "\nDefaults are shown in brackets\n\n" \
00075 " --help display this message\n"\
00076 " --version print version information and exit\n"\
00077 " --verbose print mass and galactocentic cartesian coordinates\n"\
00078 " --write-compress write a compressed xml file\n"\
00079 " --f-lower FREQUENCY lower cut-off frequency.\n"\
00080 " If so, LAL code will use 40Hz by default.\n"\
00081 " --gps-start-time TIME start injections at GPS time TIME (729273613)\n"\
00082 " --gps-end-time TIME end injections at GPS time TIME (734367613)\n"\
00083 " --time-step STEP space injections by ave of STEP sec (2630/PI)\n"\
00084 " --time-interval TIME distribute injections in interval TIME (0)\n"\
00085 " --seed SEED seed random number generator with SEED (1)\n"\
00086 " --user-tag STRING set the usertag to STRING\n"\
00087 " --min-mass MIN set the minimum component mass to MIN (3.0)\n"\
00088 " --max-mass MAX set the maximum component mass to MAX (20.0)\n"\
00089 " --max-total-mass TOTAL set the total mass of the two components\n"\
00090 " --min-distance DMIN set the minimum distance to DMIN kpc (1)\n"\
00091 " --max-distance DMAX set the maximum distance to DMAX kpc (20000)\n"\
00092 " --d-distr DDISTR distribute injections uniformly over\n"\
00093 " d (DDISTR = 0), or over log10(d) (DDISTR = 1)\n"\
00094 " or over volume (DDISTR = 2)\n"\
00095 " (default: DDISTR = 0)\n"\
00096 " --m-distr MDISTR distribute injections uniformly over\n"\
00097 " total mass (MDISTR = 0), or over mass1 and\n"\
00098 " over mass2 (MDISTR = 1) (default: MDISTR=0)\n"\
00099 " --waveform WVF set the injection waveform to WVF\n"\
00100 " (EOB, GeneratePPN, TaylorT1, TaylorT3,PadeT1);\n"\
00101 " followed by the order (newtonian, onePN,\n"\
00102 " onePointFivePN, twoPN, twoPointFivePN, threePN)\n"\
00103 " (default: EOBtwoPN)\n"\
00104 "\n"
00105
00106
00107 #define S2StartTime 729273613
00108 #define S2StopTime 734367613
00109
00110 static ProcessParamsTable *next_process_param(
00111 const char *name,
00112 const char *type,
00113 const char *fmt, ... );
00114
00115 extern int vrbflg;
00116
00117
00118 ProcessParamsTable *next_process_param(
00119 const char *name,
00120 const char *type,
00121 const char *fmt, ... )
00122 {
00123 ProcessParamsTable *pp;
00124 va_list ap;
00125 pp = calloc( 1, sizeof( *pp ) );
00126
00127 if ( ! pp )
00128 {
00129 perror( "next_process_param" );
00130 exit( 1 );
00131 }
00132 strncpy( pp->program, PROGRAM_NAME, LIGOMETA_PROGRAM_MAX );
00133 if ( ! strcmp( name, "userTag" ) || ! strcmp( name, "user-tag" ) )
00134 LALSnprintf( pp->param, LIGOMETA_PARAM_MAX, "-userTag" );
00135 else
00136 LALSnprintf( pp->param, LIGOMETA_PARAM_MAX, "--%s", name );
00137 strncpy( pp->type, type, LIGOMETA_TYPE_MAX );
00138 va_start( ap, fmt );
00139 LALVsnprintf( pp->value, LIGOMETA_VALUE_MAX, fmt, ap );
00140 va_end( ap );
00141
00142 return pp;
00143 }
00144
00145
00146 int main( int argc, char *argv[] )
00147 {
00148 LALStatus status = blank_status;
00149 LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE;
00150 #if 0
00151 const INT4 S2StartTime = 729273613;
00152 const INT4 S2StopTime = 734367613;
00153 #endif
00154
00155 LIGOTimeGPS gpsStartTime = {S2StartTime, 0};
00156 LIGOTimeGPS gpsEndTime = {S2StopTime, 0};
00157 REAL8 meanTimeStep = 2630 / LAL_PI;
00158 REAL8 timeInterval = 0;
00159 UINT4 randSeed = 1;
00160 CHAR *userTag = NULL;
00161 REAL4 minMass = 3.0;
00162 REAL4 maxMass = 20.0;
00163 REAL4 sumMaxMass = 0.0;
00164 UINT4 sumMaxMassUse=0;
00165 REAL4 dmin = 1.0;
00166 REAL4 dmax = 20000.0 ;
00167 REAL4 fLower = 0;
00168
00169 UINT4 ddistr = 0, mdistr=0;
00170
00171
00172 RandomParams *randParams = NULL;
00173 REAL4 u, exponent, d2;
00174 REAL4 deltaM, mtotal;
00175
00176 LALMSTUnitsAndAcc gmstUnits = { MST_HRS, LALLEAPSEC_STRICT };
00177
00178
00179
00180
00181 CHAR waveform[LIGOMETA_WAVEFORM_MAX];
00182
00183 #if 0
00184 int i, stat;
00185
00186 double d, cosphi, sinphi;
00187 #endif
00188
00189
00190 LALGPSCompareResult compareGPS;
00191
00192
00193 CHAR fname[256];
00194 MetadataTable proctable;
00195 MetadataTable procparams;
00196 MetadataTable injections;
00197 ProcessParamsTable *this_proc_param;
00198 SimInspiralTable *this_inj = NULL;
00199 LIGOLwXMLStream xmlfp;
00200 UINT4 outCompress = 0;
00201
00202
00203 struct option long_options[] =
00204 {
00205 {"help", no_argument, 0, 'h'},
00206 {"verbose", no_argument, &vrbflg, 1 },
00207 {"write-compress", no_argument, &outCompress, 1 },
00208 {"version", no_argument, 0, 'V'},
00209 {"f-lower", required_argument, 0, 'f'},
00210 {"gps-start-time", required_argument, 0, 'a'},
00211 {"gps-end-time", required_argument, 0, 'b'},
00212 {"time-step", required_argument, 0, 't'},
00213 {"time-interval", required_argument, 0, 'i'},
00214 {"seed", required_argument, 0, 's'},
00215 {"min-mass", required_argument, 0, 'A'},
00216 {"max-mass", required_argument, 0, 'B'},
00217 {"max-total-mass", required_argument, 0, 'x'},
00218 {"min-distance", required_argument, 0, 'p'},
00219 {"max-distance", required_argument, 0, 'r'},
00220 {"d-distr", required_argument, 0, 'd'},
00221 {"m-distr", required_argument, 0, 'm'},
00222 {"waveform", required_argument, 0, 'w'},
00223 {"debug-level", required_argument, 0, 'z'},
00224 {"user-tag", required_argument, 0, 'Z'},
00225 {"userTag", required_argument, 0, 'Z'},
00226 {0, 0, 0, 0}
00227 };
00228 int c;
00229
00230
00231 lal_errhandler = LAL_ERR_EXIT;
00232 set_debug_level( "1" );
00233
00234
00235
00236 proctable.processTable = (ProcessTable *)
00237 calloc( 1, sizeof(ProcessTable) );
00238 LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time),
00239 &accuracy ), &status );
00240 LAL_CALL( populate_process_table( &status, proctable.processTable,
00241 PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE ), &status );
00242 LALSnprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " );
00243 this_proc_param = procparams.processParamsTable = (ProcessParamsTable *)
00244 calloc( 1, sizeof(ProcessParamsTable) );
00245
00246
00247 memset( waveform, 0, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR) );
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 while ( 1 )
00258 {
00259
00260 int option_index = 0;
00261 long int gpsinput;
00262 size_t optarg_len;
00263
00264 c = getopt_long_only( argc, argv,
00265 "a:A:b:B:d:f:hi:m:p:q:r:s:t:vz:Z:w:", long_options, &option_index );
00266
00267
00268 if ( c == - 1 )
00269 {
00270 break;
00271 }
00272
00273 switch ( c )
00274 {
00275 case 0:
00276
00277 if ( long_options[option_index].flag != 0 )
00278 {
00279 break;
00280 }
00281 else
00282 {
00283 fprintf( stderr, "error parsing option %s with argument %s\n",
00284 long_options[option_index].name, optarg );
00285 exit( 1 );
00286 }
00287 break;
00288
00289 case 'a':
00290 gpsinput = atol( optarg );
00291 if ( gpsinput < 441417609 )
00292 {
00293 fprintf( stderr, "invalid argument to --%s:\n"
00294 "GPS start time is prior to "
00295 "Jan 01, 1994 00:00:00 UTC:\n"
00296 "(%ld specified)\n",
00297 long_options[option_index].name, gpsinput );
00298 exit( 1 );
00299 }
00300 if ( gpsinput > 999999999 )
00301 {
00302 fprintf( stderr, "invalid argument to --%s:\n"
00303 "GPS start time is after "
00304 "Sep 14, 2011 01:46:26 UTC:\n"
00305 "(%ld specified)\n",
00306 long_options[option_index].name, gpsinput );
00307 exit( 1 );
00308 }
00309 gpsStartTime.gpsSeconds = gpsinput;
00310
00311 this_proc_param = this_proc_param->next =
00312 next_process_param( long_options[option_index].name, "int",
00313 "%ld", gpsinput );
00314 break;
00315
00316 case 'b':
00317 gpsinput = atol( optarg );
00318 if ( gpsinput < 441417609 )
00319 {
00320 fprintf( stderr, "invalid argument to --%s:\n"
00321 "GPS start time is prior to "
00322 "Jan 01, 1994 00:00:00 UTC:\n"
00323 "(%ld specified)\n",
00324 long_options[option_index].name, gpsinput );
00325 exit( 1 );
00326 }
00327 if ( gpsinput > 999999999 )
00328 {
00329 fprintf( stderr, "invalid argument to --%s:\n"
00330 "GPS start time is after "
00331 "Sep 14, 2011 01:46:26 UTC:\n"
00332 "(%ld specified)\n",
00333 long_options[option_index].name, gpsinput );
00334 exit( 1 );
00335 }
00336 gpsEndTime.gpsSeconds = gpsinput;
00337 this_proc_param = this_proc_param->next =
00338 next_process_param( long_options[option_index].name, "int",
00339 "%ld", gpsinput );
00340 break;
00341
00342 case 'f':
00343 fLower = atof( optarg );
00344 this_proc_param = this_proc_param->next =
00345 next_process_param( long_options[option_index].name, "float",
00346 "%f", fLower );
00347 break;
00348
00349 case 's':
00350 randSeed = atoi( optarg );
00351 this_proc_param = this_proc_param->next =
00352 next_process_param( long_options[option_index].name, "int",
00353 "%d", randSeed );
00354 break;
00355
00356 case 't':
00357 meanTimeStep = (REAL8) atof( optarg );
00358 if ( meanTimeStep <= 0 )
00359 {
00360 fprintf( stderr, "invalid argument to --%s:\n"
00361 "time step must be > 0: (%e seconds specified)\n",
00362 long_options[option_index].name, meanTimeStep );
00363 exit( 1 );
00364 }
00365 this_proc_param = this_proc_param->next =
00366 next_process_param( long_options[option_index].name, "float",
00367 "%e", meanTimeStep );
00368 break;
00369
00370 case 'i':
00371 timeInterval = atof( optarg );
00372 if ( timeInterval < 0 )
00373 {
00374 fprintf( stderr, "invalid argument to --%s:\n"
00375 "time interval must be >= 0: (%e seconds specified)\n",
00376 long_options[option_index].name, meanTimeStep );
00377 exit( 1 );
00378 }
00379 this_proc_param = this_proc_param->next =
00380 next_process_param( long_options[option_index].name,
00381 "float", "%e", timeInterval );
00382 break;
00383
00384 case 'A':
00385
00386 minMass = (REAL4) atof( optarg );
00387 if ( minMass <= 0 )
00388 {
00389 fprintf( stderr, "invalid argument to --%s:\n"
00390 "miniumum component mass must be > 0: "
00391 "(%f solar masses specified)\n",
00392 long_options[option_index].name, minMass );
00393 exit( 1 );
00394 }
00395 this_proc_param = this_proc_param->next =
00396 next_process_param( long_options[option_index].name,
00397 "float", "%e", minMass );
00398 break;
00399
00400 case 'B':
00401
00402 maxMass = (REAL4) atof( optarg );
00403 if ( maxMass <= 0 )
00404 {
00405 fprintf( stderr, "invalid argument to --%s:\n"
00406 "maxiumum component mass must be > 0: "
00407 "(%f solar masses specified)\n",
00408 long_options[option_index].name, maxMass );
00409 exit( 1 );
00410 }
00411 this_proc_param = this_proc_param->next =
00412 next_process_param( long_options[option_index].name,
00413 "float", "%e", maxMass );
00414 break;
00415
00416 case 'x':
00417
00418 sumMaxMass = (REAL4) atof( optarg );
00419 if ( sumMaxMass <= 0 )
00420 {
00421 fprintf( stderr, "invalid argument to --%s:\n"
00422 "sum of two component masses must be > 0: "
00423 "(%f solar masses specified)\n",
00424 long_options[option_index].name, sumMaxMass );
00425 exit( 1 );
00426 }
00427 sumMaxMassUse=1;
00428 this_proc_param = this_proc_param->next =
00429 next_process_param( long_options[option_index].name,
00430 "float", "%e", sumMaxMass );
00431 break;
00432
00433 case 'p':
00434
00435 dmin = (REAL4) atof( optarg );
00436 if ( dmin <= 0 )
00437 {
00438 fprintf( stderr, "invalid argument to --%s:\n"
00439 "minimum distance must be > 0: "
00440 "(%f kpc specified)\n",
00441 long_options[option_index].name, dmin );
00442 exit( 1 );
00443 }
00444 this_proc_param = this_proc_param->next =
00445 next_process_param( long_options[option_index].name,
00446 "float", "%e", dmin );
00447 break;
00448
00449 case 'r':
00450
00451 dmax = (REAL4) atof( optarg );
00452 if ( dmax <= 0 )
00453 {
00454 fprintf( stderr, "invalid argument to --%s:\n"
00455 "maximum distance must be greater than 0: "
00456 "(%f kpc specified)\n",
00457 long_options[option_index].name, dmax );
00458 exit( 1 );
00459 }
00460 this_proc_param = this_proc_param->next =
00461 next_process_param( long_options[option_index].name,
00462 "float", "%e", dmax );
00463 break;
00464
00465 case 'd':
00466 ddistr = (UINT4) atoi( optarg );
00467 if ( ddistr != 0 && ddistr != 1 && ddistr != 2)
00468 {
00469 fprintf( stderr, "invalid argument to --%s:\n"
00470 "DDISTR must be either 0 or 1 or 2\n",
00471 long_options[option_index].name);
00472 exit(1);
00473 }
00474 this_proc_param = this_proc_param->next =
00475 next_process_param( long_options[option_index].name,
00476 "int", "%d", ddistr );
00477
00478 break;
00479
00480 case 'm':
00481 mdistr = (UINT4) atoi( optarg );
00482 if ( mdistr != 0 && mdistr != 1 )
00483 {
00484 fprintf( stderr, "invalid argument to --%s:\n"
00485 "MDISTR must be either 0 or 1\n",
00486 long_options[option_index].name);
00487 exit(1);
00488 }
00489 this_proc_param = this_proc_param->next =
00490 next_process_param( long_options[option_index].name,
00491 "int", "%d", mdistr );
00492
00493
00494 break;
00495
00496 case 'Z':
00497
00498 optarg_len = strlen( optarg ) + 1;
00499 userTag = (CHAR *) calloc( optarg_len, sizeof(CHAR) );
00500 memcpy( userTag, optarg, optarg_len );
00501 this_proc_param = this_proc_param->next =
00502 next_process_param( long_options[option_index].name,
00503 "string", "%s", optarg );
00504 break;
00505
00506 case 'w':
00507 LALSnprintf( waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), "%s",
00508 optarg);
00509 this_proc_param = this_proc_param->next =
00510 next_process_param( long_options[option_index].name, "string",
00511 "%s", optarg);
00512 break;
00513
00514 case 'z':
00515 set_debug_level( optarg );
00516 this_proc_param = this_proc_param->next =
00517 next_process_param( long_options[option_index].name,
00518 "string", "%s", optarg );
00519 break;
00520
00521 case 'V':
00522
00523 fprintf( stdout, "Binary Black Hole INJection generation routine\n"
00524 "Duncan A Brown and Eirini Messaritaki\n"
00525 "CVS Version: " CVS_ID_STRING "\n"
00526 "CVS Tag: " CVS_NAME_STRING "\n" );
00527 exit( 0 );
00528 break;
00529
00530 case 'h':
00531 case '?':
00532 fprintf( stderr, USAGE );
00533 exit( 0 );
00534 break;
00535
00536 default:
00537 fprintf( stderr, "unknown error while parsing options\n" );
00538 fprintf( stderr, USAGE );
00539 exit( 1 );
00540 }
00541 }
00542
00543 if ( optind < argc )
00544 {
00545 fprintf( stderr, "extraneous command line arguments:\n" );
00546 while ( optind < argc )
00547 {
00548 fprintf ( stderr, "%s\n", argv[optind++] );
00549 }
00550 exit( 1 );
00551 }
00552
00553
00554 if ( !*waveform )
00555 {
00556
00557 LALSnprintf( waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR),
00558 "EOBtwoPN");
00559 }
00560
00561 if ( !fLower )
00562 {
00563 fprintf( stderr, "--f-lower must be specified and non-zero\n" );
00564 exit( 1 );
00565 }
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575 LAL_CALL( LALCreateRandomParams( &status, &randParams, randSeed ), &status );
00576
00577
00578 deltaM = maxMass - minMass;
00579
00580
00581 injections.simInspiralTable = NULL;
00582
00583
00584 if ( userTag && outCompress )
00585 {
00586 LALSnprintf( fname, sizeof(fname), "HL-INJECTIONS_%d_%s-%d-%d.xml.gz",
00587 randSeed, userTag, gpsStartTime.gpsSeconds,
00588 gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds );
00589 }
00590 else if ( userTag && !outCompress )
00591 {
00592 LALSnprintf( fname, sizeof(fname), "HL-INJECTIONS_%d_%s-%d-%d.xml",
00593 randSeed, userTag, gpsStartTime.gpsSeconds,
00594 gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds );
00595 }
00596 else if ( !userTag && outCompress )
00597 {
00598 LALSnprintf( fname, sizeof(fname), "HL-INJECTIONS_%d-%d-%d.xml.gz",
00599 randSeed, gpsStartTime.gpsSeconds,
00600 gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds );
00601 }
00602 else
00603 {
00604 LALSnprintf( fname, sizeof(fname), "HL-INJECTIONS_%d-%d-%d.xml",
00605 randSeed, gpsStartTime.gpsSeconds,
00606 gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds );
00607 }
00608
00609
00610 LAL_CALL( LALCompareGPS( &status, &compareGPS, &gpsStartTime, &gpsEndTime ),
00611 &status );
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621 while ( compareGPS == LALGPS_EARLIER )
00622 {
00623
00624
00625
00626 #if 0
00627 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00628 galacticPar.lGal = LAL_TWOPI * u;
00629
00630 galacticPar.z = r * sinphi ;
00631 galacticPar.rho = 0.0 - Rcore * cos(galacticPar.lGal) +
00632 sqrt( r * r - galacticPar.z * galacticPar.z -
00633 Rcore * Rcore * sin(galacticPar.lGal) * sin(galacticPar.lGal) );
00634 #endif
00635
00636 #if 0
00637 if ( vrbflg ) fprintf( stdout, "%e %e %e %e %e\n",
00638 galacticPar.m1, galacticPar.m2,
00639 galacticPar.rho * cos( galacticPar.lGal ),
00640 galacticPar.rho * sin( galacticPar.lGal ),
00641 galacticPar.z );
00642 #endif
00643
00644
00645 if ( injections.simInspiralTable )
00646 {
00647 this_inj = this_inj->next = (SimInspiralTable *)
00648 LALCalloc( 1, sizeof(SimInspiralTable) );
00649 }
00650 else
00651 {
00652 injections.simInspiralTable = this_inj = (SimInspiralTable *)
00653 LALCalloc( 1, sizeof(SimInspiralTable) );
00654 }
00655
00656
00657
00658 this_inj->geocent_end_time = gpsStartTime;
00659 if ( timeInterval )
00660 {
00661 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00662 LAL_CALL( LALAddFloatToGPS( &status, &(this_inj->geocent_end_time),
00663 &(this_inj->geocent_end_time), u * timeInterval ), &status );
00664 }
00665
00666
00667 LAL_CALL( LALGPStoGMST1( &status, &(this_inj->end_time_gmst),
00668 &(this_inj->geocent_end_time), &gmstUnits ), &status);
00669
00670
00671
00672
00673 if (mdistr == 1)
00674
00675 {
00676 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00677 this_inj->mass1 = minMass + u * deltaM;
00678 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00679 this_inj->mass2 = minMass + u * deltaM;
00680 mtotal = this_inj->mass1 + this_inj->mass2 ;
00681 this_inj->eta = this_inj->mass1 * this_inj->mass2 / ( mtotal * mtotal );
00682 this_inj->mchirp = (this_inj->mass1 + this_inj->mass2) *
00683 pow(this_inj->eta, 0.6);
00684 }
00685 else if (mdistr == 0)
00686
00687 {
00688 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status);
00689 mtotal = 2.0 * minMass + u * 2.0 *deltaM ;
00690
00691 if (sumMaxMassUse==1) {
00692 while (mtotal > sumMaxMass) {
00693 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status);
00694 mtotal = 2.0 * minMass + u * 2.0 *deltaM ;
00695 }
00696 }
00697
00698 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00699 this_inj->mass1 = minMass + u * deltaM;
00700 this_inj->mass2 = mtotal - this_inj->mass1;
00701
00702 while (this_inj->mass1 >= mtotal ||
00703 this_inj->mass2 >= maxMass || this_inj->mass2 <= minMass )
00704 {
00705 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00706 this_inj->mass1 = minMass + u * deltaM;
00707 this_inj->mass2 = mtotal - this_inj->mass1;
00708 }
00709 this_inj->eta = this_inj->mass1 * this_inj->mass2 / ( mtotal * mtotal );
00710 this_inj->mchirp = (this_inj->mass1 + this_inj->mass2) *
00711 pow(this_inj->eta, 0.6);
00712
00713 }
00714
00715
00716
00717 #if 0
00718 LAL_CALL( LALUniformDeviate( &status, &u, randParams ),
00719 &status );
00720 sinphi = 2.0 * u - 1.0;
00721 cosphi = sqrt( 1.0 - sinphi*sinphi );
00722 #endif
00723
00724 if (ddistr == 0)
00725
00726 {
00727 REAL4 deltaD = dmax - dmin ;
00728 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00729 this_inj->distance = dmin + deltaD * u ;
00730 }
00731 else if (ddistr == 1)
00732
00733 {
00734 REAL4 lmin = log10(dmin);
00735 REAL4 lmax = log10(dmax);
00736 REAL4 deltaL = lmax - lmin;
00737 LAL_CALL( LALUniformDeviate(&status,&u,randParams),&status );
00738 exponent = lmin + deltaL * u;
00739 this_inj->distance = pow(10.0,(REAL4) exponent);
00740 }
00741 else if (ddistr == 2)
00742
00743 {
00744 REAL4 d2min = pow(dmin,3.0) ;
00745 REAL4 d2max = pow(dmax,3.0) ;
00746 REAL4 deltad2 = d2max - d2min ;
00747 LAL_CALL( LALUniformDeviate(&status,&u,randParams),&status );
00748 d2 = d2min + u * deltad2 ;
00749 this_inj->distance = pow(d2,1.0/3.0);
00750 }
00751
00752 this_inj->distance = this_inj->distance / 1000.0;
00753
00754
00755
00756 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00757 this_inj->latitude = asin( 2.0 * u - 1.0 ) ;
00758 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00759 this_inj->longitude = LAL_TWOPI * u ;
00760
00761
00762 #if 0
00763 LAL_CALL( LALGalacticInspiralParamsToSimInspiralTable( &status,
00764 this_inj, &galacticPar, randParams ), &status );
00765 if (vrbflg)
00766 {
00767 fprintf( stdout, "%e\n",
00768 sqrt(galacticPar.z*galacticPar.z+galacticPar.rho*galacticPar.rho
00769 + Rcore*Rcore + 2.0*Rcore*galacticPar.rho*cos(galacticPar.lGal))-
00770 this_inj->distance*1000.0);
00771 }
00772 #endif
00773
00774
00775
00776 LALSnprintf( this_inj->source, LIGOMETA_SOURCE_MAX * sizeof(CHAR), "???" );
00777 memcpy( this_inj->waveform, waveform, LIGOMETA_WAVEFORM_MAX *
00778 sizeof(CHAR));
00779
00780
00781
00782 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00783 this_inj->inclination = acos( 2.0 * u - 1.0 );
00784 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00785 this_inj->polarization = LAL_TWOPI * u ;
00786 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status );
00787 this_inj->coa_phase = LAL_TWOPI * u ;
00788
00789
00790 LAL_CALL(LALPopulateSimInspiralSiteInfo( &status, this_inj ),
00791 &status);
00792
00793
00794 LAL_CALL( LALAddFloatToGPS( &status, &gpsStartTime, &gpsStartTime,
00795 meanTimeStep ), &status );
00796 LAL_CALL( LALCompareGPS( &status, &compareGPS, &gpsStartTime,
00797 &gpsEndTime ), &status );
00798
00799
00800 if (fLower > 0)
00801 {
00802 this_inj->f_lower = fLower;
00803 }
00804 else
00805 {
00806 this_inj->f_lower = 0;
00807 }
00808
00809
00810 }
00811
00812
00813 LAL_CALL( LALDestroyRandomParams( &status, &randParams ), &status );
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824 memset( &xmlfp, 0, sizeof(LIGOLwXMLStream) );
00825 LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlfp, fname ), &status );
00826
00827
00828 LALSnprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" );
00829 LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time),
00830 &accuracy ), &status );
00831 LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ),
00832 &status );
00833 LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable,
00834 process_table ), &status );
00835 LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status );
00836 free( proctable.processTable );
00837
00838
00839 this_proc_param = procparams.processParamsTable;
00840 procparams.processParamsTable = procparams.processParamsTable->next;
00841 free( this_proc_param );
00842
00843
00844 if ( procparams.processParamsTable )
00845 {
00846 LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_params_table ),
00847 &status );
00848 LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, procparams,
00849 process_params_table ), &status );
00850 LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status );
00851 while( procparams.processParamsTable )
00852 {
00853 this_proc_param = procparams.processParamsTable;
00854 procparams.processParamsTable = this_proc_param->next;
00855 free( this_proc_param );
00856 }
00857 }
00858
00859
00860 if ( injections.simInspiralTable )
00861 {
00862 LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, sim_inspiral_table ),
00863 &status );
00864 LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, injections,
00865 sim_inspiral_table ), &status );
00866 LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status );
00867 }
00868 while ( injections.simInspiralTable )
00869 {
00870 this_inj = injections.simInspiralTable;
00871 injections.simInspiralTable = injections.simInspiralTable->next;
00872 LALFree( this_inj );
00873 }
00874
00875
00876 LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &xmlfp ), &status );
00877
00878
00879 LALCheckMemoryLeaks();
00880 return 0;
00881 }
00882 #endif