changes for setting threshold without trimbits for eiger

This commit is contained in:
Dhanya Maliakal
2017-06-28 10:24:07 +02:00
parent ca358e4d17
commit c2980b3c44
17 changed files with 152 additions and 80 deletions

View File

@@ -138,7 +138,7 @@ int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset)
slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2){
slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb){
// only implemented for eiger currently (in terms of which dacs)
if(myDetectorType != EIGER) {
printf("Interpolation of Trim values not implemented for this detector!\n");
@@ -168,8 +168,10 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
}
//Interpolate all trimbits
for (int i = 0; i<myMod->nchan; i++)
myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]);
if(tb) {
for (int i = 0; i<myMod->nchan; i++)
myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]);
}
return myMod;
}
@@ -180,7 +182,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
/* I/O */
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod){
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod, int tb){
@@ -372,19 +374,21 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
infile.read((char*) myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
infile.read((char*)&iodelay,sizeof(iodelay));
infile.read((char*)&tau,sizeof(tau));
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
#ifdef VERBOSE
for(int i=0;i<myMod->ndac;i++)
std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl;
std::cout << "iodelay:" << iodelay << std::endl;
std::cout << "tau:" << tau << std::endl;
#endif
if(infile.eof()){
cout<<endl<<"Error, could not load trimbits end of file, "<<myfname<<", reached."<<endl<<endl;
if (nflag)
deleteModule(myMod);
if(tb) {
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
if(infile.eof()){
cout<<endl<<"Error, could not load trimbits end of file, "<<myfname<<", reached."<<endl<<endl;
if (nflag)
deleteModule(myMod);
return NULL;
return NULL;
}
}
infile.close();
strcpy(settingsFile,fname.c_str());

View File

@@ -88,9 +88,10 @@ class energyConversion
\param energy energy to trim at
\param e1 reference trim value
\param e2 reference trim value
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
\returns the pointer to the module structure with interpolated values or NULL if error
*/
sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2);
sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb=1);
@@ -103,10 +104,11 @@ class energyConversion
\param iodelay io delay (detector specific)
\param tau tau (detector specific)
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
\returns the pointer to myMod or NULL if reading the file failed
*/
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL);
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1);
/**
writes a trim/settings file