- Added amorstatus projectytof
This commit is contained in:
98
amorstat.c
98
amorstat.c
@ -15,6 +15,10 @@
|
|||||||
call SINQHMProject directly.
|
call SINQHMProject directly.
|
||||||
|
|
||||||
Mark Koennecke, August 2001
|
Mark Koennecke, August 2001
|
||||||
|
|
||||||
|
An additional projection mode: onto the y -tof plane was added
|
||||||
|
|
||||||
|
Mark Koennecke, June 2005
|
||||||
--------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -33,6 +37,13 @@
|
|||||||
#include "lld.h"
|
#include "lld.h"
|
||||||
#include "amorstat.i"
|
#include "amorstat.i"
|
||||||
#include "amorstat.h"
|
#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.
|
A static which determines if we are in TOF or scan mode.
|
||||||
*/
|
*/
|
||||||
@ -577,6 +588,84 @@
|
|||||||
free(iImage);
|
free(iImage);
|
||||||
return 1;
|
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
|
SendSingleTOF sends single detector data for TOF mode
|
||||||
*/
|
*/
|
||||||
@ -846,6 +935,15 @@
|
|||||||
}
|
}
|
||||||
return iRet;
|
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)
|
else if(strcmp(argv[1],"sample") == 0)
|
||||||
{
|
{
|
||||||
if(argc < 7)
|
if(argc < 7)
|
||||||
|
4
t_conv.f
4
t_conv.f
@ -416,10 +416,10 @@ c-----------------------------------------------------------------------
|
|||||||
c Calculation of mono curvature RM or analyser curvature RA
|
c Calculation of mono curvature RM or analyser curvature RA
|
||||||
c Standard law is:
|
c Standard law is:
|
||||||
c
|
c
|
||||||
c For monochr:
|
c For monochr: (Vertical)
|
||||||
c CM1RX + CM2RX/SIN(abs(A1)/RD)
|
c CM1RX + CM2RX/SIN(abs(A1)/RD)
|
||||||
c
|
c
|
||||||
c For analyser:
|
c For analyser: (Horizontal)
|
||||||
c CA1RX + CA2RX*SIN(abs(A5)/RD)
|
c CA1RX + CA2RX*SIN(abs(A5)/RD)
|
||||||
c
|
c
|
||||||
c CM1RX/CM2RX/CA1RX/CA2RX are parameters depending on monochr/analyser and
|
c CM1RX/CM2RX/CA1RX/CA2RX are parameters depending on monochr/analyser and
|
||||||
|
Reference in New Issue
Block a user