focus histrogramm aufgeteilt in 3 Module
This commit is contained in:
243
fowrite.c
243
fowrite.c
@ -32,13 +32,19 @@
|
|||||||
#include "fitcenter.h"
|
#include "fitcenter.h"
|
||||||
#include "fomerge.h"
|
#include "fomerge.h"
|
||||||
|
|
||||||
|
/* histogram memory names */
|
||||||
|
#define HM1 "hm1"
|
||||||
|
#define HM2 "hm2"
|
||||||
|
#define HM3 "hm3"
|
||||||
|
|
||||||
|
|
||||||
/* the name of the SICS chopper controller object */
|
/* the name of the SICS chopper controller object */
|
||||||
#define CHOPPERNAME "choco"
|
#define CHOPPERNAME "choco"
|
||||||
|
|
||||||
/*--------- the internal data structure ------------------------------------*/
|
/*--------- the internal data structure ------------------------------------*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pObjectDescriptor pDes;
|
pObjectDescriptor pDes;
|
||||||
pHistMem pHist;
|
pHistMem pHistogram1, pHistogram2, pHistogram3;
|
||||||
int iNew;
|
int iNew;
|
||||||
time_t tUpdate;
|
time_t tUpdate;
|
||||||
int iInterval;
|
int iInterval;
|
||||||
@ -52,8 +58,11 @@
|
|||||||
/* detector availability flags */
|
/* detector availability flags */
|
||||||
} FoWrite, *pFoWrite;
|
} FoWrite, *pFoWrite;
|
||||||
/* ------------------- forward declaration of task function --------------*/
|
/* ------------------- forward declaration of task function --------------*/
|
||||||
|
|
||||||
static int FoTask(void *pData);
|
static int FoTask(void *pData);
|
||||||
static void FoUpdate(pFoWrite self, SConnection *pCon);
|
static void FoUpdate(pFoWrite self, SConnection *pCon);
|
||||||
|
|
||||||
|
|
||||||
/*------------------ The Countstart Callback Function ----------------------*/
|
/*------------------ The Countstart Callback Function ----------------------*/
|
||||||
static int Countstartcallback(int iEvent, void *pEventData, void *pUser)
|
static int Countstartcallback(int iEvent, void *pEventData, void *pUser)
|
||||||
{
|
{
|
||||||
@ -173,6 +182,9 @@
|
|||||||
{
|
{
|
||||||
NXhandle pFile = NULL;
|
NXhandle pFile = NULL;
|
||||||
NXdict pDict = NULL;
|
NXdict pDict = NULL;
|
||||||
|
pSicsVariable var1 = NULL;
|
||||||
|
pSicsVariable var2 = NULL;
|
||||||
|
int lbank, mbank;
|
||||||
int iStat, iLength, i;
|
int iStat, iLength, i;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
CounterMode eMode;
|
CounterMode eMode;
|
||||||
@ -251,7 +263,43 @@
|
|||||||
SNXSPutVariable(pServ->pSics,pCon,pFile,pDict,"fcdist","fermidist");
|
SNXSPutVariable(pServ->pSics,pCon,pFile,pDict,"fcdist","fermidist");
|
||||||
|
|
||||||
/* counting data */
|
/* counting data */
|
||||||
eMode = GetHistCountMode(self->pHist);
|
|
||||||
|
var2 = FindVariable(pServ->pSics,"mbank");
|
||||||
|
if(var2)
|
||||||
|
{
|
||||||
|
VarGetInt(var2,&mbank);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||||
|
}
|
||||||
|
if(var2)
|
||||||
|
{
|
||||||
|
eMode = GetHistCountMode(self->pHistogram2);
|
||||||
|
fTime = GetHistTimeBin(self->pHistogram2,&iLength);
|
||||||
|
fVal = GetHistPreset(self->pHistogram2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var1 = FindVariable(pServ->pSics,"lbank");
|
||||||
|
if(var1)
|
||||||
|
{
|
||||||
|
VarGetInt(var1,&lbank);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||||
|
}
|
||||||
|
if(var1)
|
||||||
|
{
|
||||||
|
eMode = GetHistCountMode(self->pHistogram1);
|
||||||
|
fTime = GetHistTimeBin(self->pHistogram1,&iLength);
|
||||||
|
fVal = GetHistPreset(self->pHistogram1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eMode = GetHistCountMode(self->pHistogram3);
|
||||||
|
fTime = GetHistTimeBin(self->pHistogram3,&iLength);
|
||||||
|
fVal = GetHistPreset(self->pHistogram3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(eMode == eTimer)
|
if(eMode == eTimer)
|
||||||
{
|
{
|
||||||
strcpy(pBueffel,"timer");
|
strcpy(pBueffel,"timer");
|
||||||
@ -261,12 +309,9 @@
|
|||||||
strcpy(pBueffel,"monitor");
|
strcpy(pBueffel,"monitor");
|
||||||
}
|
}
|
||||||
NXDputalias(pFile,pDict,"cnmode",pBueffel);
|
NXDputalias(pFile,pDict,"cnmode",pBueffel);
|
||||||
fVal = GetHistPreset(self->pHist);
|
|
||||||
NXDputalias(pFile,pDict,"cnpreset",&fVal);
|
NXDputalias(pFile,pDict,"cnpreset",&fVal);
|
||||||
|
|
||||||
|
|
||||||
/* detector banks */
|
/* detector banks */
|
||||||
fTime = GetHistTimeBin(self->pHist,&iLength);
|
|
||||||
fTime2 = (float *)malloc(iLength*sizeof(float));
|
fTime2 = (float *)malloc(iLength*sizeof(float));
|
||||||
if(fTime2)
|
if(fTime2)
|
||||||
{
|
{
|
||||||
@ -371,12 +416,18 @@
|
|||||||
{
|
{
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
int iInt, iStat, iTime, i, j, iDet, iIndex;
|
int iInt, iStat, iTime, i, j, iDet, iIndex;
|
||||||
|
pSicsVariable var1 = NULL;
|
||||||
|
pSicsVariable var2 = NULL;
|
||||||
|
pSicsVariable var3 = NULL;
|
||||||
|
int lbank, mbank, ubank;
|
||||||
long lVal;
|
long lVal;
|
||||||
float fVal;
|
float fVal;
|
||||||
const float *fTime;
|
const float *fTime;
|
||||||
NXhandle pFile = NULL;
|
NXhandle pFile = NULL;
|
||||||
NXdict pDict;
|
NXdict pDict;
|
||||||
HistInt *lData = NULL;
|
HistInt *lData = NULL;
|
||||||
|
HistInt *mData = NULL;
|
||||||
|
HistInt *uData = NULL;
|
||||||
int *iSum = NULL;
|
int *iSum = NULL;
|
||||||
float *fAxis = NULL;
|
float *fAxis = NULL;
|
||||||
long *lSum = NULL;
|
long *lSum = NULL;
|
||||||
@ -417,38 +468,116 @@
|
|||||||
SNXSPutDrivable(pServ->pSics,pCon,pFile,pDict,"ratio","cratio");
|
SNXSPutDrivable(pServ->pSics,pCon,pFile,pDict,"ratio","cratio");
|
||||||
|
|
||||||
/* counter data */
|
/* counter data */
|
||||||
fVal = GetHistCountTime(self->pHist,pCon);
|
var2 = FindVariable(pServ->pSics,"mbank");
|
||||||
|
if(var2)
|
||||||
|
{
|
||||||
|
VarGetInt(var2,&mbank);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||||
|
}
|
||||||
|
if(var2)
|
||||||
|
{
|
||||||
|
fVal = GetHistCountTime(self->pHistogram2,pCon);
|
||||||
NXDputalias(pFile,pDict,"cntime",&fVal);
|
NXDputalias(pFile,pDict,"cntime",&fVal);
|
||||||
lVal = GetHistMonitor(self->pHist,1,pCon);
|
lVal = GetHistMonitor(self->pHistogram2,1,pCon);
|
||||||
NXDputalias(pFile,pDict,"cnmon1",&lVal);
|
NXDputalias(pFile,pDict,"cnmon1",&lVal);
|
||||||
lVal = GetHistMonitor(self->pHist,0,pCon);
|
lVal = GetHistMonitor(self->pHistogram2,0,pCon);
|
||||||
NXDputalias(pFile,pDict,"cnmon2",&lVal);
|
NXDputalias(pFile,pDict,"cnmon2",&lVal);
|
||||||
lVal = GetHistMonitor(self->pHist,4,pCon);
|
lVal = GetHistMonitor(self->pHistogram2,4,pCon);
|
||||||
NXDputalias(pFile,pDict,"cnmon3",&lVal);
|
NXDputalias(pFile,pDict,"cnmon3",&lVal);
|
||||||
|
fTime = GetHistTimeBin(self->pHistogram2,&iInt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var1 = FindVariable(pServ->pSics,"lbank");
|
||||||
|
if(var1)
|
||||||
|
{
|
||||||
|
VarGetInt(var2,&lbank);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||||
|
}
|
||||||
|
if(var1)
|
||||||
|
{
|
||||||
|
fVal = GetHistCountTime(self->pHistogram1,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cntime",&fVal);
|
||||||
|
lVal = GetHistMonitor(self->pHistogram1,1,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cnmon1",&lVal);
|
||||||
|
lVal = GetHistMonitor(self->pHistogram1,0,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cnmon2",&lVal);
|
||||||
|
lVal = GetHistMonitor(self->pHistogram1,4,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cnmon3",&lVal);
|
||||||
|
fTime = GetHistTimeBin(self->pHistogram1,&iInt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fVal = GetHistCountTime(self->pHistogram3,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cntime",&fVal);
|
||||||
|
lVal = GetHistMonitor(self->pHistogram3,1,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cnmon1",&lVal);
|
||||||
|
lVal = GetHistMonitor(self->pHistogram3,0,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cnmon2",&lVal);
|
||||||
|
lVal = GetHistMonitor(self->pHistogram3,4,pCon);
|
||||||
|
NXDputalias(pFile,pDict,"cnmon3",&lVal);
|
||||||
|
fTime = GetHistTimeBin(self->pHistogram3,&iInt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* histogram with three detector banks */
|
/* histogram with three detector banks */
|
||||||
fTime = GetHistTimeBin(self->pHist,&iInt);
|
|
||||||
iTime = iInt;
|
iTime = iInt;
|
||||||
sprintf(pBueffel,"%d",iInt);
|
sprintf(pBueffel,"%d",iInt);
|
||||||
NXDupdate(pDict,"timebin",pBueffel);
|
NXDupdate(pDict,"timebin",pBueffel);
|
||||||
lData = GetHistogramPointer(self->pHist,pCon);
|
|
||||||
|
if (var1)
|
||||||
|
{
|
||||||
|
lData = GetHistogramPointer(self->pHistogram1,pCon);
|
||||||
if(!lData)
|
if(!lData)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: failed to find Histogram Memory Data",eError);
|
SCWrite(pCon,"ERROR: failed to find Histogram Memory Data (lower bank)",eError);
|
||||||
NXclose(&pFile);
|
NXclose(&pFile);
|
||||||
NXDclose(pDict,NULL);
|
NXDclose(pDict,NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (var2)
|
||||||
|
{
|
||||||
|
mData = GetHistogramPointer(self->pHistogram2,pCon);
|
||||||
|
if(!mData)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: failed to find Histogram Memory Data (middle bank)",eError);
|
||||||
|
NXclose(&pFile);
|
||||||
|
NXDclose(pDict,NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var3 = FindVariable(pServ->pSics,"ubank");
|
||||||
|
if(var1)
|
||||||
|
{
|
||||||
|
VarGetInt(var3,&ubank);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: ubank value not found!",eError);
|
||||||
|
}
|
||||||
|
if (var3)
|
||||||
|
{
|
||||||
|
uData = GetHistogramPointer(self->pHistogram3,pCon);
|
||||||
|
if(!uData)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: failed to find Histogram Memory Data (upper bank)",eError);
|
||||||
|
NXclose(&pFile);
|
||||||
|
NXDclose(pDict,NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
setFMDataPointer(lData,iTime);
|
setFMDataPointer(lData,iTime);
|
||||||
|
setFMDataPointer(mData,iTime);
|
||||||
|
setFMDataPointer(uData,iTime);
|
||||||
if(self->iUpper)
|
if(self->iUpper)
|
||||||
{
|
{
|
||||||
NXDupdate(pDict,"bank","upperbank");
|
NXDupdate(pDict,"bank","upperbank");
|
||||||
iDet = getFMdim(UPPER);
|
iDet = 117;
|
||||||
sprintf(pBueffel,"%d",iDet);
|
sprintf(pBueffel,"%d",iDet);
|
||||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||||
lData = getFMBankPointer(UPPER);
|
uData = getFMBankPointer(UPPER);
|
||||||
NXDputalias(pFile,pDict,"dcounts",lData);
|
NXDputalias(pFile,pDict,"dcounts",uData);
|
||||||
/* summed counts for each detector */
|
/* summed counts for each detector */
|
||||||
iSum = (int *)malloc(iDet*sizeof(int));
|
iSum = (int *)malloc(iDet*sizeof(int));
|
||||||
if(iSum)
|
if(iSum)
|
||||||
@ -459,7 +588,7 @@
|
|||||||
iIndex = i * iTime;
|
iIndex = i * iTime;
|
||||||
for(j = 0; j < iTime; j++)
|
for(j = 0; j < iTime; j++)
|
||||||
{
|
{
|
||||||
iSum[i] += lData[iIndex+j];
|
iSum[i] += uData[iIndex+j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NXDputalias(pFile,pDict,"dsums",iSum);
|
NXDputalias(pFile,pDict,"dsums",iSum);
|
||||||
@ -475,11 +604,11 @@
|
|||||||
if(self->iMiddle)
|
if(self->iMiddle)
|
||||||
{
|
{
|
||||||
NXDupdate(pDict,"bank","bank1");
|
NXDupdate(pDict,"bank","bank1");
|
||||||
iDet = getFMdim(MIDDLE);
|
iDet = 150;
|
||||||
sprintf(pBueffel,"%d",iDet);
|
sprintf(pBueffel,"%d",iDet);
|
||||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||||
lData = getFMBankPointer(MIDDLE);
|
mData = getFMBankPointer(MIDDLE);
|
||||||
NXDputalias(pFile,pDict,"dcounts",lData);
|
NXDputalias(pFile,pDict,"dcounts",mData);
|
||||||
/* summed counts for each detector */
|
/* summed counts for each detector */
|
||||||
iSum = (int *)malloc(iDet*sizeof(int));
|
iSum = (int *)malloc(iDet*sizeof(int));
|
||||||
if(iSum)
|
if(iSum)
|
||||||
@ -490,7 +619,7 @@
|
|||||||
iIndex = i * iTime;
|
iIndex = i * iTime;
|
||||||
for(j = 0; j < iTime; j++)
|
for(j = 0; j < iTime; j++)
|
||||||
{
|
{
|
||||||
iSum[i] += lData[iIndex+j];
|
iSum[i] += mData[iIndex+j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NXDputalias(pFile,pDict,"dsums",iSum);
|
NXDputalias(pFile,pDict,"dsums",iSum);
|
||||||
@ -505,7 +634,7 @@
|
|||||||
if(self->iLower)
|
if(self->iLower)
|
||||||
{
|
{
|
||||||
NXDupdate(pDict,"bank","lowerbank");
|
NXDupdate(pDict,"bank","lowerbank");
|
||||||
iDet = getFMdim(LOWER);
|
iDet = 116;
|
||||||
sprintf(pBueffel,"%d",iDet);
|
sprintf(pBueffel,"%d",iDet);
|
||||||
NXDupdate(pDict,"noofdetectors",pBueffel);
|
NXDupdate(pDict,"noofdetectors",pBueffel);
|
||||||
lData = getFMBankPointer(LOWER);
|
lData = getFMBankPointer(LOWER);
|
||||||
@ -776,8 +905,7 @@
|
|||||||
int FoInstall(SConnection *pCon, SicsInterp *pSics, void *pData,
|
int FoInstall(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
CommandList *pCom = NULL;
|
||||||
pHistMem pHist= NULL;
|
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
pFoWrite pNew = NULL;
|
pFoWrite pNew = NULL;
|
||||||
pICallBack pCall = NULL;
|
pICallBack pCall = NULL;
|
||||||
@ -790,15 +918,40 @@
|
|||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* find things in interpreter */
|
||||||
pHist = (pHistMem)FindCommandData(pSics,argv[1],"HistMem");
|
pCom = FindCommand(pSics,HM1);
|
||||||
if(!pHist)
|
if(pCom)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: Histogram memory NOT found",eError);
|
pNew->pHistogram1 = (pHistMem)pCom->pData;
|
||||||
return 0;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: Histogram memory for lower detector bank NOT found",eError);
|
||||||
|
pNew->pHistogram1 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!initializeFM(argv[3]))
|
pCom = FindCommand(pSics,HM2);
|
||||||
|
if(pCom)
|
||||||
|
{
|
||||||
|
pNew->pHistogram2 = (pHistMem)pCom->pData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: Histogram memory for middle detector bank NOT found",eError);
|
||||||
|
pNew->pHistogram2 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pCom = FindCommand(pSics,HM3);
|
||||||
|
if(pCom)
|
||||||
|
{
|
||||||
|
pNew->pHistogram3 = (pHistMem)pCom->pData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: Histogram memory for upper detector bank NOT found",eError);
|
||||||
|
pNew->pHistogram3 = NULL;
|
||||||
|
}
|
||||||
|
if(!initializeFM(argv[2]))
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: bad merge data file",eError);
|
SCWrite(pCon,"ERROR: bad merge data file",eError);
|
||||||
return 0;
|
return 0;
|
||||||
@ -817,21 +970,41 @@
|
|||||||
if( (!pNew->pDes) || (!pNew->pFitter) )
|
if( (!pNew->pDes) || (!pNew->pFitter) )
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: out of memory in FoInstall",eError);
|
SCWrite(pCon,"ERROR: out of memory in FoInstall",eError);
|
||||||
|
free(pNew);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pNew->pHist = pHist;
|
pNew->pDictFile = strdup(argv[1]);
|
||||||
pNew->pDictFile = strdup(argv[2]);
|
|
||||||
pNew->iInterval = 20*60;
|
pNew->iInterval = 20*60;
|
||||||
pNew->iMiddle =1;
|
pNew->iMiddle =1;
|
||||||
|
|
||||||
/* install callbacks */
|
/* install callbacks */
|
||||||
pDum = (pDummy)pHist;
|
pCom = FindCommand(pSics,HM2);
|
||||||
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pHist,
|
if(pCom)
|
||||||
|
{
|
||||||
|
pDum = (pDummy)pNew->pHistogram2;
|
||||||
|
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pNew->pHistogram2,
|
||||||
CALLBACKINTERFACE);
|
CALLBACKINTERFACE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pCom = FindCommand(pSics,HM1);
|
||||||
|
if(pCom)
|
||||||
|
{
|
||||||
|
pDum = (pDummy)pNew->pHistogram1;
|
||||||
|
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pNew->pHistogram1,
|
||||||
|
CALLBACKINTERFACE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pDum = (pDummy)pNew->pHistogram3;
|
||||||
|
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pNew->pHistogram3, CALLBACKINTERFACE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!pCall)
|
if(!pCall)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,
|
SCWrite(pCon,
|
||||||
"ERROR: no callback interface found at your histogram memory",
|
"ERROR: no callback interface found at your histogram memories",
|
||||||
eError);
|
eError);
|
||||||
KillFoWrite(pNew);
|
KillFoWrite(pNew);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user