LALPulsar 7.1.1.1-eeff03c
HoughFstatToplist.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Bernd Machenschalk, Reinhard Prix
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 HOUGHFSTATTOPLIST_H
21#define HOUGHFSTATTOPLIST_H
22
23#include <lal/HeapToplist.h>
24#include <lal/LALDatatypes.h>
25
26
27/** Type to hold the fields that will be kept in a "toplist" */
28typedef struct {
29 REAL8 Freq; /**< Frequency at maximum (?) of the cluster */
30 REAL8 f1dot; /**< spindown value f1dot = df/dt */
31 REAL8 Alpha; /**< Skyposition: longitude in equatorial coords, radians */
32 REAL8 Delta; /**< skyposition: latitude */
33 REAL8 HoughFstat; /**< Hough significance */
34 REAL8 AlphaBest; /**< skyposition of best candidate: longitude */
35 REAL8 DeltaBest; /**< skyposition of best candidate: latitude */
36 REAL8 MeanSig; /**< mean of significance values in hough map*/
37 REAL8 VarianceSig; /**< variance of significance values in hough map*/
38 REAL4 sumTwoF; /**< sum of 2F-values as recomputed in LV postprocessing */
39 REAL4Vector *sumTwoFX; /**< sum of 2F-values per detector, computed in LV postprocessing */
41
42
43/* This has by now been reduced to an interface to the HeapToplist functions */
44
45/**
46 * creates a toplist with length elements,
47 * returns -1 on error (usually out of memory), else 0
48 */
49extern int create_houghFstat_toplist( toplist_t **list, UINT8 length );
50
51/** frees the space occupied by the toplist */
52extern void free_houghFstat_toplist( toplist_t **list );
53
54/**
55 * Inserts an element in to the toplist either if there is space left
56 * or the element is larger than the smallest element in the toplist.
57 * In the latter case, remove the smallest element from the toplist
58 * Returns 1 if the element was actually inserted, 0 if not.
59 */
61
62/**
63 * Writes the toplist to an (already open) filepointer
64 * Returns the number of written charactes
65 * sets the checksum if non-NULL
66 * Returns something <0 on error
67 */
68extern int write_houghFstat_toplist_to_fp( toplist_t *list, FILE *fp, UINT4 *checksum );
69
70/**
71 * reads a (created!) toplist from an open filepointer
72 * sets the checksum if non-NULL
73 * reads maximum maxbytes, all that is there if maxbytes is 0
74 * returns the number of bytes read,
75 * 0 if we found a %DONE marker at the end,
76 * -1 if the file contained a syntax error,
77 * -2 if given an improper toplist
78 */
79extern int read_houghFstat_toplist_from_fp( toplist_t *list, FILE *fp, UINT4 *checksum, UINT4 maxbytes );
80
81/**
82 * sorts the toplist with an internal sorting function,
83 * used before finally writing it
84 */
85extern void sort_houghFstat_toplist( toplist_t *list );
86
87
88
89
90/** File IO */
91
92/**
93 * writes an HoughFstatOutputEntry line to an open filepointer.
94 * Returns the number of chars written, -1 if in error
95 * Updates checksum if given (i.e. not NULL)
96 */
98
99/**
100 * writes the given toplitst to a temporary file, then renames the
101 * temporary file to filename. The name of the temporary file is
102 * derived from the filename by appending ".tmp". Returns the number
103 * of chars written or -1 if the temp file could not be opened.
104 */
105extern int atomic_write_houghFstat_toplist_to_file( toplist_t *list, const char *filename, UINT4 *checksum );
106
107/**
108 * meant for the final writing of the toplist
109 * - reduces toplist precision
110 * - sorts the toplist
111 * - finally calls atomic_write_houghFstat_toplist_to_file()
112 */
113extern int final_write_houghFstat_toplist_to_file( toplist_t *list, const char *filename, UINT4 *checksum );
114
115
116
117/** new, simpler checkpointing for HierarchicalSearch */
118
119/**
120 * writes a checkpoint:
121 * - constructs temporary filename (by appending .TMP)
122 * - writes number of elements ("elems") in toplist to tempfile
123 * - dumps data to tempfile
124 * - appends counter
125 * - appends checksum (of elems, data and counter)
126 * - renames tempfile to final name
127 * returns
128 * -1 in case of an I/O error,
129 * -2 if out of memory,
130 * 0 otherwise (successful)
131 */
132extern int write_hfs_checkpoint( const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync );
133
134/**
135 * tries to read a checkpoint
136 * - tries to open the file, returns 1 if no file found
137 * - reads elems, data, counter and checksum
138 * - verifies checksum
139 * - restores the heap by sorting
140 * returns
141 * 0 if successfully read a checkpoint
142 * 1 if no checkpoint was found
143 * -1 in case of an I/O error
144 * -2 if the checksum was wrong or elems was unreasonable
145 */
146extern int read_hfs_checkpoint( const char *filename, toplist_t *tl, UINT4 *counter );
147
148/**
149 * write the final output file:
150 * - re-sort the toplist into freq/alpha/delta/fdot order
151 * - write out the toplist in ASCII format with end marker to a temporary file
152 * - rename the file to the final name
153 */
154extern int write_hfs_oputput( const char *filename, toplist_t *tl );
155
156#endif /* HOUGHFSTATTOPLIST_H - double inclusion protection */
int write_houghFstat_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 ...
int read_hfs_checkpoint(const char *filename, toplist_t *tl, UINT4 *counter)
tries to read a checkpoint
int create_houghFstat_toplist(toplist_t **list, UINT8 length)
creates a toplist with length elements, returns -1 on error (usually out of memory),...
void free_houghFstat_toplist(toplist_t **list)
frees the space occupied by the toplist
int read_houghFstat_toplist_from_fp(toplist_t *list, FILE *fp, UINT4 *checksum, UINT4 maxbytes)
reads a (created!) toplist from an open filepointer sets the checksum if non-NULL reads maximum maxby...
void sort_houghFstat_toplist(toplist_t *list)
sorts the toplist with an internal sorting function, used before finally writing it
int write_houghFstat_toplist_item_to_fp(HoughFstatOutputEntry line, FILE *fp, UINT4 *checksum)
File IO.
int write_hfs_checkpoint(const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync)
new, simpler checkpointing for HierarchicalSearch
int final_write_houghFstat_toplist_to_file(toplist_t *list, const char *filename, UINT4 *checksum)
meant for the final writing of the toplist
int insert_into_houghFstat_toplist(toplist_t *list, HoughFstatOutputEntry line)
Inserts an element in to the toplist either if there is space left or the element is larger than the ...
int atomic_write_houghFstat_toplist_to_file(toplist_t *list, const char *filename, UINT4 *checksum)
writes the given toplitst to a temporary file, then renames the temporary file to filename.
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
float REAL4
Type to hold the fields that will be kept in a "toplist"
REAL8 AlphaBest
skyposition of best candidate: longitude
REAL4 sumTwoF
sum of 2F-values as recomputed in LV postprocessing
REAL8 Delta
skyposition: latitude
REAL8 VarianceSig
variance of significance values in hough map
REAL8 f1dot
spindown value f1dot = df/dt
REAL8 Alpha
Skyposition: longitude in equatorial coords, radians.
REAL4Vector * sumTwoFX
sum of 2F-values per detector, computed in LV postprocessing
REAL8 Freq
Frequency at maximum (?) of the cluster.
REAL8 DeltaBest
skyposition of best candidate: latitude
REAL8 MeanSig
mean of significance values in hough map
REAL8 HoughFstat
Hough significance.