LALPulsar 7.1.1.1-eeff03c
HierarchSearchGCT.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009-2010 Holger Pletsch.
3 *
4 * Based on HierarchicalSearch.h by
5 * Copyright (C) 2005-2008 Badri Krishnan, Alicia Sintes, Bernd Machenschalk.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with with program; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 *
22 */
23
24#ifndef _HIERARCHSEARCHGCTH /* Double-include protection. */
25#define _HIERARCHSEARCHGCTH
26
27#include "config.h"
28
29/* standard includes */
30#include <sys/types.h>
31#include <fcntl.h>
32#include <string.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <math.h>
36#include <time.h>
37#include <errno.h>
38
39#include <lal/UserInput.h>
40#include <lal/LALStdlib.h>
41#include <lal/PulsarDataTypes.h>
42#include <lal/SFTfileIO.h>
43#include <lal/AVFactories.h>
44#include <lal/RngMedBias.h>
45#include <lal/LALComputeAM.h>
46#include <lal/ComputeSky.h>
47#include <lal/LALInitBarycenter.h>
48#include <lal/Velocity.h>
49#include <lal/ExtrapolatePulsarSpins.h>
50#include <lal/Date.h>
51#include <lal/LALHough.h>
52#include <lal/NormalizeSFTRngMed.h>
53#include <lal/ComputeFstat.h>
54#include <lal/Statistics.h>
55#include <lal/GeneratePulsarSignal.h>
56#include <lal/LogPrintf.h>
57#include <lal/DopplerScan.h>
58#include <lal/UniversalDopplerMetric.h>
59#include <lal/LALPulsarVCSInfo.h>
60
61/* more efficient toplist using heaps */
62#include "GCTtoplist.h"
63
64
65/******************************************************
66 * Protection against C++ name mangling
67 */
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73
74/******************************************************
75 * Error codes and messages.
76 */
77
78#define HIERARCHICALSEARCH_ENORM 0
79#define HIERARCHICALSEARCH_ESUB 1
80#define HIERARCHICALSEARCH_EARG 2
81#define HIERARCHICALSEARCH_EBAD 3
82#define HIERARCHICALSEARCH_EFILE 4
83#define HIERARCHICALSEARCH_ENULL 5
84#define HIERARCHICALSEARCH_EVAL 6
85#define HIERARCHICALSEARCH_ENONULL 7
86#define HIERARCHICALSEARCH_EDLOPEN 8
87#define HIERARCHICALSEARCH_EWORKER 9
88#define HIERARCHICALSEARCH_ECHECKPT 10
89#define HIERARCHICALSEARCH_EMEM 11
90#define HIERARCHICALSEARCH_ESFT 12
91#define HIERARCHICALSEARCH_ECG 13
92#define HIERARCHICALSEARCH_EXLAL 14
93
94#define HIERARCHICALSEARCH_MSGENORM "Normal exit"
95#define HIERARCHICALSEARCH_MSGESUB "Subroutine failed"
96#define HIERARCHICALSEARCH_MSGEARG "Error parsing arguments"
97#define HIERARCHICALSEARCH_MSGEBAD "Bad argument values"
98#define HIERARCHICALSEARCH_MSGEFILE "Could not create output file"
99#define HIERARCHICALSEARCH_MSGENULL "Null pointer"
100#define HIERARCHICALSEARCH_MSGEVAL "Invalid value"
101#define HIERARCHICALSEARCH_MSGENONULL "Pointer not null"
102#define HIERARCHICALSEARCH_MSGECHECKPT "Could not resume from checkpoint"
103#define HIERARCHICALSEARCH_MSGEMEM "Out of memory"
104#define HIERARCHICALSEARCH_MSGESFT "SFT validity check failed"
105#define HIERARCHICALSEARCH_MSGEXLAL "XLAL function call failed"
106
107
108/* ******************************************************************
109 * Structure, enum, union, etc., typdefs.
110 */
111
112/** type describing one coherent segment of data: ( start-time + duration ) */
113typedef struct {
114 UINT4 startTime; /**< gps start-time of segment, in seconds */
115 UINT4 duration; /**< duration of segment in seconds */
116} Segment_t;
117
118/** a standard vector of data-segments */
119typedef struct {
120 UINT4 length; /**< number of segments */
121 Segment_t *data; /**< array of segments */
123
124/* sequence of SFT catalogs -- for each stack */
125typedef struct tagSFTCatalogSequence {
126 UINT4 length; /**< the number of stacks */
127 SFTCatalog *data; /**< the catalogs */
129
130
131/** parameters for the semicoherent stage */
132typedef struct tagSemiCoherentParams {
133 LIGOTimeGPSVector *tsMid; /**< timestamps of mid points of segments */
134 LIGOTimeGPS refTime; /**< reference time for f, fdot definition */
135 REAL8VectorSequence *pos; /**< Earth orbital position for each segment */
136 REAL8VectorSequence *vel; /**< Earth orbital velocity for each segment */
137 REAL8VectorSequence *acc; /**< Earth orbital acceleration for each segment (new) */
138 CHAR *outBaseName; /**< file for writing output -- if chosen */
139 REAL8 threshold; /**< Threshold for candidate selection */
140 UINT4 extraBinsFstat; /**< Extra bins required for Fstat calculation */
142
143
144/* ------------------------------------------------------------------------- */
145
146
147/** structure for storing fine-grid points */
148#ifdef GC_SSE2_OPT
149#define FINEGRID_NC_T UCHAR
150#else
151#define FINEGRID_NC_T UINT4
152#endif
153typedef struct tagFineGrid {
154 REAL8 freqmin_fg; /**< fine-grid start in frequency */
155 REAL8 dfreq_fg; /**< fine-grid spacing in frequency */
156 REAL8 alpha; /**< right ascension */
157 REAL8 delta; /**< declination */
158 LIGOTimeGPS refTime; /**< reference time for candidates */
159 UINT4 length; /**< length of multi-IFO stats vectors 'sumTwoF', 'nc' (currently 'length'= 'freqlength') */
160 UINT4 freqlength; /**< number of fine-grid points in frequency */
161 UINT4 numDetectors; /**< number of detectors for sumTwoFX array */
162 REAL4 *sumTwoF; /**< sum of 2F-values, 1D array over fine-grid frequencies (of length 'length') */
163 UINT4 freqlengthAL; /**< "aligned" number of fine-grid points in frequency: in blocks of 16 bytes, consistent with ALAlloc() [used for sumTwoFX, maxTwoFXl, maxTwoFXlIdx] */
164 REAL4 *sumTwoFX; /**< sum of per-IFO 2F-values, 2D array over frequencies and detectors (of length 'freqlengthAL*numDetectors') */
165 FINEGRID_NC_T *nc; /**< number count (1D array over frequencies, of length 'length') */
166 REAL4 *maxTwoFl; /**< maximum of multi-IFO 2F over segments, 1D array over fine-grid frequencies (of length 'length') */
167 REAL4 *maxTwoFXl; /**< maximum of per-IFO 2F over segments, 2D array over frequencies and detectors (of length 'freqlengthAL*numDetectors') */
168 UINT4 *maxTwoFlIdx; /**< segment index (zero based) of corresponding entry in maxTwoFl */
169 UINT4 *maxTwoFXlIdx; /**< segment index (zero based) of corresponding entry in maxTwoFXl */
170} FineGrid;
171
172/* macro to index arrays in the FineGrid structure
173 * frequency/GCT U1 index MUST always be the innermost index
174 */
175#define FG_INDEX(fg, iFreq) \
176 ( (iFreq) )
177
178/* macro to index FX array in the FineGrid structure
179 * frequency/GCT U1 index MUST always be the innermost index
180 * NOTE!: this 2D array needs 16-byte aligned blocks of frequency-bins (one block per detector),
181 * therefore we need to use the special length field freqlengthAL (which is a multiple of 4xREAL4 bytes)
182 */
183#define FG_FX_INDEX(fg, iDet, iFreq) \
184 ( ( (iDet) * (fg).freqlengthAL ) + (iFreq) )
185
186/* ------------------------------------------------------------------------- */
187
188/** structure for storing coarse-grid points */
189typedef struct tagCoarseGrid {
190 UINT4 length; /**< length of multi-IFO array 'sumTwoF', 'Uindex' (currently 'length'= 'nStacks * freqlength') */
191 UINT4 nStacks; /**< number of stacks */
192 UINT4 freqlength; /**< number of coarse-grid points in frequency */
193 UINT4 *Uindex; /**< U index, 2D array over stacks and frequencies (of length 'length') */
194 REAL4 *TwoF; /**< 2F-value, 2D array over stacks and frequencies (of length 'length') */
195 UINT4 numDetectors; /**< number of detectors */
196 REAL4 *TwoFX; /**< per-IFO 2F-values, 3D array over {frequencies, stacks, detectors} (of length = 'numDetector * length' */
197} CoarseGrid;
198
199/* macro to index 2D arrays in the CoarseGrid structure
200 * frequency/GCT U1 index MUST always be the innermost index
201 */
202#define CG_INDEX(cg, iStack, iFreq) \
203 ( ( (iStack) * (cg).freqlength ) + (iFreq) )
204
205/* macro to index 3D FX array in the CoarseGrid structure
206 * frequency/GCT U1 index MUST always be the innermost index
207 */
208#define CG_FX_INDEX(cg, iDet, iStack, iFreq) \
209 ( ( (iDet) * (cg).length ) + ( (iStack) * (cg).freqlength ) + (iFreq) )
210
211/* ------------------------------------------------------------------------- */
212
213/* function prototypes */
214
217 REAL8 tStack,
218 SFTCatalog *in,
219 UINT4 nStacks );
220
222 INT4 *loopindex,
223 const CHAR *fnameChkPoint );
224
225#ifdef __cplusplus
226} /* Close C++ protection */
227#endif
228
229#endif /* Double-include protection. */
void GetChkPointIndex(LALStatus *status, INT4 *loopindex, const CHAR *fnameChkPoint)
Read checkpointing file This does not (yet) check any consistency of the existing results file.
#define FINEGRID_NC_T
structure for storing fine-grid points
void SetUpStacks(LALStatus *status, SFTCatalogSequence *out, REAL8 tStack, SFTCatalog *in, UINT4 nStacks)
Breaks up input sft catalog into specified number of stacks Loops over elements of the catalog,...
double REAL8
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
structure for storing coarse-grid points
UINT4 length
length of multi-IFO array 'sumTwoF', 'Uindex' (currently 'length'= 'nStacks * freqlength')
UINT4 * Uindex
U index, 2D array over stacks and frequencies (of length 'length')
UINT4 numDetectors
number of detectors
UINT4 nStacks
number of stacks
UINT4 freqlength
number of coarse-grid points in frequency
REAL4 * TwoFX
per-IFO 2F-values, 3D array over {frequencies, stacks, detectors} (of length = 'numDetector * length'
REAL4 * TwoF
2F-value, 2D array over stacks and frequencies (of length 'length')
REAL4 * sumTwoFX
sum of per-IFO 2F-values, 2D array over frequencies and detectors (of length 'freqlengthAL*numDetecto...
REAL8 alpha
right ascension
FINEGRID_NC_T * nc
number count (1D array over frequencies, of length 'length')
UINT4 * maxTwoFXlIdx
segment index (zero based) of corresponding entry in maxTwoFXl
REAL8 delta
declination
REAL8 dfreq_fg
fine-grid spacing in frequency
UINT4 numDetectors
number of detectors for sumTwoFX array
REAL8 freqmin_fg
fine-grid start in frequency
UINT4 freqlength
number of fine-grid points in frequency
REAL4 * maxTwoFXl
maximum of per-IFO 2F over segments, 2D array over frequencies and detectors (of length 'freqlengthAL...
UINT4 length
length of multi-IFO stats vectors 'sumTwoF', 'nc' (currently 'length'= 'freqlength')
UINT4 freqlengthAL
"aligned" number of fine-grid points in frequency: in blocks of 16 bytes, consistent with ALAlloc() [...
LIGOTimeGPS refTime
reference time for candidates
REAL4 * maxTwoFl
maximum of multi-IFO 2F over segments, 1D array over fine-grid frequencies (of length 'length')
UINT4 * maxTwoFlIdx
segment index (zero based) of corresponding entry in maxTwoFl
REAL4 * sumTwoF
sum of 2F-values, 1D array over fine-grid frequencies (of length 'length')
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
Definition: SFTfileIO.h:238
sequence of SFT catalogs – for each segment
SFTCatalog * data
the catalogs
UINT4 length
the number of stacks
type describing one coherent segment of data: ( start-time + duration )
UINT4 duration
duration of segment in seconds
UINT4 startTime
gps start-time of segment, in seconds
a standard vector of data-segments
UINT4 length
number of segments
Segment_t * data
array of segments
parameters for the semicoherent stage
REAL8VectorSequence * acc
Earth orbital acceleration for each segment (new)
REAL8VectorSequence * pos
Earth orbital position for each segment.
LIGOTimeGPSVector * tsMid
timestamps of mid points of segments
CHAR * outBaseName
file for writing output – if chosen
LIGOTimeGPS refTime
reference time for f, fdot definition
REAL8VectorSequence * vel
Earth orbital velocity for each segment.
REAL8 threshold
Threshold for candidate selection.
UINT4 extraBinsFstat
Extra bins required for Fstat calculation.