Skip to content

Commit fad3636

Browse files
committed
Fixes on documentation and free's in FINALLY
1 parent 11520c0 commit fad3636

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

mcstas-comps/contrib/TOF_PSDmonitor_toQ.comp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
* Position-sensitive, linear Q monitor.
1414
*
1515
* %D
16+
* One-dimensional Q-monitor. Calculates Q from "measured" time-of-flight,
17+
* i.e. not from particle velocity parameters.
18+
*
1619
* Adapted from Kim Lefmann's TOF_cylPSDmonitor and PSD_monitors
1720
* An n pixel Q-monitor based on measured Time of Flight detection.
1821
* This component may also be used as a beam
1922
* detector.
2023
*
2124
* Example: TOF_PSDmonitor_toQ(xmin=-0.1, xmax=0.1, ymin=-0.1, ymax=0.1,
22-
* ny=90, nchan=100, TOFmin=0.0, TOFmax=20000.0, filename="Output.psd")
25+
* ny=90, nqbin=100, TOFmin=0.0, TOFmax=20000.0, filename="Output.psd")
2326
*
2427
* %P
2528
* INPUT PARAMETERS:
@@ -30,7 +33,7 @@
3033
* yheight: [m] height of detector opening
3134
* ymin: [m] Lower y bound of detector opening
3235
* ymax: [m] Upper y bound of detector opening
33-
* ny: [1] Number of y bins (unsused?)
36+
* ny: [1] Number of y bins (for discretisation of
3437
* filename: [str] Name of file in which to store the detector image
3538
* nowritefile: [1] If set, detector will skip writing to disk
3639
* tmin: [mu-s] Beginning TOF window
@@ -56,6 +59,7 @@ DECLARE
5659
%}
5760
INITIALIZE
5861
%{
62+
5963
if (xwidth > 0) { xmax = xwidth/2; xmin = -xmax; }
6064
if (yheight > 0) { ymax = yheight/2; ymin = -ymax; }
6165

@@ -128,9 +132,9 @@ SAVE
128132
%}
129133

130134
FINALLY %{
131-
destroy_darr2d(Q_N);
132-
destroy_darr2d(Q_p);
133-
destroy_darr2d(Q_p2);
135+
destroy_darr1d(Q_N);
136+
destroy_darr1d(Q_p);
137+
destroy_darr1d(Q_p2);
134138
%}
135139

136140
MCDISPLAY
@@ -141,6 +145,13 @@ MCDISPLAY
141145
(double)xmax, (double)ymax, 0.0,
142146
(double)xmin, (double)ymax, 0.0,
143147
(double)xmin, (double)ymin, 0.0);
148+
double dy=(ymax-ymin)/(ny);
149+
int j;
150+
double ytmp=ymin;
151+
for(j=0; j<ny; j++) {
152+
multiline(2, xmin, ytmp, 0.0, xmax, ytmp, 0.0);
153+
ytmp+=dy;
154+
}
144155
%}
145156

146157
END

0 commit comments

Comments
 (0)