mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 16:27:13 +02:00
settings file shud read and write according ot dac names and can be in any order, included eiger definitions
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@609 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -44,7 +44,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
|||||||
nd=13; // dacs+adcs
|
nd=13; // dacs+adcs
|
||||||
break;
|
break;
|
||||||
case EIGER:
|
case EIGER:
|
||||||
nch=65536; // one EIGER half module
|
nch=256*256; // one EIGER half module
|
||||||
nm=1; //modules/detector
|
nm=1; //modules/detector
|
||||||
nc=4; //chips
|
nc=4; //chips
|
||||||
nd=16; //dacs+adcs
|
nd=16; //dacs+adcs
|
||||||
@ -489,10 +489,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->myDetectorType=type;
|
thisDetector->myDetectorType=type;
|
||||||
switch(thisDetector->myDetectorType) {
|
switch(thisDetector->myDetectorType) {
|
||||||
case MYTHEN:
|
case MYTHEN:
|
||||||
thisDetector->nChans=128;
|
|
||||||
thisDetector->nChan[X]=128;
|
thisDetector->nChan[X]=128;
|
||||||
thisDetector->nChan[Y]=1;
|
thisDetector->nChan[Y]=1;
|
||||||
thisDetector->nChips=10;
|
|
||||||
thisDetector->nChip[X]=10;
|
thisDetector->nChip[X]=10;
|
||||||
thisDetector->nChip[Y]=1;
|
thisDetector->nChip[Y]=1;
|
||||||
thisDetector->nDacs=6;
|
thisDetector->nDacs=6;
|
||||||
@ -506,10 +504,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case PICASSO:
|
case PICASSO:
|
||||||
thisDetector->nChans=128;
|
|
||||||
thisDetector->nChan[X]=128;
|
thisDetector->nChan[X]=128;
|
||||||
thisDetector->nChan[Y]=1;
|
thisDetector->nChan[Y]=1;
|
||||||
thisDetector->nChips=12;
|
|
||||||
thisDetector->nChip[X]=12;
|
thisDetector->nChip[X]=12;
|
||||||
thisDetector->nChip[Y]=1;
|
thisDetector->nChip[Y]=1;
|
||||||
thisDetector->nDacs=6;
|
thisDetector->nDacs=6;
|
||||||
@ -519,10 +515,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->dynamicRange=24;
|
thisDetector->dynamicRange=24;
|
||||||
break;
|
break;
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
thisDetector->nChans=128;
|
|
||||||
thisDetector->nChan[X]=128;
|
thisDetector->nChan[X]=128;
|
||||||
thisDetector->nChan[Y]=1;
|
thisDetector->nChan[Y]=1;
|
||||||
thisDetector->nChips=10;
|
|
||||||
thisDetector->nChip[X]=10;
|
thisDetector->nChip[X]=10;
|
||||||
thisDetector->nChip[Y]=1;
|
thisDetector->nChip[Y]=1;
|
||||||
thisDetector->nDacs=8;
|
thisDetector->nDacs=8;
|
||||||
@ -532,10 +526,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->dynamicRange=16;
|
thisDetector->dynamicRange=16;
|
||||||
break;
|
break;
|
||||||
case MOENCH:
|
case MOENCH:
|
||||||
thisDetector->nChans=160*160;
|
|
||||||
thisDetector->nChan[X]=160;
|
thisDetector->nChan[X]=160;
|
||||||
thisDetector->nChan[Y]=160;
|
thisDetector->nChan[Y]=160;
|
||||||
thisDetector->nChips=1;
|
|
||||||
thisDetector->nChip[X]=1;
|
thisDetector->nChip[X]=1;
|
||||||
thisDetector->nChip[Y]=1;
|
thisDetector->nChip[Y]=1;
|
||||||
thisDetector->nDacs=8;
|
thisDetector->nDacs=8;
|
||||||
@ -544,11 +536,20 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->nModMax[Y]=1;
|
thisDetector->nModMax[Y]=1;
|
||||||
thisDetector->dynamicRange=16;
|
thisDetector->dynamicRange=16;
|
||||||
break;
|
break;
|
||||||
|
case EIGER:
|
||||||
|
thisDetector->nChan[X]=256;
|
||||||
|
thisDetector->nChan[Y]=256;
|
||||||
|
thisDetector->nChip[X]=4;
|
||||||
|
thisDetector->nChip[Y]=1;
|
||||||
|
thisDetector->nDacs=16;
|
||||||
|
thisDetector->nAdcs=1;
|
||||||
|
thisDetector->nModMax[X]=1;
|
||||||
|
thisDetector->nModMax[Y]=1;
|
||||||
|
thisDetector->dynamicRange=16;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
thisDetector->nChans=0;
|
|
||||||
thisDetector->nChan[X]=0;
|
thisDetector->nChan[X]=0;
|
||||||
thisDetector->nChan[Y]=0;
|
thisDetector->nChan[Y]=0;
|
||||||
thisDetector->nChips=0;
|
|
||||||
thisDetector->nChip[X]=0;
|
thisDetector->nChip[X]=0;
|
||||||
thisDetector->nChip[Y]=0;
|
thisDetector->nChip[Y]=0;
|
||||||
thisDetector->nDacs=0;
|
thisDetector->nDacs=0;
|
||||||
@ -557,6 +558,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->nModMax[Y]=0;
|
thisDetector->nModMax[Y]=0;
|
||||||
thisDetector->dynamicRange=32;
|
thisDetector->dynamicRange=32;
|
||||||
}
|
}
|
||||||
|
thisDetector->nChans=thisDetector->nChan[X]*thisDetector->nChan[Y];
|
||||||
|
thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y];
|
||||||
thisDetector->nModsMax=thisDetector->nModMax[0]*thisDetector->nModMax[1];
|
thisDetector->nModsMax=thisDetector->nModMax[0]*thisDetector->nModMax[1];
|
||||||
/** number of modules is initally the maximum number of modules */
|
/** number of modules is initally the maximum number of modules */
|
||||||
thisDetector->nMod[X]=thisDetector->nModMax[X];
|
thisDetector->nMod[X]=thisDetector->nModMax[X];
|
||||||
@ -2794,131 +2797,166 @@ slsDetectorDefs::detectorSettings slsDetector::getSettings(int imod){
|
|||||||
|
|
||||||
slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){
|
slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "slsDetector setSettings "<< std::endl;
|
std::cout<< "slsDetector setSettings "<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
sls_detector_module *myMod=createModule();
|
sls_detector_module *myMod=createModule();
|
||||||
int modmi=imod, modma=imod+1, im=imod;
|
int modmi=imod, modma=imod+1, im=imod;
|
||||||
string settingsfname, calfname;
|
string settingsfname, calfname;
|
||||||
string ssettings;
|
string ssettings;
|
||||||
detectorSettings minsettings, maxsettings;
|
|
||||||
|
|
||||||
switch(thisDetector->myDetectorType){
|
switch (isettings) {
|
||||||
case MOENCH:
|
case STANDARD:
|
||||||
case GOTTHARD:
|
if ( (thisDetector->myDetectorType == MYTHEN) ||
|
||||||
minsettings = HIGHGAIN;
|
(thisDetector->myDetectorType == EIGER)) {
|
||||||
maxsettings = VERYHIGHGAIN;
|
ssettings="/standard";
|
||||||
break;
|
thisDetector->currentSettings=STANDARD;
|
||||||
default:
|
}
|
||||||
minsettings = STANDARD;
|
break;
|
||||||
maxsettings = HIGHGAIN;
|
case FAST:
|
||||||
}
|
if (thisDetector->myDetectorType == MYTHEN) {
|
||||||
|
ssettings="/fast";
|
||||||
if (isettings>=minsettings && isettings<=maxsettings) {
|
thisDetector->currentSettings=FAST;
|
||||||
switch (isettings) {
|
}
|
||||||
case STANDARD:
|
break;
|
||||||
ssettings="/standard";
|
case HIGHGAIN:
|
||||||
thisDetector->currentSettings=STANDARD;
|
if ( (thisDetector->myDetectorType == MYTHEN) ||
|
||||||
break;
|
(thisDetector->myDetectorType == GOTTHARD) ||
|
||||||
case FAST:
|
(thisDetector->myDetectorType == EIGER)) {
|
||||||
ssettings="/fast";
|
ssettings="/highgain";
|
||||||
thisDetector->currentSettings=FAST;
|
thisDetector->currentSettings=HIGHGAIN;
|
||||||
break;
|
}
|
||||||
case HIGHGAIN:
|
break;
|
||||||
ssettings="/highgain";
|
case DYNAMICGAIN:
|
||||||
thisDetector->currentSettings=HIGHGAIN;
|
if (thisDetector->myDetectorType == GOTTHARD){
|
||||||
break;
|
ssettings="/dynamicgain";
|
||||||
case DYNAMICGAIN:
|
thisDetector->currentSettings=DYNAMICGAIN;
|
||||||
ssettings="/dynamicgain";
|
}
|
||||||
thisDetector->currentSettings=DYNAMICGAIN;
|
break;
|
||||||
break;
|
case LOWGAIN:
|
||||||
case LOWGAIN:
|
if (thisDetector->myDetectorType == GOTTHARD){
|
||||||
ssettings="/lowgain";
|
ssettings="/lowgain";
|
||||||
thisDetector->currentSettings=LOWGAIN;
|
thisDetector->currentSettings=LOWGAIN;
|
||||||
break;
|
}
|
||||||
case MEDIUMGAIN:
|
break;
|
||||||
ssettings="/mediumgain";
|
case MEDIUMGAIN:
|
||||||
thisDetector->currentSettings=MEDIUMGAIN;
|
if (thisDetector->myDetectorType == GOTTHARD){
|
||||||
break;
|
ssettings="/mediumgain";
|
||||||
case VERYHIGHGAIN:
|
thisDetector->currentSettings=MEDIUMGAIN;
|
||||||
ssettings="/veryhighgain";
|
}
|
||||||
thisDetector->currentSettings=VERYHIGHGAIN;
|
break;
|
||||||
break;
|
case VERYHIGHGAIN:
|
||||||
default:
|
if (thisDetector->myDetectorType == GOTTHARD){
|
||||||
std::cout<< "Unknown settings!" << std::endl;
|
ssettings="/veryhighgain";
|
||||||
}
|
thisDetector->currentSettings=VERYHIGHGAIN;
|
||||||
|
}
|
||||||
if (imod<0) {
|
break;
|
||||||
modmi=0;
|
case LOWNOISE:
|
||||||
// modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y];
|
if (thisDetector->myDetectorType == EIGER){
|
||||||
modma=thisDetector->nMod[X]*thisDetector->nMod[Y];
|
ssettings="/lownoise";
|
||||||
}
|
thisDetector->currentSettings=LOWNOISE;
|
||||||
|
}
|
||||||
for (im=modmi; im<modma; im++) {
|
break;
|
||||||
ostringstream ostfn, oscfn;
|
|
||||||
myMod->module=im;
|
|
||||||
//create file names
|
|
||||||
switch(thisDetector->myDetectorType){
|
|
||||||
case MOENCH:
|
|
||||||
case GOTTHARD:
|
|
||||||
//settings is saved in myMod.reg for gotthard
|
|
||||||
myMod->reg=thisDetector->currentSettings;
|
|
||||||
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
|
||||||
oscfn << thisDetector->calDir << ssettings << "/calibration.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
|
||||||
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
|
||||||
}
|
|
||||||
settingsfname=ostfn.str();
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "the settings name is "<<settingsfname << endl;
|
|
||||||
#endif
|
|
||||||
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
|
|
||||||
calfname=oscfn.str();
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << calfname << endl;
|
|
||||||
#endif
|
|
||||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
|
||||||
setModule(*myMod);
|
|
||||||
} else {
|
|
||||||
ostringstream ostfn,oscfn;
|
|
||||||
switch(thisDetector->myDetectorType){
|
|
||||||
case MOENCH:
|
|
||||||
case GOTTHARD:
|
|
||||||
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".settings";
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".trim";
|
break;
|
||||||
}
|
}
|
||||||
oscfn << thisDetector->calDir << ssettings << ssettings << ".cal";
|
|
||||||
calfname=oscfn.str();
|
|
||||||
settingsfname=ostfn.str();
|
if (isettings != thisDetector->currentSettings) {
|
||||||
|
std::cout<< "Unknown settings for this detector!" << std::endl;
|
||||||
|
}else{
|
||||||
|
if (imod<0) {
|
||||||
|
modmi=0;
|
||||||
|
// modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y];
|
||||||
|
modma=thisDetector->nMod[X]*thisDetector->nMod[Y];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (im=modmi; im<modma; im++) {
|
||||||
|
ostringstream ostfn, oscfn;
|
||||||
|
myMod->module=im;
|
||||||
|
|
||||||
|
//create file names
|
||||||
|
switch(thisDetector->myDetectorType){
|
||||||
|
case EIGER:
|
||||||
|
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
|
oscfn << thisDetector->calDir << ssettings << "/calibration.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
|
//add the trimbits binary file
|
||||||
|
break;
|
||||||
|
case MOENCH:
|
||||||
|
case GOTTHARD:
|
||||||
|
//settings is saved in myMod.reg for gotthard
|
||||||
|
myMod->reg=thisDetector->currentSettings;
|
||||||
|
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
|
oscfn << thisDetector->calDir << ssettings << "/calibration.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << settingsfname << endl;
|
std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl;
|
||||||
cout << calfname << endl;
|
|
||||||
#endif
|
#endif
|
||||||
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
|
break;
|
||||||
calfname=oscfn.str();
|
default:
|
||||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
setModule(*myMod);
|
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsfname=ostfn.str();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "the settings name is "<<settingsfname << endl;
|
||||||
|
#endif
|
||||||
|
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
|
||||||
|
calfname=oscfn.str();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << calfname << endl;
|
||||||
|
#endif
|
||||||
|
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||||
|
setModule(*myMod);
|
||||||
|
} else {
|
||||||
|
ostringstream ostfn,oscfn;
|
||||||
|
switch(thisDetector->myDetectorType){
|
||||||
|
case MOENCH:
|
||||||
|
case GOTTHARD:
|
||||||
|
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".settings";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".trim";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
oscfn << thisDetector->calDir << ssettings << ssettings << ".cal";
|
||||||
|
calfname=oscfn.str();
|
||||||
|
settingsfname=ostfn.str();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << settingsfname << endl;
|
||||||
|
cout << calfname << endl;
|
||||||
|
#endif
|
||||||
|
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
|
||||||
|
calfname=oscfn.str();
|
||||||
|
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||||
|
setModule(*myMod);
|
||||||
|
}else{
|
||||||
|
std::cout << "Could not set settings" << endl;
|
||||||
|
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
|
||||||
|
return thisDetector->currentSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deleteModule(myMod);
|
deleteModule(myMod);
|
||||||
switch(thisDetector->myDetectorType==MYTHEN){
|
switch(thisDetector->myDetectorType==MYTHEN){
|
||||||
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
int isett=getSettings(imod);
|
int isett=getSettings(imod);
|
||||||
double t[]=defaultTDead;
|
double t[]=defaultTDead;
|
||||||
if (isett>-1 && isett<3) {
|
if (isett>-1 && isett<3) {
|
||||||
thisDetector->tDead=t[isett];
|
thisDetector->tDead=t[isett];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getSettings(imod);
|
|
||||||
|
if (getSettings(imod) != isettings){
|
||||||
|
std::cout << "Could not set settings" << endl;
|
||||||
|
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
|
||||||
|
}
|
||||||
|
|
||||||
|
return thisDetector->currentSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user