00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "BankEfficiency.h"
00022
00023 NRCSID( BANKEFFICIENCYC, "$Id: BankEfficiency.c,v 1.142 2008/07/07 17:36:46 devanka Exp $");
00024 RCSID( "$Id: BankEfficiency.c,v 1.142 2008/07/07 17:36:46 devanka Exp $");
00025
00026 #define CVS_ID_STRING_C "$Id: BankEfficiency.c,v 1.142 2008/07/07 17:36:46 devanka Exp $"
00027 #define CVS_REVISION_C "$Revision: 1.142 $"
00028 #define CVS_NAME_STRING_C "$Name: $"
00029 #define CVS_SOURCE_C "$Source: /usr/local/cvs/lscsoft/lalapps/src/findchirp/BankEfficiency.c,v $"
00030 #define CVS_DATE_C "$Date: 2008/07/07 17:36:46 $"
00031 #define PROGRAM_NAME "BankEfficiency"
00032
00033
00034 RandomParams *randParams = NULL;
00035 INT4 randnStartPad = 0;
00036 INT4 ascii2xml = 0;
00037
00038
00039 int
00040 main (INT4 argc, CHAR **argv )
00041 {
00042
00043 INT4 i;
00044 INT4 j;
00045 INT4 thisTemplateIndex;
00046 Order tempOrder;
00047
00048
00049 UserParametersIn userParam;
00050
00051
00052 REAL4Vector signal;
00053 RandomInspiralSignalIn randIn;
00054
00055
00056 Mybank mybank;
00057 InspiralTemplate insptmplt;
00058 InspiralCoarseBankIn coarseBankIn;
00059 INT4 sizeBank = 0;
00060 MetadataTable templateBank;
00061 SnglInspiralTable *tmpltHead = NULL;
00062
00063
00064 REAL4Vector correlation;
00065 BankEfficiencyBCV bankefficiencyBCV;
00066 InspiralWaveOverlapIn overlapin;
00067
00068
00069 OverlapOutputIn overlapOutputThisTemplate;
00070 OverlapOutputIn overlapOutputBestTemplate;
00071
00072
00073 RealFFTPlan *fwdp = NULL;
00074 RealFFTPlan *revp = NULL;
00075
00076
00077 LALStatus status = blank_status;
00078 FILE *Foutput;
00079
00080
00081 UINT4 fast_index;
00082
00083
00084 REAL4 tempEccentricity = 0;
00085
00086
00087 gsl_histogram *histogramNoise = gsl_histogram_alloc (200);
00088 gsl_matrix *amb1;
00089
00090
00091 BankEfficiencySimulation simulation;
00092
00093
00094 gsl_histogram_set_ranges_uniform (histogramNoise, 0.,20.);
00095 lal_errhandler = LAL_ERR_EXIT;
00096 lalDebugLevel = 0;
00097 templateBank.snglInspiralTable = NULL;
00098
00099
00100 BankEfficiencyParametersInitialization(&coarseBankIn, &randIn, &userParam);
00101
00102
00103 BankEfficiencyParseParameters(&argc, argv,&coarseBankIn, &randIn, &userParam);
00104
00105
00106 BankEfficiencyUpdateParams(&coarseBankIn, &randIn, &userParam);
00107
00108
00109 BankEfficiencyEccentricBankInit(&userParam);
00110
00111
00112 randParams = XLALCreateRandomParams(randIn.useed );
00113
00114
00115
00116
00117
00118
00119
00120 if (ascii2xml == 1){
00121 BankEfficiencyAscii2Xml();
00122 }
00123
00124
00125
00126
00127
00128
00129 if (userParam.printPrototype){
00130 BankEfficiencyPrintProtoXml(coarseBankIn, randIn, userParam);
00131 }
00132
00133
00134
00135 LAL_CALL(BankEfficiencyGetMaximumSize(&status,
00136 randIn, coarseBankIn, userParam, &(signal.length)),
00137 &status);
00138
00139
00140 randIn.psd.length = signal.length/2 + 1;
00141 correlation.length = signal.length;
00142
00143 signal.data = (REAL4*)LALCalloc(1, sizeof(REAL4) * signal.length);
00144 correlation.data = (REAL4*)LALCalloc(1, sizeof(REAL4) * correlation.length);
00145 randIn.psd.data = (REAL8*)LALCalloc(1, sizeof(REAL8) * randIn.psd.length);
00146
00147 if (userParam.template == BCV)
00148 {
00149 INT4 n;
00150 n = signal.length;
00151 bankefficiencyBCV.FilterBCV1.length = n;
00152 bankefficiencyBCV.FilterBCV2.length = n;
00153 bankefficiencyBCV.FilterBCV1.data = (REAL4*)LALCalloc(1, sizeof(REAL4) * n);
00154 bankefficiencyBCV.FilterBCV2.data = (REAL4*)LALCalloc(1, sizeof(REAL4) * n);
00155 }
00156
00157
00158 LAL_CALL(BankEfficiencyCreatePsd(&status, &coarseBankIn, &randIn, userParam),
00159 &status);
00160
00161
00162 LAL_CALL(BankEfficiencyCreateTemplateBank(&status, &coarseBankIn,
00163 &templateBank, &tmpltHead, userParam, &randIn, &sizeBank), &status);
00164
00165
00166 BankEfficiencyInitMyBank(&mybank, &sizeBank, tmpltHead, userParam);
00167
00168
00169
00170 amb1 = gsl_matrix_alloc(4,sizeBank);
00171 for (i=0;i<4; i++)
00172 {
00173 for (j=0;j<sizeBank; j++)
00174 {
00175 gsl_matrix_set(amb1, i, j, 0.);
00176 }
00177 }
00178
00179
00180 LALCreateForwardRealFFTPlan(&status, &fwdp, signal.length, 0);
00181 LALCreateReverseRealFFTPlan(&status, &revp, signal.length, 0);
00182
00183
00184 overlapin.nBegin = 0;
00185 overlapin.nEnd = 0;
00186 overlapin.psd = randIn.psd;
00187 overlapin.fwdp = randIn.fwdp = fwdp;
00188 overlapin.revp = revp;
00189 overlapin.ifExtOutput = 0;
00190 overlapin.ifCorrelationOutput = 1;
00191
00192
00193 if ((userParam.template == BCV) )
00194 {
00195 LAL_CALL( BankEfficiencyCreatePowerVector(&status,
00196 &(bankefficiencyBCV.powerVector), randIn, signal.length), &status);
00197
00198 BankEfficiencyCreateBCVMomentVector(
00199 &(bankefficiencyBCV.moments), &coarseBankIn.shf,randIn.param.tSampling,
00200 randIn.param.fLower, signal.length);
00201 }
00202
00203
00204
00205
00206
00207 simulation.ntrials = 0;
00208 simulation.N = userParam.ntrials;
00209
00210 while (++simulation.ntrials <= userParam.ntrials)
00211 {
00212 if (vrbflg){
00213 fprintf(stdout,"Simulation number %d/%d\n", simulation.ntrials, userParam.ntrials);
00214 }
00215
00216
00217 BankEfficiencyInitOverlapOutputIn(&overlapOutputBestTemplate);
00218
00219
00220 randIn.param.fCutoff = userParam.signalfFinal;
00221
00222
00223 LAL_CALL(BankEfficiencyGenerateInputData(&status,
00224 &signal, &randIn, userParam), &status);
00225
00226
00227 overlapin.signal = signal;
00228
00229
00230 insptmplt = randIn.param;
00231 insptmplt.approximant = userParam.template;
00232 insptmplt.order = coarseBankIn.order;
00233 insptmplt.ampOrder = coarseBankIn.ampOrder;
00234
00235
00236 for (i=0; i<sizeBank; i++){
00237 mybank.used[i] = 0;
00238 }
00239
00240
00241 simulation.filter_processed = 0;
00242 simulation.lastEMatch = 1;
00243 simulation.filteringIndex = 0;
00244 simulation.stop = 0;
00245 simulation.bestSNR = 0;
00246 simulation.bestSNRIndex = 0;
00247 simulation.SNRMax = 0;
00248 simulation.fastParam1 = userParam.fastParam1;
00249 simulation.fastParam1 *= 1.+log10(userParam.eccentricBank.bins);
00250 simulation.eMatch = userParam.eMatch;
00251 simulation.bestEMatch = -1e16;
00252 simulation.randIn = randIn;
00253
00254
00255 while ( simulation.filteringIndex<sizeBank && simulation.stop == 0 )
00256 {
00257
00258 simulation.filteringIndex++;
00259
00260
00261 BankEfficiencyInitOverlapOutputIn(&overlapOutputThisTemplate);
00262
00263 GetClosestValidTemplate(mybank, simulation.randIn, &fast_index);
00264
00265 LAL_CALL(BankEfficiencyCreateListFromTmplt(&status,
00266 &insptmplt, mybank, fast_index), &status);
00267 thisTemplateIndex = fast_index;
00268
00269 switch(userParam.template)
00270 {
00271 case BCV:
00272
00273 insptmplt.massChoice = psi0Andpsi3;
00274 LAL_CALL(LALInspiralParameterCalc(&status, &(insptmplt)),&status);
00275 overlapin.param = insptmplt;
00276
00277 LAL_CALL(LALInspiralParameterCalc( &status, &(overlapin.param) ),
00278 &status);
00279
00280
00281
00282
00283 if (userParam.faithfulness)
00284 {
00285 insptmplt = randIn.param;
00286 overlapin.param = randIn.param;
00287 overlapin.param.approximant = userParam.template;
00288 insptmplt.fFinal = randIn.param.fFinal;
00289
00290 simulation.stop = 1;
00291 }
00292
00293 LAL_CALL(BankEfficiencyInspiralOverlapBCV(&status,
00294 &insptmplt, userParam, &randIn,
00295 &overlapin, &overlapOutputThisTemplate,
00296 &correlation, &bankefficiencyBCV),
00297 &status);
00298
00299
00300
00301 overlapOutputThisTemplate.freq = overlapin.param.fFinal;
00302 overlapOutputThisTemplate.templateNumber = thisTemplateIndex;
00303 simulation.filter_processed++;
00304 break;
00305
00306 case AmpCorPPN:
00307 case TaylorT1:
00308 case Eccentricity:
00309 case TaylorT2:
00310 case TaylorT3:
00311 case TaylorF1:
00312 case TaylorF2:
00313 case EOB:
00314 case EOBNR:
00315 case PadeT1:
00316 case PadeF1:
00317 case SpinTaylor:
00318 if (vrbflg){
00319 fprintf(stderr,"closeest template is tau0= %f tau3= %f index=%d filterintIndex= %d,",
00320 mybank.tau0[fast_index], mybank.tau3[fast_index],fast_index,simulation.filteringIndex);
00321 }
00322
00323
00324
00325 insptmplt.massChoice = t03;
00326 LAL_CALL(LALInspiralParameterCalc( &status, &(insptmplt) ),
00327 &status);
00328
00329 overlapin.param = insptmplt;
00330 LAL_CALL(LALInspiralParameterCalc( &status, &(overlapin.param) ),
00331 &status);
00332 overlapin.param.fCutoff = coarseBankIn.fUpper;
00333 overlapin.param.fLower = coarseBankIn.fLower;
00334 overlapin.param.fFinal = randIn.param.tSampling/2. - 1;
00335
00336
00337 simulation.lastEMatch = BankEfficiencyComputeEMatch(&randIn, mybank,
00338 thisTemplateIndex);
00339 if (simulation.lastEMatch > simulation.bestEMatch)
00340 simulation.bestEMatch = simulation.lastEMatch;
00341
00342
00343 if (userParam.faithfulness)
00344 {
00345 simulation.lastEMatch = 1;
00346 tempOrder = insptmplt.order;
00347 tempEccentricity = insptmplt.eccentricity;
00348
00349 insptmplt = randIn.param;
00350 overlapin.param = randIn.param;
00351
00352 LAL_CALL(LALInspiralParameterCalc( &status, &(overlapin.param) ), &status);
00353 overlapin.param.fCutoff = coarseBankIn.fUpper;
00354 overlapin.param.fFinal = randIn.param.tSampling/2. - 1;
00355 overlapin.param.approximant = userParam.template;
00356 overlapin.param.fLower = coarseBankIn.fLower;
00357
00358
00359 overlapin.param.order = tempOrder;
00360 overlapin.param.eccentricity = tempEccentricity;
00361 insptmplt.eccentricity = tempEccentricity;
00362
00363 simulation.stop = 1;
00364 }
00365
00366
00367
00368
00369 if (userParam.fastSimulation == Heuristic1)
00370 {
00371
00372 if (simulation.lastEMatch < simulation.eMatch){
00373 simulation.eMatch = simulation.lastEMatch-1;
00374 }
00375
00376 if (simulation.SNRMax >= simulation.fastParam1
00377 && userParam.fastSimulation){
00378 simulation.stop = 1;
00379 }
00380 }
00381
00382
00383
00384 if ((simulation.filteringIndex !=1) &&
00385 (userParam.fastSimulation != None)
00386 && (simulation.lastEMatch < simulation.eMatch ))
00387 {
00388 gsl_matrix_set(amb1,2,thisTemplateIndex, 0);
00389 gsl_matrix_set(amb1,3,thisTemplateIndex, 0);
00390 gsl_matrix_set(amb1,0,thisTemplateIndex, insptmplt.t0);
00391 gsl_matrix_set(amb1,1,thisTemplateIndex, insptmplt.t3);
00392
00393 simulation.stop = 1;
00394 }
00395 else
00396 {
00397 LAL_CALL(BankEfficiencyWaveOverlap(&status,
00398 &correlation,
00399 &overlapin,
00400 &overlapOutputThisTemplate,
00401 randIn.param.nStartPad), &status);
00402
00403
00404 overlapOutputThisTemplate.templateNumber = thisTemplateIndex;
00405
00406
00407 BankEfficiencyPopulateAmbiguityFunction(
00408 amb1,correlation,thisTemplateIndex,
00409 overlapOutputThisTemplate, randIn.param.nStartPad,
00410 insptmplt);
00411
00412
00413 insptmplt.fFinal = overlapin.param.fFinal;
00414 simulation.filter_processed++;
00415
00416 if (vrbflg){
00417 fprintf(stderr, "snr = %f ematch=%f (threshold is %f) snrMax for %d\n",
00418 overlapOutputThisTemplate.rhoMax, simulation.lastEMatch,
00419 simulation.eMatch,simulation.SNRMax);
00420
00421 fflush(stderr);
00422 }
00423
00424 if (overlapOutputThisTemplate.rhoMax > simulation.bestSNR)
00425 {
00426 simulation.bestSNR = overlapOutputThisTemplate.rhoMax;
00427 simulation.bestSNRIndex = simulation.filteringIndex;
00428 simulation.SNRMax = 0;
00429 if (userParam.fastSimulation == Heuristic1)
00430 {
00431 simulation.randIn.param.t0 = insptmplt.t0;
00432 simulation.randIn.param.t3 = insptmplt.t3;
00433 }
00434 simulation.bestEMatch = simulation.lastEMatch;
00435 }
00436 else
00437 {
00438 simulation.SNRMax++;
00439 }
00440
00441 }
00442 break;
00443 }
00444
00445
00446
00447
00448
00449 if (userParam.printSNRHisto){
00450 BankEfficiencyUpdateSNRHistogram(&correlation, histogramNoise);
00451 }
00452
00453
00454
00455 BankEfficiencyKeepHighestValues( overlapOutputThisTemplate,
00456 &overlapOutputBestTemplate, insptmplt);
00457
00458 }
00459
00460
00461 LAL_CALL(BankEfficiencyFinalise(&status,mybank,
00462 overlapOutputBestTemplate,randIn,userParam,simulation,
00463 coarseBankIn), &status);
00464
00465 if (userParam.template == BCV)
00466 {
00467 if (userParam.printBestOverlap || userParam.printBestTemplate)
00468 {
00469 userParam.extraFinalPrinting = 1;
00470 LAL_CALL(BankEfficiencyInspiralOverlapBCV(&status,
00471 &insptmplt, userParam, &randIn,
00472 &overlapin, &overlapOutputThisTemplate, &correlation,
00473 &bankefficiencyBCV),
00474 &status);
00475 }
00476 }
00477
00478
00479 if (userParam.printBestOverlap ){
00480 BankEfficiencySaveVector("BankEfficiency-correlation.dat", correlation,
00481 randIn.param.tSampling);
00482 }
00483
00484 }
00485
00486
00487
00488 if (userParam.printSNRHisto)
00489 {
00490 Foutput = fopen(BANKEFFICIENCY_SNRHISTOGRAM,"w");
00491 gsl_histogram_fprintf(Foutput, histogramNoise, "%f", "%g");
00492 fclose(Foutput);
00493 }
00494
00495
00496
00497 BankEfficiencyPrintAmbiguity(userParam,sizeBank,amb1);
00498
00499
00500 while ( templateBank.snglInspiralTable )
00501 {
00502 tmpltHead = templateBank.snglInspiralTable;
00503 templateBank.snglInspiralTable = templateBank.snglInspiralTable->next;
00504 LALFree( tmpltHead );
00505 }
00506
00507
00508
00509
00510
00511 if (userParam.template == BCV)
00512 {
00513 LALFree(bankefficiencyBCV.powerVector.fm5_3.data);
00514 LALFree(bankefficiencyBCV.powerVector.fm2_3.data);
00515 LALFree(bankefficiencyBCV.powerVector.fm1_2.data);
00516 LALFree(bankefficiencyBCV.powerVector.fm7_6.data);
00517 LALFree(bankefficiencyBCV.moments.a11.data);
00518 LALFree(bankefficiencyBCV.moments.a21.data);
00519 LALFree(bankefficiencyBCV.moments.a22.data);
00520
00521 if (userParam.template == BCV)
00522 {
00523 LALFree(bankefficiencyBCV.FilterBCV2.data);
00524 LALFree(bankefficiencyBCV.FilterBCV1.data);
00525 }
00526 }
00527
00528 LALFree(randIn.psd.data);
00529 LALDDestroyVector( &status, &(coarseBankIn.shf.data) );
00530
00531 LALFree(signal.data);
00532 LALFree(correlation.data);
00533
00534 LALDestroyRealFFTPlan(&status,&fwdp);
00535 LALDestroyRealFFTPlan(&status,&revp);
00536
00537 gsl_matrix_free(amb1);
00538 gsl_histogram_free(histogramNoise);
00539
00540 free(mybank.mass1);
00541 free(mybank.mass2);
00542
00543
00544 LALCheckMemoryLeaks();
00545
00546 return 0;
00547 }
00548
00549
00550
00551
00552
00553
00554
00555 void BankEfficiencyKeepHighestValues(
00556 OverlapOutputIn resultThisTemplate,
00557 OverlapOutputIn *resultBestTemplate,
00558 InspiralTemplate insptmplt)
00559 {
00560
00561 if (resultThisTemplate.rhoMax > resultBestTemplate->rhoMax)
00562 {
00563 resultBestTemplate->rhoMax = resultThisTemplate.rhoMax;
00564 resultBestTemplate->phase = resultThisTemplate.phase;
00565 resultBestTemplate->alpha = resultThisTemplate.alpha;
00566 resultBestTemplate->rhoBin = resultThisTemplate.rhoBin;
00567 resultBestTemplate->freq = resultThisTemplate.freq;
00568 resultBestTemplate->templateNumber = resultThisTemplate.templateNumber;
00569 resultBestTemplate->snrAtCoaTime = resultThisTemplate.snrAtCoaTime;
00570 resultBestTemplate->eccentricity = insptmplt.eccentricity;
00571 }
00572 }
00573
00574
00575
00576
00577
00578 void BankEfficiencyGetResult(
00579 LALStatus *status,
00580 InspiralTemplate *list,
00581 InspiralTemplate injected,
00582 OverlapOutputIn bestOverlap,
00583 ResultIn *result,
00584 UserParametersIn userParam
00585 )
00586 {
00587 INT4 templateNumber;
00588 InspiralTemplate trigger;
00589
00590 INITSTATUS (status, "GetResult", BANKEFFICIENCYC);
00591 ATTATCHSTATUSPTR(status);
00592
00593 templateNumber = bestOverlap.templateNumber;
00594
00595 trigger = *list;
00596
00597 if (userParam.template == BCV ){
00598
00599
00600
00601
00602 result->psi0_inject = injected.psi0;
00603 result->psi3_inject = injected.psi3;
00604 result->psi0_trigger = trigger.psi0;
00605 result->psi3_trigger = trigger.psi3;
00606 result->tau0_trigger = 0.;
00607 result->tau3_trigger = 0.;
00608 result->tau0_inject = 0.;
00609 result->tau3_inject = 0.;
00610 }
00611 else
00612 {
00613 LALInspiralParameterCalc( status->statusPtr, &trigger );
00614 CHECKSTATUSPTR(status);
00615 result->psi0_inject = 0.;
00616 result->psi3_inject = 0.;
00617 result->psi0_trigger = 0.;
00618 result->psi3_trigger = 0.;
00619 result->tau0_trigger = trigger.t0;
00620 result->tau3_trigger = trigger.t3;
00621 result->tau0_inject = injected.t0;
00622 result->tau3_inject = injected.t3;
00623 result->polarisationAngle = injected.polarisationAngle;
00624 result->inclination = injected.inclination;
00625 }
00626
00627 result->mass1_inject = injected.mass1;
00628 result->mass2_inject = injected.mass2;
00629 result->fend_inject = injected.fFinal;
00630 result->fend_trigger = bestOverlap.freq;
00631 result->rho_final = bestOverlap.rhoMax;
00632 result->alphaF = bestOverlap.alpha*pow(bestOverlap.freq,2./3.);
00633 result->bin = bestOverlap.rhoBin;
00634 result->phase = bestOverlap.phase;
00635 result->layer = bestOverlap.layer;
00636 result->phase = bestOverlap.phase;
00637 result->snrAtCoaTime = bestOverlap.snrAtCoaTime;
00638 result->eccentricity = bestOverlap.eccentricity;
00639
00640 DETATCHSTATUSPTR(status);
00641 RETURN (status);
00642 }
00643
00644
00645 void BankEfficiencyPrintResults(
00646 ResultIn result,
00647 RandomInspiralSignalIn randIn,
00648 BankEfficiencySimulation simulation)
00649 {
00650 fprintf(stdout,
00651 "%e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %d %d %d %d %f %d/%d\n",
00652 result.psi0_trigger, result.psi3_trigger,
00653 randIn.param.psi0, randIn.param.psi3,
00654 result.tau0_trigger, result.tau3_trigger,
00655 randIn.param.t0, randIn.param.t3,
00656 result.eccentricity, randIn.param.eccentricity,randIn.param.alpha1,
00657 result.fend_trigger, randIn.param.fFinal,
00658 randIn.param.mass1,randIn.param.mass2,
00659 randIn.param.inclination,randIn.param.polarisationAngle,
00660 randIn.param.startPhase, result.rho_final,
00661 result.snrAtCoaTime, result.phase,
00662 result.alphaF,result.bin, randIn.param.nStartPad, result.nfast,
00663 simulation.bestSNRIndex,simulation.bestEMatch,simulation.ntrials, simulation.N);
00664
00665 fflush(stdout);
00666 }
00667
00668
00669
00670
00671
00672 void BankEfficiencyCreateBCVMomentVector(
00673 BankEfficiencyMoments *moments,
00674 REAL8FrequencySeries *psd,
00675 REAL8 sampling,
00676 REAL8 fLower,
00677 INT4 length)
00678 {
00679 REAL8 m7 = 0.;
00680 REAL8 m5 = 0.;
00681 REAL8 m3 = 0.;
00682 REAL8 f;
00683
00684 UINT4 kMin;
00685 UINT4 kMax;
00686 UINT4 k;
00687
00688 InspiralMomentsIn in;
00689
00690 moments->a11.length = length / 2 ;
00691 moments->a22.length = length / 2 ;
00692 moments->a21.length = length / 2 ;
00693 moments->a11.data = (REAL4*) LALCalloc(1, sizeof(REAL4) * moments->a11.length);
00694 moments->a22.data = (REAL4*) LALCalloc(1, sizeof(REAL4) * moments->a22.length);
00695 moments->a21.data = (REAL4*) LALCalloc(1, sizeof(REAL4) * moments->a21.length);
00696
00697
00698 in.shf = psd;
00699 in.xmin = fLower;
00700
00701 in.xmax = sampling/2.;
00702 in.norm = 1./4.;
00703
00704 in.norm *= sampling * sampling;
00705
00706
00707 kMin = (UINT8) floor( (in.xmin - psd->f0) / psd->deltaF );
00708 kMax = (UINT8) floor( (in.xmax - psd->f0) / psd->deltaF );
00709
00710
00711 for (k = 0; k < kMin ; k++)
00712 {
00713 moments->a11.data[k] = 0.;
00714 moments->a21.data[k] = 0.;
00715 moments->a22.data[k] = 0.;
00716 }
00717 for ( k = kMin; k < kMax; ++k )
00718 {
00719 f = psd->f0 + (REAL8) k * psd->deltaF;
00720 if (psd->data->data[k])
00721 {
00722 m7 += pow( f, -(7./3.) ) / psd->data->data[k] * psd->deltaF / in.norm;
00723 m5 += pow( f, -(5./3) ) / psd->data->data[k] * psd->deltaF / in.norm;
00724 m3 += pow( f, -(1.) ) / psd->data->data[k] * psd->deltaF / in.norm;
00725 moments->a11.data[k] = 1./sqrt(m7);
00726 moments->a22.data[k] = 1. / sqrt(m3 - m5*m5/m7);
00727 moments->a21.data[k] = -m5 / m7 * moments->a22.data[k];
00728 }
00729 }
00730 BankEfficiencySaveVector("moment1.dat",moments->a11,sampling);
00731 }
00732
00733
00734
00735
00736
00737 void BankEfficiencyGetOrthogonalFilter(
00738 REAL4Vector *filter)
00739 {
00740 UINT4 i;
00741 UINT4 n = filter->length;
00742 UINT4 nby2 = filter->length / 2;
00743 REAL4 temp;
00744
00745 for (i = 1; i < nby2; i++)
00746 {
00747 temp = filter->data[i];
00748 filter->data[i] = -filter->data[n-i];
00749 filter->data[n-i] = temp;
00750 }
00751 }
00752
00753
00754
00755
00756 void BankEfficiencyCreateVectorFreqPower(
00757 REAL4Vector *vector,
00758 InspiralTemplate params,
00759 INT4 a,
00760 INT4 b)
00761 {
00762 INT4 i;
00763 INT4 n = vector->length;
00764
00765 REAL8 power = (REAL8)a / (REAL8)b;
00766 REAL8 f;
00767 REAL8 df = params.tSampling/(REAL8)n/2.;
00768
00769
00770 vector->data[0] = 0.;
00771 for( i = 1; i < n; i++)
00772 {
00773 f = i * df;
00774
00775
00776 vector->data[i] = pow(f, power);
00777 }
00778 }
00779
00780
00781
00782
00783
00784 void BankEfficiencyCreateBCVFilters(
00785 BankEfficiencyBCV *bankefficiencyBCV,
00786 UINT4 kMin,
00787 UINT4 kMax,
00788 REAL4 psi0,
00789