blob: 2b0c12d44c49a399a908c86ceb081317cae95676 (
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
|
/*
* detector.c
*
* Detector properties
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
* pattern_sim - Simulate diffraction patterns from small crystals
*
*/
#include <stdlib.h>
#include <math.h>
#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));
for ( x=0; x<image->width; x++ ) {
for ( y=0; y<image->height; y++ ) {
uint16_t counts;
double val, intensity;
double sa;
val = image->sfacs[x + image->width*y];
/* What solid angle is subtended by this pixel? */
sa = 1.0;
intensity = pow(val, 2.0);
counts = intensity * ph_per_e * sa;
image->data[x + image->width*y] = counts;
}
}
}
|