mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 07:47:12 +02:00
added gain and offsets to the shared memory, that are sent along with sls_detector_module, only for eiger
This commit is contained in:
@ -47,7 +47,6 @@ int energyConversion::readCalibrationFile(string fname, double &gain, double &of
|
||||
int energyConversion::writeCalibrationFile(string fname, double gain, double offset){
|
||||
//std::cout<< "Function not yet implemented " << std::endl;
|
||||
ofstream outfile;
|
||||
|
||||
outfile.open (fname.c_str());
|
||||
|
||||
// >> i/o operations here <<
|
||||
@ -70,66 +69,62 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
|
||||
};
|
||||
|
||||
|
||||
int energyConversion::readCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType){
|
||||
int energyConversion::readCalibrationFile(string fname, int *gain, int *offset, detectorType myDetectorType){
|
||||
|
||||
|
||||
|
||||
string str;
|
||||
ifstream infile;
|
||||
double o,g;
|
||||
int ig=0;
|
||||
switch (myDetectorType) {
|
||||
case EIGER:
|
||||
string str;
|
||||
ifstream infile;
|
||||
double o,g;
|
||||
int ig=0;
|
||||
switch (myDetectorType) {
|
||||
case EIGER:
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Opening file "<< fname << std::endl;
|
||||
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);
|
||||
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;
|
||||
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.;
|
||||
istringstream ssstr(str);
|
||||
ssstr >> o >> g;
|
||||
offset[ig]=(int)(o*1000);
|
||||
gain[ig]=(int)(g*1000);
|
||||
// ig++;
|
||||
if (ig>=4)
|
||||
break;
|
||||
}
|
||||
infile.close();
|
||||
cout << "Calibration file loaded: " << fname << endl;
|
||||
} else {
|
||||
cout << "Could not open calibration file: "<< fname << std::endl;
|
||||
gain[0]=0;
|
||||
offset[0]=0;
|
||||
#ifndef MYROOT
|
||||
return FAIL;
|
||||
return FAIL;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#ifndef MYROOT
|
||||
return OK;
|
||||
return OK;
|
||||
#endif
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return readCalibrationFile(fname, *gain, *offset);
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int energyConversion::writeCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType){
|
||||
int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset, detectorType myDetectorType){
|
||||
//std::cout<< "Function not yet implemented " << std::endl;
|
||||
ofstream outfile;
|
||||
switch (myDetectorType) {
|
||||
@ -140,7 +135,7 @@ int energyConversion::writeCalibrationFile(string fname, double *gain, double *o
|
||||
// >> i/o operations here <<
|
||||
if (outfile.is_open()) {
|
||||
for (int ig=0; ig<4; ig++)
|
||||
outfile << offset[ig] << " " << gain[ig] << std::endl;
|
||||
outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl;
|
||||
} else {
|
||||
std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl;
|
||||
#ifndef MYROOT
|
||||
@ -156,7 +151,8 @@ int energyConversion::writeCalibrationFile(string fname, double *gain, double *o
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return writeCalibrationFile(fname, *gain, *offset);
|
||||
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user