diff options
-rw-r--r-- | src/detector.c | 23 | ||||
-rw-r--r-- | src/ewald.c | 16 | ||||
-rw-r--r-- | src/image.h | 1 |
3 files changed, 18 insertions, 22 deletions
diff --git a/src/detector.c b/src/detector.c index 9e4e5649..2b0c12d4 100644 --- a/src/detector.c +++ b/src/detector.c @@ -15,11 +15,23 @@ #include <stdio.h> #include "image.h" +#include "utils.h" + + +/* Pulse energy density in J/m^2 */ +#define PULSE_ENERGY_DENSITY (30.0e7) void record_image(struct image *image) { int x, y; + double ph_per_e; + + /* How many photons are scattered per electron? */ + ph_per_e = PULSE_ENERGY_DENSITY * pow(THOMSON_LENGTH, 2.0) + / image->xray_energy; + + printf("%e photons are scattered per electron\n", ph_per_e); image->data = malloc(image->width * image->height * sizeof(uint16_t)); @@ -27,15 +39,16 @@ void record_image(struct image *image) for ( y=0; y<image->height; y++ ) { uint16_t counts; - double val; - double intensity; - double phac; + double val, intensity; + double sa; val = image->sfacs[x + image->width*y]; - phac = image->phactors[x + image->width*y]; + + /* What solid angle is subtended by this pixel? */ + sa = 1.0; intensity = pow(val, 2.0); - counts = intensity * phac; + counts = intensity * ph_per_e * sa; image->data[x + image->width*y] = counts; diff --git a/src/ewald.c b/src/ewald.c index e9f36596..d543d98a 100644 --- a/src/ewald.c +++ b/src/ewald.c @@ -19,10 +19,6 @@ #include "cell.h" -/* Pulse energy density in J/m^2 */ -#define PULSE_ENERGY_DENSITY (30.0e7) - - void get_ewald(struct image *image) { int x, y; @@ -31,18 +27,9 @@ void get_ewald(struct image *image) k = 1/image->lambda; - /* How many photons are scattered per electron? */ - i0fac = PULSE_ENERGY_DENSITY * pow(THOMSON_LENGTH, 2.0) - / image->xray_energy; - - printf("%e photons are scattered per electron\n", i0fac); - image->qvecs = malloc(image->width * image->height * sizeof(struct threevec)); - image->phactors = malloc(image->width * image->height - * sizeof(double)); - for ( x=0; x<image->width; x++ ) { for ( y=0; y<image->height; y++ ) { @@ -66,9 +53,6 @@ void get_ewald(struct image *image) image->qvecs[x + image->width*y].u = qx; image->qvecs[x + image->width*y].v = qy; image->qvecs[x + image->width*y].w = qz; - - /* Calculate photon factor ("phactor") */ - } } diff --git a/src/image.h b/src/image.h index d5d5bb9c..b675ab41 100644 --- a/src/image.h +++ b/src/image.h @@ -62,7 +62,6 @@ struct image { uint16_t *data; double *sfacs; struct threevec *qvecs; - double *phactors; /* Radians. Defines where the pattern lies in reciprocal space */ double tilt; |