focus histrogramm aufgeteilt in 3 Module

This commit is contained in:
cvs
2003-04-08 07:21:57 +00:00
parent fd86170f8b
commit 5ebd84ddc7

279
fowrite.c
View File

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