Changed HM-configuration at FOCUS
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
|
||||
#line 461 "histogram.w"
|
||||
#line 462 "histogram.w"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
H I S T D R I V
|
||||
@ -68,7 +68,7 @@
|
||||
void *pPriv;
|
||||
} HistDriver;
|
||||
|
||||
#line 473 "histogram.w"
|
||||
#line 474 "histogram.w"
|
||||
|
||||
|
||||
#line 228 "histogram.w"
|
||||
@ -78,7 +78,7 @@
|
||||
int HistDriverConfig(pHistDriver self, pStringDict pOpt,
|
||||
SConnection *pCon);
|
||||
|
||||
#line 474 "histogram.w"
|
||||
#line 475 "histogram.w"
|
||||
|
||||
|
||||
#endif
|
||||
|
11
HistMem.h
11
HistMem.h
@ -1,5 +1,5 @@
|
||||
|
||||
#line 434 "histogram.w"
|
||||
#line 435 "histogram.w"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
H I S T M E M
|
||||
@ -42,7 +42,7 @@
|
||||
eReflect
|
||||
} OverFlowMode;
|
||||
|
||||
#line 454 "histogram.w"
|
||||
#line 455 "histogram.w"
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -70,9 +70,10 @@
|
||||
float GetHistCountTime(pHistMem self,SConnection *pCon);
|
||||
int HistDoCount(pHistMem self, SConnection *pCon);
|
||||
int HistBlockCount(pHistMem self, SConnection *pCon);
|
||||
void HistDirty(pHistMem self);
|
||||
|
||||
|
||||
#line 360 "histogram.w"
|
||||
#line 361 "histogram.w"
|
||||
|
||||
int SetHistogram(pHistMem self, SConnection *pCon,
|
||||
int i,int iStart, int iEnd, HistInt *lData);
|
||||
@ -84,7 +85,7 @@
|
||||
HistInt *lData, int iDataLen);
|
||||
int PresetHistogram(pHistMem self, SConnection *pCon, HistInt lVal);
|
||||
|
||||
#line 403 "histogram.w"
|
||||
#line 404 "histogram.w"
|
||||
|
||||
int MakeHistMemory(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
@ -93,7 +94,7 @@
|
||||
int argc, char *argv[]);
|
||||
|
||||
|
||||
#line 456 "histogram.w"
|
||||
#line 457 "histogram.w"
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#line 479 "histogram.w"
|
||||
#line 480 "histogram.w"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
H I S T M E M -- Internal
|
||||
@ -24,7 +24,7 @@
|
||||
pStringDict pOption;
|
||||
} HistMem;
|
||||
|
||||
#line 489 "histogram.w"
|
||||
#line 490 "histogram.w"
|
||||
|
||||
|
||||
#endif
|
||||
|
242
faverage.c
242
faverage.c
@ -22,6 +22,7 @@
|
||||
#include <time.h>
|
||||
#include "fortify.h"
|
||||
#include "sics.h"
|
||||
#include "sicsvar.h"
|
||||
#include "counter.h"
|
||||
#include "HistMem.h"
|
||||
#include "fomerge.h"
|
||||
@ -33,10 +34,16 @@
|
||||
/*-------------------------------------------------------------------------*/
|
||||
typedef struct __FocusAverager {
|
||||
pObjectDescriptor pDes;
|
||||
pHistMem pHist;
|
||||
pHistMem pHistogram1;
|
||||
pHistMem pHistogram2;
|
||||
pHistMem pHistogram3;
|
||||
} FocusAverager, *pFocusAverager;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
HistInt *CheckBank(pFocusAverager self, SConnection *pCon,
|
||||
int iLength, int iBank);
|
||||
|
||||
static void KillFA(void *pData)
|
||||
{
|
||||
pFocusAverager self = NULL;
|
||||
@ -61,7 +68,11 @@
|
||||
char pBueffel[256];
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
time_t tStart, tEnd;
|
||||
int iBank = MIDDLE;
|
||||
int iBank = MIDDLE;
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
@ -129,7 +140,36 @@
|
||||
#endif
|
||||
|
||||
/* do work! first retrieve time binning data */
|
||||
fTimeBin = GetHistTimeBin(self->pHist,&iLength);
|
||||
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(var2)
|
||||
{
|
||||
fTimeBin = GetHistTimeBin(self->pHistogram2,&iLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(var1)
|
||||
{
|
||||
fTimeBin = GetHistTimeBin(self->pHistogram1,&iLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
fTimeBin = GetHistTimeBin(self->pHistogram3,&iLength);
|
||||
}
|
||||
}
|
||||
assert(fTimeBin);
|
||||
if(iLength <= 0)
|
||||
{
|
||||
@ -157,23 +197,19 @@
|
||||
printf("Getting histogram....\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
hiData = GetHistogramPointer(self->pHist,pCon);
|
||||
if(hiData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory data",eError);
|
||||
free(iData);
|
||||
return 0;
|
||||
}
|
||||
setFMDataPointer(hiData, iLength);
|
||||
hiData = getFMBankPointer(iBank);
|
||||
|
||||
hiData = CheckBank(self,pCon,iLength,iBank);
|
||||
|
||||
#ifdef DEB
|
||||
tEnd = time(NULL);
|
||||
printf("Histogram received in %d seconds\n", tStart - tEnd);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if(hiData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: BAD Configuration",eError);
|
||||
free(iData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -228,6 +264,10 @@
|
||||
const float *timeBin;
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
int iBank = MIDDLE;
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
@ -250,23 +290,38 @@
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
timeBin = GetHistTimeBin(self->pHist,&iLength);
|
||||
assert(timeBin);
|
||||
hiData = GetHistogramPointer(self->pHist,pCon);
|
||||
if(hiData == NULL)
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory data",eError);
|
||||
return 0;
|
||||
}
|
||||
setFMDataPointer(hiData, iLength);
|
||||
hiData = getFMBankPointer(iBank);
|
||||
if(hiData == NULL)
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(var2)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: BAD Configuration",eError);
|
||||
return 0;
|
||||
timeBin = GetHistTimeBin(self->pHistogram2,&iLength);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(var1)
|
||||
{
|
||||
timeBin = GetHistTimeBin(self->pHistogram1,&iLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeBin = GetHistTimeBin(self->pHistogram3,&iLength);
|
||||
}
|
||||
}
|
||||
assert(timeBin);
|
||||
hiData = CheckBank(self, pCon, iLength, iBank);
|
||||
|
||||
/* get histogram length */
|
||||
iLength = getFMdim(iBank);
|
||||
noTimebin = getFMdim(TIMEBIN);
|
||||
@ -305,7 +360,11 @@
|
||||
pDummy pDum = NULL;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
|
||||
@ -334,9 +393,9 @@
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(pDum->pDescriptor->name,"HistMem") != 0)
|
||||
if(strcmp(pDum->pDescriptor->name,"HMcontrol") != 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s is NO histogram memory object!", argv[2]);
|
||||
sprintf(pBueffel,"ERROR: %s is NO histogram control object!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
@ -356,8 +415,45 @@
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeFA",eError);
|
||||
return 0;
|
||||
}
|
||||
pNew->pHist = (pHistMem)pDum;
|
||||
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(mbank==1)
|
||||
{
|
||||
pCom = FindCommand(pSics,"hm2");
|
||||
pDum = (pDummy)pCom->pData;
|
||||
pNew->pHistogram2 = (pHistMem)pDum;
|
||||
}
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(lbank==1)
|
||||
{
|
||||
pCom = FindCommand(pSics,"hm1");
|
||||
pDum = (pDummy)pCom->pData;
|
||||
pNew->pHistogram1 = (pHistMem)pDum;
|
||||
}
|
||||
var3 = FindVariable(pServ->pSics,"ubank");
|
||||
if(var3)
|
||||
{
|
||||
VarGetInt(var3,&ubank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: ubank value not found!",eError);
|
||||
}
|
||||
if(ubank==1)
|
||||
{
|
||||
pCom = FindCommand(pSics,"hm3");
|
||||
pDum = (pDummy)pCom->pData;
|
||||
pNew->pHistogram3 = (pHistMem)pDum;
|
||||
}
|
||||
iRet = AddCommand(pSics,argv[1],FocusAverageDo, KillFA, pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
@ -375,3 +471,87 @@
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
HistInt *CheckBank(pFocusAverager self, SConnection *pCon,
|
||||
int iLength, int iBank)
|
||||
{
|
||||
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
HistInt *lData = NULL;
|
||||
HistInt *mData = NULL;
|
||||
HistInt *uData = NULL;
|
||||
HistInt *mergData = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
if (iBank==2)
|
||||
{
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(mbank==1)
|
||||
{
|
||||
mData = GetHistogramPointer(self->pHistogram2,pCon);
|
||||
if(mData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
setFMDataPointer(mData, iLength,1);
|
||||
mData = getFMBankPointer(1);
|
||||
return mData;
|
||||
}
|
||||
}
|
||||
if (iBank==3)
|
||||
{
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(lbank==1)
|
||||
{
|
||||
lData = GetHistogramPointer(self->pHistogram1,pCon);
|
||||
if(lData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
setFMDataPointer(lData, iLength, 3);
|
||||
lData = getFMBankPointer(3);
|
||||
return lData;
|
||||
}
|
||||
}
|
||||
if (iBank==1)
|
||||
{
|
||||
var3 = FindVariable(pServ->pSics,"ubank");
|
||||
if(var3)
|
||||
{
|
||||
VarGetInt(var3,&ubank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: ubank value not found!",eError);
|
||||
}
|
||||
if(ubank==1)
|
||||
{
|
||||
uData = GetHistogramPointer(self->pHistogram3,pCon);
|
||||
if(uData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
setFMDataPointer(uData, iLength, 2);
|
||||
uData = getFMBankPointer(2);
|
||||
return uData;
|
||||
}
|
||||
}
|
||||
if (iBank==4)
|
||||
{
|
||||
setFMDataPointer(mergData, iLength,4);
|
||||
mergData = getFMBankPointer(4);
|
||||
return mergData;
|
||||
}
|
||||
}
|
||||
|
@ -18,3 +18,4 @@
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -75,6 +75,8 @@ cnmon2=/entry1,NXentry/FOCUS,NXinstrument/counter,NXmonitor/SDS beam_monitor \
|
||||
-type DFNT_INT32 -attr {units,counts}
|
||||
cnmon3=/entry1,NXentry/FOCUS,NXinstrument/counter,NXmonitor/SDS proton_beam_monitor \
|
||||
-type DFNT_INT32 -attr {units,counts}
|
||||
tofmon=/entry1,NXentry/FOCUS,NXinstrument/SDS \
|
||||
tof_monitor -type DFNT_INT32 -rank 1 -dim {$(timebin)}
|
||||
#-------------- detector bank
|
||||
dname=/entry1,NXentry/FOCUS,NXinstrument/$(bank),NXdetector/SDS type \
|
||||
-type DFNT_CHAR -rank 1 -dim {132}
|
||||
|
414
focusmerge.dat
414
focusmerge.dat
@ -1,5 +1,5 @@
|
||||
#---- Merge Table
|
||||
383
|
||||
375
|
||||
001 10.050 000 001 000
|
||||
002 10.850 000 002 000
|
||||
003 11.660 000 003 000
|
||||
@ -179,212 +179,204 @@
|
||||
177 67.825 054 000 000
|
||||
178 68.610 000 074 000
|
||||
179 68.650 055 000 000
|
||||
180 68.650 000 000 051
|
||||
181 69.410 000 075 000
|
||||
182 69.850 056 000 000
|
||||
183 70.350 000 000 052
|
||||
184 70.675 057 000 000
|
||||
185 71.175 000 000 053
|
||||
186 71.500 058 000 000
|
||||
187 72.000 000 000 054
|
||||
188 72.325 059 000 000
|
||||
189 72.825 000 000 055
|
||||
190 72.900 000 076 000
|
||||
191 73.650 000 000 056
|
||||
192 73.700 000 077 000
|
||||
193 74.510 000 078 000
|
||||
194 74.850 000 000 057
|
||||
195 75.310 000 079 000
|
||||
196 75.675 000 000 058
|
||||
197 76.110 000 080 000
|
||||
198 76.500 060 000 000
|
||||
199 76.500 000 000 059
|
||||
200 76.910 000 081 000
|
||||
201 77.325 061 000 000
|
||||
202 77.325 000 000 060
|
||||
203 77.710 000 082 000
|
||||
204 78.150 062 000 000
|
||||
205 78.150 000 000 061
|
||||
206 78.520 000 083 000
|
||||
207 79.320 000 084 000
|
||||
208 79.350 063 000 000
|
||||
209 79.350 000 000 062
|
||||
210 80.120 000 085 000
|
||||
211 80.175 064 000 000
|
||||
212 80.175 000 000 063
|
||||
213 80.920 000 086 000
|
||||
214 81.000 065 000 000
|
||||
215 81.000 000 000 064
|
||||
216 81.720 000 087 000
|
||||
217 81.825 066 000 000
|
||||
218 81.825 000 000 065
|
||||
219 82.530 000 088 000
|
||||
220 82.650 067 000 000
|
||||
221 82.650 000 000 066
|
||||
222 83.330 000 089 000
|
||||
223 83.850 068 000 000
|
||||
224 83.850 000 000 067
|
||||
225 84.130 000 090 000
|
||||
226 84.675 069 000 000
|
||||
227 84.675 000 000 068
|
||||
228 84.930 000 091 000
|
||||
229 85.500 070 000 000
|
||||
230 85.500 000 000 069
|
||||
231 85.740 000 092 000
|
||||
232 86.325 071 000 000
|
||||
233 86.325 000 000 070
|
||||
234 86.540 000 093 000
|
||||
235 87.150 072 000 000
|
||||
236 87.150 000 000 071
|
||||
237 87.340 000 094 000
|
||||
238 88.140 000 095 000
|
||||
239 88.350 073 000 000
|
||||
240 88.350 000 000 072
|
||||
241 88.940 000 096 000
|
||||
242 89.175 074 000 000
|
||||
243 89.175 000 000 073
|
||||
244 89.750 000 097 000
|
||||
245 90.000 075 000 000
|
||||
246 90.000 000 000 074
|
||||
247 90.550 000 098 000
|
||||
248 90.825 076 000 000
|
||||
249 90.825 000 000 075
|
||||
250 91.350 000 099 000
|
||||
251 91.650 077 000 000
|
||||
252 91.650 000 000 076
|
||||
253 92.150 000 100 000
|
||||
254 92.850 078 000 000
|
||||
255 92.850 000 000 077
|
||||
256 92.960 000 101 000
|
||||
257 93.675 079 000 000
|
||||
258 93.675 000 000 078
|
||||
259 93.760 000 102 000
|
||||
260 94.500 080 000 000
|
||||
261 94.500 000 000 079
|
||||
262 94.560 000 103 000
|
||||
263 95.325 081 000 000
|
||||
264 95.325 000 000 080
|
||||
265 95.360 000 104 000
|
||||
266 96.150 082 000 000
|
||||
267 96.150 000 000 081
|
||||
268 96.160 000 105 000
|
||||
269 96.970 000 106 000
|
||||
270 97.350 083 000 000
|
||||
271 97.350 000 000 082
|
||||
272 97.770 000 107 000
|
||||
273 98.175 084 000 000
|
||||
274 98.175 000 000 083
|
||||
275 98.570 000 108 000
|
||||
276 99.000 085 000 000
|
||||
277 99.000 000 000 084
|
||||
278 99.370 000 109 000
|
||||
279 99.825 086 000 000
|
||||
280 99.825 000 000 085
|
||||
281 100.180 000 110 000
|
||||
282 100.650 087 000 000
|
||||
283 100.650 000 000 086
|
||||
284 100.980 000 111 000
|
||||
285 101.780 000 112 000
|
||||
286 101.850 088 000 000
|
||||
287 101.850 000 000 087
|
||||
288 102.580 000 113 000
|
||||
289 102.675 089 000 000
|
||||
290 102.675 000 000 088
|
||||
291 103.380 000 114 000
|
||||
292 103.500 090 000 000
|
||||
293 103.500 000 000 089
|
||||
294 104.190 000 115 000
|
||||
295 104.325 091 000 000
|
||||
296 104.325 000 000 090
|
||||
297 104.990 000 116 000
|
||||
298 105.150 092 000 000
|
||||
299 105.150 000 000 091
|
||||
300 105.790 000 117 000
|
||||
301 106.350 093 000 000
|
||||
302 106.350 000 000 092
|
||||
303 106.590 000 118 000
|
||||
304 107.175 094 000 000
|
||||
305 107.175 000 000 093
|
||||
306 107.390 000 119 000
|
||||
307 108.000 095 000 000
|
||||
308 108.000 000 000 094
|
||||
309 108.200 000 120 000
|
||||
310 108.825 096 000 000
|
||||
311 108.825 000 000 095
|
||||
312 109.000 000 121 000
|
||||
313 109.650 097 000 000
|
||||
314 109.650 000 000 096
|
||||
315 109.800 000 122 000
|
||||
316 110.600 000 123 000
|
||||
317 110.850 098 000 000
|
||||
318 110.850 000 000 097
|
||||
319 111.410 000 124 000
|
||||
320 111.675 099 000 000
|
||||
321 111.675 000 000 098
|
||||
322 112.210 000 125 000
|
||||
323 112.500 100 000 000
|
||||
324 112.500 000 000 099
|
||||
325 113.010 000 126 000
|
||||
326 113.325 101 000 000
|
||||
327 113.325 000 000 100
|
||||
328 113.810 000 127 000
|
||||
329 114.150 102 000 000
|
||||
330 114.150 000 000 101
|
||||
331 114.610 000 128 000
|
||||
332 115.350 103 000 000
|
||||
333 115.350 000 000 102
|
||||
334 115.420 000 129 000
|
||||
335 116.175 104 000 000
|
||||
336 116.175 000 000 103
|
||||
337 116.220 000 130 000
|
||||
338 117.000 105 000 000
|
||||
339 117.000 000 000 104
|
||||
340 117.020 000 131 000
|
||||
341 117.820 000 132 000
|
||||
342 117.825 106 000 000
|
||||
343 117.825 000 000 105
|
||||
344 118.630 000 133 000
|
||||
345 118.650 107 000 000
|
||||
346 118.650 000 000 106
|
||||
347 119.430 000 134 000
|
||||
348 119.850 108 000 000
|
||||
349 119.850 000 000 107
|
||||
350 120.230 000 135 000
|
||||
351 120.675 109 000 000
|
||||
352 120.675 000 000 108
|
||||
353 121.030 000 136 000
|
||||
354 121.500 110 000 000
|
||||
355 121.500 000 000 109
|
||||
356 121.830 000 137 000
|
||||
357 122.325 111 000 000
|
||||
358 122.325 000 000 110
|
||||
359 122.640 000 138 000
|
||||
360 123.150 112 000 000
|
||||
361 123.150 000 000 111
|
||||
362 123.440 000 139 000
|
||||
363 124.240 000 140 000
|
||||
364 124.350 113 000 000
|
||||
365 124.350 000 000 112
|
||||
366 125.040 000 141 000
|
||||
367 125.175 114 000 000
|
||||
368 125.175 000 000 113
|
||||
369 125.850 000 142 000
|
||||
370 126.000 115 000 000
|
||||
371 126.000 000 000 114
|
||||
372 126.650 000 143 000
|
||||
373 126.825 116 000 000
|
||||
374 126.825 000 000 115
|
||||
375 127.450 000 144 000
|
||||
376 127.650 117 000 000
|
||||
377 127.650 000 000 116
|
||||
378 128.250 000 145 000
|
||||
379 129.050 000 146 000
|
||||
380 129.860 000 147 000
|
||||
381 130.660 000 148 000
|
||||
382 131.460 000 149 000
|
||||
383 132.260 000 150 000
|
||||
180 69.410 000 075 000
|
||||
181 70.350 000 000 051
|
||||
182 71.175 000 000 052
|
||||
183 72.000 000 000 053
|
||||
184 72.825 000 000 054
|
||||
185 72.900 000 076 000
|
||||
186 73.650 000 000 055
|
||||
187 73.700 000 077 000
|
||||
188 74.510 000 078 000
|
||||
189 74.850 000 000 056
|
||||
190 75.310 000 079 000
|
||||
191 75.675 000 000 057
|
||||
192 76.110 000 080 000
|
||||
193 76.500 000 000 058
|
||||
194 76.910 000 081 000
|
||||
195 77.325 000 000 059
|
||||
196 77.710 000 082 000
|
||||
197 78.150 000 000 060
|
||||
198 78.520 000 083 000
|
||||
199 79.320 000 084 000
|
||||
200 79.350 056 000 000
|
||||
201 79.350 000 000 061
|
||||
202 80.120 000 085 000
|
||||
203 80.175 057 000 000
|
||||
204 80.175 000 000 062
|
||||
205 80.920 000 086 000
|
||||
206 81.000 058 000 000
|
||||
207 81.000 000 000 063
|
||||
208 81.720 000 087 000
|
||||
209 81.825 059 000 000
|
||||
210 81.825 000 000 064
|
||||
211 82.530 000 088 000
|
||||
212 82.650 060 000 000
|
||||
213 82.650 000 000 065
|
||||
214 83.330 000 089 000
|
||||
215 83.850 061 000 000
|
||||
216 83.850 000 000 066
|
||||
217 84.130 000 090 000
|
||||
218 84.675 062 000 000
|
||||
219 84.675 000 000 067
|
||||
220 84.930 000 091 000
|
||||
221 85.500 063 000 000
|
||||
222 85.500 000 000 068
|
||||
223 85.740 000 092 000
|
||||
224 86.325 064 000 000
|
||||
225 86.325 000 000 069
|
||||
226 86.540 000 093 000
|
||||
227 87.150 065 000 000
|
||||
228 87.150 000 000 070
|
||||
229 87.340 000 094 000
|
||||
230 88.140 000 095 000
|
||||
231 88.350 066 000 000
|
||||
232 88.350 000 000 071
|
||||
233 88.940 000 096 000
|
||||
234 89.175 067 000 000
|
||||
235 89.175 000 000 072
|
||||
236 89.750 000 097 000
|
||||
237 90.000 068 000 000
|
||||
238 90.000 000 000 073
|
||||
239 90.550 000 098 000
|
||||
240 90.825 069 000 000
|
||||
241 90.825 000 000 074
|
||||
242 91.350 000 099 000
|
||||
243 91.650 070 000 000
|
||||
244 91.650 000 000 075
|
||||
245 92.150 000 100 000
|
||||
246 92.850 071 000 000
|
||||
247 92.850 000 000 076
|
||||
248 92.960 000 101 000
|
||||
249 93.675 072 000 000
|
||||
250 93.675 000 000 077
|
||||
251 93.760 000 102 000
|
||||
252 94.500 073 000 000
|
||||
253 94.500 000 000 078
|
||||
254 94.560 000 103 000
|
||||
255 95.325 074 000 000
|
||||
256 95.325 000 000 079
|
||||
257 95.360 000 104 000
|
||||
258 96.150 075 000 000
|
||||
259 96.150 000 000 080
|
||||
260 96.160 000 105 000
|
||||
261 96.970 000 106 000
|
||||
262 97.350 076 000 000
|
||||
263 97.350 000 000 081
|
||||
264 97.770 000 107 000
|
||||
265 98.175 077 000 000
|
||||
266 98.175 000 000 082
|
||||
267 98.570 000 108 000
|
||||
268 99.000 078 000 000
|
||||
269 99.000 000 000 083
|
||||
270 99.370 000 109 000
|
||||
271 99.825 079 000 000
|
||||
272 99.825 000 000 084
|
||||
273 100.180 000 110 000
|
||||
274 100.650 080 000 000
|
||||
275 100.650 000 000 085
|
||||
276 100.980 000 111 000
|
||||
277 101.780 000 112 000
|
||||
278 101.850 081 000 000
|
||||
279 101.850 000 000 086
|
||||
280 102.580 000 113 000
|
||||
281 102.675 082 000 000
|
||||
282 102.675 000 000 087
|
||||
283 103.380 000 114 000
|
||||
284 103.500 083 000 000
|
||||
285 103.500 000 000 088
|
||||
286 104.190 000 115 000
|
||||
287 104.325 084 000 000
|
||||
288 104.325 000 000 089
|
||||
289 104.990 000 116 000
|
||||
290 105.150 085 000 000
|
||||
291 105.150 000 000 090
|
||||
292 105.790 000 117 000
|
||||
293 106.350 086 000 000
|
||||
294 106.350 000 000 091
|
||||
295 106.590 000 118 000
|
||||
296 107.175 087 000 000
|
||||
297 107.175 000 000 092
|
||||
298 107.390 000 119 000
|
||||
299 108.000 088 000 000
|
||||
300 108.000 000 000 093
|
||||
301 108.200 000 120 000
|
||||
302 108.825 089 000 000
|
||||
303 108.825 000 000 094
|
||||
304 109.000 000 121 000
|
||||
305 109.650 090 000 000
|
||||
306 109.650 000 000 095
|
||||
307 109.800 000 122 000
|
||||
308 110.600 000 123 000
|
||||
309 110.850 091 000 000
|
||||
310 110.850 000 000 096
|
||||
311 111.410 000 124 000
|
||||
312 111.675 092 000 000
|
||||
313 111.675 000 000 097
|
||||
314 112.210 000 125 000
|
||||
315 112.500 093 000 000
|
||||
316 112.500 000 000 098
|
||||
317 113.010 000 126 000
|
||||
318 113.325 094 000 000
|
||||
319 113.325 000 000 099
|
||||
320 113.810 000 127 000
|
||||
321 114.150 095 000 000
|
||||
322 114.150 000 000 100
|
||||
323 114.610 000 128 000
|
||||
324 115.350 096 000 000
|
||||
325 115.350 000 000 101
|
||||
326 115.420 000 129 000
|
||||
327 116.175 097 000 000
|
||||
328 116.175 000 000 102
|
||||
329 116.220 000 130 000
|
||||
330 117.000 098 000 000
|
||||
331 117.000 000 000 103
|
||||
332 117.020 000 131 000
|
||||
333 117.820 000 132 000
|
||||
334 117.825 099 000 000
|
||||
335 117.825 000 000 104
|
||||
336 118.630 000 133 000
|
||||
337 118.650 100 000 000
|
||||
338 118.650 000 000 105
|
||||
339 119.430 000 134 000
|
||||
340 119.850 101 000 000
|
||||
341 119.850 000 000 106
|
||||
342 120.230 000 135 000
|
||||
343 120.675 102 000 000
|
||||
344 120.675 000 000 107
|
||||
345 121.030 000 136 000
|
||||
346 121.500 103 000 000
|
||||
347 121.500 000 000 108
|
||||
348 121.830 000 137 000
|
||||
349 122.325 104 000 000
|
||||
350 122.325 000 000 109
|
||||
351 122.640 000 138 000
|
||||
352 123.150 105 000 000
|
||||
353 123.150 000 000 110
|
||||
354 123.440 000 139 000
|
||||
355 124.240 000 140 000
|
||||
356 124.350 106 000 000
|
||||
357 124.350 000 000 111
|
||||
358 125.040 000 141 000
|
||||
359 125.175 107 000 000
|
||||
360 125.175 000 000 112
|
||||
361 125.850 000 142 000
|
||||
362 126.000 108 000 000
|
||||
363 126.000 000 000 113
|
||||
364 126.650 000 143 000
|
||||
365 126.825 109 000 000
|
||||
366 126.825 000 000 114
|
||||
367 127.450 000 144 000
|
||||
368 127.650 110 000 000
|
||||
369 127.650 000 000 115
|
||||
370 128.250 000 145 000
|
||||
371 129.050 000 146 000
|
||||
372 129.860 000 147 000
|
||||
373 130.660 000 148 000
|
||||
374 131.460 000 149 000
|
||||
375 132.260 000 150 000
|
||||
#----- upper bank two theta
|
||||
117
|
||||
110
|
||||
18.35
|
||||
19.175
|
||||
20
|
||||
@ -440,13 +432,6 @@
|
||||
67
|
||||
67.825
|
||||
68.65
|
||||
69.85
|
||||
70.675
|
||||
71.5
|
||||
72.325
|
||||
76.5
|
||||
77.325
|
||||
78.15
|
||||
79.35
|
||||
80.175
|
||||
81
|
||||
@ -655,7 +640,7 @@
|
||||
131.46
|
||||
132.26
|
||||
#------- lower bank two theta
|
||||
116
|
||||
115
|
||||
18.35
|
||||
19.175
|
||||
20
|
||||
@ -706,7 +691,6 @@
|
||||
62.5
|
||||
63.325
|
||||
64.15
|
||||
68.65
|
||||
70.35
|
||||
71.175
|
||||
72
|
||||
|
68
fomerge.c
68
fomerge.c
@ -22,10 +22,13 @@
|
||||
#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;
|
||||
@ -100,7 +103,7 @@ int initializeFM(char *mergefile)
|
||||
iTest = sscanf(pBuffer,"%d",&nUpper);
|
||||
if((iTest != 1) || (nUpper <= 0) )
|
||||
{
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge data file");
|
||||
fprintf(stdout,"ERROR: Invalid or corrupt merge data file");
|
||||
return 0;
|
||||
}
|
||||
upperTheta = (float *)malloc(nUpper*sizeof(float));
|
||||
@ -161,7 +164,7 @@ int initializeFM(char *mergefile)
|
||||
timeBin = 0;
|
||||
iMerged = 0;
|
||||
medium =1;
|
||||
upper = lower = 0;
|
||||
upper = lower = 1;
|
||||
|
||||
fclose(fd);
|
||||
return 1;
|
||||
@ -171,7 +174,7 @@ int initializeFM(char *mergefile)
|
||||
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)
|
||||
int setFMDataPointer(HistInt *lData, int mytimeBins, int bank)
|
||||
{
|
||||
HistInt *dataPtr;
|
||||
|
||||
@ -180,37 +183,38 @@ int setFMDataPointer(HistInt *lData, int mytimeBins)
|
||||
|
||||
/* the first set is the medium bank */
|
||||
masterData = dataPtr = lData;
|
||||
if(medium)
|
||||
{
|
||||
mediumData = masterData;
|
||||
if (bank==1){
|
||||
if(medium)
|
||||
{
|
||||
mediumData = masterData;
|
||||
}
|
||||
else
|
||||
{
|
||||
mediumData = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mediumData = NULL;
|
||||
}
|
||||
|
||||
/* the next set is the upper bank */
|
||||
if(upper)
|
||||
{
|
||||
upperData = dataPtr + mytimeBins*nMedium;
|
||||
dataPtr = upperData;
|
||||
}
|
||||
else
|
||||
{
|
||||
upperData = NULL;
|
||||
}
|
||||
|
||||
if (bank==2){
|
||||
if(upper)
|
||||
{
|
||||
upperData = masterData;
|
||||
}
|
||||
else
|
||||
{
|
||||
upperData = NULL;
|
||||
}
|
||||
}
|
||||
/* the last is the lower bank */
|
||||
if(lower)
|
||||
{
|
||||
lowerData = dataPtr + mytimeBins*nUpper;
|
||||
dataPtr = lowerData;
|
||||
}
|
||||
else
|
||||
{
|
||||
lowerData = NULL;
|
||||
if (bank==3) {
|
||||
if(lower)
|
||||
{
|
||||
lowerData = masterData;
|
||||
}
|
||||
else
|
||||
{
|
||||
lowerData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* deal with data allocation for merged data */
|
||||
if(mytimeBins != timeBin)
|
||||
{
|
||||
@ -234,6 +238,7 @@ int setFMDataPointer(HistInt *lData, int mytimeBins)
|
||||
iMerged = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void setFMconfiguration(int up, int med, int low)
|
||||
{
|
||||
@ -253,6 +258,7 @@ static void mergeData(void)
|
||||
if(!mergedData)
|
||||
return;
|
||||
|
||||
memset(mergedData,0,nMerged*sizeof(HistInt));
|
||||
for(i = 0; i < nMerged; i++)
|
||||
{
|
||||
startMerge = mergedData + i * timeBin;
|
||||
@ -396,3 +402,5 @@ int getFMdim(int which)
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define MERGED 4
|
||||
#define TIMEBIN 5
|
||||
|
||||
int setFMDataPointer(HistInt *lData, int timeBins);
|
||||
int setFMDataPointer(HistInt *lData, int timeBins, int bank);
|
||||
/*
|
||||
sets the data array with the unmerged data. timeBins is the
|
||||
length of the time binning used. upper, medium and lower are flags
|
||||
@ -65,6 +65,7 @@
|
||||
the length of the time binning if TIMEBIN has been specified.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
228
fowrite.c
228
fowrite.c
@ -30,6 +30,7 @@
|
||||
#include "scan.h"
|
||||
#include "sicsvar.h"
|
||||
#include "fitcenter.h"
|
||||
#include "hmcontrol.h"
|
||||
#include "fomerge.h"
|
||||
|
||||
/* histogram memory names */
|
||||
@ -50,10 +51,12 @@
|
||||
int iInterval;
|
||||
int iEnd;
|
||||
SConnection *pCon;
|
||||
pCounter pCount;
|
||||
char *pFile;
|
||||
char *pDictFile;
|
||||
pFit pFitter;
|
||||
float fElastic;
|
||||
pICallBack pCall;
|
||||
int iUpper, iMiddle, iLower;
|
||||
/* detector availability flags */
|
||||
} FoWrite, *pFoWrite;
|
||||
@ -92,7 +95,9 @@
|
||||
assert(self);
|
||||
self->tUpdate = time(NULL);
|
||||
self->iEnd = 1;
|
||||
/*
|
||||
FoUpdate(self,self->pCon);
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
@ -362,7 +367,7 @@
|
||||
if(self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
iLength = getFMdim(MIDDLE);
|
||||
iLength = 150;
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(MIDDLE);
|
||||
@ -371,7 +376,7 @@
|
||||
if(self->iLower)
|
||||
{
|
||||
NXDupdate(pDict,"bank","lowerbank");
|
||||
iLength = getFMdim(LOWER);
|
||||
iLength = 115;
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(LOWER);
|
||||
@ -380,7 +385,7 @@
|
||||
if(self->iUpper)
|
||||
{
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
iLength = getFMdim(UPPER);
|
||||
iLength = 110;
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(UPPER);
|
||||
@ -389,7 +394,7 @@
|
||||
if(self->iMiddle && ( self->iLower || self->iUpper) )
|
||||
{
|
||||
NXDupdate(pDict,"bank","merged");
|
||||
iLength = getFMdim(MERGED);
|
||||
iLength = 375;
|
||||
sprintf(pBuffer,"%d",iLength);
|
||||
NXDupdate(pDict,"noofdetectors",pBuffer);
|
||||
fArray = getFMBankTheta(MERGED);
|
||||
@ -415,7 +420,7 @@
|
||||
static void FoUpdate(pFoWrite self, SConnection *pCon)
|
||||
{
|
||||
char pBueffel[512];
|
||||
int iInt, iStat, iTime, i, j, iDet, iIndex;
|
||||
int iInt, iStat, iTime, i,ii, j, iDet, iIndex;
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
@ -492,7 +497,7 @@
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var2,&lbank);
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
@ -526,7 +531,13 @@
|
||||
iTime = iInt;
|
||||
sprintf(pBueffel,"%d",iInt);
|
||||
NXDupdate(pDict,"timebin",pBueffel);
|
||||
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if (var1)
|
||||
{
|
||||
lData = GetHistogramPointer(self->pHistogram1,pCon);
|
||||
@ -550,7 +561,7 @@
|
||||
}
|
||||
}
|
||||
var3 = FindVariable(pServ->pSics,"ubank");
|
||||
if(var1)
|
||||
if(var3)
|
||||
{
|
||||
VarGetInt(var3,&ubank);
|
||||
} else {
|
||||
@ -567,39 +578,9 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
setFMDataPointer(lData,iTime);
|
||||
setFMDataPointer(mData,iTime);
|
||||
setFMDataPointer(uData,iTime);
|
||||
if(self->iUpper)
|
||||
{
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
iDet = 117;
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
uData = getFMBankPointer(UPPER);
|
||||
NXDputalias(pFile,pDict,"dcounts",uData);
|
||||
/* 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] += uData[iIndex+j];
|
||||
}
|
||||
}
|
||||
NXDputalias(pFile,pDict,"dsums",iSum);
|
||||
free(iSum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
setFMDataPointer(lData,iTime,3);
|
||||
setFMDataPointer(mData,iTime,1);
|
||||
setFMDataPointer(uData,iTime,2);
|
||||
/* middle bank */
|
||||
if(self->iMiddle)
|
||||
{
|
||||
@ -631,10 +612,40 @@
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
if(self->iUpper)
|
||||
{
|
||||
NXDupdate(pDict,"bank","upperbank");
|
||||
iDet = 110;
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
uData = getFMBankPointer(UPPER);
|
||||
NXDputalias(pFile,pDict,"dcounts",uData);
|
||||
/* 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] += uData[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 = 116;
|
||||
iDet = 115;
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
lData = getFMBankPointer(LOWER);
|
||||
@ -659,13 +670,30 @@
|
||||
{
|
||||
SCWrite(pCon,"WARNING: out of memory, failed to do sums",
|
||||
eWarning);
|
||||
}
|
||||
}
|
||||
/*
|
||||
now get and write tof_monitor
|
||||
*/
|
||||
|
||||
lData = (HistInt *)malloc(iTime*sizeof(HistInt));
|
||||
if(!lData)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory while writing tof-monitor",
|
||||
eError);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(lData,0,iTime*sizeof(HistInt));
|
||||
GetHistogramDirect(self->pHistogram1,pCon,0,115*iTime,
|
||||
116*iTime, lData, iTime*sizeof(HistInt));
|
||||
NXDputalias(pFile,pDict,"tofmon",lData);
|
||||
}
|
||||
}
|
||||
/* merged data */
|
||||
if( (self->iUpper || self->iLower) && self->iMiddle)
|
||||
{
|
||||
NXDupdate(pDict,"bank","merged");
|
||||
iDet = getFMdim(MERGED);
|
||||
iDet = 375;
|
||||
sprintf(pBueffel,"%d",iDet);
|
||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||
lData = getFMBankPointer(MERGED);
|
||||
@ -696,8 +724,8 @@
|
||||
|
||||
/* calculate elastic peak position */
|
||||
NXDupdate(pDict,"bank","bank1");
|
||||
lData = getFMBankPointer(MIDDLE);
|
||||
if(lData)
|
||||
mData = getFMBankPointer(MIDDLE);
|
||||
if(mData)
|
||||
{
|
||||
lSum = (long *)malloc(iTime *sizeof(long));
|
||||
fAxis = (float *)malloc(iTime *sizeof(float));
|
||||
@ -710,7 +738,7 @@
|
||||
iIndex = i * iTime;
|
||||
for(j = 0; j < iTime; j++)
|
||||
{
|
||||
lSum[j] += lData[iIndex+j];
|
||||
lSum[j] += mData[iIndex+j];
|
||||
}
|
||||
}
|
||||
for(i = 0; i < iTime; i++)
|
||||
@ -858,6 +886,7 @@
|
||||
self->tUpdate = 0;
|
||||
iWrite = 0;
|
||||
iRet = 0;
|
||||
FoUpdate(self,self->pCon);
|
||||
}
|
||||
|
||||
if(iWrite)
|
||||
@ -910,7 +939,8 @@
|
||||
pFoWrite pNew = NULL;
|
||||
pICallBack pCall = NULL;
|
||||
pDummy pDum;
|
||||
|
||||
pHMcontrol pHMC = NULL;
|
||||
|
||||
/* check arguments */
|
||||
if(argc < 4 )
|
||||
{
|
||||
@ -918,22 +948,52 @@
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
/* find things in interpreter */
|
||||
pCom = FindCommand(pSics,HM1);
|
||||
if(pCom)
|
||||
|
||||
/* allocate data structure */
|
||||
pNew = (pFoWrite)malloc(sizeof(FoWrite));
|
||||
if(!pNew)
|
||||
{
|
||||
pNew->pHistogram1 = (pHistMem)pCom->pData;
|
||||
SCWrite(pCon,"ERROR: out of memory in FoInstall",eError);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
memset(pNew,0,sizeof(FoWrite));
|
||||
pNew->pDes = CreateDescriptor("FocusWrite");
|
||||
pNew->pCall = CreateCallBackInterface();
|
||||
pNew->pFitter = CreateFitCenter(NULL);
|
||||
if( (!pNew->pDes) || (!pNew->pFitter) )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in FoInstall",eError);
|
||||
free(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->pDictFile = strdup(argv[2]);
|
||||
pNew->iInterval = 20*60;
|
||||
|
||||
pHMC = FindCommandData(pSics,argv[1],"HMcontrol");
|
||||
if(!pHMC){
|
||||
SCWrite(pCon,"ERROR: no histogram memory control found!",eError);
|
||||
free(pNew);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* find things in interpreter */
|
||||
pCom = FindCommand(pSics,"hm1");
|
||||
if(!pCom)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Histogram memory for lower detector bank NOT found",eError);
|
||||
pNew->pHistogram1 = NULL;
|
||||
}
|
||||
} else
|
||||
{
|
||||
pNew->pHistogram1 = (pHistMem)pCom->pData;
|
||||
pNew->iLower =1;
|
||||
}
|
||||
|
||||
|
||||
pCom = FindCommand(pSics,HM2);
|
||||
if(pCom)
|
||||
{
|
||||
pNew->pHistogram2 = (pHistMem)pCom->pData;
|
||||
pNew->iMiddle =1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -944,73 +1004,29 @@
|
||||
pCom = FindCommand(pSics,HM3);
|
||||
if(pCom)
|
||||
{
|
||||
pNew->pHistogram3 = (pHistMem)pCom->pData;
|
||||
pNew->pHistogram3 = (pHistMem)pCom->pData;
|
||||
pNew->iUpper =1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Histogram memory for upper detector bank NOT found",eError);
|
||||
pNew->pHistogram3 = NULL;
|
||||
}
|
||||
if(!initializeFM(argv[2]))
|
||||
|
||||
if(!initializeFM(argv[3]))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: bad merge data file",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate data structure */
|
||||
pNew = (pFoWrite)malloc(sizeof(FoWrite));
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in FoInstall",eError);
|
||||
return 0;
|
||||
}
|
||||
memset(pNew,0,sizeof(FoWrite));
|
||||
pNew->pDes = CreateDescriptor("FocusWrite");
|
||||
pNew->pFitter = CreateFitCenter(NULL);
|
||||
if( (!pNew->pDes) || (!pNew->pFitter) )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in FoInstall",eError);
|
||||
free(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->pDictFile = strdup(argv[1]);
|
||||
pNew->iInterval = 20*60;
|
||||
pNew->iMiddle =1;
|
||||
|
||||
/* install callbacks */
|
||||
pCom = FindCommand(pSics,HM2);
|
||||
pCom = FindCommand(pSics,"counter");
|
||||
if(pCom)
|
||||
{
|
||||
pDum = (pDummy)pNew->pHistogram2;
|
||||
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pNew->pHistogram2,
|
||||
CALLBACKINTERFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
pCom = FindCommand(pSics,HM1);
|
||||
if(pCom)
|
||||
{
|
||||
pDum = (pDummy)pNew->pHistogram1;
|
||||
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pNew->pHistogram1,
|
||||
CALLBACKINTERFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDum = (pDummy)pNew->pHistogram3;
|
||||
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pNew->pHistogram3, CALLBACKINTERFACE);
|
||||
}
|
||||
pNew->pCount = (pCounter)pCom->pData;
|
||||
}
|
||||
|
||||
if(!pCall)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: no callback interface found at your histogram memories",
|
||||
eError);
|
||||
KillFoWrite(pNew);
|
||||
return 0;
|
||||
}
|
||||
RegisterCallback(pCall,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||
RegisterCallback(pCall,COUNTEND,Countendcallback,pNew,NULL);
|
||||
RegisterCallback(pHMC->pCall,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||
RegisterCallback(pHMC->pCall,COUNTEND,Countendcallback,pNew,NULL);
|
||||
|
||||
/* install command */
|
||||
AddCommand(pSics,"StoreFocus",FoAction,KillFoWrite,pNew);
|
||||
|
@ -436,6 +436,7 @@ $\langle$Protos {\footnotesize ?}$\rangle\equiv$
|
||||
\mbox{}\verb@ float GetHistCountTime(pHistMem self,SConnection *pCon);@\\
|
||||
\mbox{}\verb@ int HistDoCount(pHistMem self, SConnection *pCon);@\\
|
||||
\mbox{}\verb@ int HistBlockCount(pHistMem self, SConnection *pCon);@\\
|
||||
\mbox{}\verb@ void HistDirty(pHistMem self); @\\
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\end{list}
|
||||
|
@ -340,6 +340,7 @@ controlled by the following functions:
|
||||
float GetHistCountTime(pHistMem self,SConnection *pCon);
|
||||
int HistDoCount(pHistMem self, SConnection *pCon);
|
||||
int HistBlockCount(pHistMem self, SConnection *pCon);
|
||||
void HistDirty(pHistMem self);
|
||||
|
||||
@}
|
||||
The first four functions are simple parameter enquiry and manipulation
|
||||
|
23
hmcontrol.c
23
hmcontrol.c
@ -16,6 +16,7 @@
|
||||
#include <tcl.h>
|
||||
#include "fortify.h"
|
||||
#include "hmcontrol.h"
|
||||
#include "HistMem.h"
|
||||
#include "devexec.h"
|
||||
|
||||
|
||||
@ -57,7 +58,7 @@ static int HMCStart(void *pData, SConnection *pCon)
|
||||
|
||||
self = (pHMcontrol)pData;
|
||||
assert(self);
|
||||
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++)
|
||||
{
|
||||
status = self->slaves[i]->StartCount(self->slaveData[i],pCon);
|
||||
@ -72,7 +73,7 @@ static int HMCStart(void *pData, SConnection *pCon)
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int HMCStatus(void *pData, SConnection *pCon)
|
||||
{
|
||||
int status;
|
||||
int status,i;
|
||||
pHMcontrol self = NULL;
|
||||
|
||||
self = (pHMcontrol)pData;
|
||||
@ -85,8 +86,22 @@ static int HMCStatus(void *pData, SConnection *pCon)
|
||||
stop counting on slaves when finished or when an error
|
||||
occurred.
|
||||
*/
|
||||
InvokeCallBack(self->pCall,COUNTEND,pCon);
|
||||
HMCHalt(self);
|
||||
}
|
||||
/*
|
||||
Warning: this assumes that salves 1 - MAXSLAVE are histogram memories.
|
||||
If this assumption does not hold, change this code to check if this
|
||||
is really a histogram memory.
|
||||
*/
|
||||
for(i = 1; i < MAXSLAVE; i++)
|
||||
{
|
||||
if(self->slaves[i] != NULL)
|
||||
{
|
||||
HistDirty((pHistMem)self->slaveData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -214,6 +229,7 @@ int MakeHMControl(SConnection *pCon, SicsInterp *pSics,
|
||||
memset(pNew,0,sizeof(HMcontrol));
|
||||
pNew->pDes = CreateDescriptor("HMcontrol");
|
||||
pNew->pCount = CreateCountableInterface();
|
||||
pNew->pCall = CreateCallBackInterface();
|
||||
if(!pNew->pDes || ! pNew->pCount)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeHMControl",eError);
|
||||
@ -334,7 +350,8 @@ int HMControlAction(SConnection *pCon, SicsInterp *pSics,
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to start counting",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
InvokeCallBack(self->pCall,COUNTSTART,pCon);
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
else
|
||||
|
@ -31,6 +31,7 @@ the maximum number of slaves
|
||||
int nSlaves;
|
||||
float fPreset;
|
||||
CounterMode eMode;
|
||||
pICallBack pCall;
|
||||
} HMcontrol, *pHMcontrol;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user