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:
l_maliakal_d
2013-06-17 13:40:38 +00:00
parent 05b898b82c
commit a17e6f616d

View File

@ -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];
@ -2800,53 +2803,67 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
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){
case MOENCH:
case GOTTHARD:
minsettings = HIGHGAIN;
maxsettings = VERYHIGHGAIN;
break;
default:
minsettings = STANDARD;
maxsettings = HIGHGAIN;
}
if (isettings>=minsettings && isettings<=maxsettings) {
switch (isettings) { switch (isettings) {
case STANDARD: case STANDARD:
if ( (thisDetector->myDetectorType == MYTHEN) ||
(thisDetector->myDetectorType == EIGER)) {
ssettings="/standard"; ssettings="/standard";
thisDetector->currentSettings=STANDARD; thisDetector->currentSettings=STANDARD;
}
break; break;
case FAST: case FAST:
if (thisDetector->myDetectorType == MYTHEN) {
ssettings="/fast"; ssettings="/fast";
thisDetector->currentSettings=FAST; thisDetector->currentSettings=FAST;
}
break; break;
case HIGHGAIN: case HIGHGAIN:
if ( (thisDetector->myDetectorType == MYTHEN) ||
(thisDetector->myDetectorType == GOTTHARD) ||
(thisDetector->myDetectorType == EIGER)) {
ssettings="/highgain"; ssettings="/highgain";
thisDetector->currentSettings=HIGHGAIN; thisDetector->currentSettings=HIGHGAIN;
}
break; break;
case DYNAMICGAIN: case DYNAMICGAIN:
if (thisDetector->myDetectorType == GOTTHARD){
ssettings="/dynamicgain"; ssettings="/dynamicgain";
thisDetector->currentSettings=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; break;
case MEDIUMGAIN: case MEDIUMGAIN:
if (thisDetector->myDetectorType == GOTTHARD){
ssettings="/mediumgain"; ssettings="/mediumgain";
thisDetector->currentSettings=MEDIUMGAIN; thisDetector->currentSettings=MEDIUMGAIN;
}
break; break;
case VERYHIGHGAIN: case VERYHIGHGAIN:
if (thisDetector->myDetectorType == GOTTHARD){
ssettings="/veryhighgain"; ssettings="/veryhighgain";
thisDetector->currentSettings=VERYHIGHGAIN; thisDetector->currentSettings=VERYHIGHGAIN;
}
break;
case LOWNOISE:
if (thisDetector->myDetectorType == EIGER){
ssettings="/lownoise";
thisDetector->currentSettings=LOWNOISE;
}
break; break;
default: default:
std::cout<< "Unknown settings!" << std::endl; break;
} }
if (isettings != thisDetector->currentSettings) {
std::cout<< "Unknown settings for this detector!" << std::endl;
}else{
if (imod<0) { if (imod<0) {
modmi=0; modmi=0;
// modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y]; // modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y];
@ -2856,8 +2873,14 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
for (im=modmi; im<modma; im++) { for (im=modmi; im<modma; im++) {
ostringstream ostfn, oscfn; ostringstream ostfn, oscfn;
myMod->module=im; myMod->module=im;
//create file names //create file names
switch(thisDetector->myDetectorType){ 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 MOENCH:
case GOTTHARD: case GOTTHARD:
//settings is saved in myMod.reg for gotthard //settings is saved in myMod.reg for gotthard
@ -2872,6 +2895,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10); 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); oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
} }
settingsfname=ostfn.str(); settingsfname=ostfn.str();
#ifdef VERBOSE #ifdef VERBOSE
cout << "the settings name is "<<settingsfname << endl; cout << "the settings name is "<<settingsfname << endl;
@ -2892,6 +2916,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
break; break;
default: default:
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".trim"; ostfn << thisDetector->settingsDir << ssettings << ssettings << ".trim";
break;
} }
oscfn << thisDetector->calDir << ssettings << ssettings << ".cal"; oscfn << thisDetector->calDir << ssettings << ssettings << ".cal";
calfname=oscfn.str(); calfname=oscfn.str();
@ -2904,10 +2929,17 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
calfname=oscfn.str(); calfname=oscfn.str();
readCalibrationFile(calfname,myMod->gain, myMod->offset); readCalibrationFile(calfname,myMod->gain, myMod->offset);
setModule(*myMod); 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)) {
@ -2918,7 +2950,13 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
} }
} }
} }
return getSettings(imod);
if (getSettings(imod) != isettings){
std::cout << "Could not set settings" << endl;
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
}
return thisDetector->currentSettings;
}; };