aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.c
blob: 22bad02ceb665a7a6a81a5db8ccfe326bfc8e967 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * datatemplate.c
 *
 * Data template structure
 *
 * Copyright © 2019 Deutsches Elektronen-Synchrotron DESY,
 *                  a research centre of the Helmholtz Association.
 *
 * Authors:
 *   2019 Thomas White <taw@physics.org>
 *
 * This file is part of CrystFEL.
 *
 * CrystFEL 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 3 of the License, or
 * (at your option) any later version.
 *
 * CrystFEL 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 CrystFEL.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>

#include "datatemplate.h"


/**
 * \file datatemplate.h
 */

enum adu_per_unit
{
	ADU_PER_PHOTON,
	ADU_PER_EV
};


/**
 * Represents one panel of a detector
 */
struct panel_template
{
	/** Text name for panel (fixed length array) */
	char     name[1024];

	/** \name Location of corner in units of the pixel size of this panel */
	/**@{*/
	double   cnx;
	double   cny;
	/**@}*/

	/** Location to get \ref cnz from, e.g. from HDF5 file */
	char    *cnz_from;

	/** The offset to be applied from \ref clen */
	double   coffset;

	/** Location of mask data */
	char    *mask;

	/** Filename for mask data */
	char    *mask_file;

	/** Location of per-pixel saturation map */
	char    *satmap;

	/** Filename for saturation map */
	char    *satmap_file;

	/** Resolution in pixels per metre  */
	double   pixel_pitch;

	/** Readout direction (for filtering out clusters of peaks)
	  * ('x' or 'y') */
	char     badrow;

	/** Number of detector intensity units per photon, or eV */
	double   adu_scale;
	enum adu_per_unit adu_scale_unit;

	/** Treat pixel as unreliable if higher than this */
	double   max_adu;

	/** Location of data in file */
	char    *data;

	/** Dimension structure */
	struct dim_structure *dim_structure;

	/** \name Transformation matrix from pixel coordinates to lab frame */
	/*@{*/
	double fsx;
	double fsy;
	double fsz;
	double ssx;
	double ssy;
	double ssz;
	/*@}*/

	/** \name Rail direction */
	/*@{*/
	double rail_x;
	double rail_y;
	double rail_z;
	/*@}*/

	/* Value of clen (without coffset) at which beam is centered */
	double clen_for_centering;

	/** \name Position of the panel in the data block in the file. */
	/*@{*/
	int orig_min_fs;
	int orig_max_fs;
	int orig_min_ss;
	int orig_max_ss;
	/*@}*/
};


struct _datatemplate
{
	struct panel_template     *panels;
	int                        n_panels;

	struct badregion          *bad;
	int                        n_bad;

	unsigned int               mask_bad;
	unsigned int               mask_good;

	struct rigid_group       **rigid_groups;
	int                        n_rigid_groups;

	struct rg_collection     **rigid_group_collections;
	int                        n_rg_collections;

	int                        path_dim;
	int                        dim_dim;

	struct panel_template      defaults;
};


DataTemplate *data_template_new_from_file(const char *filename)
{
	return NULL;
}


void data_template_free(DataTemplate *dt)
{
}