34#include <gsl/gsl_errno.h>
35#include <gsl/gsl_math.h>
36#include <gsl/gsl_roots.h>
37#include <lal/LALStdio.h>
38#include <lal/LALStdlib.h>
39#include <lal/LALConstants.h>
40#include <lal/LIGOLwXML.h>
41#include <lal/LIGOMetadataInspiralUtils.h>
42#include <lal/LIGOMetadataTables.h>
43#include <lal/LIGOMetadataUtils.h>
45#include <lal/SkyCoordinates.h>
46#include <lal/GeneratePPNInspiral.h>
47#include <lal/GenerateInspiral.h>
48#include <lal/DetectorSite.h>
49#include <lal/DetResponse.h>
50#include <lal/TimeDelay.h>
54#define CVS_ID_STRING "$Id$"
55#define CVS_NAME_STRING "$Name$"
56#define CVS_REVISION "$Revision$"
57#define CVS_SOURCE "$Source$"
58#define CVS_DATE "$Date$"
59#define PROGRAM_NAME "spininj"
62"lalapps_spininj [options]\n"\
63"\nDefaults are shown in brackets\n\n" \
64" --help display this message\n"\
65" --verbose print mass and galactocentic cartesian coordinates\n"\
66" --gps-start-time TIME start injections at GPS time TIME (729273613)\n"\
67" --gps-end-time TIME end injections at GPS time TIME (734367613)\n"\
68" --time-step STEP space injections by ave of STEP sec (2630/PI)\n"\
69" --time-interval TIME distribute injections in interval TIME (0)\n"\
70" --seed SEED seed random number generator with SEED (1)\n"\
71" --user-tag STRING set the usertag to STRING\n"\
72" --waveform WVF set the injection waveform to WVF\n"\
73" (EOB, TaylorT1, TaylorT3,PadeT1; followed by the\n"\
74" order: newtonian, onePN, onePointFivePN, twoPN,\n"\
75" twoPointFivePN, threePN) (default: EOBtwoPN)\n"\
76" --fLower set the lower cutoff frequency of the isnpiral waveform (40)\n\n"\
77" --dist-distr DDISTR set method of simulated source distance distr to DDISTR \n"\
78" SPININJ_distance : uniform distr of sources in distance \n"\
79" SPININJ_logDistance : uniform distr of sources in log(distance) \n"\
80" SPININJ_volume : uniform distr of sources in volume \n"\
81" Default is SPININJ_logDistance \n"\
82" --distance-min set minimal value of simulated sources distance in kpc \n"\
83" --distance-max set maximal value of simulated sources distance in kpc \n\n"\
84" --coa-phase-min set minimal value of the initial orbital angle coa-phase (0)\n"\
85" --coa-phase-max set maximal value of the initial orbital angle coa-phase (2 pi)\n"\
86" --coa-phase-range set range of the initial orbital angle coa-phase (0 - 2 pi)\n\n"\
87" --inclination-min set minimal value of the initial inclination (>=0.01 \n"\
88" --inclination-max set maximal value of the initial inclination (<=pi)\n"\
89" --inclination-range set range of the initial inclination (0.01 - pi)\n\n"\
90" --spin1-min set minimal value of the initial spin (>=0)\n"\
91" --spin1-max set maximal value of the initial spin (<=1)\n"\
92" --spin1-range set range of the initial spin (0 - 1)\n\n"\
93" --spin2-min set minimal value of the initial spin (>=0)\n"\
94" --spin2-max set maximal value of the initial spin (<=1)\n"\
95" --spin2-range set range of the initial spin (0 - 1)\n\n"\
96" --mass-distr MDISTR set method of simulated source mass distr to MDISTR \n"\
97" SPININJ_m1Andm2 : uniform distr of sources component mass \n"\
98" SPININJ_totalMass : uniform distr of sources total mass \n"\
99" Default is SPININJ_totalMass \n"\
100" --mass1-range set range of the first mass (3 - 20 )\n"\
101" --mass2-range set range of the second mass (3 - 20)\n\n"\
189 const char *fmt, ... )
193 pp = calloc( 1,
sizeof( *
pp ) );
196 perror(
"next_process_param" );
215int main(
int argc,
char *argv[] )
335 mtotal +=
u* (deltaM1+deltaM2);
351 this_inj->
mchirp = pow( this_inj->
eta, 0.6) *
375 this_inj->
spin1z = (
u - 0.5) * 2 * (spin1Mag);
377 r1 = pow( ((spin1Mag * spin1Mag) - (this_inj->
spin1z * this_inj->
spin1z)) , 0.5);
393 this_inj->
spin2z = (
u - 0.5) * 2 * (spin2Mag);
395 r2 = pow( ((spin2Mag * spin2Mag) - (this_inj->
spin2z * this_inj->
spin2z)) , 0.5);
412 REAL4 u, deltaL, lmin,lmax, d3min,d3max,deltad3,d3, exponent;
424 deltaL = lmax - lmin;
426 exponent = lmin + deltaL *
u;
433 deltad3 = d3max - d3min ;
435 d3 = d3min +
u * deltad3 ;
436 this_inj->
distance = pow(d3, 1.0/3.0);
489 REAL4 cosiota, splus, scross;
507 detAndSource.
pSource = &source;
541 splus = -( 1.0 + cosiota * cosiota );
542 scross = -2.0 * cosiota;
591 if (
params.timeInterval )
638 params->coa_phase.min = 0.;
642 params->gpsStartTime.gpsNanoSeconds = 0;
644 params->gpsEndTime.gpsNanoSeconds = 0;
650 params->timeInterval = 1000.;
658 snprintf(
fname,
sizeof(
fname),
"HL-INJECTIONS_%d-%d-%d.xml",
660 params->gpsEndTime.gpsSeconds -
params->gpsStartTime.gpsSeconds );
668 if ( (strcmp(argv[
i],
"--help") == 0) || (strcmp(argv[
i],
"-h") == 0) ){
672 else if ( strcmp(argv[
i],
"--user-tag") == 0){
674 params->userTag = (
CHAR *) calloc( strlen( argv[
i+1] ) + 1,
sizeof(
CHAR) );
675 memcpy(
params->userTag, argv[
i+1], strlen( argv[
i+1] ) + 1 );
676 this_proc_param = this_proc_param->
next =
680 else if ( strcmp(argv[
i],
"--gps-start-time") == 0){
682 this_proc_param = this_proc_param->
next =
685 else if ( strcmp(argv[
i],
"--gps-end-time") == 0){
687 this_proc_param = this_proc_param->
next =
690 else if ( strcmp(argv[
i],
"--seed") == 0){
691 params->randSeed = atoi( argv[++
i]);
692 this_proc_param = this_proc_param->
next =
695 else if ( strcmp(argv[
i] ,
"--time-interval") == 0 ){
696 params->timeInterval = atof( argv[++
i] );
697 this_proc_param = this_proc_param->
next =
700 else if ( strcmp(argv[
i] ,
"--time-step") == 0 ){
701 params->meanTimeStep = atof( argv[++
i] );
702 this_proc_param = this_proc_param->
next =
705 else if ( strcmp(argv[
i] ,
"--coa-phase-min") == 0 ){
706 params->coa_phase.min = atof( argv[++
i] );
707 this_proc_param = this_proc_param->
next =
710 else if ( strcmp(argv[
i] ,
"--coa-phase-max") == 0 ){
711 params->coa_phase.max = atof( argv[++
i] );
712 this_proc_param = this_proc_param->
next =
715 else if ( strcmp(argv[
i] ,
"--coa-phase-range") == 0 ){
716 params->coa_phase.min = atof( argv[++
i] );
717 params->coa_phase.max = atof( argv[++
i] );
718 this_proc_param = this_proc_param->
next =
720 this_proc_param = this_proc_param->
next =
723 else if ( strcmp(argv[
i] ,
"--mass1-min") == 0 ){
725 this_proc_param = this_proc_param->
next =
728 else if ( strcmp(argv[
i] ,
"--mass1-max") == 0 ){
730 this_proc_param = this_proc_param->
next =
733 else if ( strcmp(argv[
i] ,
"--mass1-range") == 0 ){
736 this_proc_param = this_proc_param->
next =
738 this_proc_param = this_proc_param->
next =
741 else if ( strcmp(argv[
i] ,
"--fLower") == 0 ){
742 params->fLower = atof( argv[++
i] );
743 this_proc_param = this_proc_param->
next =
746 else if ( strcmp(argv[
i] ,
"--mass2-min") == 0 ){
748 this_proc_param = this_proc_param->
next =
751 else if ( strcmp(argv[
i] ,
"--mass2-max") == 0 ){
753 this_proc_param = this_proc_param->
next =
756 else if ( strcmp(argv[
i] ,
"--mass2-range") == 0 ){
759 this_proc_param = this_proc_param->
next =
761 this_proc_param = this_proc_param->
next =
764 else if ( strcmp(argv[
i] ,
"--distance-min") == 0 ){
766 this_proc_param = this_proc_param->
next =
769 else if ( strcmp(argv[
i] ,
"--distance-max") == 0 ){
771 this_proc_param = this_proc_param->
next =
774 else if ( strcmp(argv[
i] ,
"--distance-range") == 0 ){
777 this_proc_param = this_proc_param->
next =
779 this_proc_param = this_proc_param->
next =
782 else if ( strcmp(argv[
i] ,
"--spin1-min") == 0 ){
783 params->spin1.min = atof( argv[++
i] );
784 this_proc_param = this_proc_param->
next =
787 else if ( strcmp(argv[
i] ,
"--spin2-min") == 0 ){
788 params->spin2.min = atof( argv[++
i] );
789 this_proc_param = this_proc_param->
next =
792 else if ( strcmp(argv[
i] ,
"--spin1-max") == 0 ){
793 params->spin1.max = atof( argv[++
i] );
794 this_proc_param = this_proc_param->
next =
797 else if ( strcmp(argv[
i] ,
"--spin2-max") == 0 ){
798 params->spin2.max = atof( argv[++
i] );
799 this_proc_param = this_proc_param->
next =
802 else if ( strcmp(argv[
i] ,
"--spin1-range") == 0 ){
803 params->spin1.min = atof( argv[++
i] );
804 params->spin1.max = atof( argv[++
i] );
806 this_proc_param = this_proc_param->
next =
808 this_proc_param = this_proc_param->
next =
811 else if ( strcmp(argv[
i] ,
"--spin2-range") == 0 ){
812 params->spin2.min = atof( argv[++
i] );
813 params->spin2.max = atof( argv[++
i] );
815 this_proc_param = this_proc_param->
next =
817 this_proc_param = this_proc_param->
next =
820 else if ( strcmp(argv[
i] ,
"--inclination-min") == 0 ){
822 this_proc_param = this_proc_param->
next =
825 else if ( strcmp(argv[
i] ,
"--inclination-max") == 0 ){
827 this_proc_param = this_proc_param->
next =
830 else if ( strcmp(argv[
i] ,
"--inclination-range") == 0 ){
834 this_proc_param = this_proc_param->
next =
836 this_proc_param = this_proc_param->
next =
839 else if ( strcmp(argv[
i] ,
"--waveform") == 0 ){
841 this_proc_param = this_proc_param->
next =
845 else if ( strcmp(argv[
i] ,
"--mass-distr") == 0 ){
846 if ( ! strcmp(
"SPININJ_m1Andm2", argv[++
i] ) )
850 else if ( ! strcmp(
"SPININJ_totalMass", argv[
i] ) )
856 fprintf( stderr,
"invalid arg to --mass-distr \n");
859 this_proc_param = this_proc_param->
next =
863 else if ( strcmp(argv[
i] ,
"--dist-distr") == 0 ){
864 if ( ! strcmp(
"SPININJ_distance", argv[++
i] ) )
868 else if ( ! strcmp(
"SPININJ_logDistance", argv[
i] ) )
872 else if ( ! strcmp(
"SPININJ_volume", argv[
i] ) )
878 fprintf( stderr,
"invalid arg to --dist-distr \n");
881 this_proc_param = this_proc_param->
next =
886 fprintf(stderr,
"option %s unknown !!! abort\n", argv[
i]);
895 snprintf(
fname,
sizeof(
fname),
"HL-INJECTIONS_%d_%s-%d-%d.xml",
897 params->gpsEndTime.gpsSeconds -
params->gpsStartTime.gpsSeconds );
917 this_proc_param = procparams;
918 procparams = procparams->
next;
919 free( this_proc_param );
939 fprintf( stderr,
"invalid argument to --%s:\n"
940 "fLower should not be less than 5Hz or greater than 1000Hz "
942 "fLower",
params.fLower );
945 if (
params.gpsStartTime.gpsSeconds < 441417609 )
947 fprintf( stderr,
"invalid argument to --%s:\n"
948 "GPS start time is prior to "
949 "Jan 01, 1994 00:00:00 UTC:\n"
951 "gps-start-time",
params.gpsStartTime.gpsSeconds );
955 if (
params.meanTimeStep <= 0 )
957 fprintf( stderr,
"invalid argument to --%s:\n"
958 "time step must be > 0: (%e seconds specified)\n",
959 "mean-time",
params.meanTimeStep );
962 if (
params.timeInterval < 0 )
964 fprintf( stderr,
"invalid argument to --%s:\n"
965 "time interval must be >= 0: (%e seconds specified)\n",
966 "time-interval",
params.timeInterval );
971 fprintf( stderr,
"invalid argument to --%s:\n"
972 "miniumum component mass must be > 0: \n",
979 fprintf( stderr,
"invalid argument to --%s:\n"
980 "minimum component (%f) mass must be < maximum component (%f) : \n",
987 fprintf( stderr,
"invalid argument to --%s:\n"
988 "minimum component (%f) mass must be < maximum component (%f) : \n",
995 fprintf( stderr,
"invalid argument to --%s:\n"
996 "minimum distance must be > 0: "
1003 fprintf( stderr,
"invalid argument to --%s:\n"
1004 "maximum distance max (%f) must be > distance min (%f)",
1011 fprintf( stderr,
"invalid argument to --%s:\n"
1012 "maximum coa_phase max (%f) must be > coa_phase min (%f)",
1013 "coa-phase-range",
params.coa_phase.max,
params.coa_phase.min);
1021 fprintf( stderr,
"invalid argument to --%s:\n"
1022 "spin1-min (%f) and spin1-max (%f) must be > 0 \n",
1023 "spin1-min or spin1-max",
params.spin1.min,
params.spin1.max);
1030 fprintf( stderr,
"invalid argument to --%s:\n"
1031 "spin1-min (%f) must be < spin1-max (%f) \n",
1032 "spin1-min or spin1-max",
params.spin1.min,
params.spin1.max);
1039 fprintf( stderr,
"invalid argument to --%s:\n"
1040 "spin2-min (%f) and spin2-max (%f) must be > 0 \n",
1041 "spin2-min or spin2-max",
params.spin2.min,
params.spin2.max);
1048 fprintf( stderr,
"invalid argument to --%s:\n"
1049 "spin2-min (%f) must be < spin2-max (%f) \n",
1050 "spin2-min or spin2-max",
params.spin2.min,
params.spin2.max);
1057 fprintf( stderr,
"invalid argument to --%s:\n"
1058 "inclination-max (%f) must be < pi \n",
1066 fprintf( stderr,
"invalid argument to --%s:\n"
1067 "inclination-min (%f) must be > 0.01 \n",
1075 fprintf( stderr,
"invalid argument to --%s:\n"
1076 "inclination-min (%f) must be < inclination-max (%f) \n",
const LALVCSInfo lalAppsVCSIdentInfo
Identable VCS and build information for LALApps.
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define LAL_CALL(function, statusptr)
void LALCheckMemoryLeaks(void)
#define ASSERT(assertion, statusptr, code, mesg)
int XLALCloseLIGOLwXMLFile(LIGOLwXMLStream *xml)
LIGOLwXMLStream * XLALOpenLIGOLwXMLFile(const char *path)
int XLALWriteLIGOLwXMLProcessTable(LIGOLwXMLStream *, const ProcessTable *)
int XLALWriteLIGOLwXMLProcessParamsTable(LIGOLwXMLStream *, const ProcessParamsTable *)
int XLALWriteLIGOLwXMLSimInspiralTable(LIGOLwXMLStream *, const SimInspiralTable *)
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
LIGOTimeGPS * XLALGPSTimeNow(LIGOTimeGPS *gpstime)
void LALComputeDetAMResponse(LALStatus *status, LALDetAMResponse *pResponse, const LALDetAndSource *pDetAndSrc, const LIGOTimeGPS *gps)
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
void LALUniformDeviate(LALStatus *status, REAL4 *deviate, RandomParams *params)
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
COORDINATESYSTEM_EQUATORIAL
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
#define XLAL_IS_REAL8_FAIL_NAN(val)
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
SimInspiralTable * injections
char name[LIGOMETA_SOURCE_MAX]
int main(int argc, char *argv[])
RandomParams * randParams
void LALSetSpin(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
static ProcessParamsTable * next_process_param(const char *name, const char *type, const char *fmt,...)
void LALSetSiteParameters(LALStatus *status, SimInspiralTable *this_inj)
void XLALCheckInspiralInjectionParameters(InspiralInjectionParameters params)
void LALSetSpatialDistribution(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
void LALSetGeoCentricEndTime(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
void LALParserInspiralInjection(int, char **, InspiralInjectionParameters *)
int vrbflg
defined in lal/lib/std/LALError.c
void LALSetIndividualMasses(LALStatus *status, InspiralInjectionParameters params, SimInspiralTable *this_inj)
void LALSimInspiralTablePopulate(SimInspiralTable **this_inj)
void LALSetDistance(LALStatus *status, InspiralInjectionParameters, SimInspiralTable *this_inj)
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
const LALDetector * pDetector
SkyPosition equatorialCoords
const char *const vcsDate
const char *const vcsStatus
struct tagProcessParamsTable * next
CHAR ifos[LIGOMETA_IFOS_MAX]
CHAR comment[LIGOMETA_COMMENT_MAX]
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next
CHAR waveform[LIGOMETA_WAVEFORM_MAX]