- Fixes to HM code for AMOR TOF
- A couple of TAS fixes - o2t was fixed to work with any drivable - FOCUS was mended to include beam monitor in data file
This commit is contained in:
95
amorstat.c
95
amorstat.c
@@ -61,7 +61,7 @@
|
||||
iTime[0] = htonl(iLength);
|
||||
for(i = 0 ; i < iLength; i++)
|
||||
{
|
||||
iTime[i+1] = htonl((int)(fTime[i]*65536.));
|
||||
iTime[i+1] = htonl((int)((fTime[i]/10.)*65536.));
|
||||
}
|
||||
/* send new time binning to all clients */
|
||||
SCWrite(pCon,"TOFClear",eError);
|
||||
@@ -499,6 +499,7 @@
|
||||
int *iImage = NULL, *iPtr;
|
||||
pSINQHM pHist;
|
||||
SinqHMDriv *pTata;
|
||||
int iMax = -999999;
|
||||
|
||||
/* get size of our problem */
|
||||
GetHistDim(self->pHM,iDim,&i3);
|
||||
@@ -537,8 +538,16 @@
|
||||
*/
|
||||
for(i = 2; i < length; i++)
|
||||
{
|
||||
/*
|
||||
if(iImage[i] > iMax){
|
||||
iMax = iImage[i];
|
||||
}
|
||||
*/
|
||||
iImage[i] = htonl(iImage[i]);
|
||||
}
|
||||
/*
|
||||
printf("Collpased maximum: %d\n",iMax);
|
||||
*/
|
||||
if(status != 1)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: histogram memory refused to Collapse",eError);
|
||||
@@ -562,10 +571,74 @@
|
||||
|
||||
/* send image */
|
||||
SCWriteUUencoded(pCon,"arrow_image",iImage,
|
||||
(iDim[0]*iDim[1]+2)*sizeof(int));
|
||||
((iDim[0]*iDim[1])+2)*sizeof(int));
|
||||
free(iImage);
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------
|
||||
SendSingleTOF sends single detector data for TOF mode
|
||||
*/
|
||||
|
||||
static int SendSingleTOF(pAmorStat self, SConnection *pCon)
|
||||
{
|
||||
HistInt *lData = NULL;
|
||||
int i, i2, i3, iDim[MAXDIM], iIdx, iSum, status, length;
|
||||
pSINQHM pHist;
|
||||
SinqHMDriv *pTata;
|
||||
int iMax = -999999;
|
||||
const float *timebin;
|
||||
HistInt *iData = NULL;
|
||||
|
||||
/* get size of our problem */
|
||||
GetHistDim(self->pHM,iDim,&i3);
|
||||
assert(i3 == 3);
|
||||
|
||||
/* allocate some data */
|
||||
timebin = GetHistTimeBin(self->pHM, &i3);
|
||||
length = 1 + 2*i3;
|
||||
iData = (HistInt *)malloc(length*sizeof(HistInt));
|
||||
if(iData == NULL){
|
||||
SCWrite(pCon,"ERROR: failed to allocate memory in SendSingleTOF",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
memset(iData,0,length*sizeof(int));
|
||||
|
||||
/* first number is the length of each single histogram */
|
||||
iData[0] = htonl(i3);
|
||||
|
||||
|
||||
if(isSINQHMDriv(self->pHM->pDriv))
|
||||
{
|
||||
GetHistogramDirect(self->pHM,pCon,0,iDim[0]*iDim[1]*iDim[2],
|
||||
2*iDim[2],&iData[1],2*iDim[2]*sizeof(HistInt));
|
||||
for(i = 1; i < length; i++)
|
||||
{
|
||||
iData[i] = htonl(iData[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
we are in simulation and just create some random numbers
|
||||
*/
|
||||
for(i = 1; i < length; i++)
|
||||
{
|
||||
iData[i] = htonl(random());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
send, with a little trick to do two histograms.
|
||||
*/
|
||||
SCWriteUUencoded(pCon,"SING1",iData,
|
||||
(iDim[2]+1)*sizeof(int));
|
||||
iData[iDim[2]] = htonl(iDim[2]);
|
||||
SCWriteUUencoded(pCon,"SING2",&iData[iDim[2]],
|
||||
(iDim[2]+1)*sizeof(int));
|
||||
free(iData);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------
|
||||
SubSample sums histogram data in the area defined by the rectangle
|
||||
x1,y1 x2, y2. Summing is along the time axis.
|
||||
@@ -585,10 +658,16 @@
|
||||
assert(i3 == 3);
|
||||
|
||||
/* check limits */
|
||||
if(x2 < x1)
|
||||
x2 = x1 + 1;
|
||||
if(y2 < y1)
|
||||
y2 = y1 + 1;
|
||||
if(x2 < x1){
|
||||
i = x1;
|
||||
x1 = x2;
|
||||
x2 = i +1;
|
||||
}
|
||||
if(y2 < y1){
|
||||
i = y1;
|
||||
y1 = y2;
|
||||
y2 = i + 1;
|
||||
}
|
||||
|
||||
iLimit = 0;
|
||||
if( x1 > iDim[0])
|
||||
@@ -797,6 +876,10 @@
|
||||
SCSendOK(pCon);
|
||||
return iRet;
|
||||
}
|
||||
else if(strcmp(argv[1],"singletof") == 0)
|
||||
{
|
||||
return SendSingleTOF(self,pCon);
|
||||
}
|
||||
else if(strcmp(argv[1],"sendloaded") == 0)
|
||||
{
|
||||
SendLoadedData(self,pCon);
|
||||
|
||||
Reference in New Issue
Block a user