mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-21 15:18:53 +01:00
added function to read 4 energy calibration coefficients for eiger, comments on how to add them to the software
This commit is contained in:
@@ -591,13 +591,31 @@ unsigned int Feb_Control_GetNHalfModules(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Feb_Control_SetPhotonEnergy(unsigned int full_energy_eV){
|
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;
|
Feb_Control_photon_energy_eV = full_energy_eV;
|
||||||
printf("Setting photon energy to: %d eV\n",Feb_Control_photon_energy_eV);
|
printf("Setting photon energy to: %d eV\n",Feb_Control_photon_energy_eV);
|
||||||
|
|
||||||
return 1;
|
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){
|
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);
|
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);
|
||||||
|
|||||||
@@ -414,6 +414,7 @@ int setModule(sls_detector_module myMod){
|
|||||||
|
|
||||||
Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt);
|
Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt);
|
||||||
|
|
||||||
|
// use gain and offset!!!
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -910,7 +910,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t)
|
|||||||
nm=1; //modules/detector
|
nm=1; //modules/detector
|
||||||
nc=4*1; //chips
|
nc=4*1; //chips
|
||||||
nd=16; //dacs
|
nd=16; //dacs
|
||||||
na=0;
|
na=0; //use for gain????
|
||||||
break;
|
break;
|
||||||
case MOENCH:
|
case MOENCH:
|
||||||
nch=160*160;
|
nch=160*160;
|
||||||
@@ -3077,8 +3077,15 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << calfname << endl;
|
cout << calfname << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//reads calibration files here!
|
||||||
|
|
||||||
|
|
||||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||||
setModule(*myMod);
|
setModule(*myMod);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ostringstream ostfn,oscfn;
|
ostringstream ostfn,oscfn;
|
||||||
switch(thisDetector->myDetectorType){
|
switch(thisDetector->myDetectorType){
|
||||||
|
|||||||
@@ -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
|
#ifndef MYROOT
|
||||||
|
|
||||||
/* I/O */
|
/* I/O */
|
||||||
|
|
||||||
|
|
||||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){
|
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int nflag=0;
|
int nflag=0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,33 @@ class energyConversion
|
|||||||
*/
|
*/
|
||||||
static int writeCalibrationFile(string fname, double gain, double offset);
|
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
|
#ifndef MYROOT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user