LALPulsar 7.1.1.1-eeff03c
GCTtoplist.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007, 2009 Bernd Machenschalk, Reinhard Prix, Holger Pletsch
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#ifndef GCTFSTATTOPLIST_H
21#define GCTFSTATTOPLIST_H
22
23#include <lal/LALDatatypes.h>
24#include <lal/PulsarDataTypes.h>
25#include <lal/HeapToplist.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30extern char **global_argv;
31extern int global_argc;
32#ifdef __cplusplus
33}
34#endif
35
36/**
37 * \f[
38 * \newcommand{\F}{\mathcal{F}}
39 * \f]
40 * Type to hold the fields that will be kept in a "toplist"
41 */
42typedef struct {
43 REAL8 Freq; /**< frequency */
44 REAL8 F1dot;/**< spindown value f1dot = df/dt */
45 REAL8 F2dot;/**< spindown value f2dot = d2f/dt2 */
46 REAL8 F3dot;/**< spindown value f2dot = d2f/dt2 */
47 REAL8 Alpha; /**< skyposition: longitude in equatorial coords, radians */
48 REAL8 Delta;/**< skyposition: latitude */
49 REAL4 avTwoF; /**< average of F-statistic values \f$ 2\F \f$ over segments */
50 UINT4 nc; /**< number count */
51 REAL4 log10BSGL; /**< Line-robust statistic \f$ \log_{10} B_{\mathrm{SGL}} \f$ */
52 REAL4 log10BSGLtL; /**< Line-robust statistic \f$ \log_{10} B_{\mathrm{SGLtL}} \f$ */
53 REAL4 log10BtSGLtL; /**< Line-robust transient-CW statistic \f$ \log_{10} B_{\mathrm{tSGLtL}} \f$ */
54 UINT4 numDetectors; /**< number of detectors for optional avTwoFX arrays */
55 REAL4 avTwoFX[PULSAR_MAX_DETECTORS]; /**< fixed-size array of single-detector average \f$ 2\F^X \f$ -values */
56 REAL4 maxTwoFl; /**< multi-detector maximum 2F over segments \f$ \max2\F^\ell \f$ */
57 INT4 maxTwoFlSeg; /**< index of segment with maximum multi-detector 2F */
58 REAL4 maxTwoFXl[PULSAR_MAX_DETECTORS]; /**< fixed-size array of single-detector maximum 2F over segments \f$ \max2\F^{X\ell} \f$ */
59 INT4 maxTwoFXlSeg[PULSAR_MAX_DETECTORS]; /**< fixed-size array of index of segment with maximum single-detector 2F */
60 REAL4 avTwoFrecalc; /**< average of \f$ 2\F \f$ -values as recomputed by recalcToplistStats */
61 REAL4 avTwoFXrecalc[PULSAR_MAX_DETECTORS]; /**< fixed-size array of single-detector \f$ 2\F^X \f$ -values as recomputed by recalcToplistStats */
62 REAL4 log10BSGLrecalc; /**< Line-robust statistic \f$ \log_{10} B_{\mathrm{SGL}} \f$ recomputed by recalcToplistStats */
63 REAL4 log10BSGLtLrecalc; /**< Line-robust statistic \f$ \log_{10} B_{\mathrm{SGL}} \f$ recomputed by recalcToplistStats */
64 BOOLEAN have_f3dot; /**< output F3dot value */
65 INT4 loudestSeg; /**< index of the loudest segment in multi-F */
66 REAL4 twoFloudestSeg; /**< loudest single-segment multi-IFO F-stat value */
67 REAL4 twoFXloudestSeg[PULSAR_MAX_DETECTORS]; /**< single-IFO F-stat values from the loudest segment in multi-F */
69
70/// enumerate all toplist-sorting options: by F (0), number-count (1), BSGL (2), "dual" toplists F + BSGL (3)
71typedef enum {
72 SORTBY_F = 0, //< sort by multi-IFO F-stat (averaged over segments)
73 SORTBY_NC = 1, //< sort by number-count 'nc'
74 SORTBY_BSGL = 2, //< sort by line-robust statistic B_S/GL
75 SORTBY_DUAL_F_BSGL = 3, //< dual toplists: one sorted by F, one by B_S/GL
76 SORTBY_BSGLtL = 4, //< sort by transient-line robust statistic B_S/GLtL
77 SORTBY_BtSGLtL = 5, //< sort by transient-CW line robust statistic B_tS/GLtL
78 SORTBY_TRIPLE_BStSGLtL = 6, //< triple toplists: one sorted by B_S/GL, one by B_S/GLtL, one by B_tS/GLtL
79 SORTBY_F_BSGLtL_BtSGLtL = 7,//< triple toplists: one sorted by 2F, one by B_S/GLtL, one by B_tS/GLtL
80 SORTBY_LAST //< end-marker
82
83/* This has by now been reduced to an interface to the HeapToplist functions */
84
85/**
86 * creates a toplist with length elements,
87 * returns -1 on error (usually out of memory), else 0
88 */
89extern int create_gctFstat_toplist( toplist_t **list, UINT8 length, SortBy_t whatToSortBy );
90
91/** frees the space occupied by the toplist */
92extern void free_gctFstat_toplist( toplist_t **list );
93
94/**
95 * Inserts an element in to the toplist either if there is space left
96 * or the element is larger than the smallest element in the toplist.
97 * In the latter case, remove the smallest element from the toplist
98 * Returns 1 if the element was actually inserted, 0 if not.
99 */
101
102
103/**
104 * Writes the toplist to an (already open) filepointer
105 * Returns the number of written charactes
106 * sets the checksum if non-NULL
107 * Returns something <0 on error
108 */
109extern int write_gctFstat_toplist_to_fp( toplist_t *list, FILE *fp, UINT4 *checksum );
110
111
112/**
113 * sorts the toplist with an internal sorting function,
114 * used before finally writing it
115 */
116extern void sort_gctFstat_toplist( toplist_t *list );
117
118
119/**
120 * sorts the toplist with an internal sorting function,
121 * used before doing the follow-up analysis
122 */
124
125
126
127/** Checkpointing */
128
129/**
130 * writes a checkpoint:
131 * - constructs temporary filename (by appending .TMP)
132 * - writes number of elements ("elems") in toplist to tempfile
133 * - dumps data to tempfile
134 * - appends counter
135 * - appends checksum (of elems, data and counter)
136 * - renames tempfile to final name
137 * returns
138 * -1 in case of an I/O error,
139 * -2 if out of memory,
140 * 0 otherwise (successful)
141 */
142extern int write_gct_checkpoint( const char *filename, toplist_t *tl, toplist_t *t2, toplist_t *t3, UINT4 counter, BOOLEAN do_sync );
143
144/**
145 * tries to read a checkpoint
146 * - tries to open the file, returns 1 if no file found
147 * - reads elems, data, counter and checksum
148 * - verifies checksum
149 * - restores the heap by sorting
150 * returns
151 * 0 if successfully read a checkpoint
152 * 1 if no checkpoint was found
153 * -1 in case of an I/O error
154 * -2 if the checksum was wrong or elems was unreasonable
155 */
156extern int read_gct_checkpoint( const char *filename, toplist_t *tl, toplist_t *t2, toplist_t *t3, UINT4 *counter );
157
158/**
159 * removes a checkpoint
160 * returns 0 on success, errno on failure
161 */
162extern int clear_gct_checkpoint( const char *filename );
163
164/**
165 * write the final output file:
166 * - re-sort the toplist into freq/alpha/delta/fdot order
167 * - write out the toplist in ASCII format with end marker to a temporary file
168 * - rename the file to the final name
169 */
170extern int write_hfs_oputput( const char *filename, toplist_t *tl );
171
172#endif /* GCTFSTATTOPLIST_H - double inclusion protection */
void sort_gctFstat_toplist(toplist_t *list)
sorts the toplist with an internal sorting function, used before finally writing it
Definition: GCTtoplist.c:291
char ** global_argv
void free_gctFstat_toplist(toplist_t **list)
frees the space occupied by the toplist
Definition: GCTtoplist.c:270
SortBy_t
enumerate all toplist-sorting options: by F (0), number-count (1), BSGL (2), "dual" toplists F + BSGL...
Definition: GCTtoplist.h:71
@ SORTBY_NC
Definition: GCTtoplist.h:73
@ SORTBY_BtSGLtL
Definition: GCTtoplist.h:77
@ SORTBY_LAST
Definition: GCTtoplist.h:80
@ SORTBY_DUAL_F_BSGL
Definition: GCTtoplist.h:75
@ SORTBY_BSGL
Definition: GCTtoplist.h:74
@ SORTBY_F
Definition: GCTtoplist.h:72
@ SORTBY_BSGLtL
Definition: GCTtoplist.h:76
@ SORTBY_F_BSGLtL_BtSGLtL
Definition: GCTtoplist.h:79
@ SORTBY_TRIPLE_BStSGLtL
Definition: GCTtoplist.h:78
int clear_gct_checkpoint(const char *filename)
removes a checkpoint returns 0 on success, errno on failure
Definition: GCTtoplist.c:1242
int global_argc
int create_gctFstat_toplist(toplist_t **list, UINT8 length, SortBy_t whatToSortBy)
creates a toplist with length elements, returns -1 on error (usually out of memory),...
Definition: GCTtoplist.c:246
int insert_into_gctFstat_toplist(toplist_t *list, GCTtopOutputEntry *line)
Inserts an element in to the toplist either if there is space left or the element is larger than the ...
Definition: GCTtoplist.c:281
int write_gctFstat_toplist_to_fp(toplist_t *list, FILE *fp, UINT4 *checksum)
Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the ...
Definition: GCTtoplist.c:489
int read_gct_checkpoint(const char *filename, toplist_t *tl, toplist_t *t2, toplist_t *t3, UINT4 *counter)
tries to read a checkpoint
Definition: GCTtoplist.c:941
int write_gct_checkpoint(const char *filename, toplist_t *tl, toplist_t *t2, toplist_t *t3, UINT4 counter, BOOLEAN do_sync)
Checkpointing.
Definition: GCTtoplist.c:688
void sort_gctFstat_toplist_strongest(toplist_t *list)
sorts the toplist with an internal sorting function, used before doing the follow-up analysis
int write_hfs_oputput(const char *filename, toplist_t *tl)
write the final output file:
Definition: GCTtoplist.c:1284
unsigned char BOOLEAN
uint64_t UINT8
double REAL8
uint32_t UINT4
int32_t INT4
float REAL4
#define PULSAR_MAX_DETECTORS
maximal number of detectors we can handle (for static arrays of detector quantities)
Definition: GCTtoplist.h:42
REAL4 log10BSGLtL
Line-robust statistic .
Definition: GCTtoplist.h:52
INT4 maxTwoFlSeg
index of segment with maximum multi-detector 2F
Definition: GCTtoplist.h:57
UINT4 numDetectors
number of detectors for optional avTwoFX arrays
Definition: GCTtoplist.h:54
REAL4 log10BSGLrecalc
Line-robust statistic recomputed by recalcToplistStats.
Definition: GCTtoplist.h:62
REAL8 Freq
frequency
Definition: GCTtoplist.h:43
REAL4 log10BSGLtLrecalc
Line-robust statistic recomputed by recalcToplistStats.
Definition: GCTtoplist.h:63
INT4 loudestSeg
index of the loudest segment in multi-F
Definition: GCTtoplist.h:65
REAL4 maxTwoFl
multi-detector maximum 2F over segments
Definition: GCTtoplist.h:56
UINT4 nc
number count
Definition: GCTtoplist.h:50
REAL4 log10BtSGLtL
Line-robust transient-CW statistic .
Definition: GCTtoplist.h:53
REAL4 log10BSGL
Line-robust statistic .
Definition: GCTtoplist.h:51
REAL8 F2dot
spindown value f2dot = d2f/dt2
Definition: GCTtoplist.h:45
REAL8 Alpha
skyposition: longitude in equatorial coords, radians
Definition: GCTtoplist.h:47
REAL8 Delta
skyposition: latitude
Definition: GCTtoplist.h:48
REAL8 F1dot
spindown value f1dot = df/dt
Definition: GCTtoplist.h:44
REAL4 twoFloudestSeg
loudest single-segment multi-IFO F-stat value
Definition: GCTtoplist.h:66
BOOLEAN have_f3dot
output F3dot value
Definition: GCTtoplist.h:64
REAL8 F3dot
spindown value f2dot = d2f/dt2
Definition: GCTtoplist.h:46
REAL4 avTwoFrecalc
average of -values as recomputed by recalcToplistStats
Definition: GCTtoplist.h:60
REAL4 avTwoF
average of F-statistic values over segments
Definition: GCTtoplist.h:49