aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/examples/cspad-feb2011.geom2
-rw-r--r--doc/examples/lcls-cxi-9keV.beam7
-rw-r--r--doc/examples/lcls-dec.beam7
-rw-r--r--doc/examples/lcls-dec.geom1
-rw-r--r--doc/examples/lcls-june-r0013-r0128.geom1
-rw-r--r--doc/examples/lcls-june.beam7
-rw-r--r--doc/examples/lcls-xpp-estimate.beam7
-rw-r--r--doc/examples/lcls-xpp-estimate.geom1
-rw-r--r--doc/examples/simple.geom2
-rw-r--r--libcrystfel/src/beam-parameters.c15
-rw-r--r--libcrystfel/src/beam-parameters.h3
-rw-r--r--libcrystfel/src/detector.c18
-rw-r--r--libcrystfel/src/detector.h1
-rw-r--r--libcrystfel/src/utils.h6
-rw-r--r--src/get_hkl.c19
-rw-r--r--tests/gpu_sim_check.c4
-rw-r--r--tests/integration_check.c3
17 files changed, 43 insertions, 61 deletions
diff --git a/doc/examples/cspad-feb2011.geom b/doc/examples/cspad-feb2011.geom
index 7eaedda0..9ef79077 100644
--- a/doc/examples/cspad-feb2011.geom
+++ b/doc/examples/cspad-feb2011.geom
@@ -1,3 +1,5 @@
+adu_per_eV = 1.0
+
q0a0/min_fs = 0
q0a0/min_ss = 0
q0a0/max_fs = 193
diff --git a/doc/examples/lcls-cxi-9keV.beam b/doc/examples/lcls-cxi-9keV.beam
index fb1f94bb..bf4a32bd 100644
--- a/doc/examples/lcls-cxi-9keV.beam
+++ b/doc/examples/lcls-cxi-9keV.beam
@@ -14,10 +14,3 @@ beam/bandwidth = 0.001
; Beam divergence in radians
beam/divergence = 0.008
-
-
-; Detector's quantum efficiency
-detector/dqe = 1.0
-
-; Number of detector ADU per photon
-detector/adu_per_photon = 1.0
diff --git a/doc/examples/lcls-dec.beam b/doc/examples/lcls-dec.beam
index b52f30e1..f277b729 100644
--- a/doc/examples/lcls-dec.beam
+++ b/doc/examples/lcls-dec.beam
@@ -14,10 +14,3 @@ beam/bandwidth = 0.001
; Beam divergence in radians
beam/divergence = 0.001
-
-
-; Detector's quantum efficiency
-detector/dqe = 0.9
-
-; Number of detector ADU per photon
-detector/adu_per_photon = 167.0
diff --git a/doc/examples/lcls-dec.geom b/doc/examples/lcls-dec.geom
index f98b42fd..ef6bcbb7 100644
--- a/doc/examples/lcls-dec.geom
+++ b/doc/examples/lcls-dec.geom
@@ -5,6 +5,7 @@ mask_bad = 0x00
; These default values will be used unless overridden by the per-panel values
peak_sep = 50.0
integr_radius = 10.0
+adu_per_eV = 0.0835
upper/min_fs = 0
upper/max_fs = 1023
diff --git a/doc/examples/lcls-june-r0013-r0128.geom b/doc/examples/lcls-june-r0013-r0128.geom
index 7e4be71c..ff1fab87 100644
--- a/doc/examples/lcls-june-r0013-r0128.geom
+++ b/doc/examples/lcls-june-r0013-r0128.geom
@@ -5,6 +5,7 @@ mask_bad = 0x00
; These default values will be used unless overridden by the per-panel values
peak_sep = 50.0
integr_radius = 10.0
+adu_per_eV = 0.01045
; Upper panel (nearest the beam)
0/min_fs = 0
diff --git a/doc/examples/lcls-june.beam b/doc/examples/lcls-june.beam
index 8a263024..30f05813 100644
--- a/doc/examples/lcls-june.beam
+++ b/doc/examples/lcls-june.beam
@@ -14,10 +14,3 @@ beam/bandwidth = 0.01
; Beam divergence in radians
beam/divergence = 0.0087
-
-
-; Detector's quantum efficiency
-detector/dqe = 0.9
-
-; Number of detector ADU per photon
-detector/adu_per_photon = 20.9
diff --git a/doc/examples/lcls-xpp-estimate.beam b/doc/examples/lcls-xpp-estimate.beam
index af9bb6ec..23ad560d 100644
--- a/doc/examples/lcls-xpp-estimate.beam
+++ b/doc/examples/lcls-xpp-estimate.beam
@@ -14,10 +14,3 @@ beam/bandwidth = 0.001
; Beam divergence in radians
beam/divergence = 0.001
-
-
-; Detector's quantum efficiency
-detector/dqe = 1.0
-
-; Number of detector ADU per photon
-detector/adu_per_photon = 1.0
diff --git a/doc/examples/lcls-xpp-estimate.geom b/doc/examples/lcls-xpp-estimate.geom
index c64c985a..7c4d21a8 100644
--- a/doc/examples/lcls-xpp-estimate.geom
+++ b/doc/examples/lcls-xpp-estimate.geom
@@ -10,3 +10,4 @@
0/res = 9090 ; 110 micron pixel size
0/badrow_direction = x
0/peak_sep = 4
+0/adu_per_eV = 1.0
diff --git a/doc/examples/simple.geom b/doc/examples/simple.geom
index 62ee53db..65769883 100644
--- a/doc/examples/simple.geom
+++ b/doc/examples/simple.geom
@@ -1,3 +1,5 @@
+adu_per_eV = 1.0
+
; Upper panel
0/min_fs = 0
0/max_fs = 1023
diff --git a/libcrystfel/src/beam-parameters.c b/libcrystfel/src/beam-parameters.c
index 082e9651..654d7550 100644
--- a/libcrystfel/src/beam-parameters.c
+++ b/libcrystfel/src/beam-parameters.c
@@ -51,8 +51,6 @@ struct beam_params *get_beam_parameters(const char *filename)
b->photon_energy = -1.0;
b->bandwidth = -1.0;
b->divergence = -1.0;
- b->dqe = -1.0;
- b->adu_per_photon = -1.0;
do {
@@ -88,10 +86,6 @@ struct beam_params *get_beam_parameters(const char *filename)
b->bandwidth = atof(bits[2]);
} else if ( strcmp(bits[0], "beam/divergence") == 0 ) {
b->divergence = atof(bits[2]);
- } else if ( strcmp(bits[0], "detector/dqe") == 0 ) {
- b->dqe = atof(bits[2]);
- } else if ( strcmp(bits[0], "detector/adu_per_photon") == 0 ) {
- b->adu_per_photon = atof(bits[2]);
} else {
ERROR("Unrecognised field '%s'\n", bits[0]);
}
@@ -125,15 +119,6 @@ struct beam_params *get_beam_parameters(const char *filename)
ERROR("Invalid or unspecified value for 'beam/divergence'.\n");
reject = 1;
}
- if ( b->dqe < 0.0 ) {
- ERROR("Invalid or unspecified value for 'detector/dqe'.\n");
- reject = 1;
- }
- if ( b->adu_per_photon < 0.0 ) {
- ERROR("Invalid or unspecified value for"
- " 'detector/adu_per_photon'.\n");
- reject = 1;
- }
if ( reject ) {
ERROR("Please fix the above problems with the beam"
diff --git a/libcrystfel/src/beam-parameters.h b/libcrystfel/src/beam-parameters.h
index 6f5d8a75..2cf1bf39 100644
--- a/libcrystfel/src/beam-parameters.h
+++ b/libcrystfel/src/beam-parameters.h
@@ -40,9 +40,6 @@ struct beam_params
* a rectangular distribution with this as
* its (full) width. */
double divergence; /* divergence (radians) */
-
- double dqe; /* Detector DQE (fraction) */
- double adu_per_photon; /* Detector "gain" */
};
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index ee09eb73..6c4dcbb6 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -365,15 +365,14 @@ void record_image(struct image *image, int do_poisson)
sa = proj_area / (dsq + Lsq);
if ( do_poisson ) {
- counts = poisson_noise(intensity * ph_per_e
- * sa * image->beam->dqe );
+ counts = poisson_noise(intensity * ph_per_e * sa);
} else {
- cf = intensity * ph_per_e * sa * image->beam->dqe;
+ cf = intensity * ph_per_e * sa;
counts = cf;
}
- image->data[x + image->width*y] = counts
- * image->beam->adu_per_photon;
+ image->data[x + image->width*y] = counts * p->adu_per_eV
+ * ph_lambda_to_eV(image->lambda);
/* Sanity checks */
if ( isinf(image->data[x+image->width*y]) ) n_inf2++;
@@ -577,6 +576,8 @@ static int parse_field_for_panel(struct panel *panel, const char *key,
panel->cnx = atof(val);
} else if ( strcmp(key, "corner_y") == 0 ) {
panel->cny = atof(val);
+ } else if ( strcmp(key, "adu_per_eV") == 0 ) {
+ panel->adu_per_eV = atof(val);
} else if ( strcmp(key, "rigid_group") == 0 ) {
panel->rigid_group = find_or_add_rg(det, val);
} else if ( strcmp(key, "clen") == 0 ) {
@@ -737,6 +738,7 @@ struct detector *get_detector_geometry(const char *filename)
det->defaults.ssx = 0.0;
det->defaults.ssy = 1.0;
det->defaults.rigid_group = NULL;
+ det->defaults.adu_per_eV = NAN;
strncpy(det->defaults.name, "", 1023);
do {
@@ -871,6 +873,11 @@ struct detector *get_detector_geometry(const char *filename)
" panel %s\n", det->panels[i].name);
reject = 1;
}
+ if ( isnan(det->panels[i].adu_per_eV) ) {
+ ERROR("Please specify the number of ADU per eV for"
+ " panel %s\n", det->panels[i].name);
+ reject = 1;
+ }
/* It's OK if the badrow direction is '0' */
/* It's not a problem if "no_index" is still zero */
/* The default peak_sep is OK (maybe) */
@@ -1242,6 +1249,7 @@ int write_detector_geometry(const char *filename, struct detector *det)
fprintf(fh, "%s/ss = %+fx %+fy\n", p->name, p->ssx, p->ssy);
fprintf(fh, "%s/corner_x = %g\n", p->name, p->cnx);
fprintf(fh, "%s/corner_y = %g\n", p->name, p->cny);
+ fprintf(fh, "%s/adu_per_eV = %g\n", p->name, p->adu_per_eV);
if ( p->no_index ) {
fprintf(fh, "%s/no_index = 1\n", p->name);
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index 53aca93d..b3743935 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -59,6 +59,7 @@ struct panel
double peak_sep; /* Characteristic peak separation */
double integr_radius; /* Peak integration radius */
char *rigid_group; /* Rigid group, or -1 for none */
+ double adu_per_eV; /* Number of ADU per eV */
double fsx;
double fsy;
diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h
index 8d5ee479..8c11abd6 100644
--- a/libcrystfel/src/utils.h
+++ b/libcrystfel/src/utils.h
@@ -186,6 +186,12 @@ static inline int within_tolerance(double a, double b, double percent)
/* Joules to eV */
#define J_to_eV(a) ((a)/ELECTRON_CHARGE)
+/* Photon wavelength (m) to energy (eV) */
+#define ph_lambda_to_eV(a) J_to_eV(ph_lambda_to_en(a))
+
+/* Photon energy (eV) to wavelength (m) */
+#define ph_eV_to_lambda(a) ph_en_to_lambda(eV_to_J(a))
+
#define UNUSED __attribute__((unused))
diff --git a/src/get_hkl.c b/src/get_hkl.c
index 905da569..cec55495 100644
--- a/src/get_hkl.c
+++ b/src/get_hkl.c
@@ -56,7 +56,7 @@ static void show_help(const char *s)
" --noise Add 10%% random noise.\n"
"\n"
"To calculate Poisson samples accurately, you must also give:\n"
-" -b, --beam=<file> Get beam parameters from file.\n"
+" --adu-per-photon=<n> Number of ADU per photon.\n"
"\n"
"You can artificially 'twin' the reflections, or expand them out.\n"
" -w, --twin=<sym> Generate twinned data according to the given\n"
@@ -362,6 +362,8 @@ int main(int argc, char *argv[])
char *beamfile = NULL;
struct beam_params *beam = NULL;
RefList *input;
+ double adu_per_photon = 0.0;
+ int have_adu_per_photon = 0;
/* Long options */
const struct option longopts[] = {
@@ -375,8 +377,8 @@ int main(int argc, char *argv[])
{"expand", 1, NULL, 'e'},
{"intensities", 1, NULL, 'i'},
{"multiplicity", 0, &config_multi, 1},
- {"beam", 1, NULL, 'b'},
{"trim-centrics", 0, &config_trimc, 1},
+ {"adu-per-photon", 1, NULL, 2},
{0, 0, NULL, 0}
};
@@ -413,8 +415,9 @@ int main(int argc, char *argv[])
expand_str = strdup(optarg);
break;
- case 'b' :
- beamfile = strdup(optarg);
+ case 2 :
+ adu_per_photon = strtof(optarg, NULL);
+ have_adu_per_photon = 1;
break;
case 0 :
@@ -476,11 +479,11 @@ int main(int argc, char *argv[])
}
if ( config_poisson ) {
- if ( beam != NULL ) {
- poisson_reflections(input, beam->adu_per_photon);
+ if ( have_adu_per_photon ) {
+ poisson_reflections(input, adu_per_photon);
} else {
- ERROR("You must give a beam parameters file in order"
- " to calculate Poisson noise.\n");
+ ERROR("You must give the number of ADU per photon to "
+ "use --poisson.\n");
return 1;
}
}
diff --git a/tests/gpu_sim_check.c b/tests/gpu_sim_check.c
index 4557b551..5b6f6da7 100644
--- a/tests/gpu_sim_check.c
+++ b/tests/gpu_sim_check.c
@@ -115,6 +115,7 @@ int main(int argc, char *argv[])
det->panels[0].cny = -512.0-sep;
det->panels[0].clen = 100.0e-3;
det->panels[0].res = 9090.91;
+ det->panels[0].adu_per_eV = 1.0;
det->panels[1].min_fs = 0;
det->panels[1].max_fs = 1023;
@@ -132,6 +133,7 @@ int main(int argc, char *argv[])
det->panels[1].cny = sep;
det->panels[1].clen = 100.0e-3;
det->panels[1].res = 9090.91;
+ det->panels[0].adu_per_eV = 1.0;
cpu_image.det = det;
gpu_image.det = det;
@@ -142,8 +144,6 @@ int main(int argc, char *argv[])
beam->photon_energy = 9000.0;
beam->bandwidth = 0.1 / 100.0;
beam->divergence = 0.0;
- beam->dqe = 1.0;
- beam->adu_per_photon = 1.0;
cpu_image.beam = beam;
gpu_image.beam = beam;
diff --git a/tests/integration_check.c b/tests/integration_check.c
index 1e439611..80a214d1 100644
--- a/tests/integration_check.c
+++ b/tests/integration_check.c
@@ -291,6 +291,8 @@ int main(int argc, char *argv[])
image.data = malloc(128*128*sizeof(float));
image.flags = NULL;
+ image.beam = NULL;
+ image.lambda = ph_eV_to_lambda(1000.0);
image.det = calloc(1, sizeof(struct detector));
image.det->n_panels = 1;
@@ -313,6 +315,7 @@ int main(int argc, char *argv[])
image.det->panels[0].clen = 1.0;
image.det->panels[0].res = 1.0;
image.det->panels[0].integr_radius = 10.0;
+ image.det->panels[0].adu_per_eV = 1.0;
image.width = 128;
image.height = 128;