Added support for three detector banks for FOCUS
This commit is contained in:
45
faverage.c
45
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,7 +128,8 @@
|
||||
char pBueffel[256];
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
time_t tStart, tEnd;
|
||||
|
||||
int iBank = MIDDLE;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
@@ -152,7 +157,19 @@
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user