mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
scripting stuff added
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@26 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -330,11 +330,12 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
} else if (var=="trimen") {
|
} else if (var=="trimen") {
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
sscanf(args[1],"%d",&ival);
|
sscanf(args[1],"%d",&ival);
|
||||||
std::cout<< ival << std::endl ;
|
//std::cout<< ival << std::endl ;
|
||||||
|
if (ival>narg-2)
|
||||||
|
ival=narg-2;
|
||||||
int ene[ival];
|
int ene[ival];
|
||||||
for (int ie=0; ie<ival; ie++) {
|
for (int ie=0; ie<ival; ie++) {
|
||||||
std::cout<< ie << " " << args[2+ie] ;
|
sscanf(args[2+ie],"%d",ene+ie);
|
||||||
std::cout<< sscanf(args[2+ie],"%d",ene+ie)<< std::endl;;
|
|
||||||
}
|
}
|
||||||
setTrimEn(ival,ene);
|
setTrimEn(ival,ene);
|
||||||
}
|
}
|
||||||
@ -363,6 +364,196 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
sprintf(answer,"%d",setOnline());
|
sprintf(answer,"%d",setOnline());
|
||||||
return string(answer);
|
return string(answer);
|
||||||
}
|
}
|
||||||
|
else if (var=="startscript") {
|
||||||
|
ival=startScript;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setAction(ival,args[1]);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d %s",getActionMode(ival), getActionScript(ival).c_str());
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="startscriptpar") {
|
||||||
|
ival=startScript;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setActionParameter(ival,args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getActionParameter(ival);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (var=="stopscript") {
|
||||||
|
ival=stopScript;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setAction(ival,args[1]);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d %s",getActionMode(ival), getActionScript(ival).c_str());
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="stopscriptpar") {
|
||||||
|
ival=stopScript;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setActionParameter(ival,args[1]);
|
||||||
|
}
|
||||||
|
return getActionParameter(ival);
|
||||||
|
|
||||||
|
} else if (var=="scriptbefore") {
|
||||||
|
ival=scriptBefore;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setAction(ival,args[1]);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d %s",getActionMode(ival), getActionScript(ival).c_str());
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="scriptbeforepar") {
|
||||||
|
ival=scriptBefore;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setActionParameter(ival,args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getActionParameter(ival);
|
||||||
|
|
||||||
|
} else if (var=="scriptafter") {
|
||||||
|
ival=scriptAfter;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setAction(ival,args[1]);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d %s",getActionMode(ival), getActionScript(ival).c_str());
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="scriptafterpar") {
|
||||||
|
ival=scriptAfter;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setActionParameter(ival,args[1]);
|
||||||
|
}
|
||||||
|
return getActionParameter(ival);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if (var=="headerafter") {
|
||||||
|
ival=headerAfter;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setAction(ival,args[1]);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d %s",getActionMode(ival), getActionScript(ival).c_str());
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="headerafterpar") {
|
||||||
|
ival=headerAfter;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setActionParameter(ival,args[1]);
|
||||||
|
}
|
||||||
|
return getActionParameter(ival);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if (var=="headerbefore") {
|
||||||
|
ival=headerBefore;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setAction(ival,args[1]);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d %s",getActionMode(ival), getActionScript(ival).c_str());
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="headerbeforepar") {
|
||||||
|
ival=headerBefore;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setActionParameter(ival,args[1]);
|
||||||
|
}
|
||||||
|
return getActionParameter(ival);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var=="scan0script") {
|
||||||
|
int ind=0;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setScanScript(ind,args[1]);
|
||||||
|
}
|
||||||
|
return getScanScript(ind);
|
||||||
|
} else if (var=="scan0par") {
|
||||||
|
int ind=0;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setScanParameter(ind,args[1]);
|
||||||
|
}
|
||||||
|
return getScanParameter(ind);
|
||||||
|
} else if (var=="scan0prec") {
|
||||||
|
int ind=0;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
setScanPrecision(ind,ival);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d",getScanPrecision(ind));
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="scan0steps") {
|
||||||
|
int ind=0;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
//cout << ival << " " << narg << endl;
|
||||||
|
if (ival>narg-2)
|
||||||
|
ival=narg-2;
|
||||||
|
float ene[ival];
|
||||||
|
for (int ie=0; ie<ival; ie++) {
|
||||||
|
sscanf(args[2+ie],"%f",ene+ie);
|
||||||
|
}
|
||||||
|
setScanSteps(ind,ival,ene);
|
||||||
|
}
|
||||||
|
int nen=getScanSteps(ind);
|
||||||
|
sprintf(answer,"%d",nen);
|
||||||
|
float oen[nen];
|
||||||
|
getScanSteps(ind,oen);
|
||||||
|
char form[20];
|
||||||
|
sprintf(form,"%%s %%0.%df",getScanPrecision(ind));
|
||||||
|
for (int ie=0; ie<nen;ie++) {
|
||||||
|
sprintf(answer,form,answer,oen[ie]);
|
||||||
|
}
|
||||||
|
return string(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (var=="scan1script") {
|
||||||
|
int ind=1;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setScanScript(ind,args[1]);
|
||||||
|
}
|
||||||
|
return getScanScript(ind);
|
||||||
|
} else if (var=="scan1par") {
|
||||||
|
int ind=1;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
setScanParameter(ind,args[1]);
|
||||||
|
}
|
||||||
|
return getScanParameter(ind);
|
||||||
|
} else if (var=="scan1prec") {
|
||||||
|
int ind=1;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
setScanPrecision(ind,ival);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d",getScanPrecision(ind));
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="scan1steps") {
|
||||||
|
int ind=1;
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
if (ival>narg-2)
|
||||||
|
ival=narg-2;
|
||||||
|
float ene[ival];
|
||||||
|
for (int ie=0; ie<ival; ie++) {
|
||||||
|
sscanf(args[2+ie],"%f",ene+ie);
|
||||||
|
}
|
||||||
|
setScanSteps(ind,ival,ene);
|
||||||
|
}
|
||||||
|
int nen=getScanSteps(ind);
|
||||||
|
sprintf(answer,"%d",nen);
|
||||||
|
float oen[nen];
|
||||||
|
getScanSteps(ind,oen);
|
||||||
|
char form[20];
|
||||||
|
sprintf(form,"%%s %%0.%df",getScanPrecision(ind));
|
||||||
|
for (int ie=0; ie<nen;ie++) {
|
||||||
|
sprintf(answer,form,answer,oen[ie]);
|
||||||
|
}
|
||||||
|
return string(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -837,6 +1028,71 @@ string mythenDetector::helpLine( int action) {
|
|||||||
os << std::endl;
|
os << std::endl;
|
||||||
os << "trimen nen [e0 e1...en] \t sets the number of energies for which trimbit files exist and their value"<< std::endl;
|
os << "trimen nen [e0 e1...en] \t sets the number of energies for which trimbit files exist and their value"<< std::endl;
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
os << "startscript script \t sets script to execute at the beginning of the measurements - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex par=startscriptpar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "startscriptpar par \t sets start script parameter (see startscript)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "scan0script script \t sets script to launch at level 0 scan. If \"energy\" energy scan, if \"threshold\" threshold scan, if \"trimbits\" trimbits scan, \"none\" unsets otherwise will be launched as a system call with arguments nrun=fileindex fn=filename var=scan0var par=scan0par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan0par par\t sets the level 0 scan parameter. See scan0script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan0prec n \t sets the level 0 scan precision for the output file name. See scan0script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan0steps nsteps [s0 s1...] \t sets the level 0 scan steps. See scan0script - nsteps=0 unsets the scan level"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "scan1script script \t sets script to launch at level 1 scan. If \"energy\" energy scan, if \"threshold\" threshold scan, if \"trimbits\" trimbits scan, \"none\" unsets otherwise will be launched as a system call with arguments nrun=fileindex fn=filename var=scan1var par=scan1par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "scan1par par\t sets the level 1 scan parameter. See scan1script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan1prec n \t sets the level 1 scan precision for the output file name. See scan1script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan1steps nsteps [s0 s1...] \t sets the level 1 scan steps. See scan1script - nsteps=0 unsets the scan level"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "scriptbefore script \t sets script to execute at the beginning of the realtime acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename par=scriptbeforepar sv0=scan0var sv1=scan1var p0=scan0par p1=scan1par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scriptbeforepar \t sets script before parameter (see scriptbefore)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "headerbefore script \n script to launch to acquire the headerfile just before the acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename acqtime=t gainmode=sett threshold=thr badfile=badf angfile=angf bloffset=bloffset fineoffset=fineoffset fffile=ffile tau=taucorr par=headerbeforepar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "headerbeforepar \t sets header before parameter (see headerbefore)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "headerafter script \n script to launch to acquire the headerfile just after the acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename acqtime=t gainmode=sett threshold=thr badfile=badf angfile=angf bloffset=bloffset fineoffset=fineoffset fffile=ffile tau=taucorr par=headerafterpar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "headerafterpar par \t sets header after parameter (see headerafter)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "scriptafter script \t sets script to execute at the end of the realtime acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename par=scriptafterpar sv0=scan0var sv1=scan1var p0=scan0par p1=scan1par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scriptafterpar par \t sets script after parameter (see scriptafter)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "stopscript script \t sets script to execute at the end of the measurements - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex par=stopscriptpar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "stopscriptpar par\t sets stop script parameter (see stopscript)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
os << "outdir \t directory to which the files will be written by default" << std::endl;
|
os << "outdir \t directory to which the files will be written by default" << std::endl;
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
os << "fname \t filename to which the files will be written by default (to which file and position indexes will eventually be attached)" << std::endl;
|
os << "fname \t filename to which the files will be written by default (to which file and position indexes will eventually be attached)" << std::endl;
|
||||||
@ -940,6 +1196,85 @@ string mythenDetector::helpLine( int action) {
|
|||||||
os << "trimdir \t Gets path of the trim files " << std::endl;
|
os << "trimdir \t Gets path of the trim files " << std::endl;
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
os << "trimen \t returns the number of energies for which trimbit files exist and their values"<< std::endl;
|
os << "trimen \t returns the number of energies for which trimbit files exist and their values"<< std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
os << "startscript \t gets script to execute at the beginning of the measurements - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex par=startscriptpar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "startscriptpar \t gets start script parameter (see startscript)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "scan0script \t gets script to launch at level 0 scan. If \"energy\" energy scan, if \"threshold\" threshold scan, if \"trimbits\" trimbits scan, \"none\" unsets otherwise will be launched as a system call with arguments nrun=fileindex fn=filename var=scan0var par=scan0par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan0par \t gets the level 0 scan parameter. See scan0script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan0prec \t gets the level 0 scan precision for the output file name. See scan0script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan0steps \t gets the level 0 scan steps. See scan0script - nsteps=0 unsets the scan level"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "scan1script \t gets script to launch at level 1 scan. If \"energy\" energy scan, if \"threshold\" threshold scan, if \"trimbits\" trimbits scan, \"none\" unsets otherwise will be launched as a system call with arguments nrun=fileindex fn=filename var=scan1var par=scan1par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "scan1par \t gets the level 1 scan parameter. See scan1script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan1prec \t gets the level 1 scan precision for the output file name. See scan1script"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scan1steps \t gets the level 1 scan steps. See scan1script - nsteps=0 unsets the scan level"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "scriptbefore \t gets script to execute at the beginning of the realtime acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename par=scriptbeforepar sv0=scan0var sv1=scan1var p0=scan0par p1=scan1par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scriptbeforepar \t gets script before parameter (see scriptbefore)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "headerbefore \n gets the script to launch to acquire the headerfile just before the acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename acqtime=t gainmode=sett threshold=thr badfile=badf angfile=angf bloffset=bloffset fineoffset=fineoffset fffile=ffile tau=taucorr par=headerbeforepar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "headerbeforepar \t gets header before parameter (see headerbefore)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "headerafter \n gets the script to launch to acquire the headerfile just after the acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename acqtime=t gainmode=sett threshold=thr badfile=badf angfile=angf bloffset=bloffset fineoffset=fineoffset fffile=ffile tau=taucorr par=headerafterpar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "headerafterpar \t gets header after parameter (see headerafter)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
os << "scriptafter \t gets script to execute at the end of the realtime acquisition - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex fn=filename par=scriptafterpar sv0=scan0var sv1=scan1var p0=scan0par p1=scan1par"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "scriptafterpar \t gets script after parameter (see scriptafter)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
os << "stopscript \t gets script to execute at the end of the measurements - \"none\" to unset - will be launched as a system call with arguments nrun=fileindex par=stopscriptpar"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
os << "stopscriptpar\t gets stop script parameter (see stopscript)"<< std::endl;
|
||||||
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
os << "outdir \t directory to which the files will be written by default" << std::endl;
|
os << "outdir \t directory to which the files will be written by default" << std::endl;
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
os << "fname \t filename to which the files will be written by default (to which file and position indexes will eventually be attached)" << std::endl;
|
os << "fname \t filename to which the files will be written by default (to which file and position indexes will eventually be attached)" << std::endl;
|
||||||
@ -1564,7 +1899,7 @@ int mythenDetector::retrieveDetectorSetup(string fname1, int level){
|
|||||||
strcpy(thisDetector->trimFile,fname.c_str());
|
strcpy(thisDetector->trimFile,fname.c_str());
|
||||||
return myMod;
|
return myMod;
|
||||||
} else {
|
} else {
|
||||||
std::cout<< "could not open file " << myfname<< std::endl;
|
std::cout<< "could not open trim file " << myfname << std::endl;
|
||||||
if (nflag)
|
if (nflag)
|
||||||
deleteModule(myMod);
|
deleteModule(myMod);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1921,9 +2256,17 @@ int mythenDetector::setAngularConversion(string fname) {
|
|||||||
if (fname=="") {
|
if (fname=="") {
|
||||||
thisDetector->correctionMask&=~(1<< ANGULAR_CONVERSION);
|
thisDetector->correctionMask&=~(1<< ANGULAR_CONVERSION);
|
||||||
//strcpy(thisDetector->angConvFile,"none");
|
//strcpy(thisDetector->angConvFile,"none");
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
std::cout << "Unsetting angular conversion" << std::endl;
|
||||||
|
//#endif
|
||||||
} else {
|
} else {
|
||||||
if (fname=="default")
|
if (fname=="default") {
|
||||||
fname=string(thisDetector->angConvFile);
|
fname=string(thisDetector->angConvFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
std::cout << "Setting angular conversion to" << fname << std:: endl;
|
||||||
|
//#endif
|
||||||
if (readAngularConversion(fname)>=0) {
|
if (readAngularConversion(fname)>=0) {
|
||||||
thisDetector->correctionMask|=(1<< ANGULAR_CONVERSION);
|
thisDetector->correctionMask|=(1<< ANGULAR_CONVERSION);
|
||||||
strcpy(thisDetector->angConvFile,fname.c_str());
|
strcpy(thisDetector->angConvFile,fname.c_str());
|
||||||
@ -1932,6 +2275,12 @@ int mythenDetector::setAngularConversion(string fname) {
|
|||||||
return thisDetector->correctionMask&(1<< ANGULAR_CONVERSION);
|
return thisDetector->correctionMask&(1<< ANGULAR_CONVERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mythenDetector::getAngularConversion(int &direction, angleConversionConstant *angconv) {
|
int mythenDetector::getAngularConversion(int &direction, angleConversionConstant *angconv) {
|
||||||
direction=thisDetector->angDirection;
|
direction=thisDetector->angDirection;
|
||||||
if (angconv) {
|
if (angconv) {
|
||||||
@ -2064,7 +2413,6 @@ int mythenDetector::addToMerging(float *p1, float *v1, float *e1, float *mp, fl
|
|||||||
int ibin=0;
|
int ibin=0;
|
||||||
int imod;
|
int imod;
|
||||||
float ang=0;
|
float ang=0;
|
||||||
|
|
||||||
if (thisDetector->binSize>0)
|
if (thisDetector->binSize>0)
|
||||||
binsize=thisDetector->binSize;
|
binsize=thisDetector->binSize;
|
||||||
else
|
else
|
||||||
@ -2133,10 +2481,19 @@ int mythenDetector::addToMerging(float *p1, float *v1, float *e1, float *mp, fl
|
|||||||
|
|
||||||
void mythenDetector::acquire(int delflag){
|
void mythenDetector::acquire(int delflag){
|
||||||
void *status;
|
void *status;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
int iloop=0;
|
//int iloop=0;
|
||||||
#endif
|
//#endif
|
||||||
|
int trimbit;
|
||||||
|
int startindex=thisDetector->fileIndex;
|
||||||
|
int lastindex=startindex;
|
||||||
|
char cmd[MAX_STR_LENGTH];
|
||||||
|
//string sett;
|
||||||
|
|
||||||
thisDetector->progressIndex=0;
|
thisDetector->progressIndex=0;
|
||||||
|
thisDetector->stoppedFlag=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resetFinalDataQueue();
|
resetFinalDataQueue();
|
||||||
resetDataQueue();
|
resetDataQueue();
|
||||||
@ -2144,6 +2501,11 @@ void mythenDetector::acquire(int delflag){
|
|||||||
|
|
||||||
jointhread=0;
|
jointhread=0;
|
||||||
queuesize=0;
|
queuesize=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (thisDetector->threadedProcessing) {
|
if (thisDetector->threadedProcessing) {
|
||||||
startThread(delflag);
|
startThread(delflag);
|
||||||
}
|
}
|
||||||
@ -2152,75 +2514,269 @@ void mythenDetector::acquire(int delflag){
|
|||||||
if (thisDetector->numberOfPositions>0)
|
if (thisDetector->numberOfPositions>0)
|
||||||
np=thisDetector->numberOfPositions;
|
np=thisDetector->numberOfPositions;
|
||||||
|
|
||||||
currentPositionIndex=0;
|
int ns0=1;
|
||||||
|
if (thisDetector->actionMask & (1 << MAX_ACTIONS)) {
|
||||||
|
ns0=thisDetector->nScanSteps[0];
|
||||||
|
}
|
||||||
|
if (ns0<1)
|
||||||
|
ns0=1;
|
||||||
|
|
||||||
for (int ip=0; ip<np; ip++) {
|
|
||||||
if (thisDetector->numberOfPositions>0) {
|
int ns1=1;
|
||||||
go_to_position (thisDetector->detPositions[ip]);
|
if (thisDetector->actionMask & (1 << (MAX_ACTIONS+1))) {
|
||||||
currentPositionIndex=ip+1;
|
ns1=thisDetector->nScanSteps[1];
|
||||||
|
}
|
||||||
|
if (ns1<1)
|
||||||
|
ns1=1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//action at start
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->actionMask & (1 << startScript)) {
|
||||||
|
//"Custom start script. The arguments are passed as nrun=n par=p.");
|
||||||
|
sprintf(cmd,"%s nrun=%d par=%s",thisDetector->actionScript[startScript],thisDetector->fileIndex,thisDetector->actionParameter[startScript]);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "moving to position" << std::endl;
|
cout << "Executing start script " << cmd << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
system(cmd);
|
||||||
if (thisDetector->correctionMask&(1<< I0_NORMALIZATION))
|
}
|
||||||
currentI0=get_i0();
|
}
|
||||||
//write header before?
|
|
||||||
|
|
||||||
startAndReadAll();
|
for (int is0=0; is0<ns0; is0++) {//scan0 loop
|
||||||
|
|
||||||
//write header after?
|
if (thisDetector->stoppedFlag==0) {
|
||||||
if (thisDetector->correctionMask&(1<< I0_NORMALIZATION))
|
|
||||||
currentI0=get_i0();
|
|
||||||
if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION))
|
|
||||||
currentPosition=get_position();
|
|
||||||
|
|
||||||
|
|
||||||
if (thisDetector->threadedProcessing==0)
|
currentScanVariable[0]=thisDetector->scanSteps[0][is0];
|
||||||
processData(delflag);
|
|
||||||
|
switch(thisDetector->scanMode[0]) {
|
||||||
#ifdef ACQVERBOSE
|
case 1:
|
||||||
std::cout<< "--------------------------------------------------waiting to empty raw data queue " << queuesize << std::endl ;
|
setThresholdEnergy((int)currentScanVariable[0]); //energy scan
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
setDAC(currentScanVariable[0],THRESHOLD); // threshold scan
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
trimbit=(int)currentScanVariable[0];
|
||||||
|
setChannel((trimbit<<((int)TRIMBIT_OFF))|((int)COMPARATOR_ENABLE)); // trimbit scan
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
currentScanVariable[0]=0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//Custom scan script level 0. The arguments are passed as nrun=n fn=filename var=v par=p"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",thisDetector->scanScript[0],thisDetector->fileIndex,createFileName().c_str(),currentScanVariable[0],thisDetector->scanParameter[0]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing scan script 0 " << cmd << endl;
|
||||||
#endif
|
#endif
|
||||||
//while (!dataQueue.empty()){
|
system(cmd);
|
||||||
while (queuesize){
|
|
||||||
usleep(100);
|
|
||||||
// #ifdef VERBOSE
|
|
||||||
// if (iloop%10000==0)
|
|
||||||
// std::cout<< "--------------------------------------------------looping raw data queue " << queuesize << std::endl ;
|
|
||||||
// // //std::cout<< "--------------------------------------------------looping raw data queue " << dataQueue.size() << std::endl ;
|
|
||||||
// iloop++;
|
|
||||||
// //usleep(100000);
|
|
||||||
// #endif
|
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
for (int is1=0; is1<ns0; is1++) {//scan0 loop
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
|
||||||
|
currentScanVariable[1]=thisDetector->scanSteps[1][is1];
|
||||||
|
|
||||||
|
switch(thisDetector->scanMode[1]) {
|
||||||
|
case 1:
|
||||||
|
setThresholdEnergy((int)currentScanVariable[1]); //energy scan
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
setDAC(currentScanVariable[1],THRESHOLD); // threshold scan
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
trimbit=(int)currentScanVariable[1];
|
||||||
|
setChannel((trimbit<<((int)TRIMBIT_OFF))|((int)COMPARATOR_ENABLE)); // trimbit scan
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
currentScanVariable[1]=0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//Custom scan script level 1. The arguments are passed as nrun=n fn=filename var=v par=p"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",thisDetector->scanScript[1],thisDetector->fileIndex,createFileName().c_str(),currentScanVariable[1],thisDetector->scanParameter[1]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing scan script 1 " << cmd << endl;
|
||||||
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->actionMask & (1 << scriptBefore)) {
|
||||||
|
//Custom script before each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",thisDetector->actionScript[scriptBefore],thisDetector->fileIndex,createFileName().c_str(),thisDetector->actionParameter[scriptBefore],currentScanVariable[0],currentScanVariable[1],thisDetector->scanParameter[0],thisDetector->scanParameter[1]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing script before " << cmd << endl;
|
||||||
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
currentPositionIndex=0;
|
||||||
|
|
||||||
|
for (int ip=0; ip<np; ip++) {
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->numberOfPositions>0) {
|
||||||
|
go_to_position (thisDetector->detPositions[ip]);
|
||||||
|
currentPositionIndex=ip+1;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< "moving to position" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
//write header before?
|
||||||
|
//cmd=headerBeforeScript;
|
||||||
|
//Custom script to write the header. \n The arguments will be passed as nrun=n fn=filenam acqtime=t gainmode=g threshold=thr badfile=badf angfile=angf bloffset=blo fineoffset=fo fffile=fffn tau=deadtau par=p")
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->correctionMask&(1<< I0_NORMALIZATION))
|
||||||
|
currentI0=get_i0();
|
||||||
|
if (thisDetector->actionMask & (1 << headerBefore)) {
|
||||||
|
//Custom script after each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s acqtime=%f gainmode=%d threshold=%d badfile=%s angfile=%s bloffset=%f fineoffset=%f fffile=%s/%s tau=%f par=%s",thisDetector->actionScript[headerBefore],thisDetector->fileIndex,createFileName().c_str(),((float)thisDetector->timerValue[ACQUISITION_TIME])*1E-9, thisDetector->currentSettings, thisDetector->currentThresholdEV, getBadChannelCorrectionFile().c_str(), getAngularConversion().c_str(), thisDetector->globalOffset, thisDetector->fineOffset,getFlatFieldCorrectionDir(),getFlatFieldCorrectionFile(), getRateCorrectionTau(), thisDetector->actionParameter[headerBefore]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing header after " << cmd << endl;
|
||||||
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
startAndReadAll();
|
||||||
|
|
||||||
|
if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION))
|
||||||
|
currentPosition=get_position();
|
||||||
|
|
||||||
|
if (thisDetector->correctionMask&(1<< I0_NORMALIZATION))
|
||||||
|
currentI0=get_i0()-currentI0;
|
||||||
|
|
||||||
|
|
||||||
|
if (thisDetector->threadedProcessing==0)
|
||||||
|
processData(delflag);
|
||||||
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
//while (!dataQueue.empty()){
|
||||||
|
while (queuesize){
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "----------------------------------------------------raw data queue is empty!" << std::endl ;
|
if (thisDetector->fileIndex>lastindex)
|
||||||
|
lastindex=thisDetector->fileIndex;
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->actionMask & (1 << headerAfter)) {
|
||||||
|
//Custom script after each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s acqtime=%f gainmode=%d threshold=%d badfile=%s angfile=%s bloffset=%f fineoffset=%f fffile=%s/%s tau=%f par=%s", \
|
||||||
|
thisDetector->actionScript[headerAfter], \
|
||||||
|
thisDetector->fileIndex,\
|
||||||
|
createFileName().c_str(), \
|
||||||
|
((float)thisDetector->timerValue[ACQUISITION_TIME])*1E-9, \
|
||||||
|
thisDetector->currentSettings, \
|
||||||
|
thisDetector->currentThresholdEV, \
|
||||||
|
getBadChannelCorrectionFile().c_str(), \
|
||||||
|
getAngularConversion().c_str(), \
|
||||||
|
thisDetector->globalOffset, \
|
||||||
|
thisDetector->fineOffset, \
|
||||||
|
getFlatFieldCorrectionDir(), \
|
||||||
|
getFlatFieldCorrectionFile(), \
|
||||||
|
getRateCorrectionTau(), \
|
||||||
|
thisDetector->actionParameter[headerAfter]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing header after " << cmd << endl;
|
||||||
#endif
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (thisDetector->stoppedFlag) {
|
if (thisDetector->stoppedFlag) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "exiting since the detector has been stopped" << std::endl;
|
std::cout<< "exiting since the detector has been stopped" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (ip<(np-1))
|
} else if (ip<(np-1)) {
|
||||||
thisDetector->fileIndex=thisDetector->fileIndex-thisDetector->timerValue[FRAME_NUMBER];
|
thisDetector->fileIndex=startindex;
|
||||||
#ifdef VERBOSE
|
}
|
||||||
cout << "------------------------------------------------------Setting file index to " << thisDetector->fileIndex << endl;
|
} // loop on position finished
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ACQVERBOSE
|
//script after
|
||||||
std::cout<< "------------------------------------------------------cancelling data processing thread " << std::endl ;
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->actionMask & (1 << scriptAfter)) {
|
||||||
|
//Custom script after each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",thisDetector->actionScript[scriptAfter],thisDetector->fileIndex,createFileName().c_str(),thisDetector->actionParameter[scriptAfter],currentScanVariable[0],currentScanVariable[1],thisDetector->scanParameter[0],thisDetector->scanParameter[1]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing script after " << cmd << endl;
|
||||||
#endif
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< "exiting since the detector has been stopped" << std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
} else if (is1<(ns1-1)) {
|
||||||
|
thisDetector->fileIndex=startindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//end scan1 loop is1
|
||||||
|
//currentScanVariable[MAX_SCAN_LEVELS];
|
||||||
|
|
||||||
|
|
||||||
|
if (thisDetector->stoppedFlag) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< "exiting since the detector has been stopped" << std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
} else if (is0<(ns0-1)) {
|
||||||
|
thisDetector->fileIndex=startindex;
|
||||||
|
}
|
||||||
|
} //end scan0 loop is0
|
||||||
|
|
||||||
|
thisDetector->fileIndex=lastindex;
|
||||||
|
if (thisDetector->stoppedFlag==0) {
|
||||||
|
if (thisDetector->actionMask & (1 << stopScript)) {
|
||||||
|
//Custom stop script. The arguments are passed as nrun=n par=p.
|
||||||
|
sprintf(cmd,"%s nrun=%d par=%s",thisDetector->actionScript[stopScript],thisDetector->fileIndex,thisDetector->actionParameter[stopScript]);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing stop script " << cmd << endl;
|
||||||
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (thisDetector->threadedProcessing) {
|
if (thisDetector->threadedProcessing) {
|
||||||
jointhread=1;
|
jointhread=1;
|
||||||
pthread_join(dataProcessingThread, &status);
|
pthread_join(dataProcessingThread, &status);
|
||||||
|
|
||||||
/* while (pthread_cancel(dataProcessingThread)) {
|
|
||||||
;
|
|
||||||
}*/
|
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "----------------------------------------------------process canceled" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2240,21 +2796,11 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
int np;
|
int np;
|
||||||
detectorData *thisData;
|
detectorData *thisData;
|
||||||
int dum=1;
|
int dum=1;
|
||||||
// thisDetector->progressIndex=0;
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
int iloop=0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ACQVERBOSE
|
#ifdef ACQVERBOSE
|
||||||
std::cout<< " processing data - threaded mode " << thisDetector->threadedProcessing;
|
std::cout<< " processing data - threaded mode " << thisDetector->threadedProcessing;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,&outer_c_s );
|
|
||||||
//#ifdef VERBOSE
|
|
||||||
// std::cout<< "impossible to cancel process " << std::endl;
|
|
||||||
//#endif
|
|
||||||
// pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &outer_c_s);
|
|
||||||
|
|
||||||
while(dum | thisDetector->threadedProcessing) { // ????????????????????????
|
while(dum | thisDetector->threadedProcessing) { // ????????????????????????
|
||||||
|
|
||||||
@ -2264,29 +2810,20 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
|
|
||||||
/** Pop data queue */
|
/** Pop data queue */
|
||||||
myData=dataQueue.front(); // get the data from the queue
|
myData=dataQueue.front(); // get the data from the queue
|
||||||
//dataQueue.pop(); //remove the data from the queue
|
|
||||||
if (myData) {
|
if (myData) {
|
||||||
//process data
|
//process data
|
||||||
/** decode data */
|
/** decode data */
|
||||||
fdata=decodeData(myData);
|
fdata=decodeData(myData);
|
||||||
|
|
||||||
//delete [] myData;
|
|
||||||
// myData=NULL;
|
|
||||||
/** write raw data file */
|
/** write raw data file */
|
||||||
if (thisDetector->correctionMask==0 && delflag==1) {
|
if (thisDetector->correctionMask==0 && delflag==1) {
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "------------------------------------no processing "<< delflag <<std::endl;
|
|
||||||
#endif
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "********************** no processing: writing file " << createFileName().append(".raw") << endl;
|
|
||||||
#endif
|
|
||||||
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
||||||
delete [] fdata;
|
delete [] fdata;
|
||||||
} else {
|
} else {
|
||||||
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "********************** if (thisDetector->correctionMask!=0 || delflag==0) { writing raw data file " << createFileName() <<" " << thisDetector->correctionMask<< " " << delflag << endl;
|
|
||||||
#endif
|
|
||||||
/** rate correction */
|
/** rate correction */
|
||||||
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
rcdata=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
rcdata=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
@ -2314,11 +2851,7 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION)) {
|
if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||||
|
|
||||||
/** angular conversion */
|
|
||||||
/** data merging */
|
|
||||||
// if (thisDetector->numberOfPositions) {
|
|
||||||
|
|
||||||
if (currentPositionIndex<=1) {
|
if (currentPositionIndex<=1) {
|
||||||
if (thisDetector->binSize>0)
|
if (thisDetector->binSize>0)
|
||||||
bs=thisDetector->binSize;
|
bs=thisDetector->binSize;
|
||||||
@ -2347,27 +2880,13 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (thisDetector->correctionMask!=0)
|
if (thisDetector->correctionMask!=0)
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "********************** writing dat data file if (thisDetector->correctionMask!=0) { " << createFileName() <<" " << thisDetector->correctionMask << endl;
|
|
||||||
#endif
|
|
||||||
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr,ang);
|
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr,ang);
|
||||||
|
|
||||||
|
|
||||||
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity);
|
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((currentPositionIndex==thisDetector->numberOfPositions) || (currentPositionIndex==0)) {
|
if ((currentPositionIndex==thisDetector->numberOfPositions) || (currentPositionIndex==0)) {
|
||||||
|
|
||||||
np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity);
|
np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity);
|
||||||
|
|
||||||
/** file writing */
|
/** file writing */
|
||||||
currentPositionIndex++;
|
currentPositionIndex++;
|
||||||
if (thisDetector->correctionMask!=0)
|
if (thisDetector->correctionMask!=0)
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "********************** writing dat data file if ((currentPositionIndex==thisDetector->numberOfPositions) || (currentPositionIndex==0))" << createFileName() << endl;
|
|
||||||
#endif
|
|
||||||
writeDataFile (createFileName().append(".dat"),mergingCounts, mergingErrors, mergingBins,'f',np);
|
writeDataFile (createFileName().append(".dat"),mergingCounts, mergingErrors, mergingBins,'f',np);
|
||||||
if (delflag) {
|
if (delflag) {
|
||||||
delete [] mergingBins;
|
delete [] mergingBins;
|
||||||
@ -2381,9 +2900,6 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,thisDetector->progressIndex+1,(createFileName().append(".raw")).c_str(),np);
|
thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,thisDetector->progressIndex+1,(createFileName().append(".raw")).c_str(),np);
|
||||||
|
|
||||||
finalDataQueue.push(thisData);
|
finalDataQueue.push(thisData);
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "------------------------------------pushing final data queue " << finalDataQueue.size() << " " << createFileName() << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2393,13 +2909,9 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
delete [] ffcerr;
|
delete [] ffcerr;
|
||||||
if (ang)
|
if (ang)
|
||||||
delete [] ang;
|
delete [] ang;
|
||||||
//}
|
|
||||||
} else {
|
} else {
|
||||||
if (thisDetector->correctionMask!=0) {
|
if (thisDetector->correctionMask!=0) {
|
||||||
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr);
|
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr);
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "********************** if (thisDetector->correctionMask!=0) writing dat data file " << createFileName() << endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (delflag) {
|
if (delflag) {
|
||||||
if (ffcdata)
|
if (ffcdata)
|
||||||
@ -2411,58 +2923,26 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
} else {
|
} else {
|
||||||
if (thisDetector->correctionMask!=0) {
|
if (thisDetector->correctionMask!=0) {
|
||||||
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".dat")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".dat")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
||||||
} else {
|
} else {
|
||||||
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".raw")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".raw")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
||||||
}
|
}
|
||||||
finalDataQueue.push(thisData);
|
finalDataQueue.push(thisData);
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout<< "------------------------------------pushing final data queue with " << createFileName() << " " <<finalDataQueue.size() << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thisDetector->fileIndex++;
|
thisDetector->fileIndex++;
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "setting file index to "<< thisDetector->fileIndex << endl;
|
|
||||||
#endif
|
|
||||||
thisDetector->progressIndex++;
|
thisDetector->progressIndex++;
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "------------------------------------raw data queueto be popped " << dataQueue.size() << " empty " << !dataQueue.empty() << std::endl;
|
|
||||||
#endif
|
|
||||||
delete [] myData;
|
delete [] myData;
|
||||||
myData=NULL;
|
myData=NULL;
|
||||||
dataQueue.pop(); //remove the data from the queue
|
dataQueue.pop(); //remove the data from the queue
|
||||||
queuesize=dataQueue.size();
|
queuesize=dataQueue.size();
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "------------------------------------raw data queue popped " << dataQueue.size() << " var " << queuesize << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
else
|
|
||||||
std::cout<< "could not pop data queue " << std::endl;
|
|
||||||
#endif
|
|
||||||
//#ifdef VERBOSE
|
|
||||||
// std::cout<< "possible to cancel process " << std::endl;
|
|
||||||
//#endif
|
|
||||||
// pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &outer_c_s);
|
|
||||||
// pthread_testcancel();
|
|
||||||
}
|
}
|
||||||
|
if (jointhread) {
|
||||||
// #ifdef VERBOSE
|
if (dataQueue.size()==0)
|
||||||
// if (iloop%10000==0)
|
break;
|
||||||
// std::cout<< "------------------------------------process idle " << dataQueue.size() << " empty " << !dataQueue.empty() << std::endl;
|
}
|
||||||
// iloop++;
|
dum=0;
|
||||||
// #endif
|
|
||||||
|
|
||||||
|
|
||||||
if (jointhread) {
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout<< "acquisition finished " << dataQueue.size() << " empty " << !dataQueue.empty() << "final data queue size: " << finalDataQueue.size() <<std::endl;
|
|
||||||
#endif
|
|
||||||
if (dataQueue.size()==0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dum=0;
|
|
||||||
} // ????????????????????????
|
} // ????????????????????????
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -241,6 +241,30 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->binSize=0;
|
thisDetector->binSize=0;
|
||||||
thisDetector->stoppedFlag=0;
|
thisDetector->stoppedFlag=0;
|
||||||
|
|
||||||
|
thisDetector->actionMask=0;
|
||||||
|
|
||||||
|
|
||||||
|
for (int ia=0; ia<MAX_ACTIONS; ia++) {
|
||||||
|
thisDetector->actionMode[ia]=0;
|
||||||
|
strcpy(thisDetector->actionScript[ia],"none");
|
||||||
|
strcpy(thisDetector->actionParameter[ia],"none");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (int iscan=0; iscan<MAX_SCAN_LEVELS; iscan++) {
|
||||||
|
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
strcpy(thisDetector->scanScript[iscan],"none");
|
||||||
|
strcpy(thisDetector->scanParameter[iscan],"none");
|
||||||
|
thisDetector->nScanSteps[iscan]=0;
|
||||||
|
thisDetector->scanPrecision[iscan]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** calculates the memory offsets for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */
|
/** calculates the memory offsets for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */
|
||||||
@ -627,11 +651,27 @@ string slsDetector::createFileName() {
|
|||||||
/*directory name +root file name */
|
/*directory name +root file name */
|
||||||
osfn << thisDetector->filePath << "/" << thisDetector->fileName;
|
osfn << thisDetector->filePath << "/" << thisDetector->fileName;
|
||||||
|
|
||||||
|
// scan level 0
|
||||||
|
if (thisDetector->actionMask & (1 << (MAX_ACTIONS)))
|
||||||
|
osfn << "_S" << fixed << setprecision(thisDetector->scanPrecision[0]) << currentScanVariable[0];
|
||||||
|
|
||||||
|
//scan level 1
|
||||||
|
if (thisDetector->actionMask & (1 << (MAX_ACTIONS+1)))
|
||||||
|
osfn << "_s" << fixed << setprecision(thisDetector->scanPrecision[1]) << currentScanVariable[1];
|
||||||
|
|
||||||
|
|
||||||
|
//position
|
||||||
if (currentPositionIndex>0 && currentPositionIndex<=thisDetector->numberOfPositions)
|
if (currentPositionIndex>0 && currentPositionIndex<=thisDetector->numberOfPositions)
|
||||||
osfn << "_p" << currentPositionIndex;
|
osfn << "_p" << currentPositionIndex;
|
||||||
|
|
||||||
|
// file index
|
||||||
osfn << "_" << thisDetector->fileIndex;
|
osfn << "_" << thisDetector->fileIndex;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "created file name " << osfn.str() << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return osfn.str();
|
return osfn.str();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3094,11 +3134,11 @@ int slsDetector::setFlatFieldCorrection(string fname){
|
|||||||
fillBadChannelMask();
|
fillBadChannelMask();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::cout<< "Flat field data from file " << fname << " are not valid " << std::endl;
|
std::cout<< "Flat field data from file " << fname << " are not valid (" << nmed << "///" << xmed[nmed/2] << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cout<< "Flat field from file " << fname << " is not valid " << std::endl;
|
std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3216,6 +3256,27 @@ int slsDetector::getRateCorrection(float &t){
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float slsDetector::getRateCorrectionTau(){
|
||||||
|
|
||||||
|
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< "Rate correction is enabled with dead time "<< thisDetector->tDead << std::endl;
|
||||||
|
#endif
|
||||||
|
return thisDetector->tDead;
|
||||||
|
//return 1;
|
||||||
|
} else
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< "Rate correction is disabled " << std::endl;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::getRateCorrection(){
|
int slsDetector::getRateCorrection(){
|
||||||
|
|
||||||
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
@ -3428,6 +3489,392 @@ int slsDetector::exitServer(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
set action
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||||
|
\param fname for script ("" disable but leaves script unchanged, "none" disables and overwrites)
|
||||||
|
\returns 0 if action disabled, >0 otherwise
|
||||||
|
*/
|
||||||
|
int slsDetector::setAction(int iaction, string fname, string par) {
|
||||||
|
|
||||||
|
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||||
|
|
||||||
|
if (fname=="") {
|
||||||
|
thisDetector->actionMode[iaction]=0;
|
||||||
|
} else if (fname=="none") {
|
||||||
|
thisDetector->actionMode[iaction]=0;
|
||||||
|
strcpy(thisDetector->actionScript[iaction],fname.c_str());
|
||||||
|
} else {
|
||||||
|
strcpy(thisDetector->actionScript[iaction],fname.c_str());
|
||||||
|
thisDetector->actionMode[iaction]=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (par!="") {
|
||||||
|
strcpy(thisDetector->actionParameter[iaction],par.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisDetector->actionMode[iaction]) {
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << iaction << " " << hex << (1 << iaction) << " " << thisDetector->actionMask << dec;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
thisDetector->actionMask |= (1 << iaction);
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << " set " << hex << thisDetector->actionMask << dec << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} else {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << iaction << " " << hex << thisDetector->actionMask << dec;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
thisDetector->actionMask &= ~(1 << iaction);
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << " unset " << hex << thisDetector->actionMask << dec << endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << iaction << " Action mask set to " << hex << thisDetector->actionMask << dec << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return thisDetector->actionMode[iaction];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setActionScript(int iaction, string fname) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
return setAction(iaction,fname,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setActionParameter(int iaction, string par) {
|
||||||
|
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||||
|
|
||||||
|
if (par!="") {
|
||||||
|
strcpy(thisDetector->actionParameter[iaction],par.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisDetector->actionMode[iaction]) {
|
||||||
|
thisDetector->actionMask |= (1 << iaction);
|
||||||
|
} else {
|
||||||
|
thisDetector->actionMask &= ~(1 << iaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
return thisDetector->actionMode[iaction];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns action script
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
|
\returns action script
|
||||||
|
*/
|
||||||
|
string slsDetector::getActionScript(int iaction){
|
||||||
|
if (iaction>=0 && iaction<MAX_ACTIONS)
|
||||||
|
return string(thisDetector->actionScript[iaction]);
|
||||||
|
else
|
||||||
|
return string("wrong index");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns action parameter
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
|
\returns action parameter
|
||||||
|
*/
|
||||||
|
string slsDetector::getActionParameter(int iaction){
|
||||||
|
if (iaction>=0 && iaction<MAX_ACTIONS)
|
||||||
|
return string(thisDetector->actionParameter[iaction]);
|
||||||
|
else
|
||||||
|
return string("wrong index");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns action mode
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
|
\returns action mode
|
||||||
|
*/
|
||||||
|
int slsDetector::getActionMode(int iaction){
|
||||||
|
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "slsDetetctor : action " << iaction << " mode is " << thisDetector->actionMode[iaction] << endl;
|
||||||
|
#endif
|
||||||
|
return thisDetector->actionMode[iaction];
|
||||||
|
} else {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "slsDetetctor : wrong action index " << iaction << endl;
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
set scan
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param fname for script ("" disable)
|
||||||
|
\returns 0 if scan disabled, >0 otherwise
|
||||||
|
*/
|
||||||
|
int slsDetector::setScan(int iscan, string script, int nvalues, float *values, string par, int precision) {
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
|
||||||
|
if (script=="") {
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
} else {
|
||||||
|
strcpy(thisDetector->scanScript[iscan],script.c_str());
|
||||||
|
if (script=="none") {
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
} else if (script=="energy") {
|
||||||
|
thisDetector->scanMode[iscan]=1;
|
||||||
|
} else if (script=="threshold") {
|
||||||
|
thisDetector->scanMode[iscan]=2;
|
||||||
|
} else if (script=="trimbits") {
|
||||||
|
thisDetector->scanMode[iscan]=3;
|
||||||
|
} else {
|
||||||
|
thisDetector->scanMode[iscan]=4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (par!="")
|
||||||
|
strcpy(thisDetector->scanParameter[iscan],par.c_str());
|
||||||
|
|
||||||
|
if (nvalues>=0) {
|
||||||
|
if (nvalues==0)
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
else {
|
||||||
|
thisDetector->nScanSteps[iscan]=nvalues;
|
||||||
|
if (nvalues>MAX_SCAN_STEPS)
|
||||||
|
thisDetector->nScanSteps[iscan]=MAX_SCAN_STEPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values) {
|
||||||
|
for (int iv=0; iv<thisDetector->nScanSteps[iscan]; iv++) {
|
||||||
|
thisDetector->scanSteps[iscan][iv]=values[iv];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (precision>=0)
|
||||||
|
thisDetector->scanPrecision[iscan]=precision;
|
||||||
|
|
||||||
|
if (thisDetector->scanMode[iscan]>0){
|
||||||
|
thisDetector->actionMask |= 1 >> (iscan+MAX_ACTIONS);
|
||||||
|
} else {
|
||||||
|
thisDetector->actionMask &= ~(1 >> (iscan+MAX_ACTIONS));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return thisDetector->scanMode[iscan];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int slsDetector::setScanScript(int iscan, string script) {
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
if (script=="") {
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
} else {
|
||||||
|
strcpy(thisDetector->scanScript[iscan],script.c_str());
|
||||||
|
if (script=="none") {
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
} else if (script=="energy") {
|
||||||
|
thisDetector->scanMode[iscan]=1;
|
||||||
|
} else if (script=="threshold") {
|
||||||
|
thisDetector->scanMode[iscan]=2;
|
||||||
|
} else if (script=="trimbits") {
|
||||||
|
thisDetector->scanMode[iscan]=3;
|
||||||
|
} else {
|
||||||
|
thisDetector->scanMode[iscan]=4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisDetector->scanMode[iscan]>0){
|
||||||
|
thisDetector->actionMask |= (1 << (iscan+MAX_ACTIONS));
|
||||||
|
} else {
|
||||||
|
thisDetector->actionMask &= ~(1 << (iscan+MAX_ACTIONS));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return thisDetector->scanMode[iscan];
|
||||||
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setScanParameter(int iscan, string par) {
|
||||||
|
|
||||||
|
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
if (par!="")
|
||||||
|
strcpy(thisDetector->scanParameter[iscan],par.c_str());
|
||||||
|
return thisDetector->scanMode[iscan];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setScanPrecision(int iscan, int precision) {
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
if (precision>=0)
|
||||||
|
thisDetector->scanPrecision[iscan]=precision;
|
||||||
|
return thisDetector->scanMode[iscan];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int slsDetector::setScanSteps(int iscan, int nvalues, float *values) {
|
||||||
|
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
|
||||||
|
if (nvalues>=0) {
|
||||||
|
if (nvalues==0)
|
||||||
|
thisDetector->scanMode[iscan]=0;
|
||||||
|
else {
|
||||||
|
thisDetector->nScanSteps[iscan]=nvalues;
|
||||||
|
if (nvalues>MAX_SCAN_STEPS)
|
||||||
|
thisDetector->nScanSteps[iscan]=MAX_SCAN_STEPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values) {
|
||||||
|
for (int iv=0; iv<thisDetector->nScanSteps[iscan]; iv++) {
|
||||||
|
thisDetector->scanSteps[iscan][iv]=values[iv];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisDetector->scanMode[iscan]>0){
|
||||||
|
thisDetector->actionMask |= (1 << (iscan+MAX_ACTIONS));
|
||||||
|
} else {
|
||||||
|
thisDetector->actionMask &= ~(1 << (iscan+MAX_ACTIONS));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return thisDetector->scanMode[iscan];
|
||||||
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan script
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan script
|
||||||
|
*/
|
||||||
|
string slsDetector::getScanScript(int iscan){
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS)
|
||||||
|
return string(thisDetector->scanScript[iscan]);
|
||||||
|
else
|
||||||
|
return string("wrong index");
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan parameter
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan parameter
|
||||||
|
*/
|
||||||
|
string slsDetector::getScanParameter(int iscan){
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS)
|
||||||
|
return string(thisDetector->scanParameter[iscan]);
|
||||||
|
else
|
||||||
|
return string("wrong index");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan mode
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan mode
|
||||||
|
*/
|
||||||
|
int slsDetector::getScanMode(int iscan){
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS)
|
||||||
|
return thisDetector->scanMode[iscan];
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan steps
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\param v is the pointer to the scan steps
|
||||||
|
\returns scan steps
|
||||||
|
*/
|
||||||
|
int slsDetector::getScanSteps(int iscan, float *v) {
|
||||||
|
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
if (v) {
|
||||||
|
for (int iv=0; iv<thisDetector->nScanSteps[iscan]; iv++) {
|
||||||
|
v[iv]=thisDetector->scanSteps[iscan][iv];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thisDetector->nScanSteps[iscan];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::getScanPrecision(int iscan){
|
||||||
|
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||||
|
return thisDetector->scanPrecision[iscan];
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void slsDetector::startThread() {
|
void slsDetector::startThread() {
|
||||||
|
@ -28,6 +28,8 @@ extern "C" {
|
|||||||
#define MAX_ROIS 100
|
#define MAX_ROIS 100
|
||||||
#define MAX_BADCHANS 2000
|
#define MAX_BADCHANS 2000
|
||||||
#define MAXPOS 50
|
#define MAXPOS 50
|
||||||
|
#define MAX_SCAN_LEVELS 2
|
||||||
|
#define MAX_SCAN_STEPS 2000
|
||||||
|
|
||||||
#define NMODMAXX 24
|
#define NMODMAXX 24
|
||||||
#define NMODMAXY 24
|
#define NMODMAXY 24
|
||||||
@ -43,6 +45,9 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
data structure to hold the detector data after postprocessing (e.g. to plot, store in a root tree etc.)
|
data structure to hold the detector data after postprocessing (e.g. to plot, store in a root tree etc.)
|
||||||
*/
|
*/
|
||||||
@ -243,6 +248,7 @@ typedef struct sharedSlsDetector {
|
|||||||
/** readout flags */
|
/** readout flags */
|
||||||
readOutFlags roFlags;
|
readOutFlags roFlags;
|
||||||
|
|
||||||
|
|
||||||
/* detector setup - not needed */
|
/* detector setup - not needed */
|
||||||
/** name root of the output files */
|
/** name root of the output files */
|
||||||
char trimFile[MAX_STR_LENGTH];
|
char trimFile[MAX_STR_LENGTH];
|
||||||
@ -254,9 +260,28 @@ typedef struct sharedSlsDetector {
|
|||||||
int64_t timerValue[MAX_TIMERS];
|
int64_t timerValue[MAX_TIMERS];
|
||||||
/** clock divider */
|
/** clock divider */
|
||||||
//int clkDiv;
|
//int clkDiv;
|
||||||
|
|
||||||
|
|
||||||
|
/** Scans and scripts */
|
||||||
|
|
||||||
|
int actionMask;
|
||||||
|
|
||||||
|
int actionMode[MAX_ACTIONS];
|
||||||
|
char actionScript[MAX_ACTIONS][MAX_STR_LENGTH];
|
||||||
|
char actionParameter[MAX_ACTIONS][MAX_STR_LENGTH];
|
||||||
|
|
||||||
|
|
||||||
|
int scanMode[MAX_SCAN_LEVELS];
|
||||||
|
char scanScript[MAX_SCAN_LEVELS][MAX_STR_LENGTH];
|
||||||
|
char scanParameter[MAX_SCAN_LEVELS][MAX_STR_LENGTH];
|
||||||
|
int nScanSteps[MAX_SCAN_LEVELS];
|
||||||
|
float scanSteps[MAX_SCAN_LEVELS][MAX_SCAN_STEPS];
|
||||||
|
int scanPrecision[MAX_SCAN_LEVELS];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*offsets*/
|
/*offsets*/
|
||||||
/** memory offsets for the flat filed coefficients */
|
/** memory offsets for the flat field coefficients */
|
||||||
int ffoff;
|
int ffoff;
|
||||||
/** memory offsets for the flat filed coefficient errors */
|
/** memory offsets for the flat filed coefficient errors */
|
||||||
int fferroff;
|
int fferroff;
|
||||||
@ -1079,7 +1104,7 @@ s
|
|||||||
get flat field corrections file name
|
get flat field corrections file name
|
||||||
\returns flat field correction file name
|
\returns flat field correction file name
|
||||||
*/
|
*/
|
||||||
char *getFlatFieldCorrectionFile(){return thisDetector->flatFieldFile;};
|
char *getFlatFieldCorrectionFile(){ if (thisDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION)) return thisDetector->flatFieldFile; else return "none";};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set rate correction
|
set rate correction
|
||||||
@ -1094,8 +1119,14 @@ s
|
|||||||
\param t reference for dead time
|
\param t reference for dead time
|
||||||
\returns 0 if rate correction disabled, >0 otherwise
|
\returns 0 if rate correction disabled, >0 otherwise
|
||||||
*/
|
*/
|
||||||
int getRateCorrection(float &t);
|
int getRateCorrection(float &t);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
get rate correction tau
|
||||||
|
\returns 0 if rate correction disabled, otherwise the tau used for the correction
|
||||||
|
*/
|
||||||
|
float getRateCorrectionTau();
|
||||||
/**
|
/**
|
||||||
get rate correction
|
get rate correction
|
||||||
\returns 0 if rate correction disabled, >0 otherwise
|
\returns 0 if rate correction disabled, >0 otherwise
|
||||||
@ -1210,6 +1241,106 @@ s
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
set action
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||||
|
\param fname for script ("" disable)
|
||||||
|
\param par for script
|
||||||
|
\returns 0 if action disabled, >0 otherwise
|
||||||
|
*/
|
||||||
|
int setAction(int iaction, string fname="", string par="");
|
||||||
|
|
||||||
|
/**
|
||||||
|
set action
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||||
|
\param fname for script ("" disable)
|
||||||
|
\returns 0 if action disabled, >0 otherwise
|
||||||
|
*/
|
||||||
|
int setActionScript(int iaction, string fname="");
|
||||||
|
/**
|
||||||
|
set action
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||||
|
\param par for script ("" disable)
|
||||||
|
\returns 0 if action disabled, >0 otherwise
|
||||||
|
*/
|
||||||
|
int setActionParameter(int iaction, string par="");
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns action script
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
|
\returns action script
|
||||||
|
*/
|
||||||
|
string getActionScript(int iaction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns action parameter
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
|
\returns action parameter
|
||||||
|
*/
|
||||||
|
string getActionParameter(int iaction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns action mode
|
||||||
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
|
\returns action mode
|
||||||
|
*/
|
||||||
|
int getActionMode(int iaction);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
set scan
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param fname for script ("" disables, "none" disables and overwrites current)
|
||||||
|
\param nvalues number of steps (0 disables, -1 leaves current value)
|
||||||
|
\param values pointer to steps (if NULL leaves current values)
|
||||||
|
\param par parameter for the scan script ("" leaves unchanged)
|
||||||
|
\returns 0 is scan disabled, >0 otherwise
|
||||||
|
*/
|
||||||
|
int setScan(int index, string script="", int nvalues=-1, float *values=NULL, string par="", int precision=-1);
|
||||||
|
|
||||||
|
int setScanScript(int index, string script="");
|
||||||
|
int setScanParameter(int index, string par="");
|
||||||
|
int setScanPrecision(int index, int precision=-1);
|
||||||
|
int setScanSteps(int index, int nvalues=-1, float *values=NULL);
|
||||||
|
/**
|
||||||
|
returns scan script
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan script
|
||||||
|
*/
|
||||||
|
string getScanScript(int iscan);
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan parameter
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan parameter
|
||||||
|
*/
|
||||||
|
string getScanParameter(int iscan);
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan mode
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan mode
|
||||||
|
*/
|
||||||
|
int getScanMode(int iscan);
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan steps
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\param v is the pointer to the scan steps
|
||||||
|
\returns scan steps
|
||||||
|
*/
|
||||||
|
int getScanSteps(int iscan, float *v=NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns scan precision
|
||||||
|
\param iscan can be (0,1)
|
||||||
|
\returns scan precision
|
||||||
|
*/
|
||||||
|
int getScanPrecision(int iscan);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
decode data from the detector converting them to an array of floats, one for each channle
|
decode data from the detector converting them to an array of floats, one for each channle
|
||||||
@ -1407,6 +1538,20 @@ s
|
|||||||
*/
|
*/
|
||||||
float currentI0;
|
float currentI0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
current scan variable of the detector
|
||||||
|
*/
|
||||||
|
float currentScanVariable[MAX_SCAN_LEVELS];
|
||||||
|
|
||||||
|
/**
|
||||||
|
current scan variable index of the detector
|
||||||
|
*/
|
||||||
|
int currentScanIndex[MAX_SCAN_LEVELS];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** merging bins */
|
/** merging bins */
|
||||||
@ -1421,11 +1566,6 @@ s
|
|||||||
/** merging multiplicity */
|
/** merging multiplicity */
|
||||||
int *mergingMultiplicity;
|
int *mergingMultiplicity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** pointer to flat field coefficients */
|
/** pointer to flat field coefficients */
|
||||||
float *ffcoefficients;
|
float *ffcoefficients;
|
||||||
|
Reference in New Issue
Block a user