FStatNomad.h 10.1 KB
Newer Older
Miroslav Shaltev's avatar
Miroslav Shaltev committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 *  Copyright (C) 2012 Miroslav Shaltev.
 *
 *  May include code snippets by:
 *      Holger Pletsch, Karl Wette, Reinhard Prix,
 *      Badri Krishnan, Alicia Sintes, Bernd Machenschalk.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with with program; see the file COPYING. If not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 */

#ifndef _FSTATNOMADH  /* Double-include protection. */
#define _FSTATNOMADH

#include "libFStatNomad.h"

/******************************************************
 *   Protection against C++ name mangling
 */

#ifdef  __cplusplus
extern "C" {
#endif
Miroslav Shaltev's avatar
Miroslav Shaltev committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    typedef struct {
        BOOLEAN help;                // did user request help-output?
        BOOLEAN ComputeStartingPointStatistics;
        LALStringVector *Signal; // Alpha,Delta,Freq,f1dot,f2dot,f3dot,cosi,psi,phi0,h0,asini,argp,ecc,tpssb,period
        LALStringVector *Alpha;
        LALStringVector *Delta;
        LALStringVector *Freq;
        LALStringVector *f1dot;
        LALStringVector *f2dot;
        LALStringVector *f3dot;
        LALStringVector *TpSSB;
        LALStringVector *Argp;
        LALStringVector *asini;
        LALStringVector *ecc;
        LALStringVector *Period;

        BOOLEAN log; 	/* logging done if true */
54

Miroslav Shaltev's avatar
Miroslav Shaltev committed
55
56
57
58
59
60
61
62
        BOOLEAN SignalOnly;     /* if Signal-only case (for SFT normalization) */

        REAL8 minStartTime;
        REAL8 maxEndTime;

        REAL8 refTime;
        INT4 blocksRngMed;

63
64
        REAL8 dopplermax;

Miroslav Shaltev's avatar
Miroslav Shaltev committed
65
66
67
68
69
70
71
        REAL8 tStack;
        INT4  nStacksMax;
        CHAR *segmentList;

        INT4 Dterms;
        INT4 SSBprecision;

Miroslav Shaltev's avatar
Miroslav Shaltev committed
72
73
        CHAR *ephemEarth;
        CHAR *ephemSun;
74
		INT4 FstatMethod;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
75
76
77
78
79
80
81
        CHAR *fnameout;
        CHAR *DataFiles;
        INT4 SortToplist;
        BOOLEAN version;

        INT4 LTMADS;
        INT4 FinalLTMADS;
82

Miroslav Shaltev's avatar
Miroslav Shaltev committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
        BOOLEAN TargetedSearch;
        BOOLEAN ReSearch;
        BOOLEAN FinalReSearch;
        BOOLEAN ResamplingSearch;
        INT4 RandomSearch;
        INT4 RandomSearchRadius;
        BOOLEAN PreSearchFixedSky;
        BOOLEAN ClearCache;

        BOOLEAN FixedSpindownSearch;

        BOOLEAN PredictFStat;

        REAL8 avg2F;

        INT4 Type;
        INT4 DisplayDegree;

        INT4 FinalType;
102
103
		
		INT4 Seed;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
104
105
106
107
108
109
110
111
112

        REAL8 Epsilon;
        REAL8 MinMeshSize;
        REAL8 MinPollSize;
        INT4 MaxIterations;
        INT4 ModelSearch;
        INT4 ModelEvalSort;
        REAL8 VnsSearch;
        INT4 MaxBBEval;
113
		INT4 MeshType;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
114
115
116
        INT4 MeshCoarseningExponent;
        INT4 MeshRefiningExponent;
        REAL8 MeshUpdateBasis;
117
		REAL8 PollUpdateBasis;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
118
        REAL8 FinalMeshUpdateBasis;
119
		REAL8 FinalPollUpdateBasis;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
120
121
122
123
124
125
126
127
128
        BOOLEAN UseMetric;
        LALStringVector* MetricIFO;
        BOOLEAN LoopMeshCoarseningExponent;
        INT4 MinMeshCoarseningExponent;
        INT4 MaxMeshCoarseningExponent;
        INT4 StepMeshCoarseningExponent;
        INT4 FinalMinMeshCoarseningExponent;
        INT4 FinalMaxMeshCoarseningExponent;
        INT4 FinalStepMeshCoarseningExponent;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
129
        REAL8 nB;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151

        INT4 SemicoherentStages;

        BOOLEAN ComputeDTS;

        REAL8 avg2Fth;
        BOOLEAN SaveNomadStat;

        REAL8 NoiseLimit;

        BOOLEAN DumpMetric;
        BOOLEAN DumpSegments;

        INT4 ModelSearchMaxTrialPts;
        INT4 ModelQuadMinYSize;
        INT4 ModelQuadMaxYSize;
        BOOLEAN ModelSearchProjToMesh;
        REAL8 ModelQuadRadiusFactor;
        BOOLEAN ModelQuadUseWP;
        BOOLEAN ModelSearchOptimistic;
        BOOLEAN OpportunisticEval;
        BOOLEAN OpportunisticLuckyEval;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
152

Miroslav Shaltev's avatar
Miroslav Shaltev committed
153
        INT4 ExhaustiveSearch;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
154

155
156
		BOOLEAN DumpCache;
		
Miroslav Shaltev's avatar
Miroslav Shaltev committed
157
158
        BOOLEAN outputLoudest;
        BOOLEAN outputTiming;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
159

Miroslav Shaltev's avatar
Miroslav Shaltev committed
160
        INT4 FStatSearchType;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
161

Miroslav Shaltev's avatar
Miroslav Shaltev committed
162
        REAL8 StandardDeviations;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
163

Miroslav Shaltev's avatar
Miroslav Shaltev committed
164
165
166
167
168
        BOOLEAN BreakASAP;
        REAL8 AcceptDev;
        BOOLEAN RoundStat;
        INT4 RoundStatDigit;
        INT4 FinalRoundStatDigit;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
169

170
171
        BOOLEAN BinarySearch;
        BOOLEAN BNSLEL;
172
		
Miroslav Shaltev's avatar
Miroslav Shaltev committed
173
174
		BOOLEAN HybridSearch;
		REAL8 HybridSearchMismatch;
175
		INT4 HybridSearchLattice;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
176
		INT4 HybridSearchPoints;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
177
		BOOLEAN HybridSearchLatticeAtOnce;
178
179
		BOOLEAN FinalHybridSearch;
		REAL8 FinalHybridSearchMismatch;
180
		INT4 FinalHybridSearchLattice;
181
		INT4 FinalHybridSearchPoints;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
182
		BOOLEAN FinalHybridSearchLatticeAtOnce;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
183
		
184
185
		INT4 metricType;
		
186
	} UserInput_t;
187

Miroslav Shaltev's avatar
Miroslav Shaltev committed
188
189
190
    class FCSearch: public FStatNomad {
    public:

191
        UserInput_t UserVariables;
192
193
        UserInput_t *uvar;

Miroslav Shaltev's avatar
Miroslav Shaltev committed
194
195
        std::vector<BOOLEAN> bFirstPoint;
        std::vector<BOOLEAN> bSkipSearch;
196
197
198
199
		
		BOOLEAN DumpCache(){
			return uvar->DumpCache;
		};
Miroslav Shaltev's avatar
Miroslav Shaltev committed
200
201
202
203
204

        FCSearch(int argc, char *argv[]);
        virtual ~FCSearch();

        virtual INT4 XLALInitUserVars( int argc, char *argv[]);
205

206
        CHAR* DTSFile() {
Miroslav Shaltev's avatar
Miroslav Shaltev committed
207
208
            char* dts_file = (char*)LALCalloc( strlen(uvar->fnameout) + 1 + 55, sizeof(CHAR) );
            sprintf(dts_file,"%s.dts",uvar->fnameout);
Miroslav Shaltev's avatar
Miroslav Shaltev committed
209
210
            return dts_file;
        }
211
212

        CHAR* PFSFile() {
Miroslav Shaltev's avatar
Miroslav Shaltev committed
213
214
            char* pfs_file = (char*)LALCalloc( strlen(uvar->fnameout) + 1 + 55, sizeof(CHAR) );
            sprintf(pfs_file,"%s.pfs",uvar->fnameout);
215
            return pfs_file;
216
217
218
219
220
221
        }

        REAL8 RoundValue(REAL8 v, REAL8 p) {
            REAL8 pw = pow(10,p);
            return floor(v*pw)/pw;
        };
222
		INT4 write_cache(NOMAD::Cache *cache, INT4 cnt, INT4 type);
223
224
225
226
227
228

        INT4 write_dts_file();
        INT4 write_pfs_file(REAL8 snr2, INT4 nseg);

        std::vector<REAL8> DTS;

Miroslav Shaltev's avatar
Miroslav Shaltev committed
229
        tDirection CMDLineDirToDirection(LALStringVector *v) {
230
231
232
233
234
235
236
237
238
            tDirection d;
            d.min = atof(v->data[DIR_MIN]);
            d.max = atof(v->data[DIR_MAX]);
            d.startpoint = atof(v->data[DIR_STARTPOINT]);
            d.startstep = atof(v->data[DIR_STARTSTEP]);
            d.scale = atof(v->data[DIR_SCALE]);
            d.name = DirNameToID(v->data[DIR_NAME]);
            if (d.scale < 0) {
                d.scale = 1 / fabs(d.startpoint);
239
                LogPrintf(LOG_NORMAL,"Found negative scale factor for direction %10s, new scale factor is: %e\n",DirIDToName(d.name),d.scale);
240
// 				d.startstep = d.startstep * d.scale;
241
242
            }
            return d;
243
        };
244
245
246
247
248
249
250
251
252
253
254

        tDirection CMDLineTargetDirToDirection(REAL8 v, const CHAR* n) {
            tDirection d;
            d.min = v;
            d.max = v;
            d.startpoint = v;
            d.startstep = 0;
            d.scale = 0;
            d.name = DirNameToID(n);
            return d;
        }
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295

        const CHAR* DirIDToName(INT4 d) {
            switch (d) {
            case PID_ALPHA:
                return "alpha";
                break;
            case PID_DELTA:
                return "delta";
                break;
            case PID_FREQ:
                return "freq";
                break;
            case PID_F1DOT:
                return "f1dot";
                break;
            case PID_F2DOT:
                return "f2dot";
                break;
            case PID_F3DOT:
                return "f3dot";
                break;
            case PID_ASINI:
                return "asini";
                break;
            case PID_ARGP:
                return "argp";
                break;
            case PID_ECC:
                return "ecc";
                break;
            case PID_TPSSB:
                return "tpssb";
                break;
            case PID_PERIOD:
                return "period";
                break;
            default:
                LogPrintf(LOG_NORMAL,"Unknown ID %d. Abort!!!",d);
                exit(-1);
            }
        };
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311

        INT4 DirNameToID(const CHAR* c) {
            if (strcmp(c,"alpha") == 0) return PID_ALPHA;
            if (strcmp(c,"delta") == 0) return PID_DELTA;
            if (strcmp(c,"freq") == 0) return PID_FREQ;
            if (strcmp(c,"f1dot") == 0) return PID_F1DOT;
            if (strcmp(c,"f2dot") == 0) return PID_F2DOT;
            if (strcmp(c,"f3dot") == 0) return PID_F3DOT;
            if (strcmp(c,"asini") == 0) return PID_ASINI;
            if (strcmp(c,"argp") == 0) return PID_ARGP;
            if (strcmp(c,"ecc") == 0) return PID_ECC;
            if (strcmp(c,"tpssb") == 0) return PID_TPSSB;
            if (strcmp(c,"period") == 0) return PID_PERIOD;
            LogPrintf(LOG_NORMAL,"Unknown directoin name %s, should be one of alpha, delta, freq, f1dot, f2dot, f3dot, asini, argp, ecc, tpssb, period. Abort!!!\n",c);
            exit(-1);
        }
312
313
314

        void PrintDirections() {
            for (INT4 i = 0; i < directions.size(); i++ ) {
315
                printf("id: %2d, name: %10s, startpoint: %.16e, min: %.16e, max: %.16e, startstep: %.16e, scale: %.16e\n",directions.at(i).name,DirIDToName(directions.at(i).name),directions.at(i).startpoint,directions.at(i).min,directions.at(i).max,directions.at(i).startstep,directions.at(i).scale);
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
            }
        }

        BOOLEAN CMDLineDirBand(LALStringVector *v) {
            if (atof(v->data[DIR_MIN]) == atof(v->data[DIR_MAX])) {
                return  FALSE;
            }
            else {
                return TRUE;
            }
        }

        BOOLEAN CMDLineDirIsFixed(LALStringVector *v) {
            return (BOOLEAN)atoi(v->data[DIR_FIXED]);
        };

        REAL8 CMDLineDirFixedValue(LALStringVector *v) {
            return atof(v->data[DIR_STARTPOINT]);
        };

        REAL8 CMDLineDirValue(LALStringVector *v, INT4 d) {
            return atof(v->data[d]);
        };

        CHAR* CMDLineDirName(LALStringVector *v) {
            return v->data[DIR_NAME];
        };

        BOOLEAN SignalIsKnown;
Miroslav Shaltev's avatar
Miroslav Shaltev committed
345
346
347
348
349
350
351
352

    };

#ifdef  __cplusplus
}                /* Close C++ protection */
#endif

#endif  /* Double-include protection. */