28static const std::array<std::tuple<Unit_sptr, bool>, 6> &displayUnits() {
29 static const std::array<std::tuple<Unit_sptr, bool>, 6> units = {
49 : m_workspace(
std::move(
workspace)), m_spectrumInfo(nullptr) {
55 const QMap<QString, QString> &)
const {
62 const auto wsIndex = yAxis->indexOfValue(
y);
63 const auto &spectrum =
m_workspace->getSpectrum(wsIndex);
64 if (yAxis->isSpectra()) {
82 }
catch (
const std::exception &exc) {
83 g_log.
debug() <<
"Unable to fill in instrument angle-related value: " << exc.what() <<
"\n";
98 const double x)
const {
104 if (
pmap.find(UnitParams::efixed) !=
pmap.end()) {
112 const auto tofUnit = unitFactory.create(
"TOF");
119 }
catch (std::exception &exc) {
121 if (
g_log.
is(Logger::Priority::PRIO_DEBUG))
122 g_log.
debug() <<
"Error calculating TOF from " <<
m_xunit->unitID() <<
": " << exc.what() <<
"\n";
126 for (
auto [unit, requiresEFixed] : displayUnits()) {
127 if (unit->unitID() ==
m_xunit->unitID())
129 if (!requiresEFixed ||
efixed > 0.0) {
132 const auto unitValue = unit->convertSingleFromTOF(tof, l1, emode,
pmap);
134 }
catch (std::exception &exc) {
135 if (
g_log.
is(Logger::Priority::PRIO_DEBUG))
136 g_log.
debug() <<
"Error calculating " << unit->unitID() <<
" from " <<
m_xunit->unitID() <<
": " << exc.what()
148 g_log.
debug(
"Updating cached workspace info");
154 g_log.
debug(
"No source on instrument in MatrixWorkspace");
159 g_log.
debug(
"No sample on instrument in MatrixWorkspace");
162 g_log.
debug(
"No instrument on MatrixWorkspace");
174 auto appendName = [
this](
const auto &name) {
m_names.emplace_back(name); };
175 auto shortUnitName = [](
const Unit &unit) {
176 const auto caption = unit.caption();
177 if (caption.rfind(
"-flight") != std::string::npos)
178 return QString(
"TOF");
179 else if (caption ==
"q")
180 return QString(
"|Q|");
182 return QString::fromStdString(caption);
184 auto appendUnit = [&appendName, &shortUnitName](
const auto &unit) {
185 QString name = shortUnitName(unit);
186 const auto unitLabel = unit.label().utf8();
187 if (!unitLabel.empty()) {
199 if (yaxis->isSpectra())
200 appendName(
"Spectrum");
201 else if (
auto yunit = yaxis->unit()) {
202 if (!yunit->caption().empty())
209 appendName(
"Signal");
210 appendName(
"Det ID");
212 appendName(
"TwoTheta(Deg)");
213 appendName(
"Azimuthal(Deg)");
216 auto appendUnitIfNotX = [
this, &appendUnit](
const auto &unit) {
217 if (unit.unitID() ==
m_xunit->unitID())
221 for (
const auto &unitInfo : displayUnits()) {
222 appendUnitIfNotX(*std::get<0>(unitInfo));
IPeaksWorkspace_sptr workspace
double signedTwoTheta(const size_t index) const
Returns the signed scattering angle 2 theta in radians (angle w.r.t.
bool hasDetectors(const size_t index) const
Returns true if the spectrum is associated with detectors in the instrument.
double l2(const size_t index) const
Returns L2 (distance from sample to spectrum).
double azimuthal(const size_t index) const
Returns the out-of-plane angle in radians (angle w.r.t.
double l1() const
Returns L1 (distance from source to sample).
void getDetectorValues(const Kernel::Unit &inputUnit, const Kernel::Unit &outputUnit, const Kernel::DeltaEMode::Type emode, const bool signedTheta, int64_t wsIndex, Kernel::UnitParametersMap &pmap) const
Get the detector values relevant to unit conversion for a workspace index.
The Logger class is in charge of the publishing messages from the framework through various channels.
void debug(const std::string &msg)
Logs at debug level.
bool is(int level) const
Returns true if at least the given log level is set.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
The base units (abstract) class.
QString toQStringInternal(const wchar_t *str)
Internal version of QString::fromStdWString.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
constexpr double rad2deg
Radians to degrees conversion factor.
std::unordered_map< UnitParams, double > UnitParametersMap
Generate a tableworkspace to store the calibration results.