changes for setting threshold without trimbits for eiger

This commit is contained in:
Dhanya Maliakal
2017-06-28 10:24:07 +02:00
parent ca358e4d17
commit c2980b3c44
17 changed files with 152 additions and 80 deletions

View File

@ -2980,7 +2980,7 @@ int slsDetector::setModule(int reg, int imod){
};
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval){
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval, int tb){
int fnum=F_SET_MODULE;
int retval;
@ -2997,6 +2997,11 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
//to exclude trimbits
if(!tb) {
module.nchan=0;
module.nchip=0;
}
sendModule(&module);
//not included in module
@ -3030,23 +3035,29 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
if (ret!=FAIL) {
if (detectorModules) {
if (imod>=0 && imod<thisDetector->nMod[X]*thisDetector->nMod[Y]) {
(detectorModules+imod)->nchan=module.nchan;
(detectorModules+imod)->nchip=module.nchip;
if(tb) {
(detectorModules+imod)->nchan=module.nchan;
(detectorModules+imod)->nchip=module.nchip;
}
(detectorModules+imod)->ndac=module.ndac;
(detectorModules+imod)->nadc=module.nadc;
thisDetector->nChips=module.nchip;
thisDetector->nChans=module.nchan/module.nchip;
if(tb) {
thisDetector->nChips=module.nchip;
thisDetector->nChans=module.nchan/module.nchip;
}
thisDetector->nDacs=module.ndac;
thisDetector->nAdcs=module.nadc;
if(thisDetector->myDetectorType != JUNGFRAU){
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
if (chipregs)
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
if(tb) {
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
if (chipregs)
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
if (chanregs) {
for (int i=0; i<thisDetector->nChans; i++) {
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
if (chanregs) {
for (int i=0; i<thisDetector->nChans; i++) {
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
}
}
}
}
@ -3277,11 +3288,11 @@ int slsDetector::getThresholdEnergy(int imod){
return thisDetector->currentThresholdEV;
};
int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings){
int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings, int tb){
//currently only for eiger
if (thisDetector->myDetectorType == EIGER) {
setThresholdEnergyAndSettings(e_eV,isettings);
setThresholdEnergyAndSettings(e_eV,isettings,tb);
return thisDetector->currentThresholdEV;
}
@ -3322,7 +3333,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings) {
int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb) {
//if settings provided, use that, else use the shared memory variable
detectorSettings is = ((isettings != GET_SETTINGS) ? isettings: thisDetector->currentSettings);
@ -3388,7 +3399,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
#endif
//read the files
myMod=createModule();
if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, iodelay, tau, myMod)) {
if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, iodelay, tau, myMod, tb)) {
if(myMod)deleteModule(myMod);
return FAIL;
}
@ -3423,13 +3434,13 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
int tau1 = -1; //not included in the module
int iodelay2 = -1; //not included in the module
int tau2 = -1; //not included in the module
if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, iodelay1, tau1, myMod1)) {
if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, iodelay1, tau1, myMod1, tb)) {
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
deleteModule(myMod1);
deleteModule(myMod2);
return FAIL;
}
if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, iodelay2, tau2, myMod2)) {
if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, iodelay2, tau2, myMod2, tb)) {
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
deleteModule(myMod1);
deleteModule(myMod2);
@ -3445,7 +3456,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
iodelay = iodelay1;
//interpolate module
myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, e_eV, trim1, trim2);
myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, e_eV, trim1, trim2, tb);
if (myMod == NULL) {
printf("Could not interpolate, different dac values in files\n");
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
@ -3461,7 +3472,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
myMod->module=0;
myMod->reg=thisDetector->currentSettings;
setModule(*myMod, iodelay, tau, e_eV, 0, 0);
setModule(*myMod, iodelay, tau, e_eV, 0, 0, tb);
deleteModule(myMod);
if (getSettings(-1) != is){
std::cout << "Could not set settings in detector" << endl;

View File

@ -965,10 +965,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\param e_eV threashold in eV (detector specific)
\param gainval pointer to extra gain values
\param offsetval pointer to extra offset values
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
\returns current register value
\sa ::sls_detector_module
*/
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0);
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0, int tb=1);
//virtual int setModule(sls_detector_module module);
/**
@ -999,17 +1000,19 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\param e_eV threshold in eV
\param imod module number (-1 all)
\param isettings ev. change settings
\param tb 1 to include trimbits, 0 to exclude
\returns current threshold value for imod in ev (-1 failed)
*/
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1);
/**
set threshold energy
\param e_eV threshold in eV
\param isettings ev. change settings
\param tb 1 to include trimbits, 0 to exclude
\returns OK if successful, else FAIL
*/
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings);
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb=1);
/**
get detector settings

View File

@ -207,7 +207,7 @@ class slsDetectorActions : public virtual slsDetectorBase
/* *\/ */
/* virtual detectorType getDetectorsType(int pos=-1)=0; */
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;

View File

@ -429,7 +429,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
int setTimingMode(int i=-1){return slsDetectorUsers::getTimingMode( externalCommunicationType( setExternalCommunicationMode(externalCommunicationType( slsDetectorUsers::getTimingMode(i) ) ) ) );};
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};

View File

@ -564,6 +564,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
descrToFuncMap[i].m_pFuncName="thresholdnotb"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
descrToFuncMap[i].m_pFuncName="trimbits"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
@ -3390,10 +3394,10 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
return myDet->getDetectorSettings(myDet->getSettings());
} else if (cmd=="threshold") {
if (action==PUT_ACTION) {
detectorType type = myDet->getDetectorsType();
if (!sscanf(args[1],"%d",&val)) {
return string("invalid threshold value");
}
detectorType type = myDet->getDetectorsType();
if (type != EIGER || (type == EIGER && narg<=2)) {
myDet->setThresholdEnergy(val);
} else {
@ -3405,6 +3409,25 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
}
sprintf(ans,"%d",myDet->getThresholdEnergy());
return string(ans);
} else if (cmd=="thresholdnotb") {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&val)) {
return string("invalid threshold value");
}
detectorType type = myDet->getDetectorsType();
if (type != EIGER)
return string("not implemented for this detector");
if (narg<=2) {
myDet->setThresholdEnergy(val, -1, GET_SETTINGS, 0);
} else {
detectorSettings sett= myDet->getDetectorSettings(string(args[2]));
if(sett == -1)
return string("invalid settings value");
myDet->setThresholdEnergy(val, -1, sett, 0);
}
}
sprintf(ans,"%d",myDet->getThresholdEnergy());
return string(ans);
} else if (cmd=="trimbits") {
if (narg>=2) {
string sval=string(args[1]);
@ -3487,7 +3510,8 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "settings s \n sets the settings of the detector - can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain"
"lownoise, dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"<< std::endl;
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett"<< std::endl;
os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl;
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
os << "trimval i \n sets all the trimbits to i" << std::endl;
@ -3497,6 +3521,7 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
if (action==GET_ACTION || action==HELP_ACTION) {
os << "settings \n gets the settings of the detector"<< std::endl;
os << "threshold V\n gets the detector threshold"<< std::endl;
os << "thresholdnotb V\n gets the detector threshold"<< std::endl;
os << "trimbits [fname]\n returns the trimfile loaded on the detector. If fname is specified the trimbits are saved to file. If no extension is specified, the serial number of each module will be attached."<< std::endl;
os << "trimval \n returns the value all trimbits are set to. If they are different, returns -1." << std::endl;
}

View File

@ -421,7 +421,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
// double* convertAngles(){return convertAngles(currentPosition);};
// virtual double* convertAngles(double pos)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
virtual double getRateCorrectionTau()=0;