- Added amorstatus projectytof
This commit is contained in:
98
amorstat.c
98
amorstat.c
@ -15,6 +15,10 @@
|
||||
call SINQHMProject directly.
|
||||
|
||||
Mark Koennecke, August 2001
|
||||
|
||||
An additional projection mode: onto the y -tof plane was added
|
||||
|
||||
Mark Koennecke, June 2005
|
||||
--------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@ -33,6 +37,13 @@
|
||||
#include "lld.h"
|
||||
#include "amorstat.i"
|
||||
#include "amorstat.h"
|
||||
/*-------------------------------------------------------------------
|
||||
Manually from SinqHM_def.h
|
||||
--------------------------------------------------------------------*/
|
||||
#define PROJECT__FRAME 0x0005
|
||||
#define PROJECT__AMOR 0x0006
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
A static which determines if we are in TOF or scan mode.
|
||||
*/
|
||||
@ -577,6 +588,84 @@
|
||||
free(iImage);
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------
|
||||
projectYTOF creates a 2D image from the detector by summing all x channels
|
||||
together onto the y - tof plane
|
||||
*/
|
||||
|
||||
static int projectYTOF(pAmorStat self, SConnection *pCon)
|
||||
{
|
||||
HistInt *lData = NULL;
|
||||
int i, i2, i3, iDim[MAXDIM], iIdx, iSum, status, length;
|
||||
int *iImage = NULL, *iPtr;
|
||||
pSINQHM pHist;
|
||||
SinqHMDriv *pTata;
|
||||
int iMax = -999999;
|
||||
|
||||
/* get size of our problem */
|
||||
GetHistDim(self->pHM,iDim,&i3);
|
||||
if(i3 < 3 || iDim[2] < 2){
|
||||
SCWrite(pCon,"ERROR: cannot project on Y - TOF, not in TOF mode", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate some data */
|
||||
length = 2 + iDim[1]*iDim[2];
|
||||
iImage = (int *)malloc(length*sizeof(int));
|
||||
if(iImage == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to allocate memory in projectYTOF",eError);
|
||||
return 0;
|
||||
}
|
||||
memset(iImage,0,(2 + iDim[1]*iDim[2])*sizeof(int));
|
||||
|
||||
/* first two numbers are the dimensions of the image */
|
||||
iImage[0] = htonl(iDim[1]);
|
||||
iImage[1] = htonl(iDim[2]);
|
||||
|
||||
|
||||
if(isSINQHMDriv(self->pHM->pDriv))
|
||||
{
|
||||
/*
|
||||
send a Project request to the histogram memory
|
||||
*/
|
||||
pTata = (SinqHMDriv *)self->pHM->pDriv->pPriv;
|
||||
pHist = (pSINQHM)pTata->pMaster;
|
||||
status = SINQHMProject(pHist, PROJECT__AMOR, 0, 0,
|
||||
0, 0, iImage+2, (length-2)*sizeof(int));
|
||||
|
||||
for(i = 2; i < length; i++)
|
||||
{
|
||||
iImage[i] = htonl(iImage[i]);
|
||||
}
|
||||
if(status != 1)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: histogram memory refused to project",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
we are in simulation and just create some random numbers
|
||||
*/
|
||||
for(i = 0; i < iDim[1]; i++)
|
||||
{
|
||||
for(i2 = 0; i2 < iDim[2]; i2++)
|
||||
{
|
||||
iIdx = i*iDim[2] + i2;
|
||||
iImage[iIdx+2] = htonl(random());
|
||||
iImage[iIdx+2] = htonl(77);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* send image */
|
||||
SCWriteUUencoded(pCon,"y_tof_projection",iImage,
|
||||
((iDim[1]*iDim[2])+2)*sizeof(int));
|
||||
free(iImage);
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------
|
||||
SendSingleTOF sends single detector data for TOF mode
|
||||
*/
|
||||
@ -846,6 +935,15 @@
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
else if(strcmp(argv[1],"projectytof") == 0)
|
||||
{
|
||||
iRet = projectYTOF(self,pCon);
|
||||
if(iRet)
|
||||
{
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
else if(strcmp(argv[1],"sample") == 0)
|
||||
{
|
||||
if(argc < 7)
|
||||
|
Reference in New Issue
Block a user