00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <string.h>
00023
00024 #include <sys/types.h>
00025 #include <sys/stat.h>
00026 #include <unistd.h>
00027
00028 #include "datacondAPI/DatacondCaller.h"
00029
00030 #include <burstdso.h>
00031
00032 #include <lalapps/lalapps.h>
00033
00034
00035 int main(int argc, char *argv[]) {
00036
00037 char nocondor = 0;
00038
00039 char *fQuery;
00040
00041 char *algorithms;
00042
00043 char *filterParams;
00044
00045 char *rFiles = NULL;
00046
00047 float f0=0.0, f1=1.0;
00048
00049 int Nsymbols = 0;
00050 static datacond_symbol_type *symbols = NULL;
00051
00052 BurstSearchParams bparams;
00053
00054 char *times, *algo, *params, *fraction, *resp, *dataserver;
00055
00056
00057 lal_errhandler = LAL_ERR_EXIT;
00058 set_debug_level( "227" );
00059
00060
00061 if(argc<5) {
00062 fprintf(stderr,"burstdso [-nocondor] dataserver framesQuery algorithms filterParams [responseFiles] [fraction]\n");
00063 fprintf(stderr,"frameQuery, algorithms, filterParams and responseFiles can be files or strings\n");
00064 fprintf(stderr,"Pass an empty string (\"\") for responseFiles to use fraction without responseFiles\n");
00065 fprintf(stderr,"fraction: f0-f1\n");
00066 return 1;
00067 }
00068
00069 if(strstr(argv[1],"nocondor")) {
00070 argc -= 1;
00071 argv++;
00072 nocondor=1;
00073 }
00074
00075 dataserver = argv[1];
00076 fQuery = argv[2];
00077 algo = argv[3];
00078 params = argv[4];
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 {
00090
00091 struct stat buf;
00092
00093 if(stat(fQuery,&buf)) {
00094 times = (char *)calloc(1 + strlen(fQuery), sizeof(char));
00095 strcpy(times, fQuery);
00096 } else {
00097
00098 FILE *in;
00099 char *p;
00100
00101 if((in = fopen(fQuery,"r"))==NULL) {
00102 fprintf(stderr,"Can't open %s\n",fQuery);
00103 return 1;
00104 }
00105
00106 p = times = (char *)calloc(1 + buf.st_size, sizeof(char));
00107
00108 while((p=fgets(p,buf.st_size,in))) {
00109 p += strlen(p);
00110 }
00111
00112 fclose(in);
00113 }
00114 }
00115
00116
00117 {
00118
00119 struct stat buf;
00120
00121 if(stat(algo,&buf)) {
00122 algorithms = (char *)calloc(1 + strlen(algo), sizeof(char));
00123 strcpy(algorithms, algo);
00124 } else {
00125
00126 FILE *in;
00127 char *p;
00128
00129 if((in = fopen(algo,"r"))==NULL) {
00130 fprintf(stderr,"Can't open %s\n",algo);
00131 return 1;
00132 }
00133
00134 p = algorithms = (char *)calloc(1 + buf.st_size, sizeof(char));
00135
00136 while((p=fgets(p,buf.st_size,in))) {
00137 p += strlen(p);
00138 }
00139
00140 fclose(in);
00141 }
00142 }
00143
00144 {
00145
00146 struct stat buf;
00147
00148 if(stat(params,&buf)) {
00149 filterParams = (char *)calloc(1 + strlen(params), sizeof(char));
00150 strcpy(filterParams, params);
00151 } else {
00152
00153 FILE *in;
00154 char *p;
00155
00156 if((in = fopen(params,"r"))==NULL) {
00157 fprintf(stderr,"Can't open %s\n",params);
00158 return 1;
00159 }
00160
00161 p = filterParams = (char *)calloc(1 + buf.st_size, sizeof(char));
00162
00163 while((p=fgets(p,buf.st_size,in))) {
00164 p += strlen(p);
00165 }
00166
00167 fclose(in);
00168 }
00169 }
00170
00171 if(argc>5)
00172 {
00173
00174 struct stat buf;
00175
00176 resp = argv[5];
00177
00178 if(stat(resp,&buf)) {
00179 if(strlen(resp)>0) {
00180 rFiles = (char *)calloc(1 + strlen(resp), sizeof(char));
00181 strcpy(rFiles, resp);
00182 }
00183 } else {
00184
00185 FILE *in;
00186 char *p;
00187
00188 if((in = fopen(resp,"r"))==NULL) {
00189 fprintf(stderr,"Can't open %s\n",resp);
00190 return 1;
00191 }
00192
00193 p = rFiles = (char *)calloc(1 + buf.st_size, sizeof(char));
00194
00195 while((p=fgets(p,buf.st_size,in))) {
00196 p += strlen(p);
00197 }
00198
00199 fclose(in);
00200 }
00201 }
00202
00203 if(argc>6) {
00204 fraction = argv[6];
00205 sscanf(fraction,"%g-%g",&f0,&f1);
00206 }
00207
00208
00209 #ifdef DEBUGBURST
00210 fprintf(stderr,"%s\n%s\n%s\n%s\n%g\n%g\n",fQuery,algorithms,filterParams,rFiles,f0,f1);
00211 #endif
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 if(OutputSymbols(algorithms, &Nsymbols, &symbols)) {
00227 fprintf(stderr,"ERROR: OutputSymbols\n");
00228 return 1;
00229 }
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 if(nocondor) {
00243
00244 if(getFrameData(times, dataserver, &Nsymbols, &symbols)) {
00245 fprintf(stderr,"ERROR: can't get frame data\n");
00246 return 1;
00247 }
00248
00249 } else {
00250
00251 if(getFrameData(times, dataserver, &Nsymbols, &symbols)) {
00252 fprintf(stderr,"ERROR: can't get frame data\n");
00253 return 1;
00254 }
00255
00256 }
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 if(rFiles) {
00268 if(getNonFrameData(rFiles, &algorithms, &Nsymbols, &symbols)) {
00269 fprintf(stderr,"ERROR: can't get non-frame data\n");
00270 return 1;
00271 }
00272 }
00273
00274
00275
00276
00277 if(ConditionData(Nsymbols, symbols, algorithms)) {
00278 fprintf(stderr,"ERROR: dataconditioning failed\n");
00279 return 1;
00280 }
00281
00282
00283
00284
00285
00286 if(InitSearch(filterParams, &bparams)) {
00287 fprintf( stderr, "ERROR: InitSearch\n");
00288 return 1;
00289 }
00290
00291
00292 if(ReConditionData(Nsymbols, symbols, algorithms, &bparams)) {
00293 fprintf(stderr,"ERROR: dataconditioning failed, level 2\n");
00294 return 1;
00295 }
00296
00297
00298
00299
00300 if(RunSearch(&bparams, f0, f1)) {
00301 fprintf( stderr, "ERROR: RunSearch\n");
00302 return 1;
00303 }
00304
00305
00306
00307
00308 free(times);
00309 free(algorithms);
00310 free(filterParams);
00311
00312 if(rFiles) free(rFiles);
00313
00314 symbolsfree(symbols);
00315
00316 bparamsfree(&bparams);
00317
00318 return 0;
00319 }