From 1069bf59795b9190003b593b9c1ca753d72e38d8 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 23 Apr 2018 13:31:05 +0200 Subject: [PATCH] esrf changes: slsDetector: fix setThresholdEnergy and slsDetectorAnalysis file read: * slsDetector: Proper cleanup and return when no interpolation is possible * slsDetectorAnalysis: treat CAL DAC as irrelevant when interpolating settings for two energies(do not abort if different), also including VRS in copying --- slsDetectorSoftware/slsDetector/slsDetector.cpp | 3 +++ .../slsDetectorAnalysis/energyConversion.cpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index e17f8cef6..e6a6875c0 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -3720,6 +3720,9 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti if (myMod == NULL) { printf("Could not interpolate, different dac values in files\n"); setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); + deleteModule(myMod1); + deleteModule(myMod2); + return FAIL; } //interpolate tau tau = linearInterpolation(e_eV, trim1, trim2, tau1, tau2); diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp index cb709058d..57ccbd14d 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp @@ -150,7 +150,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector //Copy other dacs int num_dacs_to_copy = 9; - int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,CAL,RXB_RB,RXB_LB,VCN,VIS}; + int dacs_to_copy[] = {SVP,VTR,VRS,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; for (int i = 0; i < num_dacs_to_copy; ++i) { if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { deleteModule(myMod); @@ -159,6 +159,16 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]]; } + + //Copy irrelevant dacs (without failing): CAL + if (a->dacs[CAL] != b->dacs[CAL]) { + printf("Warning: DAC CAL differs in both energies (%d, %d)! ", + a->dacs[CAL], b->dacs[CAL]); + printf("Taking first: %d\n", a->dacs[CAL]); + } + myMod->dacs[CAL] = a->dacs[CAL]; + + //Interpolate vrf, vcmp, vcp int num_dacs_to_interpolate = 7; int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS};