aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build7
-rw-r--r--src/align_detector.c128
2 files changed, 135 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index c07a326a..32a156d5 100644
--- a/meson.build
+++ b/meson.build
@@ -155,6 +155,13 @@ executable('whirligig',
install: true,
install_rpath: crystfel_rpath)
+# align_detector
+executable('align_detector',
+ ['src/align_detector.c', versionc],
+ dependencies: [mdep, libcrystfeldep],
+ install: true,
+ install_rpath: '$ORIGIN/../lib64/:$ORIGIN/../lib')
+
# indexamajig
indexamajig_sources = ['src/indexamajig.c', 'src/im-sandbox.c',
'src/process_image.c',
diff --git a/src/align_detector.c b/src/align_detector.c
new file mode 100644
index 00000000..1bc9b5e3
--- /dev/null
+++ b/src/align_detector.c
@@ -0,0 +1,128 @@
+/*
+ * align_detector.c
+ *
+ * Align detector using Millepede
+ *
+ * Copyright © 2023 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2023 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 <stdio.h>
+#include <string.h>
+#include <getopt.h>
+
+#include <datatemplate.h>
+#include <utils.h>
+
+#include "version.h"
+
+
+static void show_syntax(const char *s)
+{
+ printf("Syntax: %s [options] -g <input.geom> -o <output.geom> <mille-0.dat> [...]\n", s);
+}
+
+
+static void show_help(const char *s)
+{
+ show_syntax(s);
+ printf("\nRefine detector geometry using Millepede.\n"
+ "\n"
+ " -g, --geometry=file Input geometry file\n"
+ " -o, --output=file Output geometry file\n"
+ "\n"
+ " -h, --help Display this help message\n"
+ " --version Print version number and exit\n");
+}
+
+
+int main(int argc, char *argv[])
+{
+ int c;
+ char *in_geom = NULL;
+ char *out_geom = NULL;
+
+ /* Long options */
+ const struct option longopts[] = {
+
+ {"help", 0, NULL, 'h'},
+ {"verbose", 0, NULL, 'v'},
+
+ {"version", 0, NULL, 'V'},
+ {"input", 1, NULL, 'g'},
+ {"output", 1, NULL, 'o'},
+
+ {0, 0, NULL, 0}
+ };
+
+ /* Short options */
+ while ((c = getopt_long(argc, argv, "hVo:g:i:",
+ longopts, NULL)) != -1)
+ {
+
+ switch (c) {
+
+ case 'h' :
+ show_help(argv[0]);
+ return 0;
+
+ case 'V' :
+ printf("CrystFEL: %s\n", crystfel_version_string());
+ printf("%s\n", crystfel_licence_string());
+ return 0;
+
+ case 'g' :
+ case 'i' :
+ in_geom = strdup(optarg);
+ break;
+
+ case 'o' :
+ out_geom = strdup(optarg);
+ break;
+
+ case 0 :
+ break;
+
+ case '?' :
+ break;
+
+ default :
+ ERROR("Unhandled option '%c'\n", c);
+ break;
+
+ }
+
+ }
+
+ if ( (in_geom == NULL) || (out_geom == NULL) || (argc == optind) ) {
+ show_syntax(argv[0]);
+ return 1;
+ }
+
+ return 0;
+}