reg for m3 is reserved only for gaincaps and not settings. Fixed in set threshold and setall threshold

This commit is contained in:
maliakal_d 2022-02-09 11:53:18 +01:00
parent 75f98b27a3
commit 2cf539c16e

View File

@ -214,9 +214,21 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
myMod.iodelay = myMod1.iodelay;
myMod.tau =
linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau);
// m3, reg is used for gaincaps
if (shm->detType == Mythen3) {
if (myMod1.reg != myMod2.reg) {
throw RuntimeError(
"setThresholdEnergyAndSettings: gaincaps do not "
"match between files");
}
myMod.reg = myMod1.reg;
}
}
// m3, reg is used for gaincaps
if (shm->detType != Mythen3) {
myMod.reg = isettings;
}
myMod.reg = isettings;
myMod.eV[0] = e_eV;
setModule(myMod, trimbits);
if (getSettings() != isettings) {
@ -231,6 +243,7 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
detectorSettings isettings, bool trimbits) {
// only mythen3
if (shm()->trimEnergies.empty()) {
throw RuntimeError(
"Trim energies have not been defined for this module yet!");
@ -311,6 +324,13 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
myMods[i] = interpolateTrim(&myMod1, &myMod2, energy[i], trim1,
trim2, trimbits);
// gaincaps
if (myMod1.reg != myMod2.reg) {
throw RuntimeError("setAllThresholdEnergy: gaincaps do not "
"match between files for energy (eV) " +
to_string(energy[i]));
}
myMods[i].reg = myMod1.reg;
}
}
@ -357,6 +377,11 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
for (int i = 0; i < myMod.nchan; ++i) {
myMod.chanregs[i] = myMods[i % 3].chanregs[i];
}
// gain caps
if (myMods[0].reg != myMods[1].reg || myMods[1].reg != myMods[2].reg) {
throw RuntimeError("setAllThresholdEnergy: gaincaps do not "
"match between files for all energies");
}
}
myMod.reg = isettings;
@ -3330,9 +3355,9 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
dacs_to_copy.end(),
{E_SVP, E_SVN, E_VTGSTV, E_RXB_RB, E_RXB_LB, E_VCN, E_VIS});
// interpolate vrf, vcmp, vcp
dacs_to_interpolate.insert(
dacs_to_interpolate.end(),
{E_VTR, E_VRF, E_VCMP_LL, E_VCMP_LR, E_VCMP_RL, E_VCMP_RR, E_VCP, E_VRS});
dacs_to_interpolate.insert(dacs_to_interpolate.end(),
{E_VTR, E_VRF, E_VCMP_LL, E_VCMP_LR,
E_VCMP_RL, E_VCMP_RR, E_VCP, E_VRS});
} else {
dacs_to_copy.insert(dacs_to_copy.end(),
{M_VCASSH, M_VRSHAPER, M_VRSHAPER_N, M_VIPRE_OUT,