1 | /** |
---|
2 | This software was developed by the University of Tennessee as part of the |
---|
3 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
4 | project funded by the US National Science Foundation. |
---|
5 | |
---|
6 | If you use DANSE applications to do scientific research that leads to |
---|
7 | publication, we ask that you acknowledge the use of the software with the |
---|
8 | following sentence: |
---|
9 | |
---|
10 | "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
11 | |
---|
12 | copyright 2009, University of Tennessee |
---|
13 | */ |
---|
14 | #ifndef SMEARER_CLASS_H |
---|
15 | #define SMEARER_CLASS_H |
---|
16 | |
---|
17 | #include <vector> |
---|
18 | |
---|
19 | using namespace std; |
---|
20 | |
---|
21 | /** |
---|
22 | * Base smearer class, implementing the matrix multiplication only |
---|
23 | */ |
---|
24 | class BaseSmearer { |
---|
25 | protected: |
---|
26 | // Internal flag: true when the weights vector is filled |
---|
27 | bool has_matrix; |
---|
28 | // True when only qmin, qmax and nbins are given. Bins are equidistant |
---|
29 | bool even_binning; |
---|
30 | // Smearing matrix |
---|
31 | vector<double>* weights; |
---|
32 | // Q vector |
---|
33 | double* q_values; |
---|
34 | // Q_min (Min Q-value for I(q)) |
---|
35 | double qmin; |
---|
36 | // Q_max (Max Q_value for I(q)) |
---|
37 | double qmax; |
---|
38 | // Number of Q bins |
---|
39 | int nbins; |
---|
40 | |
---|
41 | public: |
---|
42 | // Constructor |
---|
43 | BaseSmearer(double qmin, double qmax, int nbins); |
---|
44 | BaseSmearer(double* q, int nbins); |
---|
45 | // Smear function |
---|
46 | virtual void smear(double *, double *, int, int); |
---|
47 | // Compute the smearing matrix |
---|
48 | virtual void compute_matrix(){}; |
---|
49 | // Utility function to check the number of bins |
---|
50 | int get_nbins() { return nbins; } |
---|
51 | // Get the q range of a particular bin |
---|
52 | virtual int get_bin_range(int, double*, double*, double*); |
---|
53 | }; |
---|
54 | |
---|
55 | |
---|
56 | /** |
---|
57 | * Slit smearer class |
---|
58 | */ |
---|
59 | class SlitSmearer : public BaseSmearer { |
---|
60 | |
---|
61 | protected: |
---|
62 | // Number of points used in the smearing computation |
---|
63 | static const int npts = 1000; |
---|
64 | |
---|
65 | public: |
---|
66 | // Slit width in Q units |
---|
67 | double width; |
---|
68 | // Slit height in Q units |
---|
69 | double height; |
---|
70 | |
---|
71 | // Constructor |
---|
72 | SlitSmearer(double width, double height, double qmin, double qmax, int nbins); |
---|
73 | SlitSmearer(double width, double height, double* q, int nbins); |
---|
74 | // Compute the smearing matrix |
---|
75 | virtual void compute_matrix(); |
---|
76 | }; |
---|
77 | |
---|
78 | |
---|
79 | /** |
---|
80 | * Point smearer class |
---|
81 | */ |
---|
82 | class QSmearer : public BaseSmearer { |
---|
83 | |
---|
84 | protected: |
---|
85 | // Standard deviation in Q [A-1] |
---|
86 | double* width; |
---|
87 | |
---|
88 | public: |
---|
89 | |
---|
90 | // Constructor |
---|
91 | QSmearer(double* width, double qmin, double qmax, int nbins); |
---|
92 | QSmearer(double* width, double* q, int nbins); |
---|
93 | // Compute the smearing matrix |
---|
94 | virtual void compute_matrix(); |
---|
95 | }; |
---|
96 | |
---|
97 | #endif |
---|