/// /// Parse a string representing a range of LIGOTimeGPS values into a LIGOTimeGPSRange. Possible formats /// are <tt>start</tt>, <tt>start,end</tt>, <tt>start/band</tt>, or <tt>start~plusminus</tt>. /// Output range is always <tt>low,high</tt> with <tt>range[0] = low; range[1] = high</tt>. /// int XLALParseStringValueAsEPOCHRange( LIGOTimeGPSRange *gpsRange, ///< [out] output range of LIGOTimeGPS values const char *valString ///< [in] input string ) { // Check input XLAL_CHECK(gpsRange != NULL, XLAL_EFAULT); XLAL_CHECK(valString != NULL, XLAL_EFAULT); // Parse range char part[2][256]; int T[2][2]; split_string_into_range(valString, part, T); LIGOTimeGPS val[2]; XLAL_CHECK( XLALParseStringValueAsEPOCH(&val[0], part[0]) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK( XLALParseStringValueAsEPOCH(&val[1], part[1]) == XLAL_SUCCESS, XLAL_EFUNC ); XLALINT8NSToGPS( &(*gpsRange)[0], T[0][0] * XLALGPSToINT8NS(&val[0]) + T[0][1] * XLALGPSToINT8NS(&val[1]) ); XLALINT8NSToGPS( &(*gpsRange)[1], T[1][0] * XLALGPSToINT8NS(&val[0]) + T[1][1] * XLALGPSToINT8NS(&val[1]) ); // Check range ordering if (XLALGPSCmp(&(*gpsRange)[0], &(*gpsRange)[1]) > 0) { const LIGOTimeGPS tmp = (*gpsRange)[0]; (*gpsRange)[0] = (*gpsRange)[1]; (*gpsRange)[1] = tmp; } return XLAL_SUCCESS; }
INT8 XLALReturnSimInspiralEndTime ( SimInspiralTable *event, CHAR *ifo ) { if ( ! strcmp( "L1", ifo ) ) { return( XLALGPSToINT8NS(&(event->l_end_time) ) ); } else if ( ! strcmp( "H1", ifo ) || ! strcmp( "H2", ifo ) ) { return( XLALGPSToINT8NS(&(event->h_end_time) ) ); } else if ( ! strcmp( "G1", ifo ) ) { return(XLALGPSToINT8NS(&(event->g_end_time) ) ); } else if ( ! strcmp( "T1", ifo ) ) { return( XLALGPSToINT8NS(&(event->t_end_time) ) ); } else if ( ! strcmp( "V1", ifo ) ) { return( XLALGPSToINT8NS(&(event->v_end_time) ) ); } else { XLAL_ERROR(XLAL_EIO); } }
INT8 XLALReturnSimRingdownStartTime ( SimRingdownTable *event, CHAR *ifo ) { if ( ! strcmp( "L1", ifo ) ) { return( XLALGPSToINT8NS(&(event->l_start_time) ) ); } else if ( ! strcmp( "H1", ifo ) || ! strcmp( "H2", ifo ) ) { return( XLALGPSToINT8NS(&(event->h_start_time) ) ); } else if ( ! strcmp( "V1", ifo ) ) { return( XLALGPSToINT8NS(&(event->v_start_time) ) ); } else { XLAL_ERROR(XLAL_EIO); } }
/** * Adds two GPS times. Computes epoch + dt and places the result in epoch. * Returns epoch on success, NULL on error. */ LIGOTimeGPS * XLALGPSAddGPS( LIGOTimeGPS *epoch, const LIGOTimeGPS *dt ) { /* when GPS times are converted to 8-byte counts of nanoseconds their sum * cannot overflow, however it might not be possible to convert the sum * back to a LIGOTimeGPS without overflowing. that is caught by the * XLALINT8NSToGPS() function */ return XLALINT8NSToGPS( epoch, XLALGPSToINT8NS( epoch ) + XLALGPSToINT8NS( dt ) ); }
/** * Difference between two GPS times. Computes t1 - t0 and places the * result in t1. Returns t1 on success, NULL on error. */ LIGOTimeGPS * XLALGPSSubGPS( LIGOTimeGPS *t1, const LIGOTimeGPS *t0 ) { /* when GPS times are converted to 8-byte counts of nanoseconds their * difference cannot overflow, however it might not be possible to * convert the difference back to a LIGOTimeGPS without overflowing. * that is caught by the XLALINT8NSToGPS() function */ return XLALINT8NSToGPS(t1, XLALGPSToINT8NS(t1) - XLALGPSToINT8NS(t0)); }
/** * Compares two GPS times. * Returns: * - -1 if t0 < t1 * - 0 if t0 == t1 * - 1 if t0 > t1. * A NULL GPS time is always less than a non-NULL GPS time, * and two NULL GPS times are considered equal. */ int XLALGPSCmp( const LIGOTimeGPS *t0, const LIGOTimeGPS *t1 ) { if ( t0 == NULL || t1 == NULL ) { return ( t1 != NULL ) ? -1 : ( ( t0 != NULL ) ? 1 : 0 ); } else { INT8 ns0 = XLALGPSToINT8NS( t0 ); INT8 ns1 = XLALGPSToINT8NS( t1 ); return ( ns0 > ns1 ) - ( ns0 < ns1 ); } }
static PyObject *__sub__(PyObject *self, PyObject *other) { LIGOTimeGPS self_gps; LIGOTimeGPS other_gps; if(!pyobject_to_ligotimegps(self, &self_gps)) return NULL; if(!pyobject_to_ligotimegps(other, &other_gps)) return NULL; XLALINT8NSToGPS(&self_gps, XLALGPSToINT8NS(&self_gps) - XLALGPSToINT8NS(&other_gps)); return pylal_LIGOTimeGPS_new(self_gps); }
static int __init__(PyObject *self, PyObject *args, PyObject *kwds) { LIGOTimeGPS *gps = &((pylal_LIGOTimeGPS *) self)->gps; PyObject *seconds; long long nanoseconds = 0; if(!PyArg_ParseTuple(args, "O|L", &seconds, &nanoseconds)) return -1; if(PyUnicode_Check(seconds)) { /* convert to ascii string */ PyObject *str = PyUnicode_AsASCIIString(seconds); if(!str) return -1; seconds = str; } if(PyString_Check(seconds)) { char *end, *str = PyString_AsString(seconds); int result = XLALStrToGPS(gps, str, &end); if((result < 0) || (end == str)) { PyErr_SetObject(PyExc_ValueError, seconds); return -1; } } else if(!pyobject_to_ligotimegps(seconds, gps)) { PyErr_SetObject(PyExc_ValueError, seconds); return -1; } XLALINT8NSToGPS(gps, XLALGPSToINT8NS(gps) + nanoseconds); return 0; }
/** * Breaks the GPS time into REAL8 integral and fractional parts, * each of which has the same sign as the epoch. Returns the * fractional part, and stores the integral part (as a REAL8) * in the object pointed to by iptr. Like the standard C math * library function modf(). */ REAL8 XLALGPSModf( REAL8 *iptr, const LIGOTimeGPS *epoch ) { INT8 ns = XLALGPSToINT8NS(epoch); INT8 rem; /* remainder */ *iptr = ns < 0 ? -floor(-ns / XLAL_BILLION_REAL8) : floor(ns / XLAL_BILLION_REAL8); rem = ns - ((INT8)(*iptr) * XLAL_BILLION_INT8); return (REAL8)(rem) / XLAL_BILLION_REAL8; }
static PyObject *ns(PyObject *self, PyObject *args) { LIGOTimeGPS gps; if(!pyobject_to_ligotimegps(self, &gps)) return NULL; return PyLong_FromLongLong(XLALGPSToINT8NS(&gps)); }
/* The following function would be called by the GSL minimizer */ static REAL8 minimizeEThincaParameterOverTimeDiff( REAL8 timeShift, void *minimizer ) { EThincaMinimizer *params = (EThincaMinimizer *) minimizer; INT8 curTimeANS, curTimeBNS; REAL8 originalTimeA; REAL8 originalTimeB; REAL8 overlap; originalTimeA = gsl_vector_get( params->aPtr->position, 0 ); originalTimeB = gsl_vector_get( params->bPtr->position, 0 ); curTimeANS = XLALGPSToINT8NS( &(params->aPtr->trigger->end_time) ); curTimeBNS = XLALGPSToINT8NS( &(params->bPtr->trigger->end_time) ); /* Reset the times to avoid any precision problems */ XLALSetTimeInPositionVector( params->aPtr->position, timeShift ); XLALSetTimeInPositionVector( params->bPtr->position, (curTimeBNS - curTimeANS) * 1.0e-9 ); /* check for the intersection of the ellipsoids */ params->workSpace->invQ1 = params->aPtr->err_matrix; params->workSpace->invQ2 = params->bPtr->err_matrix; overlap = XLALCheckOverlapOfEllipsoids( params->aPtr->position, params->bPtr->position, params->workSpace ); if (XLAL_IS_REAL8_FAIL_NAN(overlap)) { /* Set the times back to their correct values */ XLALSetTimeInPositionVector( params->aPtr->position, originalTimeA ); XLALSetTimeInPositionVector( params->bPtr->position, originalTimeB ); XLAL_ERROR_REAL8( XLAL_EFUNC ); } /* Set the times back to their correct values */ XLALSetTimeInPositionVector( params->aPtr->position, originalTimeA ); XLALSetTimeInPositionVector( params->bPtr->position, originalTimeB ); return overlap; }
static PyObject *__neg__(PyObject *self) { LIGOTimeGPS gps; if(!pyobject_to_ligotimegps(self, &gps)) return NULL; XLALINT8NSToGPS(&gps, -XLALGPSToINT8NS(&gps)); return pylal_LIGOTimeGPS_new(gps); }
static PyObject *__mod__(PyObject *self, PyObject *other) { LIGOTimeGPS gps; const double other_double = PyFloat_AsDouble(other); if(PyErr_Occurred()) return NULL; if(!pyobject_to_ligotimegps(self, &gps)) return NULL; /* FIXME: loss of precision */ XLALINT8NSToGPS(&gps, XLALGPSToINT8NS(&gps) % (long long) (other_double * 1e9)); return pylal_LIGOTimeGPS_new(gps); }
/* a few useful static functions */ static INT8 geocent_end_time(const SimInspiralTable *x) { return(XLALGPSToINT8NS(&x->geocent_end_time)); }
int main( int argc, char *argv[] ) { LALStatus status = blank_status; UINT4 k; UINT4 kLow; UINT4 kHi; INT4 numPoints = 524288; REAL4 fSampling = 2048.; REAL4 fLow = 70.; REAL4 fLowInj = 40.; REAL8 deltaT = 1./fSampling; REAL8 deltaF = fSampling / numPoints; REAL4 statValue; /* vars required to make freq series */ LIGOTimeGPS epoch = { 0, 0 }; LIGOTimeGPS gpsStartTime = {0, 0}; REAL8 f0 = 0.; REAL8 offset = 0.; INT8 waveformStartTime = 0; /* files contain PSD info */ CHAR *injectionFile = NULL; CHAR *outputFile = NULL; CHAR *specFileH1 = NULL; CHAR *specFileH2 = NULL; CHAR *specFileL1 = NULL; COMPLEX8Vector *unity = NULL; const LALUnit strainPerCount = {0,{0,0,0,0,0,1,-1},{0,0,0,0,0,0,0}}; int numInjections = 0; int numTriggers = 0; /* template bank simulation variables */ INT4 injSimCount = 0; SimInspiralTable *injectionHead = NULL; SimInspiralTable *thisInjection = NULL; SnglInspiralTable *snglHead = NULL; SearchSummaryTable *searchSummHead = NULL; /*SummValueTable *summValueHead = NULL; */ /* raw input data storage */ REAL8FrequencySeries *specH1 = NULL; REAL8FrequencySeries *specH2 = NULL; REAL8FrequencySeries *specL1 = NULL; REAL8FrequencySeries *thisSpec = NULL; COMPLEX8FrequencySeries *resp = NULL; COMPLEX8FrequencySeries *detTransDummy = NULL; REAL4TimeSeries *chan = NULL; RealFFTPlan *pfwd = NULL; COMPLEX8FrequencySeries *fftData = NULL; REAL8 thisSnrsq = 0; REAL8 thisSnr = 0; REAL8 thisCombSnr = 0; REAL8 snrVec[3]; REAL8 dynRange = 1./(3.0e-23); /* needed for inj */ CoherentGW waveform; PPNParamStruc ppnParams; DetectorResponse detector; InterferometerNumber ifoNumber = LAL_UNKNOWN_IFO; /* output data */ LIGOLwXMLStream xmlStream; MetadataTable proctable; MetadataTable outputTable; MetadataTable procparams; CHAR fname[256]; CHAR comment[LIGOMETA_COMMENT_MAX]; ProcessParamsTable *this_proc_param = NULL; CHAR chanfilename[FILENAME_MAX]; REAL4 sum = 0; REAL4 bitten_H1 = 0; REAL4 bitten_H2 = 0; REAL4 thisCombSnr_H1H2 = 0; /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); XLALGPSTimeNow(&(proctable.processTable->start_time)); XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, lalAppsVCSIdentId, lalAppsVCSIdentStatus, lalAppsVCSIdentDate, 0); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); memset( comment, 0, LIGOMETA_COMMENT_MAX * sizeof(CHAR) ); /* look at input args, write process params where required */ while ( 1 ) { /* getopt arguments */ static struct option long_options[] = { /* these options set a flag */ /* these options do not set a flag */ {"help", no_argument, 0, 'h'}, {"verbose", no_argument, &vrbflg, 1 }, {"version", no_argument, 0, 'V'}, {"spectrum-H1", required_argument, 0, 'a'}, {"spectrum-H2", required_argument, 0, 'b'}, {"spectrum-L1", required_argument, 0, 'c'}, {"inj-file", required_argument, 0, 'd'}, {"comment", required_argument, 0, 'e'}, {"output-file", required_argument, 0, 'f'}, {"coire-flag", no_argument, &coireflg, 1 }, {"ligo-srd", no_argument, &ligosrd, 1 }, {"write-chan", no_argument, &writechan, 1 }, {"inject-overhead", no_argument, &injoverhead, 1 }, {"f-lower", required_argument, 0, 'g'}, {0, 0, 0, 0} }; int c; /* * * parse command line arguments * */ /* getopt_long stores long option here */ int option_index = 0; size_t optarg_len; c = getopt_long_only( argc, argv, "a:b:c:d:e:f:g:hV", long_options, &option_index ); /* detect the end of the options */ if ( c == - 1 ) { break; } switch ( c ) { case 0: /* if this option set a flag, do nothing else now */ if ( long_options[option_index].flag != 0 ) { break; } else { fprintf( stderr, "error parsing option %s with argument %s\n", long_options[option_index].name, optarg ); exit( 1 ); } break; case 'h': fprintf( stderr, USAGE ); exit( 0 ); break; case 'a': /* create storage for the spectrum file name */ optarg_len = strlen( optarg ) + 1; specFileH1 = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( specFileH1, optarg, optarg_len ); ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'b': /* create storage for the spectrum file name */ optarg_len = strlen( optarg ) + 1; specFileH2 = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( specFileH2, optarg, optarg_len ); ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'c': /* create storage for the spectrum file name */ optarg_len = strlen( optarg ) + 1; specFileL1 = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( specFileL1, optarg, optarg_len ); ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'd': /* create storage for the injection file name */ optarg_len = strlen( optarg ) + 1; injectionFile = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( injectionFile, optarg, optarg_len ); ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'f': /* create storage for the output file name */ optarg_len = strlen( optarg ) + 1; outputFile = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( outputFile, optarg, optarg_len ); ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'g': fLow = (INT4) atof( optarg ); if ( fLow < 40 ) { fprintf( stderr, "invalid argument to --%s:\n" "f-lower must be > 40Hz (%e specified)\n", long_options[option_index].name, fLow ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", fLow ); break; case 'e': if ( strlen( optarg ) > LIGOMETA_COMMENT_MAX - 1 ) { fprintf( stderr, "invalid argument to --%s:\n" "comment must be less than %d characters\n", long_options[option_index].name, LIGOMETA_COMMENT_MAX ); exit( 1 ); } else { snprintf( comment, LIGOMETA_COMMENT_MAX, "%s", optarg); } break; case 'V': /* print version information and exit */ fprintf( stdout, "calculation of expected SNR of injections\n" "Gareth Jones\n"); XLALOutputVersionString(stderr, 0); exit( 0 ); break; default: fprintf( stderr, "unknown error while parsing options\n" ); fprintf( stderr, USAGE ); exit( 1 ); } } if ( optind < argc ) { fprintf( stderr, "extraneous command line arguments:\n" ); while ( optind < argc ) { fprintf ( stderr, "%s\n", argv[optind++] ); } exit( 1 ); } /* check the input arguments */ if ( injectionFile == NULL ) { fprintf( stderr, "Must specify the --injection-file\n" ); exit( 1 ); } if ( outputFile == NULL ) { fprintf( stderr, "Must specify the --output-file\n" ); exit( 1 ); } if ( !ligosrd && specFileH1 == NULL ) { fprintf( stderr, "Must specify the --spectrum-H1\n" ); exit( 1 ); } if ( !ligosrd && specFileH2 == NULL ) { fprintf( stderr, "Must specify the --spectrum-H2\n" ); exit( 1 ); } if ( !ligosrd && specFileL1 == NULL ) { fprintf( stderr, "Must specify the --spectrum-L1\n" ); exit( 1 ); } if ( ligosrd && (specFileH1 || specFileH2 || specFileL1 )) { fprintf( stdout, "WARNING: using LIGOI SRD power spectral density \n" ); } if ( vrbflg ){ fprintf( stdout, "injection file is %s\n", injectionFile ); fprintf( stdout, "output file is %s\n", outputFile ); fprintf( stdout, "H1 spec file is %s\n", specFileH1 ); fprintf( stdout, "H2 spec file is %s\n", specFileH2 ); fprintf( stdout, "L1 spec file is %s\n", specFileL1 ); } /* create vector for H1, H2 and L1 spectrums */ specH1 = XLALCreateREAL8FrequencySeries ( "",&epoch, f0, deltaF, &lalADCCountUnit, (numPoints / 2 + 1) ); specH2 = XLALCreateREAL8FrequencySeries ( "",&epoch, f0, deltaF, &lalADCCountUnit, (numPoints / 2 + 1) ); specL1 = XLALCreateREAL8FrequencySeries ( "",&epoch, f0, deltaF, &lalADCCountUnit, (numPoints / 2 + 1) ); if (!specH1 || !specH2 || !specL1){ XLALDestroyREAL8FrequencySeries ( specH1 ); XLALDestroyREAL8FrequencySeries ( specH2 ); XLALDestroyREAL8FrequencySeries ( specL1 ); XLALPrintError("failure allocating H1, H2 and L1 spectra"); exit(1); } if (!ligosrd){ /* read in H1 spectrum */ LAL_CALL( LALDReadFrequencySeries(&status, specH1, specFileH1), &status ); if ( vrbflg ){ fprintf( stdout, "read in H1 spec file\n" ); fflush( stdout ); } /* read in H2 spectrum */ LAL_CALL( LALDReadFrequencySeries(&status, specH2, specFileH2), &status ); if ( vrbflg ){ fprintf( stdout, "read in H2 spec file\n" ); fflush( stdout ); } /* read in L1 spectrum */ LAL_CALL( LALDReadFrequencySeries(&status, specL1, specFileL1), &status ); if ( vrbflg ){ fprintf( stdout, "read in L1 spec file\n" ); fflush( stdout ); } } chan = XLALCreateREAL4TimeSeries( "", &epoch, f0, deltaT, &lalADCCountUnit, numPoints ); if ( !chan ){ XLALPrintError("failure allocating chan"); exit(1); } /* * * set up the response function * */ resp = XLALCreateCOMPLEX8FrequencySeries( chan->name, &chan->epoch, f0, deltaF, &strainPerCount, (numPoints / 2 + 1) ); if ( !resp ){ XLALPrintError("failure allocating response function"); exit(1); } /* create vector that will contain detector.transfer info, since this * is constant I calculate it once outside of all the loops and pass it * in to detector.transfer when required */ detTransDummy = XLALCreateCOMPLEX8FrequencySeries( chan->name, &chan->epoch, f0, deltaF, &strainPerCount, (numPoints / 2 + 1) ); if ( !detTransDummy ){ XLALPrintError("failure allocating detector.transfer info"); exit(1); } /* invert the response function to get the transfer function */ unity = XLALCreateCOMPLEX8Vector( resp->data->length ); for ( k = 0; k < unity->length; ++k ) { unity->data[k] = 1.0; } /* set response */ for ( k = 0; k < resp->data->length; ++k ) { resp->data->data[k] = 1.0; } XLALCCVectorDivide( detTransDummy->data, unity, resp->data ); XLALDestroyCOMPLEX8Vector( unity ); /* read in injections from injection file */ /* set endtime to 0 so that we read in all events */ if ( vrbflg ) fprintf( stdout, "Reading sim_inspiral table of %s\n", injectionFile ); LAL_CALL(numInjections = SimInspiralTableFromLIGOLw( &injectionHead, injectionFile, 0, 0), &status); if ( vrbflg ) fprintf( stdout, "Read %d injections from sim_inspiral table of %s\n", numInjections, injectionFile ); if (coireflg){ if ( vrbflg ) fprintf( stdout, "Reading sngl_inspiral table of %s\n", injectionFile ); LAL_CALL(numTriggers = LALSnglInspiralTableFromLIGOLw(&snglHead, injectionFile, 0, -1), &status); if ( vrbflg ) fprintf( stdout, "Read %d triggers from sngl_inspiral table of %s\n", numTriggers, injectionFile ); if ( vrbflg ) { fprintf( stdout, "Reading search_summary table of %s ...", injectionFile ); fflush( stdout ); } searchSummHead = XLALSearchSummaryTableFromLIGOLw (injectionFile); if ( vrbflg ) fprintf( stdout, " done\n"); } /* make sure we start at head of linked list */ thisInjection = injectionHead; /* setting fixed waveform injection parameters */ memset( &ppnParams, 0, sizeof(PPNParamStruc) ); ppnParams.deltaT = deltaT; ppnParams.lengthIn = 0; ppnParams.ppn = NULL; /* loop over injections */ injSimCount = 0; do { fprintf( stdout, "injection %d/%d\n", injSimCount+1, numInjections ); /* reset waveform structure */ memset( &waveform, 0, sizeof(CoherentGW) ); /* reset chan structure */ memset( chan->data->data, 0, chan->data->length * sizeof(REAL4) ); if (thisInjection->f_lower == 0){ fprintf( stdout, "WARNING: f_lower in sim_inpiral = 0, "); fprintf( stdout, "changing this to %e\n ", fLowInj); thisInjection->f_lower = fLowInj; } /* create the waveform, amp, freq phase etc */ LAL_CALL( LALGenerateInspiral(&status, &waveform, thisInjection, &ppnParams), &status); if (vrbflg) fprintf( stdout, "ppnParams.tc %e\n ", ppnParams.tc); statValue = 0.; /* calc lower index for integration */ kLow = ceil(fLow / deltaF); if ( vrbflg ) { fprintf( stdout, "starting integration to find SNR at frequency %e ", fLow); fprintf( stdout, "at index %d \n", kLow); } /* calc upper index for integration */ kHi = floor(fSampling / (2. * deltaF)); if ( vrbflg ) { fprintf( stdout, "ending integration to find SNR at frequency %e ", fSampling / 2.); fprintf( stdout, "at index %d \n", kHi); } /* loop over ifo */ for ( ifoNumber = 1; ifoNumber < 4; ifoNumber++ ) { /* allocate memory and copy the parameters describing the freq series */ memset( &detector, 0, sizeof( DetectorResponse ) ); detector.site = (LALDetector *) LALMalloc( sizeof(LALDetector) ); if (injoverhead){ if ( vrbflg ) fprintf( stdout, "WARNING: perform overhead injections\n"); /* setting detector.site to NULL causes SimulateCoherentGW to * perform overhead injections */ detector.site = NULL; } else { /* if not overhead, set detector.site using ifonumber */ XLALReturnDetector( detector.site, ifoNumber ); } switch ( ifoNumber ) { case 1: if ( vrbflg ) fprintf( stdout, "looking at H1 \n"); thisSpec = specH1; break; case 2: if ( vrbflg ) fprintf( stdout, "looking at H2 \n"); thisSpec = specH2; break; case 3: if ( vrbflg ) fprintf( stdout, "looking at L1 \n"); thisSpec = specL1; break; default: fprintf( stderr, "Error: ifoNumber %d does not correspond to H1, H2 or L1: \n", ifoNumber ); exit( 1 ); } /* get the gps start time of the signal to inject */ waveformStartTime = XLALGPSToINT8NS( &(thisInjection->geocent_end_time) ); waveformStartTime -= (INT8) ( 1000000000.0 * ppnParams.tc ); offset = (chan->data->length / 2.0) * chan->deltaT; gpsStartTime.gpsSeconds = thisInjection->geocent_end_time.gpsSeconds - offset; gpsStartTime.gpsNanoSeconds = thisInjection->geocent_end_time.gpsNanoSeconds; chan->epoch = gpsStartTime; if (vrbflg) fprintf(stdout, "offset start time of injection by %f seconds \n", offset ); /* is this okay? copying in detector transfer which so far only contains response info */ detector.transfer = detTransDummy; XLALUnitInvert( &(detector.transfer->sampleUnits), &(resp->sampleUnits) ); /* set the start times for injection */ XLALINT8NSToGPS( &(waveform.a->epoch), waveformStartTime ); memcpy(&(waveform.f->epoch), &(waveform.a->epoch), sizeof(LIGOTimeGPS) ); memcpy(&(waveform.phi->epoch), &(waveform.a->epoch), sizeof(LIGOTimeGPS) ); /* perform the injection */ LAL_CALL( LALSimulateCoherentGW(&status, chan, &waveform, &detector ), &status); if (writechan){ /* write out channel data */ if (vrbflg) fprintf(stdout, "writing channel data to file... \n" ); switch ( ifoNumber ) { case 1: snprintf( chanfilename, FILENAME_MAX, "chanTest_H1_inj%d.dat", injSimCount+1); if (vrbflg) fprintf( stdout, "writing H1 channel time series out to %s\n", chanfilename ); LALSPrintTimeSeries(chan, chanfilename ); break; case 2: snprintf( chanfilename, FILENAME_MAX, "chanTest_H2_inj%d.dat", injSimCount+1); if (vrbflg) fprintf( stdout, "writing H2 channel time series out to %s\n", chanfilename ); LALSPrintTimeSeries(chan, chanfilename ); break; case 3: snprintf( chanfilename, FILENAME_MAX, "chanTest_L1_inj%d.dat", injSimCount+1); if (vrbflg) fprintf( stdout, "writing L1 channel time series out to %s\n", chanfilename ); LALSPrintTimeSeries(chan, chanfilename ); break; default: fprintf( stderr, "Error: ifoNumber %d does not correspond to H1, H2 or L1: \n", ifoNumber ); exit( 1 ); } } LAL_CALL( LALCreateForwardRealFFTPlan( &status, &pfwd, chan->data->length, 0), &status); fftData = XLALCreateCOMPLEX8FrequencySeries( chan->name, &chan->epoch, f0, deltaF, &lalDimensionlessUnit, (numPoints / 2 + 1) ); if ( !fftData ){ XLALPrintError("failure allocating fftData"); exit(1); } LAL_CALL( LALTimeFreqRealFFT( &status, fftData, chan, pfwd ), &status); LAL_CALL( LALDestroyRealFFTPlan( &status, &pfwd ), &status); pfwd = NULL; /* compute the SNR */ thisSnrsq = 0; /* avoid f=0 part of psd */ if (ligosrd){ if (vrbflg) fprintf( stdout, "using LIGOI PSD \n"); for ( k = kLow; k < kHi; k++ ) { REAL8 freq; REAL8 sim_psd_value; freq = fftData->deltaF * k; LALLIGOIPsd( NULL, &sim_psd_value, freq ); thisSnrsq += ((crealf(fftData->data->data[k]) * dynRange) * (crealf(fftData->data->data[k]) * dynRange)) / sim_psd_value; thisSnrsq += ((cimagf(fftData->data->data[k]) * dynRange) * (cimagf(fftData->data->data[k]) * dynRange)) / sim_psd_value; } } else { if (vrbflg) fprintf( stdout, "using input spectra \n"); for ( k = kLow; k < kHi; k++ ) { thisSnrsq += ((crealf(fftData->data->data[k]) * dynRange) * (crealf(fftData->data->data[k]) * dynRange)) / (thisSpec->data->data[k] * dynRange * dynRange); thisSnrsq += ((cimagf(fftData->data->data[k]) * dynRange) * (cimagf(fftData->data->data[k]) * dynRange)) / (thisSpec->data->data[k] * dynRange * dynRange); } } thisSnrsq *= 4*fftData->deltaF; thisSnr = pow(thisSnrsq, 0.5); /* Note indexing on snrVec, ifoNumber runs from 1..3 to get source correct, * we must index snrVec 0..2 */ snrVec[ifoNumber-1] = thisSnr; XLALDestroyCOMPLEX8FrequencySeries(fftData); if ( vrbflg ){ fprintf( stdout, "thisSnrsq %e\n", thisSnrsq ); fprintf( stdout, "snrVec %e\n", snrVec[ifoNumber-1] ); fflush( stdout ); } /* sum thisSnrsq to eventually get combined snr*/ statValue += thisSnrsq; /* free some memory */ if (detector.transfer) detector.transfer = NULL; if ( detector.site ) {LALFree( detector.site); detector.site = NULL;} } /* end loop over ifo */ destroyCoherentGW( &waveform ); /* store inverse eff snrs in eff_dist columns */ thisInjection->eff_dist_h = 1./snrVec[0]; thisInjection->eff_dist_g = 1./snrVec[1]; thisInjection->eff_dist_l = 1./snrVec[2]; /* store inverse sum of squares snr in eff_dist_t */ thisCombSnr = pow(statValue, 0.5); if ( vrbflg ) fprintf( stdout, "thisCombSnr %e\n", thisCombSnr); thisInjection->eff_dist_t = 1./thisCombSnr; /* calc inverse bittenL snr for H1H2 and store in eff_dist_v */ thisCombSnr_H1H2 = 0.; sum = snrVec[0] * snrVec[0] + snrVec[1] * snrVec[1]; bitten_H1 = 3 * snrVec[0] -3; bitten_H2 = 3 * snrVec[1] -3; if (sum < bitten_H1){ thisCombSnr_H1H2 = sum; } else { thisCombSnr_H1H2 = bitten_H1; } if (bitten_H2 < thisCombSnr_H1H2){ thisCombSnr_H1H2 = bitten_H2; } thisInjection->eff_dist_v = 1./thisCombSnr_H1H2; /* increment the bank sim sim_inspiral table if necessary */ if ( injectionHead ) { thisInjection = thisInjection->next; } } while ( ++injSimCount < numInjections ); /* end loop over injections */ /* try opening, writing and closing an xml file */ /* open the output xml file */ memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); snprintf( fname, sizeof(fname), "%s", outputFile); LAL_CALL( LALOpenLIGOLwXMLFile ( &status, &xmlStream, fname), &status); /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, process_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); free( proctable.processTable ); /* Just being pedantic here ... */ proctable.processTable = NULL; /* free the unused process param entry */ this_proc_param = procparams.processParamsTable; procparams.processParamsTable = procparams.processParamsTable->next; free( this_proc_param ); this_proc_param = NULL; /* write the process params table */ if ( vrbflg ) fprintf( stdout, "process_params... " ); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_params_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, procparams, process_params_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); /* write the search summary table */ if ( coireflg ){ if ( vrbflg ) fprintf( stdout, "search_summary... " ); outputTable.searchSummaryTable = searchSummHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, search_summary_table), &status); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, search_summary_table), &status); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream), &status); } /* write the sim inspiral table */ if ( vrbflg ) fprintf( stdout, "sim_inspiral... " ); outputTable.simInspiralTable = injectionHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sim_inspiral_table), &status); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sim_inspiral_table), &status); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream), &status); /* write the sngl inspiral table */ if ( coireflg ){ if ( vrbflg ) fprintf( stdout, "sngl_inspiral... " ); outputTable.snglInspiralTable = snglHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sngl_inspiral_table), &status); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sngl_inspiral_table), &status); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream), &status); } /* close the xml file */ LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &xmlStream), &status); /* Freeing memory */ XLALDestroyREAL4TimeSeries(chan); XLALDestroyCOMPLEX8FrequencySeries(resp); XLALDestroyCOMPLEX8FrequencySeries(detTransDummy); XLALDestroyREAL8FrequencySeries ( specH1 ); XLALDestroyREAL8FrequencySeries ( specH2 ); XLALDestroyREAL8FrequencySeries ( specL1 ); free( specFileH1 ); specFileH1 = NULL; free( specFileH2 ); specFileH2 = NULL; free( specFileL1 ); specFileL1 = NULL; free( injectionFile ); injectionFile = NULL; /* free the process params */ while( procparams.processParamsTable ) { this_proc_param = procparams.processParamsTable; procparams.processParamsTable = this_proc_param->next; free( this_proc_param ); this_proc_param = NULL; } /* free the sim inspiral tables */ while ( injectionHead ) { thisInjection = injectionHead; injectionHead = injectionHead->next; LALFree( thisInjection ); } /*check for memory leaks */ LALCheckMemoryLeaks(); exit( 0 ); }
REAL8 XLALEThincaParameterForInjection( SimInspiralTable *injection, SnglInspiralTable *trigger ) { /* Trigger parameters */ REAL8 fLower; REAL8 mTotal; REAL8 tau0; REAL8 eta; /* Inj parameters */ InspiralTemplate injTmplt; /* Used to calculate parameters */ INT8 injEndTime; /* Parameter differences */ REAL8 dtC, dt0, dt3; REAL8 eMatch; LALStatus status; #ifndef LAL_NDEBUG if ( !injection || !trigger ) XLAL_ERROR_REAL8( XLAL_EFAULT ); #endif memset( &status, 0, sizeof(LALStatus)); /* We need the tau0 and tau3 for the injection */ /* To do this, we will need to calculate the lower frequency used in the * case of the inspiral trigger */ mTotal = trigger->mass1 + trigger->mass2; eta = trigger->eta; tau0 = trigger->tau0; mTotal = mTotal * LAL_MTSUN_SI; fLower = 5.0 / (256.0 * eta * pow(mTotal, 5.0/3.0) * tau0 ); fLower = pow(fLower, 3.0/8.0) / LAL_PI; XLALPrintInfo("%s: fLower found to be %e\n", __func__, fLower ); /* Now populate the inspiral template with relevant parameters */ injTmplt.mass1 = injection->mass1; injTmplt.mass2 = injection->mass2; injTmplt.massChoice = m1Andm2; injTmplt.fLower = fLower; injTmplt.order = LAL_PNORDER_THREE_POINT_FIVE; LALInspiralParameterCalc( &status, &injTmplt ); /* Get the GPS time from the injection*/ injEndTime = XLALReturnSimInspiralEndTime( injection, trigger->ifo ); dtC = ( injEndTime - XLALGPSToINT8NS( &(trigger->end_time) ) ) * 1.0e-9; dt0 = injTmplt.t0 - trigger->tau0; dt3 = injTmplt.t3 - trigger->tau3; eMatch = trigger->Gamma[0] * dtC * dtC + 2.0 * trigger->Gamma[1] * dtC * dt0 + 2.0 * trigger->Gamma[2] * dtC * dt3 + trigger->Gamma[3] * dt0 * dt0 + 2.0 * trigger->Gamma[4] * dt0 * dt3 + trigger->Gamma[5] * dt3 * dt3; return eMatch; }
void LALFindChirpClusterEvents ( LALStatus *status, SnglInspiralTable **eventList, FindChirpFilterInput *input, FindChirpFilterParams *params, FindChirpBankVetoData *bankVetoData, UINT4 subBankIndex, int writeCData, InspiralTemplate *bankCurrent ) { int xlalRetCode = 0; INT8 bvTimeNS = 0; UINT4 numPoints = 0; UINT4 ignoreIndex = 0; UINT4 eventStartIdx = 0; UINT4 deltaEventIndex = 0; UINT4 lowerIndex = 0; UINT4 upperIndex = 0; UINT4 buffer = 0; UINT4 bvTimeIndex = 0; UINT4 j, kmax; UINT4 doChisqFlag = 1; REAL4 norm = 0; REAL4 deltaT; REAL8 deltaF; REAL4 modqsqThresh = 0; REAL4 chisqThreshFac = 0; UINT4 numChisqBins = 0; COMPLEX8 *q = NULL; SnglInspiralTable *thisEvent = NULL; CHAR searchName[LIGOMETA_SEARCH_MAX]; UINT4 bvDOF = 0; REAL4 bvChisq = 0; UINT4 ccDOF = 0; REAL4 ccChisq = 0; INITSTATUS(status); ATTATCHSTATUSPTR( status ); /* * * check that the arguments are reasonable * */ /* make sure the output handle exists, but points to a null pointer */ ASSERT( eventList, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( !*eventList, status, FINDCHIRPH_ENNUL, FINDCHIRPH_MSGENNUL ); /* check the allowed approximants */ xlalRetCode = XLALInspiralGetApproximantString( searchName, LIGOMETA_SEARCH_MAX, params->approximant, params->order ); if ( xlalRetCode == XLAL_FAILURE ) { ABORTXLAL( status ); } /* make sure the approximant in the tmplt and segment agree */ if ( params->approximant != input->fcTmplt->tmplt.approximant || params->approximant != input->segment->approximant ) { ABORT( status, FINDCHIRPH_EAPRX, FINDCHIRPH_MSGEAPRX ); } /* * * set up the variables needed to cluster * */ q = params->qVec->data; numPoints = params->qVec->length; ignoreIndex = params->ignoreIndex; lowerIndex = ignoreIndex; upperIndex = numPoints - ignoreIndex; deltaT = params->deltaT; deltaF = 1.0 / ( (REAL4) params->deltaT * (REAL4) numPoints ); kmax = input->fcTmplt->tmplt.fFinal / deltaF < numPoints/2 ? input->fcTmplt->tmplt.fFinal / deltaF : numPoints/2; /* normalisation */ norm = input->fcTmplt->norm; /* normalised snr threhold */ modqsqThresh = params->rhosqThresh / norm; /* the length of the chisq bin vec is the number of bin boundaries so the */ /* number of chisq bins is (length - 1) or 0 if there are no boundaries */ numChisqBins = input->segment->chisqBinVec->length ? input->segment->chisqBinVec->length - 1 : 0; /* we threshold on the "modified" chisq threshold computed from */ /* chisqThreshFac = chisqDelta * norm / p */ /* */ /* rho^2 = norm * modqsq */ /* */ /* So we actually threshold on */ /* */ /* r^2 < chisqThresh * ( 1 + modqsq * chisqThreshFac ) */ /* */ /* which is the same as thresholding on */ /* r^2 < chisqThresh * ( 1 + rho^2 * chisqDelta / p ) */ /* and since */ /* chisq = p r^2 */ /* this is equivalent to thresholding on */ /* chisq < chisqThresh * ( p + rho^2 chisqDelta ) */ /* */ /* The raw chisq is stored in the database. this quantity is chisq */ /* distributed with 2p-2 degrees of freedom. */ chisqThreshFac = norm * params->chisqDelta / (REAL4) numChisqBins; /* * * Apply one of the clustering algorithms * */ /* set deltaEventIndex depending on clustering method used */ if ( params->clusterMethod == FindChirpClustering_tmplt ) { deltaEventIndex = (UINT4) rint( (input->fcTmplt->tmplt.tC / deltaT) + 1.0 ); } else if ( params->clusterMethod == FindChirpClustering_window ) { deltaEventIndex = (UINT4) rint( (params->clusterWindow / deltaT) + 1.0 ); } else if ( params->clusterMethod == FindChirpClustering_tmpltwindow ) { if ( input->fcTmplt->tmplt.tC > params->clusterWindow ) { deltaEventIndex = (UINT4) rint( (input->fcTmplt->tmplt.tC / deltaT) + 1.0 ); } else { deltaEventIndex = (UINT4) rint( (params->clusterWindow / deltaT) + 1.0 ); } } /* In coherent stage cluster around trigbank-coherent triggers */ if (writeCData) { /* set the event LIGO GPS time of the bankVetoTrigger */ bvTimeNS = 1000000000L * (INT8) (bankCurrent->end_time.gpsSeconds); bvTimeNS += (INT8) (bankCurrent->end_time.gpsNanoSeconds); bvTimeNS -= XLALGPSToINT8NS( &(input->segment->data->epoch) ); bvTimeIndex = (UINT4) rint( ((REAL8) bvTimeNS)/ (deltaT*1.0e9) ); buffer = (UINT4) rint( 64.0 / deltaT ); if ( (bvTimeIndex < buffer ) || (bvTimeIndex > (numPoints-buffer) ) ) { upperIndex = 0; lowerIndex = 0; } else { lowerIndex = ( ( bvTimeIndex > deltaEventIndex ) ? (bvTimeIndex) : 0 ); upperIndex = bvTimeIndex + deltaEventIndex; } } /* look for an events in the filter output */ for ( j = lowerIndex; j < upperIndex; ++j ) { REAL4 modqsq = crealf(q[j]) * crealf(q[j]) + cimagf(q[j]) * cimagf(q[j]); /* if snrsq exceeds threshold at any point */ if ( modqsq > modqsqThresh ) { /* If it crosses the threshold see if we need to do a chisq test since this is no longer computed in FindChirpFilterSegment */ if ( input->segment->chisqBinVec->length && doChisqFlag) { /* compute the chisq vector for this segment */ memset( params->chisqVec->data, 0, params->chisqVec->length * sizeof(REAL4) ); /* pointers to chisq input */ params->chisqInput->qtildeVec = params->qtildeVec; params->chisqInput->qVec = params->qVec; /* pointer to the chisq bin vector in the segment */ params->chisqParams->chisqBinVec = input->segment->chisqBinVec; params->chisqParams->norm = norm; /* compute the chisq bin boundaries for this template */ if (params->chisqParams->chisqBinVec->data) { LALFree(params->chisqParams->chisqBinVec->data); params->chisqParams->chisqBinVec->data = NULL; } LALFindChirpComputeChisqBins( status->statusPtr, params->chisqParams->chisqBinVec, input->segment, kmax ); CHECKSTATUSPTR( status ); /* compute the chisq threshold: this is slow! */ LALFindChirpChisqVeto( status->statusPtr, params->chisqVec, params->chisqInput, params->chisqParams ); CHECKSTATUSPTR (status); doChisqFlag = 0; } /* if we have don't have a chisq or the chisq drops below the */ /* modified chisq threshold, start processing events */ if ( ! input->segment->chisqBinVec->length || params->chisqVec->data[j] < (params->chisqThresh * ( 1.0 + modqsq * chisqThreshFac )) ) { if (1) /* eventually check bank veto ! */ { /* * * find the local maximum of the event * */ if ( ! *eventList ) { /* store the start of the crossing */ eventStartIdx = j; /* if this is the first event, start the list */ thisEvent = *eventList = (SnglInspiralTable *) LALCalloc( 1, sizeof(SnglInspiralTable) ); if ( ! thisEvent ) { ABORT( status, FINDCHIRPH_EALOC, FINDCHIRPH_MSGEALOC ); } /* record the data that we need for the clustering algorithm */ thisEvent->end_time.gpsSeconds = j; thisEvent->snr = modqsq; } else if ( ! params->clusterMethod == FindChirpClustering_none && j <= thisEvent->end_time.gpsSeconds + deltaEventIndex && modqsq > thisEvent->snr ) { /* if this is the same event, update the maximum */ thisEvent->end_time.gpsSeconds = j; thisEvent->snr = modqsq; } else if ( j > thisEvent->end_time.gpsSeconds + deltaEventIndex || params->clusterMethod == FindChirpClustering_none ) { /* clean up this event */ SnglInspiralTable *lastEvent; if ( bankVetoData->length > 1 ) { bvChisq = XLALComputeBankVeto( bankVetoData, subBankIndex, thisEvent->end_time.gpsSeconds, deltaT, &bvDOF); } if ( !writeCData ) { ccChisq = XLALComputeFullChisq(bankVetoData,input,params,q, subBankIndex, thisEvent->end_time.gpsSeconds, &ccDOF, norm); } LALFindChirpStoreEvent(status->statusPtr, input, params, thisEvent, q, kmax, norm, eventStartIdx, numChisqBins, searchName ); CHECKSTATUSPTR( status ); /* Set bank_chisq and cont_chisq */ thisEvent->bank_chisq_dof = bvDOF; thisEvent->bank_chisq = bvChisq; thisEvent->cont_chisq_dof = ccDOF; thisEvent->cont_chisq = ccChisq; if ( writeCData ) { if ( !thisEvent->event_id ) thisEvent->event_id = (EventIDColumn *) LALCalloc(1, sizeof(EventIDColumn) ); thisEvent->event_id->id = bankVetoData->fcInputArray[subBankIndex]->fcTmplt->tmplt.event_id->id; } /* store the start of the crossing */ eventStartIdx = j; /* allocate memory for the newEvent */ lastEvent = thisEvent; lastEvent->next = thisEvent = (SnglInspiralTable *) LALCalloc( 1, sizeof(SnglInspiralTable) ); if ( ! lastEvent->next ) { ABORT( status, FINDCHIRPH_EALOC, FINDCHIRPH_MSGEALOC ); } /* stick minimal data into the event */ thisEvent->end_time.gpsSeconds = j; thisEvent->snr = modqsq; } } /* end if bank veto */ } /* end if chisq */ } } /* * * clean up last event * */ if ( thisEvent ) { if ( bankVetoData->length > 1 ) { bvChisq = XLALComputeBankVeto( bankVetoData, subBankIndex, thisEvent->end_time.gpsSeconds, deltaT, &bvDOF); } if ( !writeCData ) { ccChisq = XLALComputeFullChisq(bankVetoData, input,params,q, subBankIndex, thisEvent->end_time.gpsSeconds, &ccDOF, norm); } LALFindChirpStoreEvent(status->statusPtr, input, params, thisEvent, q, kmax, norm, eventStartIdx, numChisqBins, searchName ); thisEvent->bank_chisq_dof = bvDOF; thisEvent->bank_chisq = bvChisq; thisEvent->cont_chisq_dof = ccDOF; thisEvent->cont_chisq = ccChisq; if ( writeCData ) { if ( !thisEvent->event_id ) thisEvent->event_id = (EventIDColumn *) LALCalloc(1, sizeof(EventIDColumn) ); thisEvent->event_id->id = bankVetoData->fcInputArray[subBankIndex]->fcTmplt->tmplt.event_id->id; } CHECKSTATUSPTR( status ); } /* normal exit */ DETATCHSTATUSPTR( status ); RETURN( status ); }
int XLALSimRingdownInSearchedData( SimRingdownTable **eventHead, SearchSummaryTable **summList ) { SearchSummaryTable *thisSearchSumm = NULL; SimRingdownTable *eventList = NULL; SimRingdownTable *prevEvent = NULL; SimRingdownTable *thisEvent = NULL; int numInj = 0; XLALTimeSortSearchSummary( summList, LALCompareSearchSummaryByOutTime ); XLALSortSimRingdown( eventHead, XLALCompareSimRingdownByGeocentStartTime ); thisEvent = *eventHead; thisSearchSumm = *summList; while ( thisEvent ) { SimRingdownTable *tmpEvent = thisEvent; thisEvent = thisEvent->next; while ( thisSearchSumm ) { if ( geocent_start_time(tmpEvent) < XLALGPSToINT8NS( &(thisSearchSumm->out_start_time) )) { XLALPrintInfo( "XLALSimRingdownInSearchedData: Discarding injection\n" ); LALFree( tmpEvent ); break; } else { if ( geocent_start_time(tmpEvent) < XLALGPSToINT8NS( &(thisSearchSumm->out_end_time) )) { XLALPrintInfo( "XLALSimRingdownInSearchedData: Keeping injection\n" ); numInj++; if ( ! eventList ) { eventList = tmpEvent; } else { prevEvent->next = tmpEvent; } tmpEvent->next = NULL; prevEvent = tmpEvent; break; } } thisSearchSumm = thisSearchSumm->next; } if ( !thisSearchSumm ) { XLALPrintInfo( "XLALSimRingdownInSearchedData: Discarding injection\n" ); LALFree( tmpEvent ); } } *eventHead = eventList; return(numInj); }
void XLALPlayTestSimRingdown( SimRingdownTable **eventHead, LALPlaygroundDataMask *dataType ) { SimRingdownTable *ringdownEventList = NULL; SimRingdownTable *thisEvent = NULL; SimRingdownTable *prevEvent = NULL; INT8 triggerTime = 0; INT4 isPlay = 0; INT4 numTriggers; /* Remove all the triggers which are not of the desired type */ numTriggers = 0; thisEvent = *eventHead; if ( (*dataType == playground_only) || (*dataType == exclude_play) ) { while ( thisEvent ) { SimRingdownTable *tmpEvent = thisEvent; thisEvent = thisEvent->next; triggerTime = XLALGPSToINT8NS( &(tmpEvent->geocent_start_time) ); isPlay = XLALINT8NanoSecIsPlayground( triggerTime ); if ( ( (*dataType == playground_only) && isPlay ) || ( (*dataType == exclude_play) && ! isPlay) ) { /* keep this trigger */ if ( ! ringdownEventList ) { ringdownEventList = tmpEvent; } else { prevEvent->next = tmpEvent; } tmpEvent->next = NULL; prevEvent = tmpEvent; ++numTriggers; } else { /* discard this template */ XLALFreeSimRingdown ( &tmpEvent ); } } *eventHead = ringdownEventList; if ( *dataType == playground_only ) { XLALPrintInfo( "Kept %d playground triggers \n", numTriggers ); } else if ( *dataType == exclude_play ) { XLALPrintInfo( "Kept %d non-playground triggers \n", numTriggers ); } } else if ( *dataType == all_data ) { XLALPrintInfo( "XLALPlayTestSimRingdown: Keeping all triggers\n" ); } else { XLALPrintInfo( "XLALPlayTestSimRingdown: Unknown data type, returning no triggers\n" ); *eventHead = NULL; } }
int XLALSnglSimRingdownTest ( SimRingdownTable **simHead, SnglRingdownTable **eventHead, SimRingdownTable **missedSimHead, SnglRingdownTable **missedSnglHead, INT8 injectWindowNS ) { /* Note: we are assuming that both the ringdown and */ /* injection events are time sorted */ SimRingdownTable *thisSimEvent = *simHead; SimRingdownTable *thisMissedSim= NULL; SimRingdownTable *prevSimEvent = NULL; SnglRingdownTable *thisEvent = *eventHead; SnglRingdownTable *prevEvent = NULL; SnglRingdownTable *thisMissed = NULL; EventIDColumn *thisId = NULL; int numSimFound = 0; int coincidence = 0; INT8 simGeocentTime, simSiteTime, ringdownTime; INT8 earthRadiusNS = (INT8) ( 1e9 * 2 * LAL_REARTH_SI / LAL_C_SI ); *simHead = NULL; *eventHead = NULL; if ( ! thisEvent ) { XLALPrintInfo( "No triggers in input data, all injections missed\n" ); *missedSimHead = thisSimEvent; return(0); } else { /* begin loop over the sim_ringdown events */ while ( thisSimEvent ) { coincidence = 0; /* find the end time of the SimEvent */ simGeocentTime = geocent_start_time( thisSimEvent ); /* find the first ringdown event after the current sim event */ while ( thisEvent ) { /* compute the time in nanosec for thisEvent */ ringdownTime = XLALGPSToINT8NS( &(thisEvent->start_time) ); if( ringdownTime < (simGeocentTime - earthRadiusNS - injectWindowNS ) ) { /* discard this event and move on to the next one */ if ( ! *missedSnglHead ) { *missedSnglHead = thisMissed = thisEvent; } else { thisMissed = thisMissed->next = thisEvent; } if ( prevEvent ) prevEvent->next = thisEvent->next; thisEvent = thisEvent->next; thisMissed->next = NULL; XLALPrintInfo( "-" ); } else { /* we have reached the negative coincincidence window */ break; } } while ( thisEvent ) { /* compute the time in nanosec for thisEvent */ ringdownTime = XLALGPSToINT8NS( &(thisEvent->start_time) ); if( ringdownTime < (simGeocentTime + earthRadiusNS + injectWindowNS ) ) { /* this event may be in coincidence window, need to check site * end time */ simSiteTime = XLALReturnSimRingdownStartTime( thisSimEvent, thisEvent->ifo ); if ( (ringdownTime > (simSiteTime - injectWindowNS)) && (ringdownTime < (simSiteTime + injectWindowNS)) ) { /* this event is within the coincidence window */ /* store the sim ringdown in the event_id's for this sngl */ thisId = thisEvent->event_id; while ( thisId ) { thisId->simRingdownTable = thisSimEvent; thisId = thisId->next; } /* store this event and move on to the next one */ if ( ! *eventHead ) *eventHead = thisEvent; prevEvent = thisEvent; thisEvent = thisEvent->next; coincidence = 1; XLALPrintInfo( "+" ); } else { /* discard this event and move on to the next one */ if ( ! *missedSnglHead ) { *missedSnglHead = thisMissed = thisEvent; } else { thisMissed = thisMissed->next = thisEvent; } if ( prevEvent ) prevEvent->next = thisEvent->next; thisEvent = thisEvent->next; thisMissed->next = NULL; XLALPrintInfo( "-" ); } } else { /* we have reached the end of the positive coincincidence window */ break; } } if ( coincidence ) { /* keep this sim event in the list and move to the next sim event */ if ( ! *simHead ) *simHead = thisSimEvent; prevSimEvent = thisSimEvent; ++numSimFound; thisSimEvent = thisSimEvent->next; XLALPrintInfo( "F" ); } else { /* save this sim event in the list of missed events... */ if ( ! *missedSimHead ) { *missedSimHead = thisMissedSim = thisSimEvent; } else { thisMissedSim = thisMissedSim->next = thisSimEvent; } /* ...and remove it from the list of found events */ if ( prevSimEvent ) prevSimEvent->next = thisSimEvent->next; XLALPrintInfo( "M" ); /* move to the next sim in the list */ thisSimEvent = thisSimEvent->next; /* make sure the missed sim list is terminated */ thisMissedSim->next = NULL; } if ( ! thisEvent ) { /* these are no more events to process so all the rest of the */ /* injections must be put in the missed injections list */ if ( ! *missedSimHead ) { /* this and any subsequent events are in the missed sim list */ if ( thisSimEvent ) thisMissedSim = *missedSimHead = thisSimEvent; } else { if ( thisSimEvent ) { /* append the rest of the list to the list of missed injections */ thisMissedSim = thisMissedSim->next = thisSimEvent; } else { /* there are no injections after this one */ thisMissedSim = thisMissedSim->next = NULL; } } /* terminate the list of found injections correctly */ if ( prevSimEvent ) prevSimEvent->next = NULL; while ( thisMissedSim ) { /* count the number of injections just stuck in the missed list */ XLALPrintInfo( "M" ); thisMissedSim = thisMissedSim->next; } thisSimEvent = NULL; break; } } if ( thisEvent ) { while( thisEvent ) { /* discard this event and move on to the next one */ if ( ! *missedSnglHead ) { *missedSnglHead = thisMissed = thisEvent; } else { thisMissed = thisMissed->next = thisEvent; } if ( prevEvent ) prevEvent->next = thisEvent->next; thisEvent = thisEvent->next; thisMissed->next = NULL; XLALPrintInfo( "-" ); } } } XLALPrintInfo( "\n" ); return( numSimFound ); }
int main( int argc, char *argv[] ) { /* lal initialization variables */ LALStatus status = blank_status; /* program option variables */ CHAR *userTag = NULL; CHAR comment[LIGOMETA_COMMENT_MAX]; char *ifoName = NULL; char *inputGlob = NULL; char *inputFileName = NULL; char *outputFileName = NULL; char *tamaFileName = NULL; char *summFileName = NULL; REAL4 snrStar = -1; SnglInspiralClusterChoice clusterchoice = none; INT8 cluster_dt = -1; char *injectFileName = NULL; INT8 inject_dt = -1; char *missedFileName = NULL; INT4 hardware = 0; int enableTrigStartTime = 1; int j; FILE *fp = NULL; glob_t globbedFiles; int numInFiles = 0; char **inFileNameList; char line[MAX_PATH]; int errnum; UINT8 triggerInputTimeNS = 0; MetadataTable proctable; MetadataTable procparams; ProcessParamsTable *this_proc_param; UINT4 numSimEvents = 0; UINT4 numSimInData = 0; UINT4 numSimFound = 0; UINT4 numSimMissed = 0; UINT4 numSimDiscard = 0; UINT4 numSimProcessed = 0; SimRingdownTable *simEventHead = NULL; SimRingdownTable *thisSimEvent = NULL; SimRingdownTable *missedSimHead = NULL; SimRingdownTable *thisMissedSim = NULL; SimRingdownTable *tmpSimEvent = NULL; SimRingdownTable *prevSimEvent = NULL; SearchSummaryTable *searchSummaryTable = NULL; UINT4 numEvents = 0; UINT4 numEventsKept = 0; UINT4 numEventsInIFO = 0; UINT4 numEventsCoinc = 0; UINT4 numEventsDiscard = 0; UINT4 numEventsProcessed = 0; UINT4 numClusteredEvents = 0; SnglRingdownTable **eventHandle = NULL; SnglRingdownTable *eventHead = NULL; SnglRingdownTable *thisEvent = NULL; SnglRingdownTable *tmpEvent = NULL; SnglRingdownTable *prevEvent = NULL; LIGOLwXMLStream xmlStream; MetadataTable outputTable; /* * * initialization * */ /* set up inital debugging values */ lal_errhandler = LAL_ERR_EXIT; /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); XLALGPSTimeNow(&(proctable.processTable->start_time)); XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, lalAppsVCSIdentId, lalAppsVCSIdentStatus, lalAppsVCSIdentDate, 0); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); memset( comment, 0, LIGOMETA_COMMENT_MAX * sizeof(CHAR) ); /* * * parse command line arguments * */ while (1) { /* LALgetopt arguments */ static struct LALoption long_options[] = { {"verbose", no_argument, &vrbflg, 1 }, {"sort-triggers", no_argument, &sortTriggers, 1 }, {"help", no_argument, 0, 'h'}, {"user-tag", required_argument, 0, 'Z'}, {"userTag", required_argument, 0, 'Z'}, {"comment", required_argument, 0, 'c'}, {"version", no_argument, 0, 'V'}, {"glob", required_argument, 0, 'g'}, {"input", required_argument, 0, 'i'}, {"output", required_argument, 0, 'o'}, {"data-type", required_argument, 0, 'k'}, {"tama-output", required_argument, 0, 'j'}, {"summary-file", required_argument, 0, 'S'}, {"snr-threshold", required_argument, 0, 's'}, {"cluster-algorithm", required_argument, 0, 'C'}, {"cluster-time", required_argument, 0, 't'}, {"ifo-cut", required_argument, 0, 'd'}, {"injection-file", required_argument, 0, 'I'}, {"injection-coincidence", required_argument, 0, 'T'}, {"missed-injections", required_argument, 0, 'm'}, {"hardware-injections", required_argument, 0, 'H'}, {"disable-trig-start-time", no_argument, 0, 'D'}, {0, 0, 0, 0} }; int c; /* LALgetopt_long stores the option index here. */ int option_index = 0; size_t LALoptarg_len; c = LALgetopt_long_only ( argc, argv, "hZ:c:d:g:i:o:j:S:s:C:Vt:I:T:m:H:D", long_options, &option_index ); /* detect the end of the options */ if ( c == - 1 ) break; switch ( c ) { case 0: /* if this option set a flag, do nothing else now */ if ( long_options[option_index].flag != 0 ) { break; } else { fprintf( stderr, "error parsing option %s with argument %s\n", long_options[option_index].name, LALoptarg ); exit( 1 ); } break; case 'h': fprintf( stdout, USAGE ); exit( 0 ); break; case 'Z': /* create storage for the usertag */ LALoptarg_len = strlen( LALoptarg ) + 1; userTag = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR) ); memcpy( userTag, LALoptarg, LALoptarg_len ); this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "-userTag" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, "%s", LALoptarg ); break; case 'c': if ( strlen( LALoptarg ) > LIGOMETA_COMMENT_MAX - 1 ) { fprintf( stderr, "invalid argument to --%s:\n" "comment must be less than %d characters\n", long_options[option_index].name, LIGOMETA_COMMENT_MAX ); exit( 1 ); } else { snprintf( comment, LIGOMETA_COMMENT_MAX, "%s", LALoptarg); } break; case 'V': fprintf( stdout, "Single Ringdown Reader and Injection Analysis\n" "Patrick Brady, Duncan Brown and Steve Fairhurst\n"); XLALOutputVersionString(stderr, 0); exit( 0 ); break; case 'g': /* create storage for the input file glob */ LALoptarg_len = strlen( LALoptarg ) + 1; inputGlob = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( inputGlob, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "'%s'", LALoptarg ); break; case 'i': /* create storage for the input file name */ LALoptarg_len = strlen( LALoptarg ) + 1; inputFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( inputFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'o': /* create storage for the output file name */ LALoptarg_len = strlen( LALoptarg ) + 1; outputFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( outputFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'j': /* create storage of the TAMA file name */ LALoptarg_len = strlen( LALoptarg ) + 1; tamaFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( tamaFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'S': /* create storage for the summ file name */ LALoptarg_len = strlen( LALoptarg ) + 1; summFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( summFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 's': snrStar = (REAL4) atof( LALoptarg ); if ( snrStar < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "threshold must be >= 0: " "(%f specified)\n", long_options[option_index].name, snrStar ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", snrStar ); break; case 'k': /* type of data to analyze */ if ( ! strcmp( "playground_only", LALoptarg ) ) { dataType = playground_only; } else if ( ! strcmp( "exclude_play", LALoptarg ) ) { dataType = exclude_play; } else if ( ! strcmp( "all_data", LALoptarg ) ) { dataType = all_data; } else { fprintf( stderr, "invalid argument to --%s:\n" "unknown data type, %s, specified: " "(must be playground_only, exclude_play or all_data)\n", long_options[option_index].name, LALoptarg ); exit( 1 ); } ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'C': /* choose the clustering algorithm */ { if ( ! strcmp( "snr_and_chisq", LALoptarg ) ) { clusterchoice = snr_and_chisq; } else if ( ! strcmp( "snrsq_over_chisq", LALoptarg) ) { clusterchoice = snrsq_over_chisq; } else if ( ! strcmp( "snr", LALoptarg) ) { clusterchoice = snr; } else { fprintf( stderr, "invalid argument to --%s:\n" "unknown clustering specified:\n " "%s (must be one of: snr_and_chisq, \n" " snrsq_over_chisq or snr)\n", long_options[option_index].name, LALoptarg); exit( 1 ); } ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); } break; case 't': /* cluster time is specified on command line in ms */ cluster_dt = (INT8) atoi( LALoptarg ); if ( cluster_dt <= 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "custer window must be > 0: " "(%" LAL_INT8_FORMAT " specified)\n", long_options[option_index].name, cluster_dt ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%" LAL_INT8_FORMAT "", cluster_dt ); /* convert cluster time from ms to ns */ cluster_dt *= LAL_INT8_C(1000000); break; case 'I': /* create storage for the injection file name */ LALoptarg_len = strlen( LALoptarg ) + 1; injectFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( injectFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'd': LALoptarg_len = strlen( LALoptarg ) + 1; ifoName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( ifoName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'T': /* injection coincidence time is specified on command line in ms */ inject_dt = (INT8) atoi( LALoptarg ); if ( inject_dt < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "injection coincidence window must be >= 0: " "(%" LAL_INT8_FORMAT " specified)\n", long_options[option_index].name, inject_dt ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%" LAL_INT8_FORMAT " ", inject_dt ); /* convert inject time from ms to ns */ inject_dt *= LAL_INT8_C(1000000); break; case 'm': /* create storage for the missed injection file name */ LALoptarg_len = strlen( LALoptarg ) + 1; missedFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( missedFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'H': hardware = (INT4) atoi( LALoptarg ); if ( hardware <= 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "GPS start time of hardware injections must be > 0: " "(%d specified)\n", long_options[option_index].name, hardware ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%" LAL_INT4_FORMAT " ", hardware ); break; case 'D': enableTrigStartTime = 0; ADD_PROCESS_PARAM( "string", "%s", " " ); break; case '?': exit( 1 ); break; default: fprintf( stderr, "unknown error while parsing options\n" ); exit( 1 ); } } if ( LALoptind < argc ) { fprintf( stderr, "extraneous command line arguments:\n" ); while ( LALoptind < argc ) { fprintf ( stderr, "%s\n", argv[LALoptind++] ); } exit( 1 ); } /* * * can use LALCalloc() / LALMalloc() from here * */ /* don't buffer stdout if we are in verbose mode */ if ( vrbflg ) setvbuf( stdout, NULL, _IONBF, 0 ); /* fill the comment, if a user has specified it, or leave it blank */ if ( ! *comment ) { snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); } else { snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, "%s", comment ); } /* check that the input and output file names have been specified */ if ( (! inputGlob && ! inputFileName) || (inputGlob && inputFileName) ) { fprintf( stderr, "exactly one of --glob or --input must be specified\n" ); exit( 1 ); } if ( ! outputFileName ) { fprintf( stderr, "--output must be specified\n" ); exit( 1 ); } /* check that Data Type has been specified */ if ( dataType == unspecified_data_type ) { fprintf( stderr, "Error: --data-type must be specified\n"); exit(1); } /* check that if clustering is being done that we have all the options */ if ( clusterchoice && cluster_dt < 0 ) { fprintf( stderr, "--cluster-time must be specified if --cluster-algorithm " "is given\n" ); exit( 1 ); } else if ( ! clusterchoice && cluster_dt >= 0 ) { fprintf( stderr, "--cluster-algorithm must be specified if --cluster-time " "is given\n" ); exit( 1 ); } /* check that we have all the options to do injections */ if ( injectFileName && inject_dt < 0 ) { fprintf( stderr, "--injection-coincidence must be specified if " "--injection-file is given\n" ); exit( 1 ); } else if ( ! injectFileName && inject_dt >= 0 ) { fprintf( stderr, "--injection-file must be specified if " "--injection-coincidence is given\n" ); exit( 1 ); } /* save the sort triggers flag */ if ( sortTriggers ) { this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "--sort-triggers" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } switch ( dataType ) { case playground_only: if ( vrbflg ) fprintf( stdout, "using data from playground times only\n" ); snprintf( procparams.processParamsTable->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( procparams.processParamsTable->param, LIGOMETA_PARAM_MAX, "--playground-only" ); snprintf( procparams.processParamsTable->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( procparams.processParamsTable->value, LIGOMETA_TYPE_MAX, " " ); break; case exclude_play: if ( vrbflg ) fprintf( stdout, "excluding all triggers in playground times\n" ); snprintf( procparams.processParamsTable->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( procparams.processParamsTable->param, LIGOMETA_PARAM_MAX, "--exclude-play" ); snprintf( procparams.processParamsTable->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( procparams.processParamsTable->value, LIGOMETA_TYPE_MAX, " " ); break; case all_data: if ( vrbflg ) fprintf( stdout, "using all input data\n" ); snprintf( procparams.processParamsTable->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( procparams.processParamsTable->param, LIGOMETA_PARAM_MAX, "--all-data" ); snprintf( procparams.processParamsTable->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( procparams.processParamsTable->value, LIGOMETA_TYPE_MAX, " " ); break; default: fprintf( stderr, "data set not defined\n" ); exit( 1 ); } /* * * read in the injection XML file, if we are doing an injection analysis * */ if ( injectFileName ) { if ( vrbflg ) fprintf( stdout, "reading injections from %s... ", injectFileName ); simEventHead = XLALSimRingdownTableFromLIGOLw( injectFileName, 0, 0 ); if ( vrbflg ) fprintf( stdout, "got %d injections\n", numSimEvents ); if ( ! simEventHead ) { fprintf( stderr, "error: unable to read sim_ringdown table from %s\n", injectFileName ); exit( 1 ); } /* if we are doing hardware injections, increment all the start times */ if ( hardware ) { if ( vrbflg ) fprintf( stdout, "incrementing GPS times of injections by %d seconds\n", hardware ); for ( thisSimEvent = simEventHead; thisSimEvent; thisSimEvent = thisSimEvent->next ) { thisSimEvent->geocent_start_time.gpsSeconds += hardware; thisSimEvent->h_start_time.gpsSeconds += hardware; thisSimEvent->l_start_time.gpsSeconds += hardware; } } /* discard all injection events that are not in the data we want */ if ( dataType != all_data ) { numSimDiscard = 0; thisSimEvent = simEventHead; simEventHead = NULL; prevSimEvent = NULL; if ( vrbflg ) fprintf( stdout, "discarding injections not in data\n" ); while ( thisSimEvent ) { INT4 isPlayground = XLALINT8NanoSecIsPlayground(XLALGPSToINT8NS(&(thisSimEvent->geocent_start_time))); if ( (dataType == playground_only && isPlayground) || (dataType == exclude_play && ! isPlayground) ) { /* store the head of the linked list */ if ( ! simEventHead ) simEventHead = thisSimEvent; /* keep this event */ prevSimEvent = thisSimEvent; thisSimEvent = thisSimEvent->next; ++numSimInData; if ( vrbflg ) fprintf( stdout, "+" ); } else { /* throw this event away */ tmpSimEvent = thisSimEvent; if ( prevSimEvent ) prevSimEvent->next = thisSimEvent->next; thisSimEvent = thisSimEvent->next; LALFree( tmpSimEvent ); ++numSimDiscard; if ( vrbflg ) fprintf( stdout, "-" ); } } if ( vrbflg ) fprintf( stdout, "\nusing %d (discarded %d) of %d injections\n", numSimInData, numSimDiscard, numSimEvents ); } else { if ( vrbflg ) fprintf( stdout, "using all %d injections\n", numSimInData ); numSimInData = numSimEvents; } } /* * * read in the input triggers from the xml files * */ if ( inputGlob ) { /* use glob() to get a list of the input file names */ if ( glob( inputGlob, GLOB_ERR, NULL, &globbedFiles ) ) { fprintf( stderr, "error globbing files from %s\n", inputGlob ); perror( "error:" ); exit( 1 ); } numInFiles = globbedFiles.gl_pathc; inFileNameList = (char **) LALCalloc( numInFiles, sizeof(char *) ); for ( j = 0; j < numInFiles; ++j ) { inFileNameList[j] = globbedFiles.gl_pathv[j]; } } else if ( inputFileName ) { /* read the list of input filenames from a file */ fp = fopen( inputFileName, "r" ); if ( ! fp ) { fprintf( stderr, "could not open file containing list of xml files\n" ); perror( "error:" ); exit( 1 ); } /* count the number of lines in the file */ while ( get_next_line( line, sizeof(line), fp ) ) { ++numInFiles; } rewind( fp ); /* allocate memory to store the input file names */ inFileNameList = (char **) LALCalloc( numInFiles, sizeof(char *) ); /* read in the input file names */ for ( j = 0; j < numInFiles; ++j ) { inFileNameList[j] = (char *) LALCalloc( MAX_PATH, sizeof(char) ); get_next_line( line, sizeof(line), fp ); strncpy( inFileNameList[j], line, strlen(line) - 1); } fclose( fp ); } else { fprintf( stderr, "no input file mechanism specified\n" ); exit( 1 ); } if ( vrbflg ) { fprintf( stdout, "reading input triggers from:\n" ); for ( j = 0; j < numInFiles; ++j ) { fprintf( stdout, "%s\n", inFileNameList[j] ); } } /* * * read in the triggers from the input xml files * */ if ( injectFileName ) { thisSimEvent = simEventHead; simEventHead = NULL; prevSimEvent = NULL; numSimDiscard = 0; numSimInData = 0; if ( vrbflg ) fprintf( stdout, "discarding injections not in input data\n" ); } for ( j = 0; j < numInFiles; ++j ) { LIGOTimeGPS inPlay, outPlay; UINT8 outPlayNS, outStartNS, outEndNS, triggerTimeNS; INT4 trigStartTimeArg = 0; searchSummaryTable = XLALSearchSummaryTableFromLIGOLw( inFileNameList[j] ); if ( ( ! searchSummaryTable ) || searchSummaryTable->next ) { fprintf( stderr, "error: zero or multiple search_summary tables in %s\n", inFileNameList[j] ); exit( 1 ); } if ( enableTrigStartTime ) { /* override the value of out_start_time if there is a non-zero */ /* --trig-start-time option in the process_params table */ /* this is necessary to get round a bug in early versions of */ /* the ringdown code */ int mioStatus; int pParParam; int pParValue; struct MetaioParseEnvironment parseEnv; const MetaioParseEnv env = &parseEnv; /* open the procress_params table from the input file */ mioStatus = MetaioOpenTable( env, inFileNameList[j], "process_params" ); if ( mioStatus ) { fprintf( stderr, "error opening process_params table from file %s\n", inFileNameList[j] ); exit( 1 ); } /* figure out where the param and value columns are */ if ( (pParParam = MetaioFindColumn( env, "param" )) < 0 ) { fprintf( stderr, "unable to find column param in process_params\n" ); MetaioClose(env); exit( 1 ); } if ( (pParValue = MetaioFindColumn( env, "value" )) < 0 ) { fprintf( stderr, "unable to find column value in process_params\n" ); MetaioClose(env); exit( 1 ); } /* get the trigger start time from the process params */ while ( (mioStatus = MetaioGetRow(env)) == 1 ) { if ( ! strcmp( env->ligo_lw.table.elt[pParParam].data.lstring.data, "--trig-start-time" ) ) { trigStartTimeArg = (INT4) atoi( env->ligo_lw.table.elt[pParValue].data.lstring.data ); } } MetaioClose( env ); if ( trigStartTimeArg ) { searchSummaryTable->out_start_time.gpsSeconds = trigStartTimeArg; searchSummaryTable->out_start_time.gpsNanoSeconds = 0; if ( vrbflg ) fprintf( stdout, "file %s has --trig-start-time %d\n", inFileNameList[j], trigStartTimeArg ); } } /* compute the out time from the search summary table */ outStartNS = XLALGPSToINT8NS ( &(searchSummaryTable->out_start_time) ); outEndNS = XLALGPSToINT8NS ( &(searchSummaryTable->out_end_time) ); triggerTimeNS = outEndNS - outStartNS; /* check for events and playground */ if ( dataType != all_data ) { LAL_CALL( LALPlaygroundInSearchSummary( &status, searchSummaryTable, &inPlay, &outPlay ), &status ); outPlayNS = XLALGPSToINT8NS ( &outPlay ); if ( dataType == playground_only ) { if ( outPlayNS ) { /* increment the total trigger time by the amount of playground */ triggerInputTimeNS += outPlayNS; } else { /* skip this file as it does not contain any playground data */ if ( vrbflg ) { fprintf( stdout, "file %s not in playground, continuing\n", inFileNameList[j] ); } LALFree( searchSummaryTable ); searchSummaryTable = NULL; continue; } } else if ( dataType == exclude_play ) { /* increment the total trigger time by the out time minus */ /* the time that is in the playground */ triggerInputTimeNS += triggerTimeNS - outPlayNS; } } else { /* increment the total trigger time by the out time minus */ triggerInputTimeNS += triggerTimeNS; } if ( injectFileName ) { if ( vrbflg ) fprintf( stdout, "discarding injections not in file: " ); /* throw away injections that are outside analyzed times */ while ( thisSimEvent && thisSimEvent->geocent_start_time.gpsSeconds < searchSummaryTable->out_end_time.gpsSeconds ) { /* check if injection is before file start time */ if ( thisSimEvent->geocent_start_time.gpsSeconds < searchSummaryTable->out_start_time.gpsSeconds ) { /* discard the current injection */ if ( prevSimEvent ) prevSimEvent->next = thisSimEvent->next; tmpSimEvent = thisSimEvent; thisSimEvent = thisSimEvent->next; LALFree( tmpSimEvent ); ++numSimDiscard; if ( vrbflg ) fprintf( stdout, "-" ); } else { /* store the head of the linked list */ if ( ! simEventHead ) simEventHead = thisSimEvent; /* keep this injection */ prevSimEvent = thisSimEvent; thisSimEvent = thisSimEvent->next; ++numSimInData; if ( vrbflg ) fprintf( stdout, "+" ); } } if ( vrbflg ) fprintf( stdout, "\n" ); } /* * * if there are any events in the file, read them in * */ if ( searchSummaryTable->nevents ) { INT4 isPlay; if ( vrbflg ) fprintf( stdout, "file %s contains %d events, processing\n", inFileNameList[j], searchSummaryTable->nevents ); if ( ! prevEvent ) { eventHandle = &thisEvent; } else { eventHandle = &(prevEvent->next); } /* read the events from the file into a temporary list */ XLAL_TRY( *eventHandle = XLALSnglRingdownTableFromLIGOLw( inFileNameList[j] ), errnum); if ( ! *eventHandle ) switch ( errnum ) { case XLAL_EDATA: XLALPrintError("Unable to read sngl_ringdown table from %s\n", inFileNameList[j] ); /*LALFree(thisInputFile);*/ XLALClearErrno(); break; default: XLALSetErrno( errnum ); XLAL_ERROR(XLAL_EFUNC ); } /* only keep triggers from the data that we want to analyze */ thisEvent = *eventHandle; while ( thisEvent ) { numEvents++; isPlay = XLALINT8NanoSecIsPlayground( XLALGPSToINT8NS( &(thisEvent->start_time) ) ); if ( (dataType == all_data || (dataType == playground_only && isPlay) || (dataType == exclude_play && ! isPlay)) && ( snrStar < 0 || thisEvent->snr > snrStar) ) { /* keep the trigger and increment the count of triggers */ if ( ! eventHead ) eventHead = thisEvent; prevEvent = thisEvent; thisEvent = thisEvent->next; ++numEventsKept; } else { /* discard the trigger and move to the next one */ if ( prevEvent ) prevEvent->next = thisEvent->next; tmpEvent = thisEvent; thisEvent = thisEvent->next; LAL_CALL ( LALFreeSnglRingdown ( &status, &tmpEvent ), &status); } } /* make sure that the linked list is properly terminated */ if ( prevEvent && prevEvent->next ) prevEvent->next->next = NULL; } else { if ( vrbflg ) fprintf( stdout, "file %s contains no events, skipping\n", inFileNameList[j] ); } LALFree( searchSummaryTable ); searchSummaryTable = NULL; } /* discard the remaining injections which occured after the last file */ if ( injectFileName ) { if ( vrbflg ) fprintf( stdout, "kept %d injections, discarded %d\n", numSimInData, numSimDiscard ); if ( prevSimEvent ) prevSimEvent->next = NULL; numSimDiscard = 0; while ( thisSimEvent ) { tmpSimEvent = thisSimEvent; thisSimEvent = thisSimEvent->next; LALFree( tmpSimEvent ); ++numSimDiscard; if ( vrbflg ) fprintf( stdout, "-" ); } if ( vrbflg ) fprintf( stdout, "\ndiscarded %d injections at end of list\n", numSimDiscard ); } /* * * sort the ringdown events by time * */ if ( injectFileName || sortTriggers ) { if ( vrbflg ) fprintf( stdout, "sorting ringdown trigger list..." ); LAL_CALL( LALSortSnglRingdown( &status, &eventHead, *LALCompareSnglRingdownByTime ), &status ); if ( vrbflg ) fprintf( stdout, "done\n" ); } /* * * keep only event from requested ifo * */ if ( ifoName ) { if ( vrbflg ) fprintf( stdout, "keeping only triggers from %s, discarding others...", ifoName ); LAL_CALL( LALIfoCutSingleRingdown( &status, &eventHead, ifoName ), &status ); LALIfoCountSingleRingdown( &status, &numEventsInIFO, eventHead, XLALIFONumber(ifoName) ); if ( vrbflg ) fprintf( stdout, "done\n" ); } /* * * check for events that are coincident with injections * */ if ( injectFileName ) { int coincidence = 0; UINT8 simTime, ringdownTime; if ( vrbflg ) fprintf( stdout, "checking for events that are coincident with injections\n" ); /* Note: we are assuming that both the ringdown and */ /* injection events are time sorted */ thisSimEvent = simEventHead; thisEvent = eventHead; simEventHead = NULL; eventHead = NULL; prevSimEvent = NULL; prevEvent = NULL; numSimFound = 0; numSimDiscard = 0; numEventsDiscard = 0; numEventsCoinc = 0; if ( ! thisEvent ) { /* no triggers in the input data, so all injections are missed */ if ( vrbflg ) fprintf( stdout, "no triggers in input data\n" ); thisMissedSim = missedSimHead = thisSimEvent; while ( thisMissedSim ) { /* count the number of injections just stuck in the missed list */ if ( vrbflg ) fprintf( stdout, "M" ); ++numSimMissed; ++numSimProcessed; thisMissedSim = thisMissedSim->next; } } else { /* begin loop over the sim_ringdown events */ while ( thisSimEvent ) { /* compute the end time in nanosec for the injection */ /* at the relevant detector */ if ( ! strcmp( "L1", thisEvent->ifo ) ) { simTime = XLALGPSToINT8NS ( &(thisSimEvent->l_start_time) ); } else if ( ! strcmp( "H1", thisEvent->ifo ) || ! strcmp( "H2", thisEvent->ifo ) ) { simTime = XLALGPSToINT8NS ( &(thisSimEvent->h_start_time) ); } else { fprintf( stderr, "unknown detector found in event list: %s\n", thisEvent->ifo ); fprintf( stderr, "Detector must be one of (G1|H1|H2|L1|T1|V1)\n"); exit( 1 ); } /* find the first ringdown event after the current sim event */ while ( thisEvent ) { coincidence = 0; /* compute the time in nanosec for the ringdown */ ringdownTime = XLALGPSToINT8NS ( &(thisEvent->start_time) ); if ( ringdownTime < (simTime - inject_dt) ) { /* discard this event and move on to the next one */ if ( prevEvent ) prevEvent->next = thisEvent->next; tmpEvent = thisEvent; thisEvent = thisEvent->next; LAL_CALL ( LALFreeSnglRingdown ( &status, &tmpEvent ), &status); ++numEventsProcessed; ++numEventsDiscard; if ( vrbflg ) fprintf( stdout, "-" ); } else { /* we have reached the negative coincincidence window */ break; } } while ( thisEvent ) { /* compute the time in nanosec for the ringdown */ ringdownTime = XLALGPSToINT8NS ( &(thisEvent->start_time) ); if ( ringdownTime < (simTime + inject_dt) ) { /* this event is within the coincidence window */ /* store this event and move on to the next one */ if ( ! eventHead ) eventHead = thisEvent; prevEvent = thisEvent; thisEvent = thisEvent->next; coincidence = 1; ++numEventsProcessed; ++numEventsCoinc; if ( vrbflg ) fprintf( stdout, "+" ); } else { /* we have reached the end of the positive coincincidence window */ break; } } if ( coincidence ) { /* keep this event in the list and move to the next sim event */ if ( ! simEventHead ) simEventHead = thisSimEvent; prevSimEvent = thisSimEvent; ++numSimFound; ++numSimProcessed; thisSimEvent = thisSimEvent->next; if ( vrbflg ) fprintf( stdout, "F" ); } else { /* save this sim event in the list of missed events... */ if ( ! missedSimHead ) { missedSimHead = thisMissedSim = thisSimEvent; } else { thisMissedSim = thisMissedSim->next = thisSimEvent; } /* ...and remove it from the list of found events */ if ( prevSimEvent ) prevSimEvent->next = thisSimEvent->next; ++numSimMissed; if ( vrbflg ) fprintf( stdout, "M" ); /* move to the next sim in the list */ ++numSimProcessed; thisSimEvent = thisSimEvent->next; /* make sure the missed sim list is terminated */ thisMissedSim->next = NULL; } if ( ! thisEvent ) { /* these are no more events to process so all the rest of the */ /* injections must be put in the missed injections list */ if ( ! missedSimHead ) { /* this and any subsequent events are in the missed sim list */ if ( thisSimEvent ) thisMissedSim = missedSimHead = thisSimEvent; } else { if ( thisSimEvent ) { /* append the rest of the list to the list of missed injections */ thisMissedSim = thisMissedSim->next = thisSimEvent; } else { /* there are no injections after this one */ thisMissedSim = thisMissedSim->next = NULL; } } /* terminate the list of found injections correctly */ if ( prevSimEvent ) prevSimEvent->next = NULL; while ( thisMissedSim ) { /* count the number of injections just stuck in the missed list */ if ( vrbflg ) fprintf( stdout, "M" ); ++numSimMissed; ++numSimProcessed; thisMissedSim = thisMissedSim->next; } thisSimEvent = NULL; break; } } if ( thisEvent ) { /* discard any remaining ringdown triggers -- including thisEvent */ /* as we have run out of injections */ tmpEvent = thisEvent; if ( prevEvent ) prevEvent->next = NULL; while ( tmpEvent ) { thisEvent = tmpEvent; tmpEvent = tmpEvent->next; LAL_CALL ( LALFreeSnglRingdown ( &status, &thisEvent ), &status); ++numEventsDiscard; ++numEventsProcessed; if ( vrbflg ) fprintf( stdout, "-" ); } } } if ( vrbflg ) { fprintf( stdout, "\nfound %d injections, missed %d injections " "(%d injections processed)\n", numSimFound, numSimMissed, numSimProcessed ); fprintf( stdout, "found %d coincident events, %d events discarded " "(%d events processed)\n", numEventsCoinc, numEventsDiscard, numEventsProcessed ); } } /* end if ( injectFileName ) */ /* * * cluster the remaining events * */ if ( eventHead && clusterchoice ) { if ( vrbflg ) fprintf( stdout, "clustering remaining triggers... " ); LAL_CALL( LALClusterSnglRingdownTable( &status, eventHead, cluster_dt, clusterchoice ), &status ); if ( vrbflg ) fprintf( stdout, "done\n" ); /* count the number of triggers surviving the clustering */ thisEvent = eventHead; numClusteredEvents = 0; while ( thisEvent ) { ++numClusteredEvents; thisEvent = thisEvent->next; } } /* * * write output data * */ /* write the main output file containing found injections */ if ( vrbflg ) fprintf( stdout, "writing output xml files... " ); memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlStream, outputFileName ), &status ); /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); XLALGPSTimeNow(&(proctable.processTable->start_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, process_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); free( proctable.processTable ); /* write the process params table */ if ( vrbflg ) fprintf( stdout, "process_params... " ); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_params_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, procparams, process_params_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); /* Write the found injections to the sim table */ if ( simEventHead ) { if ( vrbflg ) fprintf( stdout, "sim_ringdown... " ); outputTable.simRingdownTable = simEventHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sim_ringdown_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sim_ringdown_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream ), &status ); } /* Write the results to the ringdown table */ if ( eventHead ) { if ( vrbflg ) fprintf( stdout, "sngl_ringdown... " ); outputTable.snglRingdownTable = eventHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sngl_ringdown_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sngl_ringdown_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream ), &status); } /* close the output file */ LAL_CALL( LALCloseLIGOLwXMLFile(&status, &xmlStream), &status); if ( vrbflg ) fprintf( stdout, "done\n" ); /* write out the TAMA file if it is requested */ if ( tamaFileName ) { /* FIXME */ REAL8 UNUSED trigtime; fp = fopen( tamaFileName, "w" ); if ( ! fp ) { perror( "TAMA file" ); exit( 1 ); } fprintf( fp, "IFO trigger time snr chisq " " total mass eta eff dist (kpc)\n" ); for ( thisEvent = eventHead; thisEvent; thisEvent = thisEvent->next ) { trigtime = XLALGPSGetREAL8(&(thisEvent->start_time)); } fclose( fp ); } if ( missedFileName ) { /* open the missed injections file and write the missed injections to it */ if ( vrbflg ) fprintf( stdout, "writing missed injections... " ); memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlStream, missedFileName ), &status ); if ( missedSimHead ) { outputTable.simRingdownTable = missedSimHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sim_ringdown_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sim_ringdown_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream ), &status ); } LAL_CALL( LALCloseLIGOLwXMLFile( &status, &xmlStream ), &status ); if ( vrbflg ) fprintf( stdout, "done\n" ); } if ( summFileName ) { LIGOTimeGPS triggerTime; /* write out a summary file */ fp = fopen( summFileName, "w" ); switch ( dataType ) { case playground_only: fprintf( fp, "using data from playground times only\n" ); break; case exclude_play: fprintf( fp, "excluding all triggers in playground times\n" ); break; case all_data: fprintf( fp, "using all input data\n" ); break; default: fprintf( stderr, "data set not defined\n" ); exit( 1 ); } fprintf( fp, "read triggers from %d files\n", numInFiles ); fprintf( fp, "number of triggers in input files: %d \n", numEvents ); if ( snrStar >= 0 ) { fprintf( fp, "number of triggers in input data with snr above %f: %d \n", snrStar, numEventsKept ); } else { fprintf( fp, "number of triggers in input data %d \n", numEventsKept ); } if ( ifoName ) { fprintf( fp, "number of triggers from %s ifo %d \n", ifoName, numEventsInIFO ); } XLALINT8NSToGPS( &triggerTime, triggerInputTimeNS ); fprintf( fp, "amount of time analysed for triggers %d sec %d ns\n", triggerTime.gpsSeconds, triggerTime.gpsNanoSeconds ); if ( injectFileName ) { fprintf( fp, "read %d injections from file %s\n", numSimEvents, injectFileName ); fprintf( fp, "number of injections in input data: %d\n", numSimInData ); fprintf( fp, "number of injections found in input data: %d\n", numSimFound ); fprintf( fp, "number of triggers found within %" LAL_INT8_FORMAT "msec of injection: %d\n", (inject_dt / LAL_INT8_C(1000000) ), numEventsCoinc ); fprintf( fp, "efficiency: %f \n", (REAL4) numSimFound / (REAL4) numSimInData ); } if ( clusterchoice ) { fprintf( fp, "number of event clusters with %" LAL_INT8_FORMAT " msec window: %d\n", cluster_dt/ LAL_INT8_C(1000000), numClusteredEvents ); } fclose( fp ); } /* * * free memory and exit * */ /* free the ringdown events we saved */ while ( eventHead ) { thisEvent = eventHead; eventHead = eventHead->next; LAL_CALL ( LALFreeSnglRingdown ( &status, &thisEvent ), &status); } /* free the process params */ while( procparams.processParamsTable ) { this_proc_param = procparams.processParamsTable; procparams.processParamsTable = this_proc_param->next; free( this_proc_param ); } /* free the found injections */ while ( simEventHead ) { thisSimEvent = simEventHead; simEventHead = simEventHead->next; LALFree( thisSimEvent ); } /* free the temporary memory containing the missed injections */ while ( missedSimHead ) { tmpSimEvent = missedSimHead; missedSimHead = missedSimHead->next; LALFree( tmpSimEvent ); } /* free the input file name data */ if ( inputGlob ) { LALFree( inFileNameList ); globfree( &globbedFiles ); } else { for ( j = 0; j < numInFiles; ++j ) { LALFree( inFileNameList[j] ); } LALFree( inFileNameList ); } if ( vrbflg ) fprintf( stdout, "checking memory leaks and exiting\n" ); LALCheckMemoryLeaks(); exit( 0 ); }
/** * \brief Provides an interface between code build from \ref lalinspiral_findchirp and * various simulation packages for injecting chirps into data. * \author Brown, D. A. and Creighton, T. D * * Injects the signals described * in the linked list of \c SimInspiralTable structures \c events * into the data \c chan. The response function \c resp should * contain the response function to use when injecting the signals into the data. */ void LALFindChirpInjectIMR ( LALStatus *status, REAL4TimeSeries *chan, SimInspiralTable *events, SimRingdownTable *ringdownevents, COMPLEX8FrequencySeries *resp, INT4 injectSignalType ) { UINT4 k; DetectorResponse detector; SimInspiralTable *thisEvent = NULL; SimRingdownTable *thisRingdownEvent = NULL; PPNParamStruc ppnParams; CoherentGW waveform, *wfm; INT8 waveformStartTime; REAL4TimeSeries signalvec; COMPLEX8Vector *unity = NULL; CHAR warnMsg[512]; #if 0 UINT4 n; UINT4 i; #endif INITSTATUS(status); ATTATCHSTATUSPTR( status ); ASSERT( chan, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( chan->data, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( chan->data->data, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( events, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( resp, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( resp->data, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); ASSERT( resp->data->data, status, FINDCHIRPH_ENULL, FINDCHIRPH_MSGENULL ); /* * * set up structures and parameters needed * */ /* fixed waveform injection parameters */ memset( &ppnParams, 0, sizeof(PPNParamStruc) ); ppnParams.deltaT = chan->deltaT; ppnParams.lengthIn = 0; ppnParams.ppn = NULL; /* * * compute the transfer function from the given response function * */ /* allocate memory and copy the parameters describing the freq series */ memset( &detector, 0, sizeof( DetectorResponse ) ); detector.transfer = (COMPLEX8FrequencySeries *) LALCalloc( 1, sizeof(COMPLEX8FrequencySeries) ); if ( ! detector.transfer ) { ABORT( status, FINDCHIRPH_EALOC, FINDCHIRPH_MSGEALOC ); } memcpy( &(detector.transfer->epoch), &(resp->epoch), sizeof(LIGOTimeGPS) ); detector.transfer->f0 = resp->f0; detector.transfer->deltaF = resp->deltaF; detector.site = (LALDetector *) LALMalloc( sizeof(LALDetector) ); /* set the detector site */ switch ( chan->name[0] ) { case 'H': *(detector.site) = lalCachedDetectors[LALDetectorIndexLHODIFF]; LALWarning( status, "computing waveform for Hanford." ); break; case 'L': *(detector.site) = lalCachedDetectors[LALDetectorIndexLLODIFF]; LALWarning( status, "computing waveform for Livingston." ); break; case 'G': *(detector.site) = lalCachedDetectors[LALDetectorIndexGEO600DIFF]; LALWarning( status, "computing waveform for GEO600." ); break; case 'T': *(detector.site) = lalCachedDetectors[LALDetectorIndexTAMA300DIFF]; LALWarning( status, "computing waveform for TAMA300." ); break; case 'V': *(detector.site) = lalCachedDetectors[LALDetectorIndexVIRGODIFF]; LALWarning( status, "computing waveform for Virgo." ); break; default: LALFree( detector.site ); detector.site = NULL; LALWarning( status, "Unknown detector site, computing plus mode " "waveform with no time delay" ); break; } /* set up units for the transfer function */ if (XLALUnitDivide( &(detector.transfer->sampleUnits), &lalADCCountUnit, &lalStrainUnit ) == NULL) { ABORTXLAL(status); } /* invert the response function to get the transfer function */ LALCCreateVector( status->statusPtr, &( detector.transfer->data ), resp->data->length ); CHECKSTATUSPTR( status ); LALCCreateVector( status->statusPtr, &unity, resp->data->length ); CHECKSTATUSPTR( status ); for ( k = 0; k < resp->data->length; ++k ) { unity->data[k] = 1.0; } LALCCVectorDivide( status->statusPtr, detector.transfer->data, unity, resp->data ); CHECKSTATUSPTR( status ); LALCDestroyVector( status->statusPtr, &unity ); CHECKSTATUSPTR( status ); thisRingdownEvent = ringdownevents; /* * * loop over the signals and inject them into the time series * */ for ( thisEvent = events; thisEvent; thisEvent = thisEvent->next) { /* * * generate waveform and inject it into the data * */ /* clear the waveform structure */ memset( &waveform, 0, sizeof(CoherentGW) ); LALGenerateInspiral(status->statusPtr, &waveform, thisEvent, &ppnParams); CHECKSTATUSPTR( status ); /* add the ringdown */ wfm = XLALGenerateInspRing( &waveform, thisEvent, thisRingdownEvent, injectSignalType ); if ( !wfm ) { fprintf( stderr, "Failed to generate the waveform \n" ); if (xlalErrno == XLAL_EFAILED) { fprintf( stderr, "Too much merger\n"); XLALDestroyREAL4TimeSeries( chan ); xlalErrno = XLAL_SUCCESS; return; } else exit ( 1 ); } waveform = *wfm; LALInfo( status, ppnParams.termDescription ); if ( thisEvent->geocent_end_time.gpsSeconds ) { /* get the gps start time of the signal to inject */ waveformStartTime = XLALGPSToINT8NS( &(thisEvent->geocent_end_time) ); waveformStartTime -= (INT8) ( 1000000000.0 * ppnParams.tc ); } else { LALInfo( status, "Waveform start time is zero: injecting waveform " "into center of data segment" ); /* center the waveform in the data segment */ waveformStartTime = XLALGPSToINT8NS( &(chan->epoch) ); waveformStartTime += (INT8) ( 1000000000.0 * ((REAL8) (chan->data->length - ppnParams.length) / 2.0) * chan->deltaT ); } snprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg), "Injected waveform timing:\n" "thisEvent->geocent_end_time.gpsSeconds = %d\n" "thisEvent->geocent_end_time.gpsNanoSeconds = %d\n" "ppnParams.tc = %e\n" "waveformStartTime = %" LAL_INT8_FORMAT "\n", thisEvent->geocent_end_time.gpsSeconds, thisEvent->geocent_end_time.gpsNanoSeconds, ppnParams.tc, waveformStartTime ); LALInfo( status, warnMsg ); /* clear the signal structure */ memset( &signalvec, 0, sizeof(REAL4TimeSeries) ); /* set the start times for injection */ XLALINT8NSToGPS( &(waveform.a->epoch), waveformStartTime ); memcpy( &(waveform.f->epoch), &(waveform.a->epoch), sizeof(LIGOTimeGPS) ); memcpy( &(waveform.phi->epoch), &(waveform.a->epoch), sizeof(LIGOTimeGPS) ); /* set the start time of the signal vector to the start time of the chan */ signalvec.epoch = chan->epoch; /* set the parameters for the signal time series */ signalvec.deltaT = chan->deltaT; if ( ( signalvec.f0 = chan->f0 ) != 0 ) { ABORT( status, FINDCHIRPH_EHETR, FINDCHIRPH_MSGEHETR ); } signalvec.sampleUnits = lalADCCountUnit; /* simulate the detectors response to the inspiral */ LALSCreateVector( status->statusPtr, &(signalvec.data), chan->data->length ); CHECKSTATUSPTR( status ); LALSimulateCoherentGW( status->statusPtr, &signalvec, &waveform, &detector ); CHECKSTATUSPTR( status ); /* *****************************************************************************/ #if 0 FILE *fp; char fname[512]; UINT4 jj, kplus, kcross; snprintf( fname, sizeof(fname) / sizeof(*fname), "waveform-%d-%d-%s.txt", thisEvent->geocent_end_time.gpsSeconds, thisEvent->geocent_end_time.gpsNanoSeconds, thisEvent->waveform ); fp = fopen( fname, "w" ); for( jj = 0, kplus = 0, kcross = 1; jj < waveform.phi->data->length; ++jj, kplus += 2, kcross +=2 ) { fprintf(fp, "%d %e %e %le %e\n", jj, waveform.a->data->data[kplus], waveform.a->data->data[kcross], waveform.phi->data->data[jj], waveform.f->data->data[jj]); } fclose( fp ); #endif /* ********************************************************************************/ #if 0 FILE *fp; char fname[512]; UINT4 jj; snprintf( fname, sizeof(fname) / sizeof(*fname), "waveform-%d-%d-%s.txt", thisEvent->geocent_end_time.gpsSeconds, thisEvent->geocent_end_time.gpsNanoSeconds, thisEvent->waveform ); fp = fopen( fname, "w" ); for( jj = 0; jj < signalvec.data->length; ++jj ) { fprintf(fp, "%d %e %e \n", jj, signalvec.data->data[jj]); } fclose( fp ); #endif /* ********************************************************************************/ /* inject the signal into the data channel */ LALSSInjectTimeSeries( status->statusPtr, chan, &signalvec ); CHECKSTATUSPTR( status ); /* allocate and go to next SimRingdownTable */ if( thisEvent->next ) thisRingdownEvent = thisRingdownEvent->next = (SimRingdownTable *) calloc( 1, sizeof(SimRingdownTable) ); else thisRingdownEvent->next = NULL; /* destroy the signal */ LALSDestroyVector( status->statusPtr, &(signalvec.data) ); CHECKSTATUSPTR( status ); LALSDestroyVectorSequence( status->statusPtr, &(waveform.a->data) ); CHECKSTATUSPTR( status ); LALSDestroyVector( status->statusPtr, &(waveform.f->data) ); CHECKSTATUSPTR( status ); LALDDestroyVector( status->statusPtr, &(waveform.phi->data) ); CHECKSTATUSPTR( status ); if ( waveform.shift ) { LALSDestroyVector( status->statusPtr, &(waveform.shift->data) ); CHECKSTATUSPTR( status ); } LALFree( waveform.a ); LALFree( waveform.f ); LALFree( waveform.phi ); if ( waveform.shift ) { LALFree( waveform.shift ); } } LALCDestroyVector( status->statusPtr, &( detector.transfer->data ) ); CHECKSTATUSPTR( status ); if ( detector.site ) LALFree( detector.site ); LALFree( detector.transfer ); DETATCHSTATUSPTR( status ); RETURN( status ); }
static int runtest(const struct TESTCASE *testcase) { int retval; LIGOTimeGPS gps; LIGOTimeGPS gpsCorrect; char *endptr; int failure = 0; XLALGPSSet(&gpsCorrect, testcase->sec, testcase->ns); XLALClearErrno(); retval = XLALStrToGPS(&gps, testcase->string, &endptr); if(retval == 0 && testcase->xlal_errno == 0) { if(XLALGPSCmp(&gps, &gpsCorrect) || strcmp(endptr, testcase->remainder)) failure = 1; } else if(XLALGetBaseErrno() != testcase->xlal_errno) failure = 1; if(lalDebugLevel || failure) fprintf(stdout, "Input = \"%s\"\n\tOutput =\t%" LAL_INT8_FORMAT " ns with \"%s\" remainder, errno %d\n\tCorrect =\t%" LAL_INT8_FORMAT " ns with \"%s\" remainder, errno %d\n\t\t===> %s\n", testcase->string, XLALGPSToINT8NS(&gps), endptr, XLALGetBaseErrno(), XLALGPSToINT8NS(&gpsCorrect), testcase->remainder, testcase->xlal_errno, failure ? "*** FAIL ***" : "Pass"); return failure; }
REAL8 XLALCalculateEThincaParameter( SnglInspiralTable *table1, SnglInspiralTable *table2, InspiralAccuracyList* accuracyParams ) { TriggerErrorList * errorList[2]; REAL8 travelTime; INT4 i; INT4 ifoANum, ifoBNum; fContactWorkSpace *workSpace; REAL8 ethinca; EThincaMinimizer *minimizer = NULL; #ifndef LAL_NDEBUG if ( !table1 || !table2 || !accuracyParams) XLAL_ERROR_REAL8( XLAL_EFAULT ); #endif memset( errorList, 0, 2 * sizeof(TriggerErrorList *) ); /* Before we do anything, check we have triggers from different ifos */ if ( !strcmp(table1->ifo, table2->ifo) ) { XLALPrintError("%s: Triggers provided are from the same ifo!\n", __func__ ); XLAL_ERROR_REAL8( XLAL_EINVAL ); } /* Allocate memory */ errorList[0] = LALCalloc( 1, sizeof( TriggerErrorList )); if (errorList[0]) { errorList[1] = errorList[0]->next = LALCalloc( 1, sizeof( TriggerErrorList )); } if (!errorList[0] || !errorList[1] ) { if (errorList[0]) XLALDestroyTriggerErrorList( errorList[0] ); XLAL_ERROR_REAL8( XLAL_ENOMEM ); } workSpace = XLALInitFContactWorkSpace( 3, NULL, NULL, gsl_min_fminimizer_brent, 1.0e-5 ); if (!workSpace) { XLALDestroyTriggerErrorList( errorList[0] ); XLAL_ERROR_REAL8( XLAL_EFUNC | XLALClearErrno() ); } /* Set up the trigger lists */ if ( XLALGPSToINT8NS( &(table1->end_time) ) < XLALGPSToINT8NS( &(table2->end_time )) ) { errorList[0]->trigger = table1; errorList[1]->trigger = table2; } else { errorList[0]->trigger = table2; errorList[1]->trigger = table1; } for (i = 0; i < 2; i++ ) { errorList[i]->position = XLALGetPositionFromSnglInspiral( errorList[i]->trigger ); errorList[i]->err_matrix = XLALGetErrorMatrixFromSnglInspiral( errorList[i]->trigger, 1.0 ); if ( !errorList[i]->position || !errorList[i]->err_matrix ) { XLALDestroyTriggerErrorList( errorList[0] ); XLALFreeFContactWorkSpace( workSpace ); XLAL_ERROR_REAL8( XLAL_ENOMEM ); } } /* Set the travel time */ ifoANum = XLALIFONumber( errorList[0]->trigger->ifo ); ifoBNum = XLALIFONumber( errorList[1]->trigger->ifo ); travelTime = accuracyParams->lightTravelTime[ifoANum][ifoBNum] * 1.0e-9; /* Create the e-thinca minimizer */ minimizer = LALCalloc( 1, sizeof(EThincaMinimizer) ); if ( !minimizer ) { XLALDestroyTriggerErrorList( errorList[0] ); XLALFreeFContactWorkSpace( workSpace ); XLAL_ERROR_REAL8( XLAL_ENOMEM ); } minimizer->workSpace = workSpace; minimizer->aPtr = errorList[0]; minimizer->bPtr = errorList[1]; ethinca = XLALMinimizeEThincaParameterOverTravelTime( travelTime, minimizer, accuracyParams->exttrig ); if ( XLAL_IS_REAL8_FAIL_NAN( ethinca ) ) { LALFree( minimizer ); XLALDestroyTriggerErrorList( errorList[0] ); XLALFreeFContactWorkSpace( workSpace ); XLAL_ERROR_REAL8( XLAL_EFUNC ); } LALFree ( minimizer ); XLALDestroyTriggerErrorList( errorList[0] ); XLALFreeFContactWorkSpace( workSpace ); XLALPrintInfo( " I leave here and return an ethinca of %e.\n", ethinca ); return ethinca; }
static struct options parse_command_line(int *argc, char **argv[], const ProcessTable *process, ProcessParamsTable **paramaddpoint) { struct options options = options_defaults(); int c; int option_index; struct LALoption long_options[] = { {"gps-end-time", required_argument, NULL, 'A'}, {"gps-start-time", required_argument, NULL, 'B'}, {"help", no_argument, NULL, 'C'}, {"max-amplitude", required_argument, NULL, 'D'}, {"min-amplitude", required_argument, NULL, 'E'}, {"max-bandwidth", required_argument, NULL, 'F'}, {"min-bandwidth", required_argument, NULL, 'G'}, {"max-duration", required_argument, NULL, 'H'}, {"min-duration", required_argument, NULL, 'I'}, {"max-e-over-r2", required_argument, NULL, 'S'}, {"min-e-over-r2", required_argument, NULL, 'T'}, {"max-frequency", required_argument, NULL, 'J'}, {"min-frequency", required_argument, NULL, 'K'}, {"max-hrss", required_argument, NULL, 'L'}, {"min-hrss", required_argument, NULL, 'M'}, {"output", required_argument, NULL, 'V'}, {"population", required_argument, NULL, 'N'}, {"q", required_argument, NULL, 'O'}, {"ra-dec", required_argument, NULL, 'U'}, {"seed", required_argument, NULL, 'P'}, {"time-step", required_argument, NULL, 'Q'}, {"time-slide-file", required_argument, NULL, 'W'}, {"jitter", required_argument, NULL, 'X'}, {"user-tag", required_argument, NULL, 'R'}, {NULL, 0, NULL, 0} }; do switch(c = LALgetopt_long(*argc, *argv, "", long_options, &option_index)) { case 'A': XLALClearErrno(); { LIGOTimeGPS tmp; XLALStrToGPS(&tmp, LALoptarg, NULL); options.gps_end_time = XLALGPSToINT8NS(&tmp); } if(xlalErrno) { fprintf(stderr, "invalid --%s (%s specified)\n", long_options[option_index].name, LALoptarg); exit(1); } ADD_PROCESS_PARAM(process, "lstring"); break; case 'B': XLALClearErrno(); { LIGOTimeGPS tmp; XLALStrToGPS(&tmp, LALoptarg, NULL); options.gps_start_time = XLALGPSToINT8NS(&tmp); } if(xlalErrno) { fprintf(stderr, "invalid --%s (%s specified)\n", long_options[option_index].name, LALoptarg); exit(1); } ADD_PROCESS_PARAM(process, "lstring"); break; case 'C': print_usage(); exit(0); case 'D': options.maxA = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'E': options.minA = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'F': options.maxbandwidth = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'G': options.minbandwidth = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'H': options.maxduration = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'I': options.minduration = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'J': options.maxf = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'K': options.minf = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'L': options.maxhrss = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'M': options.minhrss = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'N': if(!strcmp(LALoptarg, "targeted")) options.population = POPULATION_TARGETED; else if(!strcmp(LALoptarg, "string_cusp")) options.population = POPULATION_STRING_CUSP; else if(!strcmp(LALoptarg, "all_sky_sinegaussian")) options.population = POPULATION_ALL_SKY_SINEGAUSSIAN; else if(!strcmp(LALoptarg, "all_sky_btlwnb")) options.population = POPULATION_ALL_SKY_BTLWNB; else { fprintf(stderr, "error: unrecognized population \"%s\"", LALoptarg); exit(1); } ADD_PROCESS_PARAM(process, "lstring"); break; case 'O': options.q = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'P': options.seed = atol(LALoptarg); ADD_PROCESS_PARAM(process, "int_8u"); break; case 'Q': options.time_step = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'R': options.user_tag = LALoptarg; ADD_PROCESS_PARAM(process, "lstring"); break; case 'S': options.maxEoverr2 = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'T': options.minEoverr2 = atof(LALoptarg); ADD_PROCESS_PARAM(process, "real_8"); break; case 'U': { char *end; options.ra = strtod(LALoptarg, &end); while(isspace(*end)) end++; if(*end != ',') { fprintf(stderr, "error: cannot parse --ra-dec \"%s\"\n", LALoptarg); exit(1); } options.dec = strtod(end + 1, &end); while(isspace(*end)) end++; if(*end != '\0') { fprintf(stderr, "error: cannot parse --ra-dec \"%s\"\n", LALoptarg); exit(1); } } ADD_PROCESS_PARAM(process, "lstring"); break; case 'V': options.output = LALoptarg; break; case 'W': options.time_slide_file = LALoptarg; ADD_PROCESS_PARAM(process, "lstring"); break; case 'X': options.jitter = atof(LALoptarg); ADD_PROCESS_PARAM(process, "lstring"); break; case 0: /* option sets a flag */ break; case -1: /* end of arguments */ break; case '?': /* unrecognized option */ print_usage(); exit(1); case ':': /* missing argument for an option */ print_usage(); exit(1); } while(c != -1); /* check some of the input parameters for consistency */ if(options.maxA < options.minA) { fprintf(stderr, "error: --max-amplitude < --min-amplitude\n"); exit(1); } if(options.maxbandwidth < options.minbandwidth) { fprintf(stderr, "error: --max-bandwidth < --min-bandwidth\n"); exit(1); } if(options.maxduration < options.minduration) { fprintf(stderr, "error: --max-duration < --min-duration\n"); exit(1); } if(options.maxf < options.minf) { fprintf(stderr, "error: --max-frequency < --min-frequency\n"); exit(1); } if(options.maxhrss < options.minhrss) { fprintf(stderr, "error: --max-hrss < --min-hrss\n"); exit(1); } if(options.gps_start_time == -1 || options.gps_end_time == -1) { fprintf(stderr, "--gps-start-time and --gps-end-time are both required\n"); exit(1); } if(options.gps_end_time < options.gps_start_time) { fprintf(stderr, "error: --gps-end-time < --gps-start-time\n"); exit(1); } if(!options.time_slide_file) { fprintf(stderr, "--time-slide-file is required\n"); exit(1); } switch(options.population) { case POPULATION_TARGETED: case POPULATION_ALL_SKY_SINEGAUSSIAN: case POPULATION_ALL_SKY_BTLWNB: case POPULATION_STRING_CUSP: break; default: fprintf(stderr, "error: --population is required\n"); exit(1); } if(!options.output) { int max_length = 100; /* ARGH: ugly */ options.output = calloc(max_length + 1, sizeof(*options.output)); if(options.user_tag) snprintf(options.output, max_length, "HL-INJECTIONS_%s-%d-%d.xml", options.user_tag, (int) (options.gps_start_time / LAL_INT8_C(1000000000)), (int) ((options.gps_end_time - options.gps_start_time) / LAL_INT8_C(1000000000))); else snprintf(options.output, max_length, "HL-INJECTIONS-%d-%d.xml", (int) (options.gps_start_time / LAL_INT8_C(1000000000)), (int) ((options.gps_end_time - options.gps_start_time) / LAL_INT8_C(1000000000))); } return options; }
/** * @brief Advance a LALFrStream stream to the beginning of the next frame * @details * The position of a LALFrStream is advanced so that the next read will * be at the next frame. If the stream is at the end, the #LAL_FR_STREAM_END * bit of the LALFrStreamState state is set, and the routine returns the * return code 1. If there is a gap in the data before the next frame, * the #LAL_FR_STREAM_GAP bit of the LALFrStreamState state is set, and the * routine returns the return code 2. If, however, the * #LAL_FR_STREAM_IGNOREGAP_MODE bit is not set in the LALFrStreamMode mode * then the routine produces an error if a gap is encountered. * @param stream Pointer to a #LALFrStream structure. * @retval 2 Gap in the data is encountered. * @retval 1 End of stream encountered. * @retval 0 Normal success. * @retval <0 Failure. */ int XLALFrStreamNext(LALFrStream * stream) { /* timing accuracy: tenth of a sample interval for a 16kHz fast channel */ const INT8 tacc = (INT8) floor(0.1 * 1e9 / 16384.0); const char *url1; const char *url2; int pos1; int pos2; INT8 texp = 0; INT8 tact; if (stream->state & LAL_FR_STREAM_END) return 1; /* end code */ /* turn off gap bit */ stream->state &= ~LAL_FR_STREAM_GAP; url2 = url1 = stream->cache->list[stream->fnum].url; pos2 = pos1 = stream->pos; /* open a new file if necessary */ if (!stream->file) { if (stream->fnum >= stream->cache->length) { stream->state |= LAL_FR_STREAM_END; return 1; } if (XLALFrStreamFileOpen(stream, stream->fnum) < 0) XLAL_ERROR(XLAL_EFUNC); } if (stream->file) { INT4 nFrame = XLALFrFileQueryNFrame(stream->file); if (stream->pos < nFrame) { LIGOTimeGPS gpstime; XLALGPSToINT8NS(XLALFrFileQueryGTime(&gpstime, stream->file, stream->pos)); texp = XLALGPSToINT8NS(XLALGPSAdd(&gpstime, XLALFrFileQueryDt(stream->file, stream->pos))); ++stream->pos; } if (stream->pos >= nFrame) { XLALFrStreamFileClose(stream); ++stream->fnum; } pos2 = stream->pos; } /* open a new file if necessary */ if (!stream->file) { if (stream->fnum >= stream->cache->length) { stream->state |= LAL_FR_STREAM_END; return 1; } if (XLALFrStreamFileOpen(stream, stream->fnum) < 0) XLAL_ERROR(XLAL_EFUNC); url2 = stream->cache->list[stream->fnum].url; pos2 = stream->pos; } /* compute actual start time of this new frame */ tact = XLALGPSToINT8NS(XLALFrFileQueryGTime(&stream->epoch, stream->file, stream->pos)); /* INT8 is platform dependent, cast to long long for llabs() call */ if (llabs((long long)(texp - tact)) > tacc) { /* there is a gap */ stream->state |= LAL_FR_STREAM_GAP; if (stream->mode & LAL_FR_STREAM_GAPINFO_MODE) { XLAL_PRINT_INFO("Gap in frame data between times %.6f and %.6f", 1e-9 * texp, 1e-9 * tact); } if (!(stream->mode & LAL_FR_STREAM_IGNOREGAP_MODE)) { XLAL_PRINT_ERROR("Gap in frame data"); XLAL_PRINT_ERROR("Time %.6f is end of frame %d of file %s", 1e-9 * texp, pos1, url1); XLAL_PRINT_ERROR("Time %.6f is start of frame %d of file %s", 1e-9 * tact, pos2, url2); XLAL_ERROR(XLAL_ETIME); } return 2; /* gap code */ } return 0; }
/* a few useful static functions */ static INT8 geocent_start_time(const SimRingdownTable *x) { return(XLALGPSToINT8NS(&x->geocent_start_time)); }
void LALCreateTwoIFOCoincListEllipsoid( LALStatus *status, CoincInspiralTable **coincOutput, SnglInspiralTable *snglInput, InspiralAccuracyList *accuracyParams ) { INT8 currentTriggerNS[2]; CoincInspiralTable *coincHead = NULL; CoincInspiralTable *thisCoinc = NULL; INT4 numEvents = 0; INT8 maxTimeDiff = 0; TriggerErrorList *errorListHead = NULL; TriggerErrorList UNUSED *thisErrorList = NULL; TriggerErrorList *currentError[2]; fContactWorkSpace *workSpace; REAL8 timeError = 0.0; INITSTATUS(status); ATTATCHSTATUSPTR( status ); ASSERT( snglInput, status, LIGOMETADATAUTILSH_ENULL, LIGOMETADATAUTILSH_MSGENULL ); ASSERT( coincOutput, status, LIGOMETADATAUTILSH_ENULL, LIGOMETADATAUTILSH_MSGENULL ); ASSERT( ! *coincOutput, status, LIGOMETADATAUTILSH_ENNUL, LIGOMETADATAUTILSH_MSGENNUL ); memset( currentTriggerNS, 0, 2 * sizeof(INT8) ); /* Loop through triggers and assign each of them an error ellipsoid */ errorListHead = XLALCreateTriggerErrorList( snglInput, accuracyParams->eMatch, &timeError ); if ( !errorListHead ) { ABORTXLAL( status ); } /* Initialise the workspace for ellipsoid overlaps */ workSpace = XLALInitFContactWorkSpace( 3, NULL, NULL, gsl_min_fminimizer_brent, 1.0e-2 ); if (!workSpace) { XLALDestroyTriggerErrorList( errorListHead ); ABORTXLAL( status ); } /* calculate the maximum time delay * set it equal to 2 * worst IFO timing accuracy plus * light travel time for earths diameter * (detectors cant be further apart than this) */ maxTimeDiff = (INT8) (1e9 * 2.0 * timeError); maxTimeDiff += (INT8) ( 1e9 * 2 * LAL_REARTH_SI / LAL_C_SI ); for ( currentError[0] = errorListHead; currentError[0]->next; currentError[0] = currentError[0]->next) { /* calculate the time of the trigger */ currentTriggerNS[0] = XLALGPSToINT8NS( &(currentError[0]->trigger->end_time) ); /* set next trigger for comparison */ currentError[1] = currentError[0]->next; currentTriggerNS[1] = XLALGPSToINT8NS( &(currentError[1]->trigger->end_time) ); while ( (currentTriggerNS[1] - currentTriggerNS[0]) < maxTimeDiff ) { INT2 match; /* test whether we have coincidence */ match = XLALCompareInspiralsEllipsoid( currentError[0], currentError[1], workSpace, accuracyParams ); if ( match == XLAL_FAILURE ) { /* Error in the comparison function */ XLALDestroyTriggerErrorList( errorListHead ); XLALFreeFContactWorkSpace( workSpace ); ABORTXLAL( status ); } /* Check whether the event was coincident */ if ( match ) { #if 0 REAL8 etp = XLALCalculateEThincaParameter( currentError[0]->trigger, currentError[1]->trigger, accuracyParams ); #endif /* create a 2 IFO coinc and store */ if ( ! coincHead ) { coincHead = thisCoinc = (CoincInspiralTable *) LALCalloc( 1, sizeof(CoincInspiralTable) ); } else { thisCoinc = thisCoinc->next = (CoincInspiralTable *) LALCalloc( 1, sizeof(CoincInspiralTable) ); } if ( !thisCoinc ) { /* Error allocating memory */ thisCoinc = coincHead; while ( thisCoinc ) { coincHead = thisCoinc->next; LALFree( thisCoinc ); thisCoinc = coincHead; } XLALDestroyTriggerErrorList( errorListHead ); XLALFreeFContactWorkSpace( workSpace ); ABORT( status, LAL_NOMEM_ERR, LAL_NOMEM_MSG ); } /* Add the two triggers to the coinc */ LALAddSnglInspiralToCoinc( status->statusPtr, &thisCoinc, currentError[0]->trigger ); LALAddSnglInspiralToCoinc( status->statusPtr, &thisCoinc, currentError[1]->trigger ); ++numEvents; } /* scroll on to the next sngl inspiral */ if ( (currentError[1] = currentError[1]->next) ) { currentTriggerNS[1] = XLALGPSToINT8NS( &(currentError[1]->trigger->end_time) ); } else { LALInfo(status, "Second trigger has reached end of list"); break; } } } *coincOutput = coincHead; /* Free all the memory allocated for the ellipsoid overlap */ thisErrorList = errorListHead; XLALDestroyTriggerErrorList( errorListHead ); XLALFreeFContactWorkSpace( workSpace ); DETATCHSTATUSPTR (status); RETURN (status); }
int STREAMGETSERIES(STYPE * series, LALFrStream * stream) { const REAL8 fuzz = 0.1 / 16384.0; /* smallest discernable time */ const size_t size = sizeof(TYPE); size_t noff; size_t need; size_t ncpy; TYPE *dest; STYPE *buffer; LIGOTimeGPS tend; INT8 tnow; INT8 tbeg; int gap = 0; XLAL_CHECK(!(stream->state & LAL_FR_STREAM_END), XLAL_EIO); XLAL_CHECK(!(stream->state & LAL_FR_STREAM_ERR), XLAL_EIO); /* if series does not have allocation for data, * we are to return metadata only, so we don't * need to load data in the next call */ if (series->data && series->data->length) buffer = READSERIES(stream->file, series->name, stream->pos); else buffer = READSERIESMETA(stream->file, series->name, stream->pos); if (!buffer) XLAL_ERROR(XLAL_EFUNC); tnow = XLALGPSToINT8NS(&stream->epoch); tbeg = XLALGPSToINT8NS(&buffer->epoch); /* Make sure that we aren't requesting data * that comes before the current frame. * Allow 1 millisecond padding to account * for double precision */ if (tnow + 1000 < tbeg) { DESTROYSERIES(buffer); XLAL_ERROR(XLAL_ETIME); } /* compute number of points offset very carefully: * if current time is within fuzz of a sample, get * that sample; otherwise get the sample just after * the requested time */ noff = ceil((1e-9 * (tnow - tbeg) - fuzz) / buffer->deltaT); /* adjust current time to be exactly the first sample * (rounded to nearest nanosecond) */ tnow = tbeg + floor(1e9 * noff * buffer->deltaT + 0.5); XLALINT8NSToGPS(&series->epoch, tnow); series->deltaT = buffer->deltaT; series->sampleUnits = buffer->sampleUnits; /* end here if all you want is metadata */ if (!series->data || !series->data->length) { DESTROYSERIES(buffer); return 0; } /* the rest of this function is to get the required * amount of data and copy it into the series */ dest = series->data->data; /* pointer to where to put the data */ need = series->data->length; /* number of points that are needed */ if (noff > buffer->data->length) { /* invalid time offset */ DESTROYSERIES(buffer); XLAL_ERROR(XLAL_ETIME); } /* copy as much of the buffer is needed */ ncpy = (buffer->data->length - noff) < need ? buffer->data->length - noff : need; memcpy(dest, buffer->data->data + noff, ncpy * size); dest += ncpy; need -= ncpy; DESTROYSERIES(buffer); /* continue while data is required */ while (need) { /* goto next frame */ if (XLALFrStreamNext(stream) < 0) XLAL_ERROR(XLAL_EFUNC); if (stream->state & LAL_FR_STREAM_END) XLAL_ERROR(XLAL_EIO, "End of frame stream while %zd points remain to be read", need); /* load more data */ buffer = READSERIES(stream->file, series->name, stream->pos); if (!buffer) XLAL_ERROR(XLAL_EFUNC); if (stream->state & LAL_FR_STREAM_GAP) { /* gap in data: reset dest and need and set epoch */ dest = series->data->data; need = series->data->length; series->epoch = buffer->epoch; gap = 1; } /* copy data */ ncpy = buffer->data->length < need ? buffer->data->length : need; memcpy(dest, buffer->data->data, ncpy * size); dest += ncpy; need -= ncpy; DESTROYSERIES(buffer); } /* update stream start time so that it corresponds to the * exact time of the next sample to be read */ stream->epoch = series->epoch; XLALGPSAdd(&stream->epoch, series->data->length * series->deltaT); /* are we still within the current frame? */ XLALFrFileQueryGTime(&tend, stream->file, stream->pos); XLALGPSAdd(&tend, XLALFrFileQueryDt(stream->file, stream->pos)); if (XLALGPSCmp(&tend, &stream->epoch) <= 0) { /* advance a frame... note that failure here is * benign so we suppress gap warnings: these will * be triggered on the next read (if one is done) */ int savemode = stream->mode; LIGOTimeGPS saveepoch = stream->epoch; stream->mode |= LAL_FR_STREAM_IGNOREGAP_MODE; /* ignore gaps for now */ if (XLALFrStreamNext(stream) < 0) { stream->mode = savemode; XLAL_ERROR(XLAL_EFUNC); } if (!(stream->state & LAL_FR_STREAM_GAP)) /* no gap: reset epoch */ stream->epoch = saveepoch; stream->mode = savemode; } /* make sure to set the gap flag in the stream state * if a gap had been encountered during the reading */ if (gap) stream->state |= LAL_FR_STREAM_GAP; /* FIXME: * does this need to cause a failure if mode is set to fail on gaps? */ /* if the stream state is an error then fail */ if (stream->state & LAL_FR_STREAM_ERR) XLAL_ERROR(XLAL_EIO); return 0; }
int main( int argc, char *argv[] ) { /* lal initialization variables */ LALStatus status = blank_status; /* program option variables */ CHAR *userTag = NULL; CHAR comment[LIGOMETA_COMMENT_MAX]; char *ifos = NULL; char *ifoName = NULL; char *outputFileName = NULL; char *summFileName = NULL; char *injectFileName = NULL; char *vetoFileName = NULL; char *missedFileName = NULL; REAL4 snrStar = -1; REAL4 rsqVetoThresh = -1; REAL4 rsqMaxSnr = -1; REAL4 rsqAboveSnrCoeff = -1; REAL4 rsqAboveSnrPow = -1; LALSegList vetoSegs; MultiInspiralClusterChoice clusterchoice = no_statistic; INT8 cluster_dt = -1; INT8 injectWindowNS = -1; int j; FILE *fp = NULL; int numInFiles = 0; UINT8 triggerInputTimeNS = 0; MetadataTable proctable; MetadataTable procparams; ProcessParamsTable *this_proc_param; SimInspiralTable *simEventHead = NULL; SimInspiralTable *thisSimEvent = NULL; SimInspiralTable *missedSimHead = NULL; SimInspiralTable *tmpSimEvent = NULL; SearchSummvarsTable *inputFiles = NULL; SearchSummaryTable *searchSummList = NULL; SearchSummaryTable *thisSearchSumm = NULL; SummValueTable *summValueList = NULL; int extractSlide = 0; int numSlides = 0; int numEvents = 0; int numEventsKept = 0; int numEventsInIFO = 0; int numEventsAboveSNRThresh = 0; int numEventsBelowRsqThresh = 0; int numEventsSurvivingVeto = 0; int numClusteredEvents = 0; int numEventsInIfos = 0; int numSimEvents = 0; int numSimInData = 0; int numSimFound = 0; int numMultiFound = 0; MultiInspiralTable *missedHead = NULL; MultiInspiralTable *thisEvent = NULL; MultiInspiralTable *thisInspiralTrigger = NULL; MultiInspiralTable *inspiralEventList = NULL; MultiInspiralTable *slideEvent = NULL; LIGOLwXMLStream xmlStream; MetadataTable outputTable; MetadataTable UNUSED savedEvents; MetadataTable searchSummvarsTable; /* * * initialization * */ /* set up inital debugging values */ lal_errhandler = LAL_ERR_EXIT; /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); XLALGPSTimeNow(&(proctable.processTable->start_time)); XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, lalAppsVCSIdentId, lalAppsVCSIdentStatus, lalAppsVCSIdentDate, 0); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); memset( comment, 0, LIGOMETA_COMMENT_MAX * sizeof(CHAR) ); savedEvents.multiInspiralTable = NULL; /* * * parse command line arguments * */ while (1) { /* LALgetopt arguments */ static struct LALoption long_options[] = { {"verbose", no_argument, &vrbflg, 1 }, {"sort-triggers", no_argument, &sortTriggers, 1 }, {"help", no_argument, 0, 'h'}, {"user-tag", required_argument, 0, 'Z'}, {"userTag", required_argument, 0, 'Z'}, {"comment", required_argument, 0, 'c'}, {"version", no_argument, 0, 'V'}, {"data-type", required_argument, 0, 'k'}, {"output", required_argument, 0, 'o'}, {"summary-file", required_argument, 0, 'S'}, {"extract-slide", required_argument, 0, 'e'}, {"num-slides", required_argument, 0, 'N'}, {"snr-threshold", required_argument, 0, 's'}, {"rsq-threshold", required_argument, 0, 'r'}, {"rsq-max-snr", required_argument, 0, 'R'}, {"rsq-coeff", required_argument, 0, 'p'}, {"rsq-power", required_argument, 0, 'P'}, {"cluster-algorithm", required_argument, 0, 'C'}, {"cluster-time", required_argument, 0, 't'}, {"ifo-cut", required_argument, 0, 'd'}, {"coinc-cut", required_argument, 0, 'D'}, {"veto-file", required_argument, 0, 'v'}, {"injection-file", required_argument, 0, 'I'}, {"injection-window", required_argument, 0, 'T'}, {"missed-injections", required_argument, 0, 'm'}, {0, 0, 0, 0} }; int c; /* LALgetopt_long stores the option index here. */ int option_index = 0; size_t LALoptarg_len; c = LALgetopt_long_only ( argc, argv, "c:d:D:hj:k:m:o:r:s:t:v:C:DH:I:R:ST:VZ:", long_options, &option_index ); /* detect the end of the options */ if ( c == - 1 ) break; switch ( c ) { case 0: /* if this option set a flag, do nothing else now */ if ( long_options[option_index].flag != 0 ) { break; } else { fprintf( stderr, "error parsing option %s with argument %s\n", long_options[option_index].name, LALoptarg ); exit( 1 ); } break; case 'h': print_usage(argv[0]); exit( 0 ); break; case 'Z': /* create storage for the usertag */ LALoptarg_len = strlen( LALoptarg ) + 1; userTag = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR) ); memcpy( userTag, LALoptarg, LALoptarg_len ); this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "-userTag" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, "%s", LALoptarg ); break; case 'c': if ( strlen( LALoptarg ) > LIGOMETA_COMMENT_MAX - 1 ) { fprintf( stderr, "invalid argument to --%s:\n" "comment must be less than %d characters\n", long_options[option_index].name, LIGOMETA_COMMENT_MAX ); exit( 1 ); } else { snprintf( comment, LIGOMETA_COMMENT_MAX, "%s", LALoptarg); } break; case 'V': fprintf( stdout, "Coherent Inspiral Reader and Injection Analysis\n" "Sukanta Bose\n"); XLALOutputVersionString(stderr, 0); exit( 0 ); break; case 'o': /* create storage for the output file name */ LALoptarg_len = strlen( LALoptarg ) + 1; outputFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( outputFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'e': /* store the number of slides */ extractSlide = atoi( LALoptarg ); if ( extractSlide == 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "extractSlide must be non-zero: " "(%d specified)\n", long_options[option_index].name, extractSlide ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%d", extractSlide ); break; case 'N': /* store the number of slides */ numSlides = atoi( LALoptarg ); if ( numSlides < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "numSlides >= 0: " "(%d specified)\n", long_options[option_index].name, numSlides ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%d", numSlides ); break; case 'S': /* create storage for the summ file name */ LALoptarg_len = strlen( LALoptarg ) + 1; summFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( summFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'k': /* type of data to analyze */ if ( ! strcmp( "playground_only", LALoptarg ) ) { dataType = playground_only; } else if ( ! strcmp( "exclude_play", LALoptarg ) ) { dataType = exclude_play; } else if ( ! strcmp( "all_data", LALoptarg ) ) { dataType = all_data; } else { fprintf( stderr, "invalid argument to --%s:\n" "unknown data type, %s, specified: " "(must be playground_only, exclude_play or all_data)\n", long_options[option_index].name, LALoptarg ); exit( 1 ); } ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 's': snrStar = (REAL4) atof( LALoptarg ); if ( snrStar < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "threshold must be >= 0: " "(%f specified)\n", long_options[option_index].name, snrStar ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", snrStar ); break; case 'r': rsqVetoThresh = (REAL4) atof( LALoptarg ); if ( rsqVetoThresh < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "threshold must be >= 0: " "(%f specified)\n", long_options[option_index].name, rsqVetoThresh ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", rsqVetoThresh ); break; case 'R': rsqMaxSnr = (REAL4) atof( LALoptarg ); if ( rsqMaxSnr < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "threshold must be >= 0: " "(%f specified)\n", long_options[option_index].name, rsqMaxSnr ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", rsqMaxSnr ); break; case 'p': rsqAboveSnrCoeff = (REAL4) atof( LALoptarg ); if ( rsqAboveSnrCoeff < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "coefficient must be >= 0: " "(%f specified)\n", long_options[option_index].name, rsqAboveSnrCoeff ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", rsqAboveSnrCoeff ); break; case 'P': rsqAboveSnrPow = (REAL4) atof( LALoptarg ); if ( rsqAboveSnrPow < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "power must be >= 0: " "(%f specified)\n", long_options[option_index].name, rsqAboveSnrPow ); exit( 1 ); } ADD_PROCESS_PARAM( "float", "%e", rsqAboveSnrPow ); break; case 'C': /* choose the clustering algorithm */ { if ( ! strcmp( "nullstat", LALoptarg) ) { clusterchoice = nullstat; } else if ( ! strcmp( "cohsnr", LALoptarg) ) { clusterchoice = cohsnr; } else if ( ! strcmp( "effCohSnr", LALoptarg) ) { clusterchoice = effCohSnr; } else if ( ! strcmp( "snrByNullstat", LALoptarg) ) { clusterchoice = snrByNullstat; } else if ( ! strcmp( "autoCorrCohSqByNullstat", LALoptarg) ) { clusterchoice = autoCorrCohSqByNullstat; } else if ( ! strcmp( "crossCorrCohSqByNullstat", LALoptarg) ) { clusterchoice = autoCorrCohSqByNullstat; } else if ( ! strcmp( "autoCorrNullSqByNullstat", LALoptarg) ) { clusterchoice = autoCorrCohSqByNullstat; } else if ( ! strcmp( "crossCorrNullSqByNullstat", LALoptarg) ) { clusterchoice = crossCorrCohSqByNullstat; } else { fprintf( stderr, "invalid argument to --%s:\n" "unknown clustering specified:\n " "%s (must be one of: cohsnr, effCohSnr, nullstat, snrByNullstat, autoCorrCohSqByNullstat, \n" "crossCorrCohSqByNullstat, autoCorrNullSqByNullstat, or crossCorrNullSqByNullstat)\n", long_options[option_index].name, LALoptarg); exit( 1 ); } ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); } break; case 't': /* cluster time is specified on command line in ms */ cluster_dt = (INT8) atoi( LALoptarg ); if ( cluster_dt <= 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "cluster window must be > 0: " "(%" LAL_INT8_FORMAT " specified)\n", long_options[option_index].name, cluster_dt ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%" LAL_INT8_FORMAT, cluster_dt ); /* convert cluster time from ms to ns */ cluster_dt *= 1000000LL; break; case 'v': /* create storage for the injection file name */ LALoptarg_len = strlen( LALoptarg ) + 1; vetoFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( vetoFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'I': /* create storage for the injection file name */ LALoptarg_len = strlen( LALoptarg ) + 1; injectFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( injectFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'd': LALoptarg_len = strlen( LALoptarg ) + 1; ifoName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( ifoName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'D': /* keep only coincs found in ifos */ LALoptarg_len = strlen( LALoptarg ) + 1; ifos = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( ifos, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case 'T': /* injection coincidence time is specified on command line in ms */ injectWindowNS = (INT8) atoi( LALoptarg ); if ( injectWindowNS < 0 ) { fprintf( stdout, "invalid argument to --%s:\n" "injection coincidence window must be >= 0: " "(%" LAL_INT8_FORMAT " specified)\n", long_options[option_index].name, injectWindowNS ); exit( 1 ); } ADD_PROCESS_PARAM( "int", "%" LAL_INT8_FORMAT, injectWindowNS ); /* convert inject time from ms to ns */ injectWindowNS *= 1000000LL; break; case 'm': /* create storage for the missed injection file name */ LALoptarg_len = strlen( LALoptarg ) + 1; missedFileName = (CHAR *) calloc( LALoptarg_len, sizeof(CHAR)); memcpy( missedFileName, LALoptarg, LALoptarg_len ); ADD_PROCESS_PARAM( "string", "%s", LALoptarg ); break; case '?': exit( 1 ); break; default: fprintf( stderr, "unknown error while parsing options\n" ); exit( 1 ); } } /* * * can use LALCalloc() / LALMalloc() from here * */ /* don't buffer stdout if we are in verbose mode */ if ( vrbflg ) setvbuf( stdout, NULL, _IONBF, 0 ); /* fill the comment, if a user has specified it, or leave it blank */ if ( ! *comment ) { snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); } else { snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, "%s", comment ); } /* check that the output file name has been specified */ if ( ! outputFileName ) { fprintf( stderr, "--output must be specified\n" ); exit( 1 ); } /* check that Data Type has been specified */ if ( dataType == unspecified_data_type ) { fprintf( stderr, "Error: --data-type must be specified\n"); exit(1); } /* check that if clustering is being done that we have all the options */ if ( clusterchoice && cluster_dt < 0 ) { fprintf( stderr, "--cluster-time must be specified if --cluster-algorithm " "is given\n" ); exit( 1 ); } else if ( ! clusterchoice && cluster_dt >= 0 ) { fprintf( stderr, "--cluster-algorithm must be specified if --cluster-time " "is given\n" ); exit( 1 ); } /* check that if the rsq veto is being preformed, we have the required options */ if ( ( (rsqVetoThresh > 0) || (rsqMaxSnr > 0) ) && ( (rsqVetoThresh < 0) || (rsqMaxSnr < 0) ) ) { fprintf( stderr, "--rsq-threshold and --rsq-max-snr and must be " "specified together" ); exit( 1 ); } else if ( (rsqAboveSnrCoeff > 0) && ( (rsqMaxSnr < 0) || (rsqVetoThresh < 0) || (rsqAboveSnrPow < 0) ) ) { fprintf( stderr, "--rsq-max-snr --rsq-threshold and --rsq-power " "must be specified if --rsq-coeff is given\n" ); exit( 1 ); } else if ( (rsqAboveSnrPow > 0) && ( (rsqMaxSnr < 0) || (rsqVetoThresh < 0) || (rsqAboveSnrCoeff < 0) ) ) { fprintf( stderr, "--rsq-max-snr --rsq-threshold and --rsq-coeff " "must be specified if --rsq-power is given\n" ); exit( 1 ); } /* check that we have all the options to do injections */ if ( injectFileName && injectWindowNS < 0 ) { fprintf( stderr, "--injection-coincidence must be specified if " "--injection-file is given\n" ); exit( 1 ); } else if ( ! injectFileName && injectWindowNS >= 0 ) { fprintf( stderr, "--injection-file must be specified if " "--injection-coincidence is given\n" ); exit( 1 ); } if ( numSlides && extractSlide ) { fprintf( stderr, "--num-slides and --extract-slide both specified\n" "this doesn't make sense\n" ); exit( 1 ); } /* save the sort triggers flag */ if ( sortTriggers ) { this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "--sort-triggers" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } /* read in the veto file (if specified */ if ( vetoFileName ) { XLALSegListInit( &vetoSegs ); LAL_CALL( LALSegListRead( &status, &vetoSegs, vetoFileName, NULL ), &status ); XLALSegListCoalesce( &vetoSegs ); } /* * * read in the input triggers from the xml files * */ /* if we have run out of arguments on the command line, throw an error */ if ( ! (LALoptind < argc) ) { fprintf( stderr, "Error: No input trigger files specified.\n" ); exit( 1 ); } /* read in the triggers */ for( j = LALoptind; j < argc; ++j ) { INT4 numFileTriggers = 0; MultiInspiralTable *inspiralFileList = NULL; MultiInspiralTable *thisFileTrigger = NULL; numInFiles++; numFileTriggers = XLALReadMultiInspiralTriggerFile( &inspiralFileList, &thisFileTrigger, &searchSummList, &inputFiles, argv[j] ); numEvents += numFileTriggers; if (numFileTriggers < 0) { fprintf(stderr, "Error reading triggers from file %s\n", argv[j]); exit( 1 ); } else { if ( vrbflg ) { fprintf(stdout, "Read %d reading triggers from file %s\n", numFileTriggers, argv[j]); } } /* read the summ value table as well. */ XLALReadSummValueFile(&summValueList, argv[j]); /* * * keep only relevant triggers * */ if( ifos ) { numFileTriggers = XLALMultiInspiralIfosCut( &inspiralFileList, ifos ); if ( vrbflg ) fprintf( stdout, "Kept %d coincs from %s instruments\n", numFileTriggers, ifos ); numEventsInIfos += numFileTriggers; } /* Do playground_only or exclude_play cut */ if ( dataType != all_data ) { inspiralFileList = XLALPlayTestMultiInspiral( inspiralFileList, &dataType ); /* count the triggers */ numFileTriggers = XLALCountMultiInspiralTable( inspiralFileList ); if ( dataType == playground_only && vrbflg ) fprintf( stdout, "Have %d playground triggers\n", numFileTriggers ); else if ( dataType == exclude_play && vrbflg ) fprintf( stdout, "Have %d non-playground triggers\n", numFileTriggers ); } numEventsKept += numFileTriggers; /* Do snr cut */ if ( snrStar > 0 ) { inspiralFileList = XLALSNRCutMultiInspiral( inspiralFileList, snrStar ); /* count the triggers */ numFileTriggers = XLALCountMultiInspiral( inspiralFileList ); if ( vrbflg ) fprintf( stdout, "Have %d triggers after snr cut\n", numFileTriggers ); numEventsAboveSNRThresh += numFileTriggers; } /* NOTE: Add vetoing: if ( vetoFileName ) { inspiralFileList = XLALVetoMultiInspiral( inspiralFileList, &vetoSegs , ifoName); count the triggers numFileTriggers = XLALCountMultiInspiral( inspiralFileList ); if ( vrbflg ) fprintf( stdout, "Have %d triggers after applying veto\n", numFileTriggers ); numEventsSurvivingVeto += numFileTriggers; } */ /* If there are any remaining triggers ... */ if ( inspiralFileList ) { /* add inspirals to list */ if ( thisInspiralTrigger ) { thisInspiralTrigger->next = inspiralFileList; } else { inspiralEventList = thisInspiralTrigger = inspiralFileList; } for( ; thisInspiralTrigger->next; thisInspiralTrigger = thisInspiralTrigger->next); } } for ( thisSearchSumm = searchSummList; thisSearchSumm; thisSearchSumm = thisSearchSumm->next ) { UINT8 outPlayNS, outStartNS, outEndNS, triggerTimeNS; LIGOTimeGPS inPlay, outPlay; outStartNS = XLALGPSToINT8NS( &(thisSearchSumm->out_start_time) ); outEndNS = XLALGPSToINT8NS( &(thisSearchSumm->out_end_time) ); triggerTimeNS = outEndNS - outStartNS; /* check for events and playground */ if ( dataType != all_data ) { XLALPlaygroundInSearchSummary( thisSearchSumm, &inPlay, &outPlay ); outPlayNS = XLALGPSToINT8NS( &outPlay ); if ( dataType == playground_only ) { /* increment the total trigger time by the amount of playground */ triggerInputTimeNS += outPlayNS; } else if ( dataType == exclude_play ) { /* increment the total trigger time by the out time minus */ /* the time that is in the playground */ triggerInputTimeNS += triggerTimeNS - outPlayNS; } } else { /* increment the total trigger time by the out time minus */ triggerInputTimeNS += triggerTimeNS; } } /* * * sort the inspiral events by time * */ if ( injectFileName || sortTriggers ) { inspiralEventList = XLALSortMultiInspiral( inspiralEventList, *LALCompareMultiInspiralByTime ); } /* * * read in the injection XML file, if we are doing an injection analysis * */ if ( injectFileName ) { if ( vrbflg ) fprintf( stdout, "reading injections from %s... ", injectFileName ); numSimEvents = SimInspiralTableFromLIGOLw( &simEventHead, injectFileName, 0, 0 ); if ( vrbflg ) fprintf( stdout, "got %d injections\n", numSimEvents ); if ( numSimEvents < 0 ) { fprintf( stderr, "error: unable to read sim_inspiral table from %s\n", injectFileName ); exit( 1 ); } /* keep play/non-play/all injections */ if ( dataType == playground_only && vrbflg ) fprintf( stdout, "Keeping only playground injections\n" ); else if ( dataType == exclude_play && vrbflg ) fprintf( stdout, "Keeping only non-playground injections\n" ); else if ( dataType == all_data && vrbflg ) fprintf( stdout, "Keeping all injections\n" ); XLALPlayTestSimInspiral( &simEventHead, &dataType ); /* keep only injections in times analyzed */ numSimInData = XLALSimInspiralInSearchedData( &simEventHead, &searchSummList ); if ( vrbflg ) fprintf( stdout, "%d injections in analyzed data\n", numSimInData ); /* check for events that are coincident with injections */ numSimFound = XLALMultiSimInspiralTest( &simEventHead, &inspiralEventList, &missedSimHead, &missedHead, injectWindowNS ); if ( vrbflg ) fprintf( stdout, "%d injections found in the ifos\n", numSimFound ); if ( numSimFound ) { for ( thisEvent = inspiralEventList; thisEvent; thisEvent = thisEvent->next, numMultiFound++ ); if ( vrbflg ) fprintf( stdout, "%d triggers found at times of injection\n", numMultiFound ); } /* free the missed singles */ while ( missedHead ) { thisEvent = missedHead; missedHead = missedHead->next; XLALFreeMultiInspiral( &thisEvent ); } } /* * * extract specified slide * */ if ( extractSlide ) { slideEvent = XLALMultiInspiralSlideCut( &inspiralEventList, extractSlide ); /* free events from other slides */ while ( inspiralEventList ) { thisEvent = inspiralEventList; inspiralEventList = inspiralEventList->next; XLALFreeMultiInspiral( &thisEvent ); } /* move events to inspiralEventList */ inspiralEventList = slideEvent; slideEvent = NULL; } /* * * cluster the remaining events * */ if ( inspiralEventList && clusterchoice ) { if ( vrbflg ) fprintf( stdout, "clustering remaining triggers... " ); if ( !numSlides ) { numClusteredEvents = XLALClusterMultiInspiralTable( &inspiralEventList, cluster_dt, clusterchoice ); } else { int slide = 0; int numClusteredSlide = 0; MultiInspiralTable *tmp_slideEvent = NULL; MultiInspiralTable *slideClust = NULL; if ( vrbflg ) fprintf( stdout, "splitting events by slide\n" ); for( slide = -numSlides; slide < (numSlides + 1); slide++) { if ( vrbflg ) fprintf( stdout, "slide number %d; ", slide ); /* extract the slide */ tmp_slideEvent = XLALMultiInspiralSlideCut( &inspiralEventList, slide ); /* run clustering */ numClusteredSlide = XLALClusterMultiInspiralTable( &tmp_slideEvent, cluster_dt, clusterchoice); if ( vrbflg ) fprintf( stdout, "%d clustered events \n", numClusteredSlide ); numClusteredEvents += numClusteredSlide; /* add clustered triggers */ if( tmp_slideEvent ) { if( slideClust ) { thisEvent = thisEvent->next = tmp_slideEvent; } else { slideClust = thisEvent = tmp_slideEvent; } /* scroll to end of list */ for( ; thisEvent->next; thisEvent = thisEvent->next); } } /* free inspiralEventList -- although we expect it to be empty */ while ( inspiralEventList ) { thisEvent = inspiralEventList; inspiralEventList = inspiralEventList->next; XLALFreeMultiInspiral( &thisEvent ); } /* move events to coincHead */ inspiralEventList = slideClust; slideClust = NULL; } if ( vrbflg ) fprintf( stdout, "done\n" ); if ( vrbflg ) fprintf( stdout, "%d clustered events \n", numClusteredEvents ); } /* * * update search_summary->nevents with an authoritative count of triggers * */ searchSummList->nevents = 0; thisEvent = inspiralEventList; while (thisEvent) { searchSummList->nevents += 1; thisEvent = thisEvent->next; } /* * * write output data * */ /* write the main output file containing found injections */ if ( vrbflg ) fprintf( stdout, "writing output xml files... " ); memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlStream, outputFileName ), &status ); /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, process_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); free( proctable.processTable ); /* erase the first empty process params entry */ { ProcessParamsTable *emptyPPtable = procparams.processParamsTable; procparams.processParamsTable = procparams.processParamsTable->next; free( emptyPPtable ); } /* write the process params table */ if ( vrbflg ) fprintf( stdout, "process_params... " ); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_params_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, procparams, process_params_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); /* write search_summary table */ if ( vrbflg ) fprintf( stdout, "search_summary... " ); outputTable.searchSummaryTable = searchSummList; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, search_summary_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, search_summary_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); /* write the search_summvars table */ if ( vrbflg ) fprintf( stdout, "search_summvars... " ); LAL_CALL( LALBeginLIGOLwXMLTable( &status ,&xmlStream, search_summvars_table), &status ); searchSummvarsTable.searchSummvarsTable = inputFiles; LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, searchSummvarsTable, search_summvars_table), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream), &status ); /* write summ_value table */ if ( summValueList ) { if ( vrbflg ) fprintf( stdout, "search_summary... " ); outputTable.summValueTable = summValueList; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, summ_value_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, summ_value_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); } /* Write the found injections to the sim table */ if ( simEventHead ) { if ( vrbflg ) fprintf( stdout, "sim_inspiral... " ); outputTable.simInspiralTable = simEventHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sim_inspiral_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sim_inspiral_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream ), &status ); } /* Write the results to the inspiral table */ if ( inspiralEventList ) { if ( vrbflg ) fprintf( stdout, "multi_inspiral... " ); outputTable.multiInspiralTable = inspiralEventList; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, multi_inspiral_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, multi_inspiral_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream ), &status); } /* close the output file */ LAL_CALL( LALCloseLIGOLwXMLFile(&status, &xmlStream), &status); if ( vrbflg ) fprintf( stdout, "done\n" ); if ( missedFileName ) { /* open the missed injections file and write the missed injections to it */ if ( vrbflg ) fprintf( stdout, "writing missed injections... " ); memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlStream, missedFileName ), &status ); if ( missedSimHead ) { outputTable.simInspiralTable = missedSimHead; LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, sim_inspiral_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, sim_inspiral_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable( &status, &xmlStream ), &status ); } LAL_CALL( LALCloseLIGOLwXMLFile( &status, &xmlStream ), &status ); if ( vrbflg ) fprintf( stdout, "done\n" ); } if ( summFileName ) { LIGOTimeGPS triggerTime; /* write out a summary file */ fp = fopen( summFileName, "w" ); switch ( dataType ) { case playground_only: fprintf( fp, "using data from playground times only\n" ); break; case exclude_play: fprintf( fp, "excluding all triggers in playground times\n" ); break; case all_data: fprintf( fp, "using all input data\n" ); break; default: fprintf( stderr, "data set not defined\n" ); exit( 1 ); } fprintf( fp, "read triggers from %d files\n", numInFiles ); fprintf( fp, "number of triggers in input files: %d \n", numEvents ); fprintf( fp, "number of triggers in input data %d \n", numEventsKept ); if ( ifoName ) { fprintf( fp, "number of triggers from %s ifo %d \n", ifoName, numEventsInIFO ); } if ( snrStar > 0 ) { fprintf( fp, "number of triggers in input data with snr above %f: %d \n", snrStar, numEventsAboveSNRThresh ); } if ( rsqVetoThresh > 0 ) { fprintf( fp, "performed R-squared veto on triggers with snr < %f\n", rsqMaxSnr); fprintf( fp, "with rsqveto_duration below %f\n", rsqVetoThresh); if ( (rsqAboveSnrCoeff > 0) && (rsqAboveSnrPow > 0) ) { fprintf( fp, "and on triggers with snr > %f\n", rsqMaxSnr); fprintf( fp, "with rsqveto_duration above %f * snr ^ %f\n", rsqAboveSnrCoeff, rsqAboveSnrPow ); } fprintf( fp, "the number of triggers below the R-squared veto are: %d \n", numEventsBelowRsqThresh); } if ( vetoFileName ) { fprintf( fp, "number of triggers not vetoed by %s: %d \n", vetoFileName, numEventsSurvivingVeto ); } XLALINT8NSToGPS( &triggerTime, triggerInputTimeNS ); fprintf( fp, "amount of time analysed for triggers %d sec %d ns\n", triggerTime.gpsSeconds, triggerTime.gpsNanoSeconds ); if ( injectFileName ) { fprintf( fp, "read %d injections from file %s\n", numSimEvents, injectFileName ); fprintf( fp, "number of injections in input data: %d\n", numSimInData ); fprintf( fp, "number of injections found in input data: %d\n", numSimFound ); fprintf( fp, "number of triggers found within %lld msec of injection: %d\n", (injectWindowNS / 1000000LL), numMultiFound ); fprintf( fp, "efficiency: %f \n", (REAL4) numSimFound / (REAL4) numSimInData ); } if ( extractSlide ) { fprintf( fp, "kept only triggers from slide %d\n", extractSlide ); } if ( clusterchoice ) { if ( numSlides ) { fprintf( fp, "clustering triggers from %d slides separately\n", numSlides ); } fprintf( fp, "number of event clusters with %lld msec window: %d\n", cluster_dt/ 1000000LL, numClusteredEvents ); } fclose( fp ); } /* * * free memory and exit * */ /* free the inspiral events we saved */ while ( inspiralEventList ) { thisEvent = inspiralEventList; inspiralEventList = inspiralEventList->next; LAL_CALL ( LALFreeMultiInspiral ( &status, &thisEvent ), &status); } /* free the process params */ while( procparams.processParamsTable ) { this_proc_param = procparams.processParamsTable; procparams.processParamsTable = this_proc_param->next; free( this_proc_param ); } /* free the found injections */ while ( simEventHead ) { thisSimEvent = simEventHead; simEventHead = simEventHead->next; LALFree( thisSimEvent ); } /* free the temporary memory containing the missed injections */ while ( missedSimHead ) { tmpSimEvent = missedSimHead; missedSimHead = missedSimHead->next; LALFree( tmpSimEvent ); } /* free search summaries read in */ while ( searchSummList ) { thisSearchSumm = searchSummList; searchSummList = searchSummList->next; LALFree( thisSearchSumm ); } while ( summValueList ) { SummValueTable *thisSummValue; thisSummValue = summValueList; summValueList = summValueList->next; LALFree( thisSummValue ); } if ( vetoFileName ) { XLALSegListClear( &vetoSegs ); } if ( vrbflg ) fprintf( stdout, "checking memory leaks and exiting\n" ); LALCheckMemoryLeaks(); exit( 0 ); }