added function to read 4 energy calibration coefficients for eiger, comments on how to add them to the software

This commit is contained in:
bergamaschi 2015-09-03 15:39:54 +02:00
parent 34a1dac0fe
commit 681ed0f34f
5 changed files with 152 additions and 3 deletions

View File

@ -591,13 +591,31 @@ unsigned int Feb_Control_GetNHalfModules(){
}
int Feb_Control_SetPhotonEnergy(unsigned int full_energy_eV){
/**
setDAC(VCMP_LL,val,imod,mV,retval);
setDAC(VCMP_LR,val,imod,mV,retval);
setDAC(VCMP_RL,val,imod,mV,retval);
ind = VCMP_RR;
*/
Feb_Control_photon_energy_eV = full_energy_eV;
printf("Setting photon energy to: %d eV\n",Feb_Control_photon_energy_eV);
return 1;
}
unsigned int Feb_Control_GetPhotonEnergy(){return Feb_Control_photon_energy_eV;}
unsigned int Feb_Control_GetPhotonEnergy(){
/**
setDAC(VCMP_LL,val,imod,mV,retval);
setDAC(VCMP_LR,val,imod,mV,retval);
setDAC(VCMP_RL,val,imod,mV,retval);
ind = VCMP_RR;
*/
return Feb_Control_photon_energy_eV;
}
int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units){
return Feb_Control_SetIDelays1(module_num,0,ndelay_units)&&Feb_Control_SetIDelays1(module_num,1,ndelay_units)&&Feb_Control_SetIDelays1(module_num,2,ndelay_units)&&Feb_Control_SetIDelays1(module_num,3,ndelay_units);

View File

@ -414,6 +414,7 @@ int setModule(sls_detector_module myMod){
Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt);
// use gain and offset!!!
return 0;
}

View File

@ -908,9 +908,9 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t)
case EIGER:
nch=256*256; // one EIGER half module
nm=1; //modules/detector
nc=4*1; //chips
nc=4*1; //chips
nd=16; //dacs
na=0;
na=0; //use for gain????
break;
case MOENCH:
nch=160*160;
@ -3077,8 +3077,15 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
#ifdef VERBOSE
cout << calfname << endl;
#endif
//reads calibration files here!
readCalibrationFile(calfname,myMod->gain, myMod->offset);
setModule(*myMod);
} else {
ostringstream ostfn,oscfn;
switch(thisDetector->myDetectorType){

View File

@ -70,12 +70,108 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
};
int energyConversion::readCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType){
string str;
ifstream infile;
double o,g;
int ig=0;
switch (myDetectorType) {
case EIGER:
#ifdef VERBOSE
std::cout<< "Opening file "<< fname << std::endl;
#endif
infile.open(fname.c_str(), ios_base::in);
if (infile.is_open()) {
for (ig=0; ig<4; ig++) {
//while ( (getline(infile,str)) > -1) {
getline(infile,str);
#ifdef VERBOSE
std::cout<< str << std::endl;
#endif
istringstream ssstr(str);
ssstr >> o >> g;
offset[ig]=o;
gain[ig]=g;
// ig++;
if (ig>=4)
break;
}
infile.close();
cout << "Calibration file loaded: " << fname << endl;
} else {
std::cout<< "Could not open calibration file "<< fname << std::endl;
gain[0]=0.;
offset[0]=0.;
#ifndef MYROOT
return FAIL;
#endif
return -1;
}
#ifndef MYROOT
return OK;
#endif
return 0;
break;
default:
return readCalibrationFile(fname, *gain, *offset);
}
};
int energyConversion::writeCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType){
//std::cout<< "Function not yet implemented " << std::endl;
ofstream outfile;
switch (myDetectorType) {
case EIGER:
outfile.open (fname.c_str());
// >> i/o operations here <<
if (outfile.is_open()) {
for (int ig=0; ig<4; ig++)
outfile << offset[ig] << " " << gain[ig] << std::endl;
} else {
std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl;
#ifndef MYROOT
return FAIL;
#endif
return -1;
}
outfile.close();
#ifndef MYROOT
return OK;
#endif
return 0;
break;
default:
return writeCalibrationFile(fname, *gain, *offset);
}
};
#ifndef MYROOT
/* I/O */
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){
int nflag=0;

View File

@ -45,6 +45,33 @@ class energyConversion
*/
static int writeCalibrationFile(string fname, double gain, double offset);
/**
reads a calibration file
\param fname file to be read
\param gain reference to the gain variable
\offset reference to the offset variable
*/
static int readCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType);
/**
writes a calibration file
\param fname file to be written
\param gain
\param offset
*/
static int writeCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType);
#ifndef MYROOT
/**