- Enhanced and debugged histogram memory for AMOR

* added PROJECT both in HM and driver code
  * added single detector support.
- Removed several bugs in the AMOR data bit.
- Updated documentation
This commit is contained in:
cvs
2001-08-17 14:33:05 +00:00
parent a538361516
commit db6c355f44
56 changed files with 4060 additions and 426 deletions

View File

@@ -8,6 +8,13 @@
copyright: see copyright.h
Mark Koennecke, September 1999
As AMOR's histogram memory becomes too big in tof mode to transfer it
for status information the collapse and subsample functionalities have
been moved to the histogram memory. This code had to be modified to
call SINQHMProject directly.
Mark Koennecke, August 2001
--------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
@@ -16,7 +23,12 @@
#include "fortify.h"
#include "sics.h"
#include "counter.h"
#include "stringdict.h"
#include "HistMem.h"
#include "HistMem.i"
#include "HistDriv.i"
#include "hardsup/sinqhm.h"
#include "sinqhmdriv.i"
#include "scan.h"
#include "lld.h"
#include "amorstat.i"
@@ -483,22 +495,18 @@
static int Collapse(pAmorStat self, SConnection *pCon)
{
HistInt *lData = NULL;
int i, i2, i3, iDim[MAXDIM], iIdx, iSum;
int i, i2, i3, iDim[MAXDIM], iIdx, iSum, status, length;
int *iImage = NULL, *iPtr;
pSINQHM pHist;
SinqHMDriv *pTata;
/* get size of our problem */
GetHistDim(self->pHM,iDim,&i3);
assert(i3 == 3);
/* get data */
lData = GetHistogramPointer(self->pHM,pCon);
if(!lData)
{
return 0;
}
/* allocate some data */
iImage = (int *)malloc((2 + iDim[0]*iDim[1])*sizeof(int));
length = 2 + iDim[0]*iDim[1];
iImage = (int *)malloc(length*sizeof(int));
if(iImage == NULL)
{
SCWrite(pCon,"ERROR: failed to allocate memory in Collapse",eError);
@@ -510,20 +518,46 @@
iImage[0] = htonl(iDim[0]);
iImage[1] = htonl(iDim[1]);
/* loop the loop */
for(i = 0; i < iDim[0]; i++)
if(isSINQHMDriv(self->pHM->pDriv))
{
for(i2 = 0; i2 < iDim[1]; i2++)
{
iPtr = lData + i*iDim[1]*iDim[2] +
i2*iDim[2];
iIdx = i*iDim[1] + i2;
for(i3 = 0, iSum = 0; i3 < iDim[2]; i3++)
/*
send a Project request to the histogram memory
*/
pTata = (SinqHMDriv *)self->pHM->pDriv->pPriv;
pHist = (pSINQHM)pTata->pMaster;
/*
The 3 in the following call has to be identical to
PROJECT__COLL in sinqhm_def.h
*/
status = SINQHMProject(pHist, 3, 0, iDim[0],
0, iDim[1], iImage+2, (length-2)*sizeof(int));
/*
Byte swapping
*/
for(i = 2; i < length; i++)
{
iImage[i] = htonl(iImage[i]);
}
if(status != 1)
{
SCWrite(pCon,"ERROR: histogram memory refused to Collapse",eError);
return 0;
}
}
else
{
/*
we are in simulation and justcreate some random numbers
*/
for(i = 0; i < iDim[0]; i++)
{
for(i2 = 0; i2 < iDim[1]; i2++)
{
iSum += iPtr[i3];
}
iImage[iIdx+2] = htonl(iSum);
}
iIdx = i*iDim[1] + i2;
iImage[iIdx+2] = htonl(random());
}
}
}
/* send image */
@@ -541,17 +575,14 @@
{
int iDim[MAXDIM], i, i2, i3, *iSum = NULL, iLang, *iPtr;
HistInt *lData = NULL;
int iLimit;
int iLimit, status;
char pBueffel[132];
pSINQHM pHist;
SinqHMDriv *pTata;
/* get histogram data */
/* get histogram dimensions */
GetHistDim(self->pHM,iDim,&i3);
assert(i3 == 3);
lData = GetHistogramPointer(self->pHM,pCon);
if(!lData)
{
return 0;
}
/* check limits */
if(x2 < x1)
@@ -629,25 +660,36 @@
}
memset(iSum,0,(iDim[2]+1)*sizeof(int));
/* do it! */
iSum[0] = iDim[2];
for(i = x1; i < x2; i++)
iSum[0] = htonl(iDim[2]);
if(isSINQHMDriv(self->pHM->pDriv))
{
for(i2 = x1; i2 < y2; i2++)
{
iPtr = lData + i*iDim[1]*iDim[2] +
i2*iDim[2];
for(i3 = 0; i3 < iDim[2]; i3++)
{
iSum[i3+1] += iPtr[i3];
}
}
/*
send project message to histogram memory
*/
pTata = (SinqHMDriv *)self->pHM->pDriv->pPriv;
pHist = (pSINQHM)pTata->pMaster;
status = SINQHMProject(pHist, 4, x1, x2-x1,
y1, y2-y1, iSum+1, iDim[2]*sizeof(int));
/*
convert to network byte order
*/
for(i = 1; i < iDim[2]+1; i++)
{
iSum[i] = htonl(iSum[i]);
}
if(status != 1)
{
SCWrite(pCon,"ERROR: histogram memory refused to SubSample",eError);
return 0;
}
}
/* network byte order */
for(i = 0; i < iDim[2]+1; i++)
else
{
iSum[i] = htonl(iSum[i]);
/* do acouple of random numbers! */
for(i = 1; i < iDim[2]+1; i++)
{
iSum[i] = htonl(random());
}
}
/* send */
@@ -766,6 +808,18 @@
InvokeCallBack(self->pCall, FILELOADED,self);
SCSendOK(pCon);
}
else if(strcmp(argv[1],"tofmode") == 0)
{
HMCountStartCallback(COUNTSTART,NULL,pCon);
return 1;
}
else
{
sprintf(pBueffel,"ERROR: %s nor recognized as subcommand to %s",
argv[1], argv[2]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
return 1;
}