Added support for three detector banks for FOCUS
This commit is contained in:
2
Makefile
2
Makefile
@ -25,7 +25,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
|
||||
sicsexit.o costa.o task.o $(FORTIFYOBJ)\
|
||||
macro.o ofac.o obpar.o obdes.o drive.o status.o intserv.o \
|
||||
devexec.o mumo.o mumoconf.o selector.o selvar.o fupa.o lld.o \
|
||||
lld_blob.o buffer.o strrepl.o ruli.o lin2ang.o \
|
||||
lld_blob.o buffer.o strrepl.o ruli.o lin2ang.o fomerge.o\
|
||||
script.o o2t.o alias.o napi.o nxdata.o stringdict.o sdynar.o\
|
||||
histmem.o histdriv.o histsim.o sinqhmdriv.o interface.o callback.o \
|
||||
event.o emon.o evcontroller.o evdriver.o simev.o perfmon.o \
|
||||
|
14
amortest.tcl
14
amortest.tcl
@ -221,21 +221,11 @@ MakeStoreAmor hm
|
||||
#--------------------------------------------------------------------------
|
||||
# C o m m a n d I n i t i a l i z a t i o n
|
||||
#-------------------------------------------------------------------------
|
||||
#======= logbook
|
||||
source tcl/log.tcl
|
||||
Publish LogBook Spy
|
||||
#======== Drive
|
||||
MakeDrive
|
||||
#======== scan
|
||||
source $home/tcl/topsicom.tcl
|
||||
source $home/tcl/cscan.tcl
|
||||
Publish cscan User
|
||||
Publish sscan User
|
||||
Publish sftime Spy
|
||||
Publish scan Spy
|
||||
Publish ScanCounts Spy
|
||||
Publish TextStatus Spy
|
||||
Publish otUnknown Spy
|
||||
source $home/object.tcl
|
||||
source $home/tcl/scancom.tcl
|
||||
MakeScanCommand xxxscan counter topsi.hdd recover.bin
|
||||
xxxscan configure amor
|
||||
#========== peak & center
|
||||
|
2
bruker.c
2
bruker.c
@ -172,7 +172,7 @@ extern char *rmtrail(char *p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(pCommand,"CUF/");
|
||||
strcpy(pCommand,"FIE/");
|
||||
iRet = BrukerCommand(self,pCommand,pBueffel,79);
|
||||
if(!iRet)
|
||||
{
|
||||
|
2
danu.dat
2
danu.dat
@ -1,3 +1,3 @@
|
||||
537199972
|
||||
5378
|
||||
NEVER, EVER modify or delete this file
|
||||
You'll risk eternal damnation and a reincarnation as a cockroach!|n
|
@ -399,3 +399,6 @@ C-----------------------------------------------------------------------
|
||||
$ ' Now starting a ',F5.2,' minutes delay before',
|
||||
$ ' resuming data collection.')
|
||||
END
|
||||
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Mark Koennecke, Juli 1998
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
all: topsi dmc sans
|
||||
all: topsi dmc sans focus
|
||||
|
||||
topsi:
|
||||
html2tex topman
|
||||
@ -21,3 +21,8 @@ sans:
|
||||
latex sansman
|
||||
latex sansman
|
||||
dvips sansman
|
||||
focus:
|
||||
html2tex foman
|
||||
latex foman
|
||||
latex foman
|
||||
dvips foman
|
||||
|
@ -25,6 +25,17 @@ is minutes.
|
||||
<DD>This command will overwrite the last data file written and thus
|
||||
effectively erase it. Therefore this command requires manager privilege.
|
||||
</DL>
|
||||
FOCUS has three detector banks which may not all be active at all
|
||||
times. Thus a way is needed to tell SICS about the configuration of
|
||||
the day. This is also done through ths storefocus command. There are
|
||||
three parameters, <b>upper, middle and lower</b> which can be either on
|
||||
(value greater 0) or off (value less then or equal to 0). The value
|
||||
can be inquired with <b> storefocus par</b>. For example <b>storefocus
|
||||
middle</b> prints the flag for the middle detector bank. With <b>
|
||||
storefocus par val </b> a new value for the parameter is set. For
|
||||
example <b>storefocus lower 1</B> switches the lower detector bank
|
||||
on. These commands are usually used in the configuration file and
|
||||
require manager privilege.
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
41
faverage.c
41
faverage.c
@ -6,6 +6,10 @@
|
||||
copyright: see copyright.h
|
||||
|
||||
Mark Koennecke, October 1998
|
||||
|
||||
Updated for additional detector banks
|
||||
|
||||
Mark Koennecke, March 2000
|
||||
---------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@ -15,6 +19,7 @@
|
||||
#include "sics.h"
|
||||
#include "counter.h"
|
||||
#include "HistMem.h"
|
||||
#include "fomerge.h"
|
||||
#include "faverage.h"
|
||||
|
||||
/*
|
||||
@ -40,7 +45,6 @@
|
||||
free(self);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
int MakeFA(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
@ -124,6 +128,7 @@
|
||||
char pBueffel[256];
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
time_t tStart, tEnd;
|
||||
int iBank = MIDDLE;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
@ -153,6 +158,18 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* another parameter, if available describes the detector bank*
|
||||
if(argc > 3)
|
||||
{
|
||||
iRet = Tcl_GetInt(pSics->pTcl,argv[3],&iBank);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: cannot convert %d to integer",argv[3]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* how much to do: correct parameters? */
|
||||
iNum = iEnd - iStart;
|
||||
if(iNum < 0)
|
||||
@ -191,9 +208,9 @@
|
||||
memset(iData,0,iBufLen);
|
||||
|
||||
/* get histogram length */
|
||||
i = GetHistLength(self->pHist);
|
||||
i = getFMdim(iBank);
|
||||
/* correct iEnd to maximum allowed */
|
||||
iTest = i/iLength;
|
||||
iTest = i;
|
||||
if(iEnd > iTest -1)
|
||||
{
|
||||
iEnd = iTest - 1;
|
||||
@ -202,25 +219,19 @@
|
||||
iNum = 1;
|
||||
}
|
||||
|
||||
/* get histogram data */
|
||||
hiData = (HistInt *)malloc(i*sizeof(HistInt));
|
||||
if( (!hiData) || !(iData) )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in FocusAverage",eError);
|
||||
return 0;
|
||||
}
|
||||
#ifdef DEB
|
||||
printf("Getting histogram....\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
i = GetHistogram(self->pHist,pCon,0,0,i,hiData,i*sizeof(HistInt));
|
||||
if(!i)
|
||||
hiData = GetHistogramPointer(self->pHist,pCon);
|
||||
if(hiData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory data",eError);
|
||||
free(hiData);
|
||||
free(iData);
|
||||
return 0;
|
||||
}
|
||||
setFMDataPointer(hiData, iLength);
|
||||
hiData = getFMBankPointer(iBank);
|
||||
#ifdef DEB
|
||||
tEnd = time(NULL);
|
||||
printf("Histogram received in %d seconds\n", tStart - tEnd);
|
||||
@ -245,7 +256,7 @@
|
||||
fVal *= 65536.;
|
||||
iData[i] = htonl((int)fVal);
|
||||
}
|
||||
/* truncate time binning to integer */
|
||||
/* make time binning fixed point */
|
||||
for(i = 0; i < iLength; i++)
|
||||
{
|
||||
fVal = fTimeBin[i]/10.;
|
||||
@ -260,8 +271,6 @@
|
||||
SCWriteUUencoded(pCon,"FocusAverage",iData,iBufLen);
|
||||
if(iData)
|
||||
free(iData);
|
||||
if(hiData)
|
||||
free(hiData);
|
||||
#ifdef DEB
|
||||
printf("Averaging finished\n");
|
||||
fflush(stdout);
|
||||
|
664
focusmerge.dat
Normal file
664
focusmerge.dat
Normal file
@ -0,0 +1,664 @@
|
||||
#---- Merge Table
|
||||
273
|
||||
001 10.050 000 001 000
|
||||
002 10.850 000 002 000
|
||||
003 11.660 000 003 000
|
||||
004 12.460 000 004 000
|
||||
005 13.260 000 005 000
|
||||
006 14.060 000 006 000
|
||||
007 14.870 000 007 000
|
||||
008 15.670 000 008 000
|
||||
009 16.470 000 009 000
|
||||
010 17.270 000 010 000
|
||||
011 18.070 000 011 000
|
||||
012 18.350 001 000 001
|
||||
013 18.880 000 012 000
|
||||
014 19.175 002 000 002
|
||||
015 19.680 000 013 000
|
||||
016 20.000 003 000 003
|
||||
017 20.480 000 014 000
|
||||
018 20.825 004 000 004
|
||||
019 21.280 000 015 000
|
||||
020 21.650 005 000 005
|
||||
021 22.090 000 016 000
|
||||
022 22.890 000 017 000
|
||||
023 23.350 006 000 006
|
||||
024 23.690 000 018 000
|
||||
025 24.175 007 000 007
|
||||
026 24.490 000 019 000
|
||||
027 25.000 008 000 008
|
||||
028 25.290 000 020 000
|
||||
029 25.825 009 000 009
|
||||
030 26.100 000 021 000
|
||||
031 26.650 010 000 010
|
||||
032 26.900 000 022 000
|
||||
033 27.700 000 023 000
|
||||
034 28.350 011 000 011
|
||||
035 28.500 000 024 000
|
||||
036 29.175 012 000 012
|
||||
037 29.310 000 025 000
|
||||
038 30.000 013 000 013
|
||||
039 30.110 000 026 000
|
||||
040 30.825 014 000 014
|
||||
041 30.910 000 027 000
|
||||
042 31.650 015 000 015
|
||||
043 31.710 000 028 000
|
||||
044 32.510 000 029 000
|
||||
045 33.320 000 030 000
|
||||
046 33.350 016 000 016
|
||||
047 34.120 000 031 000
|
||||
048 34.175 017 000 017
|
||||
049 34.920 000 032 000
|
||||
050 35.000 018 000 018
|
||||
051 35.720 000 033 000
|
||||
052 35.825 019 000 019
|
||||
053 36.520 000 034 000
|
||||
054 36.650 020 000 020
|
||||
055 37.330 000 035 000
|
||||
056 38.130 000 036 000
|
||||
057 38.350 021 000 021
|
||||
058 38.930 000 037 000
|
||||
059 39.175 022 000 022
|
||||
060 39.730 000 038 000
|
||||
061 40.000 023 000 023
|
||||
062 40.540 000 039 000
|
||||
063 40.825 024 000 024
|
||||
064 41.340 000 040 000
|
||||
065 41.650 025 000 025
|
||||
066 42.140 000 041 000
|
||||
067 42.850 026 000 026
|
||||
068 42.940 000 042 000
|
||||
069 43.675 027 000 027
|
||||
070 43.740 000 043 000
|
||||
071 44.500 028 000 028
|
||||
072 44.550 000 044 000
|
||||
073 45.325 029 000 029
|
||||
074 45.350 000 045 000
|
||||
075 46.150 030 046 030
|
||||
076 46.950 000 047 000
|
||||
077 47.350 031 000 031
|
||||
078 47.760 000 048 000
|
||||
079 48.175 032 000 032
|
||||
080 48.560 000 049 000
|
||||
081 49.000 033 000 033
|
||||
082 49.360 000 050 000
|
||||
083 49.825 034 000 034
|
||||
084 50.160 000 051 000
|
||||
085 50.650 035 000 035
|
||||
086 50.960 000 052 000
|
||||
087 51.770 000 053 000
|
||||
088 51.850 036 000 036
|
||||
089 52.570 000 054 000
|
||||
090 52.675 037 000 037
|
||||
091 53.370 000 055 000
|
||||
092 53.500 038 000 038
|
||||
093 54.170 000 056 000
|
||||
094 54.325 039 000 039
|
||||
095 54.980 000 057 000
|
||||
096 55.150 040 000 040
|
||||
097 55.780 000 058 000
|
||||
098 56.350 041 000 041
|
||||
099 56.580 000 059 000
|
||||
100 57.175 042 000 042
|
||||
101 57.380 000 060 000
|
||||
102 58.000 043 000 043
|
||||
103 58.180 000 061 000
|
||||
104 58.825 044 000 044
|
||||
105 58.990 000 062 000
|
||||
106 59.650 045 000 045
|
||||
107 59.790 000 063 000
|
||||
108 60.590 000 064 000
|
||||
109 60.850 046 000 046
|
||||
110 61.390 000 065 000
|
||||
111 61.675 047 000 047
|
||||
112 62.190 000 066 000
|
||||
113 62.500 048 000 048
|
||||
114 63.000 000 067 000
|
||||
115 63.325 049 000 049
|
||||
116 63.800 000 068 000
|
||||
117 64.150 050 000 050
|
||||
118 64.600 000 069 000
|
||||
119 65.350 051 000 000
|
||||
120 65.400 000 070 000
|
||||
121 66.175 052 000 000
|
||||
122 66.210 000 071 000
|
||||
123 67.000 053 000 000
|
||||
124 67.010 000 072 000
|
||||
125 67.810 000 073 000
|
||||
126 67.825 054 000 000
|
||||
127 68.610 000 074 000
|
||||
128 68.650 055 000 051
|
||||
129 69.410 000 075 000
|
||||
130 69.850 056 000 000
|
||||
131 70.350 000 000 052
|
||||
132 70.675 057 000 000
|
||||
133 71.175 000 000 053
|
||||
134 71.500 058 000 000
|
||||
135 72.000 000 000 054
|
||||
136 72.325 059 000 000
|
||||
137 72.825 000 000 055
|
||||
138 72.900 000 076 000
|
||||
139 73.650 000 000 056
|
||||
140 73.700 000 077 000
|
||||
141 74.510 000 078 000
|
||||
142 74.850 000 000 057
|
||||
143 75.310 000 079 000
|
||||
144 75.675 000 000 058
|
||||
145 76.110 000 080 000
|
||||
146 76.500 060 000 059
|
||||
147 76.910 000 081 000
|
||||
148 77.325 061 000 060
|
||||
149 77.710 000 082 000
|
||||
150 78.150 062 000 061
|
||||
151 78.520 000 083 000
|
||||
152 79.320 000 084 000
|
||||
153 79.350 063 000 062
|
||||
154 80.120 000 085 000
|
||||
155 80.175 064 000 063
|
||||
156 80.920 000 086 000
|
||||
157 81.000 065 000 064
|
||||
158 81.720 000 087 000
|
||||
159 81.825 066 000 065
|
||||
160 82.530 000 088 000
|
||||
161 82.650 067 000 066
|
||||
162 83.330 000 089 000
|
||||
163 83.850 068 000 067
|
||||
164 84.130 000 090 000
|
||||
165 84.675 069 000 068
|
||||
166 84.930 000 091 000
|
||||
167 85.500 070 000 069
|
||||
168 85.740 000 092 000
|
||||
169 86.325 071 000 070
|
||||
170 86.540 000 093 000
|
||||
171 87.150 072 000 071
|
||||
172 87.340 000 094 000
|
||||
173 88.140 000 095 000
|
||||
174 88.350 073 000 072
|
||||
175 88.940 000 096 000
|
||||
176 89.175 074 000 073
|
||||
177 89.750 000 097 000
|
||||
178 90.000 075 000 074
|
||||
179 90.550 000 098 000
|
||||
180 90.825 076 000 075
|
||||
181 91.350 000 099 000
|
||||
182 91.650 077 000 076
|
||||
183 92.150 000 100 000
|
||||
184 92.850 078 000 077
|
||||
185 92.960 000 101 000
|
||||
186 93.675 079 000 078
|
||||
187 93.760 000 102 000
|
||||
188 94.500 080 000 079
|
||||
189 94.560 000 103 000
|
||||
190 95.325 081 000 080
|
||||
191 95.360 000 104 000
|
||||
192 96.150 082 000 081
|
||||
193 96.160 000 105 000
|
||||
194 96.970 000 106 000
|
||||
195 97.350 083 000 082
|
||||
196 97.770 000 107 000
|
||||
197 98.175 084 000 083
|
||||
198 98.570 000 108 000
|
||||
199 99.000 085 000 084
|
||||
200 99.370 000 109 000
|
||||
201 99.825 086 000 085
|
||||
202 100.180 000 110 000
|
||||
203 100.650 087 000 086
|
||||
204 100.980 000 111 000
|
||||
205 101.780 000 112 000
|
||||
206 101.850 088 000 087
|
||||
207 102.580 000 113 000
|
||||
208 102.675 089 000 088
|
||||
209 103.380 000 114 000
|
||||
210 103.500 090 000 089
|
||||
211 104.190 000 115 000
|
||||
212 104.325 091 000 090
|
||||
213 104.990 000 116 000
|
||||
214 105.150 092 000 091
|
||||
215 105.790 000 117 000
|
||||
216 106.350 093 000 092
|
||||
217 106.590 000 118 000
|
||||
218 107.175 094 000 093
|
||||
219 107.390 000 119 000
|
||||
220 108.000 095 000 094
|
||||
221 108.200 000 120 000
|
||||
222 108.825 096 000 095
|
||||
223 109.000 000 121 000
|
||||
224 109.650 097 000 096
|
||||
225 109.800 000 122 000
|
||||
226 110.600 000 123 000
|
||||
227 110.850 098 000 097
|
||||
228 111.410 000 124 000
|
||||
229 111.675 099 000 098
|
||||
230 112.210 000 125 000
|
||||
231 112.500 100 000 099
|
||||
232 113.010 000 126 000
|
||||
233 113.325 101 000 100
|
||||
234 113.810 000 127 000
|
||||
235 114.150 102 000 101
|
||||
236 114.610 000 128 000
|
||||
237 115.350 103 000 102
|
||||
238 115.420 000 129 000
|
||||
239 116.175 104 000 103
|
||||
240 116.220 000 130 000
|
||||
241 117.000 105 000 104
|
||||
242 117.020 000 131 000
|
||||
243 117.820 000 132 000
|
||||
244 117.825 106 000 105
|
||||
245 118.630 000 133 000
|
||||
246 118.650 107 000 106
|
||||
247 119.430 000 134 000
|
||||
248 119.850 108 000 107
|
||||
249 120.230 000 135 000
|
||||
250 120.675 109 000 108
|
||||
251 121.030 000 136 000
|
||||
252 121.500 110 000 109
|
||||
253 121.830 000 137 000
|
||||
254 122.325 111 000 110
|
||||
255 122.640 000 138 000
|
||||
256 123.150 112 000 111
|
||||
257 123.440 000 139 000
|
||||
258 124.240 000 140 000
|
||||
259 124.350 113 000 112
|
||||
260 125.040 000 141 000
|
||||
261 125.175 114 000 113
|
||||
262 125.850 000 142 000
|
||||
263 126.000 115 000 114
|
||||
264 126.650 000 143 000
|
||||
265 126.825 116 000 115
|
||||
266 127.450 000 144 000
|
||||
267 127.650 117 000 116
|
||||
268 128.250 000 145 000
|
||||
269 129.050 000 146 000
|
||||
270 129.860 000 147 000
|
||||
271 130.660 000 148 000
|
||||
272 131.460 000 149 000
|
||||
273 132.260 000 150 000
|
||||
#----- upper bank two theta
|
||||
117
|
||||
18.35
|
||||
19.175
|
||||
20
|
||||
20.825
|
||||
21.65
|
||||
23.35
|
||||
24.175
|
||||
25
|
||||
25.825
|
||||
26.65
|
||||
28.35
|
||||
29.175
|
||||
30
|
||||
30.825
|
||||
31.65
|
||||
33.35
|
||||
34.175
|
||||
35
|
||||
35.825
|
||||
36.65
|
||||
38.35
|
||||
39.175
|
||||
40
|
||||
40.825
|
||||
41.65
|
||||
42.85
|
||||
43.675
|
||||
44.5
|
||||
45.325
|
||||
46.15
|
||||
47.35
|
||||
48.175
|
||||
49
|
||||
49.825
|
||||
50.65
|
||||
51.85
|
||||
52.675
|
||||
53.5
|
||||
54.325
|
||||
55.15
|
||||
56.35
|
||||
57.175
|
||||
58
|
||||
58.825
|
||||
59.65
|
||||
60.85
|
||||
61.675
|
||||
62.5
|
||||
63.325
|
||||
64.15
|
||||
65.35
|
||||
66.175
|
||||
67
|
||||
67.825
|
||||
68.65
|
||||
69.85
|
||||
70.675
|
||||
71.5
|
||||
72.325
|
||||
76.5
|
||||
77.325
|
||||
78.15
|
||||
79.35
|
||||
80.175
|
||||
81
|
||||
81.825
|
||||
82.65
|
||||
83.85
|
||||
84.675
|
||||
85.5
|
||||
86.325
|
||||
87.15
|
||||
88.35
|
||||
89.175
|
||||
90
|
||||
90.825
|
||||
91.65
|
||||
92.85
|
||||
93.675
|
||||
94.5
|
||||
95.325
|
||||
96.15
|
||||
97.35
|
||||
98.175
|
||||
99
|
||||
99.825
|
||||
100.65
|
||||
101.85
|
||||
102.675
|
||||
103.5
|
||||
104.325
|
||||
105.15
|
||||
106.35
|
||||
107.175
|
||||
108
|
||||
108.825
|
||||
109.65
|
||||
110.85
|
||||
111.675
|
||||
112.5
|
||||
113.325
|
||||
114.15
|
||||
115.35
|
||||
116.175
|
||||
117
|
||||
117.825
|
||||
118.65
|
||||
119.85
|
||||
120.675
|
||||
121.5
|
||||
122.325
|
||||
123.15
|
||||
124.35
|
||||
125.175
|
||||
126
|
||||
126.825
|
||||
127.65
|
||||
#----- middle bank two theta
|
||||
150
|
||||
10.05
|
||||
10.85
|
||||
11.66
|
||||
12.46
|
||||
13.26
|
||||
14.06
|
||||
14.87
|
||||
15.67
|
||||
16.47
|
||||
17.27
|
||||
18.07
|
||||
18.88
|
||||
19.68
|
||||
20.48
|
||||
21.28
|
||||
22.09
|
||||
22.89
|
||||
23.69
|
||||
24.49
|
||||
25.29
|
||||
26.1
|
||||
26.9
|
||||
27.7
|
||||
28.5
|
||||
29.31
|
||||
30.11
|
||||
30.91
|
||||
31.71
|
||||
32.51
|
||||
33.32
|
||||
34.12
|
||||
34.92
|
||||
35.72
|
||||
36.52
|
||||
37.33
|
||||
38.13
|
||||
38.93
|
||||
39.73
|
||||
40.54
|
||||
41.34
|
||||
42.14
|
||||
42.94
|
||||
43.74
|
||||
44.55
|
||||
45.35
|
||||
46.15
|
||||
46.95
|
||||
47.76
|
||||
48.56
|
||||
49.36
|
||||
50.16
|
||||
50.96
|
||||
51.77
|
||||
52.57
|
||||
53.37
|
||||
54.17
|
||||
54.98
|
||||
55.78
|
||||
56.58
|
||||
57.38
|
||||
58.18
|
||||
58.99
|
||||
59.79
|
||||
60.59
|
||||
61.39
|
||||
62.19
|
||||
63
|
||||
63.8
|
||||
64.6
|
||||
65.4
|
||||
66.21
|
||||
67.01
|
||||
67.81
|
||||
68.61
|
||||
69.41
|
||||
72.9
|
||||
73.7
|
||||
74.51
|
||||
75.31
|
||||
76.11
|
||||
76.91
|
||||
77.71
|
||||
78.52
|
||||
79.32
|
||||
80.12
|
||||
80.92
|
||||
81.72
|
||||
82.53
|
||||
83.33
|
||||
84.13
|
||||
84.93
|
||||
85.74
|
||||
86.54
|
||||
87.34
|
||||
88.14
|
||||
88.94
|
||||
89.75
|
||||
90.55
|
||||
91.35
|
||||
92.15
|
||||
92.96
|
||||
93.76
|
||||
94.56
|
||||
95.36
|
||||
96.16
|
||||
96.97
|
||||
97.77
|
||||
98.57
|
||||
99.37
|
||||
100.18
|
||||
100.98
|
||||
101.78
|
||||
102.58
|
||||
103.38
|
||||
104.19
|
||||
104.99
|
||||
105.79
|
||||
106.59
|
||||
107.39
|
||||
108.2
|
||||
109
|
||||
109.8
|
||||
110.6
|
||||
111.41
|
||||
112.21
|
||||
113.01
|
||||
113.81
|
||||
114.61
|
||||
115.42
|
||||
116.22
|
||||
117.02
|
||||
117.82
|
||||
118.63
|
||||
119.43
|
||||
120.23
|
||||
121.03
|
||||
121.83
|
||||
122.64
|
||||
123.44
|
||||
124.24
|
||||
125.04
|
||||
125.85
|
||||
126.65
|
||||
127.45
|
||||
128.25
|
||||
129.05
|
||||
129.86
|
||||
130.66
|
||||
131.46
|
||||
132.26
|
||||
#------- lower bank two theta
|
||||
116
|
||||
18.35
|
||||
19.175
|
||||
20
|
||||
20.825
|
||||
21.65
|
||||
23.35
|
||||
24.175
|
||||
25
|
||||
25.825
|
||||
26.65
|
||||
28.35
|
||||
29.175
|
||||
30
|
||||
30.825
|
||||
31.65
|
||||
33.35
|
||||
34.175
|
||||
35
|
||||
35.825
|
||||
36.65
|
||||
38.35
|
||||
39.175
|
||||
40
|
||||
40.825
|
||||
41.65
|
||||
42.85
|
||||
43.675
|
||||
44.5
|
||||
45.325
|
||||
46.15
|
||||
47.35
|
||||
48.175
|
||||
49
|
||||
49.825
|
||||
50.65
|
||||
51.85
|
||||
52.675
|
||||
53.5
|
||||
54.325
|
||||
55.15
|
||||
56.35
|
||||
57.175
|
||||
58
|
||||
58.825
|
||||
59.65
|
||||
60.85
|
||||
61.675
|
||||
62.5
|
||||
63.325
|
||||
64.15
|
||||
68.65
|
||||
70.35
|
||||
71.175
|
||||
72
|
||||
72.825
|
||||
73.65
|
||||
74.85
|
||||
75.675
|
||||
76.5
|
||||
77.325
|
||||
78.15
|
||||
79.35
|
||||
80.175
|
||||
81
|
||||
81.825
|
||||
82.65
|
||||
83.85
|
||||
84.675
|
||||
85.5
|
||||
86.325
|
||||
87.15
|
||||
88.35
|
||||
89.175
|
||||
90
|
||||
90.825
|
||||
91.65
|
||||
92.85
|
||||
93.675
|
||||
94.5
|
||||
95.325
|
||||
96.15
|
||||
97.35
|
||||
98.175
|
||||
99
|
||||
99.825
|
||||
100.65
|
||||
101.85
|
||||
102.675
|
||||
103.5
|
||||
104.325
|
||||
105.15
|
||||
106.35
|
||||
107.175
|
||||
108
|
||||
108.825
|
||||
109.65
|
||||
110.85
|
||||
111.675
|
||||
112.5
|
||||
113.325
|
||||
114.15
|
||||
115.35
|
||||
116.175
|
||||
117
|
||||
117.825
|
||||
118.65
|
||||
119.85
|
||||
120.675
|
||||
121.5
|
||||
122.325
|
||||
123.15
|
||||
124.35
|
||||
125.175
|
||||
126
|
||||
126.825
|
||||
127.65
|
394
fomerge.c
Normal file
394
fomerge.c
Normal file
@ -0,0 +1,394 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
F O M E R G E
|
||||
|
||||
This module is for the FOCUS instrument. FOCUS has three detector
|
||||
banks. These are sent to SICS as one big array by the histogram memory.
|
||||
However, depending on the situation these need to be accessed either:
|
||||
- as single banks.
|
||||
- or as a merged bank, where detector counts from all three banks are
|
||||
summed onto a common two theta scale.
|
||||
|
||||
This module is responsible for accessing single banks and for doing
|
||||
the merging operation.
|
||||
|
||||
copyright: see copyright.h
|
||||
|
||||
|
||||
Mark Koennecke, March 2000
|
||||
--------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "fortify.h"
|
||||
|
||||
/* change this in line with HistMem.h */
|
||||
typedef int HistInt;
|
||||
|
||||
#include "fomerge.h"
|
||||
|
||||
/*================== module static data items ==========================*/
|
||||
static HistInt *masterData, *upperData, *mediumData, *lowerData,
|
||||
*mergedData = NULL;
|
||||
static int timeBin, nUpper, nLower, nMedium, nMerged;
|
||||
static float *upperTheta, *lowerTheta, *mediumTheta, *mergedTheta;
|
||||
static int *mergeUp, *mergeMed, *mergeLow;
|
||||
int iMerged;
|
||||
|
||||
int medium, upper, lower;
|
||||
/*------------------------------------------------------------------------
|
||||
The tables with the theta values for the detector banks aand the merge
|
||||
table living in mergeUp, mergeMed, mergeLow is initialized from a
|
||||
data file, the mergefile. mergeUp, mergeLow, mergeMed contain a 0 if
|
||||
the detector from this bank does not need to be summed for this merged
|
||||
two theta value or the number of the detector from this bank to use.
|
||||
-------------------------------------------------------------------------*/
|
||||
int initializeFM(char *mergefile)
|
||||
{
|
||||
FILE *fd = NULL;
|
||||
int i, j, iTest;
|
||||
char pBuffer[132];
|
||||
char *pPtr = NULL;
|
||||
|
||||
/* open the file */
|
||||
fd = fopen(mergefile,"r");
|
||||
if(!fd)
|
||||
{
|
||||
fprintf(stdout,"ERROR: merge data file not found!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* skip first line */
|
||||
pPtr = fgets(pBuffer,131,fd);
|
||||
|
||||
/* read the number of merged data points */
|
||||
fgets(pBuffer,131,fd);
|
||||
iTest = sscanf(pBuffer,"%d",&nMerged);
|
||||
if((iTest != 1) || (nMerged <= 0) )
|
||||
{
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge dat file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate space */
|
||||
mergedTheta = (float *)malloc(nMerged*sizeof(float));
|
||||
mergeUp = (int *)malloc(nMerged*sizeof(int));
|
||||
mergeMed = (int *)malloc(nMerged*sizeof(int));
|
||||
mergeLow = (int *)malloc(nMerged*sizeof(int));
|
||||
if( mergedTheta == NULL || mergeUp == NULL || mergeMed == NULL
|
||||
|| mergeLow == NULL )
|
||||
{
|
||||
fprintf(stdout,"ERROR: out of memory in fomerge\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* read the merge table */
|
||||
for(i = 0; i < nMerged; i++)
|
||||
{
|
||||
fgets(pBuffer,131,fd);
|
||||
iTest = sscanf(pBuffer,"%d %f %d %d %d",&j, &mergedTheta[i],
|
||||
&mergeUp[i], &mergeMed[i], &mergeLow[i]);
|
||||
if(iTest != 5)
|
||||
{
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge dat file");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* read upper bank two theta */
|
||||
fgets(pBuffer,131,fd);
|
||||
fgets(pBuffer,131,fd);
|
||||
iTest = sscanf(pBuffer,"%d",&nUpper);
|
||||
if((iTest != 1) || (nUpper <= 0) )
|
||||
{
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge data file");
|
||||
return 0;
|
||||
}
|
||||
upperTheta = (float *)malloc(nUpper*sizeof(float));
|
||||
if(upperTheta == NULL)
|
||||
{
|
||||
fprintf(stdout,"ERROR: out of memory in fomerge\n");
|
||||
return 0;
|
||||
}
|
||||
for(i = 0; i < nUpper; i++)
|
||||
{
|
||||
fgets(pBuffer,131,fd);
|
||||
sscanf(pBuffer,"%f",&upperTheta[i]);
|
||||
}
|
||||
|
||||
/* read middle bank two theta */
|
||||
fgets(pBuffer,131,fd);
|
||||
fgets(pBuffer,131,fd);
|
||||
iTest = sscanf(pBuffer,"%d",&nMedium);
|
||||
if((iTest != 1) || (nMedium <= 0) )
|
||||
{
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge data file");
|
||||
return 0;
|
||||
}
|
||||
mediumTheta = (float *)malloc(nMedium*sizeof(float));
|
||||
if(mediumTheta == NULL)
|
||||
{
|
||||
fprintf(stdout,"ERROR: out of memory in fomerge\n");
|
||||
return 0;
|
||||
}
|
||||
for(i = 0; i < nMedium; i++)
|
||||
{
|
||||
fgets(pBuffer,131,fd);
|
||||
sscanf(pBuffer,"%f",&mediumTheta[i]);
|
||||
}
|
||||
|
||||
/* read lower bank two theta */
|
||||
fgets(pBuffer,131,fd);
|
||||
fgets(pBuffer,131,fd);
|
||||
iTest = sscanf(pBuffer,"%d",&nLower);
|
||||
if((iTest != 1) || (nLower <= 0) )
|
||||
{
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge data file");
|
||||
return 0;
|
||||
}
|
||||
lowerTheta = (float *)malloc(nLower*sizeof(float));
|
||||
if(lowerTheta == NULL)
|
||||
{
|
||||
fprintf(stdout,"ERROR: out of memory in fomerge\n");
|
||||
return 0;
|
||||
}
|
||||
for(i = 0; i < nLower; i++)
|
||||
{
|
||||
fgets(pBuffer,131,fd);
|
||||
sscanf(pBuffer,"%f",&lowerTheta[i]);
|
||||
}
|
||||
|
||||
/* done */
|
||||
timeBin = 0;
|
||||
iMerged = 0;
|
||||
medium =1;
|
||||
upper = lower = 0;
|
||||
|
||||
fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
sets the data pointer and finds the starting points for the different
|
||||
banks. This routine contains the knowledge how the detector banks are
|
||||
laid out in the histogram returned from the histogram memory.
|
||||
-------------------------------------------------------------------------*/
|
||||
int setFMDataPointer(HistInt *lData, int mytimeBins)
|
||||
{
|
||||
HistInt *dataPtr;
|
||||
|
||||
if(lData == NULL)
|
||||
return 0;
|
||||
|
||||
/* the first set is the medium bank */
|
||||
masterData = dataPtr = lData;
|
||||
if(medium)
|
||||
{
|
||||
mediumData = masterData;
|
||||
}
|
||||
else
|
||||
{
|
||||
mediumData = NULL;
|
||||
}
|
||||
|
||||
/* the next set is the upper bank */
|
||||
if(upper)
|
||||
{
|
||||
upperData = dataPtr + mytimeBins*nMedium;
|
||||
dataPtr = upperData;
|
||||
}
|
||||
else
|
||||
{
|
||||
upperData = NULL;
|
||||
}
|
||||
|
||||
/* the last is the lower bank */
|
||||
if(lower)
|
||||
{
|
||||
lowerData = dataPtr + mytimeBins*nUpper;
|
||||
dataPtr = lowerData;
|
||||
}
|
||||
else
|
||||
{
|
||||
lowerData = NULL;
|
||||
}
|
||||
|
||||
/* deal with data allocation for merged data */
|
||||
if(mytimeBins != timeBin)
|
||||
{
|
||||
if(mergedData != NULL)
|
||||
{
|
||||
free(mergedData);
|
||||
}
|
||||
timeBin = mytimeBins;
|
||||
mergedData = (HistInt *)malloc(nMerged*timeBin*sizeof(HistInt));
|
||||
if(mergedData == NULL)
|
||||
{
|
||||
fprintf(stdout,"ERROR: out of memory in fomerge.setFMdataPointer\n");
|
||||
return 0;
|
||||
}
|
||||
memset(mergedData,0,nMerged*timeBin*sizeof(HistInt));
|
||||
}
|
||||
|
||||
iMerged = 0;
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void setFMconfiguration(int up, int med, int low)
|
||||
{
|
||||
upper = up;
|
||||
medium = med;
|
||||
lower = low;
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
The algorithm is suboptimal because we have to take care of the case of
|
||||
missing detector banks due to missing or broken electronics or whatever.
|
||||
*/
|
||||
static void mergeData(void)
|
||||
{
|
||||
int i, j, nDiv;
|
||||
HistInt *startMerge, *startData;
|
||||
|
||||
assert(mergedData);
|
||||
|
||||
for(i = 0; i < nMerged; i++)
|
||||
{
|
||||
startMerge = mergedData + i * timeBin;
|
||||
nDiv = 0;
|
||||
/* upper bank contribution */
|
||||
if( mergeUp[i] != 0 && upperData != NULL)
|
||||
{
|
||||
startData = upperData + (mergeUp[i]-1)*timeBin;
|
||||
for(j = 0; j < timeBin; j++)
|
||||
{
|
||||
startMerge[j] += startData[j];
|
||||
}
|
||||
nDiv++;
|
||||
}
|
||||
/* medium bank contribution */
|
||||
if( mergeMed[i] != 0 && mediumData != NULL)
|
||||
{
|
||||
startData = mediumData + (mergeMed[i]-1)*timeBin;
|
||||
for(j = 0; j < timeBin; j++)
|
||||
{
|
||||
startMerge[j] += startData[j];
|
||||
}
|
||||
nDiv++;
|
||||
}
|
||||
/* lower bank contribution */
|
||||
if( mergeLow[i] != 0 && lowerData != NULL)
|
||||
{
|
||||
startData = lowerData + (mergeLow[i]-1)*timeBin;
|
||||
for(j = 0; j < timeBin; j++)
|
||||
{
|
||||
startMerge[j] += startData[j];
|
||||
}
|
||||
nDiv++;
|
||||
}
|
||||
/* do we need to run a division? */
|
||||
if(nDiv > 1)
|
||||
{
|
||||
for(j = 0; j < timeBin; j++)
|
||||
{
|
||||
startMerge[j] /= nDiv;
|
||||
}
|
||||
}
|
||||
} /* end of for */
|
||||
iMerged = 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void killFM(void)
|
||||
{
|
||||
if(mergedData != NULL)
|
||||
free(mergedData);
|
||||
|
||||
if(lowerTheta != NULL)
|
||||
free(lowerTheta);
|
||||
|
||||
if(mediumTheta != NULL)
|
||||
free(mediumTheta);
|
||||
|
||||
if(upperTheta != NULL)
|
||||
free(upperTheta);
|
||||
|
||||
if(mergedTheta != NULL)
|
||||
free(mergedTheta);
|
||||
|
||||
if(mergeUp != NULL)
|
||||
free(mergeUp);
|
||||
|
||||
if(mergeMed != NULL)
|
||||
free(mergeMed);
|
||||
|
||||
if(mergeLow != NULL)
|
||||
free(mergeLow);
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
Below are some not very interesting data access routines
|
||||
---------------------------------------------------------------------------*/
|
||||
HistInt *getFMBankPointer(int which)
|
||||
{
|
||||
switch(which)
|
||||
{
|
||||
case UPPER:
|
||||
return upperData;
|
||||
break;
|
||||
case MIDDLE:
|
||||
return mediumData;
|
||||
break;
|
||||
case LOWER:
|
||||
return lowerData;
|
||||
break;
|
||||
case MERGED:
|
||||
if(!iMerged)
|
||||
mergeData();
|
||||
return mergedData;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
float *getFMBankTheta(int which)
|
||||
{
|
||||
switch(which)
|
||||
{
|
||||
case UPPER:
|
||||
return upperTheta;
|
||||
break;
|
||||
case MIDDLE:
|
||||
return mediumTheta;
|
||||
break;
|
||||
case LOWER:
|
||||
return lowerTheta;
|
||||
break;
|
||||
case MERGED:
|
||||
return mergedTheta;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int getFMdim(int which)
|
||||
{
|
||||
switch(which)
|
||||
{
|
||||
case UPPER:
|
||||
return nUpper;
|
||||
break;
|
||||
case MIDDLE:
|
||||
return nMedium;
|
||||
break;
|
||||
case LOWER:
|
||||
return nLower;
|
||||
break;
|
||||
case MERGED:
|
||||
return nMerged;
|
||||
break;
|
||||
case TIMEBIN:
|
||||
return timeBin;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
70
fomerge.h
Normal file
70
fomerge.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
F o M e r g e
|
||||
|
||||
This module is for the FOCUS instrument. FOCUS has three detector
|
||||
banks. These are sent to SICS as one big array by the histogram memory.
|
||||
However, depending on the situation these need to be accessed either:
|
||||
- as single banks.
|
||||
- or as a merged bank, where detector counts from all three banks are
|
||||
summed onto a common two theta scale.
|
||||
|
||||
This module is responsible for accessing single detectors and for doing
|
||||
the merging operation.
|
||||
|
||||
|
||||
Mark Koennecke, March 2000
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef FOMERGE
|
||||
#define FOMERGE
|
||||
|
||||
#define UPPER 1
|
||||
#define MIDDLE 2
|
||||
#define LOWER 3
|
||||
#define MERGED 4
|
||||
#define TIMEBIN 5
|
||||
|
||||
int setFMDataPointer(HistInt *lData, int timeBins);
|
||||
/*
|
||||
sets the data array with the unmerged data. timeBins is the
|
||||
length of the time binning used. upper, medium and lower are flags
|
||||
which indicate the presence of the detector bank.
|
||||
*/
|
||||
|
||||
void setFMconfiguration(int upper, int medium, int lower);
|
||||
/*
|
||||
sets the configuration of the histogram memory
|
||||
*/
|
||||
|
||||
HistInt *getFMBankPointer(int which);
|
||||
/*
|
||||
returns a pointer to the counted data for the detector bank
|
||||
specified by which. Possible values are given above.
|
||||
|
||||
*/
|
||||
float *getFMBankTheta(int which);
|
||||
/*
|
||||
returns a pointer to a float array with the two theta values for
|
||||
the detector bank specified by which.
|
||||
*/
|
||||
|
||||
int initializeFM(char *mergefile);
|
||||
/*
|
||||
initializes the two-theta and merging data from the file
|
||||
mergefile. This must have been cllaed before anything else.
|
||||
*/
|
||||
|
||||
void killFM(void);
|
||||
/*
|
||||
frees all merging data structures.
|
||||
*/
|
||||
|
||||
int getFMdim(int which);
|
||||
/*
|
||||
returns the dimension in two theta for the detector banks of
|
||||
the length of the time binning if TIMEBIN has been specified.
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
346
fowrite.c
346
fowrite.c
@ -6,6 +6,10 @@
|
||||
copyright: see copyright.h
|
||||
|
||||
Mark Koennecke, November 1998
|
||||
|
||||
Added code for three detector banks.
|
||||
|
||||
Mark Koennecke, March 2000
|
||||
-----------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@ -24,6 +28,7 @@
|
||||
#include "scan.h"
|
||||
#include "sicsvar.h"
|
||||
#include "fitcenter.h"
|
||||
#include "fomerge.h"
|
||||
|
||||
/* the name of the SICS chopper controller object */
|
||||
#define CHOPPERNAME "choco"
|
||||
@ -41,6 +46,8 @@
|
||||
char *pDictFile;
|
||||
pFit pFitter;
|
||||
float fElastic;
|
||||
int iUpper, iMiddle, iLower;
|
||||
/* detector availability flags */
|
||||
} FoWrite, *pFoWrite;
|
||||
/* ------------------- forward declaration of task function --------------*/
|
||||
static int FoTask(void *pData);
|
||||
@ -170,7 +177,7 @@
|
||||
float fVal, *fArray;
|
||||
const float *fTime;
|
||||
float *fTime2 = NULL;
|
||||
|
||||
char pBuffer[50];
|
||||
|
||||
/* get a filename */
|
||||
if(self->pFile)
|
||||
@ -179,7 +186,8 @@
|
||||
self->pFile = SNXMakeFileName(pServ->pSics,pCon);
|
||||
if(!self->pFile)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Extra severe: failed to create data file name",eError);
|
||||
SCWrite(pCon,"ERROR: Extra severe: failed to create data file name",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -256,7 +264,6 @@
|
||||
|
||||
|
||||
/* detector banks */
|
||||
/* currently the one and only bank */
|
||||
fTime = GetHistTimeBin(self->pHist,&iLength);
|
||||
fTime2 = (float *)malloc(iLength*sizeof(float));
|
||||
if(fTime2)
|
||||
@ -267,7 +274,29 @@
|
||||
}
|
||||
sprintf(pBueffel,"%d",iLength);
|
||||
NXDupdate(pDict,"timebin",pBueffel);
|
||||
if(self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
NXDputalias(pFile,pDict,"dtime",fTime2);
|
||||
}
|
||||
if(self->iUpper)
|
||||
{
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
NXDputalias(pFile,pDict,"dtime",fTime2);
|
||||
}
|
||||
if(self->iLower)
|
||||
{
|
||||
NXDupdate(pDict,"bank","lowerbank");
|
||||
NXDputalias(pFile,pDict,"dtime",fTime2);
|
||||
}
|
||||
if( (self->iLower || self->iUpper) && self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","merged");
|
||||
NXDputalias(pFile,pDict,"dtime",fTime2);
|
||||
}
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
|
||||
|
||||
/* calculate theoretical position of elastic peak */
|
||||
fVal = CalculateElastic(self,pCon);
|
||||
self->fElastic = (fVal - fTime2[0]) / (fTime2[1] - fTime2[0]);
|
||||
@ -282,21 +311,45 @@
|
||||
|
||||
SNXSPutVariable(pServ->pSics,pCon,pFile,pDict,"ddist","detectordist");
|
||||
|
||||
/* theta array */
|
||||
fArray = (float *)malloc(150*sizeof(float));
|
||||
if(fArray)
|
||||
/* theta arrays */
|
||||
if(self->iMiddle)
|
||||
{
|
||||
for(i = 0; i < 75; i++)
|
||||
{
|
||||
fArray[i] = 0.80219*i + 9.2503;
|
||||
}
|
||||
for(i = 75; i< 150; i++)
|
||||
{
|
||||
fArray[i] = 0.80219*i + 11.9343;
|
||||
}
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
iLength = getFMdim(MIDDLE);
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(MIDDLE);
|
||||
NXDputalias(pFile,pDict,"dtheta",fArray);
|
||||
free(fArray);
|
||||
}
|
||||
if(self->iLower)
|
||||
{
|
||||
NXDupdate(pDict,"bank","lowerbank");
|
||||
iLength = getFMdim(LOWER);
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(LOWER);
|
||||
NXDputalias(pFile,pDict,"dtheta",fArray);
|
||||
}
|
||||
if(self->iUpper)
|
||||
{
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
iLength = getFMdim(UPPER);
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(UPPER);
|
||||
NXDputalias(pFile,pDict,"dtheta",fArray);
|
||||
}
|
||||
if(self->iMiddle && ( self->iLower || self->iUpper) )
|
||||
{
|
||||
NXDupdate(pDict,"bank","merged");
|
||||
iLength = getFMdim(MERGED);
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(MERGED);
|
||||
NXDputalias(pFile,pDict,"dtheta",fArray);
|
||||
}
|
||||
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
SNXSPutVariable(pServ->pSics,pCon,pFile,pDict,"ddelay","delay");
|
||||
|
||||
|
||||
@ -369,28 +422,27 @@
|
||||
lVal = GetHistMonitor(self->pHist,2,pCon);
|
||||
NXDputalias(pFile,pDict,"cnmon2",&lVal);
|
||||
|
||||
/* histogram */
|
||||
|
||||
/* histogram with three detector banks */
|
||||
fTime = GetHistTimeBin(self->pHist,&iInt);
|
||||
iTime = iInt;
|
||||
sprintf(pBueffel,"%d",iInt);
|
||||
NXDupdate(pDict,"timebin",pBueffel);
|
||||
iInt = GetHistLength(self->pHist);
|
||||
lData = (HistInt *)malloc(iInt*sizeof(HistInt));
|
||||
if(!lData)
|
||||
lData = GetHistogramPointer(self->pHist,pCon);
|
||||
setFMDataPointer(lData,iTime);
|
||||
if(self->iUpper)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory, failed to write histogram",eError);
|
||||
return;
|
||||
}
|
||||
memset(lData,0,iInt*sizeof(HistInt));
|
||||
GetHistogram(self->pHist,pCon, 0,0,iInt,lData,iInt*sizeof(HistInt));
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
iDet = getFMdim(UPPER);
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
lData = getFMBankPointer(UPPER);
|
||||
NXDputalias(pFile,pDict,"dcounts",lData);
|
||||
|
||||
/* summed counts for each detector */
|
||||
iSum = (int *)malloc(iTime*sizeof(int));
|
||||
iDet = iInt/iTime; /* number of detectors */
|
||||
iSum = (int *)malloc(iDet*sizeof(int));
|
||||
if(iSum)
|
||||
{
|
||||
memset(iSum,0,iTime*sizeof(int));
|
||||
memset(iSum,0,iDet*sizeof(int));
|
||||
for(i = 0; i < iDet; i++)
|
||||
{
|
||||
iIndex = i * iTime;
|
||||
@ -404,10 +456,109 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",eWarning);
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
/* middle bank */
|
||||
if(self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
iDet = getFMdim(MIDDLE);
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
lData = getFMBankPointer(MIDDLE);
|
||||
NXDputalias(pFile,pDict,"dcounts",lData);
|
||||
/* summed counts for each detector */
|
||||
iSum = (int *)malloc(iDet*sizeof(int));
|
||||
if(iSum)
|
||||
{
|
||||
memset(iSum,0,iDet*sizeof(int));
|
||||
for(i = 0; i < iDet; i++)
|
||||
{
|
||||
iIndex = i * iTime;
|
||||
for(j = 0; j < iTime; j++)
|
||||
{
|
||||
iSum[i] += lData[iIndex+j];
|
||||
}
|
||||
}
|
||||
NXDputalias(pFile,pDict,"dsums",iSum);
|
||||
free(iSum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
if(self->iLower)
|
||||
{
|
||||
NXDupdate(pDict,"bank","lowerbank");
|
||||
iDet = getFMdim(LOWER);
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
lData = getFMBankPointer(LOWER);
|
||||
NXDputalias(pFile,pDict,"dcounts",lData);
|
||||
/* summed counts for each detector */
|
||||
iSum = (int *)malloc(iDet*sizeof(int));
|
||||
if(iSum)
|
||||
{
|
||||
memset(iSum,0,iDet*sizeof(int));
|
||||
for(i = 0; i < iDet; i++)
|
||||
{
|
||||
iIndex = i * iTime;
|
||||
for(j = 0; j < iTime; j++)
|
||||
{
|
||||
iSum[i] += lData[iIndex+j];
|
||||
}
|
||||
}
|
||||
NXDputalias(pFile,pDict,"dsums",iSum);
|
||||
free(iSum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
/* merged data */
|
||||
if( (self->iUpper || self->iLower) && self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","merged");
|
||||
iDet = getFMdim(MERGED);
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
lData = getFMBankPointer(MERGED);
|
||||
NXDputalias(pFile,pDict,"dcounts",lData);
|
||||
/* summed counts for each detector */
|
||||
iSum = (int *)malloc(iDet*sizeof(int));
|
||||
if(iSum)
|
||||
{
|
||||
memset(iSum,0,iDet*sizeof(int));
|
||||
for(i = 0; i < iDet; i++)
|
||||
{
|
||||
iIndex = i * iTime;
|
||||
for(j = 0; j < iTime; j++)
|
||||
{
|
||||
iSum[i] += lData[iIndex+j];
|
||||
}
|
||||
}
|
||||
NXDputalias(pFile,pDict,"dsums",iSum);
|
||||
free(iSum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* calculate elastic peak position */
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
lData = getFMBankPointer(MIDDLE);
|
||||
if(lData)
|
||||
{
|
||||
lSum = (long *)malloc(iTime *sizeof(long));
|
||||
fAxis = (float *)malloc(iTime *sizeof(float));
|
||||
if( lSum && fAxis)
|
||||
@ -453,6 +604,7 @@
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",eWarning);
|
||||
}
|
||||
}
|
||||
sprintf(pBueffel,"Elastic peak found at detector: %f",self->fElastic);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
NXDputalias(pFile,pDict,"delastic",&self->fElastic);
|
||||
@ -479,7 +631,7 @@
|
||||
int iStat;
|
||||
char pBueffel[512];
|
||||
|
||||
/* open everything agaian */
|
||||
/* open everything again */
|
||||
NXopen(self->pFile,NXACC_RDWR,&pFile);
|
||||
if(!pFile)
|
||||
{
|
||||
@ -499,10 +651,39 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if(self->iUpper)
|
||||
{
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
NXDaliaslink(pFile,pDict,"dana","dcounts");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtime");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtheta");
|
||||
NXDaliaslink(pFile,pDict,"dana","cnmon1");
|
||||
}
|
||||
if(self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
NXDaliaslink(pFile,pDict,"dana","dcounts");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtime");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtheta");
|
||||
NXDaliaslink(pFile,pDict,"dana","cnmon1");
|
||||
}
|
||||
if(self->iLower)
|
||||
{
|
||||
NXDupdate(pDict,"bank","lowerbank");
|
||||
NXDaliaslink(pFile,pDict,"dana","dcounts");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtime");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtheta");
|
||||
NXDaliaslink(pFile,pDict,"dana","cnmon1");
|
||||
}
|
||||
if( (self->iUpper || self->iLower) && self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","merged");
|
||||
NXDaliaslink(pFile,pDict,"dana","dcounts");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtime");
|
||||
NXDaliaslink(pFile,pDict,"dana","dtheta");
|
||||
NXDaliaslink(pFile,pDict,"dana","cnmon1");
|
||||
}
|
||||
|
||||
|
||||
/* close everything */
|
||||
NXclose(&pFile);
|
||||
@ -575,6 +756,9 @@
|
||||
if(self->pFitter)
|
||||
DeleteFitCenter(self->pFitter);
|
||||
|
||||
/* free fomerge */
|
||||
killFM();
|
||||
|
||||
free(self);
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@ -589,7 +773,7 @@
|
||||
pDummy pDum;
|
||||
|
||||
/* check arguments */
|
||||
if(argc < 3 )
|
||||
if(argc < 4 )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Insufficient number of arguments to FoInstall",
|
||||
eError);
|
||||
@ -603,6 +787,12 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!initializeFM(argv[3]))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: bad merge data file",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate data structure */
|
||||
pNew = (pFoWrite)malloc(sizeof(FoWrite));
|
||||
if(!pNew)
|
||||
@ -621,13 +811,16 @@
|
||||
pNew->pHist = pHist;
|
||||
pNew->pDictFile = strdup(argv[2]);
|
||||
pNew->iInterval = 20*60;
|
||||
pNew->iMiddle =1;
|
||||
|
||||
/* install callbacks */
|
||||
pDum = (pDummy)pHist;
|
||||
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pHist,CALLBACKINTERFACE);
|
||||
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pHist,
|
||||
CALLBACKINTERFACE);
|
||||
if(!pCall)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: no callback interface found at your histogram memory",
|
||||
SCWrite(pCon,
|
||||
"ERROR: no callback interface found at your histogram memory",
|
||||
eError);
|
||||
KillFoWrite(pNew);
|
||||
return 0;
|
||||
@ -710,6 +903,93 @@
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1],"middle") == 0)
|
||||
{
|
||||
if(argc > 2) /* set value */
|
||||
{
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
iRet = Tcl_GetInt(pSics->pTcl,argv[2],&iVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: cannot convert --> %s <-- to number ",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(iVal < 0) iVal = 0;
|
||||
self->iMiddle = iVal;
|
||||
setFMconfiguration(self->iUpper,self->iMiddle,self->iLower);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else /* read the value */
|
||||
{
|
||||
sprintf(pBueffel,"storefocus.middle = %d",self->iMiddle);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1],"lower") == 0)
|
||||
{
|
||||
if(argc > 2) /* set value */
|
||||
{
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
iRet = Tcl_GetInt(pSics->pTcl,argv[2],&iVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: cannot convert --> %s <-- to number ",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(iVal < 0) iVal = 0;
|
||||
self->iLower = iVal;
|
||||
setFMconfiguration(self->iUpper,self->iMiddle,self->iLower);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else /* read the value */
|
||||
{
|
||||
sprintf(pBueffel,"storefocus.lower = %d",self->iLower);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1],"upper") == 0)
|
||||
{
|
||||
if(argc > 2) /* set value */
|
||||
{
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
iRet = Tcl_GetInt(pSics->pTcl,argv[2],&iVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: cannot convert --> %s <-- to number ",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(iVal < 0) iVal = 0;
|
||||
self->iUpper = iVal;
|
||||
setFMconfiguration(self->iUpper,self->iMiddle,self->iLower);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else /* read the value */
|
||||
{
|
||||
sprintf(pBueffel,"storefocus.upper = %d",self->iUpper);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
SCWrite(pCon,"ERROR: subcommand to storefocus not recognized",eError);
|
||||
return 0;
|
||||
}
|
||||
|
@ -52,8 +52,8 @@
|
||||
#include "histsim.h"
|
||||
|
||||
|
||||
/*
|
||||
#define TESTVAL 128
|
||||
/*
|
||||
|
||||
define TESTVAL to set the simulated histogram to a fixed value for
|
||||
testing
|
||||
|
15
lin2ang.c
15
lin2ang.c
@ -49,12 +49,26 @@
|
||||
|
||||
self = (pLin2Ang)pData;
|
||||
assert(self);
|
||||
|
||||
if(iID == DRIVEID)
|
||||
{
|
||||
return self->pDriv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int Lin2AngSave(void *pData, char *name, FILE *fd)
|
||||
{
|
||||
pLin2Ang self = NULL;
|
||||
|
||||
self = (pLin2Ang)pData;
|
||||
if(!self)
|
||||
return;
|
||||
|
||||
fprintf(fd,"%s.length %f\n",name, self->length);
|
||||
return 1;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int L2AHalt(void *pData)
|
||||
{
|
||||
@ -181,6 +195,7 @@
|
||||
|
||||
/* initialize the data structure */
|
||||
pNew->pDes->GetInterface = Lin2AngGetInterface;
|
||||
pNew->pDes->SaveStatus = Lin2AngSave;
|
||||
pNew->pDriv->Halt = L2AHalt;
|
||||
pNew->pDriv->CheckLimits = L2ALimits;
|
||||
pNew->pDriv->SetValue = L2ASetValue;
|
||||
|
@ -1,3 +1,10 @@
|
||||
a5l.length 80.000000
|
||||
flightpathlength 0.000000
|
||||
flightpathlength setAccess 1
|
||||
flightpath 0.000000
|
||||
flightpath setAccess 1
|
||||
delay 2500.000000
|
||||
delay setAccess 1
|
||||
hm CountMode timer
|
||||
hm preset 100.000000
|
||||
hm genbin 120.000000 35.000000 512
|
||||
@ -122,7 +129,7 @@ phone setAccess 2
|
||||
adress UNKNOWN
|
||||
adress setAccess 2
|
||||
# Counter counter
|
||||
counter SetPreset 2.000000
|
||||
counter SetPreset 1.000000
|
||||
counter SetMode Timer
|
||||
# Motor som
|
||||
som SoftZero 0.000000
|
||||
|
14
test.tcl
14
test.tcl
@ -313,8 +313,8 @@ MakeHM hm SIM
|
||||
hm configure HistMode TOF
|
||||
hm configure OverFlowMode Ceil
|
||||
hm configure Rank 1
|
||||
hm configure dim0 150
|
||||
hm configure Length 150
|
||||
hm configure dim0 383
|
||||
hm configure Length 383
|
||||
hm configure BinWidth 4
|
||||
hm preset 100.
|
||||
hm CountMode Timer
|
||||
@ -322,8 +322,16 @@ hm configure Counter counter
|
||||
hm configure init 0
|
||||
hm genbin 120. 35. 512
|
||||
hm init
|
||||
|
||||
VarMake delay Float Mugger
|
||||
delay 158.8
|
||||
VarMake flightpath Float Mugger
|
||||
delay 2000
|
||||
VarMake flightpathlength Float Mugger
|
||||
delay 2500
|
||||
|
||||
MakeFocusAverager average hm
|
||||
FocusInstall hm focus.dic
|
||||
FocusInstall hm focus.dic $shome/sics/focusmerge.dat
|
||||
|
||||
#MakeChopper choco docho lnsp20 4000 8
|
||||
MakeChopper choco sim
|
||||
|
Reference in New Issue
Block a user