- More debugging of scriptcontext, mostly working now
- Created driveable SICSobj for standalone and as an adapter
This commit is contained in:
48
fomerge.c
48
fomerge.c
@ -689,10 +689,8 @@ static int TOFLambda(SicsInterp *pSics, SConnection *pCon,
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
pNXScript pNexus, char *alias, float fElastic)
|
||||
static float calcElastic(SicsInterp *pSics, SConnection *pCon)
|
||||
{
|
||||
|
||||
int status, iTime, iDet, i;
|
||||
const float *fTimeBin = NULL;
|
||||
int *sum = NULL;
|
||||
@ -706,7 +704,7 @@ static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
SCWrite(pCon,
|
||||
"ERROR: need middle detector bank for elastic peak calculation",
|
||||
eError);
|
||||
return NX_ERROR;
|
||||
return -1.;
|
||||
}
|
||||
fTimeBin = GetHistTimeBin(pMem,&iTime);
|
||||
iDet = getFMdim(MIDDLE);
|
||||
@ -715,7 +713,7 @@ static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory calculating elastic peak position",
|
||||
eError);
|
||||
return NX_ERROR;
|
||||
return -1;
|
||||
}
|
||||
if(fitter == NULL)
|
||||
{
|
||||
@ -723,7 +721,7 @@ static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
if(!fitter)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: cannot allocate fitting structure",eError);
|
||||
return NX_ERROR;
|
||||
return -1.;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -734,7 +732,7 @@ static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in putElastic",eError);
|
||||
free(sum);
|
||||
return NX_ERROR;
|
||||
return -1.;
|
||||
}
|
||||
for(i = 0; i < iTime; i++)
|
||||
{
|
||||
@ -743,20 +741,26 @@ static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
status = CalculateFitFromData(fitter,(float *)fTimeBin,lSum,iTime);
|
||||
free(lSum);
|
||||
GetFitResults(fitter,&fCenter,&fStdDev,&fFWHM,&fVal);
|
||||
fVal = fCenter - fElastic;
|
||||
if(fVal < 0.)
|
||||
fVal = - fVal;
|
||||
/* bad value, leave at theoretical value */
|
||||
if(fVal < 10.)
|
||||
{
|
||||
fElastic = fCenter;
|
||||
}
|
||||
free(sum);
|
||||
|
||||
status = NXDputalias(pNexus->fileHandle, pNexus->dictHandle,alias,
|
||||
&fElastic);
|
||||
return status;
|
||||
return fCenter;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define ABS(x) (x < 0 ? -(x) : (x))
|
||||
|
||||
static int putElastic(SicsInterp *pSics, SConnection *pCon,
|
||||
pNXScript pNexus, char *alias, float fElastic)
|
||||
{
|
||||
float fCalc;
|
||||
int status;
|
||||
|
||||
fCalc = calcElastic(pSics,pCon);
|
||||
if(ABS(fElastic -fCalc) < 20) {
|
||||
fElastic = fCalc;
|
||||
}
|
||||
|
||||
status = NXDputalias(pNexus->fileHandle, pNexus->dictHandle,alias,
|
||||
&fElastic);
|
||||
return status;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int FMputTTH(SConnection *pCon, int argc, char *argv[]){
|
||||
@ -909,6 +913,7 @@ static int FMcopyMergedSum(SConnection *pCon, int argc, char *argv[]){
|
||||
focusmerge putsum nxscriptmod bankname alias
|
||||
focusmerge putelastic nxscriptmod alias theoelastic
|
||||
focusmerge toflambda
|
||||
focusmerge elastic
|
||||
|
||||
nxscriptmod = name of the nxscript module used for writing, must be open
|
||||
alias = The alias under which to write the data item
|
||||
@ -944,6 +949,11 @@ int FocusMergeAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(strcmp(argv[1],"toflambda") == 0){
|
||||
return TOFLambda(pSics, pCon,argc,argv);
|
||||
}
|
||||
if(strcmp(argv[1],"elastic") == 0){
|
||||
fElastic = calcElastic(pSics,pCon);
|
||||
SCPrintf(pCon,eValue,"tofelastic = %f", fElastic);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(strcmp(argv[1],"puttwotheta") == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user