Commit f8e62a6a authored by Danny Hindson's avatar Danny Hindson Committed by Zhang, Chen
Browse files

Add overload to spectrumInfo::diffractometerConstants

Add overload that doesn't require the 2nd warning dets parameter
parent e4716c8b
......@@ -71,6 +71,8 @@ public:
std::tuple<double, double, double>
diffractometerConstants(const size_t index,
std::vector<detid_t> &uncalibratedDets) const;
std::tuple<double, double, double>
diffractometerConstants(const size_t index) const;
double difcUncalibrated(const size_t index) const;
bool hasDetectors(const size_t index) const;
bool hasUniqueDetector(const size_t index) const;
......
......@@ -1225,9 +1225,7 @@ void IFunction::convertValue(std::vector<double> &values, Kernel::Unit_sptr &out
efixed = 0.0;
emode = 0;
}
std::vector<int> emptyWarningVec;
auto [difa, difc, tzero] =
spectrumInfo.diffractometerConstants(wsIndex, emptyWarningVec);
auto [difa, difc, tzero] = spectrumInfo.diffractometerConstants(wsIndex);
std::vector<double> emptyVec;
Kernel::ExtraParametersMap pmap{
......
......@@ -173,6 +173,18 @@ SpectrumInfo::diffractometerConstants(const size_t index,
tzero / static_cast<double>(spectrumDefinition(index).size())};
}
/** Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors
* associated with this spectrum. Use calibrated values where possible, filling
* in with uncalibrated values where they're missing
* @param index Index of the spectrum that constants are required for
* @return tuple containing the average constants
*/
std::tuple<double, double, double>
SpectrumInfo::diffractometerConstants(const size_t index) const {
std::vector<int> warningDets;
return diffractometerConstants(index, warningDets);
}
/** Calculate average uncalibrated DIFC value of detectors associated with this
* spectrum
* @param index Index of the spectrum that DIFC is required for
......
......@@ -105,9 +105,7 @@ void ConvertSpectrumAxis::exec() {
l1val = l1;
efixed =
getEfixed(spectrumInfo.detector(i), inputWS, emode); // get efixed
std::vector<int> emptyWarningVec;
auto [difa, difc, tzero] =
spectrumInfo.diffractometerConstants(i, emptyWarningVec);
auto [difa, difc, tzero] = spectrumInfo.diffractometerConstants(i);
pmap = {{UnitConversionParameters::efixed, efixed},
{UnitConversionParameters::difa, difa},
{UnitConversionParameters::difc, difc},
......
......@@ -248,6 +248,7 @@ void BackgroundHelper::removeBackground(int nHist, HistogramX &x_data, Histogram
double twoTheta = m_spectrumInfo->twoTheta(nHist);
double L1 = m_spectrumInfo->l1();
double L2 = m_spectrumInfo->l2(nHist);
auto [difa, difc, tzero] = m_spectrumInfo->diffractometerConstants(nHist);
// get access to source workspace in case if target is different from source
auto &XValues = m_wkWS->x(nHist);
auto &YValues = m_wkWS->y(nHist);
......@@ -256,7 +257,10 @@ void BackgroundHelper::removeBackground(int nHist, HistogramX &x_data, Histogram
// use thread-specific unit conversion class to avoid multithreading issues
Kernel::Unit *unitConv = m_WSUnit[threadNum].get();
unitConv->initialize(L1, L2, twoTheta, m_Emode,
{{UnitConversionParameters::efixed, m_Efix}});
{{UnitConversionParameters::efixed, m_Efix},
{UnitConversionParameters::difa, difa},
{UnitConversionParameters::difc, difc},
{UnitConversionParameters::tzero, tzero}});
x_data[0] = XValues[0];
double tof1 = unitConv->singleToTOF(x_data[0]);
......
......@@ -295,9 +295,7 @@ void RemoveBins::calculateDetectorPosition(const int index, double &l1,
twoTheta = 0.0;
else
twoTheta = m_spectrumInfo->twoTheta(index);
std::vector<int> emptyWarningVec;
std::tie(difa, difc, tzero) =
m_spectrumInfo->diffractometerConstants(index, emptyWarningVec);
std::tie(difa, difc, tzero) = m_spectrumInfo->diffractometerConstants(index);
g_log.debug() << "Detector for index " << index << " has L1+L2=" << l1 + l2 << " & 2theta= " << twoTheta << '\n';
}
......
......@@ -80,9 +80,8 @@ SXPeak::SXPeak(double t, double phi, double intensity, const std::vector<int> &s
const auto l1 = spectrumInfo.l1();
const auto l2 = spectrumInfo.l2(m_wsIndex);
std::vector<int> warningDets;
const auto [difa, difc, tzero] =
spectrumInfo.diffractometerConstants(m_wsIndex, warningDets);
spectrumInfo.diffractometerConstants(m_wsIndex);
m_twoTheta = spectrumInfo.twoTheta(m_wsIndex);
m_LTotal = l1 + l2;
......
......@@ -328,9 +328,7 @@ void SaveGSS::generateBankHeader(std::stringstream &out, const API::SpectrumInfo
const auto l1 = spectrumInfo.l1();
const auto l2 = spectrumInfo.l2(specIndex);
const auto twoTheta = spectrumInfo.twoTheta(specIndex);
std::vector<detid_t> warnDetIds{};
auto [difa, difc, tzero] =
spectrumInfo.diffractometerConstants(specIndex, warnDetIds);
auto [difa, difc, tzero] = spectrumInfo.diffractometerConstants(specIndex);
out << "# Total flight path " << (l1 + l2) << "m, tth "
<< (twoTheta * 180. / M_PI) << "deg, DIFC " << difc << "\n";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment