aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/fom.h
blob: d337304407f33515963103e8871fa7d1f561d5de (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
/*
 * fom.h
 *
 * Figure of merit calculation
 *
 * Copyright © 2012-2021 Deutsches Elektronen-Synchrotron DESY,
 *                       a research centre of the Helmholtz Association.
 *
 * Authors:
 *   2010-2021 Thomas White <taw@physics.org>
 *   2013      Lorenzo Galli <lorenzo.galli@desy.de>
 *
 * 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/>.
 *
 */

#ifndef FOM_H
#define FOM_H

/**
 * \file fom.h
 * Figure of merit calculation
 */

#include <reflist.h>
#include <symmetry.h>

enum fom_type
{
	FOM_R1I,
	FOM_R1F,
	FOM_R2,
	FOM_RSPLIT,
	FOM_CC,
	FOM_CCSTAR,
	FOM_CCANO,
	FOM_CRDANO,
	FOM_RANO,
	FOM_RANORSPLIT,
	FOM_D1SIG,
	FOM_D2SIG
};

struct fom_shells
{
	int nshells;
	double *rmins;
	double *rmaxs;
};

struct fom_context
{
	enum fom_type fom;
	int nshells;
	int *cts;

	/* For R-factors */
	double *num;
	double *den;

	/* For "double" R-factors */
	double *num2;
	double *den2;

	/* For CCs */
	double **vec1;
	double **vec2;
	int *n;
	int nmax;

	/* For "counting" things e.g. d1sig or d2sig */
	int *n_within;
};

extern int fom_select_reflections(RefList *list1, RefList *list2,
                                  RefList *list1_acc, RefList *list2_acc,
                                  UnitCell *cell, SymOpList *sym,
                                  int anom, double rmin_fix, double rmax_fix,
                                  double sigma_cutoff, int ignore_negs,
                                  int zero_negs, int mul_cutoff);

extern struct fom_context *fom_calculate(RefList *list1, RefList *list2,
                                         UnitCell *cell,
                                         struct fom_shells *shells,
                                         enum fom_type fom, int noscale,
                                         SymOpList *sym);

extern struct fom_shells *fom_make_resolution_shells(double rmin, double rmax,
                                                     int nshells);

extern double fom_shell_label(struct fom_shells *s, int i);

extern double fom_shell(struct fom_context *fctx, int i);

extern double fom_overall(struct fom_context *fctx);

extern enum fom_type fom_type_from_string(const char *s);

#endif	/* FOM */